Dotcms Dynamic Plugin with Filters

52 views
Skip to first unread message

gsuj...@gmail.com

unread,
Aug 22, 2017, 1:31:56 PM8/22/17
to dotCMS User Group
Hi,

I am developing a dynamic plugin in dotcms using Filters to check the form submissions . Once the form is submitted it is redirecting to the 404 page error instead returning to the form .

Can anyone help me in this scenario,will the chain.doFilter work in dynamic plugins .I have used the example filter plugin provided by the dotcms. Following is the 

code used in the activator


package com.dotmarketing.osgi.servlet;

import com.dotcms.repackage.org.apache.felix.http.api.ExtHttpService;
import com.dotcms.repackage.org.osgi.framework.BundleContext;
import com.dotcms.repackage.org.osgi.framework.ServiceReference;
import com.dotcms.repackage.org.osgi.util.tracker.ServiceTracker;
import com.dotmarketing.filters.CMSFilter;
import com.dotmarketing.osgi.GenericBundleActivator;
import com.dotmarketing.osgi.service.HelloWorld;

public class Activator extends GenericBundleActivator {

    private HelloWorldServlet simpleServlet;
    private ExtHttpService httpService;
    private ServiceTracker helloWorldServiceTracker;

    @SuppressWarnings ("unchecked")
    public void start ( BundleContext context ) throws Exception {

        //Initializing services...
        initializeServices( context );

        //Create new ServiceTracker for HelloWorldService via HelloWorld interface
        helloWorldServiceTracker = new ServiceTracker( context, HelloWorld.class.getName(), null );

        //Service reference to ExtHttpService that will allows to register servlets and filters
        ServiceReference sRef = context.getServiceReference( ExtHttpService.class.getName() );
        if ( sRef != null ) {

            helloWorldServiceTracker.addingService( sRef );
            httpService = (ExtHttpService) context.getService( sRef );
            try {
                //Registering a simple test servlet
                simpleServlet = new HelloWorldServlet( helloWorldServiceTracker );
                httpService.registerServlet( "/helloworld", simpleServlet, null, null );

                //Registering a simple test filter
                httpService.registerFilter( new TestFilter( "testFilter" ), "/helloworld/.*", null, 100, null );
            } catch ( Exception e ) {
                e.printStackTrace();
            }
        }

        CMSFilter.addExclude( "/app/helloworld" );

        // open service tracker to start tracking
        helloWorldServiceTracker.open();
    }

    public void stop ( BundleContext context ) throws Exception {

        //Unregister the servlet
        if ( httpService != null && simpleServlet != null ) {
            httpService.unregisterServlet( simpleServlet );
        }

        CMSFilter.removeExclude( "/app/helloworld" );

        // close service tracker to stop tracking
        helloWorldServiceTracker.close();
    }

}

Nathan Keiter

unread,
Aug 22, 2017, 1:34:09 PM8/22/17
to dot...@googlegroups.com

In the code are you actually performing a redirect or a forward?

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/58064e06-94ac-4875-aa00-ebd7cab3b9fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

gsuj...@gmail.com

unread,
Aug 22, 2017, 1:41:22 PM8/22/17
to dotCMS User Group
No, i am not sure how to do that? I tried to use dotcms example plugin "com.dotcms.servlet" as base project

gsuj...@gmail.com

unread,
Aug 22, 2017, 1:41:45 PM8/22/17
to dotCMS User Group
No, i am not sure how to do that? I tried to use dotcms example plugin "com.dotcms.servlet" as base project

Nathan Keiter

unread,
Aug 22, 2017, 1:41:48 PM8/22/17
to dot...@googlegroups.com
This should work:


filterChain.doFilter( httpServletRequest, httpServletResponse );


Sample use case:


[cid:0b79b87a-4738-4dcd-9ab9-84f40c7cc403]


Nathan I. Keiter | Lead Network Applications Programmer | Administrative Advisory Council Member | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
https://www.gettysburg.edu
________________________________
From: dot...@googlegroups.com <dot...@googlegroups.com> on behalf of Nathan Keiter <nke...@gettysburg.edu>
Sent: Tuesday, August 22, 2017 1:34 PM
To: dot...@googlegroups.com
Subject: RE: [dotcms] Dotcms Dynamic Plugin with Filters

In the code are you actually performing a redirect or a forward?

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
https://www.gettysburg.edu<https://www.gettysburg.edu/>
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To post to this group, send email to dot...@googlegroups.com<mailto:dot...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/58064e06-94ac-4875-aa00-ebd7cab3b9fe%40googlegroups.com<https://groups.google.com/d/msgid/dotcms/58064e06-94ac-4875-aa00-ebd7cab3b9fe%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To post to this group, send email to dot...@googlegroups.com<mailto:dot...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/b8d6ca7b85874dff94288cdf22c36166%40exch13c.ms.gettysburg.edu<https://groups.google.com/d/msgid/dotcms/b8d6ca7b85874dff94288cdf22c36166%40exch13c.ms.gettysburg.edu?utm_medium=email&utm_source=footer>.

gsuj...@gmail.com

unread,
Aug 22, 2017, 1:48:43 PM8/22/17
to dotCMS User Group
Can you send the Activator class used in the plugin ?? I am using this way in the doFilter Method

Logger.info(this, "Testing for bots");

ValidateForHoneypot validateForHoneyPot = new ValidateForHoneypot();

// Check for honeypot values
if (validateForHoneyPot.isHoneyPotPopulated(request)) {
System.out.println("Hello 5");
Logger.info(this, "Honeypot filter - BOT deteced ");
((HttpServletResponse) response).sendError(HttpServletResponse.SC_NOT_ACCEPTABLE,
"Some of the fields entered are not valid.");
return;
} else {
System.out.println("Hello 6");
// if its not a bot then check for duplicate submissions.
ValidateForDuplicateSubmissions checkDuplicate = new ValidateForDuplicateSubmissions();

if (checkDuplicate.isDuplicateSubmissionMade(request)) {
System.out.println("Hello 7");
Logger.info(this, "Duplicate submissions was made.");
((HttpServletResponse) response).sendError(HttpServletResponse.SC_CONFLICT,
"Duplicate Form Submission: Wait sometime before resubmitting the form.");
return;
}
}

// Forward the request on
chain.doFilter(request, response);

I have used the above code in the doFilter Method



On Tuesday, 22 August 2017 12:31:56 UTC-5, sujeeth kumar wrote:

Nathan Keiter

unread,
Aug 22, 2017, 1:54:51 PM8/22/17
to dot...@googlegroups.com
Sure, this is the 4.0.1 version of the plugin activator:


[cid:59e9d24b-0be9-441a-b254-f7f7eb52f7b3]

[cid:9861a97b-5745-4019-a973-93f9ef3b732b]


Nathan I. Keiter | Lead Network Applications Programmer | Administrative Advisory Council Member | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
https://www.gettysburg.edu
________________________________
From: dot...@googlegroups.com <dot...@googlegroups.com> on behalf of gsuj...@gmail.com <gsuj...@gmail.com>
Sent: Tuesday, August 22, 2017 1:48 PM
To: dotCMS User Group
Subject: [dotcms] Re: Dotcms Dynamic Plugin with Filters
--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To post to this group, send email to dot...@googlegroups.com<mailto:dot...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/ed5e36d3-f57e-45e0-a95f-73156a627f9a%40googlegroups.com<https://groups.google.com/d/msgid/dotcms/ed5e36d3-f57e-45e0-a95f-73156a627f9a%40googlegroups.com?utm_medium=email&utm_source=footer>.

Nathan Keiter

unread,
Aug 22, 2017, 1:57:54 PM8/22/17
to dot...@googlegroups.com
Looking at your code these might be the wrong object type:


chain.doFilter(request, response);


You could prepare them ahead of time, or cast them inline, but you need this class type I think:


HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse;


I could be wrong, but maybe try that?


Nathan I. Keiter | Lead Network Applications Programmer | Administrative Advisory Council Member | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
https://www.gettysburg.edu
________________________________
From: dot...@googlegroups.com <dot...@googlegroups.com> on behalf of gsuj...@gmail.com <gsuj...@gmail.com>
Sent: Tuesday, August 22, 2017 1:48 PM
To: dotCMS User Group
Subject: [dotcms] Re: Dotcms Dynamic Plugin with Filters

hpa...@gmail.com

unread,
Aug 22, 2017, 2:30:02 PM8/22/17
to dot...@googlegroups.com
No, i am not sure how to do that? I tried to use dotcms example plugin
"com.dotcms.servlet" as base project



--
View this message in context: http://forumarchive.dotcms.com/Dotcms-Dynamic-Plugin-with-Filters-tp5733751p5733753.html
Sent from the dotCMS Users Group mailing list archive at Nabble.com.

gsuj...@gmail.com

unread,
Aug 22, 2017, 2:30:59 PM8/22/17
to dotCMS User Group
I have added the same code as you have suggested but still it redirects to the 404 page .The following is the code added in the Activator Class

WebSecurityFilter websecuirtyFilter = new WebSecurityFilter();
                httpService.registerFilter(websecuirtyFilter, "/dotCMS/sendEmail", null, 0, null);         
                addRewriteRule("/dotCMS/sendEmail","/app/dotCMS/sendEmail","redirect", "WebSecurirtyFilter");
                System.out.println("adding rewrite rule....");

                

                NormalRule forwardRule = new NormalRule();
                forwardRule.setFrom( "/dotCMS/sendEmail" );
                forwardRule.setToType( "forward" );
                forwardRule.setTo( "/app/dotCMS/sendeEmail?browser=chrome" );
                forwardRule.setName( "WebSecurirtyFilter" );
                //Create a Condition for this rule
                Condition condition = new Condition();
                condition.setName( "user-agent" );
                condition.setValue( "Chrome/*.*" );
                forwardRule.addCondition( condition );

                //Register the tuckey rewrite rule
                addRewriteRule( forwardRule );


On Tuesday, 22 August 2017 12:31:56 UTC-5, sujeeth kumar wrote:

Nathan Keiter

unread,
Aug 22, 2017, 2:41:49 PM8/22/17
to dot...@googlegroups.com

Typo? "/app/dotCMS/sendeEmail”

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member


Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

 

From: dot...@googlegroups.com [mailto:dot...@googlegroups.com] On Behalf Of gsuj...@gmail.com
Sent: Tuesday, August 22, 2017 2:31 PM
To: dotCMS User Group
Subject: [dotcms] Re: Dotcms Dynamic Plugin with Filters

 

I have added the same code as you have suggested but still it redirects to the 404 page .The following is the code added in the Activator Class

--

http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.

To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/8d90e61b-9e70-4d0d-8d3b-13a323121cfc%40googlegroups.com.

gsuj...@gmail.com

unread,
Aug 22, 2017, 2:49:26 PM8/22/17
to dotCMS User Group
It is still redirecting to the 404 page .Is anything else wrong in the implimented logic of the plugin ?? 


On Tuesday, 22 August 2017 12:31:56 UTC-5, sujeeth kumar wrote:

Nathan Keiter

unread,
Aug 22, 2017, 2:56:19 PM8/22/17
to dot...@googlegroups.com

Add lots of debug code and write to the log.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: dot...@googlegroups.com [mailto:dot...@googlegroups.com] On Behalf Of gsuj...@gmail.com
Sent: Tuesday, August 22, 2017 2:49 PM
To: dotCMS User Group
Subject: [dotcms] Re: Dotcms Dynamic Plugin with Filters

 

It is still redirecting to the 404 page .Is anything else wrong in the implimented logic of the plugin ?? 

--

http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.

Nathan Keiter

unread,
Aug 22, 2017, 3:02:15 PM8/22/17
to dot...@googlegroups.com

Also, it looks like you tied a forward and a redirect to the same pattern?

 

That would conflict internally somewhere I’m thinking.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: dot...@googlegroups.com [mailto:dot...@googlegroups.com] On Behalf Of gsuj...@gmail.com
Sent: Tuesday, August 22, 2017 2:49 PM
To: dotCMS User Group
Subject: [dotcms] Re: Dotcms Dynamic Plugin with Filters

 

It is still redirecting to the 404 page .Is anything else wrong in the implimented logic of the plugin ?? 

--

gsuj...@gmail.com

unread,
Aug 22, 2017, 3:04:44 PM8/22/17
to dotCMS User Group
We rectified and tried it ,But still it redirects to the 404 page .Below mentioned is the Activator class code


package com.ehc.plugins.dynamic.websecurity.controller;

import com.dotcms.repackage.org.apache.felix.http.api.ExtHttpService;
import com.dotcms.repackage.org.osgi.framework.BundleContext;
import com.dotcms.repackage.org.osgi.framework.ServiceReference;
import com.dotcms.repackage.org.tuckey.web.filters.urlrewrite.Condition;
import com.dotcms.repackage.org.tuckey.web.filters.urlrewrite.NormalRule;
import com.dotmarketing.osgi.GenericBundleActivator;
import com.dotmarketing.util.Logger;

public class Activator extends GenericBundleActivator {

// private HelloWorldServlet simpleServlet;
private ExtHttpService httpService;

@SuppressWarnings("unchecked")
public void start(BundleContext context) throws Exception {

// Initializing services...
initializeServices(context);
Logger.info(this, "Latest Code Deployed ");
System.out.println("Latest Code Deployed ");
System.out
.println("******************************************************************************************");
System.out.println();
System.out.println();
System.out
.println("******************************************************************************************");
Logger.info(this, "Activator Start 1");

// Service reference to ExtHttpService that will allows to register
// servlets and filters
@SuppressWarnings("rawtypes")
ServiceReference sRef = context.getServiceReference(ExtHttpService.class.getName());
if (sRef != null) {
Logger.info(this, "Activator Start 2");
// helloWorldServiceTracker.addingService( sRef );
httpService = (ExtHttpService) context.getService(sRef);
try {
Logger.info(this, "Activator Start 3");
// Registering a simple test filter
System.out.println("Hello 2");
System.out.println();
WebSecurityFilter websecuirtyFilter = new WebSecurityFilter();
httpService.registerFilter(websecuirtyFilter, "/dotCMS/sendEmail", null, 0, null);
addRewriteRule("/dotCMS/sendEmail", "/app/dotCMS/sendEmail", "forward", "WebSecurirtyFilter");
System.out.println("adding rewrite rule....");

NormalRule forwardRule = new NormalRule();
forwardRule.setFrom("/dotCMS/sendEmail");
forwardRule.setToType("forward");
forwardRule.setTo("/app/dotCMS/sendeEmail?browser=chrome");
forwardRule.setName("WebSecurirtyFilter");
// Create a Condition for this rule
Condition condition = new Condition();
condition.setName("user-agent");
condition.setValue("Chrome/*.*");
forwardRule.addCondition(condition);

// Register the tuckey rewrite rule
addRewriteRule(forwardRule);

} catch (Exception e) {
Logger.info(this, "Activator Start 3");
System.out.println("Error Page Catch Block");
e.printStackTrace();
}
}

// open service tracker to start tracking
// helloWorldServiceTracker.open();
}

public void stop(BundleContext arg0) throws Exception {
// TODO Auto-generated method stub
unregisterRewriteRule();
}

}


On Tuesday, 22 August 2017 12:31:56 UTC-5, sujeeth kumar wrote:

Nathan Keiter

unread,
Aug 22, 2017, 3:11:21 PM8/22/17
to dot...@googlegroups.com

I still see /dotCMS/sendEmail as a “from” in both forwards.

 

Why two rules?

 

Also add logging to the Filter class itself.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: dot...@googlegroups.com [mailto:dot...@googlegroups.com] On Behalf Of gsuj...@gmail.com
Sent: Tuesday, August 22, 2017 3:05 PM
To: dotCMS User Group
Subject: [dotcms] Re: Dotcms Dynamic Plugin with Filters

 

We rectified and tried it ,But still it redirects to the 404 page .Below mentioned is the Activator class code

--

http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.

gsuj...@gmail.com

unread,
Aug 22, 2017, 3:21:12 PM8/22/17
to dotCMS User Group
Tried with 1 rule it redirected to the 404 page .then added 2nd rule still it does the same thing.Even if i add both the rules it is going to 404 page .Not completing the form submission

gsuj...@gmail.com

unread,
Aug 22, 2017, 3:21:35 PM8/22/17
to dotCMS User Group
Added Loggers in the  filter class as well


On Tuesday, 22 August 2017 14:11:21 UTC-5, Nathan Keiter wrote:

Nathan Keiter

unread,
Aug 22, 2017, 3:22:38 PM8/22/17
to dot...@googlegroups.com
Oh, right. On success that won't work. You want dotCMS to process the form on success?


Do this:

new WebFormServlet().service( httpServletRequest, httpServletResponse );


Nathan I. Keiter | Lead Network Applications Programmer | Administrative Advisory Council Member | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
https://www.gettysburg.edu
________________________________
From: dot...@googlegroups.com <dot...@googlegroups.com> on behalf of gsuj...@gmail.com <gsuj...@gmail.com>
Sent: Tuesday, August 22, 2017 3:21 PM
To: dotCMS User Group
Subject: Re: [dotcms] Re: Dotcms Dynamic Plugin with Filters

