Created
August 26, 2016 17:46
-
-
Save chrismccracken/77d11cec98fb636452213c9fb69c568e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.dotmarketing.osgi.tuckey; | |
import com.dotcms.repackage.org.osgi.framework.BundleContext; | |
import com.dotmarketing.osgi.GenericBundleActivator; | |
import com.dotcms.repackage.org.tuckey.web.filters.urlrewrite.NormalRule; | |
import com.dotcms.repackage.org.tuckey.web.filters.urlrewrite.SetAttribute; | |
public class Activator extends GenericBundleActivator { | |
@SuppressWarnings ("unchecked") | |
public void start ( BundleContext context ) throws Exception { | |
initializeServices( context ); | |
// Create the rewrite rule with the specified request prefix "es" | |
NormalRule esLangRewriteRule = new NormalRule(); | |
esLangRewriteRule.setFrom( "^/es/(.*)" ); | |
// Set the target page language ID request attribute | |
SetAttribute langIdRequestAttribute = new SetAttribute(); | |
langIdRequestAttribute.setName( "com.dotmarketing.htmlpage.language" ); | |
langIdRequestAttribute.setValue( "2" ); | |
esLangRewriteRule.addSetAttribute( langIdRequestAttribute ); | |
// Set the target page language ID session attribute | |
SetAttribute langIdSessionAttribute = new SetAttribute(); | |
langIdSessionAttribute.setType( "session" ); | |
langIdSessionAttribute.setName( "com.dotmarketing.htmlpage.language" ); | |
langIdSessionAttribute.setValue( "2" ); | |
esLangRewriteRule.addSetAttribute( langIdSessionAttribute ); | |
// Set the target page URL attribute | |
SetAttribute cmsFilterUrlMapOverrideAttribute = new SetAttribute(); | |
cmsFilterUrlMapOverrideAttribute.setName( "CMS_FILTER_URLMAP_OVERRIDE" ); | |
cmsFilterUrlMapOverrideAttribute.setValue( "/$1" ); | |
esLangRewriteRule.addSetAttribute( cmsFilterUrlMapOverrideAttribute ); | |
addRewriteRule( esLangRewriteRule ); | |
} | |
public void stop ( BundleContext context ) throws Exception { | |
unregisterServices( context ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment