Dotcms Dynamic Plugin with Filters

classic Classic list List threaded Threaded
32 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Dotcms Dynamic Plugin with Filters

gsujeeth
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();
    }

}

--
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 [hidden email].
To post to this group, send email to [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

RE: Dotcms Dynamic Plugin with Filters

Nathan Keiter

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

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of [hidden email]
Sent: Tuesday, August 22, 2017 1:32 PM
To: dotCMS User Group
Subject: [dotcms] Dotcms Dynamic Plugin with Filters

 

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();

    }

 

}

--
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 [hidden email].
To post to this group, send email to [hidden email].
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.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/b8d6ca7b85874dff94288cdf22c36166%40exch13c.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: Dotcms Dynamic Plugin with Filters

hpaks23@gmail.com
No, i am not sure how to do that? I tried to use dotcms example plugin "com.dotcms.servlet" as base project
Reply | Threaded
Open this post in threaded view
|

Re: Dotcms Dynamic Plugin with Filters

gsujeeth
In reply to this post by Nathan Keiter
No, i am not sure how to do that? I tried to use dotcms example plugin "com.dotcms.servlet" as base project

On Tuesday, 22 August 2017 12:34:09 UTC-5, Nathan Keiter wrote:

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

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="gyFX7a8xDQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@... [mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="gyFX7a8xDQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@googlegroups.com] On Behalf Of <a href="javascript:" target="_blank" gdf-obfuscated-mailto="gyFX7a8xDQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">gsuj...@...
Sent: Tuesday, August 22, 2017 1:32 PM
To: dotCMS User Group
Subject: [dotcms] Dotcms Dynamic Plugin with Filters

 

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();

    }

 

}

--
<a href="http://dotcms.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;">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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="gyFX7a8xDQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dotcms+un...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="gyFX7a8xDQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@....
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/dotcms/58064e06-94ac-4875-aa00-ebd7cab3b9fe%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/dotcms/58064e06-94ac-4875-aa00-ebd7cab3b9fe%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/dotcms/58064e06-94ac-4875-aa00-ebd7cab3b9fe%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/dotcms/58064e06-94ac-4875-aa00-ebd7cab3b9fe%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/e28e900b-cd8a-44e8-9422-fa4b2428ddf8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Dotcms Dynamic Plugin with Filters

gsujeeth
In reply to this post by gsujeeth
No, i am not sure how to do that? I tried to use dotcms example plugin "com.dotcms.servlet" as base project

On Tuesday, 22 August 2017 12:31:56 UTC-5, sujeeth kumar wrote:
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();
    }

}

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/e2fc82a1-96c6-45e0-a930-b9173a8816a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Dotcms Dynamic Plugin with Filters

Nathan Keiter
In reply to this post by Nathan Keiter
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: [hidden email] <[hidden email]> on behalf of Nathan Keiter <[hidden email]>
Sent: Tuesday, August 22, 2017 1:34 PM
To: [hidden email]
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/>

From: [hidden email] [mailto:[hidden email]] On Behalf Of [hidden email]
Sent: Tuesday, August 22, 2017 1:32 PM
To: dotCMS User Group
Subject: [dotcms] Dotcms Dynamic Plugin with Filters

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();
    }

}
--
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 [hidden email]<mailto:[hidden email]>.
To post to this group, send email to [hidden email]<mailto:[hidden email]>.
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 [hidden email]<mailto:[hidden email]>.
To post to this group, send email to [hidden email]<mailto:[hidden email]>.
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>.
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/1503423706298.86514%40gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.

Screen Shot 2017-08-22 at 1.39.13 PM.png (263K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Dotcms Dynamic Plugin with Filters

gsujeeth
In reply to this post by gsujeeth
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:
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();
    }

}

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/ed5e36d3-f57e-45e0-a95f-73156a627f9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Dotcms Dynamic Plugin with Filters

Nathan Keiter
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: [hidden email] <[hidden email]> on behalf of [hidden email] <[hidden email]>
Sent: Tuesday, August 22, 2017 1:48 PM
To: dotCMS User Group
Subject: [dotcms] Re: Dotcms Dynamic Plugin with Filters

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:
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();
    }

}

--
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 [hidden email]<mailto:[hidden email]>.
To post to this group, send email to [hidden email]<mailto:[hidden email]>.
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>.
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/1503424488158.79916%40gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.

Screen Shot 2017-08-22 at 1.52.09 PM.png (373K) Download Attachment
Screen Shot 2017-08-22 at 1.52.26 PM.png (196K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Dotcms Dynamic Plugin with Filters

Nathan Keiter
In reply to this post by gsujeeth
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: [hidden email] <[hidden email]> on behalf of [hidden email] <[hidden email]>
Sent: Tuesday, August 22, 2017 1:48 PM
To: dotCMS User Group
Subject: [dotcms] Re: Dotcms Dynamic Plugin with Filters

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:
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();
    }

}

--
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 [hidden email]<mailto:[hidden email]>.
To post to this group, send email to [hidden email]<mailto:[hidden email]>.
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>.
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/1503424670648.25839%40gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Dotcms Dynamic Plugin with Filters

gsujeeth
In reply to this post by gsujeeth
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:
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();
    }

}

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/8d90e61b-9e70-4d0d-8d3b-13a323121cfc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Dotcms Dynamic Plugin with Filters