Added Loggers in the filter class as well

On Tuesday, 22 August 2017 14:11:21 UTC-5, Nathan Keiter wrote:
I still see /dotCMS/sendEmail as a “from” in both forwards.

Why two rules?

Also add logging to the Filter class itself.

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
https://www.gettysburg.edu<https://www.gettysburg.edu/>
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/4d6530a4-ddc4-4901-89d3-f43c5f8fa1af%40googlegroups.com<https://groups.google.com/d/msgid/dotcms/4d6530a4-ddc4-4901-89d3-f43c5f8fa1af%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To post to this group, send email to dot...@googlegroups.com<mailto:dot...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/e07bb80c-b835-4b8f-91d3-9de3458180ee%40googlegroups.com<https://groups.google.com/d/msgid/dotcms/e07bb80c-b835-4b8f-91d3-9de3458180ee%40googlegroups.com?utm_medium=email&utm_source=footer>.

Nathan Keiter

unread,
Aug 22, 2017, 3:26:12 PM8/22/17
to dot...@googlegroups.com

If you look at the original filter source I posted, you'll see that line and the chain code commented out.

 

This is because the form servlet endpoints are "outside" the system.

 

You are already "inside" the system.  You can't "bubble up" to an external filter.

 

So you need to pass directly to the dotCMS core class at this point.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

Nathan Keiter

unread,
Aug 22, 2017, 3:28:42 PM8/22/17
to dot...@googlegroups.com

Again, apologies.  That’s my class.  Let me get you the source.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: dot...@googlegroups.com [mailto:dot...@googlegroups.com] On Behalf Of Nathan Keiter


Sent: Tuesday, August 22, 2017 3:26 PM
To: dot...@googlegroups.com

Nathan Keiter

unread,
Aug 22, 2017, 3:31:31 PM8/22/17
to dot...@googlegroups.com
Source of WebFormServlet().service( request, response );


Basically you have to "simulate" the core struts actions. (Since we are already "inside" as I explained earlier.)


[cid:e71f5e84-b45b-4dd3-8156-0bb41149099a]


Nathan I. Keiter | Lead Network Applications Programmer | Administrative Advisory Council Member | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
https://www.gettysburg.edu
________________________________
From: dot...@googlegroups.com <dot...@googlegroups.com> on behalf of Nathan Keiter <nke...@gettysburg.edu>
Sent: Tuesday, August 22, 2017 3:28 PM
To: dot...@googlegroups.com
Subject: RE: [dotcms] Re: Dotcms Dynamic Plugin with Filters

Again, apologies. That’s my class. Let me get you the source.

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
https://www.gettysburg.edu<https://www.gettysburg.edu/>

From: dot...@googlegroups.com [mailto:dot...@googlegroups.com] On Behalf Of Nathan Keiter
Sent: Tuesday, August 22, 2017 3:26 PM
To: dot...@googlegroups.com
Subject: RE: [dotcms] Re: Dotcms Dynamic Plugin with Filters


If you look at the original filter source I posted, you'll see that line and the chain code commented out.



This is because the form servlet endpoints are "outside" the system.



You are already "inside" the system. You can't "bubble up" to an external filter.



So you need to pass directly to the dotCMS core class at this point.


Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
https://www.gettysburg.edu<https://www.gettysburg.edu/>

-----Original Message-----
From: dot...@googlegroups.com<mailto:dot...@googlegroups.com> [mailto:dot...@googlegroups.com] On Behalf Of Nathan Keiter
Sent: Tuesday, August 22, 2017 3:23 PM
To: dot...@googlegroups.com<mailto:dot...@googlegroups.com>
Subject: Re: [dotcms] Re: Dotcms Dynamic Plugin with Filters



Oh, right. On success that won't work. You want dotCMS to process the form on success?





Do this:



new WebFormServlet().service( httpServletRequest, httpServletResponse );





Nathan I. Keiter | Lead Network Applications Programmer | Administrative Advisory Council Member | Benefits Advisory Council Member | I.D.E.A Council Member Gettysburg College | Information Technology | DataSystems Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325

Phone: 717.337.6993

https://www.gettysburg.edu

________________________________

From: dot...@googlegroups.com<mailto:dot...@googlegroups.com> <dot...@googlegroups.com<mailto:dot...@googlegroups.com>> on behalf of gsuj...@gmail.com<mailto:gsuj...@gmail.com> <gsuj...@gmail.com<mailto:gsuj...@gmail.com>>

Sent: Tuesday, August 22, 2017 3:21 PM

To: dotCMS User Group

Subject: Re: [dotcms] Re: Dotcms Dynamic Plugin with Filters



Added Loggers in the filter class as well



On Tuesday, 22 August 2017 14:11:21 UTC-5, Nathan Keiter wrote:

I still see /dotCMS/sendEmail as a “from” in both forwards.



Why two rules?



Also add logging to the Filter class itself.



Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member Gettysburg College | Information Technology | DataSystems Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325

Phone: 717.337.6993

https://www.gettysburg.edu<https://www.gettysburg.edu/<https://www.gettysburg.edu%3chttps:/www.gettysburg.edu/>>
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.

To post to this group, send email to dot...@googlegroups.com<mailto:dot...@googlegroups.com>.

To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/4d6530a4-ddc4-4901-89d3-f43c5f8fa1af%40googlegroups.com<https://groups.google.com/d/msgid/dotcms/4d6530a4-ddc4-4901-89d3-f43c5f8fa1af%40googlegroups.com?utm_medium=email&utm_source=footer<https://groups.google.com/d/msgid/dotcms/4d6530a4-ddc4-4901-89d3-f43c5f8fa1af%40googlegroups.com%3chttps:/groups.google.com/d/msgid/dotcms/4d6530a4-ddc4-4901-89d3-f43c5f8fa1af%40googlegroups.com?utm_medium=email&utm_source=footer>>.

For more options, visit https://groups.google.com/d/optout.



--

http://dotcms.com - Open Source Java Content Management

---

You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.

To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com%3cmailto:dotcms+un...@googlegroups.com>>.

To post to this group, send email to dot...@googlegroups.com<mailto:dot...@googlegroups.com<mailto:dot...@googlegroups.com%3cmailto:dot...@googlegroups.com>>.

To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/e07bb80c-b835-4b8f-91d3-9de3458180ee%40googlegroups.com<https://groups.google.com/d/msgid/dotcms/e07bb80c-b835-4b8f-91d3-9de3458180ee%40googlegroups.com?utm_medium=email&utm_source=footer<https://groups.google.com/d/msgid/dotcms/e07bb80c-b835-4b8f-91d3-9de3458180ee%40googlegroups.com%3chttps:/groups.google.com/d/msgid/dotcms/e07bb80c-b835-4b8f-91d3-9de3458180ee%40googlegroups.com?utm_medium=email&utm_source=footer>>.

For more options, visit https://groups.google.com/d/optout.



--

http://dotcms.com - Open Source Java Content Management

---

You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.

To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.

To post to this group, send email to dot...@googlegroups.com<mailto:dot...@googlegroups.com>.

To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/1503429755725.27798%40gettysburg.edu.

For more options, visit https://groups.google.com/d/optout.
--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To post to this group, send email to dot...@googlegroups.com<mailto:dot...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/cf74de2f6bce46c4beed3ee91ec1992f%40exch13c.ms.gettysburg.edu<https://groups.google.com/d/msgid/dotcms/cf74de2f6bce46c4beed3ee91ec1992f%40exch13c.ms.gettysburg.edu?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To post to this group, send email to dot...@googlegroups.com<mailto:dot...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/d9b35943be694e579b6254f9d7460f1e%40exch13c.ms.gettysburg.edu<https://groups.google.com/d/msgid/dotcms/d9b35943be694e579b6254f9d7460f1e%40exch13c.ms.gettysburg.edu?utm_medium=email&utm_source=footer>.

gsuj...@gmail.com

unread,
Aug 22, 2017, 3:44:37 PM8/22/17
to dotCMS User Group
On success the form should go to the intended destination not to the 404 page

I have attached the plugin.Can you check the activator class and web security filter class and let me know if it works 

On Tuesday, 22 August 2017 12:31:56 UTC-5, sujeeth kumar wrote:
WebSecurityPlugin.zip

Nathan Keiter

unread,
Aug 22, 2017, 4:20:16 PM8/22/17
to dot...@googlegroups.com

Honestly, I don’t have time to look at your code.  What dotCMS version are you on?

 

I did post a generic example here: https://github.com/nkeiter/generic-dotCMS-plugin-code-examples/tree/master/dotcms4.0.1/osgi/org.example.nkeiter.web.form.spam.filter

 