Nathan Keiter

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

https://www.gettysburg.edu

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of [hidden email]
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

 

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:

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();

    }

 

}

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/8d90e61b-9e70-4d0d-8d3b-13a323121cfc%40googlegroups.com.
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/1a089b711cca4912a08f4b915dc83874%40exch13c.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Dotcms Dynamic Plugin with Filters

gsujeeth
In reply to this post by gsujeeth
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:
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();
    }

}

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/e3bd6ba3-6e60-46a1-842e-15ea55bfa5c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Dotcms Dynamic Plugin with Filters

Nathan Keiter

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: [hidden email] [mailto:[hidden email]] On Behalf Of [hidden email]
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 ?? 

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

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();

    }

 

}

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/e3bd6ba3-6e60-46a1-842e-15ea55bfa5c8%40googlegroups.com.
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/02bbe0d71f7c447aa68495c6bf1e2a1a%40exch13c.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Dotcms Dynamic Plugin with Filters

Nathan Keiter
In reply to this post by gsujeeth

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: [hidden email] [mailto:[hidden email]] On Behalf Of [hidden email]
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 ?? 

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

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();

    }

 

}

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/e3bd6ba3-6e60-46a1-842e-15ea55bfa5c8%40googlegroups.com.
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/7a1232838f734deda691260339d3924a%40exch13c.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Dotcms Dynamic Plugin with Filters

gsujeeth
In reply to this post by gsujeeth
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:
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();
    }

}

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/4d6530a4-ddc4-4901-89d3-f43c5f8fa1af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Dotcms Dynamic Plugin with Filters

Nathan Keiter

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: [hidden email] [mailto:[hidden email]] On Behalf Of [hidden email]
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

 

 

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:

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();

    }

 

}

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/4d6530a4-ddc4-4901-89d3-f43c5f8fa1af%40googlegroups.com.
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/6b435beb67494beba6cdc06735578661%40exch13c.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Dotcms Dynamic Plugin with Filters

gsujeeth
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

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

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CpeG4f02DQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@... [mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="CpeG4f02DQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@googlegroups.com] On Behalf Of <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CpeG4f02DQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">gsuj...@...
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

 

 

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:

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();

    }

 

}

--
<a href="http://dotcms.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;">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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CpeG4f02DQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dotcms+un...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CpeG4f02DQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@....
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/dotcms/4d6530a4-ddc4-4901-89d3-f43c5f8fa1af%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/dotcms/4d6530a4-ddc4-4901-89d3-f43c5f8fa1af%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/dotcms/4d6530a4-ddc4-4901-89d3-f43c5f8fa1af%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/dotcms/4d6530a4-ddc4-4901-89d3-f43c5f8fa1af%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/0d858a50-40d1-4bc3-9081-7894183a36f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Dotcms Dynamic Plugin with Filters

gsujeeth
In reply to this post by Nathan Keiter
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

<a href="https://www.gettysburg.edu/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gettysburg.edu%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7XlfToBr_IA0adrY4nu9tVtLS_w&#39;;return true;">https://www.gettysburg.edu

 

From: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CpeG4f02DQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@... [mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="CpeG4f02DQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@googlegroups.com] On Behalf Of <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CpeG4f02DQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">gsuj...@...
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

 

 

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:

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();

    }

 

}

--
<a href="http://dotcms.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdotcms.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFT4ej1MQxQ2vu3iAUqYQgS59efw&#39;;return true;">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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CpeG4f02DQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dotcms+un...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CpeG4f02DQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dot...@....
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/dotcms/4d6530a4-ddc4-4901-89d3-f43c5f8fa1af%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/dotcms/4d6530a4-ddc4-4901-89d3-f43c5f8fa1af%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/dotcms/4d6530a4-ddc4-4901-89d3-f43c5f8fa1af%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/dotcms/4d6530a4-ddc4-4901-89d3-f43c5f8fa1af%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/e07bb80c-b835-4b8f-91d3-9de3458180ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Dotcms Dynamic Plugin with Filters

Nathan Keiter
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: [hidden email] <[hidden email]> on behalf of [hidden email] <[hidden email]>
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/>

From: [hidden email] [mailto:[hidden email]] On Behalf Of [hidden email]
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


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:
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();
    }

}
--
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 [hidden email].
To post to this group, send email to [hidden email].
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 [hidden email]<mailto:[hidden email]>.
To post to this group, send email to [hidden email]<mailto:[hidden email]>.
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>.
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 [hidden email].
To post to this group, send email to [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

Re: Dotcms Dynamic Plugin with Filters

Nathan Keiter

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

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Nathan Keiter
Sent: Tuesday, August 22, 2017 3:23 PM
To: [hidden email]
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: [hidden email] <[hidden email]> on behalf of [hidden email] <[hidden email]>

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/>

 

From: [hidden email] [[hidden email]] On Behalf Of [hidden email]

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

 

 

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:

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();

    }

 

}

--

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 [hidden email].

To post to this group, send email to [hidden email].

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 [hidden email]>.

To post to this group, send email to [hidden email]>.

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>.

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 [hidden email].

To post to this group, send email to [hidden email].

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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/cf74de2f6bce46c4beed3ee91ec1992f%40exch13c.ms.gettysburg.edu.
For more options, visit https://groups.google.com/d/optout.
12