Maybe that can point you in the right direction.

 

It’s complex because of the order of events.  You can’t go back “UP” the filter chain, so you need to compensate.

 

Core Filter

Core Filter .-> Where I need to end up.

Core Filter

Core Filter

Core Filter

Custom Filter

Custom Filter

Custom Filter

Custom Filter -> Where custom filter is flagged!

Custom Filter

Custom Filter

Custom Filter

 

You have to make the jump “UP” via a code shortcut.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: dot...@googlegroups.com [mailto:dot...@googlegroups.com] On Behalf Of gsuj...@gmail.com
Sent: Tuesday, August 22, 2017 3:45 PM
To: dotCMS User Group
Subject: [dotcms] Re: Dotcms Dynamic Plugin with Filters

 

On success the form should go to the intended destination not to the 404 page

--

http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.

To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/00cb994d-0cee-468f-a20b-45f3191dde0d%40googlegroups.com.

gsuj...@gmail.com

unread,
Aug 22, 2017, 4:24:05 PM8/22/17
to dotCMS User Group
I am using dotcms 3.7.1 .Will it not work on 3.7.1 OSGI dynamic Plugins .It works only on the 4.0.1 version ??


On Tuesday, 22 August 2017 12:31:56 UTC-5, sujeeth kumar wrote:

Nathan Keiter

unread,
Aug 22, 2017, 4:25:12 PM8/22/17
to dot...@googlegroups.com

3.7 should be fine.  I was just asking because I posted a 4.x example.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: dot...@googlegroups.com [mailto:dot...@googlegroups.com] On Behalf Of gsuj...@gmail.com
Sent: Tuesday, August 22, 2017 4:24 PM
To: dotCMS User Group
Subject: [dotcms] Re: Dotcms Dynamic Plugin with Filters

 

I am using dotcms 3.7.1 .Will it not work on 3.7.1 OSGI dynamic Plugins .It works only on the 4.0.1 version ??

--

http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.

gsuj...@gmail.com

unread,
Aug 22, 2017, 5:12:39 PM8/22/17
to dotCMS User Group
I will try to check on the code Provided and take a look on it if it resolves the issue

Nathan Keiter

unread,
Aug 22, 2017, 5:17:32 PM8/22/17
to dot...@googlegroups.com

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: dot...@googlegroups.com [mailto:dot...@googlegroups.com] On Behalf Of Nathan Keiter


Sent: Tuesday, August 22, 2017 4:25 PM
To: dot...@googlegroups.com

gsuj...@gmail.com

unread,
Aug 23, 2017, 2:12:51 PM8/23/17
to dotCMS User Group
I have used the request Dispatcher instead of the chain.doFilter(request,response).It worked fine for me.
When i use the chain.doFilter(request,response) it is redirecting to 404 page . Can i use it ??

                RequestDispatcher rd = request.getRequestDispatcher("/dotCMS/sendEmail");
rd.forward(request, response); 
//chain.doFilter(httpServletRequest, httpServletResponse);

Nathan Keiter

unread,
Aug 23, 2017, 2:16:42 PM8/23/17
to dot...@googlegroups.com

No, because you are past the point in the chain where you want to be. You can’t traverse back up the filter chain.

 

chain.doFilter(req,res) would only be helpful if it’s not a web form and you want to pass it through to a page.

So request dispatcher is your only option for what you are attempting to do.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

 

From: dot...@googlegroups.com [mailto:dot...@googlegroups.com] On Behalf Of gsuj...@gmail.com
Sent: Wednesday, August 23, 2017 2:13 PM
To: dotCMS User Group
Subject: [dotcms] Re: Dotcms Dynamic Plugin with Filters

 

I have used the request Dispatcher instead of the chain.doFilter(request,response).It worked fine for me.

--

http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.

gsuj...@gmail.com

unread,
Aug 23, 2017, 4:13:24 PM8/23/17
to dotCMS User Group
Thanks request dispatcher solves the issue 

gsuj...@gmail.com

unread,
Aug 23, 2017, 4:29:37 PM8/23/17
to dotCMS User Group
No I am no using chain.dofilter when i use the request dispatcher .I have commented  the chain.doFilter in the above comment .I have used just the request dispatcher.

                RequestDispatcher rd = request.getRequestDispatcher("/dotCMS/sendEmail");
 rd.forward(request, response); 

Reply all
Reply to author
Forward
0 new messages