gatein SVN: r7188 - in epp/portal/branches/EPP_5_2_Branch: component and 1 other directories.
by do-not-reply@jboss.org
Author: theute
Date: 2011-08-19 12:11:19 -0400 (Fri, 19 Aug 2011)
New Revision: 7188
Modified:
epp/portal/branches/EPP_5_2_Branch/
epp/portal/branches/EPP_5_2_Branch/component/
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComponentActionListener.java
Log:
JBEPP-1097
NPE when click link to request a new password for the username in mail after delete user
Property changes on: epp/portal/branches/EPP_5_2_Branch
___________________________________________________________________
Modified: svn:mergeinfo
- /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795:5868
/portal/branches/branch-GTNPORTAL-1592:4894
/portal/branches/branch-GTNPORTAL-1643:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731:5622,5668
/portal/branches/branch-GTNPORTAL-1745:5765
/portal/branches/branch-GTNPORTAL-1822:5943,5952
/portal/branches/branch-GTNPORTAL-1832:6030,6063
/portal/branches/branch-GTNPORTAL-1872:6400,6551
/portal/branches/branch-GTNPORTAL-1921:6603
/portal/branches/branch-GTNPORTAL-1963:6904,6915-6916
/portal/branches/decoupled-webos:6214-6243
/portal/branches/gatein-management:6920-6958
/portal/branches/global-portlet-metadata:6298-6384
/portal/branches/site-describability:6171-6235
/portal/trunk:4891,5744,5822,5943,6168,6196,6201-6203,6205-6206,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061,7117,7125
+ /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795:5868
/portal/branches/branch-GTNPORTAL-1592:4894
/portal/branches/branch-GTNPORTAL-1643:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731:5622,5668
/portal/branches/branch-GTNPORTAL-1745:5765
/portal/branches/branch-GTNPORTAL-1790:5871
/portal/branches/branch-GTNPORTAL-1822:5943,5952
/portal/branches/branch-GTNPORTAL-1832:6030,6063
/portal/branches/branch-GTNPORTAL-1872:6400,6551
/portal/branches/branch-GTNPORTAL-1921:6603
/portal/branches/branch-GTNPORTAL-1963:6904,6915-6916
/portal/branches/decoupled-webos:6214-6243
/portal/branches/gatein-management:6920-6958
/portal/branches/global-portlet-metadata:6298-6384
/portal/branches/site-describability:6171-6235
/portal/trunk:4891,5744,5822,5943,6168,6196,6201-6203,6205-6206,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061,7117,7125
Property changes on: epp/portal/branches/EPP_5_2_Branch/component
___________________________________________________________________
Modified: svn:mergeinfo
- /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795/component:5868
/portal/branches/branch-GTNPORTAL-1592/component:4894
/portal/branches/branch-GTNPORTAL-1643/component:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700/component:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731/component:5622,5668
/portal/branches/branch-GTNPORTAL-1745/component:5765
/portal/branches/branch-GTNPORTAL-1822/component:5943,5952
/portal/branches/branch-GTNPORTAL-1832/component:6030,6063
/portal/branches/branch-GTNPORTAL-1872/component:6400,6551
/portal/branches/branch-GTNPORTAL-1921/component:6603
/portal/branches/branch-GTNPORTAL-1963/component:6904,6915-6916
/portal/trunk/component:4891,5744,5822,5943,6031,6033,6168,6196,6201-6203,6205-6206,6292,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061,7117,7125
+ /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795/component:5868
/portal/branches/branch-GTNPORTAL-1592/component:4894
/portal/branches/branch-GTNPORTAL-1643/component:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700/component:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731/component:5622,5668
/portal/branches/branch-GTNPORTAL-1745/component:5765
/portal/branches/branch-GTNPORTAL-1790/component:5871
/portal/branches/branch-GTNPORTAL-1822/component:5943,5952
/portal/branches/branch-GTNPORTAL-1832/component:6030,6063
/portal/branches/branch-GTNPORTAL-1872/component:6400,6551
/portal/branches/branch-GTNPORTAL-1921/component:6603
/portal/branches/branch-GTNPORTAL-1963/component:6904,6915-6916
/portal/trunk/component:4891,5744,5822,5943,6031,6033,6168,6196,6201-6203,6205-6206,6292,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061,7117,7125
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComponentActionListener.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComponentActionListener.java 2011-08-19 03:47:11 UTC (rev 7187)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComponentActionListener.java 2011-08-19 16:11:19 UTC (rev 7188)
@@ -419,23 +419,29 @@
RemindPasswordTokenService tokenService = uiPortal.getApplicationComponent(RemindPasswordTokenService.class);
String tokenId = event.getRequestContext().getRequestParameter("tokenId");
+ WebuiRequestContext requestContext = event.getRequestContext();
GateInToken token = tokenService.getToken(tokenId);
if (token == null)
{
- WebuiRequestContext requestContext = event.getRequestContext();
requestContext.getUIApplication()
.addMessage(new ApplicationMessage("UIForgetPassword.msg.expration", null));
requestContext.addUIComponentToUpdateByAjax(uiPortal.getParent());
return;
}
- UIPortalApplication uiApp = uiPortal.getAncestorOfType(UIPortalApplication.class);
- UIMaskWorkspace uiMaskWS = uiApp.getChildById(UIPortalApplication.UI_MASK_WS_ID);
-
OrganizationService orgSrc = uiPortal.getApplicationComponent(OrganizationService.class);
// get user
User user = orgSrc.getUserHandler().findUserByName(token.getPayload().getUsername());
+ if (user == null)
+ {
+ requestContext.getUIApplication()
+ .addMessage(new ApplicationMessage("UIForgetPassword.msg.user-delete", null));
+ return;
+ }
+ UIPortalApplication uiApp = uiPortal.getAncestorOfType(UIPortalApplication.class);
+ UIMaskWorkspace uiMaskWS = uiApp.getChildById(UIPortalApplication.UI_MASK_WS_ID);
+
UIResetPassword uiReset = uiMaskWS.createUIComponent(UIResetPassword.class, null, null);
uiReset.setUser(user);
uiReset.setTokenId(tokenId);
13 years, 4 months
gatein SVN: r7187 - portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page.
by do-not-reply@jboss.org
Author: ndkhoiits
Date: 2011-08-18 23:47:11 -0400 (Thu, 18 Aug 2011)
New Revision: 7187
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java
Log:
GTNPORTAL-1961 Default Home page isn't displayed
Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java 2011-08-19 02:33:32 UTC (rev 7186)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java 2011-08-19 03:47:11 UTC (rev 7187)
@@ -83,7 +83,7 @@
// If unauthenticated users have no permission on PORTAL node and URL is valid, they will be required to login
if (pcontext.getRemoteUser() == null && siteKey.getType().equals(SiteType.PORTAL))
{
- targetNode = userPortal.resolvePath(navigation, builder.withAuthMode(UserNodeFilterConfig.AUTH_NO_CHECK).build(), nodePath);
+ targetNode = userPortal.resolvePath(navigation, null, nodePath);
if (targetNode != null)
{
uiPortalApp.setLastRequestURI(null);
@@ -91,7 +91,7 @@
pcontext.sendRedirect(doLoginPath);
return;
}
- }
+ }
else
{
// If path to node is invalid, get the default node instead of.
13 years, 4 months
gatein SVN: r7186 - in portal/trunk: packaging/jboss-as6/pkg/src/main/resources/jboss/server/default/conf/gatein and 5 other directories.
by do-not-reply@jboss.org
Author: phuong_vu
Date: 2011-08-18 22:33:32 -0400 (Thu, 18 Aug 2011)
New Revision: 7186
Added:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/StaticResourceRequestHandler.java
Modified:
portal/trunk/packaging/jboss-as5/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml
portal/trunk/packaging/jboss-as6/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml
portal/trunk/packaging/jetty/pkg/src/main/resources/jetty/gatein/conf/controller.xml
portal/trunk/packaging/tomcat/pkg/src/main/resources/tomcat/gatein/conf/controller.xml
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/controller-configuration.xml
portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml
Log:
GTNPORTAL-2032 Add request handler for serving static resources in portal.war (jpg,ico,css...)
Modified: portal/trunk/packaging/jboss-as5/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml
===================================================================
--- portal/trunk/packaging/jboss-as5/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml 2011-08-18 23:05:31 UTC (rev 7185)
+++ portal/trunk/packaging/jboss-as5/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml 2011-08-19 02:33:32 UTC (rev 7186)
@@ -67,6 +67,15 @@
</route>
</route>
+ <route path="/{gtn:path}">
+ <route-param qname="gtn:handler">
+ <value>staticResource</value>
+ </route-param>
+ <path-param qname="gtn:path" encoding="preserve-path">
+ <pattern>.*\.(jpg|png|gif|ico|css)</pattern>
+ </path-param>
+ </route>
+
<route path="/">
<!-- The portal handler -->
Modified: portal/trunk/packaging/jboss-as6/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml
===================================================================
--- portal/trunk/packaging/jboss-as6/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml 2011-08-18 23:05:31 UTC (rev 7185)
+++ portal/trunk/packaging/jboss-as6/pkg/src/main/resources/jboss/server/default/conf/gatein/controller.xml 2011-08-19 02:33:32 UTC (rev 7186)
@@ -67,6 +67,15 @@
</route>
</route>
+ <route path="/{gtn:path}">
+ <route-param qname="gtn:handler">
+ <value>staticResource</value>
+ </route-param>
+ <path-param qname="gtn:path" encoding="preserve-path">
+ <pattern>.*\.(jpg|png|gif|ico|css)</pattern>
+ </path-param>
+ </route>
+
<route path="/">
<!-- The portal handler -->
Modified: portal/trunk/packaging/jetty/pkg/src/main/resources/jetty/gatein/conf/controller.xml
===================================================================
--- portal/trunk/packaging/jetty/pkg/src/main/resources/jetty/gatein/conf/controller.xml 2011-08-18 23:05:31 UTC (rev 7185)
+++ portal/trunk/packaging/jetty/pkg/src/main/resources/jetty/gatein/conf/controller.xml 2011-08-19 02:33:32 UTC (rev 7186)
@@ -66,6 +66,15 @@
</path-param>
</route>
</route>
+
+ <route path="/{gtn:path}">
+ <route-param qname="gtn:handler">
+ <value>staticResource</value>
+ </route-param>
+ <path-param qname="gtn:path" encoding="preserve-path">
+ <pattern>.*\.(jpg|png|gif|ico|css)</pattern>
+ </path-param>
+ </route>
<route path="/">
Modified: portal/trunk/packaging/tomcat/pkg/src/main/resources/tomcat/gatein/conf/controller.xml
===================================================================
--- portal/trunk/packaging/tomcat/pkg/src/main/resources/tomcat/gatein/conf/controller.xml 2011-08-18 23:05:31 UTC (rev 7185)
+++ portal/trunk/packaging/tomcat/pkg/src/main/resources/tomcat/gatein/conf/controller.xml 2011-08-19 02:33:32 UTC (rev 7186)
@@ -67,6 +67,15 @@
</route>
</route>
+ <route path="/{gtn:path}">
+ <route-param qname="gtn:handler">
+ <value>staticResource</value>
+ </route-param>
+ <path-param qname="gtn:path" encoding="preserve-path">
+ <pattern>.*\.(jpg|png|gif|ico|css)</pattern>
+ </path-param>
+ </route>
+
<route path="/">
<!-- The portal handler -->
Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/controller-configuration.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/controller-configuration.xml 2011-08-18 23:05:31 UTC (rev 7185)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/controller-configuration.xml 2011-08-19 02:33:32 UTC (rev 7186)
@@ -109,6 +109,11 @@
<set-method>register</set-method>
<type>org.exoplatform.portal.application.DefaultRequestHandler</type>
</component-plugin>
+ <component-plugin>
+ <name>StaticResourceRequestHandler</name>
+ <set-method>register</set-method>
+ <type>org.exoplatform.portal.application.StaticResourceRequestHandler</type>
+ </component-plugin>
</external-component-plugins>
</configuration>
Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml 2011-08-18 23:05:31 UTC (rev 7185)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml 2011-08-19 02:33:32 UTC (rev 7186)
@@ -273,29 +273,7 @@
<url-pattern>/</url-pattern>
</servlet-mapping>
- <!-- Explicit mappings (due to portal servlet on '/') for UIHomePagePortlet, need to find out how to improve that -->
<servlet-mapping>
- <servlet-name>default</servlet-name>
- <url-pattern>*.jpg</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>default</servlet-name>
- <url-pattern>*.png</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>default</servlet-name>
- <url-pattern>*.gif</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>default</servlet-name>
- <url-pattern>*.ico</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>default</servlet-name>
- <url-pattern>*.css</url-pattern>
- </servlet-mapping>
-
- <servlet-mapping>
<servlet-name>GateInServlet</servlet-name>
<url-pattern>/gateinservlet</url-pattern>
</servlet-mapping>
Added: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/StaticResourceRequestHandler.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/StaticResourceRequestHandler.java (rev 0)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/StaticResourceRequestHandler.java 2011-08-19 02:33:32 UTC (rev 7186)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.application;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.web.ControllerContext;
+import org.exoplatform.web.WebRequestHandler;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:phuong.vu@exoplatform.com">Vu Viet Phuong</a>
+ */
+public class StaticResourceRequestHandler extends WebRequestHandler
+{
+ @Override
+ public String getHandlerName()
+ {
+ return "staticResource";
+ }
+
+ @Override
+ public void execute(ControllerContext context) throws Exception
+ {
+ PortalContainer portalContainer = PortalContainer.getInstance();
+ ServletContext mergedContext = portalContainer.getPortalContext();
+
+ HttpServletRequest req = context.getRequest();
+ HttpServletResponse res = context.getResponse();
+ mergedContext.getNamedDispatcher("default").forward(req, res);
+ }
+}
13 years, 4 months
gatein SVN: r7185 - epp/portal/branches/EPP_5_2_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/compressor/impl.
by do-not-reply@jboss.org
Author: hfnukal
Date: 2011-08-18 19:05:31 -0400 (Thu, 18 Aug 2011)
New Revision: 7185
Modified:
epp/portal/branches/EPP_5_2_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/compressor/impl/ResourceCompressorService.java
Log:
JBEPP-763 Javascript not working with exo product developing=false
Modified: epp/portal/branches/EPP_5_2_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/compressor/impl/ResourceCompressorService.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/compressor/impl/ResourceCompressorService.java 2011-08-18 21:31:06 UTC (rev 7184)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/compressor/impl/ResourceCompressorService.java 2011-08-18 23:05:31 UTC (rev 7185)
@@ -150,14 +150,19 @@
public void setContext(ManagementContext context)
{
this.managementContext = context;
-
- //
- for (Map.Entry<ResourceType, List<ResourceCompressorPlugin>> entry : plugins.entrySet())
- {
- for (ResourceCompressorPlugin plugin : entry.getValue())
- {
- context.register(plugin);
- }
+
+ if(context==null) {
+ // TODO: throws exception when shutdown server
+ log.warn("Context is null.");
+ } else {
+ //
+ for (Map.Entry<ResourceType, List<ResourceCompressorPlugin>> entry : plugins.entrySet())
+ {
+ for (ResourceCompressorPlugin plugin : entry.getValue())
+ {
+ context.register(plugin);
+ }
+ }
}
}
}
\ No newline at end of file
13 years, 4 months
gatein SVN: r7184 - in epp/portal/branches/EPP_5_2_Branch: component and 1 other directories.
by do-not-reply@jboss.org
Author: theute
Date: 2011-08-18 17:31:06 -0400 (Thu, 18 Aug 2011)
New Revision: 7184
Modified:
epp/portal/branches/EPP_5_2_Branch/
epp/portal/branches/EPP_5_2_Branch/component/
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
Log:
JBEPP-932
EPP52-EID_100: Navigation controller
Property changes on: epp/portal/branches/EPP_5_2_Branch
___________________________________________________________________
Modified: svn:mergeinfo
- /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795:5868
/portal/branches/branch-GTNPORTAL-1592:4894
/portal/branches/branch-GTNPORTAL-1643:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731:5622,5668
/portal/branches/branch-GTNPORTAL-1745:5765
/portal/branches/branch-GTNPORTAL-1822:5943,5952
/portal/branches/branch-GTNPORTAL-1832:6030,6063
/portal/branches/branch-GTNPORTAL-1872:6400,6551
/portal/branches/branch-GTNPORTAL-1921:6603
/portal/branches/branch-GTNPORTAL-1963:6904,6915-6916
/portal/branches/decoupled-webos:6214-6243
/portal/branches/gatein-management:6920-6958
/portal/branches/global-portlet-metadata:6298-6384
/portal/branches/site-describability:6171-6235
/portal/trunk:4891,5744,5822,5943,6168,6196,6201-6203,6205-6206,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061,7117
+ /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795:5868
/portal/branches/branch-GTNPORTAL-1592:4894
/portal/branches/branch-GTNPORTAL-1643:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731:5622,5668
/portal/branches/branch-GTNPORTAL-1745:5765
/portal/branches/branch-GTNPORTAL-1822:5943,5952
/portal/branches/branch-GTNPORTAL-1832:6030,6063
/portal/branches/branch-GTNPORTAL-1872:6400,6551
/portal/branches/branch-GTNPORTAL-1921:6603
/portal/branches/branch-GTNPORTAL-1963:6904,6915-6916
/portal/branches/decoupled-webos:6214-6243
/portal/branches/gatein-management:6920-6958
/portal/branches/global-portlet-metadata:6298-6384
/portal/branches/site-describability:6171-6235
/portal/trunk:4891,5744,5822,5943,6168,6196,6201-6203,6205-6206,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061,7117,7125
Property changes on: epp/portal/branches/EPP_5_2_Branch/component
___________________________________________________________________
Modified: svn:mergeinfo
- /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795/component:5868
/portal/branches/branch-GTNPORTAL-1592/component:4894
/portal/branches/branch-GTNPORTAL-1643/component:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700/component:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731/component:5622,5668
/portal/branches/branch-GTNPORTAL-1745/component:5765
/portal/branches/branch-GTNPORTAL-1822/component:5943,5952
/portal/branches/branch-GTNPORTAL-1832/component:6030,6063
/portal/branches/branch-GTNPORTAL-1872/component:6400,6551
/portal/branches/branch-GTNPORTAL-1921/component:6603
/portal/branches/branch-GTNPORTAL-1963/component:6904,6915-6916
/portal/trunk/component:4891,5744,5822,5943,6031,6033,6168,6196,6201-6203,6205-6206,6292,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061,7117
+ /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795/component:5868
/portal/branches/branch-GTNPORTAL-1592/component:4894
/portal/branches/branch-GTNPORTAL-1643/component:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700/component:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731/component:5622,5668
/portal/branches/branch-GTNPORTAL-1745/component:5765
/portal/branches/branch-GTNPORTAL-1822/component:5943,5952
/portal/branches/branch-GTNPORTAL-1832/component:6030,6063
/portal/branches/branch-GTNPORTAL-1872/component:6400,6551
/portal/branches/branch-GTNPORTAL-1921/component:6603
/portal/branches/branch-GTNPORTAL-1963/component:6904,6915-6916
/portal/trunk/component:4891,5744,5822,5943,6031,6033,6168,6196,6201-6203,6205-6206,6292,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061,7117,7125
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2011-08-18 21:24:33 UTC (rev 7183)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2011-08-18 21:31:06 UTC (rev 7184)
@@ -295,7 +295,10 @@
{
userPortalConfig =
service_.getUserPortalConfig(portalName, remoteUser, PortalRequestContext.USER_PORTAL_CONTEXT);
- session.setAttribute(LAST_PORTAL_NAME, portalName);
+ if (userPortalConfig != null)
+ {
+ session.setAttribute(LAST_PORTAL_NAME, portalName);
+ }
}
catch (Exception e)
{
13 years, 4 months
gatein SVN: r7183 - in epp/portal/branches/EPP_5_2_Branch: component and 111 other directories.
by do-not-reply@jboss.org
Author: theute
Date: 2011-08-18 17:24:33 -0400 (Thu, 18 Aug 2011)
New Revision: 7183
Added:
epp/portal/branches/EPP_5_2_Branch/component/common/src/main/java/org/exoplatform/commons/utils/I18N.java
epp/portal/branches/EPP_5_2_Branch/component/common/src/test/java/org/exoplatform/commons/utils/TestI18N.java
epp/portal/branches/EPP_5_2_Branch/component/test/core/src/main/java/org/exoplatform/component/test/BaseGateInTest.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/gatein_controller_1_0.xsd
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/ControllerContext.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/QualifiedName.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ControllerDescriptor.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/Element.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ParamDescriptor.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RequestParamDescriptor.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteParamDescriptor.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/GroupType.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Kind.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Lexer.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Literal.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Parser.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Quantifier.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RENode.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpParser.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpRenderer.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Stream.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/SubCharSequence.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/SyntaxException.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ControlMode.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/EncodingMode.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/MalformedRouteException.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Param.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Path.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PathParam.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternBuilder.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternRoute.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PercentEncoding.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParam.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteEscaper.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteParam.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Router.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouterConfigException.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/SegmentRoute.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/URIWriter.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ValueMapping.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ValueType.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/MimeType.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/PortalURL.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceType.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLContext.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactory.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactoryPlugin.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactoryService.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NavigationResource.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURL.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURLFactoryPlugin.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestParser.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpAnalyser.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpParser.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpRenderer.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestSubCharSequence.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/AbstractTestController.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/Names.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDuplicateParam.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestHierarchy.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPath.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathEncoding.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPatternBuilder.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortal.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestQualifiedName.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRequestParam.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRouteEscaper.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRoutePriority.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/URIHelper.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml
epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/login/DoLoginServlet.java
epp/portal/branches/EPP_5_2_Branch/distribution/jboss-epp/serverAddon/src/main/resources/conf/gatein/controller.xml
epp/portal/branches/EPP_5_2_Branch/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/LocaleURLPortlet.java
epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/groovy/portal/webui/component/UIBreadcumbsPortlet.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/controller-configuration.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/gadget-configuration.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/web-configuration.xml
epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/url/
epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/url/ComponentURL.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/DefaultRequestHandler.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/LegacyRequestHandler.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/url/
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURLContext.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/url/component/
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/url/component/ComponentURLFactoryPlugin.java
Removed:
epp/portal/branches/EPP_5_2_Branch/component/resources/src/test/java/conf/exo.portal.component.resources-configuration.xml
epp/portal/branches/EPP_5_2_Branch/component/resources/src/test/java/conf/locales-config.xml
epp/portal/branches/EPP_5_2_Branch/component/resources/src/test/java/resources/locales-config.xml
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/conf/portal/configuration.xml
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/QualifiedName.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ControllerDescriptor.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/Element.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ParamDescriptor.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RequestParamDescriptor.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteParamDescriptor.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/GroupType.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Kind.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Lexer.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Literal.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Parser.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Quantifier.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RENode.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpParser.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpRenderer.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Stream.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/SubCharSequence.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/SyntaxException.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ControlMode.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/EncodingMode.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/MalformedRouteException.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Param.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Path.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PathParam.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternBuilder.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternRoute.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PercentEncoding.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParam.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteEscaper.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteParam.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Router.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouterConfigException.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/SegmentRoute.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/URIWriter.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ValueMapping.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ValueType.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/MimeType.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/PortalURL.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceType.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLContext.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactory.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactoryPlugin.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactoryService.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NavigationResource.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURL.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURLFactoryPlugin.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestParser.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpAnalyser.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpParser.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpRenderer.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestSubCharSequence.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/AbstractTestController.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/Names.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDuplicateParam.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestHierarchy.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPath.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathEncoding.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPatternBuilder.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortal.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestQualifiedName.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRequestParam.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRouteEscaper.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRoutePriority.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/URIHelper.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml
epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/conf/portal/configuration.xml
epp/portal/branches/EPP_5_2_Branch/component/web/server/src/main/java/conf/portal/configuration.xml
epp/portal/branches/EPP_5_2_Branch/examples/portal/war/src/main/webapp/index.jsp
epp/portal/branches/EPP_5_2_Branch/examples/portal/war/src/main/webapp/portal-unavailable.jsp
epp/portal/branches/EPP_5_2_Branch/examples/portal/war/src/main/webapp/portal-warning.jsp
epp/portal/branches/EPP_5_2_Branch/gadgets/core/src/main/java/conf/configuration.xml
epp/portal/branches/EPP_5_2_Branch/gadgets/core/src/main/java/conf/portal/configuration.xml
epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/WEB-INF/conf/portlet/web/FCKEditorPortlet/webui/configuration.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/demo/navigation.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/demo/pages.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/john/navigation.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/john/pages.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/marry/navigation.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/marry/pages.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/index.jsp
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/portal-unavailable.jsp
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/portal-warning.jsp
epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/url/ComponentURL.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/conf/configuration.xml
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/conf/portal/configuration.xml
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/concurrent/PortalConcurrencyMonitorLifecycle.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURLContext.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/url/component/
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/url/component/ComponentURLFactoryPlugin.java
Modified:
epp/portal/branches/EPP_5_2_Branch/
epp/portal/branches/EPP_5_2_Branch/component/
epp/portal/branches/EPP_5_2_Branch/component/common/src/main/java/conf/configuration-jboss.properties
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/Constants.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfig.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigListener.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/description/DescriptionService.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/i18n/I18NAdapter.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/i18n/I18Nized.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NodeContext.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserNode.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserNodeFilter.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserNodeFilterConfig.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserPortal.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserPortalImpl.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/mop/description/TestDescriptionService.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/mop/user/TestUserPortal.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/org/exoplatform/portal/mop/user/portal/limited/navigation.xml
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/org/exoplatform/portal/mop/user/portal/system/navigation.xml
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/org/exoplatform/portal/mop/user/portal/system/pages.xml
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/org/exoplatform/portal/mop/user/portal/system/portal.xml
epp/portal/branches/EPP_5_2_Branch/component/resources/pom.xml
epp/portal/branches/EPP_5_2_Branch/component/resources/src/main/java/org/exoplatform/services/resources/LocaleConfig.java
epp/portal/branches/EPP_5_2_Branch/component/resources/src/main/java/org/exoplatform/services/resources/LocaleContextInfo.java
epp/portal/branches/EPP_5_2_Branch/component/resources/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigImpl.java
epp/portal/branches/EPP_5_2_Branch/component/test/core/src/main/java/org/exoplatform/component/test/AbstractGateInTest.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/pom.xml
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/WebAppController.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/WebRequestHandler.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/application/RequestContext.java
epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/application/URLBuilder.java
epp/portal/branches/EPP_5_2_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java
epp/portal/branches/EPP_5_2_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/config/tasks/PortalSkinTask.java
epp/portal/branches/EPP_5_2_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/config/tasks/PortletSkinTask.java
epp/portal/branches/EPP_5_2_Branch/component/web/security/pom.xml
epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/login/ErrorLoginServlet.java
epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/login/GateinWCIController.java
epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/login/RememberMeFilter.java
epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginController.java
epp/portal/branches/EPP_5_2_Branch/component/web/server/src/main/java/org/exoplatform/web/handler/DownloadHandler.java
epp/portal/branches/EPP_5_2_Branch/component/web/server/src/main/java/org/exoplatform/web/handler/UploadHandler.java
epp/portal/branches/EPP_5_2_Branch/examples/extension/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl
epp/portal/branches/EPP_5_2_Branch/examples/portal/war/src/main/webapp/WEB-INF/web.xml
epp/portal/branches/EPP_5_2_Branch/examples/portal/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl
epp/portal/branches/EPP_5_2_Branch/examples/portlets/api/src/main/webapp/WEB-INF/portlet.xml
epp/portal/branches/EPP_5_2_Branch/pom.xml
epp/portal/branches/EPP_5_2_Branch/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardPortlet.java
epp/portal/branches/EPP_5_2_Branch/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UITabPaneDashboard.java
epp/portal/branches/EPP_5_2_Branch/portlet/dashboard/src/main/webapp/groovy/dashboard/webui/component/UITabPaneDashboard.gtmpl
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIApplicationOrganizer.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UINavigationManagement.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UINavigationNodeSelector.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIPageNodeForm.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/BasePartialUpdateToolbar.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIAdminToolbarPortlet.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarDashboardPortlet.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarGroupPortlet.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarSitePortlet.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarDashboardPortlet.gtmpl
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarGroupPortlet.gtmpl
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarSitePortlet.gtmpl
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/groovy/navigation/webui/component/UINavigationManagement.gtmpl
epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIBreadcumbsPortlet.java
epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UINavigationPortlet.java
epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UISitemapPortlet.java
epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/WEB-INF/portlet.xml
epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/groovy/groovy/webui/component/UIBannerPortlet.gtmpl
epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/groovy/portal/webui/component/UILogoPortlet.gtmpl
epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/groovy/portal/webui/component/UIPortalNavigation.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo.js
epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalHttpRequest.js
epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/portal/UIPortal.js
epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIForm.js
epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIRightClickPopupMenu.js
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/configuration.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/group/platform/guests/navigation.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/group/template/group/group.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/classic/pages.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/classic/portal.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/template/classic/portal.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/root/navigation.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/template/user/navigation.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/template/user/pages.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/web.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/UILoginForm.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/webui/core/UIRightClickPopupMenu.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/webui/core/UISitemap.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/webui/core/UISitemapTree.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl
epp/portal/branches/EPP_5_2_Branch/webui/framework/pom.xml
epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/application/WebuiRequestContext.java
epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/core/UIApplication.java
epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponent.java
epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/core/lifecycle/WebuiBindingContext.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStateManager.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStatisticLifecycle.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalURLBuilder.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/UserSiteLifeCycle.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/DefaultLocalePolicyService.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationLifecycle.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/state/PublicPropertiesPlugin.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPage.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIWizardPageSetInfo.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/PageNodeEvent.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UILanguageSelector.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalActionListener.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UISkinSelector.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/util/Util.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIMainActionListener.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplicationLifecycle.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/test/java/org/exoplatform/portal/webui/test/ComponentConfigConcurrentTest.java
epp/portal/branches/EPP_5_2_Branch/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplication.java
epp/portal/branches/EPP_5_2_Branch/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java
epp/portal/branches/EPP_5_2_Branch/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletURLBuilder.java
Log:
JBEPP-932
EPP52-EID_100: Navigation controller
Property changes on: epp/portal/branches/EPP_5_2_Branch
___________________________________________________________________
Modified: svn:mergeinfo
- /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795:5868
/portal/branches/branch-GTNPORTAL-1592:4894
/portal/branches/branch-GTNPORTAL-1643:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731:5622,5668
/portal/branches/branch-GTNPORTAL-1745:5765
/portal/branches/branch-GTNPORTAL-1822:5943,5952
/portal/branches/branch-GTNPORTAL-1832:6030,6063
/portal/branches/branch-GTNPORTAL-1872:6400,6551
/portal/branches/branch-GTNPORTAL-1921:6603
/portal/branches/branch-GTNPORTAL-1963:6904,6915-6916
/portal/branches/decoupled-webos:6214-6243
/portal/branches/gatein-management:6920-6958
/portal/branches/global-portlet-metadata:6298-6384
/portal/branches/site-describability:6171-6235
/portal/trunk:4891,5744,5822,5943,6168,6196,6201-6203,6205-6206,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061
+ /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795:5868
/portal/branches/branch-GTNPORTAL-1592:4894
/portal/branches/branch-GTNPORTAL-1643:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731:5622,5668
/portal/branches/branch-GTNPORTAL-1745:5765
/portal/branches/branch-GTNPORTAL-1822:5943,5952
/portal/branches/branch-GTNPORTAL-1832:6030,6063
/portal/branches/branch-GTNPORTAL-1872:6400,6551
/portal/branches/branch-GTNPORTAL-1921:6603
/portal/branches/branch-GTNPORTAL-1963:6904,6915-6916
/portal/branches/decoupled-webos:6214-6243
/portal/branches/gatein-management:6920-6958
/portal/branches/global-portlet-metadata:6298-6384
/portal/branches/site-describability:6171-6235
/portal/trunk:4891,5744,5822,5943,6168,6196,6201-6203,6205-6206,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061,7117
Property changes on: epp/portal/branches/EPP_5_2_Branch/component
___________________________________________________________________
Modified: svn:mergeinfo
- /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795/component:5868
/portal/branches/branch-GTNPORTAL-1592/component:4894
/portal/branches/branch-GTNPORTAL-1643/component:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700/component:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731/component:5622,5668
/portal/branches/branch-GTNPORTAL-1745/component:5765
/portal/branches/branch-GTNPORTAL-1822/component:5943,5952
/portal/branches/branch-GTNPORTAL-1832/component:6030,6063
/portal/branches/branch-GTNPORTAL-1872/component:6400,6551
/portal/branches/branch-GTNPORTAL-1921/component:6603
/portal/branches/branch-GTNPORTAL-1963/component:6904,6915-6916
/portal/trunk/component:4891,5744,5822,5943,6031,6033,6168,6196,6201-6203,6205-6206,6292,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061
+ /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795/component:5868
/portal/branches/branch-GTNPORTAL-1592/component:4894
/portal/branches/branch-GTNPORTAL-1643/component:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700/component:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731/component:5622,5668
/portal/branches/branch-GTNPORTAL-1745/component:5765
/portal/branches/branch-GTNPORTAL-1822/component:5943,5952
/portal/branches/branch-GTNPORTAL-1832/component:6030,6063
/portal/branches/branch-GTNPORTAL-1872/component:6400,6551
/portal/branches/branch-GTNPORTAL-1921/component:6603
/portal/branches/branch-GTNPORTAL-1963/component:6904,6915-6916
/portal/trunk/component:4891,5744,5822,5943,6031,6033,6168,6196,6201-6203,6205-6206,6292,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061,7117
Modified: epp/portal/branches/EPP_5_2_Branch/component/common/src/main/java/conf/configuration-jboss.properties
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/common/src/main/java/conf/configuration-jboss.properties 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/common/src/main/java/conf/configuration-jboss.properties 2011-08-18 21:24:33 UTC (rev 7183)
@@ -53,3 +53,12 @@
# Global portlet.xml
gatein.portlet.config=${gatein.conf.dir}/portlet.xml
+
+# Portal configuration
+gatein.portal.idm.createuserportal=false
+gatein.portal.idm.destroyuserportal=true
+gatein.portal.controller.config=${gatein.conf.dir}/controller.xml
+
+# key files for gadget
+gatein.gadgets.securitytokenkeyfile=${gatein.conf.dir}/gadgets/key.txt
+gatein.gadgets.signingkeyfile=${gatein.conf.dir}/gadgets/oauthkey.pem
Copied: epp/portal/branches/EPP_5_2_Branch/component/common/src/main/java/org/exoplatform/commons/utils/I18N.java (from rev 7117, portal/trunk/component/common/src/main/java/org/exoplatform/commons/utils/I18N.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/common/src/main/java/org/exoplatform/commons/utils/I18N.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/common/src/main/java/org/exoplatform/commons/utils/I18N.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,203 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.commons.utils;
+
+import java.util.Locale;
+
+/**
+ * Various I18N utility methods.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public class I18N
+{
+
+ /**
+ * Provide a string representation of the locale argument to the {@link java.util.Locale#toString()} method.
+ *
+ * @param locale the locale
+ * @return the java representation
+ * @throws NullPointerException if the locale argument is null
+ */
+ public static String toJavaIdentifier(Locale locale) throws NullPointerException
+ {
+ if (locale == null)
+ {
+ throw new NullPointerException("No null locale accepted");
+ }
+ return locale.toString();
+ }
+
+ private static boolean isLetter(char c)
+ {
+ return c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z';
+ }
+
+ /**
+ * Parse the java string representation and returns a locale.
+ * See {@link #toJavaIdentifier(java.util.Locale)} method for more details.
+ *
+ * @param s the java representation to parse
+ * @return the corresponding locale
+ * @throws NullPointerException if the locale argument is null
+ * @throws IllegalArgumentException if the string cannot be parsed to a locale
+ */
+ public static Locale parseJavaIdentifier(String s) throws NullPointerException, IllegalArgumentException
+ {
+ if (s.length() == 0)
+ {
+ throw new IllegalArgumentException("Empty locale");
+ }
+
+ //
+ char c0 = s.charAt(0);
+ if (c0 == '_')
+ {
+ return parseCountry("", s, 0);
+ }
+ else if (!isLetter(c0) || s.length() < 2 || !isLetter(s.charAt(1)))
+ {
+ throw new IllegalArgumentException();
+ }
+ else
+ {
+ return parseCountry(s.substring(0, 2), s, 2);
+ }
+ }
+
+ private static Locale parseCountry(String lang, String s, int index) throws IllegalArgumentException
+ {
+ if (s.length() == index)
+ {
+ return new Locale(lang);
+ }
+ else if (s.charAt(index) != '_' || s.length() < index + 3)
+ {
+ throw new IllegalArgumentException();
+ }
+ else
+ {
+ char c0 = s.charAt(index + 1);
+ if (c0 == '_')
+ {
+ if (lang.length() == 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ else
+ {
+ return parseVariant(lang, "", s, index + 1);
+ }
+ }
+ else if (!isLetter(c0) || !isLetter(s.charAt(index + 2)))
+ {
+ throw new IllegalArgumentException();
+ }
+ else
+ {
+ return parseVariant(lang, s.substring(index + 1, index + 3), s, index + 3);
+ }
+ }
+ }
+
+ private static Locale parseVariant(String lang, String country, String s, int index) throws IllegalArgumentException
+ {
+ if (s.length() == index)
+ {
+ return new Locale(lang, country);
+ }
+ else if (s.charAt(index) != '_' || s.length() < index + 2)
+ {
+ throw new IllegalArgumentException();
+ }
+ else
+ {
+ for (int i = index + 1;i < s.length();i++)
+ {
+ if (!isLetter(s.charAt(i)))
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+ String variant = s.substring(index + 1);
+ return new Locale(lang, country, variant);
+ }
+ }
+
+ /**
+ * Provide a string representation of the locale argument according to the <a href="RFC 1766">http://www.ietf.org/rfc/rfc1766.txt</a>:
+ * <ul>
+ * <li>locale with a language only will return the language string</li>
+ * <li>otherwise it returns the language and country separated by an hyphen '-'</li>
+ * </ul>
+ *
+ * @param locale the locale
+ * @return the RFC1766 representation
+ * @throws NullPointerException if the locale argument is null
+ */
+ public static String toTagIdentifier(Locale locale) throws NullPointerException
+ {
+ if (locale == null)
+ {
+ throw new NullPointerException("No null locale accepted");
+ }
+ String country = locale.getCountry();
+ String lang = locale.getLanguage();
+ if (country != null && country.length() > 0)
+ {
+ return lang + "-" + country;
+ }
+ else
+ {
+ return lang;
+ }
+ }
+
+ /**
+ * Parse the <a href="RFC 1766">http://www.ietf.org/rfc/rfc1766.txt</a> string representation and returns a locale.
+ * See {@link #toTagIdentifier(java.util.Locale)} method for more details.
+ *
+ * @param s the RFC1766 representation to parse
+ * @return the corresponding locale
+ * @throws NullPointerException if the locale argument is null
+ * @throws IllegalArgumentException if the string cannot be parsed to a locale
+ */
+ public static Locale parseTagIdentifier(String s) throws NullPointerException, IllegalArgumentException
+ {
+ if (s == null)
+ {
+ throw new NullPointerException("No null string accepted");
+ }
+ if (s.length() == 2)
+ {
+ return new Locale(s.substring(0, 2));
+ }
+ else if (s.length() == 5 && s.charAt(2) == '-')
+ {
+ String lang = s.substring(0, 2);
+ String country = s.substring(3, 5);
+ return new Locale(lang, country);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Locale " + s + " cannot be parsed");
+ }
+ }
+}
Copied: epp/portal/branches/EPP_5_2_Branch/component/common/src/test/java/org/exoplatform/commons/utils/TestI18N.java (from rev 7117, portal/trunk/component/common/src/test/java/org/exoplatform/commons/utils/TestI18N.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/common/src/test/java/org/exoplatform/commons/utils/TestI18N.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/common/src/test/java/org/exoplatform/commons/utils/TestI18N.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.commons.utils;
+
+import junit.framework.TestCase;
+
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public class TestI18N extends TestCase
+{
+
+ public void testToRFC1766()
+ {
+ assertEquals("en", I18N.toTagIdentifier(Locale.ENGLISH));
+ assertEquals("en-GB", I18N.toTagIdentifier(Locale.UK));
+ assertEquals("en-GB", I18N.toTagIdentifier(new Locale("en", "GB", "ab")));
+ try
+ {
+ I18N.toTagIdentifier(null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ }
+
+ public void testParseRFC1766()
+ {
+ assertEquals(Locale.ENGLISH, I18N.parseTagIdentifier("en"));
+ assertEquals(Locale.UK, I18N.parseTagIdentifier("en-GB"));
+ String[] incorrects = {"", " en", "en_GB"};
+ for (String incorrect : incorrects)
+ {
+ try
+ {
+ I18N.parseTagIdentifier(incorrect);
+ fail("Was expecting " + incorrect + " to not be parsed");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+ try
+ {
+ I18N.parseTagIdentifier(null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ }
+
+ public void testParseJavaIdentifier()
+ {
+ assertJavaIdentifier(Locale.ENGLISH, "en");
+ assertNotJavaIdentifier("");
+ assertNotJavaIdentifier("e");
+ assertNotJavaIdentifier("+e");
+ assertNotJavaIdentifier("e+");
+ assertNotJavaIdentifier("_");
+ assertNotJavaIdentifier("en+");
+ assertNotJavaIdentifier("en_");
+ assertNotJavaIdentifier("en_G");
+ assertNotJavaIdentifier("__");
+ assertNotJavaIdentifier("en_+");
+ assertNotJavaIdentifier("en_G+");
+ assertJavaIdentifier(Locale.UK, "en_GB");
+ assertNotJavaIdentifier("en__");
+ assertNotJavaIdentifier("en_GB_");
+ assertNotJavaIdentifier("en__+");
+ assertNotJavaIdentifier("en_GB_+");
+ assertNotJavaIdentifier("__f");
+ assertJavaIdentifier(new Locale("en", "", "f"), "en__f");
+ assertJavaIdentifier(new Locale("", "GB", "f"), "_GB_f");
+ }
+
+ public void testDefaultLocales()
+ {
+ for (Locale expected : Locale.getAvailableLocales())
+ {
+ String s = expected.toString();
+ Locale parsed = I18N.parseJavaIdentifier(s);
+ assertEquals(expected, parsed);
+ }
+ }
+
+ private void assertNotJavaIdentifier(String s)
+ {
+ try
+ {
+ I18N.parseJavaIdentifier(s);
+ fail("Was expecting " + s + " to fail");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ private void assertJavaIdentifier(Locale expected, String s)
+ {
+ assertEquals(expected, I18N.parseJavaIdentifier(s));
+ }
+}
Modified: epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/Constants.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/Constants.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/Constants.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -32,4 +32,6 @@
public static final String PORTAL_WINDOW_STATE = "portal:windowState";
public static final String PORTAL_PORTLET_MODE = "portal:portletMode";
+
+ public static final String QMARK = "?";
}
Modified: epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -612,15 +612,12 @@
//
if (xml == null)
{
- boolean isTemplate = (config.getTemplateName() != null && config.getTemplateName().trim().length() > 0);
- if (isTemplate)
+ String templateName = config.getTemplateName() != null ? config.getTemplateName() : fileName;
+ path = "/" + ownerType + "/template/" + templateName + "/" + fileName + ".xml";
+ xml = getDefaultConfig(config.getTemplateLocation(), path);
+ if (xml != null)
{
- path = "/" + ownerType + "/template/" + config.getTemplateName() + "/" + fileName + ".xml";
- xml = getDefaultConfig(config.getTemplateLocation(), path);
- if (xml != null)
- {
- xml = OWNER_PATTERN.matcher(xml).replaceAll(owner);
- }
+ xml = OWNER_PATTERN.matcher(xml).replaceAll(owner);
}
}
Modified: epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfig.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfig.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfig.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -24,7 +24,9 @@
import org.exoplatform.portal.mop.user.UserPortal;
import org.exoplatform.portal.mop.user.UserPortalImpl;
-public class UserPortalConfig
+import java.io.Serializable;
+
+public class UserPortalConfig implements Serializable
{
PortalConfig portal;
@@ -36,9 +38,6 @@
final String accessUser;
/** . */
- private UserPortalImpl userPortal;
-
- /** . */
private UserPortalContext userPortalContext;
public UserPortalConfig()
@@ -61,14 +60,7 @@
public UserPortal getUserPortal()
{
- userPortal = new UserPortalImpl(
- service,
- portalName,
- portal,
- accessUser,
- userPortalContext
- );
- return userPortal;
+ return new UserPortalImpl(service, portalName, portal, accessUser, userPortalContext);
}
public PortalConfig getPortalConfig()
@@ -76,8 +68,13 @@
return portal;
}
- public void setPortal(PortalConfig portal)
+ public void setPortalConfig(PortalConfig portal)
{
this.portal = portal;
}
+
+ public String getPortalName()
+ {
+ return portalName;
+ }
}
\ No newline at end of file
Modified: epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigListener.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigListener.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigListener.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -38,51 +38,52 @@
/** . */
private final UserPortalConfigService portalConfigService;
- /** . */
- private final DataStorage dataStorage;
-
- public UserPortalConfigListener(
- UserPortalConfigService portalConfigService,
- DataStorage dataStorage)
+ public UserPortalConfigListener(UserPortalConfigService portalConfigService)
{
this.portalConfigService = portalConfigService;
- this.dataStorage = dataStorage;
}
public void preDelete(User user) throws Exception
{
- RequestLifeCycle.begin(PortalContainer.getInstance());
- try
+ if (portalConfigService.getDestroyUserPortal())
{
String userName = user.getUserName();
- portalConfigService.removeUserPortalConfig("user", userName);
+
+ //
+ log.debug("About to destroy user site for user " + userName);
+ RequestLifeCycle.begin(PortalContainer.getInstance());
+ try
+ {
+ portalConfigService.removeUserPortalConfig("user", userName);
+ }
+ finally
+ {
+ RequestLifeCycle.end();
+ }
}
- finally
- {
- RequestLifeCycle.end();
- }
}
public void preSave(User user, boolean isNew)
{
- String userName = user.getUserName();
-
- //
- RequestLifeCycle.begin(PortalContainer.getInstance());
- try
+ if (portalConfigService.getCreateUserPortal())
{
- log.debug("About to create user site for user " + userName);
+ String userName = user.getUserName();
// Create the portal from the template
- portalConfigService.createUserSite(userName);
+ log.debug("About to create user site for user " + userName);
+ RequestLifeCycle.begin(PortalContainer.getInstance());
+ try
+ {
+ portalConfigService.createUserSite(userName);
+ }
+ catch (Exception e)
+ {
+ log.error("Could not create user site for user " + userName, e);
+ }
+ finally
+ {
+ RequestLifeCycle.end();
+ }
}
- catch (Exception e)
- {
- log.error("Could not create user site for user " + userName, e);
- }
- finally
- {
- RequestLifeCycle.end();
- }
}
}
Modified: epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -21,6 +21,8 @@
import org.exoplatform.commons.utils.LazyPageList;
import org.exoplatform.container.component.ComponentPlugin;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.ValueParam;
import org.exoplatform.portal.config.model.Application;
import org.exoplatform.portal.config.model.Container;
import org.exoplatform.portal.config.model.ModelObject;
@@ -63,21 +65,61 @@
/** . */
final DescriptionService descriptionService;
+ /** . */
+ boolean createUserPortal;
+
+ /** . */
+ boolean destroyUserPortal;
+
private Log log = ExoLogger.getLogger("Portal:UserPortalConfigService");
public UserPortalConfigService(
- UserACL userACL, DataStorage storage,
+ UserACL userACL,
+ DataStorage storage,
OrganizationService orgService,
NavigationService navService,
- DescriptionService descriptionService) throws Exception
+ DescriptionService descriptionService,
+ InitParams params) throws Exception
{
+
+ //
+ ValueParam createUserPortalParam = params == null ? null : params.getValueParam("create.user.portal");
+ boolean createUserPortal = createUserPortalParam == null || createUserPortalParam.getValue().toLowerCase().trim().equals("true");
+
+ //
+ ValueParam destroyUserPortalParam = params == null ? null : params.getValueParam("destroy.user.portal");
+ boolean destroyUserPortal = destroyUserPortalParam == null || destroyUserPortalParam.getValue().toLowerCase().trim().equals("true");
+
+ //
this.storage_ = storage;
this.orgService_ = orgService;
this.userACL_ = userACL;
this.navService = navService;
this.descriptionService = descriptionService;
+ this.createUserPortal = createUserPortal;
+ this.destroyUserPortal = destroyUserPortal;
}
+ public boolean getCreateUserPortal()
+ {
+ return createUserPortal;
+ }
+
+ public void setCreateUserPortal(boolean createUserPortal)
+ {
+ this.createUserPortal = createUserPortal;
+ }
+
+ public boolean getDestroyUserPortal()
+ {
+ return destroyUserPortal;
+ }
+
+ public void setDestroyUserPortal(boolean destroyUserPortal)
+ {
+ this.destroyUserPortal = destroyUserPortal;
+ }
+
/**
* Returns the navigation service associated with this service.
*
Modified: epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/description/DescriptionService.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/description/DescriptionService.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/description/DescriptionService.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -99,8 +99,9 @@
* @param locale the locale
* @param description the new description
* @throws NullPointerException if the id or locale argument is null
+ * @throws IllegalArgumentException if the locale is not valid
*/
- void setDescription(String id, Locale locale, Described.State description) throws NullPointerException;
+ void setDescription(String id, Locale locale, Described.State description) throws NullPointerException, IllegalArgumentException;
/**
* Returns a map containing all the descriptions of an object or null if the object is not internationalized.
@@ -118,7 +119,8 @@
* @param id the object id
* @param descriptions the new descriptions
* @throws NullPointerException if the id is null
+ * @throws IllegalArgumentException if the map contains an invalid locale
*/
- void setDescriptions(String id, Map<Locale, Described.State> descriptions) throws NullPointerException;
+ void setDescriptions(String id, Map<Locale, Described.State> descriptions) throws NullPointerException, IllegalArgumentException;
}
Modified: epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/i18n/I18NAdapter.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/i18n/I18NAdapter.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/i18n/I18NAdapter.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -19,8 +19,6 @@
package org.exoplatform.portal.mop.i18n;
-import org.gatein.common.i18n.LocaleFormat;
-import org.gatein.common.util.ConversionException;
import org.gatein.mop.api.workspace.WorkspaceObject;
import org.gatein.mop.spi.AdapterLifeCycle;
@@ -39,9 +37,6 @@
public class I18NAdapter
{
- /** The locale serialization format. */
- private static final LocaleFormat format = LocaleFormat.DEFAULT;
-
/** . */
private final WorkspaceObject obj;
@@ -50,16 +45,6 @@
this.obj = obj;
}
- static String toString(Locale locale)
- {
- return locale.toString();
- }
-
- static Locale parseLocale(String s) throws ConversionException
- {
- return format.getLocale(s);
- }
-
public <M> M getMixin(Class<M> mixinType, boolean create) throws NullPointerException
{
if (mixinType == null)
@@ -88,6 +73,15 @@
}
}
+ /**
+ * Resolve the mixin for the specified locale.
+ *
+ * @param mixinType the expected mixin type
+ * @param locale the locale
+ * @param <M> the mixin generic type
+ * @return the resolution or null if it cannot be resolved
+ * @throws NullPointerException if any argument is null
+ */
public <M> Resolution<M> resolveI18NMixin(Class<M> mixinType, Locale locale) throws NullPointerException
{
if (mixinType == null)
@@ -98,7 +92,7 @@
{
throw new NullPointerException("No null locale accepted");
}
- if (obj.isAdapted(I18Nized.class))
+ if (locale.getLanguage().length() > 0 && obj.isAdapted(I18Nized.class))
{
I18Nized ized = obj.adapt(I18Nized.class);
return ized.resolveMixin(mixinType, locale);
@@ -109,7 +103,7 @@
}
}
- public <M> M getI18NMixin(Class<M> mixinType, Locale locale, boolean create) throws NullPointerException
+ public <M> M getI18NMixin(Class<M> mixinType, Locale locale, boolean create) throws NullPointerException, IllegalArgumentException
{
if (mixinType == null)
{
@@ -152,7 +146,7 @@
}
}
- public <M> M addI18NMixin(Class<M> mixinType, Locale locale)
+ public <M> M addI18NMixin(Class<M> mixinType, Locale locale) throws NullPointerException, IllegalArgumentException
{
if (mixinType == null)
{
Modified: epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/i18n/I18Nized.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/i18n/I18Nized.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/i18n/I18Nized.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -23,7 +23,9 @@
import org.chromattic.api.annotations.MixinType;
import org.chromattic.api.annotations.OneToOne;
import org.chromattic.api.annotations.Owner;
-import org.gatein.common.util.ConversionException;
+import org.exoplatform.commons.utils.I18N;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
import java.util.ArrayList;
import java.util.Collection;
@@ -44,6 +46,8 @@
@MixinType(name = "gtn:i18nized")
public abstract class I18Nized
{
+ /** . */
+ private static final Logger log = LoggerFactory.getLogger(I18Nized.class);
private static Locale parent(Locale locale)
{
@@ -62,14 +66,14 @@
}
@Create
- public abstract LanguageSpace createLanguageSpace();
+ protected abstract LanguageSpace createLanguageSpace();
@OneToOne
@Owner
@MappedBy("gtn:languages")
- public abstract LanguageSpace getLanguageSpace();
+ protected abstract LanguageSpace getLanguageSpace();
- public abstract void setLanguageSpace(LanguageSpace languageSpace);
+ protected abstract void setLanguageSpace(LanguageSpace languageSpace);
public <M> Resolution<M> resolveMixin(Class<M> mixinType, Locale wantedLocale)
{
@@ -107,15 +111,15 @@
M mixin = entry.getValue().getMixin(mixinType, false);
if (mixin != null)
{
+ String lang = entry.getKey();
try
{
- Locale locale = I18NAdapter.parseLocale(entry.getKey());
+ Locale locale = I18N.parseTagIdentifier(lang);
mixins.put(locale, mixin);
}
- catch (ConversionException e)
+ catch (IllegalArgumentException e)
{
- // Handle me gracefully
- e.printStackTrace();
+ log.debug("Skipping locale " + lang + " from retrieved locales for mixin " + mixinType.getName());
}
}
}
@@ -123,7 +127,7 @@
return mixins;
}
- public <M> M getMixin(Class<M> mixinType, Locale locale, boolean createMixin) throws NullPointerException
+ public <M> M getMixin(Class<M> mixinType, Locale locale, boolean createMixin) throws NullPointerException, IllegalArgumentException
{
if (mixinType == null)
{
@@ -133,6 +137,14 @@
{
throw new NullPointerException("No null locale accepted");
}
+ if (locale.getLanguage().length() == 0)
+ {
+ throw new IllegalArgumentException("No language set on locale");
+ }
+ if (locale.getVariant().length() > 0)
+ {
+ throw new IllegalArgumentException("No variant cab be set on locale");
+ }
LanguageSpace languageSpace = getLanguageSpace();
if (languageSpace == null && createMixin)
{
@@ -141,7 +153,7 @@
}
if (languageSpace != null)
{
- return languageSpace.getLanguage(mixinType, I18NAdapter.toString(locale), createMixin);
+ return languageSpace.getLanguage(mixinType, I18N.toTagIdentifier(locale), createMixin);
}
else
{
@@ -163,20 +175,19 @@
{
if (language.removeMixin(mixinType))
{
+ String lang = language.getName();
try
{
- String lang = language.getName();
- Locale locale = I18NAdapter.parseLocale(lang);
+ Locale locale = I18N.parseTagIdentifier(lang);
if (locales.isEmpty())
{
locales = new ArrayList<Locale>();
}
locales.add(locale);
}
- catch (ConversionException e)
+ catch (IllegalArgumentException e)
{
- // Handle me gracefully
- e.printStackTrace();
+ log.debug("Skipping locale " + lang + " from removed locales for mixin " + mixinType.getName());
}
}
}
Modified: epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NodeContext.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NodeContext.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NodeContext.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -621,6 +621,12 @@
}
}
+ public N getDescendantNode(String handle) throws NullPointerException
+ {
+ NodeContext<N> descendant = getDescendant(handle);
+ return descendant != null && !descendant.hidden ? descendant.node: null;
+ }
+
public final Iterator<N> iterator()
{
return new Iterator<N>()
Modified: epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserNode.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserNode.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserNode.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -333,8 +333,7 @@
// Keep this internal for now
UserNode find(String nodeId)
{
- NodeContext<UserNode> found = context.getDescendant(nodeId);
- return found != null ? found.getNode() : null;
+ return context.getDescendantNode(nodeId);
}
public String toString()
Modified: epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserNodeFilter.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserNodeFilter.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserNodeFilter.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -20,7 +20,7 @@
package org.exoplatform.portal.mop.user;
import org.exoplatform.portal.config.UserACL;
-import org.exoplatform.portal.config.UserPortalConfigService;
+import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.mop.Visibility;
import org.exoplatform.portal.mop.navigation.NodeFilter;
import org.exoplatform.portal.mop.navigation.NodeState;
@@ -54,6 +54,46 @@
this.config = config;
}
+ private boolean canRead(NodeState state)
+ {
+ String pageRef = state.getPageRef();
+ if (pageRef != null)
+ {
+ try
+ {
+ Page page = userPortal.service.getPage(pageRef);
+ if (page != null)
+ {
+ return userPortal.service.getUserACL().hasPermission(page);
+ }
+ }
+ catch (Exception ignore)
+ {
+ }
+ }
+ return true;
+ }
+
+ private boolean canWrite(NodeState state)
+ {
+ String pageRef = state.getPageRef();
+ if (pageRef != null)
+ {
+ try
+ {
+ Page page = userPortal.service.getPage(pageRef);
+ if (page != null)
+ {
+ return userPortal.service.getUserACL().hasEditPermission(page);
+ }
+ }
+ catch (Exception ignore)
+ {
+ }
+ }
+ return false;
+ }
+
public boolean accept(int depth, String id, String name, NodeState state)
{
Visibility visibility = state.getVisibility();
@@ -71,33 +111,46 @@
}
//
- if (config.authorizationCheck)
+ UserACL acl = userPortal.service.getUserACL();
+
+ // Perform authorization check
+ if (config.authorizationMode == UserNodeFilterConfig.AUTH_NO_CHECK)
{
+ // Do nothing here
+ }
+ else
+ {
if (visibility == Visibility.SYSTEM)
{
- UserACL acl = userPortal.service.getUserACL();
- String userName = userPortal.userName;
- if (!acl.getSuperUser().equals(userName))
+ if (config.authorizationMode == UserNodeFilterConfig.AUTH_READ_WRITE)
{
- return false;
+ String userName = userPortal.userName;
+ if (!acl.getSuperUser().equals(userName))
+ {
+ return false;
+ }
}
+ else
+ {
+ if (!canRead(state))
+ {
+ return false;
+ }
+ }
}
else
{
- String pageRef = state.getPageRef();
- if (pageRef != null)
+ if (config.authorizationMode == UserNodeFilterConfig.AUTH_READ_WRITE)
{
- UserPortalConfigService upcs = userPortal.service;
- try
+ if (!canRead(state))
{
- if (upcs.getPage(pageRef, userPortal.userName) == null)
- {
- return false;
- }
+ return false;
}
- catch (Exception e)
+ }
+ else
+ {
+ if (!canRead(state))
{
- // Log me
return false;
}
}
Modified: epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserNodeFilterConfig.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserNodeFilterConfig.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserNodeFilterConfig.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -22,6 +22,7 @@
import org.exoplatform.commons.utils.Safe;
import org.exoplatform.portal.mop.Visibility;
+import java.util.Collections;
import java.util.EnumSet;
import java.util.Set;
@@ -33,10 +34,19 @@
{
/** . */
+ public static final int AUTH_NO_CHECK = 0;
+
+ /** . */
+ public static final int AUTH_READ = 1;
+
+ /** . */
+ public static final int AUTH_READ_WRITE = 2;
+
+ /** . */
final Set<Visibility> visibility;
/** . */
- final boolean authorizationCheck;
+ final int authorizationMode;
/** . */
final boolean temporalCheck;
@@ -50,7 +60,7 @@
//
this.visibility = Safe.unmodifiableSet(builder.withVisibility);
- this.authorizationCheck = builder.withAuthorizationCheck;
+ this.authorizationMode = builder.withAuthorizationMode;
this.temporalCheck = builder.withTemporalCheck;
}
@@ -59,9 +69,9 @@
return visibility;
}
- public boolean getAuthorizationCheck()
+ public int getAuthorizationMode()
{
- return authorizationCheck;
+ return authorizationMode;
}
public boolean getTemporalCheck()
@@ -83,25 +93,25 @@
{
/** . */
- private Set<Visibility> withVisibility = null;
+ private Set<Visibility> withVisibility;
/** . */
- private boolean withAuthorizationCheck = false;
+ private int withAuthorizationMode;
/** . */
- private boolean withTemporalCheck = false;
+ private boolean withTemporalCheck;
private Builder()
{
this.withVisibility = null;
- this.withAuthorizationCheck = false;
+ this.withAuthorizationMode = AUTH_NO_CHECK;
this.withTemporalCheck = false;
}
private Builder(UserNodeFilterConfig predicate)
{
this.withVisibility = predicate.visibility;
- this.withAuthorizationCheck = predicate.authorizationCheck;
+ this.withAuthorizationMode = predicate.authorizationMode;
this.withTemporalCheck = predicate.temporalCheck;
}
@@ -117,6 +127,25 @@
return this;
}
+ public Builder withVisibility(Visibility[] all)
+ {
+ if (all.length == 0)
+ {
+ withVisibility = Collections.emptySet();
+ }
+ else if (all.length == 1)
+ {
+ withVisibility = EnumSet.of(all[0]);
+ }
+ else
+ {
+ Visibility[] rest = new Visibility[all.length - 1];
+ System.arraycopy(all, 1, rest, 0, rest.length);
+ withVisibility = EnumSet.of(all[0], rest);
+ }
+ return this;
+ }
+
public Builder withoutVisibility()
{
withVisibility = null;
@@ -135,18 +164,34 @@
return this;
}
- public Builder withAuthorizationCheck()
+ public Builder withAuthMode(int withAuthorizationMode)
{
- this.withAuthorizationCheck = true;
+ if (withAuthorizationMode < 0 || withAuthorizationMode > 2)
+ {
+ throw new IllegalArgumentException("Wrong authorization mode value");
+ }
+ this.withAuthorizationMode = withAuthorizationMode;
return this;
}
- public Builder withoutAuthorizationChek()
+ public Builder withReadWriteCheck()
{
- this.withAuthorizationCheck = false;
+ this.withAuthorizationMode = AUTH_READ_WRITE;
return this;
}
+ public Builder withReadCheck()
+ {
+ this.withAuthorizationMode = AUTH_READ;
+ return this;
+ }
+
+ public Builder withNoCheck()
+ {
+ this.withAuthorizationMode = AUTH_NO_CHECK;
+ return this;
+ }
+
public UserNodeFilterConfig build()
{
return new UserNodeFilterConfig(this);
Modified: epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserPortal.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserPortal.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserPortal.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -132,6 +132,18 @@
throws UserPortalException, NavigationServiceException;
/**
+ * Returns the user node for the default path in specified navigation
+ *
+ * @param navigation the navigation
+ * @param filterConfig an optional filter
+ * @return the default navigation path
+ * @throws UserPortalException any user portal exception
+ * @throws NavigationServiceException any navigation service exception
+ */
+ UserNode getDefaultPath(UserNavigation navigation, UserNodeFilterConfig filterConfig)
+ throws UserPortalException, NavigationServiceException;
+
+ /**
* Resolves and returns a node among all user navigations for a specified path.
*
* @param filterConfig an optional filter
@@ -141,6 +153,7 @@
* @throws UserPortalException any user portal exception
* @throws NavigationServiceException any navigation service exception
*/
+ @Deprecated
UserNode resolvePath(UserNodeFilterConfig filterConfig, String path)
throws NullPointerException, UserPortalException, NavigationServiceException;
Modified: epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserPortalImpl.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserPortalImpl.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/user/UserPortalImpl.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -323,25 +323,36 @@
{
for (UserNavigation userNavigation : getNavigations())
{
- NavigationContext navigation = userNavigation.navigation;
- if (navigation.getState() != null)
+ UserNode node = getDefaultPath(userNavigation, filterConfig);
+ if (node != null)
{
- UserNodeContext context = new UserNodeContext(userNavigation, filterConfig);
- NodeContext<UserNode> nodeContext = service.getNavigationService().loadNode(context, navigation, Scope.CHILDREN, null);
- if (nodeContext != null)
- {
- UserNode root = nodeContext.getNode().filter();
- for (UserNode node : root.getChildren())
- {
- return node;
- }
- }
+ return node;
}
}
//
return null;
}
+
+ public UserNode getDefaultPath(UserNavigation userNavigation, UserNodeFilterConfig filterConfig) throws UserPortalException, NavigationServiceException
+ {
+ NavigationContext navigation = userNavigation.navigation;
+ if (navigation.getState() != null)
+ {
+ UserNodeContext context = new UserNodeContext(userNavigation, filterConfig);
+ NodeContext<UserNode> nodeContext = service.getNavigationService().loadNode(context, navigation, Scope.CHILDREN, null);
+ if (nodeContext != null)
+ {
+ UserNode root = nodeContext.getNode().filter();
+ for (UserNode node : root.getChildren())
+ {
+ return node;
+ }
+ }
+ }
+
+ return null;
+ }
public UserNode resolvePath(UserNodeFilterConfig filterConfig, String path)
throws NullPointerException, UserPortalException, NavigationServiceException
Modified: epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/mop/description/TestDescriptionService.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/mop/description/TestDescriptionService.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/mop/description/TestDescriptionService.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -34,6 +34,7 @@
import org.gatein.mop.api.workspace.Site;
import org.gatein.mop.core.api.MOPService;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@@ -121,6 +122,7 @@
//
assertEquals(null, svc.resolveDescription(id, null, Locale.GERMAN));
+ assertEquals(null, svc.resolveDescription(id, null, new Locale("", "GB")));
assertEquals(new Described.State("name_en", null), svc.resolveDescription(id, Locale.ENGLISH, Locale.GERMAN));
assertEquals(new Described.State("name_en_GB", null), svc.resolveDescription(id, Locale.UK, Locale.GERMAN));
assertEquals(new Described.State("name_en", null), svc.resolveDescription(id, Locale.US, Locale.GERMAN));
@@ -220,6 +222,34 @@
assertEquals("foo_english", desc.getName());
}
+ public void testSetInvalidLocaleDescription() throws Exception
+ {
+ DescriptionService svc = new DescriptionServiceImpl(mgr);
+ MOPService mop = mgr.getPOMService();
+ Site portal = mop.getModel().getWorkspace().addSite(ObjectType.PORTAL_SITE, "foo");
+ Navigation nav = portal.getRootNavigation().addChild("default");
+
+ //
+ try
+ {
+ svc.setDescription(nav.getObjectId(), new Locale("", "GB"), new Described.State("foo_invalid", null));
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+
+ //
+ try
+ {
+ svc.setDescription(nav.getObjectId(), new Locale("en", "GB", "variant"), new Described.State("foo_invalid", null));
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
public void testAddLocalizedDescription() throws Exception
{
DescriptionService svc = new DescriptionServiceImpl(mgr);
@@ -300,4 +330,30 @@
assertEquals(Tools.toSet(Locale.ENGLISH), description.keySet());
assertEquals(new Described.State("bar_english_2", null), description.get(Locale.ENGLISH));
}
+
+ public void testSetInvalidLocaleDescriptions() throws Exception
+ {
+ DescriptionService svc = new DescriptionServiceImpl(mgr);
+ MOPService mop = mgr.getPOMService();
+ Site portal = mop.getModel().getWorkspace().addSite(ObjectType.PORTAL_SITE, "foo");
+ Navigation nav = portal.getRootNavigation().addChild("default");
+
+ //
+ try
+ {
+ svc.setDescriptions(nav.getObjectId(), Collections.singletonMap(new Locale("", "GB"), new Described.State("bar_invalid", null)));
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ try
+ {
+ svc.setDescriptions(nav.getObjectId(), Collections.singletonMap(new Locale("en", "GB", "variant"), new Described.State("bar_invalid", null)));
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
}
Modified: epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/mop/user/TestUserPortal.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/mop/user/TestUserPortal.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/mop/user/TestUserPortal.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -184,7 +184,7 @@
{
new UnitTest()
{
- public void execute() throws Exception
+ public void doExecute() throws Exception
{
UserPortalConfig userPortalCfg = userPortalConfigSer_.getUserPortalConfig("classic", getUserId());
Map<SiteKey, UserNavigation> navigations = toMap(userPortalCfg);
@@ -208,7 +208,7 @@
{
UnitTest test = new UnitTest()
{
- public void execute() throws Exception
+ public void doExecute() throws Exception
{
UserPortalConfig userPortalCfg = userPortalConfigSer_.getUserPortalConfig("classic", getUserId());
UserPortal portal = userPortalCfg.getUserPortal();
@@ -223,35 +223,97 @@
//
test.execute("root");
- test.execute(null);
+ test.execute();
}
public void testFilterWithVisibility()
{
- UnitTest test = new UnitTest()
+ class Test extends UnitTest
{
- public void execute() throws Exception
+
+ final int authorizationMode;
+ final boolean guest;
+ final boolean displayedGuest;
+ final boolean systemGuest;
+ final boolean systemUsers;
+ final Visibility[] visibilities;
+
+ Test(int authorizationMode, boolean guest, boolean displayedGuest, boolean systemGuest, boolean systemUsers)
{
+ this(authorizationMode, guest, displayedGuest, systemGuest, systemUsers, (Visibility[])null);
+ }
+
+ Test(int authorizationMode, boolean guest, boolean displayedGuest, boolean systemGuest, boolean systemUsers, Visibility... visibilities)
+ {
+ this.authorizationMode = authorizationMode;
+ this.guest = guest;
+ this.displayedGuest = displayedGuest;
+ this.systemGuest = systemGuest;
+ this.systemUsers = systemUsers;
+ this.visibilities = visibilities;
+ }
+
+ public void doExecute() throws Exception
+ {
UserPortalConfig userPortalCfg = userPortalConfigSer_.getUserPortalConfig("system", getUserId());
UserPortal portal = userPortalCfg.getUserPortal();
UserNavigation nav = portal.getNavigation(SiteKey.portal("system"));
//
- UserNode root = portal.getNode(nav, Scope.ALL, UserNodeFilterConfig.builder().withVisibility(Visibility.DISPLAYED).build(), null);
- assertNotNull(root.getChild("home"));
- assertNotNull(root.getChild("sitemap"));
- assertNull(root.getChild("groupnavigation"));
+ UserNodeFilterConfig.Builder builder = UserNodeFilterConfig.builder().withAuthMode(authorizationMode);
+ if (visibilities != null)
+ {
+ builder.withVisibility(visibilities);
+ }
+ UserNodeFilterConfig config = builder.build();
//
- root = portal.getNode(nav, Scope.ALL, UserNodeFilterConfig.builder().withVisibility(Visibility.DISPLAYED, Visibility.SYSTEM).build(), null);
- assertNotNull(root.getChild("home"));
- assertNotNull(root.getChild("sitemap"));
- assertNotNull(root.getChild("groupnavigation"));
+ UserNode root = portal.getNode(nav, Scope.ALL, config, null);
+ assertEquals(guest, root.getChild("guest") != null);
+ assertEquals(displayedGuest, root.getChild("displayed_guest") != null);
+ assertEquals(systemGuest, root.getChild("system_guest") != null);
+ assertEquals(systemUsers, root.getChild("system_users") != null);
+
+ //
+ assertEquals(guest, portal.resolvePath(nav, config, "guest") != null);
+ assertEquals(displayedGuest, portal.resolvePath(nav, config, "displayed_guest") != null);
+ assertEquals(systemGuest, portal.resolvePath(nav, config, "system_guest") != null);
+ assertEquals(systemUsers, portal.resolvePath(nav, config, "system_users") != null);
}
- };
+ }
//
- test.execute("root");
+ new Test(UserNodeFilterConfig.AUTH_NO_CHECK, true, true, true, true).execute();
+ new Test(UserNodeFilterConfig.AUTH_NO_CHECK, true, true, true, true).execute("root");
+ new Test(UserNodeFilterConfig.AUTH_NO_CHECK, true, true, true, true).execute("demo");
+ new Test(UserNodeFilterConfig.AUTH_NO_CHECK, true, true, false, false, Visibility.DISPLAYED).execute();
+ new Test(UserNodeFilterConfig.AUTH_NO_CHECK, true, true, false, false, Visibility.DISPLAYED).execute("root");
+ new Test(UserNodeFilterConfig.AUTH_NO_CHECK, true, true, false, false, Visibility.DISPLAYED).execute("demo");
+ new Test(UserNodeFilterConfig.AUTH_NO_CHECK, true, true, true, true, Visibility.DISPLAYED, Visibility.SYSTEM).execute();
+ new Test(UserNodeFilterConfig.AUTH_NO_CHECK, true, true, true, true, Visibility.DISPLAYED, Visibility.SYSTEM).execute("root");
+ new Test(UserNodeFilterConfig.AUTH_NO_CHECK, true, true, true, true, Visibility.DISPLAYED, Visibility.SYSTEM).execute("demo");
+
+ //
+ new Test(UserNodeFilterConfig.AUTH_READ, true, true, true, false).execute();
+ new Test(UserNodeFilterConfig.AUTH_READ, true, true, true, true).execute("root");
+ new Test(UserNodeFilterConfig.AUTH_READ, true, true, true, true).execute("demo");
+ new Test(UserNodeFilterConfig.AUTH_READ, true, true, false, false, Visibility.DISPLAYED).execute();
+ new Test(UserNodeFilterConfig.AUTH_READ, true, true, false, false, Visibility.DISPLAYED).execute("root");
+ new Test(UserNodeFilterConfig.AUTH_READ, true, true, false, false, Visibility.DISPLAYED).execute("demo");
+ new Test(UserNodeFilterConfig.AUTH_READ, true, true, true, false, Visibility.DISPLAYED, Visibility.SYSTEM).execute();
+ new Test(UserNodeFilterConfig.AUTH_READ, true, true, true, true, Visibility.DISPLAYED, Visibility.SYSTEM).execute("root");
+ new Test(UserNodeFilterConfig.AUTH_READ, true, true, true, true, Visibility.DISPLAYED, Visibility.SYSTEM).execute("demo");
+
+ //
+ new Test(UserNodeFilterConfig.AUTH_READ_WRITE, true, true, false, false).execute();
+ new Test(UserNodeFilterConfig.AUTH_READ_WRITE, true, true, true, true).execute("root");
+ new Test(UserNodeFilterConfig.AUTH_READ_WRITE, true, true, false, false).execute("demo");
+ new Test(UserNodeFilterConfig.AUTH_READ_WRITE, true, true, false, false, Visibility.DISPLAYED).execute();
+ new Test(UserNodeFilterConfig.AUTH_READ_WRITE, true, true, false, false, Visibility.DISPLAYED).execute("root");
+ new Test(UserNodeFilterConfig.AUTH_READ_WRITE, true, true, false, false, Visibility.DISPLAYED).execute("demo");
+ new Test(UserNodeFilterConfig.AUTH_READ_WRITE, true, true, false, false, Visibility.DISPLAYED, Visibility.SYSTEM).execute();
+ new Test(UserNodeFilterConfig.AUTH_READ_WRITE, true, true, true, true, Visibility.DISPLAYED, Visibility.SYSTEM).execute("root");
+ new Test(UserNodeFilterConfig.AUTH_READ_WRITE, true, true, false, false, Visibility.DISPLAYED, Visibility.SYSTEM).execute("demo");
}
public void testFilterWithAuthorizationCheck()
@@ -263,14 +325,14 @@
boolean pass = true;
@Override
- protected void execute() throws Exception
+ protected void doExecute() throws Exception
{
UserPortalConfig userPortalCfg = userPortalConfigSer_.getUserPortalConfig("classic", getUserId());
UserPortal portal = userPortalCfg.getUserPortal();
UserNavigation nav = portal.getNavigation(SiteKey.group("/platform/administrators"));
//
- UserNode root = portal.getNode(nav, Scope.ALL, UserNodeFilterConfig.builder().withAuthorizationCheck().build(), null);
+ UserNode root = portal.getNode(nav, Scope.ALL, UserNodeFilterConfig.builder().withReadWriteCheck().build(), null);
pass &= root.getChild("administration") != null;
pass &= root.getChild("administration").getChild("communityManagement") != null;
}
@@ -291,7 +353,7 @@
{
UnitTest test = new UnitTest()
{
- public void execute() throws Exception
+ public void doExecute() throws Exception
{
UserPortalConfig userPortalCfg = userPortalConfigSer_.getUserPortalConfig("system", getUserId());
UserPortal portal = userPortalCfg.getUserPortal();
@@ -304,9 +366,9 @@
//
portal.updateNode(root, Scope.ALL, null);
assertTrue(root.hasChildrenRelationship());
- assertNotNull(root.getChild("home"));
- assertNotNull(root.getChild("sitemap"));
- assertNull(root.getChild("groupnavigation"));
+ assertNotNull(root.getChild("guest"));
+ assertNotNull(root.getChild("displayed_guest"));
+ assertNull(root.getChild("system_users"));
}
};
@@ -386,7 +448,7 @@
{
new UnitTest()
{
- public void execute() throws Exception
+ public void doExecute() throws Exception
{
UserPortalConfig userPortalCfg = userPortalConfigSer_.getUserPortalConfig("classic", getUserId());
UserPortal userPortal = userPortalCfg.getUserPortal();
@@ -405,7 +467,7 @@
{
new UnitTest()
{
- public void execute() throws Exception
+ public void doExecute() throws Exception
{
UserPortalConfig userPortalCfg = userPortalConfigSer_.getUserPortalConfig("classic", getUserId());
UserPortal userPortal = userPortalCfg.getUserPortal();
@@ -446,7 +508,7 @@
{
new UnitTest()
{
- public void execute() throws Exception
+ public void doExecute() throws Exception
{
UserPortalConfig userPortalCfg = userPortalConfigSer_.getUserPortalConfig("limited", getUserId());
UserPortal userPortal = userPortalCfg.getUserPortal();
@@ -460,9 +522,9 @@
assertEquals(SiteKey.portal("limited"), nav.getNavigation().getKey());
assertEquals("foo", nav.getName());
- // With authentication
+ // With read auth
UserNodeFilterConfig.Builder builder = UserNodeFilterConfig.builder();
- builder.withAuthorizationCheck();
+ builder.withReadCheck();
UserNodeFilterConfig filterConfig = builder.build();
nav = userPortal.resolvePath(filterConfig, "/");
@@ -470,9 +532,27 @@
assertEquals("bar", nav.getName());
nav = userPortal.resolvePath(filterConfig, "/foo");
+ assertNull(nav);
+
+ nav = userPortal.resolvePath(filterConfig, "/bit");
assertEquals(SiteKey.portal("limited"), nav.getNavigation().getKey());
- assertEquals("foo", nav.getName());
+ assertEquals("bit", nav.getName());
+ // With read and write auth
+ builder = UserNodeFilterConfig.builder();
+ builder.withReadWriteCheck();
+ filterConfig = builder.build();
+
+ nav = userPortal.resolvePath(filterConfig, "/");
+ assertEquals(SiteKey.portal("limited"), nav.getNavigation().getKey());
+ assertEquals("bit", nav.getName());
+
+ nav = userPortal.resolvePath(filterConfig, "/foo");
+ assertNull(nav);
+
+ nav = userPortal.resolvePath(filterConfig, "/bar");
+ assertNull(nav);
+
nav = userPortal.resolvePath(filterConfig, "/bit");
assertEquals(SiteKey.portal("limited"), nav.getNavigation().getKey());
assertEquals("bit", nav.getName());
@@ -484,7 +564,7 @@
{
new UnitTest()
{
- public void execute() throws Exception
+ public void doExecute() throws Exception
{
UserPortalConfig userPortalCfg = userPortalConfigSer_.getUserPortalConfig("classic", getUserId());
UserPortal userPortal = userPortalCfg.getUserPortal();
@@ -515,7 +595,7 @@
{
new UnitTest()
{
- public void execute() throws Exception
+ public void doExecute() throws Exception
{
SimpleUserPortalContext ctx = new SimpleUserPortalContext(Locale.ENGLISH);
Map<String, Object> map = new HashMap<String, Object>();
@@ -542,7 +622,7 @@
{
new UnitTest()
{
- public void execute() throws Exception
+ public void doExecute() throws Exception
{
UserPortalContext ctx = new SimpleUserPortalContext(Locale.ENGLISH);
UserPortal portal = userPortalConfigSer_.getUserPortalConfig("extended", getUserId(), ctx).getUserPortal();
@@ -569,7 +649,7 @@
{
new UnitTest()
{
- public void execute() throws Exception
+ public void doExecute() throws Exception
{
UserPortalConfig userPortalCfg = userPortalConfigSer_.getUserPortalConfig("classic", getUserId());
UserPortal userPortal = userPortalCfg.getUserPortal();
@@ -618,7 +698,7 @@
{
new UnitTest()
{
- public void execute() throws Exception
+ public void doExecute() throws Exception
{
UserPortalConfig userPortalCfg = userPortalConfigSer_.getUserPortalConfig("test", getUserId());
UserPortal userPortal = userPortalCfg.getUserPortal();
@@ -654,7 +734,7 @@
{
new UnitTest()
{
- public void execute() throws Exception
+ public void doExecute() throws Exception
{
storage_.create(new PortalConfig("portal", "usernode_recursive"));
end(true);
@@ -710,7 +790,7 @@
{
new UnitTest()
{
- public void execute() throws Exception
+ public void doExecute() throws Exception
{
storage_.create(new PortalConfig("portal", "usernode_invalidate_uri"));
end(true);
@@ -771,7 +851,7 @@
{
new UnitTest()
{
- public void execute() throws Exception
+ public void doExecute() throws Exception
{
storage_.create(new PortalConfig("portal", "node_extension"));
end(true);
@@ -829,7 +909,7 @@
new UnitTest()
{
- public void execute() throws Exception
+ public void doExecute() throws Exception
{
storage_.create(new PortalConfig("portal", "cache_invalidation"));
end(true);
@@ -859,7 +939,7 @@
new UnitTest()
{
@Override
- protected void execute() throws Exception
+ protected void doExecute() throws Exception
{
UserPortalConfig userPortalCfg = userPortalConfigSer_.getUserPortalConfig("classic", getUserId());
UserPortal portal = userPortalCfg.getUserPortal();
@@ -1529,6 +1609,11 @@
/** . */
private String userId;
+ protected final void execute()
+ {
+ execute(null);
+ }
+
protected final void execute(String userId)
{
Throwable failure = null;
@@ -1561,7 +1646,7 @@
ConversationState.setCurrent(conversationState);
try
{
- execute();
+ doExecute();
}
catch (Exception e)
{
@@ -1590,7 +1675,7 @@
return userId;
}
- protected abstract void execute() throws Exception;
+ protected abstract void doExecute() throws Exception;
}
}
Modified: epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/org/exoplatform/portal/mop/user/portal/limited/navigation.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/org/exoplatform/portal/mop/user/portal/limited/navigation.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/org/exoplatform/portal/mop/user/portal/limited/navigation.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -33,10 +33,11 @@
<page-reference>portal::limited::foo</page-reference>
</node>
- <!-- Node with /platform/user permission -->
+ <!-- Node SYSTEM with /platform/user permission -->
<node>
<uri>bar</uri>
<name>bar</name>
+ <visibility>SYSTEM</visibility>
<page-reference>portal::limited::bar</page-reference>
</node>
Modified: epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/org/exoplatform/portal/mop/user/portal/system/navigation.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/org/exoplatform/portal/mop/user/portal/system/navigation.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/org/exoplatform/portal/mop/user/portal/system/navigation.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -18,30 +18,30 @@
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
-<node-navigation>
- <owner-type>portal</owner-type>
- <owner-id>system</owner-id>
+<node-navigation
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2 http://www.gatein.org/xml/ns/gatein_objects_1_2"
+ xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2">
<priority>1</priority>
<page-nodes>
<node>
- <uri>home</uri>
- <name>home</name>
- <label>#{portal.classic.home}</label>
- <page-reference>portal::classic::homepage</page-reference>
+ <name>guest</name>
+ <page-reference>portal::system::everyone</page-reference>
</node>
<node>
- <uri>sitemap</uri>
- <name>sitemap</name>
- <label>#{portal.classic.sitemap}</label>
+ <name>displayed_guest</name>
<visibility>DISPLAYED</visibility>
- <page-reference>portal::classic::sitemap</page-reference>
+ <page-reference>portal::system::everyone</page-reference>
</node>
<node>
- <uri>groupnavigation</uri>
- <name>groupnavigation</name>
- <label>#{portal.classic.groupnavigation}</label>
+ <name>system_guest</name>
<visibility>SYSTEM</visibility>
- <page-reference>portal::classic::groupnavigation</page-reference>
+ <page-reference>portal::system::everyone</page-reference>
</node>
+ <node>
+ <name>system_users</name>
+ <visibility>SYSTEM</visibility>
+ <page-reference>portal::system::users</page-reference>
+ </node>
</page-nodes>
</node-navigation>
Modified: epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/org/exoplatform/portal/mop/user/portal/system/pages.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/org/exoplatform/portal/mop/user/portal/system/pages.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/org/exoplatform/portal/mop/user/portal/system/pages.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -18,5 +18,23 @@
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
-<page-set>
+<page-set
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2 http://www.gatein.org/xml/ns/gatein_objects_1_2"
+ xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2">
+ <page>
+ <name>everyone</name>
+ <access-permissions>Everyone</access-permissions>
+ <edit-permission>*:/platform/administrators</edit-permission>
+ </page>
+ <page>
+ <name>users</name>
+ <access-permissions>*:/platform/users</access-permissions>
+ <edit-permission>*:/platform/administrators</edit-permission>
+ </page>
+ <page>
+ <name>administrators</name>
+ <access-permissions>*:/platform/administrators</access-permissions>
+ <edit-permission>*:/platform/administrators</edit-permission>
+ </page>
</page-set>
Modified: epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/org/exoplatform/portal/mop/user/portal/system/portal.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/org/exoplatform/portal/mop/user/portal/system/portal.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/org/exoplatform/portal/mop/user/portal/system/portal.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -18,14 +18,13 @@
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
-<portal-config>
+<portal-config
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2 http://www.gatein.org/xml/ns/gatein_objects_1_2"
+ xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2">
<portal-name>system</portal-name>
<locale>en</locale>
- <access-permissions>test_access_permissions</access-permissions>
- <edit-permission>test_edit_permission</edit-permission>
- <skin>test_skin</skin>
-
+ <access-permissions>Everyone</access-permissions>
<portal-layout>
</portal-layout>
-
-</portal-config>
+</portal-config>
\ No newline at end of file
Modified: epp/portal/branches/EPP_5_2_Branch/component/resources/pom.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/resources/pom.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/resources/pom.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -41,8 +41,11 @@
<groupId>org.exoplatform.kernel</groupId>
<artifactId>exo.kernel.component.cache</artifactId>
</dependency>
-
<dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.common</artifactId>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
Modified: epp/portal/branches/EPP_5_2_Branch/component/resources/src/main/java/org/exoplatform/services/resources/LocaleConfig.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/resources/src/main/java/org/exoplatform/services/resources/LocaleConfig.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/resources/src/main/java/org/exoplatform/services/resources/LocaleConfig.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -57,6 +57,8 @@
public String getLocaleName();
+ public String getTagIdentifier();
+
public ResourceBundle getResourceBundle(String name);
public ResourceBundle getMergeResourceBundle(String[] names);
Modified: epp/portal/branches/EPP_5_2_Branch/component/resources/src/main/java/org/exoplatform/services/resources/LocaleContextInfo.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/resources/src/main/java/org/exoplatform/services/resources/LocaleContextInfo.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/resources/src/main/java/org/exoplatform/services/resources/LocaleContextInfo.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -39,6 +39,7 @@
private String remoteUser;
private Locale portalLocale;
private Locale sessionLocale;
+ private Locale requestLocale;
/**
* Setter for supportedLocales
@@ -165,8 +166,26 @@
{
return sessionLocale;
}
+
+ /**
+ * Getter for requestLocale
+ * @return requestLocale
+ */
+ public Locale getRequestLocale()
+ {
+ return requestLocale;
+ }
/**
+ * Setter for requestLocale
+ * @param requestLocale default locale configured for the request
+ */
+ public void setRequestLocale(Locale requestLocale)
+ {
+ this.requestLocale = requestLocale;
+ }
+
+ /**
* Helper method that returns the locale only if it's supported by portal.
* Otherwise it returns null.
*
Modified: epp/portal/branches/EPP_5_2_Branch/component/resources/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigImpl.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/resources/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigImpl.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/resources/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigImpl.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -19,6 +19,7 @@
package org.exoplatform.services.resources.impl;
+import org.exoplatform.commons.utils.I18N;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.services.resources.LocaleConfig;
import org.exoplatform.services.resources.Orientation;
@@ -59,6 +60,8 @@
private String localeName_;
+ private String tagIdentifier_;
+
private Orientation orientation;
public LocaleConfigImpl()
@@ -117,12 +120,20 @@
if (localeParams.length > 1)
{
locale_ = new Locale(localeParams[0], localeParams[1]);
- }else{
+ }
+ else
+ {
locale_ = new Locale(localeName);
}
+ tagIdentifier_ = I18N.toTagIdentifier(locale_);
}
}
+ public String getTagIdentifier()
+ {
+ return tagIdentifier_;
+ }
+
public final String getLanguage()
{
return locale_.getLanguage();
Deleted: epp/portal/branches/EPP_5_2_Branch/component/resources/src/test/java/conf/exo.portal.component.resources-configuration.xml
===================================================================
Deleted: epp/portal/branches/EPP_5_2_Branch/component/resources/src/test/java/conf/locales-config.xml
===================================================================
Deleted: epp/portal/branches/EPP_5_2_Branch/component/resources/src/test/java/resources/locales-config.xml
===================================================================
Modified: epp/portal/branches/EPP_5_2_Branch/component/test/core/src/main/java/org/exoplatform/component/test/AbstractGateInTest.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/test/core/src/main/java/org/exoplatform/component/test/AbstractGateInTest.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/test/core/src/main/java/org/exoplatform/component/test/AbstractGateInTest.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -29,7 +29,7 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
*/
-public abstract class AbstractGateInTest extends TestCase
+public abstract class AbstractGateInTest extends BaseGateInTest
{
/** . */
Copied: epp/portal/branches/EPP_5_2_Branch/component/test/core/src/main/java/org/exoplatform/component/test/BaseGateInTest.java (from rev 7117, portal/trunk/component/test/core/src/main/java/org/exoplatform/component/test/BaseGateInTest.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/test/core/src/main/java/org/exoplatform/component/test/BaseGateInTest.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/test/core/src/main/java/org/exoplatform/component/test/BaseGateInTest.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.component.test;
+
+import junit.framework.Assert;
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class BaseGateInTest extends TestCase
+{
+
+ public BaseGateInTest()
+ {
+ }
+
+ public BaseGateInTest(String name)
+ {
+ super(name);
+ }
+
+ public static <T> T assertInstanceOf(Object o, Class<T> expectedType)
+ {
+ if (expectedType != null)
+ {
+ if (expectedType.isInstance(o))
+ {
+ fail();
+ return null;
+ }
+ else
+ {
+ return expectedType.cast(o);
+ }
+ }
+ else
+ {
+ fail("Need an expected type");
+ return null;
+ }
+ }
+
+ public static <T> T fail(String msg, Throwable t)
+ {
+ AssertionFailedError afe = new AssertionFailedError(msg);
+ afe.initCause(t);
+ throw afe;
+ }
+
+ public static <T> T fail(Throwable t)
+ {
+ AssertionFailedError afe = new AssertionFailedError();
+ afe.initCause(t);
+ throw afe;
+ }
+}
Modified: epp/portal/branches/EPP_5_2_Branch/component/web/controller/pom.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/pom.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/pom.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -40,5 +40,32 @@
<groupId>org.exoplatform.portal</groupId>
<artifactId>exo.portal.component.web.resources</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.portal</artifactId>
+ </dependency>
+ <!-- Used only for pretty printing, need to find a better solution than this -->
+<!--
+ <dependency>
+ <groupId>net.java.dev.stax-utils</groupId>
+ <artifactId>stax-utils</artifactId>
+ <version>20060502</version>
+ <exclusions>
+ <exclusion>
+ <groupId>com.bea.xml</groupId>
+ <artifactId>jsr173-ri</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+-->
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.test.core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.staxnav</groupId>
+ <artifactId>staxnav.core</artifactId>
+ </dependency>
</dependencies>
</project>
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/conf/portal/configuration.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/conf/portal/configuration.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/conf/portal/configuration.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-
-<configuration
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
- xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
-
- <component>
- <type>org.exoplatform.web.WebAppController</type>
- </component>
-
-</configuration>
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/gatein_controller_1_0.xsd (from rev 7117, portal/trunk/component/web/controller/src/main/java/gatein_controller_1_0.xsd)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/gatein_controller_1_0.xsd (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/gatein_controller_1_0.xsd 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,115 @@
+<?xml version="1.0"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+
+<xs:schema
+ targetNamespace="http://www.gatein.org/xml/ns/gatein_controller_1_0"
+ xmlns="http://www.gatein.org/xml/ns/gatein_controller_1_0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0">
+
+ <xs:element name="controller" type="controllerType" />
+
+ <xs:complexType name="controllerType">
+ <xs:sequence>
+ <xs:element name="route" type="routeType" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="separator-escape" use="optional">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="_"/>
+ <xs:enumeration value="."/>
+ <xs:enumeration value="-"/>
+ <xs:enumeration value="~"/>
+ <xs:enumeration value="!"/>
+ <xs:enumeration value="$"/>
+ <xs:enumeration value="&"/>
+ <xs:enumeration value="+"/>
+ <xs:enumeration value=":"/>
+ <xs:enumeration value="@"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ </xs:complexType>
+
+ <xs:complexType name="routeType">
+ <xs:sequence>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="route-param" type="routeParamType" minOccurs="1" maxOccurs="1"/>
+ <xs:element name="path-param" type="pathParamType" minOccurs="1" maxOccurs="1"/>
+ <xs:element name="request-param" type="requestParamType" minOccurs="1" maxOccurs="1"/>
+ </xs:choice>
+ <xs:element name="route" type="routeType" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="path" type="xs:string" use="required"/>
+ </xs:complexType>
+
+ <xs:complexType name="routeParamType">
+ <xs:choice minOccurs="1" maxOccurs="1">
+ <xs:element name="value" type="xs:string"/>
+ </xs:choice>
+ <xs:attribute name="qname" type="xs:string" use="required"/>
+ </xs:complexType>
+
+ <xs:complexType name="pathParamType">
+ <xs:choice minOccurs="0" maxOccurs="1">
+ <xs:element name="pattern" type="xs:string"/>
+ </xs:choice>
+ <xs:attribute name="qname" type="xs:string" use="required"/>
+ <xs:attribute name="encoding" use="optional">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="default-form"/>
+ <xs:enumeration value="preserve-path"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ </xs:complexType>
+
+ <xs:complexType name="requestParamType">
+ <xs:choice minOccurs="0" maxOccurs="1">
+ <xs:element name="value" type="xs:string"/>
+ <xs:element name="pattern" type="xs:string"/>
+ </xs:choice>
+ <xs:attribute name="qname" type="xs:string" use="required"/>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="control-mode" type="controlModeType" use="optional"/>
+ <xs:attribute name="value-mapping" type="valueMappingType" use="optional"/>
+ </xs:complexType>
+
+ <xs:simpleType name="valueMappingType">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="canonical" />
+ <xs:enumeration value="never-empty" />
+ <xs:enumeration value="never-null" />
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="controlModeType">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="optional" />
+ <xs:enumeration value="required" />
+ </xs:restriction>
+ </xs:simpleType>
+
+</xs:schema>
\ No newline at end of file
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/ControllerContext.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/ControllerContext.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/ControllerContext.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/ControllerContext.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web;
+
+import org.exoplatform.web.controller.QualifiedName;
+import org.exoplatform.web.controller.router.Router;
+import org.exoplatform.web.controller.router.URIWriter;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ControllerContext
+{
+
+ /** . */
+ private final HttpServletRequest request;
+
+ /** . */
+ private final HttpServletResponse response;
+
+ /** . */
+ private final WebAppController controller;
+
+ /** . */
+ private final Router router;
+
+ /** . */
+ private final Map<QualifiedName, String> parameters;
+
+ /** . */
+ private final String contextName;
+
+ public ControllerContext(
+ WebAppController controller,
+ Router router,
+ HttpServletRequest request,
+ HttpServletResponse response,
+ Map<QualifiedName, String> parameters)
+ {
+ this.controller = controller;
+ this.request = request;
+ this.response = response;
+ this.parameters = parameters;
+ this.contextName = request.getContextPath().substring(1);
+ this.router = router;
+ }
+
+ public WebAppController getController()
+ {
+ return controller;
+ }
+
+ public HttpServletRequest getRequest()
+ {
+ return request;
+ }
+
+ public HttpServletResponse getResponse()
+ {
+ return response;
+ }
+
+ public String getParameter(QualifiedName parameter)
+ {
+ return parameters.get(parameter);
+ }
+
+ public void renderURL(Map<QualifiedName, String> parameters, URIWriter renderContext) throws IOException
+ {
+ renderContext.append('/');
+
+ //
+ renderContext.appendSegment(contextName);
+
+ //
+ router.render(parameters, renderContext);
+ }
+}
Modified: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/WebAppController.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/WebAppController.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/WebAppController.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -19,52 +19,108 @@
package org.exoplatform.web;
+import org.exoplatform.commons.utils.Safe;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.container.component.RequestLifeCycle;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.ValueParam;
+import org.exoplatform.management.annotations.Impact;
+import org.exoplatform.management.annotations.ImpactType;
+import org.exoplatform.management.annotations.Managed;
+import org.exoplatform.management.annotations.ManagedDescription;
+import org.exoplatform.management.annotations.ManagedName;
+import org.exoplatform.management.jmx.annotations.NameTemplate;
+import org.exoplatform.management.jmx.annotations.Property;
+import org.exoplatform.management.rest.annotations.RESTEndpoint;
import org.exoplatform.web.application.Application;
+import org.exoplatform.web.controller.QualifiedName;
+import org.exoplatform.web.controller.metadata.DescriptorBuilder;
+import org.exoplatform.web.controller.metadata.ControllerDescriptor;
+import org.exoplatform.web.controller.router.RouterConfigException;
+import org.exoplatform.web.controller.router.Router;
+import org.gatein.common.http.QueryStringParser;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
- * Created by The eXo Platform SAS
- * Mar 21, 2007
- *
- * The WebAppController is the entry point of the eXo web framework
- *
- * It also stores WebRequestHandlers, Attributes and deployed Applications
- *
+ * The WebAppController is the entry point of the GateIn service.
*/
+@Managed
+@ManagedDescription("The portal controller")
+@NameTemplate({
+ @Property(key = "view", value = "portal"),
+ @Property(key = "service", value = "controller")})
+@RESTEndpoint(path = "portalcontroller")
public class WebAppController
{
- protected static Log log = ExoLogger.getLogger("portal:WebAppController");
+ /** . */
+ public static final QualifiedName HANDLER_PARAM = QualifiedName.create("gtn", "handler");
- private HashMap<String, Object> attributes_;
+ /** . */
+ protected static Logger log = LoggerFactory.getLogger(WebAppController.class);
+ /** . */
+ private final HashMap<String, Object> attributes_;
+
+ /** . */
private volatile HashMap<String, Application> applications_;
- private HashMap<String, WebRequestHandler> handlers_;
+ /** . */
+ private final HashMap<String, WebRequestHandler> handlers;
+ /** . */
+ private final AtomicReference<Router> routerRef;
+
+ /** . */
+ private final AtomicReference<String> configurationPathRef;
+
/**
* The WebAppControler along with the PortalRequestHandler defined in the init() method of the
* PortalController servlet (controller.register(new PortalRequestHandler())) also add the
- * CommandHandler object that will listen for the incoming /command path in the URL
- *
- * @throws Exception
+ * CommandHandler object that will listen for the incoming /command path in the URL.
+ *
+ * @param params the init params
+ * @throws Exception any exception
*/
- public WebAppController() throws Exception
+ public WebAppController(InitParams params) throws Exception
{
- applications_ = new HashMap<String, Application>();
- attributes_ = new HashMap<String, Object>();
- handlers_ = new HashMap<String, WebRequestHandler>();
+ // Get router config
+ ValueParam routerConfig = params.getValueParam("controller.config");
+ if (routerConfig == null)
+ {
+ throw new IllegalArgumentException("No router param defined");
+ }
+ String configurationPath = routerConfig.getValue();
+
+ //
+ this.applications_ = new HashMap<String, Application>();
+ this.attributes_ = new HashMap<String, Object>();
+ this.handlers = new HashMap<String, WebRequestHandler>();
+ this.routerRef = new AtomicReference<Router>();
+ this.configurationPathRef = new AtomicReference<String>(configurationPath);
+
+ //
+ reloadConfiguration();
}
public Object getAttribute(String name, Object value)
@@ -94,6 +150,96 @@
applications_.remove(appId);
}
+ @Managed
+ @ManagedDescription("The configuration path")
+ public String getConfigurationPath()
+ {
+ return String.valueOf(configurationPathRef.get());
+ }
+
+ @Managed
+ @ManagedDescription("Load the controller configuration")
+ @Impact(ImpactType.WRITE)
+ public void loadConfiguration(@ManagedDescription("The configuration path") @ManagedName("path") String path) throws IOException, RouterConfigException
+ {
+ File f = new File(path);
+ if (!f.exists())
+ {
+ throw new MalformedURLException("Could not resolve path " + path);
+ }
+ if (!f.isFile())
+ {
+ throw new MalformedURLException("Could not resolve path " + path + " to a valid file");
+ }
+ loadConfiguration(f.toURI().toURL());
+ configurationPathRef.set(path);
+ }
+
+ private void loadConfiguration(URL url) throws RouterConfigException, IOException
+ {
+ log.info("Loading router configuration " + url);
+ InputStream in = url.openStream();
+ try
+ {
+ ControllerDescriptor routerDesc = new DescriptorBuilder().build(in);
+ Router router = new Router(routerDesc);
+ routerRef.set(router);
+ }
+ finally
+ {
+ Safe.close(in);
+ }
+ }
+
+ @Managed
+ @ManagedDescription("Reload the controller configuration")
+ @Impact(ImpactType.WRITE)
+ public void reloadConfiguration() throws RouterConfigException, IOException
+ {
+ log.info("Loading router configuration " + configurationPathRef.get());
+ loadConfiguration(configurationPathRef.get());
+ }
+
+ @Managed
+ @ManagedDescription("Enumerates the routes found for the specified request")
+ @Impact(ImpactType.READ)
+ public String findRoutes(@ManagedDescription("The request uri relative to the web application") @ManagedName("uri") String uri)
+ {
+ Router router = routerRef.get();
+ if (router != null)
+ {
+ Map<String, String[]> parameters;
+ String path;
+ int pos = uri.indexOf('?');
+ if (pos != -1)
+ {
+ parameters = QueryStringParser.getInstance().parseQueryString(uri.substring(pos + 1));
+ path = uri.substring(0, pos);
+ }
+ else
+ {
+ parameters = Collections.emptyMap();
+ path = uri;
+ }
+
+ //
+ List<Map<QualifiedName, String>> results = new ArrayList<Map<QualifiedName, String>>();
+ Iterator<Map<QualifiedName, String>> matcher = router.matcher(path, parameters);
+ while (matcher.hasNext())
+ {
+ Map<QualifiedName, String> match = matcher.next();
+ results.add(match);
+ }
+
+ //
+ return results.toString();
+ }
+ else
+ {
+ throw new IllegalStateException("No route currently configured");
+ }
+ }
+
/**
* Add application (portlet, gadget) to the global application map if and only if it has
* not been registered yet.
@@ -124,50 +270,106 @@
return (T)result;
}
-
+
+ /**
+ * Register an handler as a component plugin, this method is invoked by the kernel with reflection.
+ *
+ * @param handler the handler
+ * @throws Exception any exception
+ */
public void register(WebRequestHandler handler) throws Exception
{
- for (String path : handler.getPath())
- handlers_.put(path, handler);
+ handlers.put(handler.getHandlerName(), handler);
}
public void unregister(String[] paths)
{
for (String path : paths)
- handlers_.remove(path);
+ handlers.remove(path);
}
+ public void onHandlersInit(ServletConfig config) throws Exception
+ {
+ Collection<WebRequestHandler> hls = handlers.values();
+ for (WebRequestHandler handler : hls)
+ {
+ handler.onInit(this, config);
+ }
+ }
+
/**
- * This is the first method - in the eXo web framework - reached by incoming HTTP request, it acts like a
- * servlet service() method
- *
- * According to the servlet path used the correct handler is selected and then executed.
- *
- * The event "exo.application.portal.start-http-request" and "exo.application.portal.end-http-request" are also sent
- * through the ListenerService and several listeners may listen to it.
- *
- * Finally a WindowsInfosContainer object using a ThreadLocal (from the portlet-container product) is created
+ * <p>This is the first method - in the GateIn portal - reached by incoming HTTP request, it acts like a
+ * servlet service() method. According to the servlet path used the correct handler is selected and then executed.</p>
+ *
+ * <p>During a request the request life cycle is demarcated by calls to {@link RequestLifeCycle#begin(ExoContainer);}
+ * and {@link RequestLifeCycle#end()}.</p>
+ *
+ * @param req the http request
+ * @param res the http response
+ * @throws Exception any exception
*/
public void service(HttpServletRequest req, HttpServletResponse res) throws Exception
{
- WebRequestHandler handler = handlers_.get(req.getServletPath());
- if (log.isDebugEnabled())
+ boolean debug = log.isDebugEnabled();
+ String portalPath = req.getRequestURI().substring(req.getContextPath().length());
+ Router router = routerRef.get();
+
+ //
+ if (router != null)
{
- log.debug("Servlet Path: " + req.getServletPath());
- log.debug("Handler used for this path: " + handler);
- }
- if (handler != null)
- {
- ExoContainer portalContainer = ExoContainerContext.getCurrentContainer();
- RequestLifeCycle.begin(portalContainer);
- try
+ Iterator<Map<QualifiedName, String>> matcher = router.matcher(portalPath, req.getParameterMap());
+
+ //
+ Map<QualifiedName, String> parameters = null;
+ if (matcher.hasNext())
{
- handler.execute(this, req, res);
+ parameters = matcher.next();
}
- finally
+
+ //
+ if (parameters != null)
{
- RequestLifeCycle.end();
+ String handlerKey = parameters.get(HANDLER_PARAM);
+ if (handlerKey != null)
+ {
+ WebRequestHandler handler = handlers.get(handlerKey);
+ if (handler != null)
+ {
+ if (debug)
+ {
+ log.debug("Serving request path=" + portalPath + ", parameters=" + parameters + " with handler " + handler);
+ }
+
+ //
+ RequestLifeCycle.begin(ExoContainerContext.getCurrentContainer());
+
+ //
+ try
+ {
+ handler.execute(new ControllerContext(this, router, req, res, parameters));
+ }
+ finally
+ {
+ RequestLifeCycle.end();
+ }
+ }
+ else
+ {
+ log.error("Invalid handler " + handlerKey + " for request path=" + portalPath + ", parameters=" + parameters);
+ res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ }
+ }
}
+ else
+ {
+ log.error("Could not associate the request path=" + portalPath + ", parameters=" + parameters + " with an handler");
+ res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ }
}
+ else
+ {
+ log.error("Missing valid router configuration " + configurationPathRef.get());
+ res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ }
}
}
Modified: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/WebRequestHandler.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/WebRequestHandler.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/WebRequestHandler.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -23,33 +23,48 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.util.Map;
+import javax.servlet.ServletConfig;
/**
- * Created by The eXo Platform SAS
- * Mar 21, 2007
- *
- * Abstract calss that one must implement if it want to provide a dedicated handler for a custom servlet path
- *
- * In case of portal the path is /portal but you could return your own from the getPath() method and hence the
- * WebAppController would use your own handler
- *
- * The execute method is to be overrided and the buisness logic should be handled here
+ * Abstract calss that one must implement if it want to provide a dedicated handler for serving custom requests.
+ * The execute method must be impemented and the serving logic should be handled here.
*/
abstract public class WebRequestHandler extends BaseComponentPlugin
{
-
- public void onInit(WebAppController controller) throws Exception
+ /**
+ * Init callback.
+ *
+ * @param controller the controller
+ * @param sConfig the servlet config
+ * @throws Exception any exception
+ */
+ public void onInit(WebAppController controller, ServletConfig sConfig) throws Exception
{
-
}
- abstract public String[] getPath();
+ /**
+ * Returns the handler name.
+ *
+ * @return the handler name
+ */
+ public abstract String getHandlerName();
- abstract public void execute(WebAppController app, HttpServletRequest req, HttpServletResponse res) throws Exception;
+ /**
+ * Execute a service.
+ *
+ * @param context the controller context
+ * @throws Exception any exception
+ */
+ abstract public void execute(ControllerContext context) throws Exception;
- public void onDestroy(WebAppController controler) throws Exception
+ /**
+ * Destroy callback.
+ *
+ * @param controller the controller
+ * @throws Exception any exception
+ */
+ public void onDestroy(WebAppController controller) throws Exception
{
-
- }
-
+ }
}
\ No newline at end of file
Modified: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/application/RequestContext.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/application/RequestContext.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/application/RequestContext.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -20,6 +20,9 @@
package org.exoplatform.web.application;
import org.exoplatform.services.resources.Orientation;
+import org.exoplatform.web.url.URLFactory;
+import org.exoplatform.web.url.PortalURL;
+import org.exoplatform.web.url.ResourceType;
import java.io.Writer;
import java.util.HashMap;
@@ -49,15 +52,22 @@
private Application app_;
- protected RequestContext parentAppRequestContext_;
+ protected final RequestContext parentAppRequestContext_;
private Map<String, Object> attributes;
public RequestContext(Application app)
{
- app_ = app;
+ this.app_ = app;
+ this.parentAppRequestContext_ = null;
}
+ protected RequestContext(RequestContext parentAppRequestContext, Application app_)
+ {
+ this.parentAppRequestContext_ = parentAppRequestContext;
+ this.app_ = app_;
+ }
+
public Application getApplication()
{
return app_;
@@ -69,6 +79,35 @@
}
/**
+ * Returns the url factory associated with this context.
+ *
+ * @return the url factory
+ */
+ public abstract URLFactory getURLFactory();
+
+ public abstract <R, U extends PortalURL<R, U>> U newURL(ResourceType<R, U> resourceType, URLFactory urlFactory);
+
+ public final <R, U extends PortalURL<R, U>> U createURL(ResourceType<R, U> resourceType, R resource)
+ {
+ U url = createURL(resourceType);
+
+ // Set the resource on the URL
+ url.setResource(resource);
+
+ //
+ return url;
+ }
+
+ public final <R, L extends PortalURL<R, L>> L createURL(ResourceType<R, L> resourceType)
+ {
+ // Get the provider
+ URLFactory provider = getURLFactory();
+
+ // Create an URL from the factory
+ return newURL(resourceType, provider);
+ }
+
+ /**
* Returns the orientation for the current request.
*
* @return the orientation
@@ -152,11 +191,6 @@
return parentAppRequestContext_;
}
- public void setParentAppRequestContext(RequestContext context)
- {
- parentAppRequestContext_ = context;
- }
-
@SuppressWarnings("unchecked")
public static <T extends RequestContext> T getCurrentInstance()
{
Modified: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/application/URLBuilder.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/application/URLBuilder.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/application/URLBuilder.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -21,6 +21,8 @@
import java.net.URLEncoder;
+import java.util.Locale;
+
/**
* Created by The eXo Platform SAS
* Mar 29, 2007
@@ -28,102 +30,68 @@
abstract public class URLBuilder<T>
{
- protected String baseURL_;
+ /** . */
+ protected Locale locale = null;
- public URLBuilder(String baseURL)
+ /** . */
+ protected boolean removeLocale = false;
+
+ public Locale getLocale()
{
- baseURL_ = baseURL;
+ return locale;
}
- public String getBaseURL()
+ public void setLocale(Locale locale)
{
- return baseURL_;
+ this.locale = locale;
}
- public void setBaseURL(String url)
+ public void setRemoveLocale(boolean removeLocale)
{
- baseURL_ = url;
+ this.removeLocale = removeLocale;
}
- public String createURL(String action)
+ public boolean getRemoveLocale()
{
- return createURL(action, (Parameter[])null);
+ return removeLocale;
}
- abstract public String createURL(String action, Parameter[] params);
+ public final String createURL(String action)
+ {
+ throw new UnsupportedOperationException("don't use me");
+ }
- public String createURL(String action, String objectId)
+ public final String createURL(String action, Parameter[] params)
{
- return createURL(action, objectId, (Parameter[])null);
+ throw new UnsupportedOperationException("don't use me");
}
- abstract public String createURL(String action, String objectId, Parameter[] params);
-
- public String createURL(T targetComponent, String action, String targetBeanId)
+ public final String createURL(String action, String objectId)
{
- return createURL(targetComponent, action, null, targetBeanId, (Parameter[])null);
+ throw new UnsupportedOperationException("don't use me");
}
- public String createAjaxURL(T targetComponent, String action, String targetBeanId)
+ public final String createURL(String action, String objectId, Parameter[] params)
{
- return createAjaxURL(targetComponent, action, null, targetBeanId, (Parameter[])null);
+ throw new UnsupportedOperationException("don't use me");
}
- public String createAjaxURL(T targetComponent, String action, String confirm, String targetBeanId)
+ public final String createURL(T targetComponent, String action, String targetBeanId)
{
- return createAjaxURL(targetComponent, action, confirm, targetBeanId, (Parameter[])null);
+ return createURL(targetComponent, action, null, targetBeanId, (Parameter[])null);
}
- public String createAjaxURL(T targetComponent, String action, String confirm, String targetBeanId, Parameter[] params)
+ public final String createAjaxURL(T targetComponent, String action, String targetBeanId)
{
- StringBuilder builder = new StringBuilder("javascript:");
- if (confirm != null && confirm.length() > 0)
- {
- builder.append("if(confirm('").append(confirm.replaceAll("'", "\\\\'")).append("'))");
- }
- builder.append("ajaxGet('");
- if (targetBeanId != null)
- {
- try
- {
- targetBeanId = URLEncoder.encode(targetBeanId, "utf-8");
- }
- catch (Exception e)
- {
- System.err.println(e.toString());
- }
- }
- createURL(builder, targetComponent, action, targetBeanId, params);
- builder.append("&ajaxRequest=true')");
- return builder.toString();
+ return createAjaxURL(targetComponent, action, null, targetBeanId, (Parameter[])null);
}
- public String createURL(T targetComponent, String action, String confirm, String targetBeanId, Parameter[] params)
+ public final String createAjaxURL(T targetComponent, String action, String confirm, String targetBeanId)
{
- StringBuilder builder = new StringBuilder();
- boolean hasConfirm = confirm != null && confirm.length() > 0;
- if (hasConfirm)
- {
- builder.append("javascript:if(confirm('").append(confirm.replaceAll("'", "\\\\'")).append("'))");
- builder.append("window.location=\'");
- }
- if (targetBeanId != null)
- {
- try
- {
- targetBeanId = URLEncoder.encode(targetBeanId, "utf-8");
- }
- catch (Exception e)
- {
- System.err.println(e.toString());
- }
- }
- createURL(builder, targetComponent, action, targetBeanId, params);
- if (hasConfirm)
- builder.append("\';");
- return builder.toString();
+ return createAjaxURL(targetComponent, action, confirm, targetBeanId, (Parameter[])null);
}
- abstract protected void createURL(StringBuilder builder, T targetComponent, String action, String targetBeanId,
- Parameter[] params);
+ public abstract String createAjaxURL(T targetComponent, String action, String confirm, String targetBeanId, Parameter[] params);
+
+ public abstract String createURL(T targetComponent, String action, String confirm, String targetBeanId, Parameter[] params);
}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/QualifiedName.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/QualifiedName.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/QualifiedName.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,211 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller;
-
-import org.jboss.util.NullArgumentException;
-
-/**
- * <p>A qualified name that is a qualifier and a name. It can be seen as a simplified version of an XML QName
- * that retains only the prefix (qualifier) and the local name (name) and leaves out the namespace.</p>
- *
- * <p>Qualified names have a string representation that is equals to the concatenation of the qualifier
- * and name separated by a colon (:) character. When the </p>
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class QualifiedName implements Comparable<QualifiedName>
-{
-
- /**
- * Parse the string representation of a qname and returns a qualified name.
- *
- * @param qname the qname to parse
- * @return the corresponding qualified name
- * @throws NullArgumentException if the qname argument is null
- * @throws IllegalArgumentException if the qname argument contains more than one colon character
- */
- public static QualifiedName parse(String qname) throws NullArgumentException, IllegalArgumentException
- {
- if (qname == null)
- {
- throw new NullPointerException("No null argument accepted");
- }
- if (qname.length() > 0)
- {
- int index = qname.indexOf(':');
- if (index > -1)
- {
- return create(qname.substring(0, index), qname.substring(index + 1));
- }
- }
- return create(qname);
- }
-
- /**
- * Creates a qualified name.
- *
- * @param qualifier the qualifier
- * @param name the name
- * @return the qualified name
- * @throws NullPointerException if any argument is null
- * @throws IllegalArgumentException if any argument contains a colon character
- */
- public static QualifiedName create(String qualifier, String name) throws NullPointerException, IllegalArgumentException
- {
- return new QualifiedName(qualifier, name);
- }
-
- /**
- * Creates a qualified name with an empty string qualifier.
- *
- * @param name the name
- * @return the qualified name
- * @throws NullPointerException if any argument is null
- * @throws IllegalArgumentException if any argument contains a colon character
- */
- public static QualifiedName create(String name) throws NullPointerException, IllegalArgumentException
- {
- return new QualifiedName(name);
- }
-
- /** The qualifier. */
- private final String qualifier;
-
- /** The name. */
- private final String name;
-
- private QualifiedName(String name) throws NullPointerException, IllegalArgumentException
- {
- this("", name);
- }
-
- private QualifiedName(String qualifier, String name) throws NullPointerException, IllegalArgumentException
- {
- if (qualifier == null)
- {
- throw new NullPointerException("No null prefix accepted");
- }
- if (qualifier.indexOf(':') != -1)
- {
- throw new IllegalArgumentException("The name '" + qualifier + "' must not contain a colon character");
- }
- if (name == null)
- {
- throw new NullPointerException("No null prefix accepted");
- }
- if (name.indexOf(':') != -1)
- {
- throw new IllegalArgumentException("The name '" + name + "' must not contain a colon character");
- }
-
- //
- this.qualifier = qualifier;
- this.name = name;
- }
-
- /**
- * Returns the qualifier.
- *
- * @return the qualifier
- */
- public String getQualifier()
- {
- return qualifier;
- }
-
- /**
- * Returns the name.
- *
- * @return the name
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * Returns the string representation.
- *
- * @return the string representation
- */
- public String getValue()
- {
- if (qualifier.isEmpty())
- {
- return name;
- }
- else
- {
- return qualifier + ":" + name;
- }
- }
-
- @Override
- public int hashCode()
- {
- return qualifier.hashCode() ^ name.hashCode();
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
- if (obj instanceof QualifiedName)
- {
- QualifiedName that = (QualifiedName)obj;
- return qualifier.equals(that.qualifier) && name.equals(that.name);
- }
- return false;
- }
-
- public int compareTo(QualifiedName o)
- {
- if (o == null)
- {
- throw new NullPointerException("No null argument accepted");
- }
- else if (o == this)
- {
- return 0;
- }
- else
- {
- int qualifierComparison = qualifier.compareTo(o.qualifier);
- if (qualifierComparison == 0)
- {
- return name.compareTo(o.name);
- }
- else
- {
- return qualifierComparison;
- }
- }
- }
-
- @Override
- public String toString()
- {
- return "QualifiedName[prefix=" + qualifier + ",name=" + name + "]";
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/QualifiedName.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/QualifiedName.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/QualifiedName.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/QualifiedName.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,211 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller;
+
+import org.jboss.util.NullArgumentException;
+
+/**
+ * <p>A qualified name that is a qualifier and a name. It can be seen as a simplified version of an XML QName
+ * that retains only the prefix (qualifier) and the local name (name) and leaves out the namespace.</p>
+ *
+ * <p>Qualified names have a string representation that is equals to the concatenation of the qualifier
+ * and name separated by a colon (:) character. When the </p>
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class QualifiedName implements Comparable<QualifiedName>
+{
+
+ /**
+ * Parse the string representation of a qname and returns a qualified name.
+ *
+ * @param qname the qname to parse
+ * @return the corresponding qualified name
+ * @throws NullArgumentException if the qname argument is null
+ * @throws IllegalArgumentException if the qname argument contains more than one colon character
+ */
+ public static QualifiedName parse(String qname) throws NullArgumentException, IllegalArgumentException
+ {
+ if (qname == null)
+ {
+ throw new NullPointerException("No null argument accepted");
+ }
+ if (qname.length() > 0)
+ {
+ int index = qname.indexOf(':');
+ if (index > -1)
+ {
+ return create(qname.substring(0, index), qname.substring(index + 1));
+ }
+ }
+ return create(qname);
+ }
+
+ /**
+ * Creates a qualified name.
+ *
+ * @param qualifier the qualifier
+ * @param name the name
+ * @return the qualified name
+ * @throws NullPointerException if any argument is null
+ * @throws IllegalArgumentException if any argument contains a colon character
+ */
+ public static QualifiedName create(String qualifier, String name) throws NullPointerException, IllegalArgumentException
+ {
+ return new QualifiedName(qualifier, name);
+ }
+
+ /**
+ * Creates a qualified name with an empty string qualifier.
+ *
+ * @param name the name
+ * @return the qualified name
+ * @throws NullPointerException if any argument is null
+ * @throws IllegalArgumentException if any argument contains a colon character
+ */
+ public static QualifiedName create(String name) throws NullPointerException, IllegalArgumentException
+ {
+ return new QualifiedName(name);
+ }
+
+ /** The qualifier. */
+ private final String qualifier;
+
+ /** The name. */
+ private final String name;
+
+ private QualifiedName(String name) throws NullPointerException, IllegalArgumentException
+ {
+ this("", name);
+ }
+
+ private QualifiedName(String qualifier, String name) throws NullPointerException, IllegalArgumentException
+ {
+ if (qualifier == null)
+ {
+ throw new NullPointerException("No null prefix accepted");
+ }
+ if (qualifier.indexOf(':') != -1)
+ {
+ throw new IllegalArgumentException("The name '" + qualifier + "' must not contain a colon character");
+ }
+ if (name == null)
+ {
+ throw new NullPointerException("No null prefix accepted");
+ }
+ if (name.indexOf(':') != -1)
+ {
+ throw new IllegalArgumentException("The name '" + name + "' must not contain a colon character");
+ }
+
+ //
+ this.qualifier = qualifier;
+ this.name = name;
+ }
+
+ /**
+ * Returns the qualifier.
+ *
+ * @return the qualifier
+ */
+ public String getQualifier()
+ {
+ return qualifier;
+ }
+
+ /**
+ * Returns the name.
+ *
+ * @return the name
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Returns the string representation.
+ *
+ * @return the string representation
+ */
+ public String getValue()
+ {
+ if (qualifier.isEmpty())
+ {
+ return name;
+ }
+ else
+ {
+ return qualifier + ":" + name;
+ }
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return qualifier.hashCode() ^ name.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof QualifiedName)
+ {
+ QualifiedName that = (QualifiedName)obj;
+ return qualifier.equals(that.qualifier) && name.equals(that.name);
+ }
+ return false;
+ }
+
+ public int compareTo(QualifiedName o)
+ {
+ if (o == null)
+ {
+ throw new NullPointerException("No null argument accepted");
+ }
+ else if (o == this)
+ {
+ return 0;
+ }
+ else
+ {
+ int qualifierComparison = qualifier.compareTo(o.qualifier);
+ if (qualifierComparison == 0)
+ {
+ return name.compareTo(o.name);
+ }
+ else
+ {
+ return qualifierComparison;
+ }
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return "QualifiedName[prefix=" + qualifier + ",name=" + name + "]";
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ControllerDescriptor.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ControllerDescriptor.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ControllerDescriptor.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.metadata;
-
-import org.exoplatform.web.controller.router.RouterConfigException;
-import org.exoplatform.web.controller.router.Router;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Describe a controller.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class ControllerDescriptor
-{
-
- /** . */
- private final List<RouteDescriptor> routes;
-
- /** . */
- private char separatorEscape;
-
- public ControllerDescriptor()
- {
- this.routes = new ArrayList<RouteDescriptor>();
- this.separatorEscape = '_';
- }
-
- public ControllerDescriptor add(RouteDescriptor... routes)
- {
- if (routes == null)
- {
- throw new NullPointerException();
- }
-
- //
- for (RouteDescriptor route : routes)
- {
- if (route == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- this.routes.add(route);
- }
-
- //
- return this;
- }
-
- public ControllerDescriptor separatorEscapedBy(char c)
- {
- this.separatorEscape = c;
- return this;
- }
-
- public char getSeparatorEscape()
- {
- return separatorEscape;
- }
-
- public void setSeparatorEscape(char separatorEscape)
- {
- this.separatorEscape = separatorEscape;
- }
-
- public List<RouteDescriptor> getRoutes()
- {
- return routes;
- }
-
- public Router build() throws RouterConfigException
- {
- return new Router(this);
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ControllerDescriptor.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ControllerDescriptor.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ControllerDescriptor.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ControllerDescriptor.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.metadata;
+
+import org.exoplatform.web.controller.router.RouterConfigException;
+import org.exoplatform.web.controller.router.Router;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Describe a controller.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ControllerDescriptor
+{
+
+ /** . */
+ private final List<RouteDescriptor> routes;
+
+ /** . */
+ private char separatorEscape;
+
+ public ControllerDescriptor()
+ {
+ this.routes = new ArrayList<RouteDescriptor>();
+ this.separatorEscape = '_';
+ }
+
+ public ControllerDescriptor add(RouteDescriptor... routes)
+ {
+ if (routes == null)
+ {
+ throw new NullPointerException();
+ }
+
+ //
+ for (RouteDescriptor route : routes)
+ {
+ if (route == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.routes.add(route);
+ }
+
+ //
+ return this;
+ }
+
+ public ControllerDescriptor separatorEscapedBy(char c)
+ {
+ this.separatorEscape = c;
+ return this;
+ }
+
+ public char getSeparatorEscape()
+ {
+ return separatorEscape;
+ }
+
+ public void setSeparatorEscape(char separatorEscape)
+ {
+ this.separatorEscape = separatorEscape;
+ }
+
+ public List<RouteDescriptor> getRoutes()
+ {
+ return routes;
+ }
+
+ public Router build() throws RouterConfigException
+ {
+ return new Router(this);
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,216 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.metadata;
-
-import org.exoplatform.web.controller.router.ControlMode;
-import org.exoplatform.web.controller.router.EncodingMode;
-import org.exoplatform.web.controller.router.ValueMapping;
-import org.exoplatform.web.controller.router.ValueType;
-import org.staxnav.Naming;
-import org.staxnav.StaxNavException;
-import org.staxnav.StaxNavigator;
-import org.staxnav.StaxNavigatorFactory;
-
-import javax.xml.stream.XMLStreamReader;
-import java.io.InputStream;
-import java.io.Reader;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class DescriptorBuilder
-{
-
- // http://www.gatein.org/xml/ns/gatein_controller_1_0
-
- public static PathParamDescriptor pathParam(String qualifiedName)
- {
- return new PathParamDescriptor(qualifiedName);
- }
-
- public static RequestParamDescriptor requestParam(String qualifiedName)
- {
- return new RequestParamDescriptor(qualifiedName);
- }
-
- public static RouteParamDescriptor routeParam(String qualifiedName)
- {
- return new RouteParamDescriptor(qualifiedName);
- }
-
- public static RouteDescriptor route(String path)
- {
- return new RouteDescriptor(path);
- }
-
- public static ControllerDescriptor router()
- {
- return new ControllerDescriptor();
- }
-
- public ControllerDescriptor build(InputStream in) throws StaxNavException
- {
- return build(StaxNavigatorFactory.create(new Naming.Enumerated.Simple<Element>(Element.class, Element.UNKNOWN), in));
- }
-
- public ControllerDescriptor build(Reader reader) throws StaxNavException
- {
- return build(StaxNavigatorFactory.create(new Naming.Enumerated.Simple<Element>(Element.class, Element.UNKNOWN), reader));
- }
-
- public ControllerDescriptor build(XMLStreamReader reader) throws StaxNavException
- {
- return build(StaxNavigatorFactory.create(new Naming.Enumerated.Simple<Element>(Element.class, Element.UNKNOWN), reader));
- }
-
- public ControllerDescriptor build(StaxNavigator<Element> root) throws StaxNavException
- {
- ControllerDescriptor router = router();
-
- //
- String s = root.getAttribute("separator-escape");
- if (s != null)
- {
- char c = s.charAt(0);
- router.setSeparatorEscape(c);
- }
-
- //
- if (root.child() != null)
- {
- for (StaxNavigator<Element> routeNav : root.fork(Element.ROUTE))
- {
- RouteDescriptor route = buildRoute(routeNav);
- router.add(route);
- }
- }
- return router;
- }
-
- private RouteDescriptor buildRoute(StaxNavigator<Element> root) throws StaxNavException
- {
- String path = root.getAttribute("path");
-
- //
- RouteDescriptor route = new RouteDescriptor(path);
-
- //
- for (Element elt = root.child();elt != null;elt = root.sibling())
- {
- StaxNavigator<Element> fork = root.fork();
- switch (elt)
- {
- case PATH_PARAM:
- {
- String qualifiedName = fork.getAttribute("qname");
- String encoded = fork.getAttribute("encoding");
- String pattern = null;
- if (fork.child(Element.PATTERN))
- {
- pattern = fork.getContent();
- }
- EncodingMode encodingMode = "preserve-path".equals(encoded) ? EncodingMode.PRESERVE_PATH : EncodingMode.FORM;
- route.with(new PathParamDescriptor(qualifiedName).encodedBy(encodingMode).matchedBy(pattern));
- break;
- }
- case ROUTE_PARAM:
- {
- String qualifiedName = fork.getAttribute("qname");
- String value = null;
- if (fork.child(Element.VALUE))
- {
- value = fork.getContent();
- }
- route.with(new RouteParamDescriptor(qualifiedName).withValue(value));
- break;
- }
- case REQUEST_PARAM:
- {
- String qualifiedName = fork.getAttribute("qname");
- String name = fork.getAttribute("name");
- String controlModeAtt = fork.getAttribute("control-mode");
- String valueMappingAtt = fork.getAttribute("value-mapping");
- RequestParamDescriptor param = new RequestParamDescriptor(qualifiedName);
- param.setName(name);
- param.setControlMode(parseControlMode(controlModeAtt));
- param.setValueMapping(parseValueMapping(valueMappingAtt));
- if (fork.child(Element.VALUE))
- {
- param.setValue(fork.getContent());
- param.setValueType(ValueType.LITERAL);
- }
- if (fork.child(Element.PATTERN))
- {
- param.setValue(fork.getContent());
- param.setValueType(ValueType.PATTERN);
- }
- route.with(param);
- break;
- }
- case ROUTE:
- RouteDescriptor sub = buildRoute(fork);
- route.sub(sub);
- break;
- default:
- throw new AssertionError();
- }
- }
-
- //
- return route;
- }
-
- static ControlMode parseControlMode(String s)
- {
- if (s == null || "optional".equals(s))
- {
- return ControlMode.OPTIONAL;
- }
- else if ("required".equals(s))
- {
- return ControlMode.REQUIRED;
- }
- else
- {
- throw new UnsupportedOperationException("Handle me gracefully");
- }
- }
-
- static ValueMapping parseValueMapping(String s)
- {
- if (s == null || "canonical".equals(s))
- {
- return ValueMapping.CANONICAL;
- }
- else if ("never-empty".equals(s))
- {
- return ValueMapping.NEVER_EMPTY;
- }
- else if ("never-null".equals(s))
- {
- return ValueMapping.NEVER_NULL;
- }
- else
- {
- throw new UnsupportedOperationException("Handle me gracefully");
- }
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,216 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.metadata;
+
+import org.exoplatform.web.controller.router.ControlMode;
+import org.exoplatform.web.controller.router.EncodingMode;
+import org.exoplatform.web.controller.router.ValueMapping;
+import org.exoplatform.web.controller.router.ValueType;
+import org.staxnav.Naming;
+import org.staxnav.StaxNavException;
+import org.staxnav.StaxNavigator;
+import org.staxnav.StaxNavigatorFactory;
+
+import javax.xml.stream.XMLStreamReader;
+import java.io.InputStream;
+import java.io.Reader;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class DescriptorBuilder
+{
+
+ // http://www.gatein.org/xml/ns/gatein_controller_1_0
+
+ public static PathParamDescriptor pathParam(String qualifiedName)
+ {
+ return new PathParamDescriptor(qualifiedName);
+ }
+
+ public static RequestParamDescriptor requestParam(String qualifiedName)
+ {
+ return new RequestParamDescriptor(qualifiedName);
+ }
+
+ public static RouteParamDescriptor routeParam(String qualifiedName)
+ {
+ return new RouteParamDescriptor(qualifiedName);
+ }
+
+ public static RouteDescriptor route(String path)
+ {
+ return new RouteDescriptor(path);
+ }
+
+ public static ControllerDescriptor router()
+ {
+ return new ControllerDescriptor();
+ }
+
+ public ControllerDescriptor build(InputStream in) throws StaxNavException
+ {
+ return build(StaxNavigatorFactory.create(new Naming.Enumerated.Simple<Element>(Element.class, Element.UNKNOWN), in));
+ }
+
+ public ControllerDescriptor build(Reader reader) throws StaxNavException
+ {
+ return build(StaxNavigatorFactory.create(new Naming.Enumerated.Simple<Element>(Element.class, Element.UNKNOWN), reader));
+ }
+
+ public ControllerDescriptor build(XMLStreamReader reader) throws StaxNavException
+ {
+ return build(StaxNavigatorFactory.create(new Naming.Enumerated.Simple<Element>(Element.class, Element.UNKNOWN), reader));
+ }
+
+ public ControllerDescriptor build(StaxNavigator<Element> root) throws StaxNavException
+ {
+ ControllerDescriptor router = router();
+
+ //
+ String s = root.getAttribute("separator-escape");
+ if (s != null)
+ {
+ char c = s.charAt(0);
+ router.setSeparatorEscape(c);
+ }
+
+ //
+ if (root.child() != null)
+ {
+ for (StaxNavigator<Element> routeNav : root.fork(Element.ROUTE))
+ {
+ RouteDescriptor route = buildRoute(routeNav);
+ router.add(route);
+ }
+ }
+ return router;
+ }
+
+ private RouteDescriptor buildRoute(StaxNavigator<Element> root) throws StaxNavException
+ {
+ String path = root.getAttribute("path");
+
+ //
+ RouteDescriptor route = new RouteDescriptor(path);
+
+ //
+ for (Element elt = root.child();elt != null;elt = root.sibling())
+ {
+ StaxNavigator<Element> fork = root.fork();
+ switch (elt)
+ {
+ case PATH_PARAM:
+ {
+ String qualifiedName = fork.getAttribute("qname");
+ String encoded = fork.getAttribute("encoding");
+ String pattern = null;
+ if (fork.child(Element.PATTERN))
+ {
+ pattern = fork.getContent();
+ }
+ EncodingMode encodingMode = "preserve-path".equals(encoded) ? EncodingMode.PRESERVE_PATH : EncodingMode.FORM;
+ route.with(new PathParamDescriptor(qualifiedName).encodedBy(encodingMode).matchedBy(pattern));
+ break;
+ }
+ case ROUTE_PARAM:
+ {
+ String qualifiedName = fork.getAttribute("qname");
+ String value = null;
+ if (fork.child(Element.VALUE))
+ {
+ value = fork.getContent();
+ }
+ route.with(new RouteParamDescriptor(qualifiedName).withValue(value));
+ break;
+ }
+ case REQUEST_PARAM:
+ {
+ String qualifiedName = fork.getAttribute("qname");
+ String name = fork.getAttribute("name");
+ String controlModeAtt = fork.getAttribute("control-mode");
+ String valueMappingAtt = fork.getAttribute("value-mapping");
+ RequestParamDescriptor param = new RequestParamDescriptor(qualifiedName);
+ param.setName(name);
+ param.setControlMode(parseControlMode(controlModeAtt));
+ param.setValueMapping(parseValueMapping(valueMappingAtt));
+ if (fork.child(Element.VALUE))
+ {
+ param.setValue(fork.getContent());
+ param.setValueType(ValueType.LITERAL);
+ }
+ if (fork.child(Element.PATTERN))
+ {
+ param.setValue(fork.getContent());
+ param.setValueType(ValueType.PATTERN);
+ }
+ route.with(param);
+ break;
+ }
+ case ROUTE:
+ RouteDescriptor sub = buildRoute(fork);
+ route.sub(sub);
+ break;
+ default:
+ throw new AssertionError();
+ }
+ }
+
+ //
+ return route;
+ }
+
+ static ControlMode parseControlMode(String s)
+ {
+ if (s == null || "optional".equals(s))
+ {
+ return ControlMode.OPTIONAL;
+ }
+ else if ("required".equals(s))
+ {
+ return ControlMode.REQUIRED;
+ }
+ else
+ {
+ throw new UnsupportedOperationException("Handle me gracefully");
+ }
+ }
+
+ static ValueMapping parseValueMapping(String s)
+ {
+ if (s == null || "canonical".equals(s))
+ {
+ return ValueMapping.CANONICAL;
+ }
+ else if ("never-empty".equals(s))
+ {
+ return ValueMapping.NEVER_EMPTY;
+ }
+ else if ("never-null".equals(s))
+ {
+ return ValueMapping.NEVER_NULL;
+ }
+ else
+ {
+ throw new UnsupportedOperationException("Handle me gracefully");
+ }
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/Element.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/Element.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/Element.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.metadata;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- */
-public enum Element
-{
-
- CONTROLLER,
-
- ROUTE,
-
- ROUTE_PARAM,
-
- REQUEST_PARAM,
-
- PATH_PARAM,
-
- PATTERN,
-
- VALUE,
-
- UNKNOWN
-
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/Element.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/Element.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/Element.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/Element.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.metadata;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public enum Element
+{
+
+ CONTROLLER,
+
+ ROUTE,
+
+ ROUTE_PARAM,
+
+ REQUEST_PARAM,
+
+ PATH_PARAM,
+
+ PATTERN,
+
+ VALUE,
+
+ UNKNOWN
+
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ParamDescriptor.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ParamDescriptor.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ParamDescriptor.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.metadata;
-
-import org.exoplatform.web.controller.QualifiedName;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public abstract class ParamDescriptor
-{
-
- /** . */
- private final QualifiedName qualifiedName;
-
- protected ParamDescriptor(QualifiedName qualifiedName)
- {
- if (qualifiedName == null)
- {
- throw new NullPointerException("No null qualified name accepted");
- }
-
- //
- this.qualifiedName = qualifiedName;
- }
-
- public ParamDescriptor(String qualifiedName)
- {
- if (qualifiedName == null)
- {
- throw new NullPointerException("No null qualified name accepted");
- }
-
- //
- this.qualifiedName = QualifiedName.parse(qualifiedName);
- }
-
- public QualifiedName getQualifiedName()
- {
- return qualifiedName;
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ParamDescriptor.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ParamDescriptor.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ParamDescriptor.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ParamDescriptor.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.metadata;
+
+import org.exoplatform.web.controller.QualifiedName;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class ParamDescriptor
+{
+
+ /** . */
+ private final QualifiedName qualifiedName;
+
+ protected ParamDescriptor(QualifiedName qualifiedName)
+ {
+ if (qualifiedName == null)
+ {
+ throw new NullPointerException("No null qualified name accepted");
+ }
+
+ //
+ this.qualifiedName = qualifiedName;
+ }
+
+ public ParamDescriptor(String qualifiedName)
+ {
+ if (qualifiedName == null)
+ {
+ throw new NullPointerException("No null qualified name accepted");
+ }
+
+ //
+ this.qualifiedName = QualifiedName.parse(qualifiedName);
+ }
+
+ public QualifiedName getQualifiedName()
+ {
+ return qualifiedName;
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.metadata;
-
-import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.controller.router.EncodingMode;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class PathParamDescriptor extends ParamDescriptor
-{
-
- /** . */
- private String pattern;
-
- /** . */
- private EncodingMode encodingMode;
-
- public PathParamDescriptor(QualifiedName qualifiedName)
- {
- super(qualifiedName);
-
- //
- this.encodingMode = EncodingMode.FORM;
- }
-
- public PathParamDescriptor(String qualifiedName)
- {
- super(qualifiedName);
-
- //
- this.encodingMode = EncodingMode.FORM;
- }
-
- public PathParamDescriptor matchedBy(String pattern)
- {
- this.pattern = pattern;
- return this;
- }
-
- public PathParamDescriptor encodedBy(EncodingMode encodingMode)
- {
- this.encodingMode = encodingMode;
- return this;
- }
-
- public PathParamDescriptor preservePath()
- {
- return encodedBy(EncodingMode.PRESERVE_PATH);
- }
-
- public PathParamDescriptor form()
- {
- return encodedBy(EncodingMode.FORM);
- }
-
- public String getPattern()
- {
- return pattern;
- }
-
- public void setPattern(String pattern)
- {
- this.pattern = pattern;
- }
-
- public EncodingMode getEncodingMode()
- {
- return encodingMode;
- }
-
- public void setEncodingMode(EncodingMode encodingMode)
- {
- this.encodingMode = encodingMode;
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.metadata;
+
+import org.exoplatform.web.controller.QualifiedName;
+import org.exoplatform.web.controller.router.EncodingMode;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PathParamDescriptor extends ParamDescriptor
+{
+
+ /** . */
+ private String pattern;
+
+ /** . */
+ private EncodingMode encodingMode;
+
+ public PathParamDescriptor(QualifiedName qualifiedName)
+ {
+ super(qualifiedName);
+
+ //
+ this.encodingMode = EncodingMode.FORM;
+ }
+
+ public PathParamDescriptor(String qualifiedName)
+ {
+ super(qualifiedName);
+
+ //
+ this.encodingMode = EncodingMode.FORM;
+ }
+
+ public PathParamDescriptor matchedBy(String pattern)
+ {
+ this.pattern = pattern;
+ return this;
+ }
+
+ public PathParamDescriptor encodedBy(EncodingMode encodingMode)
+ {
+ this.encodingMode = encodingMode;
+ return this;
+ }
+
+ public PathParamDescriptor preservePath()
+ {
+ return encodedBy(EncodingMode.PRESERVE_PATH);
+ }
+
+ public PathParamDescriptor form()
+ {
+ return encodedBy(EncodingMode.FORM);
+ }
+
+ public String getPattern()
+ {
+ return pattern;
+ }
+
+ public void setPattern(String pattern)
+ {
+ this.pattern = pattern;
+ }
+
+ public EncodingMode getEncodingMode()
+ {
+ return encodingMode;
+ }
+
+ public void setEncodingMode(EncodingMode encodingMode)
+ {
+ this.encodingMode = encodingMode;
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RequestParamDescriptor.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RequestParamDescriptor.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RequestParamDescriptor.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,170 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.metadata;
-
-import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.controller.router.ControlMode;
-import org.exoplatform.web.controller.router.ValueMapping;
-import org.exoplatform.web.controller.router.ValueType;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class RequestParamDescriptor extends ParamDescriptor
-{
-
- /** . */
- private String name;
-
- /** . */
- private String value;
-
- /** . */
- private ValueType valueType;
-
- /** . */
- private ControlMode controlMode;
-
- /** . */
- private ValueMapping valueMapping;
-
- public RequestParamDescriptor(QualifiedName qualifiedName)
- {
- super(qualifiedName);
-
- //
- this.value = null;
- this.controlMode = ControlMode.OPTIONAL;
- this.valueType = ValueType.LITERAL;
- this.valueMapping = ValueMapping.CANONICAL;
- }
-
- public RequestParamDescriptor(String qualifiedName)
- {
- super(qualifiedName);
-
- //
- this.value = null;
- this.controlMode = ControlMode.OPTIONAL;
- this.valueType = ValueType.LITERAL;
- this.valueMapping = ValueMapping.CANONICAL;
- }
-
- public RequestParamDescriptor named(String name)
- {
- this.name = name;
- return this;
- }
-
- public RequestParamDescriptor matchedByLiteral(String value)
- {
- this.value = value;
- this.valueType = ValueType.LITERAL;
- return this;
- }
-
- public RequestParamDescriptor matchedByPattern(String value)
- {
- this.value = value;
- this.valueType = ValueType.PATTERN;
- return this;
- }
-
- public RequestParamDescriptor required()
- {
- this.controlMode = ControlMode.REQUIRED;
- return this;
- }
-
- public RequestParamDescriptor optional()
- {
- this.controlMode = ControlMode.OPTIONAL;
- return this;
- }
-
- public RequestParamDescriptor neverEmpty()
- {
- this.valueMapping = ValueMapping.NEVER_EMPTY;
- return this;
- }
-
- public RequestParamDescriptor neverNull()
- {
- this.valueMapping = ValueMapping.NEVER_NULL;
- return this;
- }
-
- public RequestParamDescriptor canonical()
- {
- this.valueMapping = ValueMapping.CANONICAL;
- return this;
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- public String getValue()
- {
- return value;
- }
-
- public void setValue(String value)
- {
- this.value = value;
- }
-
- public ValueType getValueType()
- {
- return valueType;
- }
-
- public void setValueType(ValueType valueType)
- {
- this.valueType = valueType;
- }
-
- public ControlMode getControlMode()
- {
- return controlMode;
- }
-
- public void setControlMode(ControlMode controlMode)
- {
- this.controlMode = controlMode;
- }
-
- public ValueMapping getValueMapping()
- {
- return valueMapping;
- }
-
- public void setValueMapping(ValueMapping valueMapping)
- {
- this.valueMapping = valueMapping;
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RequestParamDescriptor.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RequestParamDescriptor.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RequestParamDescriptor.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RequestParamDescriptor.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.metadata;
+
+import org.exoplatform.web.controller.QualifiedName;
+import org.exoplatform.web.controller.router.ControlMode;
+import org.exoplatform.web.controller.router.ValueMapping;
+import org.exoplatform.web.controller.router.ValueType;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class RequestParamDescriptor extends ParamDescriptor
+{
+
+ /** . */
+ private String name;
+
+ /** . */
+ private String value;
+
+ /** . */
+ private ValueType valueType;
+
+ /** . */
+ private ControlMode controlMode;
+
+ /** . */
+ private ValueMapping valueMapping;
+
+ public RequestParamDescriptor(QualifiedName qualifiedName)
+ {
+ super(qualifiedName);
+
+ //
+ this.value = null;
+ this.controlMode = ControlMode.OPTIONAL;
+ this.valueType = ValueType.LITERAL;
+ this.valueMapping = ValueMapping.CANONICAL;
+ }
+
+ public RequestParamDescriptor(String qualifiedName)
+ {
+ super(qualifiedName);
+
+ //
+ this.value = null;
+ this.controlMode = ControlMode.OPTIONAL;
+ this.valueType = ValueType.LITERAL;
+ this.valueMapping = ValueMapping.CANONICAL;
+ }
+
+ public RequestParamDescriptor named(String name)
+ {
+ this.name = name;
+ return this;
+ }
+
+ public RequestParamDescriptor matchedByLiteral(String value)
+ {
+ this.value = value;
+ this.valueType = ValueType.LITERAL;
+ return this;
+ }
+
+ public RequestParamDescriptor matchedByPattern(String value)
+ {
+ this.value = value;
+ this.valueType = ValueType.PATTERN;
+ return this;
+ }
+
+ public RequestParamDescriptor required()
+ {
+ this.controlMode = ControlMode.REQUIRED;
+ return this;
+ }
+
+ public RequestParamDescriptor optional()
+ {
+ this.controlMode = ControlMode.OPTIONAL;
+ return this;
+ }
+
+ public RequestParamDescriptor neverEmpty()
+ {
+ this.valueMapping = ValueMapping.NEVER_EMPTY;
+ return this;
+ }
+
+ public RequestParamDescriptor neverNull()
+ {
+ this.valueMapping = ValueMapping.NEVER_NULL;
+ return this;
+ }
+
+ public RequestParamDescriptor canonical()
+ {
+ this.valueMapping = ValueMapping.CANONICAL;
+ return this;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ public ValueType getValueType()
+ {
+ return valueType;
+ }
+
+ public void setValueType(ValueType valueType)
+ {
+ this.valueType = valueType;
+ }
+
+ public ControlMode getControlMode()
+ {
+ return controlMode;
+ }
+
+ public void setControlMode(ControlMode controlMode)
+ {
+ this.controlMode = controlMode;
+ }
+
+ public ValueMapping getValueMapping()
+ {
+ return valueMapping;
+ }
+
+ public void setValueMapping(ValueMapping valueMapping)
+ {
+ this.valueMapping = valueMapping;
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.metadata;
-
-import org.exoplatform.web.controller.QualifiedName;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Describes a route.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class RouteDescriptor
-{
-
- /** . */
- private final String path;
-
- /** . */
- private final Map<QualifiedName, RouteParamDescriptor> routeParams;
-
- /** . */
- private final Map<QualifiedName, PathParamDescriptor> pathParams;
-
- /** . */
- private final Map<String, RequestParamDescriptor> requestParams;
-
- /** . */
- private final List<RouteDescriptor> children;
-
- public RouteDescriptor(String path)
- {
- if (path == null)
- {
- throw new NullPointerException("Was not expecting a null path");
- }
-
- //
- this.path = path;
- this.routeParams = new HashMap<QualifiedName, RouteParamDescriptor>();
- this.pathParams = new HashMap<QualifiedName, PathParamDescriptor>();
- this.requestParams = new HashMap<String, RequestParamDescriptor>();
- this.children = new ArrayList<RouteDescriptor>();
- }
-
- public String getPath()
- {
- return path;
- }
-
- public Set<QualifiedName> getRouteParamNames()
- {
- return routeParams.keySet();
- }
-
- public Collection<RouteParamDescriptor> getRouteParams()
- {
- return routeParams.values();
- }
-
- public RouteParamDescriptor getRouteParam(QualifiedName name)
- {
- return routeParams.get(name);
- }
-
- public RouteDescriptor with(ParamDescriptor... params)
- {
- if (params == null)
- {
- throw new NullPointerException();
- }
- for (ParamDescriptor param : params)
- {
- if (param == null)
- {
- throw new IllegalArgumentException();
- }
- if (param instanceof RouteParamDescriptor)
- {
- RouteParamDescriptor routeParam = (RouteParamDescriptor)param;
- routeParams.put(routeParam.getQualifiedName(), routeParam);
- }
- else if (param instanceof RequestParamDescriptor)
- {
- RequestParamDescriptor requestParam = (RequestParamDescriptor)param;
- requestParams.put(requestParam.getName(), requestParam);
- }
- if (param instanceof PathParamDescriptor)
- {
- PathParamDescriptor pathParam = (PathParamDescriptor)param;
- pathParams.put(pathParam.getQualifiedName(), pathParam);
- }
- }
- return this;
- }
-
- public Collection<RequestParamDescriptor> getRequestParams()
- {
- return requestParams.values();
- }
-
- public Set<String> getRequestParamMatchNames()
- {
- return requestParams.keySet();
- }
-
- public RequestParamDescriptor getRequestParam(String matchName)
- {
- return requestParams.get(matchName);
- }
-
- public Map<QualifiedName, PathParamDescriptor> getPathParams()
- {
- return pathParams;
- }
-
- public RouteDescriptor sub(RouteDescriptor child)
- {
- children.add(child);
- return this;
- }
-
- public List<RouteDescriptor> getChildren()
- {
- return children;
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.metadata;
+
+import org.exoplatform.web.controller.QualifiedName;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Describes a route.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class RouteDescriptor
+{
+
+ /** . */
+ private final String path;
+
+ /** . */
+ private final Map<QualifiedName, RouteParamDescriptor> routeParams;
+
+ /** . */
+ private final Map<QualifiedName, PathParamDescriptor> pathParams;
+
+ /** . */
+ private final Map<String, RequestParamDescriptor> requestParams;
+
+ /** . */
+ private final List<RouteDescriptor> children;
+
+ public RouteDescriptor(String path)
+ {
+ if (path == null)
+ {
+ throw new NullPointerException("Was not expecting a null path");
+ }
+
+ //
+ this.path = path;
+ this.routeParams = new HashMap<QualifiedName, RouteParamDescriptor>();
+ this.pathParams = new HashMap<QualifiedName, PathParamDescriptor>();
+ this.requestParams = new HashMap<String, RequestParamDescriptor>();
+ this.children = new ArrayList<RouteDescriptor>();
+ }
+
+ public String getPath()
+ {
+ return path;
+ }
+
+ public Set<QualifiedName> getRouteParamNames()
+ {
+ return routeParams.keySet();
+ }
+
+ public Collection<RouteParamDescriptor> getRouteParams()
+ {
+ return routeParams.values();
+ }
+
+ public RouteParamDescriptor getRouteParam(QualifiedName name)
+ {
+ return routeParams.get(name);
+ }
+
+ public RouteDescriptor with(ParamDescriptor... params)
+ {
+ if (params == null)
+ {
+ throw new NullPointerException();
+ }
+ for (ParamDescriptor param : params)
+ {
+ if (param == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (param instanceof RouteParamDescriptor)
+ {
+ RouteParamDescriptor routeParam = (RouteParamDescriptor)param;
+ routeParams.put(routeParam.getQualifiedName(), routeParam);
+ }
+ else if (param instanceof RequestParamDescriptor)
+ {
+ RequestParamDescriptor requestParam = (RequestParamDescriptor)param;
+ requestParams.put(requestParam.getName(), requestParam);
+ }
+ if (param instanceof PathParamDescriptor)
+ {
+ PathParamDescriptor pathParam = (PathParamDescriptor)param;
+ pathParams.put(pathParam.getQualifiedName(), pathParam);
+ }
+ }
+ return this;
+ }
+
+ public Collection<RequestParamDescriptor> getRequestParams()
+ {
+ return requestParams.values();
+ }
+
+ public Set<String> getRequestParamMatchNames()
+ {
+ return requestParams.keySet();
+ }
+
+ public RequestParamDescriptor getRequestParam(String matchName)
+ {
+ return requestParams.get(matchName);
+ }
+
+ public Map<QualifiedName, PathParamDescriptor> getPathParams()
+ {
+ return pathParams;
+ }
+
+ public RouteDescriptor sub(RouteDescriptor child)
+ {
+ children.add(child);
+ return this;
+ }
+
+ public List<RouteDescriptor> getChildren()
+ {
+ return children;
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteParamDescriptor.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteParamDescriptor.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteParamDescriptor.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.metadata;
-
-import org.exoplatform.web.controller.QualifiedName;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class RouteParamDescriptor extends ParamDescriptor
-{
-
- /** . */
- private String value;
-
- public RouteParamDescriptor(QualifiedName qualifiedName)
- {
- super(qualifiedName);
- }
-
- public RouteParamDescriptor(String qualifiedName)
- {
- super(qualifiedName);
- }
-
- public RouteParamDescriptor withValue(String value)
- {
- this.value = value;
- return this;
- }
-
- public String getValue()
- {
- return value;
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteParamDescriptor.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteParamDescriptor.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteParamDescriptor.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteParamDescriptor.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.metadata;
+
+import org.exoplatform.web.controller.QualifiedName;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class RouteParamDescriptor extends ParamDescriptor
+{
+
+ /** . */
+ private String value;
+
+ public RouteParamDescriptor(QualifiedName qualifiedName)
+ {
+ super(qualifiedName);
+ }
+
+ public RouteParamDescriptor(String qualifiedName)
+ {
+ super(qualifiedName);
+ }
+
+ public RouteParamDescriptor withValue(String value)
+ {
+ this.value = value;
+ return this;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/GroupType.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/GroupType.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/GroupType.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.regexp;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public enum GroupType
-{
-
- CAPTURING_GROUP("(", ")"),
-
- NON_CAPTURING_GROUP("(?:", ")"),
-
- POSITIVE_LOOKAHEAD("(?=", ")"),
-
- NEGATIVE_LOOKAHEAD("(?!", ")"),
-
- POSITIVE_LOOKBEHIND("(?<=", ")"),
-
- NEGATIVE_LOOKBEHIND("(?<!", ")");
-
- /** . */
- private static final GroupType[] ALL = values();
-
- public static GroupType forPrefix(String s)
- {
- if (s == null)
- {
- throw new NullPointerException("No null prefix accepted");
- }
- // No need for a fast lookup, iteration on array will do well
- for (GroupType type : ALL)
- {
- if (type.open.equals(s))
- {
- return type;
- }
- }
- return null;
- }
-
- /** . */
- private final String open;
-
- /** . */
- private final String close;
-
- GroupType(String open, String close)
- {
- this.open = open;
- this.close = close;
- }
-
- public String getOpen()
- {
- return open;
- }
-
- public String getClose()
- {
- return close;
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/GroupType.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/GroupType.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/GroupType.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/GroupType.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.regexp;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public enum GroupType
+{
+
+ CAPTURING_GROUP("(", ")"),
+
+ NON_CAPTURING_GROUP("(?:", ")"),
+
+ POSITIVE_LOOKAHEAD("(?=", ")"),
+
+ NEGATIVE_LOOKAHEAD("(?!", ")"),
+
+ POSITIVE_LOOKBEHIND("(?<=", ")"),
+
+ NEGATIVE_LOOKBEHIND("(?<!", ")");
+
+ /** . */
+ private static final GroupType[] ALL = values();
+
+ public static GroupType forPrefix(String s)
+ {
+ if (s == null)
+ {
+ throw new NullPointerException("No null prefix accepted");
+ }
+ // No need for a fast lookup, iteration on array will do well
+ for (GroupType type : ALL)
+ {
+ if (type.open.equals(s))
+ {
+ return type;
+ }
+ }
+ return null;
+ }
+
+ /** . */
+ private final String open;
+
+ /** . */
+ private final String close;
+
+ GroupType(String open, String close)
+ {
+ this.open = open;
+ this.close = close;
+ }
+
+ public String getOpen()
+ {
+ return open;
+ }
+
+ public String getClose()
+ {
+ return close;
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Kind.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Kind.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Kind.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.regexp;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- */
-enum Kind
-{
-
- BEGIN,
-
- END,
-
- ANY,
-
- HYPHEN,
-
- OR,
-
- LITERAL,
-
- GROUP_OPEN,
-
- GROUP_CLOSE,
-
- QUANTIFIER,
-
- QUANTIFIER_MODE,
-
- CC_OPEN,
-
- CC_CLOSE,
-
- CC_AND
-
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Kind.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Kind.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Kind.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Kind.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.regexp;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+enum Kind
+{
+
+ BEGIN,
+
+ END,
+
+ ANY,
+
+ HYPHEN,
+
+ OR,
+
+ LITERAL,
+
+ GROUP_OPEN,
+
+ GROUP_CLOSE,
+
+ QUANTIFIER,
+
+ QUANTIFIER_MODE,
+
+ CC_OPEN,
+
+ CC_CLOSE,
+
+ CC_AND
+
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Lexer.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Lexer.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Lexer.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,450 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.regexp;
-
-import java.util.NoSuchElementException;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- */
-class Lexer
-{
-
- /** /. */
- private static final Pattern QUANTIFIER_PATTERN = Pattern.compile("^\\{([0-9]+)" + "(?:" + "(,)([0-9]+)?" + ")?\\}$");
-
- /** /. */
- private static final Pattern OCTAL_PATTERN = Pattern.compile("^[0-7]|[0-7][0-7]|[0-3][0-7][0-7]$");
-
- /** /. */
- private final Stream stream;
-
- /** /. */
- private int ccDepth;
-
- /** /. */
- private Kind next;
-
- /** /. */
- private String token;
-
- /** /. */
- private Kind previous;
-
- Lexer(Stream stream)
- {
- this.stream = stream;
- this.ccDepth = 0;
- this.next = null;
- this.previous = null;
- this.token = null;
- }
-
- Lexer(CharSequence seq)
- {
- this(new Stream(seq));
- }
-
- int getIndex()
- {
- return stream.getIndex();
- }
-
- void reset()
- {
- this.stream.reset();
- this.ccDepth = 0;
- this.next = null;
- this.previous = null;
- this.token = null;
- }
-
- String getToken()
- {
- return token;
- }
-
- boolean isDone()
- {
- return !stream.hasNext();
- }
-
- boolean hasNext() throws SyntaxException
- {
- if (next == null)
- {
- if (stream.hasNext())
- {
- Kind kind;
- char c = stream.next();
- switch (c)
- {
- case '^':
- kind = Kind.BEGIN;
- token = "^";
- break;
- case '$':
- kind = Kind.END;
- token = "$";
- break;
- case '.':
- kind = Kind.ANY;
- token = ".";
- break;
- case '-':
- if (ccDepth > 0)
- {
- if (stream.hasNext(']'))
- {
- kind = Kind.LITERAL;
- token = "-";
- }
- else if (previous == Kind.CC_OPEN)
- {
- kind = Kind.LITERAL;
- token = "-";
- }
- else if (previous == Kind.HYPHEN)
- {
- kind = Kind.LITERAL;
- token = "-";
- }
- else
- {
- kind = Kind.HYPHEN;
- token = "-";
- }
- }
- else
- {
- kind = Kind.LITERAL;
- token = "-";
- }
- break;
- case '|':
- kind = Kind.OR;
- token = "|";
- break;
- case '[':
- {
-
- kind = Kind.CC_OPEN;
- if (stream.next('^'))
- {
- token = "[^";
- }
- else
- {
- token = "[";
- }
- ccDepth++;
- break;
- }
- case ']':
- if (ccDepth > 0)
- {
- if (previous == Kind.CC_OPEN)
- {
- kind = Kind.LITERAL;
- token = "]";
- }
- else
- {
- kind = Kind.CC_CLOSE;
- token = "]";
- ccDepth--;
- }
- }
- else
- {
- kind = Kind.LITERAL;
- token = "]";
- }
- break;
- case '&':
- if (stream.next('&'))
- {
- kind = Kind.CC_AND;
- token = "&&";
- }
- else
- {
- kind = Kind.LITERAL;
- token = "&";
- }
- break;
- case '\\':
- {
- if (stream.hasNext())
- {
- c = stream.peek();
- if (c == '0')
- {
- StringBuilder sb = new StringBuilder().append(stream.next());
- Character matched = null;
- while (true)
- {
- if (stream.hasNext())
- {
- sb.append(stream.peek());
- Matcher matcher = OCTAL_PATTERN.matcher(sb);
- if (matcher.matches())
- {
- matched = (char)Integer.parseInt(sb.toString(), 8);
- stream.next();
- }
- else
- {
- break;
- }
- }
- else
- {
- break;
- }
- }
- if (matched != null)
- {
- kind = Kind.LITERAL;
- token = Character.toString(matched);
- }
- else
- {
- throw new SyntaxException();
- }
- }
- else if (c == 'x')
- {
- stream.next();
- if (stream.hasNext(1))
- {
- String s = "" + stream.next() + stream.next();
- try
- {
- kind = Kind.LITERAL;
- token = Character.toString((char)Integer.parseInt(s, 16));
- }
- catch (NumberFormatException e)
- {
- throw new SyntaxException();
- }
- }
- else
- {
- throw new SyntaxException();
- }
- }
- else if (c == 'u')
- {
- stream.next();
- if (stream.hasNext(3))
- {
- String s = "" + stream.next() + stream.next() + stream.next() + stream.next();
- try
- {
- kind = Kind.LITERAL;
- token = Character.toString((char)Integer.parseInt(s, 16));
- }
- catch (NumberFormatException e)
- {
- throw new SyntaxException();
- }
- }
- else
- {
- throw new SyntaxException();
- }
- }
- else if (Character.isLetterOrDigit(c))
- {
- throw new SyntaxException();
- }
- else
- {
- stream.next();
- kind = Kind.LITERAL;
- token = "" + c;
- }
- }
- else
- {
- throw new SyntaxException();
- }
- break;
- }
- case '(':
- {
- if (ccDepth == 0)
- {
- StringBuilder sb = new StringBuilder("(");
- if (stream.hasNext('?'))
- {
- if (stream.hasNext(1, ')'))
- {
- // Do nothing
- }
- else
- {
- stream.next();
- sb.append('?');
- if (stream.hasNext(':') || stream.hasNext('=') || stream.hasNext('!'))
- {
- sb.append(stream.next());
- }
- else if (stream.next('<'))
- {
- sb.append('<');
- if (stream.hasNext('=') || stream.hasNext('!'))
- {
- sb.append(stream.next());
- }
- else
- {
- throw new SyntaxException();
- }
- }
- else
- {
- throw new SyntaxException();
- }
- }
- }
- kind = Kind.GROUP_OPEN;
- token = sb.toString();
- }
- else
- {
- kind = Kind.LITERAL;
- token = "(";
- }
- break;
- }
- case '?':
- if (previous == Kind.GROUP_OPEN)
- {
- kind = Kind.LITERAL;
- token = "?";
- }
- else if (previous == Kind.QUANTIFIER)
- {
- kind = Kind.QUANTIFIER_MODE;
- token = "?";
- }
- else
- {
- kind = Kind.QUANTIFIER;
- token = "?";
- }
- break;
- case '+':
- if (previous == Kind.QUANTIFIER)
- {
- kind = Kind.QUANTIFIER_MODE;
- token = "+";
- }
- else
- {
- kind = Kind.QUANTIFIER;
- token = "+";
- break;
- }
- break;
- case '*':
- kind = Kind.QUANTIFIER;
- token = "*";
- break;
- case '{':
- {
- if (ccDepth == 0)
- {
- StringBuilder sb = new StringBuilder("{");
- while (stream.hasNext())
- {
- c = stream.next();
- sb.append(c);
- if (c == '}')
- {
- break;
- }
- }
- if (QUANTIFIER_PATTERN.matcher(sb).matches())
- {
- kind = Kind.QUANTIFIER;
- token = sb.toString();
- }
- else
- {
- throw new SyntaxException();
- }
- }
- else
- {
- kind = Kind.LITERAL;
- token = "{";
- }
- break;
- }
- case ')':
- if (ccDepth == 0)
- {
- kind = Kind.GROUP_CLOSE;
- token = ")";
- }
- else
- {
- kind = Kind.LITERAL;
- token = ")";
- }
- break;
- default:
- kind = Kind.LITERAL;
- token = "" + c;
- break;
- }
- next = kind;
- }
- }
- return next != null;
- }
-
- boolean next(Kind expected) throws SyntaxException
- {
- if (hasNext() && expected == next)
- {
- previous = next();
- next = null;
- return true;
- }
- return false;
- }
-
- Kind next() throws SyntaxException
- {
- if (!hasNext())
- {
- throw new NoSuchElementException();
- }
- previous = next;
- next = null;
- return previous;
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Lexer.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Lexer.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Lexer.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Lexer.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,450 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.regexp;
+
+import java.util.NoSuchElementException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+class Lexer
+{
+
+ /** /. */
+ private static final Pattern QUANTIFIER_PATTERN = Pattern.compile("^\\{([0-9]+)" + "(?:" + "(,)([0-9]+)?" + ")?\\}$");
+
+ /** /. */
+ private static final Pattern OCTAL_PATTERN = Pattern.compile("^[0-7]|[0-7][0-7]|[0-3][0-7][0-7]$");
+
+ /** /. */
+ private final Stream stream;
+
+ /** /. */
+ private int ccDepth;
+
+ /** /. */
+ private Kind next;
+
+ /** /. */
+ private String token;
+
+ /** /. */
+ private Kind previous;
+
+ Lexer(Stream stream)
+ {
+ this.stream = stream;
+ this.ccDepth = 0;
+ this.next = null;
+ this.previous = null;
+ this.token = null;
+ }
+
+ Lexer(CharSequence seq)
+ {
+ this(new Stream(seq));
+ }
+
+ int getIndex()
+ {
+ return stream.getIndex();
+ }
+
+ void reset()
+ {
+ this.stream.reset();
+ this.ccDepth = 0;
+ this.next = null;
+ this.previous = null;
+ this.token = null;
+ }
+
+ String getToken()
+ {
+ return token;
+ }
+
+ boolean isDone()
+ {
+ return !stream.hasNext();
+ }
+
+ boolean hasNext() throws SyntaxException
+ {
+ if (next == null)
+ {
+ if (stream.hasNext())
+ {
+ Kind kind;
+ char c = stream.next();
+ switch (c)
+ {
+ case '^':
+ kind = Kind.BEGIN;
+ token = "^";
+ break;
+ case '$':
+ kind = Kind.END;
+ token = "$";
+ break;
+ case '.':
+ kind = Kind.ANY;
+ token = ".";
+ break;
+ case '-':
+ if (ccDepth > 0)
+ {
+ if (stream.hasNext(']'))
+ {
+ kind = Kind.LITERAL;
+ token = "-";
+ }
+ else if (previous == Kind.CC_OPEN)
+ {
+ kind = Kind.LITERAL;
+ token = "-";
+ }
+ else if (previous == Kind.HYPHEN)
+ {
+ kind = Kind.LITERAL;
+ token = "-";
+ }
+ else
+ {
+ kind = Kind.HYPHEN;
+ token = "-";
+ }
+ }
+ else
+ {
+ kind = Kind.LITERAL;
+ token = "-";
+ }
+ break;
+ case '|':
+ kind = Kind.OR;
+ token = "|";
+ break;
+ case '[':
+ {
+
+ kind = Kind.CC_OPEN;
+ if (stream.next('^'))
+ {
+ token = "[^";
+ }
+ else
+ {
+ token = "[";
+ }
+ ccDepth++;
+ break;
+ }
+ case ']':
+ if (ccDepth > 0)
+ {
+ if (previous == Kind.CC_OPEN)
+ {
+ kind = Kind.LITERAL;
+ token = "]";
+ }
+ else
+ {
+ kind = Kind.CC_CLOSE;
+ token = "]";
+ ccDepth--;
+ }
+ }
+ else
+ {
+ kind = Kind.LITERAL;
+ token = "]";
+ }
+ break;
+ case '&':
+ if (stream.next('&'))
+ {
+ kind = Kind.CC_AND;
+ token = "&&";
+ }
+ else
+ {
+ kind = Kind.LITERAL;
+ token = "&";
+ }
+ break;
+ case '\\':
+ {
+ if (stream.hasNext())
+ {
+ c = stream.peek();
+ if (c == '0')
+ {
+ StringBuilder sb = new StringBuilder().append(stream.next());
+ Character matched = null;
+ while (true)
+ {
+ if (stream.hasNext())
+ {
+ sb.append(stream.peek());
+ Matcher matcher = OCTAL_PATTERN.matcher(sb);
+ if (matcher.matches())
+ {
+ matched = (char)Integer.parseInt(sb.toString(), 8);
+ stream.next();
+ }
+ else
+ {
+ break;
+ }
+ }
+ else
+ {
+ break;
+ }
+ }
+ if (matched != null)
+ {
+ kind = Kind.LITERAL;
+ token = Character.toString(matched);
+ }
+ else
+ {
+ throw new SyntaxException();
+ }
+ }
+ else if (c == 'x')
+ {
+ stream.next();
+ if (stream.hasNext(1))
+ {
+ String s = "" + stream.next() + stream.next();
+ try
+ {
+ kind = Kind.LITERAL;
+ token = Character.toString((char)Integer.parseInt(s, 16));
+ }
+ catch (NumberFormatException e)
+ {
+ throw new SyntaxException();
+ }
+ }
+ else
+ {
+ throw new SyntaxException();
+ }
+ }
+ else if (c == 'u')
+ {
+ stream.next();
+ if (stream.hasNext(3))
+ {
+ String s = "" + stream.next() + stream.next() + stream.next() + stream.next();
+ try
+ {
+ kind = Kind.LITERAL;
+ token = Character.toString((char)Integer.parseInt(s, 16));
+ }
+ catch (NumberFormatException e)
+ {
+ throw new SyntaxException();
+ }
+ }
+ else
+ {
+ throw new SyntaxException();
+ }
+ }
+ else if (Character.isLetterOrDigit(c))
+ {
+ throw new SyntaxException();
+ }
+ else
+ {
+ stream.next();
+ kind = Kind.LITERAL;
+ token = "" + c;
+ }
+ }
+ else
+ {
+ throw new SyntaxException();
+ }
+ break;
+ }
+ case '(':
+ {
+ if (ccDepth == 0)
+ {
+ StringBuilder sb = new StringBuilder("(");
+ if (stream.hasNext('?'))
+ {
+ if (stream.hasNext(1, ')'))
+ {
+ // Do nothing
+ }
+ else
+ {
+ stream.next();
+ sb.append('?');
+ if (stream.hasNext(':') || stream.hasNext('=') || stream.hasNext('!'))
+ {
+ sb.append(stream.next());
+ }
+ else if (stream.next('<'))
+ {
+ sb.append('<');
+ if (stream.hasNext('=') || stream.hasNext('!'))
+ {
+ sb.append(stream.next());
+ }
+ else
+ {
+ throw new SyntaxException();
+ }
+ }
+ else
+ {
+ throw new SyntaxException();
+ }
+ }
+ }
+ kind = Kind.GROUP_OPEN;
+ token = sb.toString();
+ }
+ else
+ {
+ kind = Kind.LITERAL;
+ token = "(";
+ }
+ break;
+ }
+ case '?':
+ if (previous == Kind.GROUP_OPEN)
+ {
+ kind = Kind.LITERAL;
+ token = "?";
+ }
+ else if (previous == Kind.QUANTIFIER)
+ {
+ kind = Kind.QUANTIFIER_MODE;
+ token = "?";
+ }
+ else
+ {
+ kind = Kind.QUANTIFIER;
+ token = "?";
+ }
+ break;
+ case '+':
+ if (previous == Kind.QUANTIFIER)
+ {
+ kind = Kind.QUANTIFIER_MODE;
+ token = "+";
+ }
+ else
+ {
+ kind = Kind.QUANTIFIER;
+ token = "+";
+ break;
+ }
+ break;
+ case '*':
+ kind = Kind.QUANTIFIER;
+ token = "*";
+ break;
+ case '{':
+ {
+ if (ccDepth == 0)
+ {
+ StringBuilder sb = new StringBuilder("{");
+ while (stream.hasNext())
+ {
+ c = stream.next();
+ sb.append(c);
+ if (c == '}')
+ {
+ break;
+ }
+ }
+ if (QUANTIFIER_PATTERN.matcher(sb).matches())
+ {
+ kind = Kind.QUANTIFIER;
+ token = sb.toString();
+ }
+ else
+ {
+ throw new SyntaxException();
+ }
+ }
+ else
+ {
+ kind = Kind.LITERAL;
+ token = "{";
+ }
+ break;
+ }
+ case ')':
+ if (ccDepth == 0)
+ {
+ kind = Kind.GROUP_CLOSE;
+ token = ")";
+ }
+ else
+ {
+ kind = Kind.LITERAL;
+ token = ")";
+ }
+ break;
+ default:
+ kind = Kind.LITERAL;
+ token = "" + c;
+ break;
+ }
+ next = kind;
+ }
+ }
+ return next != null;
+ }
+
+ boolean next(Kind expected) throws SyntaxException
+ {
+ if (hasNext() && expected == next)
+ {
+ previous = next();
+ next = null;
+ return true;
+ }
+ return false;
+ }
+
+ Kind next() throws SyntaxException
+ {
+ if (!hasNext())
+ {
+ throw new NoSuchElementException();
+ }
+ previous = next;
+ next = null;
+ return previous;
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Literal.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Literal.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Literal.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.regexp;
-
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- */
-public class Literal
-{
- /**
- * Return true if the char should be escaped. Note that the implementation sometime may escape the char
- * although the context in which it is used would not require its escape.
- *
- * @param c the char to test
- * @return true when the char should be escaped.
- */
- public static boolean isEscaped(char c)
- {
- return c >= '(' && c <= '+' // ()*+
- || c == '?'
- || c == '{'
- || c == '}'
- || c == '|'
- || c == '$'
- || c == '&'
- || c == '^'
- || c == '-'
- || c == '.'
- || c == '['
- || c == ']'
- || c == '\\';
- }
-
- /**
- * Return the char value as a string literal in a regexp. Note that the implementation does not tries
- * to optimize the value with respect to the AST context, (for instance (?) would be fine as (?) but it
- * will rewritten as (\?).
- *
- * @param value the value
- * @return the escaped string
- */
- public String getEscape(char value)
- {
- switch (value)
- {
- case '|':
- return "\\|";
- case '&':
- return "\\&";
- case '$':
- return "\\$";
- case '^':
- return "\\^";
- case '-':
- return "\\-";
- case '.':
- return "\\.";
- case '?':
- return "\\?";
- case '+':
- return "\\+";
- case '*':
- return "\\*";
- case '[':
- return "\\[";
- case ']':
- return "\\]";
- case '(':
- return "\\(";
- case ')':
- return "\\)";
- case '{':
- return "\\{";
- case '}':
- return "\\}";
- case '\\':
- return "\\\\";
- default:
- return Character.toString(value);
- }
- }
-
- public static void escapeTo(char value, Appendable appendable) throws IOException, NullPointerException
- {
- if (appendable == null)
- {
- throw new NullPointerException();
- }
- if (isEscaped(value))
- {
- appendable.append('\\');
- }
- appendable.append(value);
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Literal.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Literal.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Literal.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Literal.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.regexp;
+
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public class Literal
+{
+ /**
+ * Return true if the char should be escaped. Note that the implementation sometime may escape the char
+ * although the context in which it is used would not require its escape.
+ *
+ * @param c the char to test
+ * @return true when the char should be escaped.
+ */
+ public static boolean isEscaped(char c)
+ {
+ return c >= '(' && c <= '+' // ()*+
+ || c == '?'
+ || c == '{'
+ || c == '}'
+ || c == '|'
+ || c == '$'
+ || c == '&'
+ || c == '^'
+ || c == '-'
+ || c == '.'
+ || c == '['
+ || c == ']'
+ || c == '\\';
+ }
+
+ /**
+ * Return the char value as a string literal in a regexp. Note that the implementation does not tries
+ * to optimize the value with respect to the AST context, (for instance (?) would be fine as (?) but it
+ * will rewritten as (\?).
+ *
+ * @param value the value
+ * @return the escaped string
+ */
+ public String getEscape(char value)
+ {
+ switch (value)
+ {
+ case '|':
+ return "\\|";
+ case '&':
+ return "\\&";
+ case '$':
+ return "\\$";
+ case '^':
+ return "\\^";
+ case '-':
+ return "\\-";
+ case '.':
+ return "\\.";
+ case '?':
+ return "\\?";
+ case '+':
+ return "\\+";
+ case '*':
+ return "\\*";
+ case '[':
+ return "\\[";
+ case ']':
+ return "\\]";
+ case '(':
+ return "\\(";
+ case ')':
+ return "\\)";
+ case '{':
+ return "\\{";
+ case '}':
+ return "\\}";
+ case '\\':
+ return "\\\\";
+ default:
+ return Character.toString(value);
+ }
+ }
+
+ public static void escapeTo(char value, Appendable appendable) throws IOException, NullPointerException
+ {
+ if (appendable == null)
+ {
+ throw new NullPointerException();
+ }
+ if (isEscaped(value))
+ {
+ appendable.append('\\');
+ }
+ appendable.append(value);
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Parser.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Parser.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Parser.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.regexp;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public abstract class Parser
-{
-
- public Parser()
- {
- }
-
-/*
- protected final SyntaxException createSyntaxException(String msg, int start, int end)
- {
- StringBuilder sb = new StringBuilder(msg).append(" : ");
- sb.append(s, 0, start).append(" ->").append(s, start, end).append("<- ").append(s, end, s.length());
- return new SyntaxException(sb.toString());
- }
-*/
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Parser.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Parser.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Parser.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Parser.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.regexp;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class Parser
+{
+
+ public Parser()
+ {
+ }
+
+/*
+ protected final SyntaxException createSyntaxException(String msg, int start, int end)
+ {
+ StringBuilder sb = new StringBuilder(msg).append(" : ");
+ sb.append(s, 0, start).append(" ->").append(s, start, end).append("<- ").append(s, end, s.length());
+ return new SyntaxException(sb.toString());
+ }
+*/
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Quantifier.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Quantifier.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Quantifier.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,231 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.regexp;
-
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class Quantifier
-{
-
- public enum Mode
- {
-
- GREEDY(""), RELUCTANT("?"), POSSESSIVE("+");
-
- /** . */
- private final String value;
-
- Mode(String value)
- {
- this.value = value;
- }
- }
-
- public static class Range
- {
-
- /** . */
- private final int min;
-
- /** . */
- private final Integer max;
-
- public Range(int min, Integer max)
- {
- this.min = min;
- this.max = max;
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (o == this)
- {
- return true;
- }
- else if (o instanceof Range)
- {
- Range that = (Range)o;
- return min == that.min && (max == null ? that.max == null : max.equals(that.max));
- }
- return false;
- }
-
- public static Range onceOrNotAtAll()
- {
- return new Range(0, 1);
- }
-
- public static Range zeroOrMore()
- {
- return new Range(0, null);
- }
-
- public static Range oneOrMore()
- {
- return new Range(1, null);
- }
-
- public static Range exactly(int value)
- {
- return new Range(value, value);
- }
-
- public static Range atLeast(int value)
- {
- return new Range(value, null);
- }
-
- public static Range between(int min, int max)
- {
- return new Range(min, max);
- }
- }
-
- /** . */
- private final Mode mode;
-
- /** . */
- private final Range range;
-
- public Quantifier(Mode mode, int min, Integer max)
- {
- if (mode == null)
- {
- throw new NullPointerException("No null mode accepted");
- }
-
- //
- this.mode = mode;
- this.range = new Range(min, max);
- }
-
- public Quantifier(Mode mode, Range range)
- {
- if (mode == null)
- {
- throw new NullPointerException("No null mode accepted");
- }
- if (range == null)
- {
- throw new NullPointerException("No null range accepted");
- }
-
- //
- this.mode = mode;
- this.range = range;
- }
-
- public static Quantifier onceOrNotAtAll(Mode mode)
- {
- return new Quantifier(mode, 0, 1);
- }
-
- public static Quantifier zeroOrMore(Mode mode)
- {
- return new Quantifier(mode, 0, null);
- }
-
- public static Quantifier oneOrMore(Mode mode)
- {
- return new Quantifier(mode, 1, null);
- }
-
- public static Quantifier exactly(Mode mode, int value)
- {
- return new Quantifier(mode, value, value);
- }
-
- public static Quantifier atLeast(Mode mode, int value)
- {
- return new Quantifier(mode, value, null);
- }
-
- public static Quantifier between(Mode mode, int min, int max)
- {
- return new Quantifier(mode, min, max);
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (o == this)
- {
- return true;
- }
- else if (o instanceof Quantifier)
- {
- Quantifier that = (Quantifier)o;
- return mode == that.mode && range.equals(that.range);
- }
- return false;
- }
-
-
- @Override
- public String toString()
- {
- try
- {
- StringBuilder sb = new StringBuilder();
- toString(sb);
- return sb.toString();
- }
- catch (IOException e)
- {
- throw new AssertionError(e);
- }
- }
-
- public void toString(Appendable appendable) throws IOException
- {
- if (range.min == 0)
- {
- if (range.max == null)
- {
- appendable.append('*').append(mode.value);
- }
- else if (range.max == 1)
- {
- appendable.append('?').append(mode.value);
- }
- }
- else if (range.min == 1 && range.max == null)
- {
- appendable.append('+').append(mode.value);
- }
- else if (range.max == null)
- {
- appendable.append('{').append(Integer.toString(range.min)).append(",").append('}').append(mode.value);
- }
- else if (range.min == range.max)
- {
- appendable.append('{').append(Integer.toString(range.min)).append('}').append(mode.value);
- }
- else
- {
- appendable.append('{').append(Integer.toString(range.min)).append(",").append(range.max.toString()).append('}').append(mode.value);
- }
- }
-}
\ No newline at end of file
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Quantifier.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Quantifier.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Quantifier.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Quantifier.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,231 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.regexp;
+
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class Quantifier
+{
+
+ public enum Mode
+ {
+
+ GREEDY(""), RELUCTANT("?"), POSSESSIVE("+");
+
+ /** . */
+ private final String value;
+
+ Mode(String value)
+ {
+ this.value = value;
+ }
+ }
+
+ public static class Range
+ {
+
+ /** . */
+ private final int min;
+
+ /** . */
+ private final Integer max;
+
+ public Range(int min, Integer max)
+ {
+ this.min = min;
+ this.max = max;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (o == this)
+ {
+ return true;
+ }
+ else if (o instanceof Range)
+ {
+ Range that = (Range)o;
+ return min == that.min && (max == null ? that.max == null : max.equals(that.max));
+ }
+ return false;
+ }
+
+ public static Range onceOrNotAtAll()
+ {
+ return new Range(0, 1);
+ }
+
+ public static Range zeroOrMore()
+ {
+ return new Range(0, null);
+ }
+
+ public static Range oneOrMore()
+ {
+ return new Range(1, null);
+ }
+
+ public static Range exactly(int value)
+ {
+ return new Range(value, value);
+ }
+
+ public static Range atLeast(int value)
+ {
+ return new Range(value, null);
+ }
+
+ public static Range between(int min, int max)
+ {
+ return new Range(min, max);
+ }
+ }
+
+ /** . */
+ private final Mode mode;
+
+ /** . */
+ private final Range range;
+
+ public Quantifier(Mode mode, int min, Integer max)
+ {
+ if (mode == null)
+ {
+ throw new NullPointerException("No null mode accepted");
+ }
+
+ //
+ this.mode = mode;
+ this.range = new Range(min, max);
+ }
+
+ public Quantifier(Mode mode, Range range)
+ {
+ if (mode == null)
+ {
+ throw new NullPointerException("No null mode accepted");
+ }
+ if (range == null)
+ {
+ throw new NullPointerException("No null range accepted");
+ }
+
+ //
+ this.mode = mode;
+ this.range = range;
+ }
+
+ public static Quantifier onceOrNotAtAll(Mode mode)
+ {
+ return new Quantifier(mode, 0, 1);
+ }
+
+ public static Quantifier zeroOrMore(Mode mode)
+ {
+ return new Quantifier(mode, 0, null);
+ }
+
+ public static Quantifier oneOrMore(Mode mode)
+ {
+ return new Quantifier(mode, 1, null);
+ }
+
+ public static Quantifier exactly(Mode mode, int value)
+ {
+ return new Quantifier(mode, value, value);
+ }
+
+ public static Quantifier atLeast(Mode mode, int value)
+ {
+ return new Quantifier(mode, value, null);
+ }
+
+ public static Quantifier between(Mode mode, int min, int max)
+ {
+ return new Quantifier(mode, min, max);
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (o == this)
+ {
+ return true;
+ }
+ else if (o instanceof Quantifier)
+ {
+ Quantifier that = (Quantifier)o;
+ return mode == that.mode && range.equals(that.range);
+ }
+ return false;
+ }
+
+
+ @Override
+ public String toString()
+ {
+ try
+ {
+ StringBuilder sb = new StringBuilder();
+ toString(sb);
+ return sb.toString();
+ }
+ catch (IOException e)
+ {
+ throw new AssertionError(e);
+ }
+ }
+
+ public void toString(Appendable appendable) throws IOException
+ {
+ if (range.min == 0)
+ {
+ if (range.max == null)
+ {
+ appendable.append('*').append(mode.value);
+ }
+ else if (range.max == 1)
+ {
+ appendable.append('?').append(mode.value);
+ }
+ }
+ else if (range.min == 1 && range.max == null)
+ {
+ appendable.append('+').append(mode.value);
+ }
+ else if (range.max == null)
+ {
+ appendable.append('{').append(Integer.toString(range.min)).append(",").append('}').append(mode.value);
+ }
+ else if (range.min == range.max)
+ {
+ appendable.append('{').append(Integer.toString(range.min)).append('}').append(mode.value);
+ }
+ else
+ {
+ appendable.append('{').append(Integer.toString(range.min)).append(",").append(range.max.toString()).append('}').append(mode.value);
+ }
+ }
+}
\ No newline at end of file
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RENode.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RENode.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RENode.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,891 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.regexp;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public abstract class RENode
-{
-
- /** The owner. */
- private Ref<?> owner;
-
- public abstract String toString();
-
- public final RENode getParent()
- {
- return owner != null ? owner.parent : null;
- }
-
- public final RENode replaceBy(RENode that) throws IllegalStateException
- {
- if (owner == null)
- {
- throw new IllegalStateException("Not attached");
- }
- return owner.replace(that);
- }
-
- public static final class Disjunction extends RENode
- {
-
- /** . */
- private final NullableRef<Alternative> alternative;
-
- /** . */
- private final NullableRef<Disjunction> next;
-
- public Disjunction(Alternative alternative)
- {
- this(alternative, null);
- }
-
- public Disjunction(Alternative alternative, Disjunction next)
- {
- this.alternative = new NullableRef<Alternative>(this, Alternative.class, alternative);
- this.next = new NullableRef<Disjunction>(this, Disjunction.class, next);
- }
-
- public Alternative getAlternative()
- {
- return alternative.get();
- }
-
- public void setAlternative(Alternative alternative)
- {
- this.alternative.set(alternative);
- }
-
- public Disjunction getNext()
- {
- return next.get();
- }
-
- public void setNext(Disjunction next)
- {
- this.next.set(next);
- }
-
- @Override
- public String toString()
- {
- if (next.isNotNull())
- {
- if (alternative.isNotNull())
- {
- return alternative.get() + "|" + next.get();
- }
- else
- {
- return next.get().toString();
- }
- }
- else
- {
- if (alternative.isNotNull())
- {
- return alternative.get().toString();
- }
- else
- {
- return "";
- }
- }
- }
- }
-
- public static final class Alternative extends RENode
- {
-
- /** . */
- private final Ref<Expr> exp;
-
- /** . */
- private final Ref<Alternative> next;
-
- public Alternative(Expr exp)
- {
- this(exp, null);
- }
-
- public Alternative(Expr exp, Alternative next)
- {
- this.exp = new NonNullableRef<Expr>(this, Expr.class, exp);
- this.next = new NullableRef<Alternative>(this, Alternative.class, next);
- }
-
- public Expr getExp()
- {
- return exp.get();
- }
-
- public void setExp(Expr exp)
- {
- this.exp.set(exp);
- }
-
- public Alternative getNext()
- {
- return next.get();
- }
-
- public void setNext(Alternative next)
- {
- this.next.set(next);
- }
-
- @Override
- public String toString()
- {
- if (next.isNotNull())
- {
- return exp.get().toString() + next.get();
- }
- else
- {
- return exp.get().toString();
- }
- }
- }
-
- public static abstract class Expr extends RENode
- {
-
- /** . */
- private Quantifier quantifier;
-
- private Expr()
- {
- }
-
- public final Quantifier getQuantifier()
- {
- return quantifier;
- }
-
- public final void setQuantifier(Quantifier quantifier)
- {
- this.quantifier = quantifier;
- }
-
- @Override
- public final String toString()
- {
- StringBuilder sb = new StringBuilder();
- if (quantifier != null)
- {
- String q = quantifier.toString();
- sb.append('<').append(q).append('>');
- writeTo(sb);
- sb.append("</").append(q).append('>');
- }
- else
- {
- writeTo(sb);
- }
- return sb.toString();
- }
-
- protected abstract void writeTo(StringBuilder sb);
- }
-
- public static abstract class Assertion extends Expr
- {
-
- private Assertion()
- {
- }
-
- public static final class Begin extends Assertion
- {
- @Override
- protected void writeTo(StringBuilder sb)
- {
- sb.append("<^/>");
- }
- }
-
- public static final class End extends Assertion
- {
- @Override
- protected void writeTo(StringBuilder sb)
- {
- sb.append("<$/>");
- }
- }
- }
-
- public static final class Group extends Expr
- {
-
- /** . */
- private GroupType type;
-
- /** . */
- private final Ref<Disjunction> disjunction;
-
- public Group(Disjunction disjunction, GroupType type)
- {
- this.disjunction = new NullableRef<Disjunction>(this, Disjunction.class, disjunction);
- this.type = type;
- }
-
- public Disjunction getDisjunction()
- {
- return disjunction.get();
- }
-
- public void setDisjunction(Disjunction disjunction)
- {
- this.disjunction.set(disjunction);
- }
-
- public GroupType getType()
- {
- return type;
- }
-
- public void setType(GroupType type)
- {
- this.type = type;
- }
-
- @Override
- protected void writeTo(StringBuilder sb)
- {
- sb.append("<").append(type.getOpen()).append('>').append(disjunction.get()).append("</").append(type.getOpen()).append(">");
- }
- }
-
- public static abstract class Atom extends Expr
- {
- private Atom()
- {
- }
- }
-
- public static final class Any extends Atom
- {
- @Override
- protected void writeTo(StringBuilder sb)
- {
- sb.append("<./>");
- }
- }
-
- public static final class Char extends Atom
- {
-
- /** . */
- private char value;
-
- public Char(char value)
- {
- this.value = value;
- }
-
- public char getValue()
- {
- return value;
- }
-
- public void setValue(char value)
- {
- this.value = value;
- }
-
- @Override
- protected void writeTo(StringBuilder sb)
- {
- sb.append("<c>").append(value).append("</c>");
- }
- }
-
- public static class CharacterClass extends Atom
- {
-
- /** . */
- private final Ref<CharacterClassExpr> expr;
-
- public CharacterClass(CharacterClassExpr expr)
- {
- this.expr = new NonNullableRef<CharacterClassExpr>(this, CharacterClassExpr.class, expr);
- }
-
- public CharacterClassExpr getExpr()
- {
- return expr.get();
- }
-
- public void setExpr(CharacterClassExpr expr)
- {
- this.expr.set(expr);
- }
-
- @Override
- protected void writeTo(StringBuilder sb)
- {
- sb.append(expr.get());
- }
- }
-
- public static abstract class CharacterClassExpr extends RENode
- {
-
- private CharacterClassExpr()
- {
- }
-
- /**
- * Remove the specifed char from the expression.
- *
- * @param c the char to remove
- * @return the replacement for this node
- */
- public CharacterClassExpr remove(char c)
- {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Remove the specifed char from the expression.
- *
- * @param src the char is substituted
- * @param dst the char that substitutes
- * @return the replacement for this node
- */
- public CharacterClassExpr replace(char src, char dst)
- {
- throw new UnsupportedOperationException();
- }
-
- public static class Not extends CharacterClassExpr
- {
-
- /** . */
- private final Ref<CharacterClassExpr> negated;
-
- public Not(CharacterClassExpr negated)
- {
- this.negated = new NullableRef<CharacterClassExpr>(this, CharacterClassExpr.class, negated);
- }
-
- public CharacterClassExpr getNegated()
- {
- return negated.get();
- }
-
- public void setNegated(CharacterClassExpr negated)
- {
- this.negated.set(negated);
- }
-
- @Override
- public CharacterClassExpr remove(char c)
- {
- this.negated.get().remove(c);
- return this;
- }
-
- @Override
- public CharacterClassExpr replace(char src, char dst)
- {
- this.negated.get().replace(src, dst);
- return this;
- }
-
- @Override
- public String toString()
- {
- return "[^" + negated.get() + "]";
- }
- }
-
- public static class Or extends CharacterClassExpr
- {
-
- /** . */
- private final Ref<CharacterClassExpr> left;
-
- /** . */
- private final Ref<CharacterClassExpr> right;
-
- public Or(CharacterClassExpr left, CharacterClassExpr right)
- {
- this.left = new NullableRef<CharacterClassExpr>(this, CharacterClassExpr.class, left);
- this.right = new NullableRef<CharacterClassExpr>(this, CharacterClassExpr.class, right);
- }
-
- public CharacterClassExpr getLeft()
- {
- return left.get();
- }
-
- public void setLeft(CharacterClassExpr left)
- {
- this.left.set(left);
- }
-
- public CharacterClassExpr getRight()
- {
- return right.get();
- }
-
- public void setRight(CharacterClassExpr right)
- {
- this.right.set(right);
- }
-
- @Override
- public CharacterClassExpr remove(char c)
- {
- if (left.isNotNull())
- {
- left.get().remove(c);
- }
- if (right.isNotNull())
- {
- right.get().remove(c);
- }
- return this;
- }
-
- @Override
- public CharacterClassExpr replace(char src, char dst)
- {
- if (left.isNotNull())
- {
- left.get().replace(src, dst);
- }
- if (right.isNotNull())
- {
- right.get().replace(src, dst);
- }
- return this;
- }
-
- @Override
- public String toString()
- {
- String l = left.isNotNull() ? left.get().toString() : "";
- String r = right.isNotNull() ? right.get().toString() : "";
- return "[" + l + "||" + r + "]";
- }
- }
-
- public static class And extends CharacterClassExpr
- {
-
- /** . */
- private final Ref<CharacterClassExpr> left;
-
- /** . */
- private final Ref<CharacterClassExpr> right;
-
- public And(CharacterClassExpr left, CharacterClassExpr right)
- {
- this.left = new NullableRef<CharacterClassExpr>(this, CharacterClassExpr.class, left);
- this.right = new NullableRef<CharacterClassExpr>(this, CharacterClassExpr.class, right);
- }
-
- public CharacterClassExpr getLeft()
- {
- return left.get();
- }
-
- public void setLeft(CharacterClassExpr left)
- {
- this.left.set(left);
- }
-
- public CharacterClassExpr getRight()
- {
- return right.get();
- }
-
- public void setRight(CharacterClassExpr right)
- {
- this.right.set(right);
- }
-
- @Override
- public CharacterClassExpr remove(char c)
- {
- if (left.isNotNull())
- {
- left.get().remove(c);
- }
- if (right.isNotNull())
- {
- right.get().remove(c);
- }
- return this;
- }
-
- @Override
- public CharacterClassExpr replace(char src, char dst)
- {
- if (left.isNotNull())
- {
- left.get().replace(src, dst);
- }
- if (right.isNotNull())
- {
- right.get().replace(src, dst);
- }
- return this;
- }
-
- @Override
- public String toString()
- {
- String l = left.isNotNull() ? left.get().toString() : "";
- String r = right.isNotNull() ? right.get().toString() : "";
- return "[" + l + "&&" + r + "]";
- }
- }
-
- public static class Char extends CharacterClassExpr
- {
-
- /** . */
- private char value;
-
- public Char(char value)
- {
- this.value = value;
- }
-
- public char getValue()
- {
- return value;
- }
-
- public void setValue(char value)
- {
- this.value = value;
- }
-
- @Override
- public CharacterClassExpr remove(char c)
- {
- if (c == value)
- {
- replaceBy(null);
- return null;
- }
- else
- {
- return this;
- }
- }
-
- @Override
- public CharacterClassExpr replace(char src, char dst)
- {
- if (src == value)
- {
- value = dst;
- }
- return this;
- }
-
- @Override
- public String toString()
- {
- return "[" + value + "]";
- }
- }
-
- public static class Range extends CharacterClassExpr
- {
-
- /** From inclusive. */
- private RENode.CharacterClassExpr.Char from;
-
- /** To inclusive. */
- private RENode.CharacterClassExpr.Char to;
-
- public Range(RENode.CharacterClassExpr.Char from, RENode.CharacterClassExpr.Char to)
- {
- if (from.value > to.value)
- {
- throw new IllegalArgumentException("From cannot be greater or equals than to");
- }
- this.from = from;
- this.to = to;
- }
-
- public CharacterClassExpr remove(char c) throws IllegalArgumentException
- {
- if (from.value == to.value)
- {
- if (from.value == c)
- {
- throw new UnsupportedOperationException();
- }
- }
- else if (from.value +1 == to.value)
- {
- if (from.value == c)
- {
- Char repl = new Char(to.value);
- replaceBy(repl);
- return repl;
- }
- else
- {
- Char repl = new Char(from.value);
- replaceBy(repl);
- return repl;
- }
- }
- else
- {
- if (from.value == c)
- {
- from.value++;
- }
- else if (to.value == c)
- {
- to.value--;
- }
- else if (from.value < c && c < to.value)
- {
- CharacterClassExpr left;
- if (from.value + 1 == c)
- {
- left = new Char(from.value);
- }
- else
- {
- left = new Range(from, new Char((char)(c - 1)));
- }
- CharacterClassExpr right;
- if (c == to.value - 1)
- {
- right = new Char(to.value);
- }
- else
- {
- right = new Range(new Char((char)(c + 1)), to);
- }
- Or repl = new Or(left, right);
- replaceBy(repl);
- return repl;
- }
- }
-
- // We keep the same node
- return this;
- }
-
- @Override
- public CharacterClassExpr replace(char src, char dst)
- {
- CharacterClassExpr repl = remove(src);
- if (repl != this)
- {
- Or or = new Or(null, new Char(dst));
- repl.replaceBy(or);
- or.setLeft(repl);
- repl = or;
- }
- return repl;
- }
-
- public RENode.CharacterClassExpr.Char getFrom()
- {
- return from;
- }
-
- public RENode.CharacterClassExpr.Char getTo()
- {
- return to;
- }
-
- @Override
- public String toString()
- {
- return "[" + from.value + "-" + to.value + "]";
- }
- }
- }
-
- protected abstract class Ref<N extends RENode>
- {
-
- /** . */
- private final Class<N> type;
-
- /** . */
- private final RENode parent;
-
- protected Ref(RENode parent, Class<N> type)
- {
- this.parent = parent;
- this.type = type;
- }
-
- public final Class<N> getType()
- {
- return type;
- }
-
- protected abstract N set(N node);
-
- protected abstract N get();
-
- protected final boolean isNull()
- {
- return get() == null;
- }
-
- protected final boolean isNotNull()
- {
- return get() != null;
- }
-
- protected final N replace(RENode that)
- {
- if (that == null || type.isInstance(that))
- {
- return set(type.cast(that));
- }
- else
- {
- throw new ClassCastException("Cannot cast node with type " + that.getClass().getName() + " to type " +
- type.getName());
- }
- }
-
- }
-
- protected class NullableRef<N extends RENode> extends Ref<N>
- {
-
- /** . */
- private N node;
-
- public NullableRef(RENode parent, Class<N> type)
- {
- this(parent, type, null);
- }
-
- public NullableRef(RENode parent, Class<N> type, N node)
- {
- super(parent, type);
-
- //
- if (node != null)
- {
- if (node.owner != null)
- {
- throw new IllegalArgumentException();
- }
- else
- {
- node.owner = this;
- }
- }
- this.node = node;
- }
-
- @Override
- protected N set(N node)
- {
- if (node != null && node.owner != null)
- {
- throw new IllegalArgumentException();
- }
- N previous = this.node;
- if (this.node != null)
- {
- this.node.owner = null;
- }
- if (node != null)
- {
- node.owner = this;
- this.node = node;
- }
- else
- {
- this.node = null;
- }
- return previous;
- }
-
- @Override
- protected N get()
- {
- return node;
- }
- }
-
- protected class NonNullableRef<N extends RENode> extends Ref<N>
- {
-
- /** . */
- private N node;
-
- public NonNullableRef(RENode parent, Class<N> type, N node)
- {
- super(parent, type);
-
- //
- if (node == null)
- {
- throw new NullPointerException();
- }
- if (node.owner != null)
- {
- throw new IllegalArgumentException();
- }
- node.owner = this;
- this.node = node;
- }
-
- @Override
- protected N set(N node)
- {
- if (node == null)
- {
- throw new NullPointerException("No null node accepted");
- }
- if (node.owner != null)
- {
- throw new IllegalArgumentException();
- }
- N previous = this.node;
- this.node.owner = null;
- node.owner = this;
- this.node = node;
- return previous;
- }
-
- @Override
- protected N get()
- {
- return node;
- }
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RENode.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RENode.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RENode.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RENode.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,891 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.regexp;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class RENode
+{
+
+ /** The owner. */
+ private Ref<?> owner;
+
+ public abstract String toString();
+
+ public final RENode getParent()
+ {
+ return owner != null ? owner.parent : null;
+ }
+
+ public final RENode replaceBy(RENode that) throws IllegalStateException
+ {
+ if (owner == null)
+ {
+ throw new IllegalStateException("Not attached");
+ }
+ return owner.replace(that);
+ }
+
+ public static final class Disjunction extends RENode
+ {
+
+ /** . */
+ private final NullableRef<Alternative> alternative;
+
+ /** . */
+ private final NullableRef<Disjunction> next;
+
+ public Disjunction(Alternative alternative)
+ {
+ this(alternative, null);
+ }
+
+ public Disjunction(Alternative alternative, Disjunction next)
+ {
+ this.alternative = new NullableRef<Alternative>(this, Alternative.class, alternative);
+ this.next = new NullableRef<Disjunction>(this, Disjunction.class, next);
+ }
+
+ public Alternative getAlternative()
+ {
+ return alternative.get();
+ }
+
+ public void setAlternative(Alternative alternative)
+ {
+ this.alternative.set(alternative);
+ }
+
+ public Disjunction getNext()
+ {
+ return next.get();
+ }
+
+ public void setNext(Disjunction next)
+ {
+ this.next.set(next);
+ }
+
+ @Override
+ public String toString()
+ {
+ if (next.isNotNull())
+ {
+ if (alternative.isNotNull())
+ {
+ return alternative.get() + "|" + next.get();
+ }
+ else
+ {
+ return next.get().toString();
+ }
+ }
+ else
+ {
+ if (alternative.isNotNull())
+ {
+ return alternative.get().toString();
+ }
+ else
+ {
+ return "";
+ }
+ }
+ }
+ }
+
+ public static final class Alternative extends RENode
+ {
+
+ /** . */
+ private final Ref<Expr> exp;
+
+ /** . */
+ private final Ref<Alternative> next;
+
+ public Alternative(Expr exp)
+ {
+ this(exp, null);
+ }
+
+ public Alternative(Expr exp, Alternative next)
+ {
+ this.exp = new NonNullableRef<Expr>(this, Expr.class, exp);
+ this.next = new NullableRef<Alternative>(this, Alternative.class, next);
+ }
+
+ public Expr getExp()
+ {
+ return exp.get();
+ }
+
+ public void setExp(Expr exp)
+ {
+ this.exp.set(exp);
+ }
+
+ public Alternative getNext()
+ {
+ return next.get();
+ }
+
+ public void setNext(Alternative next)
+ {
+ this.next.set(next);
+ }
+
+ @Override
+ public String toString()
+ {
+ if (next.isNotNull())
+ {
+ return exp.get().toString() + next.get();
+ }
+ else
+ {
+ return exp.get().toString();
+ }
+ }
+ }
+
+ public static abstract class Expr extends RENode
+ {
+
+ /** . */
+ private Quantifier quantifier;
+
+ private Expr()
+ {
+ }
+
+ public final Quantifier getQuantifier()
+ {
+ return quantifier;
+ }
+
+ public final void setQuantifier(Quantifier quantifier)
+ {
+ this.quantifier = quantifier;
+ }
+
+ @Override
+ public final String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+ if (quantifier != null)
+ {
+ String q = quantifier.toString();
+ sb.append('<').append(q).append('>');
+ writeTo(sb);
+ sb.append("</").append(q).append('>');
+ }
+ else
+ {
+ writeTo(sb);
+ }
+ return sb.toString();
+ }
+
+ protected abstract void writeTo(StringBuilder sb);
+ }
+
+ public static abstract class Assertion extends Expr
+ {
+
+ private Assertion()
+ {
+ }
+
+ public static final class Begin extends Assertion
+ {
+ @Override
+ protected void writeTo(StringBuilder sb)
+ {
+ sb.append("<^/>");
+ }
+ }
+
+ public static final class End extends Assertion
+ {
+ @Override
+ protected void writeTo(StringBuilder sb)
+ {
+ sb.append("<$/>");
+ }
+ }
+ }
+
+ public static final class Group extends Expr
+ {
+
+ /** . */
+ private GroupType type;
+
+ /** . */
+ private final Ref<Disjunction> disjunction;
+
+ public Group(Disjunction disjunction, GroupType type)
+ {
+ this.disjunction = new NullableRef<Disjunction>(this, Disjunction.class, disjunction);
+ this.type = type;
+ }
+
+ public Disjunction getDisjunction()
+ {
+ return disjunction.get();
+ }
+
+ public void setDisjunction(Disjunction disjunction)
+ {
+ this.disjunction.set(disjunction);
+ }
+
+ public GroupType getType()
+ {
+ return type;
+ }
+
+ public void setType(GroupType type)
+ {
+ this.type = type;
+ }
+
+ @Override
+ protected void writeTo(StringBuilder sb)
+ {
+ sb.append("<").append(type.getOpen()).append('>').append(disjunction.get()).append("</").append(type.getOpen()).append(">");
+ }
+ }
+
+ public static abstract class Atom extends Expr
+ {
+ private Atom()
+ {
+ }
+ }
+
+ public static final class Any extends Atom
+ {
+ @Override
+ protected void writeTo(StringBuilder sb)
+ {
+ sb.append("<./>");
+ }
+ }
+
+ public static final class Char extends Atom
+ {
+
+ /** . */
+ private char value;
+
+ public Char(char value)
+ {
+ this.value = value;
+ }
+
+ public char getValue()
+ {
+ return value;
+ }
+
+ public void setValue(char value)
+ {
+ this.value = value;
+ }
+
+ @Override
+ protected void writeTo(StringBuilder sb)
+ {
+ sb.append("<c>").append(value).append("</c>");
+ }
+ }
+
+ public static class CharacterClass extends Atom
+ {
+
+ /** . */
+ private final Ref<CharacterClassExpr> expr;
+
+ public CharacterClass(CharacterClassExpr expr)
+ {
+ this.expr = new NonNullableRef<CharacterClassExpr>(this, CharacterClassExpr.class, expr);
+ }
+
+ public CharacterClassExpr getExpr()
+ {
+ return expr.get();
+ }
+
+ public void setExpr(CharacterClassExpr expr)
+ {
+ this.expr.set(expr);
+ }
+
+ @Override
+ protected void writeTo(StringBuilder sb)
+ {
+ sb.append(expr.get());
+ }
+ }
+
+ public static abstract class CharacterClassExpr extends RENode
+ {
+
+ private CharacterClassExpr()
+ {
+ }
+
+ /**
+ * Remove the specifed char from the expression.
+ *
+ * @param c the char to remove
+ * @return the replacement for this node
+ */
+ public CharacterClassExpr remove(char c)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Remove the specifed char from the expression.
+ *
+ * @param src the char is substituted
+ * @param dst the char that substitutes
+ * @return the replacement for this node
+ */
+ public CharacterClassExpr replace(char src, char dst)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public static class Not extends CharacterClassExpr
+ {
+
+ /** . */
+ private final Ref<CharacterClassExpr> negated;
+
+ public Not(CharacterClassExpr negated)
+ {
+ this.negated = new NullableRef<CharacterClassExpr>(this, CharacterClassExpr.class, negated);
+ }
+
+ public CharacterClassExpr getNegated()
+ {
+ return negated.get();
+ }
+
+ public void setNegated(CharacterClassExpr negated)
+ {
+ this.negated.set(negated);
+ }
+
+ @Override
+ public CharacterClassExpr remove(char c)
+ {
+ this.negated.get().remove(c);
+ return this;
+ }
+
+ @Override
+ public CharacterClassExpr replace(char src, char dst)
+ {
+ this.negated.get().replace(src, dst);
+ return this;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "[^" + negated.get() + "]";
+ }
+ }
+
+ public static class Or extends CharacterClassExpr
+ {
+
+ /** . */
+ private final Ref<CharacterClassExpr> left;
+
+ /** . */
+ private final Ref<CharacterClassExpr> right;
+
+ public Or(CharacterClassExpr left, CharacterClassExpr right)
+ {
+ this.left = new NullableRef<CharacterClassExpr>(this, CharacterClassExpr.class, left);
+ this.right = new NullableRef<CharacterClassExpr>(this, CharacterClassExpr.class, right);
+ }
+
+ public CharacterClassExpr getLeft()
+ {
+ return left.get();
+ }
+
+ public void setLeft(CharacterClassExpr left)
+ {
+ this.left.set(left);
+ }
+
+ public CharacterClassExpr getRight()
+ {
+ return right.get();
+ }
+
+ public void setRight(CharacterClassExpr right)
+ {
+ this.right.set(right);
+ }
+
+ @Override
+ public CharacterClassExpr remove(char c)
+ {
+ if (left.isNotNull())
+ {
+ left.get().remove(c);
+ }
+ if (right.isNotNull())
+ {
+ right.get().remove(c);
+ }
+ return this;
+ }
+
+ @Override
+ public CharacterClassExpr replace(char src, char dst)
+ {
+ if (left.isNotNull())
+ {
+ left.get().replace(src, dst);
+ }
+ if (right.isNotNull())
+ {
+ right.get().replace(src, dst);
+ }
+ return this;
+ }
+
+ @Override
+ public String toString()
+ {
+ String l = left.isNotNull() ? left.get().toString() : "";
+ String r = right.isNotNull() ? right.get().toString() : "";
+ return "[" + l + "||" + r + "]";
+ }
+ }
+
+ public static class And extends CharacterClassExpr
+ {
+
+ /** . */
+ private final Ref<CharacterClassExpr> left;
+
+ /** . */
+ private final Ref<CharacterClassExpr> right;
+
+ public And(CharacterClassExpr left, CharacterClassExpr right)
+ {
+ this.left = new NullableRef<CharacterClassExpr>(this, CharacterClassExpr.class, left);
+ this.right = new NullableRef<CharacterClassExpr>(this, CharacterClassExpr.class, right);
+ }
+
+ public CharacterClassExpr getLeft()
+ {
+ return left.get();
+ }
+
+ public void setLeft(CharacterClassExpr left)
+ {
+ this.left.set(left);
+ }
+
+ public CharacterClassExpr getRight()
+ {
+ return right.get();
+ }
+
+ public void setRight(CharacterClassExpr right)
+ {
+ this.right.set(right);
+ }
+
+ @Override
+ public CharacterClassExpr remove(char c)
+ {
+ if (left.isNotNull())
+ {
+ left.get().remove(c);
+ }
+ if (right.isNotNull())
+ {
+ right.get().remove(c);
+ }
+ return this;
+ }
+
+ @Override
+ public CharacterClassExpr replace(char src, char dst)
+ {
+ if (left.isNotNull())
+ {
+ left.get().replace(src, dst);
+ }
+ if (right.isNotNull())
+ {
+ right.get().replace(src, dst);
+ }
+ return this;
+ }
+
+ @Override
+ public String toString()
+ {
+ String l = left.isNotNull() ? left.get().toString() : "";
+ String r = right.isNotNull() ? right.get().toString() : "";
+ return "[" + l + "&&" + r + "]";
+ }
+ }
+
+ public static class Char extends CharacterClassExpr
+ {
+
+ /** . */
+ private char value;
+
+ public Char(char value)
+ {
+ this.value = value;
+ }
+
+ public char getValue()
+ {
+ return value;
+ }
+
+ public void setValue(char value)
+ {
+ this.value = value;
+ }
+
+ @Override
+ public CharacterClassExpr remove(char c)
+ {
+ if (c == value)
+ {
+ replaceBy(null);
+ return null;
+ }
+ else
+ {
+ return this;
+ }
+ }
+
+ @Override
+ public CharacterClassExpr replace(char src, char dst)
+ {
+ if (src == value)
+ {
+ value = dst;
+ }
+ return this;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "[" + value + "]";
+ }
+ }
+
+ public static class Range extends CharacterClassExpr
+ {
+
+ /** From inclusive. */
+ private RENode.CharacterClassExpr.Char from;
+
+ /** To inclusive. */
+ private RENode.CharacterClassExpr.Char to;
+
+ public Range(RENode.CharacterClassExpr.Char from, RENode.CharacterClassExpr.Char to)
+ {
+ if (from.value > to.value)
+ {
+ throw new IllegalArgumentException("From cannot be greater or equals than to");
+ }
+ this.from = from;
+ this.to = to;
+ }
+
+ public CharacterClassExpr remove(char c) throws IllegalArgumentException
+ {
+ if (from.value == to.value)
+ {
+ if (from.value == c)
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+ else if (from.value +1 == to.value)
+ {
+ if (from.value == c)
+ {
+ Char repl = new Char(to.value);
+ replaceBy(repl);
+ return repl;
+ }
+ else
+ {
+ Char repl = new Char(from.value);
+ replaceBy(repl);
+ return repl;
+ }
+ }
+ else
+ {
+ if (from.value == c)
+ {
+ from.value++;
+ }
+ else if (to.value == c)
+ {
+ to.value--;
+ }
+ else if (from.value < c && c < to.value)
+ {
+ CharacterClassExpr left;
+ if (from.value + 1 == c)
+ {
+ left = new Char(from.value);
+ }
+ else
+ {
+ left = new Range(from, new Char((char)(c - 1)));
+ }
+ CharacterClassExpr right;
+ if (c == to.value - 1)
+ {
+ right = new Char(to.value);
+ }
+ else
+ {
+ right = new Range(new Char((char)(c + 1)), to);
+ }
+ Or repl = new Or(left, right);
+ replaceBy(repl);
+ return repl;
+ }
+ }
+
+ // We keep the same node
+ return this;
+ }
+
+ @Override
+ public CharacterClassExpr replace(char src, char dst)
+ {
+ CharacterClassExpr repl = remove(src);
+ if (repl != this)
+ {
+ Or or = new Or(null, new Char(dst));
+ repl.replaceBy(or);
+ or.setLeft(repl);
+ repl = or;
+ }
+ return repl;
+ }
+
+ public RENode.CharacterClassExpr.Char getFrom()
+ {
+ return from;
+ }
+
+ public RENode.CharacterClassExpr.Char getTo()
+ {
+ return to;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "[" + from.value + "-" + to.value + "]";
+ }
+ }
+ }
+
+ protected abstract class Ref<N extends RENode>
+ {
+
+ /** . */
+ private final Class<N> type;
+
+ /** . */
+ private final RENode parent;
+
+ protected Ref(RENode parent, Class<N> type)
+ {
+ this.parent = parent;
+ this.type = type;
+ }
+
+ public final Class<N> getType()
+ {
+ return type;
+ }
+
+ protected abstract N set(N node);
+
+ protected abstract N get();
+
+ protected final boolean isNull()
+ {
+ return get() == null;
+ }
+
+ protected final boolean isNotNull()
+ {
+ return get() != null;
+ }
+
+ protected final N replace(RENode that)
+ {
+ if (that == null || type.isInstance(that))
+ {
+ return set(type.cast(that));
+ }
+ else
+ {
+ throw new ClassCastException("Cannot cast node with type " + that.getClass().getName() + " to type " +
+ type.getName());
+ }
+ }
+
+ }
+
+ protected class NullableRef<N extends RENode> extends Ref<N>
+ {
+
+ /** . */
+ private N node;
+
+ public NullableRef(RENode parent, Class<N> type)
+ {
+ this(parent, type, null);
+ }
+
+ public NullableRef(RENode parent, Class<N> type, N node)
+ {
+ super(parent, type);
+
+ //
+ if (node != null)
+ {
+ if (node.owner != null)
+ {
+ throw new IllegalArgumentException();
+ }
+ else
+ {
+ node.owner = this;
+ }
+ }
+ this.node = node;
+ }
+
+ @Override
+ protected N set(N node)
+ {
+ if (node != null && node.owner != null)
+ {
+ throw new IllegalArgumentException();
+ }
+ N previous = this.node;
+ if (this.node != null)
+ {
+ this.node.owner = null;
+ }
+ if (node != null)
+ {
+ node.owner = this;
+ this.node = node;
+ }
+ else
+ {
+ this.node = null;
+ }
+ return previous;
+ }
+
+ @Override
+ protected N get()
+ {
+ return node;
+ }
+ }
+
+ protected class NonNullableRef<N extends RENode> extends Ref<N>
+ {
+
+ /** . */
+ private N node;
+
+ public NonNullableRef(RENode parent, Class<N> type, N node)
+ {
+ super(parent, type);
+
+ //
+ if (node == null)
+ {
+ throw new NullPointerException();
+ }
+ if (node.owner != null)
+ {
+ throw new IllegalArgumentException();
+ }
+ node.owner = this;
+ this.node = node;
+ }
+
+ @Override
+ protected N set(N node)
+ {
+ if (node == null)
+ {
+ throw new NullPointerException("No null node accepted");
+ }
+ if (node.owner != null)
+ {
+ throw new IllegalArgumentException();
+ }
+ N previous = this.node;
+ this.node.owner = null;
+ node.owner = this;
+ this.node = node;
+ return previous;
+ }
+
+ @Override
+ protected N get()
+ {
+ return node;
+ }
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpParser.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpParser.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpParser.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,375 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.regexp;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class RegExpParser
-{
-
- /** . */
- private final Lexer lexer;
-
- public RegExpParser(CharSequence seq)
- {
- this.lexer = new Lexer(seq);
- }
-
- public RegExpParser(Lexer lexer)
- {
- this.lexer = lexer;
- }
-
- public void reset()
- {
- lexer.reset();
- }
-
- public int getIndex()
- {
- return lexer.getIndex();
- }
-
- public RENode parse() throws SyntaxException
- {
- return parseDisjunction();
- }
-
- public boolean isDone()
- {
- return lexer.isDone();
- }
-
- public RENode.Disjunction parseDisjunction() throws SyntaxException
- {
- RENode.Alternative alternative = parseAlternative();
- if (alternative != null)
- {
- if (lexer.next(Kind.OR))
- {
- RENode.Disjunction next = parseDisjunction();
- return new RENode.Disjunction(alternative, next);
- }
- else
- {
- return new RENode.Disjunction(alternative);
- }
- }
- else
- {
- if (lexer.next(Kind.OR))
- {
- RENode.Disjunction next = parseDisjunction();
- return new RENode.Disjunction(null, next);
- }
- else
- {
- return null;
- }
- }
- }
-
- public RENode.Alternative parseAlternative() throws SyntaxException
- {
- RENode.Expr expr = parseExpression();
- if (expr != null)
- {
- RENode.Alternative next = parseAlternative();
- return new RENode.Alternative(expr, next);
- }
- else
- {
- return null;
- }
- }
-
- public RENode.Expr parseExpression() throws SyntaxException
- {
- RENode.Expr expr;
- if (lexer.next(Kind.BEGIN))
- {
- expr = new RENode.Assertion.Begin();
- }
- else if (lexer.next(Kind.END))
- {
- expr = new RENode.Assertion.End();
- }
- else if (lexer.next(Kind.GROUP_OPEN))
- {
- GroupType groupType = GroupType.forPrefix(lexer.getToken());
- RENode.Disjunction group = parseDisjunction();
- if (lexer.next(Kind.GROUP_CLOSE))
- {
- expr = new RENode.Group(group, groupType);
- }
- else
- {
- throw new SyntaxException("Group not closed ");
- }
- }
- else
- {
- expr = parseCharacter();
- }
- if (expr != null)
- {
- Quantifier quantifier = parseQuantifier();
- if (quantifier != null)
- {
- expr.setQuantifier(quantifier);
- }
- }
- return expr;
- }
-
- private static final Pattern QUANTIFIER_PATTERN = Pattern.compile(
- "^" +
- "(\\?|\\+|\\*)|\\{([0-9]+)(?:(,)([0-9]*))?\\}" +
- "$");
-
- public Quantifier parseQuantifier() throws SyntaxException
- {
- if (lexer.next(Kind.QUANTIFIER))
- {
- String quantifierToken = lexer.getToken();
- Matcher matcher = QUANTIFIER_PATTERN.matcher(quantifierToken);
- if (!matcher.matches())
- {
- throw new AssertionError("The quantifier token " + quantifierToken + " is not valid");
- }
- Quantifier.Range range;
- if (matcher.group(1) != null)
- {
- switch (quantifierToken.charAt(0))
- {
- case '*':
- range = Quantifier.Range.zeroOrMore();
- break;
- case '+':
- range = Quantifier.Range.oneOrMore();
- break;
- case '?':
- range = Quantifier.Range.onceOrNotAtAll();
- break;
- default:
- throw new AssertionError();
- }
- }
- else
- {
- int min = Integer.parseInt(matcher.group(2));
- Integer max;
- if (matcher.group(3) != null)
- {
- max = matcher.group(4).isEmpty() ? null : Integer.parseInt(matcher.group(4));
- }
- else
- {
- max = min;
- }
- range = new Quantifier.Range(min, max);
- }
- Quantifier.Mode mode;
- if (lexer.next(Kind.QUANTIFIER_MODE))
- {
- switch (lexer.getToken().charAt(0))
- {
- case '?':
- mode = Quantifier.Mode.RELUCTANT;
- break;
- case '+':
- mode = Quantifier.Mode.POSSESSIVE;
- break;
- default:
- throw new AssertionError();
- }
- }
- else
- {
- mode = Quantifier.Mode.GREEDY;
- }
- return new Quantifier(mode, range);
- }
- else
- {
- return null;
- }
- }
-
- public RENode.Atom parseCharacter() throws SyntaxException
- {
- if (lexer.next(Kind.ANY))
- {
- return new RENode.Any();
- }
- else
- {
- RENode.Atom atom = parseCharacterLiteral();
- if (atom == null)
- {
- atom = parseCharacterClass();
- }
- return atom;
- }
- }
-
- public RENode.Char parseCharacterLiteral() throws SyntaxException
- {
- if (lexer.next(Kind.LITERAL))
- {
- return new RENode.Char(lexer.getToken().charAt(0));
- }
- else
- {
- return null;
- }
- }
-
- public RENode.CharacterClass parseCharacterClass() throws SyntaxException
- {
- RENode.CharacterClassExpr cce = _parseCharacterClass();
- if (cce != null)
- {
- return new RENode.CharacterClass(cce);
- }
- else
- {
- return null;
- }
- }
-
- private RENode.CharacterClassExpr _parseCharacterClass() throws SyntaxException
- {
- if (lexer.next(Kind.CC_OPEN))
- {
- boolean negated = lexer.getToken().length() > 1;
- RENode.CharacterClassExpr expr = parseCharacterClassExpression();
- if (expr != null)
- {
- if (lexer.next(Kind.CC_CLOSE))
- {
- return negated ? new RENode.CharacterClassExpr.Not(expr) : expr;
- }
- else
- {
- throw new SyntaxException("");
- }
- }
- else
- {
- throw new SyntaxException("");
- }
- }
- else
- {
- return null;
- }
- }
-
- public RENode.CharacterClassExpr parseCharacterClassExpression() throws SyntaxException
- {
- RENode.CharacterClassExpr left = parseCharacterClassTerm();
- if (left != null)
- {
- boolean and = lexer.next(Kind.CC_AND);
- RENode.CharacterClassExpr right = parseCharacterClassExpression();
- if (right != null)
- {
- if (and)
- {
- return new RENode.CharacterClassExpr.And(left, right);
- }
- else
- {
- return new RENode.CharacterClassExpr.Or(left, right);
- }
- }
- else
- {
- return left;
- }
- }
- else
- {
- return null;
- }
- }
-
- public RENode.CharacterClassExpr parseCharacterClassTerm() throws SyntaxException
- {
- RENode.CharacterClassExpr expr = _parseCharacterClass();
- if (expr == null)
- {
- RENode.CharacterClassExpr.Char c = parseCharacterClassLiteral();
- if (c != null)
- {
- if (lexer.next(Kind.HYPHEN))
- {
- RENode.CharacterClassExpr.Char to = parseCharacterClassLiteral();
- if (to != null)
- {
- expr = new RENode.CharacterClassExpr.Range(c, to);
- }
- else
- {
- throw new SyntaxException();
- }
- }
- else
- {
- expr = c;
- }
- }
- else if (lexer.next(Kind.ANY))
- {
- // NOT SURE THIS IS CORRECT
- expr = new RENode.CharacterClassExpr.Char('.');
- }
- else if (lexer.next(Kind.BEGIN))
- {
- // NOT SURE THIS IS CORRECT
- expr = new RENode.CharacterClassExpr.Char('^');
- }
- else if (lexer.next(Kind.END))
- {
- // NOT SURE THIS IS CORRECT
- expr = new RENode.CharacterClassExpr.Char('$');
- }
- }
- return expr;
- }
-
- public RENode.CharacterClassExpr.Char parseCharacterClassLiteral() throws SyntaxException
- {
- if (lexer.next(Kind.LITERAL))
- {
- return new RENode.CharacterClassExpr.Char(lexer.getToken().charAt(0));
- }
- else
- {
- return null;
- }
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpParser.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpParser.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpParser.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpParser.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,375 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.regexp;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class RegExpParser
+{
+
+ /** . */
+ private final Lexer lexer;
+
+ public RegExpParser(CharSequence seq)
+ {
+ this.lexer = new Lexer(seq);
+ }
+
+ public RegExpParser(Lexer lexer)
+ {
+ this.lexer = lexer;
+ }
+
+ public void reset()
+ {
+ lexer.reset();
+ }
+
+ public int getIndex()
+ {
+ return lexer.getIndex();
+ }
+
+ public RENode parse() throws SyntaxException
+ {
+ return parseDisjunction();
+ }
+
+ public boolean isDone()
+ {
+ return lexer.isDone();
+ }
+
+ public RENode.Disjunction parseDisjunction() throws SyntaxException
+ {
+ RENode.Alternative alternative = parseAlternative();
+ if (alternative != null)
+ {
+ if (lexer.next(Kind.OR))
+ {
+ RENode.Disjunction next = parseDisjunction();
+ return new RENode.Disjunction(alternative, next);
+ }
+ else
+ {
+ return new RENode.Disjunction(alternative);
+ }
+ }
+ else
+ {
+ if (lexer.next(Kind.OR))
+ {
+ RENode.Disjunction next = parseDisjunction();
+ return new RENode.Disjunction(null, next);
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ public RENode.Alternative parseAlternative() throws SyntaxException
+ {
+ RENode.Expr expr = parseExpression();
+ if (expr != null)
+ {
+ RENode.Alternative next = parseAlternative();
+ return new RENode.Alternative(expr, next);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public RENode.Expr parseExpression() throws SyntaxException
+ {
+ RENode.Expr expr;
+ if (lexer.next(Kind.BEGIN))
+ {
+ expr = new RENode.Assertion.Begin();
+ }
+ else if (lexer.next(Kind.END))
+ {
+ expr = new RENode.Assertion.End();
+ }
+ else if (lexer.next(Kind.GROUP_OPEN))
+ {
+ GroupType groupType = GroupType.forPrefix(lexer.getToken());
+ RENode.Disjunction group = parseDisjunction();
+ if (lexer.next(Kind.GROUP_CLOSE))
+ {
+ expr = new RENode.Group(group, groupType);
+ }
+ else
+ {
+ throw new SyntaxException("Group not closed ");
+ }
+ }
+ else
+ {
+ expr = parseCharacter();
+ }
+ if (expr != null)
+ {
+ Quantifier quantifier = parseQuantifier();
+ if (quantifier != null)
+ {
+ expr.setQuantifier(quantifier);
+ }
+ }
+ return expr;
+ }
+
+ private static final Pattern QUANTIFIER_PATTERN = Pattern.compile(
+ "^" +
+ "(\\?|\\+|\\*)|\\{([0-9]+)(?:(,)([0-9]*))?\\}" +
+ "$");
+
+ public Quantifier parseQuantifier() throws SyntaxException
+ {
+ if (lexer.next(Kind.QUANTIFIER))
+ {
+ String quantifierToken = lexer.getToken();
+ Matcher matcher = QUANTIFIER_PATTERN.matcher(quantifierToken);
+ if (!matcher.matches())
+ {
+ throw new AssertionError("The quantifier token " + quantifierToken + " is not valid");
+ }
+ Quantifier.Range range;
+ if (matcher.group(1) != null)
+ {
+ switch (quantifierToken.charAt(0))
+ {
+ case '*':
+ range = Quantifier.Range.zeroOrMore();
+ break;
+ case '+':
+ range = Quantifier.Range.oneOrMore();
+ break;
+ case '?':
+ range = Quantifier.Range.onceOrNotAtAll();
+ break;
+ default:
+ throw new AssertionError();
+ }
+ }
+ else
+ {
+ int min = Integer.parseInt(matcher.group(2));
+ Integer max;
+ if (matcher.group(3) != null)
+ {
+ max = matcher.group(4).isEmpty() ? null : Integer.parseInt(matcher.group(4));
+ }
+ else
+ {
+ max = min;
+ }
+ range = new Quantifier.Range(min, max);
+ }
+ Quantifier.Mode mode;
+ if (lexer.next(Kind.QUANTIFIER_MODE))
+ {
+ switch (lexer.getToken().charAt(0))
+ {
+ case '?':
+ mode = Quantifier.Mode.RELUCTANT;
+ break;
+ case '+':
+ mode = Quantifier.Mode.POSSESSIVE;
+ break;
+ default:
+ throw new AssertionError();
+ }
+ }
+ else
+ {
+ mode = Quantifier.Mode.GREEDY;
+ }
+ return new Quantifier(mode, range);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public RENode.Atom parseCharacter() throws SyntaxException
+ {
+ if (lexer.next(Kind.ANY))
+ {
+ return new RENode.Any();
+ }
+ else
+ {
+ RENode.Atom atom = parseCharacterLiteral();
+ if (atom == null)
+ {
+ atom = parseCharacterClass();
+ }
+ return atom;
+ }
+ }
+
+ public RENode.Char parseCharacterLiteral() throws SyntaxException
+ {
+ if (lexer.next(Kind.LITERAL))
+ {
+ return new RENode.Char(lexer.getToken().charAt(0));
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public RENode.CharacterClass parseCharacterClass() throws SyntaxException
+ {
+ RENode.CharacterClassExpr cce = _parseCharacterClass();
+ if (cce != null)
+ {
+ return new RENode.CharacterClass(cce);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ private RENode.CharacterClassExpr _parseCharacterClass() throws SyntaxException
+ {
+ if (lexer.next(Kind.CC_OPEN))
+ {
+ boolean negated = lexer.getToken().length() > 1;
+ RENode.CharacterClassExpr expr = parseCharacterClassExpression();
+ if (expr != null)
+ {
+ if (lexer.next(Kind.CC_CLOSE))
+ {
+ return negated ? new RENode.CharacterClassExpr.Not(expr) : expr;
+ }
+ else
+ {
+ throw new SyntaxException("");
+ }
+ }
+ else
+ {
+ throw new SyntaxException("");
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public RENode.CharacterClassExpr parseCharacterClassExpression() throws SyntaxException
+ {
+ RENode.CharacterClassExpr left = parseCharacterClassTerm();
+ if (left != null)
+ {
+ boolean and = lexer.next(Kind.CC_AND);
+ RENode.CharacterClassExpr right = parseCharacterClassExpression();
+ if (right != null)
+ {
+ if (and)
+ {
+ return new RENode.CharacterClassExpr.And(left, right);
+ }
+ else
+ {
+ return new RENode.CharacterClassExpr.Or(left, right);
+ }
+ }
+ else
+ {
+ return left;
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public RENode.CharacterClassExpr parseCharacterClassTerm() throws SyntaxException
+ {
+ RENode.CharacterClassExpr expr = _parseCharacterClass();
+ if (expr == null)
+ {
+ RENode.CharacterClassExpr.Char c = parseCharacterClassLiteral();
+ if (c != null)
+ {
+ if (lexer.next(Kind.HYPHEN))
+ {
+ RENode.CharacterClassExpr.Char to = parseCharacterClassLiteral();
+ if (to != null)
+ {
+ expr = new RENode.CharacterClassExpr.Range(c, to);
+ }
+ else
+ {
+ throw new SyntaxException();
+ }
+ }
+ else
+ {
+ expr = c;
+ }
+ }
+ else if (lexer.next(Kind.ANY))
+ {
+ // NOT SURE THIS IS CORRECT
+ expr = new RENode.CharacterClassExpr.Char('.');
+ }
+ else if (lexer.next(Kind.BEGIN))
+ {
+ // NOT SURE THIS IS CORRECT
+ expr = new RENode.CharacterClassExpr.Char('^');
+ }
+ else if (lexer.next(Kind.END))
+ {
+ // NOT SURE THIS IS CORRECT
+ expr = new RENode.CharacterClassExpr.Char('$');
+ }
+ }
+ return expr;
+ }
+
+ public RENode.CharacterClassExpr.Char parseCharacterClassLiteral() throws SyntaxException
+ {
+ if (lexer.next(Kind.LITERAL))
+ {
+ return new RENode.CharacterClassExpr.Char(lexer.getToken().charAt(0));
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpRenderer.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpRenderer.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpRenderer.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,304 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.regexp;
-
-import java.io.IOException;
-
-/**
- * Renders a {@link RENode} to its pattern representation.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class RegExpRenderer
-{
-
- public final <A extends Appendable> A render(RENode re, A appendable) throws IOException, NullPointerException
- {
- if (re == null)
- {
- throw new NullPointerException("No null disjunction accepted");
- }
- if (appendable == null)
- {
- throw new NullPointerException("No null appendable accepted");
- }
-
- //
- doRender(re, appendable);
-
- //
- return appendable;
- }
-
- protected void doRender(RENode re, Appendable appendable) throws IOException
- {
- if (re instanceof RENode.Disjunction)
- {
- doRender((RENode.Disjunction) re, appendable);
- }
- else if (re instanceof RENode.Alternative)
- {
- doRender((RENode.Alternative) re, appendable);
- }
- else if (re instanceof RENode.Expr)
- {
- doRender((RENode.Expr) re, appendable);
- }
- else
- {
- throw new AssertionError("Was not expecting node " + re);
- }
- }
-
- protected void doRender(RENode.Disjunction disjunction, Appendable appendable) throws IOException, NullPointerException
- {
- RENode.Alternative alternative = disjunction.getAlternative();
- RENode.Disjunction next = disjunction.getNext();
- if (alternative != null)
- {
- doRender(alternative, appendable);
- if (next != null)
- {
- appendable.append('|');
- doRender(next, appendable);
- }
- }
- else if (next != null)
- {
- doRender(next, appendable);
- }
- }
-
- protected void doRender(RENode.Alternative alternative, Appendable appendable) throws IOException, NullPointerException
- {
- doRender(alternative.getExp(), appendable);
- RENode.Alternative next = alternative.getNext();
- if (next != null)
- {
- doRender(next, appendable);
- }
- }
-
- protected void doRender(RENode.Expr expr, Appendable appendable) throws IOException, NullPointerException
- {
- if (expr instanceof RENode.Atom)
- {
- doRender((RENode.Atom) expr, appendable);
- }
- else if (expr instanceof RENode.Group)
- {
- doRender((RENode.Group)expr, appendable);
- }
- else if (expr instanceof RENode.Assertion)
- {
- doRender((RENode.Assertion)expr, appendable);
- }
- else
- {
- throw new AssertionError("Was not expecting node " + expr);
- }
- }
-
- protected void doRender(Quantifier quantifier, Appendable appendable) throws IOException
- {
- quantifier.toString(appendable);
- }
-
- protected void doRender(RENode.Assertion assertion, Appendable appendable) throws IOException
- {
- if (assertion instanceof RENode.Assertion.Begin)
- {
- doRender((RENode.Assertion.Begin)assertion, appendable);
- }
- else if (assertion instanceof RENode.Assertion.End)
- {
- doRender((RENode.Assertion.End)assertion, appendable);
- }
- else
- {
- throw new AssertionError("Was not expecting node " + assertion);
- }
- }
-
- protected void doRender(RENode.Assertion.Begin expr, Appendable appendable) throws IOException
- {
- appendable.append('^');
- if (expr.getQuantifier() != null)
- {
- doRender(expr.getQuantifier(), appendable);
- }
- }
-
- protected void doRender(RENode.Assertion.End expr, Appendable appendable) throws IOException
- {
- appendable.append('$');
- if (expr.getQuantifier() != null)
- {
- doRender(expr.getQuantifier(), appendable);
- }
- }
-
- protected void doRender(RENode.Group expr, Appendable appendable) throws IOException
- {
- appendable.append(expr.getType().getOpen());
- this.doRender(expr.getDisjunction(), appendable);
- appendable.append(expr.getType().getClose());
- if (expr.getQuantifier() != null)
- {
- doRender(expr.getQuantifier(), appendable);
- }
- }
-
- protected void doRender(RENode.Atom atom, Appendable appendable) throws IOException
- {
- if (atom instanceof RENode.Any)
- {
- doRender((RENode.Any) atom, appendable);
- }
- else if (atom instanceof RENode.Char)
- {
- doRender((RENode.Char)atom, appendable);
- }
- else if (atom instanceof RENode.CharacterClass)
- {
- doRender((RENode.CharacterClass)atom, appendable);
- }
- else
- {
- throw new AssertionError("Was not expecting node " + atom);
- }
- }
-
- protected void doRender(RENode.Char expr, Appendable appendable) throws IOException
- {
- Literal.escapeTo(expr.getValue(), appendable);
- if (expr.getQuantifier() != null)
- {
- doRender(expr.getQuantifier(), appendable);
- }
- }
-
- protected void doRender(RENode.Any expr, Appendable appendable) throws IOException
- {
- appendable.append('.');
- if (expr.getQuantifier() != null)
- {
- doRender(expr.getQuantifier(), appendable);
- }
- }
-
- protected void doRender(RENode.CharacterClass expr, Appendable appendable) throws IOException
- {
- appendable.append("[");
- doRender(expr.getExpr(), appendable);
- appendable.append("]");
- if (expr.getQuantifier() != null)
- {
- doRender(expr.getQuantifier(), appendable);
- }
- }
-
- protected void doRender(RENode.CharacterClassExpr expr, Appendable appendable) throws IOException, NullPointerException
- {
- if (expr instanceof RENode.CharacterClassExpr.Char)
- {
- doRender((RENode.CharacterClassExpr.Char) expr, appendable);
- }
- else if (expr instanceof RENode.CharacterClass.CharacterClassExpr.Range)
- {
- doRender((RENode.CharacterClassExpr.Range) expr, appendable);
- }
- else if (expr instanceof RENode.CharacterClass.CharacterClassExpr.And)
- {
- doRender((RENode.CharacterClassExpr.And) expr, appendable);
- }
- else if (expr instanceof RENode.CharacterClass.CharacterClassExpr.Or)
- {
- doRender((RENode.CharacterClassExpr.Or) expr, appendable);
- }
- else if (expr instanceof RENode.CharacterClass.CharacterClassExpr.Not)
- {
- doRender((RENode.CharacterClassExpr.Not) expr, appendable);
- }
- else
- {
- throw new AssertionError();
- }
- }
-
- protected void doRender(RENode.CharacterClassExpr.Not expr, Appendable appendable) throws IOException
- {
- boolean needBrace = false;
- for (RENode current = expr.getParent();current != null;current = current.getParent())
- {
- if (current instanceof RENode.CharacterClassExpr.Or)
- {
- needBrace = true;
- break;
- }
- else if (current instanceof RENode.CharacterClassExpr.And)
- {
- needBrace = true;
- break;
- }
- else if (current instanceof RENode.CharacterClassExpr.Not)
- {
- needBrace = true;
- break;
- }
- }
- if (needBrace)
- {
- appendable.append("[");
- }
- appendable.append("^");
- doRender(expr.getNegated(), appendable);
- if (needBrace)
- {
- appendable.append(']');
- }
- }
-
- protected void doRender(RENode.CharacterClassExpr.Or expr, Appendable appendable) throws IOException
- {
- doRender(expr.getLeft(), appendable);
- doRender(expr.getRight(), appendable);
- }
-
- protected void doRender(RENode.CharacterClassExpr.And expr, Appendable appendable) throws IOException
- {
- doRender(expr.getLeft(), appendable);
- appendable.append("&&");
- doRender(expr.getRight(), appendable);
- }
-
- protected void doRender(RENode.CharacterClassExpr.Range expr, Appendable appendable) throws IOException
- {
- doRender(expr.getFrom(), appendable);
- appendable.append('-');
- doRender(expr.getTo(), appendable);
- }
-
- protected void doRender(RENode.CharacterClassExpr.Char expr, Appendable appendable) throws IOException
- {
- Literal.escapeTo(expr.getValue(), appendable);
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpRenderer.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpRenderer.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpRenderer.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RegExpRenderer.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,304 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.regexp;
+
+import java.io.IOException;
+
+/**
+ * Renders a {@link RENode} to its pattern representation.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class RegExpRenderer
+{
+
+ public final <A extends Appendable> A render(RENode re, A appendable) throws IOException, NullPointerException
+ {
+ if (re == null)
+ {
+ throw new NullPointerException("No null disjunction accepted");
+ }
+ if (appendable == null)
+ {
+ throw new NullPointerException("No null appendable accepted");
+ }
+
+ //
+ doRender(re, appendable);
+
+ //
+ return appendable;
+ }
+
+ protected void doRender(RENode re, Appendable appendable) throws IOException
+ {
+ if (re instanceof RENode.Disjunction)
+ {
+ doRender((RENode.Disjunction) re, appendable);
+ }
+ else if (re instanceof RENode.Alternative)
+ {
+ doRender((RENode.Alternative) re, appendable);
+ }
+ else if (re instanceof RENode.Expr)
+ {
+ doRender((RENode.Expr) re, appendable);
+ }
+ else
+ {
+ throw new AssertionError("Was not expecting node " + re);
+ }
+ }
+
+ protected void doRender(RENode.Disjunction disjunction, Appendable appendable) throws IOException, NullPointerException
+ {
+ RENode.Alternative alternative = disjunction.getAlternative();
+ RENode.Disjunction next = disjunction.getNext();
+ if (alternative != null)
+ {
+ doRender(alternative, appendable);
+ if (next != null)
+ {
+ appendable.append('|');
+ doRender(next, appendable);
+ }
+ }
+ else if (next != null)
+ {
+ doRender(next, appendable);
+ }
+ }
+
+ protected void doRender(RENode.Alternative alternative, Appendable appendable) throws IOException, NullPointerException
+ {
+ doRender(alternative.getExp(), appendable);
+ RENode.Alternative next = alternative.getNext();
+ if (next != null)
+ {
+ doRender(next, appendable);
+ }
+ }
+
+ protected void doRender(RENode.Expr expr, Appendable appendable) throws IOException, NullPointerException
+ {
+ if (expr instanceof RENode.Atom)
+ {
+ doRender((RENode.Atom) expr, appendable);
+ }
+ else if (expr instanceof RENode.Group)
+ {
+ doRender((RENode.Group)expr, appendable);
+ }
+ else if (expr instanceof RENode.Assertion)
+ {
+ doRender((RENode.Assertion)expr, appendable);
+ }
+ else
+ {
+ throw new AssertionError("Was not expecting node " + expr);
+ }
+ }
+
+ protected void doRender(Quantifier quantifier, Appendable appendable) throws IOException
+ {
+ quantifier.toString(appendable);
+ }
+
+ protected void doRender(RENode.Assertion assertion, Appendable appendable) throws IOException
+ {
+ if (assertion instanceof RENode.Assertion.Begin)
+ {
+ doRender((RENode.Assertion.Begin)assertion, appendable);
+ }
+ else if (assertion instanceof RENode.Assertion.End)
+ {
+ doRender((RENode.Assertion.End)assertion, appendable);
+ }
+ else
+ {
+ throw new AssertionError("Was not expecting node " + assertion);
+ }
+ }
+
+ protected void doRender(RENode.Assertion.Begin expr, Appendable appendable) throws IOException
+ {
+ appendable.append('^');
+ if (expr.getQuantifier() != null)
+ {
+ doRender(expr.getQuantifier(), appendable);
+ }
+ }
+
+ protected void doRender(RENode.Assertion.End expr, Appendable appendable) throws IOException
+ {
+ appendable.append('$');
+ if (expr.getQuantifier() != null)
+ {
+ doRender(expr.getQuantifier(), appendable);
+ }
+ }
+
+ protected void doRender(RENode.Group expr, Appendable appendable) throws IOException
+ {
+ appendable.append(expr.getType().getOpen());
+ this.doRender(expr.getDisjunction(), appendable);
+ appendable.append(expr.getType().getClose());
+ if (expr.getQuantifier() != null)
+ {
+ doRender(expr.getQuantifier(), appendable);
+ }
+ }
+
+ protected void doRender(RENode.Atom atom, Appendable appendable) throws IOException
+ {
+ if (atom instanceof RENode.Any)
+ {
+ doRender((RENode.Any) atom, appendable);
+ }
+ else if (atom instanceof RENode.Char)
+ {
+ doRender((RENode.Char)atom, appendable);
+ }
+ else if (atom instanceof RENode.CharacterClass)
+ {
+ doRender((RENode.CharacterClass)atom, appendable);
+ }
+ else
+ {
+ throw new AssertionError("Was not expecting node " + atom);
+ }
+ }
+
+ protected void doRender(RENode.Char expr, Appendable appendable) throws IOException
+ {
+ Literal.escapeTo(expr.getValue(), appendable);
+ if (expr.getQuantifier() != null)
+ {
+ doRender(expr.getQuantifier(), appendable);
+ }
+ }
+
+ protected void doRender(RENode.Any expr, Appendable appendable) throws IOException
+ {
+ appendable.append('.');
+ if (expr.getQuantifier() != null)
+ {
+ doRender(expr.getQuantifier(), appendable);
+ }
+ }
+
+ protected void doRender(RENode.CharacterClass expr, Appendable appendable) throws IOException
+ {
+ appendable.append("[");
+ doRender(expr.getExpr(), appendable);
+ appendable.append("]");
+ if (expr.getQuantifier() != null)
+ {
+ doRender(expr.getQuantifier(), appendable);
+ }
+ }
+
+ protected void doRender(RENode.CharacterClassExpr expr, Appendable appendable) throws IOException, NullPointerException
+ {
+ if (expr instanceof RENode.CharacterClassExpr.Char)
+ {
+ doRender((RENode.CharacterClassExpr.Char) expr, appendable);
+ }
+ else if (expr instanceof RENode.CharacterClass.CharacterClassExpr.Range)
+ {
+ doRender((RENode.CharacterClassExpr.Range) expr, appendable);
+ }
+ else if (expr instanceof RENode.CharacterClass.CharacterClassExpr.And)
+ {
+ doRender((RENode.CharacterClassExpr.And) expr, appendable);
+ }
+ else if (expr instanceof RENode.CharacterClass.CharacterClassExpr.Or)
+ {
+ doRender((RENode.CharacterClassExpr.Or) expr, appendable);
+ }
+ else if (expr instanceof RENode.CharacterClass.CharacterClassExpr.Not)
+ {
+ doRender((RENode.CharacterClassExpr.Not) expr, appendable);
+ }
+ else
+ {
+ throw new AssertionError();
+ }
+ }
+
+ protected void doRender(RENode.CharacterClassExpr.Not expr, Appendable appendable) throws IOException
+ {
+ boolean needBrace = false;
+ for (RENode current = expr.getParent();current != null;current = current.getParent())
+ {
+ if (current instanceof RENode.CharacterClassExpr.Or)
+ {
+ needBrace = true;
+ break;
+ }
+ else if (current instanceof RENode.CharacterClassExpr.And)
+ {
+ needBrace = true;
+ break;
+ }
+ else if (current instanceof RENode.CharacterClassExpr.Not)
+ {
+ needBrace = true;
+ break;
+ }
+ }
+ if (needBrace)
+ {
+ appendable.append("[");
+ }
+ appendable.append("^");
+ doRender(expr.getNegated(), appendable);
+ if (needBrace)
+ {
+ appendable.append(']');
+ }
+ }
+
+ protected void doRender(RENode.CharacterClassExpr.Or expr, Appendable appendable) throws IOException
+ {
+ doRender(expr.getLeft(), appendable);
+ doRender(expr.getRight(), appendable);
+ }
+
+ protected void doRender(RENode.CharacterClassExpr.And expr, Appendable appendable) throws IOException
+ {
+ doRender(expr.getLeft(), appendable);
+ appendable.append("&&");
+ doRender(expr.getRight(), appendable);
+ }
+
+ protected void doRender(RENode.CharacterClassExpr.Range expr, Appendable appendable) throws IOException
+ {
+ doRender(expr.getFrom(), appendable);
+ appendable.append('-');
+ doRender(expr.getTo(), appendable);
+ }
+
+ protected void doRender(RENode.CharacterClassExpr.Char expr, Appendable appendable) throws IOException
+ {
+ Literal.escapeTo(expr.getValue(), appendable);
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Stream.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Stream.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Stream.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.regexp;
-
-import java.util.NoSuchElementException;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- */
-public class Stream
-{
-
- /** . */
- private final CharSequence stream;
-
- /** . */
- private int index;
-
- public Stream(CharSequence stream)
- {
- this.stream = stream;
- this.index = 0;
- }
-
- public int getIndex()
- {
- return index;
- }
-
- public void reset()
- {
- index = 0;
- }
-
- public boolean hasNext()
- {
- return hasNext(0);
- }
-
- public boolean hasNext(int delta)
- {
- return index + delta < stream.length();
- }
-
- public boolean hasNext(char c)
- {
- return hasNext(0, c);
- }
-
- public boolean hasNext(int delta, char c)
- {
- int offset = index + delta;
- return offset < stream.length() && stream.charAt(offset) == c;
- }
-
- public boolean next(char c)
- {
- boolean a = index < stream.length() && stream.charAt(index) == c;
- if (a)
- {
- index++;
- }
- return a;
- }
-
- public Character peek()
- {
- return peek(0);
- }
-
- public Character peek(int delta)
- {
- int offset = index + delta;
- if (offset < stream.length())
- {
- return stream.charAt(offset);
- }
- else
- {
- return null;
- }
- }
-
- public char next()
- {
- if (hasNext())
- {
- return stream.charAt(index++);
- }
- else
- {
- throw new NoSuchElementException();
- }
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Stream.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Stream.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Stream.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/Stream.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.regexp;
+
+import java.util.NoSuchElementException;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public class Stream
+{
+
+ /** . */
+ private final CharSequence stream;
+
+ /** . */
+ private int index;
+
+ public Stream(CharSequence stream)
+ {
+ this.stream = stream;
+ this.index = 0;
+ }
+
+ public int getIndex()
+ {
+ return index;
+ }
+
+ public void reset()
+ {
+ index = 0;
+ }
+
+ public boolean hasNext()
+ {
+ return hasNext(0);
+ }
+
+ public boolean hasNext(int delta)
+ {
+ return index + delta < stream.length();
+ }
+
+ public boolean hasNext(char c)
+ {
+ return hasNext(0, c);
+ }
+
+ public boolean hasNext(int delta, char c)
+ {
+ int offset = index + delta;
+ return offset < stream.length() && stream.charAt(offset) == c;
+ }
+
+ public boolean next(char c)
+ {
+ boolean a = index < stream.length() && stream.charAt(index) == c;
+ if (a)
+ {
+ index++;
+ }
+ return a;
+ }
+
+ public Character peek()
+ {
+ return peek(0);
+ }
+
+ public Character peek(int delta)
+ {
+ int offset = index + delta;
+ if (offset < stream.length())
+ {
+ return stream.charAt(offset);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public char next()
+ {
+ if (hasNext())
+ {
+ return stream.charAt(index++);
+ }
+ else
+ {
+ throw new NoSuchElementException();
+ }
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/SubCharSequence.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/SubCharSequence.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/SubCharSequence.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.regexp;
-
-/**
- * Should make it to org.gatein.common somehow.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class SubCharSequence implements CharSequence
-{
-
- /** . */
- private final CharSequence s;
-
- /** . */
- private final int from;
-
- /** . */
- private final int to;
-
- public SubCharSequence(CharSequence s, int from, int to)
- {
- if (s == null)
- {
- throw new NullPointerException("No null string accepted");
- }
- if (from < 0)
- {
- throw new IllegalArgumentException("No negative lower bound accepted");
- }
- if (to > s.length())
- {
- throw new IllegalArgumentException("Upper bound cannot be greater than the sequence length");
- }
- if (from > to)
- {
- throw new IllegalArgumentException("Upper bound cannot be lesser than the lower bound");
- }
-
- //
- this.s = s;
- this.from = from;
- this.to = to;
- }
-
- public int length()
- {
- return to - from;
- }
-
- public char charAt(int index)
- {
- if (index < 0)
- {
- throw new IndexOutOfBoundsException("Index cannot be negative");
- }
- index += from;
- if (index >= to)
- {
- throw new IndexOutOfBoundsException("Index cannot be negative");
- }
- return s.charAt(index);
- }
-
- public CharSequence subSequence(int start, int end)
- {
- if (start < 0)
- {
- throw new IndexOutOfBoundsException("The start argument cannot be negative");
- }
- if (end < 0)
- {
- throw new IndexOutOfBoundsException("The start argument cannot be negative");
- }
- if (start > end)
- {
- throw new IndexOutOfBoundsException("The start argument cannot greater than the end argument");
- }
- end += from;
- if (end > to)
- {
- throw new IndexOutOfBoundsException("The end argument cannot greater than the length");
- }
- return new SubCharSequence(s, from + start, end);
- }
-
- @Override
- public String toString()
- {
- return s.subSequence(from, to).toString();
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/SubCharSequence.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/SubCharSequence.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/SubCharSequence.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/SubCharSequence.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.regexp;
+
+/**
+ * Should make it to org.gatein.common somehow.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class SubCharSequence implements CharSequence
+{
+
+ /** . */
+ private final CharSequence s;
+
+ /** . */
+ private final int from;
+
+ /** . */
+ private final int to;
+
+ public SubCharSequence(CharSequence s, int from, int to)
+ {
+ if (s == null)
+ {
+ throw new NullPointerException("No null string accepted");
+ }
+ if (from < 0)
+ {
+ throw new IllegalArgumentException("No negative lower bound accepted");
+ }
+ if (to > s.length())
+ {
+ throw new IllegalArgumentException("Upper bound cannot be greater than the sequence length");
+ }
+ if (from > to)
+ {
+ throw new IllegalArgumentException("Upper bound cannot be lesser than the lower bound");
+ }
+
+ //
+ this.s = s;
+ this.from = from;
+ this.to = to;
+ }
+
+ public int length()
+ {
+ return to - from;
+ }
+
+ public char charAt(int index)
+ {
+ if (index < 0)
+ {
+ throw new IndexOutOfBoundsException("Index cannot be negative");
+ }
+ index += from;
+ if (index >= to)
+ {
+ throw new IndexOutOfBoundsException("Index cannot be negative");
+ }
+ return s.charAt(index);
+ }
+
+ public CharSequence subSequence(int start, int end)
+ {
+ if (start < 0)
+ {
+ throw new IndexOutOfBoundsException("The start argument cannot be negative");
+ }
+ if (end < 0)
+ {
+ throw new IndexOutOfBoundsException("The start argument cannot be negative");
+ }
+ if (start > end)
+ {
+ throw new IndexOutOfBoundsException("The start argument cannot greater than the end argument");
+ }
+ end += from;
+ if (end > to)
+ {
+ throw new IndexOutOfBoundsException("The end argument cannot greater than the length");
+ }
+ return new SubCharSequence(s, from + start, end);
+ }
+
+ @Override
+ public String toString()
+ {
+ return s.subSequence(from, to).toString();
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/SyntaxException.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/SyntaxException.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/SyntaxException.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.regexp;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class SyntaxException extends Exception
-{
- public SyntaxException()
- {
- }
-
- public SyntaxException(String s)
- {
- super(s);
- }
-
- public SyntaxException(String s, Throwable throwable)
- {
- super(s, throwable);
- }
-
- public SyntaxException(Throwable throwable)
- {
- super(throwable);
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/SyntaxException.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/SyntaxException.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/SyntaxException.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/SyntaxException.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.regexp;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class SyntaxException extends Exception
+{
+ public SyntaxException()
+ {
+ }
+
+ public SyntaxException(String s)
+ {
+ super(s);
+ }
+
+ public SyntaxException(String s, Throwable throwable)
+ {
+ super(s, throwable);
+ }
+
+ public SyntaxException(Throwable throwable)
+ {
+ super(throwable);
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ControlMode.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ControlMode.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ControlMode.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- */
-public enum ControlMode
-{
-
- OPTIONAL,
-
- REQUIRED
-
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ControlMode.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ControlMode.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ControlMode.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ControlMode.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public enum ControlMode
+{
+
+ OPTIONAL,
+
+ REQUIRED
+
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/EncodingMode.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/EncodingMode.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/EncodingMode.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-/**
- * Specifies how a string value should be encoded in an URL.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public enum EncodingMode
-{
-
- /**
- * FORM encodes the whole string with the <code>x-www-form-urlencoded</code> also known as
- * <i>default form encoding</i>. For instance the string "/a/b" is encoded to "%2Fa%2Fb".
- */
- FORM,
-
- /**
- * PRESERVE_PATH encodes the whole string like the {@link #FORM} but preserve the path separators. For
- * instance the string "/a b" is enocded to "/a+b".
- */
- PRESERVE_PATH
-
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/EncodingMode.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/EncodingMode.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/EncodingMode.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/EncodingMode.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+/**
+ * Specifies how a string value should be encoded in an URL.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public enum EncodingMode
+{
+
+ /**
+ * FORM encodes the whole string with the <code>x-www-form-urlencoded</code> also known as
+ * <i>default form encoding</i>. For instance the string "/a/b" is encoded to "%2Fa%2Fb".
+ */
+ FORM,
+
+ /**
+ * PRESERVE_PATH encodes the whole string like the {@link #FORM} but preserve the path separators. For
+ * instance the string "/a b" is enocded to "/a+b".
+ */
+ PRESERVE_PATH
+
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/MalformedRouteException.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/MalformedRouteException.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/MalformedRouteException.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-/**
- * A malformed route.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class MalformedRouteException extends RouterConfigException
-{
- public MalformedRouteException()
- {
- }
-
- public MalformedRouteException(String s)
- {
- super(s);
- }
-
- public MalformedRouteException(String s, Throwable throwable)
- {
- super(s, throwable);
- }
-
- public MalformedRouteException(Throwable throwable)
- {
- super(throwable);
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/MalformedRouteException.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/MalformedRouteException.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/MalformedRouteException.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/MalformedRouteException.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+/**
+ * A malformed route.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class MalformedRouteException extends RouterConfigException
+{
+ public MalformedRouteException()
+ {
+ }
+
+ public MalformedRouteException(String s)
+ {
+ super(s);
+ }
+
+ public MalformedRouteException(String s, Throwable throwable)
+ {
+ super(s, throwable);
+ }
+
+ public MalformedRouteException(Throwable throwable)
+ {
+ super(throwable);
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Param.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Param.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Param.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.exoplatform.web.controller.QualifiedName;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- */
-class Param
-{
-
- /** . */
- final QualifiedName name;
-
- Param(QualifiedName name)
- {
- if (name == null)
- {
- throw new NullPointerException("No null name accepted");
- }
-
- //
- this.name = name;
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Param.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Param.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Param.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Param.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.web.controller.QualifiedName;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+class Param
+{
+
+ /** . */
+ final QualifiedName name;
+
+ Param(QualifiedName name)
+ {
+ if (name == null)
+ {
+ throw new NullPointerException("No null name accepted");
+ }
+
+ //
+ this.name = name;
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Path.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Path.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Path.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,291 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.gatein.common.io.UndeclaredIOException;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- */
-class Path
-{
-
- static Path parse(String path)
- {
- try
- {
- Data data = new Data(path);
- return new Path(data, 0);
- }
- catch (IOException e)
- {
- throw new UndeclaredIOException(e);
- }
- }
-
- /** Constant. */
- public static final Path SLASH = Path.parse("/");
-
- private static final class Data
- {
-
- private int hex(char c)
- {
- if (c >= '0' && c <= '9')
- {
- return c - '0';
- }
- else if (c >= 'A' && c <= 'F')
- {
- return c + 10 - 'A';
- }
- else if (c >= 'a' && c <= 'f')
- {
- return c + 10 - 'a';
- }
- else
- {
- throw new IllegalArgumentException("Invalid hex code in " + rawValue);
- }
- }
-
- /** . */
- private final String rawValue;
-
- /** . */
- private final String value;
-
- /** . */
- private final int[] mapping;
-
- private Data(String rawValue) throws IOException, IllegalArgumentException
- {
- this.rawValue = rawValue;
-
- //
- int len = rawValue.length();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- int[] mapping = new int[len];
- int count = 0;
-
- //
- int i = 0;
- while (i < len)
- {
- char c = rawValue.charAt(i);
- mapping[count++] = i;
-
- //
- if (PercentEncoding.PATH_SEGMENT.accept(c))
- {
- baos.write((int)c);
- i++;
- }
- else if (c == '%')
- {
- if (i + 2 >= len)
- {
- throw new IllegalArgumentException("Invalid percent escape in " + rawValue);
- }
- int h = (hex(rawValue.charAt(i + 1)) << 4) + hex(rawValue.charAt(i + 2));
- baos.write(h);
- i += 3;
-
- // Compute the number of bytes to read for this char
- int size = 0;
- for (int j = h;(j & 0x80) != 0;j = j << 1)
- {
- size++;
- }
- if (size == 0)
- {
- size = 1;
- }
- else if (size > 6)
- {
- throw new IllegalArgumentException("Invalid percent escape in " + rawValue);
- }
-
- // Compute the offset we need to read those bytes
- int to = i + (size - 1) * 3;
- if (to > len)
- {
- throw new IllegalArgumentException("Invalid percent escape in " + rawValue);
- }
-
- // Read what we need
- while (i < to)
- {
- if (rawValue.charAt(i) != '%')
- {
- throw new IllegalArgumentException("Invalid percent escape in " + rawValue);
- }
- h = (hex(rawValue.charAt(i + 1)) << 4) + hex(rawValue.charAt(i + 2));
- baos.write(h);
- i += 3;
- }
- }
- else if (c == '/')
- {
- baos.write('/');
- i++;
- }
- else
- {
- throw new IllegalArgumentException("Unsupported char value in path " + (int)c + " / " + c);
- }
- }
-
- //
- this.value = baos.toString("UTF-8");
- this.mapping = mapping;
- }
-
- int getRawStart(int index)
- {
- if (index < 0)
- {
- throw new IndexOutOfBoundsException("No negative index accepted");
- }
- if (index >= value.length())
- {
- throw new IndexOutOfBoundsException("Index can't be greater than length");
- }
- return mapping[index];
- }
-
- int getRawEnd(int index)
- {
- if (index < 0)
- {
- throw new IndexOutOfBoundsException("No negative index accepted");
- }
- if (index >= value.length())
- {
- throw new IndexOutOfBoundsException("Index can't be greater than length");
- }
- index++;
- if (index == value.length())
- {
- return rawValue.length();
- }
- else
- {
- return mapping[index];
- }
- }
- }
-
- /** . */
- private final Data data;
-
- /** . */
- private final int offset;
-
- /** . */
- private final String value;
-
- private Path(Data data, int offset)
- {
- this.data = data;
- this.offset = offset;
- this.value = data.value.substring(offset);
- }
-
- String getValue()
- {
- return value;
- }
-
- int getRawStart(int index)
- {
- return data.getRawStart(innerIndex(index)) - data.getRawStart(offset);
- }
-
- int getRawEnd(int index)
- {
- return data.getRawEnd(innerIndex(index))- data.getRawStart(offset);
- }
-
- int getRawLength(int index)
- {
- return getRawEnd(index) - getRawStart(index);
- }
-
- char charAt(int pos)
- {
- return value.charAt(pos);
- }
-
- int length()
- {
- return value.length();
- }
-
- int indexOf(int c, int index)
- {
- return value.indexOf(c, index);
- }
-
- Path subPath(int index)
- {
- if (index < 0)
- {
- throw new IndexOutOfBoundsException("No negative index accepted");
- }
- else if (index == 0)
- {
- return this;
- }
- else
- {
- int i = offset + index;
- if (i >= data.value.length())
- {
- throw new IndexOutOfBoundsException("Index can't be greater than length");
- }
- return new Path(data, i);
- }
- }
-
- /**
- * Convert the specified index to the internal index.
- *
- * @param outterIndex the outter index
- * @return the inner index value
- * @throws IndexOutOfBoundsException if the outter index is not correct
- */
- private int innerIndex(int outterIndex) throws IndexOutOfBoundsException
- {
- if (outterIndex < 0)
- {
- throw new IndexOutOfBoundsException("No negative index accepted");
- }
- int pos = offset + outterIndex;
- if (pos > data.value.length())
- {
- throw new IndexOutOfBoundsException("Index can't be greater than length");
- }
- return pos;
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Path.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Path.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Path.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Path.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,291 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.gatein.common.io.UndeclaredIOException;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+class Path
+{
+
+ static Path parse(String path)
+ {
+ try
+ {
+ Data data = new Data(path);
+ return new Path(data, 0);
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+
+ /** Constant. */
+ public static final Path SLASH = Path.parse("/");
+
+ private static final class Data
+ {
+
+ private int hex(char c)
+ {
+ if (c >= '0' && c <= '9')
+ {
+ return c - '0';
+ }
+ else if (c >= 'A' && c <= 'F')
+ {
+ return c + 10 - 'A';
+ }
+ else if (c >= 'a' && c <= 'f')
+ {
+ return c + 10 - 'a';
+ }
+ else
+ {
+ throw new IllegalArgumentException("Invalid hex code in " + rawValue);
+ }
+ }
+
+ /** . */
+ private final String rawValue;
+
+ /** . */
+ private final String value;
+
+ /** . */
+ private final int[] mapping;
+
+ private Data(String rawValue) throws IOException, IllegalArgumentException
+ {
+ this.rawValue = rawValue;
+
+ //
+ int len = rawValue.length();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ int[] mapping = new int[len];
+ int count = 0;
+
+ //
+ int i = 0;
+ while (i < len)
+ {
+ char c = rawValue.charAt(i);
+ mapping[count++] = i;
+
+ //
+ if (PercentEncoding.PATH_SEGMENT.accept(c))
+ {
+ baos.write((int)c);
+ i++;
+ }
+ else if (c == '%')
+ {
+ if (i + 2 >= len)
+ {
+ throw new IllegalArgumentException("Invalid percent escape in " + rawValue);
+ }
+ int h = (hex(rawValue.charAt(i + 1)) << 4) + hex(rawValue.charAt(i + 2));
+ baos.write(h);
+ i += 3;
+
+ // Compute the number of bytes to read for this char
+ int size = 0;
+ for (int j = h;(j & 0x80) != 0;j = j << 1)
+ {
+ size++;
+ }
+ if (size == 0)
+ {
+ size = 1;
+ }
+ else if (size > 6)
+ {
+ throw new IllegalArgumentException("Invalid percent escape in " + rawValue);
+ }
+
+ // Compute the offset we need to read those bytes
+ int to = i + (size - 1) * 3;
+ if (to > len)
+ {
+ throw new IllegalArgumentException("Invalid percent escape in " + rawValue);
+ }
+
+ // Read what we need
+ while (i < to)
+ {
+ if (rawValue.charAt(i) != '%')
+ {
+ throw new IllegalArgumentException("Invalid percent escape in " + rawValue);
+ }
+ h = (hex(rawValue.charAt(i + 1)) << 4) + hex(rawValue.charAt(i + 2));
+ baos.write(h);
+ i += 3;
+ }
+ }
+ else if (c == '/')
+ {
+ baos.write('/');
+ i++;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unsupported char value in path " + (int)c + " / " + c);
+ }
+ }
+
+ //
+ this.value = baos.toString("UTF-8");
+ this.mapping = mapping;
+ }
+
+ int getRawStart(int index)
+ {
+ if (index < 0)
+ {
+ throw new IndexOutOfBoundsException("No negative index accepted");
+ }
+ if (index >= value.length())
+ {
+ throw new IndexOutOfBoundsException("Index can't be greater than length");
+ }
+ return mapping[index];
+ }
+
+ int getRawEnd(int index)
+ {
+ if (index < 0)
+ {
+ throw new IndexOutOfBoundsException("No negative index accepted");
+ }
+ if (index >= value.length())
+ {
+ throw new IndexOutOfBoundsException("Index can't be greater than length");
+ }
+ index++;
+ if (index == value.length())
+ {
+ return rawValue.length();
+ }
+ else
+ {
+ return mapping[index];
+ }
+ }
+ }
+
+ /** . */
+ private final Data data;
+
+ /** . */
+ private final int offset;
+
+ /** . */
+ private final String value;
+
+ private Path(Data data, int offset)
+ {
+ this.data = data;
+ this.offset = offset;
+ this.value = data.value.substring(offset);
+ }
+
+ String getValue()
+ {
+ return value;
+ }
+
+ int getRawStart(int index)
+ {
+ return data.getRawStart(innerIndex(index)) - data.getRawStart(offset);
+ }
+
+ int getRawEnd(int index)
+ {
+ return data.getRawEnd(innerIndex(index))- data.getRawStart(offset);
+ }
+
+ int getRawLength(int index)
+ {
+ return getRawEnd(index) - getRawStart(index);
+ }
+
+ char charAt(int pos)
+ {
+ return value.charAt(pos);
+ }
+
+ int length()
+ {
+ return value.length();
+ }
+
+ int indexOf(int c, int index)
+ {
+ return value.indexOf(c, index);
+ }
+
+ Path subPath(int index)
+ {
+ if (index < 0)
+ {
+ throw new IndexOutOfBoundsException("No negative index accepted");
+ }
+ else if (index == 0)
+ {
+ return this;
+ }
+ else
+ {
+ int i = offset + index;
+ if (i >= data.value.length())
+ {
+ throw new IndexOutOfBoundsException("Index can't be greater than length");
+ }
+ return new Path(data, i);
+ }
+ }
+
+ /**
+ * Convert the specified index to the internal index.
+ *
+ * @param outterIndex the outter index
+ * @return the inner index value
+ * @throws IndexOutOfBoundsException if the outter index is not correct
+ */
+ private int innerIndex(int outterIndex) throws IndexOutOfBoundsException
+ {
+ if (outterIndex < 0)
+ {
+ throw new IndexOutOfBoundsException("No negative index accepted");
+ }
+ int pos = offset + outterIndex;
+ if (pos > data.value.length())
+ {
+ throw new IndexOutOfBoundsException("Index can't be greater than length");
+ }
+ return pos;
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PathParam.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PathParam.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PathParam.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.controller.metadata.PathParamDescriptor;
-import org.exoplatform.web.controller.regexp.RENode;
-import org.exoplatform.web.controller.regexp.RegExpParser;
-import org.exoplatform.web.controller.regexp.RegExpRenderer;
-import org.exoplatform.web.controller.regexp.SyntaxException;
-
-import java.io.IOException;
-import java.util.regex.Pattern;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-class PathParam extends Param
-{
-
- static PathParam create(QualifiedName name)
- {
- return create(new PathParamDescriptor(name));
- }
-
- static PathParam create(PathParamDescriptor descriptor)
- {
- if (descriptor == null)
- {
- throw new NullPointerException("No null descriptor accepted");
- }
-
- //
- String regex = null;
- EncodingMode encodingMode = EncodingMode.FORM;
- if (descriptor != null)
- {
- regex = descriptor.getPattern();
- encodingMode = descriptor.getEncodingMode();
- }
-
- //
- if (regex == null)
- {
- if (encodingMode == EncodingMode.FORM)
- {
- regex = ".+";
- }
- else
- {
- regex = "[^/]+";
- }
- }
-
- // Now work on the regex
- StringBuilder renderingRegex = new StringBuilder();
- StringBuilder routingRegex = new StringBuilder();
- try
- {
- RegExpParser parser = new RegExpParser(regex);
-
- //
- RENode.Disjunction routingDisjunction = parser.parseDisjunction();
- if (encodingMode == EncodingMode.FORM)
- {
- RouteEscaper escaper = new RouteEscaper('/', '_');
- escaper.visit(routingDisjunction);
- }
- new RegExpRenderer().render(routingDisjunction, routingRegex);
-
- //
- parser.reset();
- RENode.Disjunction renderingDisjunction = parser.parseDisjunction();
- renderingRegex.append("^");
- new RegExpRenderer().render(renderingDisjunction, renderingRegex);
- renderingRegex.append("$");
- }
- catch (IOException e)
- {
- throw new RuntimeException(e);
- }
- catch (SyntaxException e)
- {
- throw new RuntimeException(e);
- }
- catch (MalformedRouteException e)
- {
- throw new RuntimeException(e);
- }
-
- //
- return new PathParam(
- descriptor.getQualifiedName(),
- encodingMode,
- routingRegex.toString(),
- renderingRegex.toString());
- }
-
- /** . */
- final EncodingMode encodingMode;
-
- /** . */
- final String routingRegex;
-
- /** . */
- final Pattern renderingPattern;
-
- PathParam(
- QualifiedName name,
- EncodingMode encodingMode,
- String routingRegex,
- String renderingRegex)
- {
- super(name);
-
- //
- if (renderingRegex == null)
- {
- throw new NullPointerException("No null pattern accepted");
- }
-
- //
- this.encodingMode = encodingMode;
- this.routingRegex = routingRegex;
- this.renderingPattern = Pattern.compile(renderingRegex);
- }
-
- @Override
- public String toString()
- {
- return "PathParam[name=" + name + ",encodingMode=" + encodingMode + ",pattern=" + renderingPattern + "]";
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PathParam.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PathParam.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PathParam.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PathParam.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.web.controller.QualifiedName;
+import org.exoplatform.web.controller.metadata.PathParamDescriptor;
+import org.exoplatform.web.controller.regexp.RENode;
+import org.exoplatform.web.controller.regexp.RegExpParser;
+import org.exoplatform.web.controller.regexp.RegExpRenderer;
+import org.exoplatform.web.controller.regexp.SyntaxException;
+
+import java.io.IOException;
+import java.util.regex.Pattern;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+class PathParam extends Param
+{
+
+ static PathParam create(QualifiedName name)
+ {
+ return create(new PathParamDescriptor(name));
+ }
+
+ static PathParam create(PathParamDescriptor descriptor)
+ {
+ if (descriptor == null)
+ {
+ throw new NullPointerException("No null descriptor accepted");
+ }
+
+ //
+ String regex = null;
+ EncodingMode encodingMode = EncodingMode.FORM;
+ if (descriptor != null)
+ {
+ regex = descriptor.getPattern();
+ encodingMode = descriptor.getEncodingMode();
+ }
+
+ //
+ if (regex == null)
+ {
+ if (encodingMode == EncodingMode.FORM)
+ {
+ regex = ".+";
+ }
+ else
+ {
+ regex = "[^/]+";
+ }
+ }
+
+ // Now work on the regex
+ StringBuilder renderingRegex = new StringBuilder();
+ StringBuilder routingRegex = new StringBuilder();
+ try
+ {
+ RegExpParser parser = new RegExpParser(regex);
+
+ //
+ RENode.Disjunction routingDisjunction = parser.parseDisjunction();
+ if (encodingMode == EncodingMode.FORM)
+ {
+ RouteEscaper escaper = new RouteEscaper('/', '_');
+ escaper.visit(routingDisjunction);
+ }
+ new RegExpRenderer().render(routingDisjunction, routingRegex);
+
+ //
+ parser.reset();
+ RENode.Disjunction renderingDisjunction = parser.parseDisjunction();
+ renderingRegex.append("^");
+ new RegExpRenderer().render(renderingDisjunction, renderingRegex);
+ renderingRegex.append("$");
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch (SyntaxException e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch (MalformedRouteException e)
+ {
+ throw new RuntimeException(e);
+ }
+
+ //
+ return new PathParam(
+ descriptor.getQualifiedName(),
+ encodingMode,
+ routingRegex.toString(),
+ renderingRegex.toString());
+ }
+
+ /** . */
+ final EncodingMode encodingMode;
+
+ /** . */
+ final String routingRegex;
+
+ /** . */
+ final Pattern renderingPattern;
+
+ PathParam(
+ QualifiedName name,
+ EncodingMode encodingMode,
+ String routingRegex,
+ String renderingRegex)
+ {
+ super(name);
+
+ //
+ if (renderingRegex == null)
+ {
+ throw new NullPointerException("No null pattern accepted");
+ }
+
+ //
+ this.encodingMode = encodingMode;
+ this.routingRegex = routingRegex;
+ this.renderingPattern = Pattern.compile(renderingRegex);
+ }
+
+ @Override
+ public String toString()
+ {
+ return "PathParam[name=" + name + ",encodingMode=" + encodingMode + ",pattern=" + renderingPattern + "]";
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternBuilder.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternBuilder.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternBuilder.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.exoplatform.web.controller.regexp.Literal;
-
-import java.util.regex.Pattern;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-class PatternBuilder
-{
-
- /** . */
- private final StringBuilder buffer = new StringBuilder();
-
- public PatternBuilder expr(CharSequence s)
- {
- if (s == null)
- {
- throw new NullPointerException("No null expression allowed");
- }
- buffer.append(s);
- return this;
- }
-
- public PatternBuilder expr(char s)
- {
- buffer.append(s);
- return this;
- }
-
- public PatternBuilder litteral(String s, int from, int to)
- {
- if (from < 0)
- {
- throw new IllegalArgumentException("No negative from argument");
- }
- if (to > s.length())
- {
- throw new IllegalArgumentException("No to argument greater than the string length");
- }
- if (from > to)
- {
- throw new IllegalArgumentException("The to argument cannot be greater than the from argument");
- }
- if (from < to)
- {
- for (int i = from;i < to;i++)
- {
- char c = s.charAt(i);
- if (Literal.isEscaped(c))
- {
- buffer.append('\\');
- }
- buffer.append(c);
- }
- }
- return this;
- }
-
- public PatternBuilder literal(String s, int from)
- {
- return litteral(s, from, s.length());
- }
-
- public PatternBuilder literal(String s)
- {
- return litteral(s, 0, s.length());
- }
-
- public PatternBuilder literal(char c)
- {
- return literal(Character.toString(c));
- }
-
- public Pattern build()
- {
- return Pattern.compile(buffer.toString());
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternBuilder.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternBuilder.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternBuilder.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternBuilder.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.web.controller.regexp.Literal;
+
+import java.util.regex.Pattern;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+class PatternBuilder
+{
+
+ /** . */
+ private final StringBuilder buffer = new StringBuilder();
+
+ public PatternBuilder expr(CharSequence s)
+ {
+ if (s == null)
+ {
+ throw new NullPointerException("No null expression allowed");
+ }
+ buffer.append(s);
+ return this;
+ }
+
+ public PatternBuilder expr(char s)
+ {
+ buffer.append(s);
+ return this;
+ }
+
+ public PatternBuilder litteral(String s, int from, int to)
+ {
+ if (from < 0)
+ {
+ throw new IllegalArgumentException("No negative from argument");
+ }
+ if (to > s.length())
+ {
+ throw new IllegalArgumentException("No to argument greater than the string length");
+ }
+ if (from > to)
+ {
+ throw new IllegalArgumentException("The to argument cannot be greater than the from argument");
+ }
+ if (from < to)
+ {
+ for (int i = from;i < to;i++)
+ {
+ char c = s.charAt(i);
+ if (Literal.isEscaped(c))
+ {
+ buffer.append('\\');
+ }
+ buffer.append(c);
+ }
+ }
+ return this;
+ }
+
+ public PatternBuilder literal(String s, int from)
+ {
+ return litteral(s, from, s.length());
+ }
+
+ public PatternBuilder literal(String s)
+ {
+ return litteral(s, 0, s.length());
+ }
+
+ public PatternBuilder literal(char c)
+ {
+ return literal(Character.toString(c));
+ }
+
+ public Pattern build()
+ {
+ return Pattern.compile(buffer.toString());
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternRoute.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternRoute.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternRoute.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import java.util.List;
-import java.util.regex.Pattern;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-class PatternRoute extends Route
-{
-
- /** . */
- final Pattern pattern;
-
- /** . */
- final PathParam[] params;
-
- /** . */
- final String[] chunks;
-
- /** The encoded chunks (so we don't reencode them later). */
- final String[] encodedChunks;
-
- PatternRoute(
- Router router,
- Pattern pattern,
- List<PathParam> params,
- List<String> chunks)
- {
- super(router);
-
- //
- if (chunks.size() != params.size() + 1)
- {
- throw new AssertionError("Was expecting chunk size " + chunks.size() + " to be equals to " + params.size() + 1);
- }
-
- //
- String[] encodedChunks = new String[chunks.size()];
- for (int i = 0;i < chunks.size();i++)
- {
- encodedChunks[i] = PercentEncoding.PATH_SEGMENT.encode(chunks.get(i));
- }
-
- //
- this.pattern = pattern;
- this.params = params.toArray(new PathParam[params.size()]);
- this.chunks = chunks.toArray(new String[chunks.size()]);
- this.encodedChunks = encodedChunks;
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternRoute.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternRoute.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternRoute.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PatternRoute.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import java.util.List;
+import java.util.regex.Pattern;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+class PatternRoute extends Route
+{
+
+ /** . */
+ final Pattern pattern;
+
+ /** . */
+ final PathParam[] params;
+
+ /** . */
+ final String[] chunks;
+
+ /** The encoded chunks (so we don't reencode them later). */
+ final String[] encodedChunks;
+
+ PatternRoute(
+ Router router,
+ Pattern pattern,
+ List<PathParam> params,
+ List<String> chunks)
+ {
+ super(router);
+
+ //
+ if (chunks.size() != params.size() + 1)
+ {
+ throw new AssertionError("Was expecting chunk size " + chunks.size() + " to be equals to " + params.size() + 1);
+ }
+
+ //
+ String[] encodedChunks = new String[chunks.size()];
+ for (int i = 0;i < chunks.size();i++)
+ {
+ encodedChunks[i] = PercentEncoding.PATH_SEGMENT.encode(chunks.get(i));
+ }
+
+ //
+ this.pattern = pattern;
+ this.params = params.toArray(new PathParam[params.size()]);
+ this.chunks = chunks.toArray(new String[chunks.size()]);
+ this.encodedChunks = encodedChunks;
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PercentEncoding.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PercentEncoding.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PercentEncoding.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.exoplatform.commons.utils.CharEncoder;
-import org.exoplatform.commons.utils.CharsetCharEncoder;
-import org.gatein.common.io.UndeclaredIOException;
-
-import java.io.IOException;
-import java.util.BitSet;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- */
-public final class PercentEncoding
-{
-
- /** . */
- private static final CharEncoder encoder = CharsetCharEncoder.getUTF8();
-
- /** . */
- private static final char[] ALPHABET = "0123456789ABCDEF".toCharArray();
-
- /** Path segment. */
- public static final PercentEncoding PATH_SEGMENT;
-
- static
- {
- BitSet allowed = new BitSet();
-
- // Unreserved
- for (char c = 'A';c <= 'Z';c++)
- {
- allowed.set(c);
- }
- for (char c = 'a';c <= 'z';c++)
- {
- allowed.set(c);
- }
- for (char c = '0';c <= '9';c++)
- {
- allowed.set(c);
- }
- allowed.set('_');
- allowed.set('.');
- allowed.set('-');
- allowed.set('~');
-
- // sub-delims
- allowed.set('!');
- allowed.set('$');
- allowed.set('&');
- allowed.set('\'');
- allowed.set('(');
- allowed.set(')');
- allowed.set('*');
- allowed.set('+');
- allowed.set(',');
- allowed.set(';');
- allowed.set('=');
-
- // ':' | '@'
- allowed.set(':');
- allowed.set('@');
-
- //
- PATH_SEGMENT = new PercentEncoding(allowed);
- }
-
- /** Query params name or value. */
- public static final PercentEncoding QUERY_PARAM;
-
- static
- {
- BitSet allowed = new BitSet(128);
- for (char c = 'A';c <= 'Z';c++)
- {
- allowed.set(c);
- }
- for (char c = 'a';c <= 'z';c++)
- {
- allowed.set(c);
- }
- for (char c = '0';c <= '9';c++)
- {
- allowed.set(c);
- }
- allowed.set('_');
- allowed.set('.');
- allowed.set('-');
- allowed.set('~');
-
- // sub-delims without ( '&' | '=' )
- allowed.set('!');
- allowed.set('$');
- allowed.set('\'');
- allowed.set('(');
- allowed.set(')');
- allowed.set('*');
- allowed.set('+');
- allowed.set(',');
- allowed.set(';');
-
- // ':' | '@'
- allowed.set(':');
- allowed.set('@');
-
- // '?' | '/'
- allowed.set('?');
- allowed.set('/');
-
- //
- QUERY_PARAM = new PercentEncoding(allowed);
- }
-
- /** . */
- private final BitSet allowed;
-
- private PercentEncoding(BitSet allowed)
- {
- this.allowed = allowed;
- }
-
- boolean accept(char c)
- {
- return c < allowed.length() && allowed.get(c);
- }
-
- public void encode(CharSequence s, Appendable appendable) throws IOException
- {
- for (int len = s.length(), i = 0;i < len;i++)
- {
- char c = s.charAt(i);
- encode(c, appendable);
- }
- }
-
- public String encode(CharSequence s)
- {
- try
- {
- StringBuilder sb = new StringBuilder(s.length());
- encode(s, sb);
- return sb.toString();
- }
- catch (IOException e)
- {
- throw new UndeclaredIOException(e);
- }
- }
-
- public void encode(char c, Appendable appendable) throws IOException
- {
- if (accept(c))
- {
- appendable.append(c);
- }
- else
- {
- byte[] bytes = encoder.encode(c);
- for (byte b : bytes)
- {
- appendable.append('%');
- appendable.append(ALPHABET[(b & 0xF0) >> 4]);
- appendable.append(ALPHABET[b & 0xF]);
- }
- }
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PercentEncoding.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PercentEncoding.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PercentEncoding.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/PercentEncoding.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,186 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.commons.utils.CharEncoder;
+import org.exoplatform.commons.utils.CharsetCharEncoder;
+import org.gatein.common.io.UndeclaredIOException;
+
+import java.io.IOException;
+import java.util.BitSet;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public final class PercentEncoding
+{
+
+ /** . */
+ private static final CharEncoder encoder = CharsetCharEncoder.getUTF8();
+
+ /** . */
+ private static final char[] ALPHABET = "0123456789ABCDEF".toCharArray();
+
+ /** Path segment. */
+ public static final PercentEncoding PATH_SEGMENT;
+
+ static
+ {
+ BitSet allowed = new BitSet();
+
+ // Unreserved
+ for (char c = 'A';c <= 'Z';c++)
+ {
+ allowed.set(c);
+ }
+ for (char c = 'a';c <= 'z';c++)
+ {
+ allowed.set(c);
+ }
+ for (char c = '0';c <= '9';c++)
+ {
+ allowed.set(c);
+ }
+ allowed.set('_');
+ allowed.set('.');
+ allowed.set('-');
+ allowed.set('~');
+
+ // sub-delims
+ allowed.set('!');
+ allowed.set('$');
+ allowed.set('&');
+ allowed.set('\'');
+ allowed.set('(');
+ allowed.set(')');
+ allowed.set('*');
+ allowed.set('+');
+ allowed.set(',');
+ allowed.set(';');
+ allowed.set('=');
+
+ // ':' | '@'
+ allowed.set(':');
+ allowed.set('@');
+
+ //
+ PATH_SEGMENT = new PercentEncoding(allowed);
+ }
+
+ /** Query params name or value. */
+ public static final PercentEncoding QUERY_PARAM;
+
+ static
+ {
+ BitSet allowed = new BitSet(128);
+ for (char c = 'A';c <= 'Z';c++)
+ {
+ allowed.set(c);
+ }
+ for (char c = 'a';c <= 'z';c++)
+ {
+ allowed.set(c);
+ }
+ for (char c = '0';c <= '9';c++)
+ {
+ allowed.set(c);
+ }
+ allowed.set('_');
+ allowed.set('.');
+ allowed.set('-');
+ allowed.set('~');
+
+ // sub-delims without ( '&' | '=' )
+ allowed.set('!');
+ allowed.set('$');
+ allowed.set('\'');
+ allowed.set('(');
+ allowed.set(')');
+ allowed.set('*');
+ allowed.set('+');
+ allowed.set(',');
+ allowed.set(';');
+
+ // ':' | '@'
+ allowed.set(':');
+ allowed.set('@');
+
+ // '?' | '/'
+ allowed.set('?');
+ allowed.set('/');
+
+ //
+ QUERY_PARAM = new PercentEncoding(allowed);
+ }
+
+ /** . */
+ private final BitSet allowed;
+
+ private PercentEncoding(BitSet allowed)
+ {
+ this.allowed = allowed;
+ }
+
+ boolean accept(char c)
+ {
+ return c < allowed.length() && allowed.get(c);
+ }
+
+ public void encode(CharSequence s, Appendable appendable) throws IOException
+ {
+ for (int len = s.length(), i = 0;i < len;i++)
+ {
+ char c = s.charAt(i);
+ encode(c, appendable);
+ }
+ }
+
+ public String encode(CharSequence s)
+ {
+ try
+ {
+ StringBuilder sb = new StringBuilder(s.length());
+ encode(s, sb);
+ return sb.toString();
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+
+ public void encode(char c, Appendable appendable) throws IOException
+ {
+ if (accept(c))
+ {
+ appendable.append(c);
+ }
+ else
+ {
+ byte[] bytes = encoder.encode(c);
+ for (byte b : bytes)
+ {
+ appendable.append('%');
+ appendable.append(ALPHABET[(b & 0xF0) >> 4]);
+ appendable.append(ALPHABET[b & 0xF]);
+ }
+ }
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParam.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParam.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParam.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.controller.metadata.RequestParamDescriptor;
-
-import java.util.regex.Pattern;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-class RequestParam extends Param
-{
-
- static RequestParam create(RequestParamDescriptor descriptor)
- {
- if (descriptor == null)
- {
- throw new NullPointerException("No null descriptor accepted");
- }
-
- //
- Pattern matchValue = null;
- if (descriptor.getValue() != null)
- {
- PatternBuilder matchValueBuilder = new PatternBuilder();
- matchValueBuilder.expr("^");
- if (descriptor.getValueType() == ValueType.PATTERN)
- {
- matchValueBuilder.expr(descriptor.getValue());
- }
- else
- {
- matchValueBuilder.literal(descriptor.getValue());
- }
- matchValueBuilder.expr("$");
- matchValue = matchValueBuilder.build();
- }
-
- //
- return new RequestParam(
- descriptor.getQualifiedName(),
- descriptor.getName(),
- matchValue,
- descriptor.getControlMode(),
- descriptor.getValueMapping());
- }
-
- /** . */
- final QualifiedName name;
-
- /** . */
- final String matchName;
-
- /** . */
- final Pattern matchPattern;
-
- /** . */
- final ControlMode controlMode;
-
- /** . */
- final ValueMapping valueMapping;
-
- RequestParam(QualifiedName name, String matchName, Pattern matchPattern, ControlMode controlMode, ValueMapping valueMapping)
- {
- super(name);
-
- //
- if (matchName == null)
- {
- throw new NullPointerException("No null match name accepted");
- }
- if (controlMode == null)
- {
- throw new NullPointerException("No null control mode accepted");
- }
- if (valueMapping == null)
- {
- throw new NullPointerException("No null value mapping accepted");
- }
-
- //
- this.name = name;
- this.matchName = matchName;
- this.matchPattern = matchPattern;
- this.controlMode = controlMode;
- this.valueMapping = valueMapping;
- }
-
- boolean matchValue(String value)
- {
- return matchPattern == null || matchPattern.matcher(value).matches();
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParam.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParam.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParam.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParam.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.web.controller.QualifiedName;
+import org.exoplatform.web.controller.metadata.RequestParamDescriptor;
+
+import java.util.regex.Pattern;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+class RequestParam extends Param
+{
+
+ static RequestParam create(RequestParamDescriptor descriptor)
+ {
+ if (descriptor == null)
+ {
+ throw new NullPointerException("No null descriptor accepted");
+ }
+
+ //
+ Pattern matchValue = null;
+ if (descriptor.getValue() != null)
+ {
+ PatternBuilder matchValueBuilder = new PatternBuilder();
+ matchValueBuilder.expr("^");
+ if (descriptor.getValueType() == ValueType.PATTERN)
+ {
+ matchValueBuilder.expr(descriptor.getValue());
+ }
+ else
+ {
+ matchValueBuilder.literal(descriptor.getValue());
+ }
+ matchValueBuilder.expr("$");
+ matchValue = matchValueBuilder.build();
+ }
+
+ //
+ return new RequestParam(
+ descriptor.getQualifiedName(),
+ descriptor.getName(),
+ matchValue,
+ descriptor.getControlMode(),
+ descriptor.getValueMapping());
+ }
+
+ /** . */
+ final QualifiedName name;
+
+ /** . */
+ final String matchName;
+
+ /** . */
+ final Pattern matchPattern;
+
+ /** . */
+ final ControlMode controlMode;
+
+ /** . */
+ final ValueMapping valueMapping;
+
+ RequestParam(QualifiedName name, String matchName, Pattern matchPattern, ControlMode controlMode, ValueMapping valueMapping)
+ {
+ super(name);
+
+ //
+ if (matchName == null)
+ {
+ throw new NullPointerException("No null match name accepted");
+ }
+ if (controlMode == null)
+ {
+ throw new NullPointerException("No null control mode accepted");
+ }
+ if (valueMapping == null)
+ {
+ throw new NullPointerException("No null value mapping accepted");
+ }
+
+ //
+ this.name = name;
+ this.matchName = matchName;
+ this.matchPattern = matchPattern;
+ this.controlMode = controlMode;
+ this.valueMapping = valueMapping;
+ }
+
+ boolean matchValue(String value)
+ {
+ return matchPattern == null || matchPattern.matcher(value).matches();
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,1283 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-//import javanet.staxutils.IndentingXMLStreamWriter;
-import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.controller.metadata.PathParamDescriptor;
-import org.exoplatform.web.controller.metadata.RequestParamDescriptor;
-import org.exoplatform.web.controller.metadata.RouteDescriptor;
-import org.exoplatform.web.controller.metadata.RouteParamDescriptor;
-import org.gatein.common.util.Tools;
-
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
-import java.util.regex.Matcher;
-
-/**
- * The implementation of the routing algorithm.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-class Route
-{
-
- void writeTo(XMLStreamWriter writer) throws XMLStreamException
- {
- if (this instanceof SegmentRoute)
- {
- writer.writeStartElement("segment");
- writer.writeAttribute("path", "/" + ((SegmentRoute)this).name);
- writer.writeAttribute("terminal", "" + terminal);
- }
- else if (this instanceof PatternRoute)
- {
- PatternRoute pr = (PatternRoute)this;
- StringBuilder path = new StringBuilder("/");
- for (int i = 0;i < pr.params.length;i++)
- {
- path.append(pr.chunks[i]).append("{").append(pr.params[i].name.getValue()).append("}");
- }
- path.append(pr.chunks[pr.chunks.length - 1]);
- writer.writeStartElement("pattern");
- writer.writeAttribute("path", path.toString());
- writer.writeAttribute("terminal", Boolean.toString(terminal));
- for (PathParam param : pr.params)
- {
- writer.writeStartElement("path-param");
- writer.writeAttribute("qname", param.name.getValue());
- writer.writeAttribute("encodingMode", param.encodingMode.toString());
- writer.writeAttribute("pattern", param.renderingPattern.toString());
- writer.writeEndElement();
- }
- }
- else
- {
- writer.writeStartElement("route");
- }
-
- //
- for (RouteParam routeParam : routeParams.values())
- {
- writer.writeStartElement("route-param");
- writer.writeAttribute("qname", routeParam.name.getValue());
- writer.writeAttribute("value", routeParam.value);
- writer.writeEndElement();
- }
-
- //
- for (RequestParam requestParam : requestParams.values())
- {
- writer.writeStartElement("request-param");
- writer.writeAttribute("qname", requestParam.name.getValue());
- writer.writeAttribute("name", requestParam.matchName);
- if (requestParam.matchPattern != null)
- {
- writer.writeAttribute("value", requestParam.matchPattern.pattern());
- }
- writer.writeEndElement();
- }
-
- //
-/*
- for (Map.Entry<String, SegmentRoute[]> entry : segments.entrySet())
- {
- writer.writeStartElement("segment");
- writer.writeAttribute("name", entry.getKey());
- for (SegmentRoute segment : entry.getValue())
- {
- segment.writeTo(writer);
- }
- writer.writeEndElement();
- }
-
- //
- for (PatternRoute pattern : patterns)
- {
- pattern.writeTo(writer);
- }
-*/
-
- //
- writer.writeEndElement();
- }
-
- @Override
- public String toString()
- {
- try
- {
- XMLOutputFactory factory = XMLOutputFactory.newInstance();
- StringWriter sw = new StringWriter();
- XMLStreamWriter xmlWriter = factory.createXMLStreamWriter(sw);
-// xmlWriter = new IndentingXMLStreamWriter(xmlWriter);
- writeTo(xmlWriter);
- return sw.toString();
- }
- catch (XMLStreamException e)
- {
- throw new AssertionError(e);
- }
- }
-
- /** . */
- private static final Route[] EMPTY_ROUTE_ARRAY = new Route[0];
-
- /** . */
- private final Router router;
-
- /** . */
- private Route parent;
-
- /** . */
- private boolean terminal;
-
- /** . */
- private Route[] children;
-
- /** . */
- private final Map<QualifiedName, RouteParam> routeParams;
-
- /** . */
- private final Map<String, RequestParam> requestParams;
-
- Route(Router router)
- {
- this.router = router;
- this.parent = null;
- this.terminal = true;
- this.children = EMPTY_ROUTE_ARRAY;
- this.routeParams = new HashMap<QualifiedName, RouteParam>();
- this.requestParams = new HashMap<String, RequestParam>();
- }
-
- final boolean isTerminal()
- {
- return terminal;
- }
-
- /*
- * Ok, so this is not the fastest way to do it, but for now it's OK, it's what is needed, we'll find
- * a way to optimize it later with some precompilation.
- */
- final void render(Map<QualifiedName, String> blah, URIWriter writer) throws IOException
- {
- Route r = find(blah);
-
- // We found a route we need to render it now
- if (r != null)
- {
- // Append path first
- r.renderPath(blah, writer, false);
-
- // Append query parameters after
- r.renderQueryString(blah, writer);
- }
- }
-
- private boolean renderPath(Map<QualifiedName, String> blah, URIWriter writer, boolean hasChildren) throws IOException
- {
- boolean endWithSlash;
- if (parent != null)
- {
- endWithSlash = parent.renderPath(blah, writer, true);
- }
- else
- {
- endWithSlash = false;
- }
-
- //
- if (this instanceof SegmentRoute)
- {
- SegmentRoute sr = (SegmentRoute)this;
- if (!endWithSlash)
- {
- writer.append('/');
- endWithSlash = true;
- }
- String name = sr.encodedName;
- writer.append(name);
- if (name.length() > 0)
- {
- endWithSlash = false;
- }
- }
- else if (this instanceof PatternRoute)
- {
- PatternRoute pr = (PatternRoute)this;
- if (!endWithSlash)
- {
- writer.append('/');
- endWithSlash = true;
- }
- int i = 0;
- int count = 0;
- while (i < pr.params.length)
- {
- writer.append(pr.encodedChunks[i]);
- count += pr.chunks[i].length();
-
- //
- PathParam def = pr.params[i];
- String value = blah.get(def.name);
- count += value.length();
-
- // Write value
- for (int len = value.length(), j = 0;j < len;j++)
- {
- char c = value.charAt(j);
- if (c == router.separatorEscape)
- {
- if (def.encodingMode == EncodingMode.PRESERVE_PATH)
- {
- writer.append('_');
- } else
- {
- writer.append('%');
- writer.append(router.separatorEscapeNible1);
- writer.append(router.separatorEscapeNible2);
- }
- }
- else if (c == '/')
- {
- writer.append(def.encodingMode == EncodingMode.PRESERVE_PATH ? '/' : router.separatorEscape);
- }
- else
- {
- writer.appendSegment(c);
- }
- }
-
- //
- i++;
- }
- writer.append(pr.encodedChunks[i]);
- count += pr.chunks[i].length();
- if (count > 0)
- {
- endWithSlash = false;
- }
- }
- else
- {
- if (!hasChildren)
- {
- writer.append('/');
- endWithSlash = true;
- }
- }
-
- //
- return endWithSlash;
- }
-
- private void renderQueryString(Map<QualifiedName, String> blah, URIWriter writer) throws IOException
- {
- if (parent != null)
- {
- parent.renderQueryString(blah, writer);
- }
-
- //
- if (requestParams.size() > 0)
- {
- for (RequestParam requestParamDef : requestParams.values())
- {
- String s = blah.get(requestParamDef.name);
- switch (requestParamDef.valueMapping)
- {
- case CANONICAL:
- break;
- case NEVER_EMPTY:
- if (s != null && s.length() == 0)
- {
- s = null;
- }
- break;
- case NEVER_NULL:
- if (s == null)
- {
- s = "";
- }
- break;
- }
- if (s != null)
- {
- writer.appendQueryParameter(requestParamDef.matchName, s);
- }
- }
- }
- }
-
- final Route find(Map<QualifiedName, String> blah)
- {
-
- // Remove what is matched
- Map<QualifiedName, String> abc = new HashMap<QualifiedName, String>(blah);
-
- // Match first the static parameteters
- for (RouteParam param : routeParams.values())
- {
- String value = blah.get(param.name);
- if (param.value.equals(value))
- {
- abc.remove(param.name);
- }
- else
- {
- return null;
- }
- }
-
- // Match any request parameter
- if (requestParams.size() > 0)
- {
- for (RequestParam requestParamDef : requestParams.values())
- {
- String a = blah.get(requestParamDef.name);
- boolean matched = false;
- if (a != null)
- {
- if (requestParamDef.matchValue(a))
- {
- matched = true;
- }
- }
- if (matched)
- {
- abc.remove(requestParamDef.name);
- }
- else
- {
- switch (requestParamDef.controlMode)
- {
- case OPTIONAL:
- // Do nothing
- break;
- case REQUIRED:
- return null;
- default:
- throw new AssertionError();
- }
- }
- }
- }
-
- // Match any pattern parameter
- if (this instanceof PatternRoute)
- {
- PatternRoute prt = (PatternRoute)this;
- for (int i = 0;i < prt.params.length;i++)
- {
- PathParam param = prt.params[i];
- String s = blah.get(param.name);
- boolean matched = false;
- if (s != null)
- {
- switch (param.encodingMode)
- {
- case FORM:
- matched = param.renderingPattern.matcher(s).matches();
- break;
- case PRESERVE_PATH:
- matched = param.renderingPattern.matcher(s).matches();
- break;
- default:
- throw new AssertionError();
- }
- }
- if (matched)
- {
- abc.remove(param.name);
- }
- else
- {
- return null;
- }
- }
- }
-
- //
- if (abc.isEmpty() && terminal)
- {
- return this;
- }
-
- //
- for (Route route : children)
- {
- Route a = route.find(abc);
- if (a != null)
- {
- return a;
- }
- }
-
- //
- return null;
- }
-
- /**
- * Create a route matcher for the a request.
- *
- * @param path the path
- * @param requestParams the query parameters
- * @return the route matcher
- */
- final RouteMatcher route(String path, Map<String, String[]> requestParams)
- {
- return new RouteMatcher(this, Path.parse(path), requestParams);
- }
-
- static class RouteFrame
- {
-
- /**
- * Defines the status of a frame.
- */
- static enum Status
- {
- BEGIN,
-
- MATCHED_PARAMS,
-
- PROCESS_CHILDREN,
-
- MATCHED,
-
- END
-
- }
-
- /** . */
- private final RouteFrame parent;
-
- /** . */
- private final Route route;
-
- /** . */
- private final Path path;
-
- /** . */
- private Status status;
-
- /** The matches. */
- private Map<QualifiedName, String> matches;
-
- /** The index when iterating child in {@link org.exoplatform.web.controller.router.Route.RouteFrame.Status#PROCESS_CHILDREN} status. */
- private int childIndex;
-
- private RouteFrame(RouteFrame parent, Route route, Path path)
- {
- this.parent = parent;
- this.route = route;
- this.path = path;
- this.status = Status.BEGIN;
- this.childIndex = 0;
- }
-
- private RouteFrame(Route route, Path path)
- {
- this(null, route, path);
- }
-
- Map<QualifiedName, String> getParameters()
- {
- Map<QualifiedName, String> parameters = null;
- for (RouteFrame frame = this;frame != null;frame = frame.parent)
- {
- if (frame.matches != null)
- {
- if (parameters == null)
- {
- parameters = new HashMap<QualifiedName, String>();
- }
- parameters.putAll(frame.matches);
- }
- if (frame.route.routeParams.size() > 0)
- {
- if (parameters == null)
- {
- parameters = new HashMap<QualifiedName, String>();
- }
- for (RouteParam param : frame.route.routeParams.values())
- {
- parameters.put(param.name, param.value);
- }
- }
- }
- return parameters != null ? parameters : Collections.<QualifiedName, String>emptyMap();
- }
- }
-
- static class RouteMatcher implements Iterator<Map<QualifiedName, String>>
- {
-
- /** . */
- private final Map<String, String[]> requestParams;
-
- /** . */
- private RouteFrame frame;
-
- /** . */
- private RouteFrame next;
-
- RouteMatcher(Route route, Path path, Map<String, String[]> requestParams)
- {
- this.frame = new RouteFrame(route, path);
- this.requestParams = requestParams;
- }
-
- public boolean hasNext()
- {
- if (next == null)
- {
- if (frame != null)
- {
- frame = route(frame, requestParams);
- }
- if (frame != null && frame.status == RouteFrame.Status.MATCHED)
- {
- next = frame;
- }
- }
- return next != null;
- }
-
- public Map<QualifiedName, String> next()
- {
- if (!hasNext())
- {
- throw new NoSuchElementException();
- }
- Map<QualifiedName, String> parameters = next.getParameters();
- next = null;
- return parameters;
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
- }
-
- private static RouteFrame route(RouteFrame root, Map<String, String[]> requestParams)
- {
- RouteFrame current = root;
-
- //
- if (root.status == RouteFrame.Status.MATCHED)
- {
- if (root.parent != null)
- {
- current = root.parent;
- }
- else
- {
- return null;
- }
- }
- else if (root.status != RouteFrame.Status.BEGIN)
- {
- throw new AssertionError("Unexpected status " + root.status);
- }
-
- //
- while (true)
- {
- if (current.status == RouteFrame.Status.BEGIN)
- {
- boolean matched = true;
-
- // We enter a frame
- if (current.route.requestParams.size() > 0)
- {
- for (RequestParam requestParamDef : current.route.requestParams.values())
- {
- String value = null;
- String[] values = requestParams.get(requestParamDef.matchName);
- if (values != null && values.length > 0 && values[0] != null)
- {
- value = values[0];
- }
- if (value == null)
- {
- switch (requestParamDef.controlMode)
- {
- case OPTIONAL:
- // Do nothing
- break;
- case REQUIRED:
- matched = false;
- break;
- }
- }
- else if (!requestParamDef.matchValue(value))
- {
- matched = false;
- break;
- }
- switch (requestParamDef.valueMapping)
- {
- case CANONICAL:
- break;
- case NEVER_EMPTY:
- if (value != null && value.length() == 0)
- {
- value = null;
- }
- break;
- case NEVER_NULL:
- if (value == null)
- {
- value = "";
- }
- break;
- }
- if (value != null)
- {
- if (current.matches == null)
- {
- current.matches = new HashMap<QualifiedName, String>();
- }
- current.matches.put(requestParamDef.name, value);
- }
- }
- }
-
- //
- if (matched)
- {
- // We enter next state
- current.status = RouteFrame.Status.MATCHED_PARAMS;
- }
- else
- {
- current.status = RouteFrame.Status.END;
- }
- }
- else if (current.status == RouteFrame.Status.MATCHED_PARAMS)
- {
- RouteFrame.Status next;
-
- // Anything that does not begin with '/' returns null
- if (current.path.length() > 0 && current.path.charAt(0) == '/')
- {
- // The '/' means the current controller if any, otherwise it may be processed by the pattern matching
- if (current.path.length() == 1 && current.route.terminal)
- {
- next = RouteFrame.Status.MATCHED;
- }
- else
- {
- next = RouteFrame.Status.PROCESS_CHILDREN;
- }
- }
- else
- {
- next = RouteFrame.Status.END;
- }
-
- //
- current.status = next;
- }
- else if (current.status == RouteFrame.Status.PROCESS_CHILDREN)
- {
- if (current.childIndex < current.route.children.length)
- {
- Route child = current.route.children[current.childIndex++];
-
- // The next frame
- RouteFrame next;
-
- //
- if (child instanceof SegmentRoute)
- {
- SegmentRoute segmentRoute = (SegmentRoute)child;
-
- //
- if (segmentRoute.name.length() == 0)
- {
- // Delegate the process to the next route
- next = new RouteFrame(current, segmentRoute, current.path);
- }
- else
- {
- // Find the next '/' for determining the segment and next path
- // JULIEN : this can be computed multiple times
- int pos = current.path.indexOf('/', 1);
- if (pos == -1)
- {
- pos = current.path.length();
- }
- String segment = current.path.getValue().substring(1, pos);
-
- // Determine next path
- if (segmentRoute.name.equals(segment))
- {
- // Lazy create next segment path
- // JULIEN : this can be computed multiple times
- Path nextSegmentPath;
- if (pos == current.path.length())
- {
- // todo make a constant
- nextSegmentPath = Path.SLASH;
- }
- else
- {
- nextSegmentPath = current.path.subPath(pos);
- }
-
- // Delegate the process to the next route
- next = new RouteFrame(current, segmentRoute, nextSegmentPath);
- }
- else
- {
- next = null;
- }
- }
- }
- else if (child instanceof PatternRoute)
- {
- PatternRoute patternRoute = (PatternRoute)child;
-
- //
- Matcher matcher = patternRoute.pattern.matcher(current.path.getValue());
-
- // We match
- if (matcher.find())
- {
- // Build next controller context
- int nextPos = matcher.end();
- Path nextPath;
- if (current.path.length() == nextPos)
- {
- nextPath = Path.SLASH;
- }
- else
- {
- if (nextPos > 0 && current.path.charAt(nextPos - 1) == '/')
- {
- nextPos--;
- }
-
- //
- nextPath = current.path.subPath(nextPos);
- }
-
- // Delegate to next patternRoute
- next = new RouteFrame(current, patternRoute, nextPath);
-
- // JULIEN : this can be done lazily
- // Append parameters
- int group = 1;
- for (int i = 0;i < patternRoute.params.length;i++)
- {
- PathParam param = patternRoute.params[i];
-
- //
- int end = matcher.end(group);
-
- //
- if (end != -1)
- {
- String value;
- if (param.encodingMode == EncodingMode.FORM)
- {
- StringBuilder sb = new StringBuilder();
- for (int from = matcher.start(group);from < end;from++)
- {
- char c = current.path.charAt(from);
- if (c == child.router.separatorEscape && current.path.getRawLength(from) == 1)
- {
- c = '/';
- }
- sb.append(c);
- }
- value = sb.toString();
- }
- else
- {
- value = matcher.group(group);
- }
- if (next.matches == null)
- {
- next.matches = new HashMap<QualifiedName, String>();
- }
- next.matches.put(param.name, value);
- }
- else
- {
- // We have an optional match
- }
-
- //
- group++;
- }
- }
- else
- {
- next = null;
- }
- }
- else
- {
- throw new AssertionError();
- }
-
- //
- if (next != null)
- {
- current = next;
- }
- }
- else
- {
- current.status = RouteFrame.Status.END;
- }
- }
- else if (current.status == RouteFrame.Status.MATCHED)
- {
- // We found a solution
- break;
- }
- else if (current.status == RouteFrame.Status.END)
- {
- if (current.parent != null)
- {
- current = current.parent;
- }
- else
- {
- // The end of the search
- break;
- }
- }
- else
- {
- throw new AssertionError();
- }
- }
-
- //
- return current;
- }
-
- final <R extends Route> R add(R route) throws MalformedRouteException
- {
- if (route == null)
- {
- throw new NullPointerException("No null route accepted");
- }
- if (route.parent != null)
- {
- throw new IllegalArgumentException("No route with an existing parent can be accepted");
- }
-
- //
- LinkedList<Param> ancestorParams = new LinkedList<Param>();
- findAncestorOrSelfParams(ancestorParams);
- LinkedList<Param> descendantParams = new LinkedList<Param>();
- for (Param param : ancestorParams)
- {
- route.findDescendantOrSelfParams(param.name, descendantParams);
- if (descendantParams.size() > 0)
- {
- throw new MalformedRouteException("Duplicate parameter " + param.name);
- }
- }
-
- //
- if (route instanceof PatternRoute || route instanceof SegmentRoute)
- {
- children = Tools.appendTo(children, route);
- terminal = false;
- route.parent = this;
- }
- else
- {
- throw new IllegalArgumentException("Only accept segment or pattern routes");
- }
-
- //
- return route;
- }
-
- final Set<String> getSegmentNames()
- {
- Set<String> names = new HashSet<String>();
- for (Route child : children)
- {
- if (child instanceof SegmentRoute)
- {
- SegmentRoute childSegment = (SegmentRoute)child;
- names.add(childSegment.name);
- }
- }
- return names;
- }
-
- final int getSegmentSize(String segmentName)
- {
- int size = 0;
- for (Route child : children)
- {
- if (child instanceof SegmentRoute)
- {
- SegmentRoute childSegment = (SegmentRoute)child;
- if (segmentName.equals(childSegment.name))
- {
- size++;
- }
- }
- }
- return size;
- }
-
- final SegmentRoute getSegment(String segmentName, int index)
- {
- for (Route child : children)
- {
- if (child instanceof SegmentRoute)
- {
- SegmentRoute childSegment = (SegmentRoute)child;
- if (segmentName.equals(childSegment.name))
- {
- if (index == 0)
- {
- return childSegment;
- }
- else
- {
- index--;
- }
- }
- }
- }
- return null;
- }
-
- final int getPatternSize()
- {
- int size = 0;
- for (Route route : children)
- {
- if (route instanceof PatternRoute)
- {
- size++;
- }
- }
- return size;
- }
-
- final PatternRoute getPattern(int index)
- {
- for (Route route : children)
- {
- if (route instanceof PatternRoute)
- {
- if (index == 0)
- {
- return (PatternRoute)route;
- }
- else
- {
- index--;
- }
- }
- }
- return null;
- }
-
- final Route append(RouteDescriptor descriptor) throws MalformedRouteException
- {
- Route route = append(descriptor.getPathParams(), descriptor.getPath());
-
- //
- for (RouteParamDescriptor routeParamDesc : descriptor.getRouteParams())
- {
- route.add(RouteParam.create(routeParamDesc));
- }
-
- //
- for (RequestParamDescriptor requestParamDesc : descriptor.getRequestParams())
- {
- route.add(RequestParam.create(requestParamDesc));
- }
-
- //
- for (RouteDescriptor childDescriptor : descriptor.getChildren())
- {
- route.append(childDescriptor);
- }
-
- //
- return route;
- }
-
- final Route add(RouteParam param) throws MalformedRouteException
- {
- Param existing = findParam(param.name);
- if (existing != null)
- {
- throw new MalformedRouteException("Duplicate parameter " + param.name);
- }
- routeParams.put(param.name, param);
- return this;
- }
-
- final Route add(RequestParam param) throws MalformedRouteException
- {
- Param existing = findParam(param.name);
- if (existing != null)
- {
- throw new MalformedRouteException("Duplicate parameter " + param.name);
- }
- requestParams.put(param.matchName, param);
- return this;
- }
-
- /**
- * Append a path, creates the necessary routes and returns the last route added.
- *
- * @param pathParamDescriptors the path param descriptors
- * @param path the path to append
- * @return the last route added
- */
- private Route append(Map<QualifiedName, PathParamDescriptor> pathParamDescriptors, String path) throws MalformedRouteException
- {
- if (path.length() == 0 || path.charAt(0) != '/')
- {
- throw new MalformedRouteException();
- }
-
- //
- int pos = path.length();
- int level = 0;
- List<Integer> start = new ArrayList<Integer>();
- List<Integer> end = new ArrayList<Integer>();
- for (int i = 1;i < path.length();i++)
- {
- char c = path.charAt(i);
- if (c == '{')
- {
- if (level++ == 0)
- {
- start.add(i);
- }
- }
- else if (c == '}')
- {
- if (--level == 0)
- {
- end.add(i);
- }
- }
- else if (c == '/')
- {
- if (level == 0)
- {
- pos = i;
- break;
- }
- }
- }
-
- //
- Route next;
- if (start.isEmpty())
- {
- String segment = path.substring(1, pos);
- SegmentRoute route = new SegmentRoute(router, segment);
- add(route);
- next = route;
- }
- else
- {
- if (start.size() == end.size())
- {
- PatternBuilder builder = new PatternBuilder();
- builder.expr("^").expr('/');
- List<String> chunks = new ArrayList<String>();
- List<PathParam> parameterPatterns = new ArrayList<PathParam>();
-
- //
- int previous = 1;
- for (int i = 0;i < start.size();i++)
- {
- builder.litteral(path, previous, start.get(i));
- chunks.add(path.substring(previous, start.get(i)));
- String parameterName = path.substring(start.get(i) + 1, end.get(i));
-
- //
- QualifiedName parameterQName = QualifiedName.parse(parameterName);
-
- // Now get path param metadata
- PathParamDescriptor parameterDescriptor = pathParamDescriptors.get(parameterQName);
-
- //
- PathParam param;
- if (parameterDescriptor != null)
- {
- param = PathParam.create(parameterDescriptor);
- }
- else
- {
- param = PathParam.create(parameterQName);
- }
-
- // Append routing regex to the route regex
- builder.expr("(").expr(param.routingRegex).expr(")");
-
- // Add the path param with the rendering regex
- parameterPatterns.add(param);
- previous = end.get(i) + 1;
- }
-
- //
- builder.litteral(path, previous, pos);
-
- // We want to satisfy one of the following conditions
- // - the next char after the matched expression is '/'
- // - the expression matched until the end
- // - the match expression is the '/' expression
- builder.expr("(?:(?<=^/)|(?=/)|$)");
-
- //
- chunks.add(path.substring(previous, pos));
- PatternRoute route = new PatternRoute(router, builder.build(), parameterPatterns, chunks);
-
- // Wire
- add(route);
-
- //
- next = route;
- }
- else
- {
- throw new UnsupportedOperationException("Report error");
- }
- }
-
- //
- if (pos < path.length())
- {
- return next.append(pathParamDescriptors, path.substring(pos));
- }
- else
- {
- return next;
- }
- }
-
- private Param getParam(QualifiedName name)
- {
- if (routeParams.containsKey(name))
- {
- return routeParams.get(name);
- }
- else
- {
- for (RequestParam param : requestParams.values())
- {
- if (param.name.equals(name))
- {
- return param;
- }
- }
- }
- if (this instanceof PatternRoute)
- {
- for (PathParam param : ((PatternRoute)this).params)
- {
- if (param.name.equals(name))
- {
- return param;
- }
- }
- }
- return null;
- }
-
- private Param findParam(QualifiedName name)
- {
- Param param = getParam(name);
- if (param == null && parent != null)
- {
- param = parent.findParam(name);
- }
- return param;
- }
-
- private void findParams(List<Param> params)
- {
- for (RouteParam param : routeParams.values())
- {
- params.add(param);
- }
- for (RequestParam param : requestParams.values())
- {
- params.add(param);
- }
- if (this instanceof PatternRoute)
- {
- Collections.addAll(params, ((PatternRoute)this).params);
- }
- }
-
- private void findAncestorOrSelfParams(List<Param> params)
- {
- findParams(params);
- if (parent != null)
- {
- parent.findAncestorOrSelfParams(params);
- }
- }
-
- /**
- * Find the params having the specified <code>name</code> among this route or its descendants.
- *
- * @param name the name
- * @param params the list collecting the found params
- */
- private void findDescendantOrSelfParams(QualifiedName name, List<Param> params)
- {
- Param param = getParam(name);
- if (param != null)
- {
- params.add(param);
- }
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,1283 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+//import javanet.staxutils.IndentingXMLStreamWriter;
+import org.exoplatform.web.controller.QualifiedName;
+import org.exoplatform.web.controller.metadata.PathParamDescriptor;
+import org.exoplatform.web.controller.metadata.RequestParamDescriptor;
+import org.exoplatform.web.controller.metadata.RouteDescriptor;
+import org.exoplatform.web.controller.metadata.RouteParamDescriptor;
+import org.gatein.common.util.Tools;
+
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.regex.Matcher;
+
+/**
+ * The implementation of the routing algorithm.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+class Route
+{
+
+ void writeTo(XMLStreamWriter writer) throws XMLStreamException
+ {
+ if (this instanceof SegmentRoute)
+ {
+ writer.writeStartElement("segment");
+ writer.writeAttribute("path", "/" + ((SegmentRoute)this).name);
+ writer.writeAttribute("terminal", "" + terminal);
+ }
+ else if (this instanceof PatternRoute)
+ {
+ PatternRoute pr = (PatternRoute)this;
+ StringBuilder path = new StringBuilder("/");
+ for (int i = 0;i < pr.params.length;i++)
+ {
+ path.append(pr.chunks[i]).append("{").append(pr.params[i].name.getValue()).append("}");
+ }
+ path.append(pr.chunks[pr.chunks.length - 1]);
+ writer.writeStartElement("pattern");
+ writer.writeAttribute("path", path.toString());
+ writer.writeAttribute("terminal", Boolean.toString(terminal));
+ for (PathParam param : pr.params)
+ {
+ writer.writeStartElement("path-param");
+ writer.writeAttribute("qname", param.name.getValue());
+ writer.writeAttribute("encodingMode", param.encodingMode.toString());
+ writer.writeAttribute("pattern", param.renderingPattern.toString());
+ writer.writeEndElement();
+ }
+ }
+ else
+ {
+ writer.writeStartElement("route");
+ }
+
+ //
+ for (RouteParam routeParam : routeParams.values())
+ {
+ writer.writeStartElement("route-param");
+ writer.writeAttribute("qname", routeParam.name.getValue());
+ writer.writeAttribute("value", routeParam.value);
+ writer.writeEndElement();
+ }
+
+ //
+ for (RequestParam requestParam : requestParams.values())
+ {
+ writer.writeStartElement("request-param");
+ writer.writeAttribute("qname", requestParam.name.getValue());
+ writer.writeAttribute("name", requestParam.matchName);
+ if (requestParam.matchPattern != null)
+ {
+ writer.writeAttribute("value", requestParam.matchPattern.pattern());
+ }
+ writer.writeEndElement();
+ }
+
+ //
+/*
+ for (Map.Entry<String, SegmentRoute[]> entry : segments.entrySet())
+ {
+ writer.writeStartElement("segment");
+ writer.writeAttribute("name", entry.getKey());
+ for (SegmentRoute segment : entry.getValue())
+ {
+ segment.writeTo(writer);
+ }
+ writer.writeEndElement();
+ }
+
+ //
+ for (PatternRoute pattern : patterns)
+ {
+ pattern.writeTo(writer);
+ }
+*/
+
+ //
+ writer.writeEndElement();
+ }
+
+ @Override
+ public String toString()
+ {
+ try
+ {
+ XMLOutputFactory factory = XMLOutputFactory.newInstance();
+ StringWriter sw = new StringWriter();
+ XMLStreamWriter xmlWriter = factory.createXMLStreamWriter(sw);
+// xmlWriter = new IndentingXMLStreamWriter(xmlWriter);
+ writeTo(xmlWriter);
+ return sw.toString();
+ }
+ catch (XMLStreamException e)
+ {
+ throw new AssertionError(e);
+ }
+ }
+
+ /** . */
+ private static final Route[] EMPTY_ROUTE_ARRAY = new Route[0];
+
+ /** . */
+ private final Router router;
+
+ /** . */
+ private Route parent;
+
+ /** . */
+ private boolean terminal;
+
+ /** . */
+ private Route[] children;
+
+ /** . */
+ private final Map<QualifiedName, RouteParam> routeParams;
+
+ /** . */
+ private final Map<String, RequestParam> requestParams;
+
+ Route(Router router)
+ {
+ this.router = router;
+ this.parent = null;
+ this.terminal = true;
+ this.children = EMPTY_ROUTE_ARRAY;
+ this.routeParams = new HashMap<QualifiedName, RouteParam>();
+ this.requestParams = new HashMap<String, RequestParam>();
+ }
+
+ final boolean isTerminal()
+ {
+ return terminal;
+ }
+
+ /*
+ * Ok, so this is not the fastest way to do it, but for now it's OK, it's what is needed, we'll find
+ * a way to optimize it later with some precompilation.
+ */
+ final void render(Map<QualifiedName, String> blah, URIWriter writer) throws IOException
+ {
+ Route r = find(blah);
+
+ // We found a route we need to render it now
+ if (r != null)
+ {
+ // Append path first
+ r.renderPath(blah, writer, false);
+
+ // Append query parameters after
+ r.renderQueryString(blah, writer);
+ }
+ }
+
+ private boolean renderPath(Map<QualifiedName, String> blah, URIWriter writer, boolean hasChildren) throws IOException
+ {
+ boolean endWithSlash;
+ if (parent != null)
+ {
+ endWithSlash = parent.renderPath(blah, writer, true);
+ }
+ else
+ {
+ endWithSlash = false;
+ }
+
+ //
+ if (this instanceof SegmentRoute)
+ {
+ SegmentRoute sr = (SegmentRoute)this;
+ if (!endWithSlash)
+ {
+ writer.append('/');
+ endWithSlash = true;
+ }
+ String name = sr.encodedName;
+ writer.append(name);
+ if (name.length() > 0)
+ {
+ endWithSlash = false;
+ }
+ }
+ else if (this instanceof PatternRoute)
+ {
+ PatternRoute pr = (PatternRoute)this;
+ if (!endWithSlash)
+ {
+ writer.append('/');
+ endWithSlash = true;
+ }
+ int i = 0;
+ int count = 0;
+ while (i < pr.params.length)
+ {
+ writer.append(pr.encodedChunks[i]);
+ count += pr.chunks[i].length();
+
+ //
+ PathParam def = pr.params[i];
+ String value = blah.get(def.name);
+ count += value.length();
+
+ // Write value
+ for (int len = value.length(), j = 0;j < len;j++)
+ {
+ char c = value.charAt(j);
+ if (c == router.separatorEscape)
+ {
+ if (def.encodingMode == EncodingMode.PRESERVE_PATH)
+ {
+ writer.append('_');
+ } else
+ {
+ writer.append('%');
+ writer.append(router.separatorEscapeNible1);
+ writer.append(router.separatorEscapeNible2);
+ }
+ }
+ else if (c == '/')
+ {
+ writer.append(def.encodingMode == EncodingMode.PRESERVE_PATH ? '/' : router.separatorEscape);
+ }
+ else
+ {
+ writer.appendSegment(c);
+ }
+ }
+
+ //
+ i++;
+ }
+ writer.append(pr.encodedChunks[i]);
+ count += pr.chunks[i].length();
+ if (count > 0)
+ {
+ endWithSlash = false;
+ }
+ }
+ else
+ {
+ if (!hasChildren)
+ {
+ writer.append('/');
+ endWithSlash = true;
+ }
+ }
+
+ //
+ return endWithSlash;
+ }
+
+ private void renderQueryString(Map<QualifiedName, String> blah, URIWriter writer) throws IOException
+ {
+ if (parent != null)
+ {
+ parent.renderQueryString(blah, writer);
+ }
+
+ //
+ if (requestParams.size() > 0)
+ {
+ for (RequestParam requestParamDef : requestParams.values())
+ {
+ String s = blah.get(requestParamDef.name);
+ switch (requestParamDef.valueMapping)
+ {
+ case CANONICAL:
+ break;
+ case NEVER_EMPTY:
+ if (s != null && s.length() == 0)
+ {
+ s = null;
+ }
+ break;
+ case NEVER_NULL:
+ if (s == null)
+ {
+ s = "";
+ }
+ break;
+ }
+ if (s != null)
+ {
+ writer.appendQueryParameter(requestParamDef.matchName, s);
+ }
+ }
+ }
+ }
+
+ final Route find(Map<QualifiedName, String> blah)
+ {
+
+ // Remove what is matched
+ Map<QualifiedName, String> abc = new HashMap<QualifiedName, String>(blah);
+
+ // Match first the static parameteters
+ for (RouteParam param : routeParams.values())
+ {
+ String value = blah.get(param.name);
+ if (param.value.equals(value))
+ {
+ abc.remove(param.name);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ // Match any request parameter
+ if (requestParams.size() > 0)
+ {
+ for (RequestParam requestParamDef : requestParams.values())
+ {
+ String a = blah.get(requestParamDef.name);
+ boolean matched = false;
+ if (a != null)
+ {
+ if (requestParamDef.matchValue(a))
+ {
+ matched = true;
+ }
+ }
+ if (matched)
+ {
+ abc.remove(requestParamDef.name);
+ }
+ else
+ {
+ switch (requestParamDef.controlMode)
+ {
+ case OPTIONAL:
+ // Do nothing
+ break;
+ case REQUIRED:
+ return null;
+ default:
+ throw new AssertionError();
+ }
+ }
+ }
+ }
+
+ // Match any pattern parameter
+ if (this instanceof PatternRoute)
+ {
+ PatternRoute prt = (PatternRoute)this;
+ for (int i = 0;i < prt.params.length;i++)
+ {
+ PathParam param = prt.params[i];
+ String s = blah.get(param.name);
+ boolean matched = false;
+ if (s != null)
+ {
+ switch (param.encodingMode)
+ {
+ case FORM:
+ matched = param.renderingPattern.matcher(s).matches();
+ break;
+ case PRESERVE_PATH:
+ matched = param.renderingPattern.matcher(s).matches();
+ break;
+ default:
+ throw new AssertionError();
+ }
+ }
+ if (matched)
+ {
+ abc.remove(param.name);
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ //
+ if (abc.isEmpty() && terminal)
+ {
+ return this;
+ }
+
+ //
+ for (Route route : children)
+ {
+ Route a = route.find(abc);
+ if (a != null)
+ {
+ return a;
+ }
+ }
+
+ //
+ return null;
+ }
+
+ /**
+ * Create a route matcher for the a request.
+ *
+ * @param path the path
+ * @param requestParams the query parameters
+ * @return the route matcher
+ */
+ final RouteMatcher route(String path, Map<String, String[]> requestParams)
+ {
+ return new RouteMatcher(this, Path.parse(path), requestParams);
+ }
+
+ static class RouteFrame
+ {
+
+ /**
+ * Defines the status of a frame.
+ */
+ static enum Status
+ {
+ BEGIN,
+
+ MATCHED_PARAMS,
+
+ PROCESS_CHILDREN,
+
+ MATCHED,
+
+ END
+
+ }
+
+ /** . */
+ private final RouteFrame parent;
+
+ /** . */
+ private final Route route;
+
+ /** . */
+ private final Path path;
+
+ /** . */
+ private Status status;
+
+ /** The matches. */
+ private Map<QualifiedName, String> matches;
+
+ /** The index when iterating child in {@link org.exoplatform.web.controller.router.Route.RouteFrame.Status#PROCESS_CHILDREN} status. */
+ private int childIndex;
+
+ private RouteFrame(RouteFrame parent, Route route, Path path)
+ {
+ this.parent = parent;
+ this.route = route;
+ this.path = path;
+ this.status = Status.BEGIN;
+ this.childIndex = 0;
+ }
+
+ private RouteFrame(Route route, Path path)
+ {
+ this(null, route, path);
+ }
+
+ Map<QualifiedName, String> getParameters()
+ {
+ Map<QualifiedName, String> parameters = null;
+ for (RouteFrame frame = this;frame != null;frame = frame.parent)
+ {
+ if (frame.matches != null)
+ {
+ if (parameters == null)
+ {
+ parameters = new HashMap<QualifiedName, String>();
+ }
+ parameters.putAll(frame.matches);
+ }
+ if (frame.route.routeParams.size() > 0)
+ {
+ if (parameters == null)
+ {
+ parameters = new HashMap<QualifiedName, String>();
+ }
+ for (RouteParam param : frame.route.routeParams.values())
+ {
+ parameters.put(param.name, param.value);
+ }
+ }
+ }
+ return parameters != null ? parameters : Collections.<QualifiedName, String>emptyMap();
+ }
+ }
+
+ static class RouteMatcher implements Iterator<Map<QualifiedName, String>>
+ {
+
+ /** . */
+ private final Map<String, String[]> requestParams;
+
+ /** . */
+ private RouteFrame frame;
+
+ /** . */
+ private RouteFrame next;
+
+ RouteMatcher(Route route, Path path, Map<String, String[]> requestParams)
+ {
+ this.frame = new RouteFrame(route, path);
+ this.requestParams = requestParams;
+ }
+
+ public boolean hasNext()
+ {
+ if (next == null)
+ {
+ if (frame != null)
+ {
+ frame = route(frame, requestParams);
+ }
+ if (frame != null && frame.status == RouteFrame.Status.MATCHED)
+ {
+ next = frame;
+ }
+ }
+ return next != null;
+ }
+
+ public Map<QualifiedName, String> next()
+ {
+ if (!hasNext())
+ {
+ throw new NoSuchElementException();
+ }
+ Map<QualifiedName, String> parameters = next.getParameters();
+ next = null;
+ return parameters;
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ private static RouteFrame route(RouteFrame root, Map<String, String[]> requestParams)
+ {
+ RouteFrame current = root;
+
+ //
+ if (root.status == RouteFrame.Status.MATCHED)
+ {
+ if (root.parent != null)
+ {
+ current = root.parent;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else if (root.status != RouteFrame.Status.BEGIN)
+ {
+ throw new AssertionError("Unexpected status " + root.status);
+ }
+
+ //
+ while (true)
+ {
+ if (current.status == RouteFrame.Status.BEGIN)
+ {
+ boolean matched = true;
+
+ // We enter a frame
+ if (current.route.requestParams.size() > 0)
+ {
+ for (RequestParam requestParamDef : current.route.requestParams.values())
+ {
+ String value = null;
+ String[] values = requestParams.get(requestParamDef.matchName);
+ if (values != null && values.length > 0 && values[0] != null)
+ {
+ value = values[0];
+ }
+ if (value == null)
+ {
+ switch (requestParamDef.controlMode)
+ {
+ case OPTIONAL:
+ // Do nothing
+ break;
+ case REQUIRED:
+ matched = false;
+ break;
+ }
+ }
+ else if (!requestParamDef.matchValue(value))
+ {
+ matched = false;
+ break;
+ }
+ switch (requestParamDef.valueMapping)
+ {
+ case CANONICAL:
+ break;
+ case NEVER_EMPTY:
+ if (value != null && value.length() == 0)
+ {
+ value = null;
+ }
+ break;
+ case NEVER_NULL:
+ if (value == null)
+ {
+ value = "";
+ }
+ break;
+ }
+ if (value != null)
+ {
+ if (current.matches == null)
+ {
+ current.matches = new HashMap<QualifiedName, String>();
+ }
+ current.matches.put(requestParamDef.name, value);
+ }
+ }
+ }
+
+ //
+ if (matched)
+ {
+ // We enter next state
+ current.status = RouteFrame.Status.MATCHED_PARAMS;
+ }
+ else
+ {
+ current.status = RouteFrame.Status.END;
+ }
+ }
+ else if (current.status == RouteFrame.Status.MATCHED_PARAMS)
+ {
+ RouteFrame.Status next;
+
+ // Anything that does not begin with '/' returns null
+ if (current.path.length() > 0 && current.path.charAt(0) == '/')
+ {
+ // The '/' means the current controller if any, otherwise it may be processed by the pattern matching
+ if (current.path.length() == 1 && current.route.terminal)
+ {
+ next = RouteFrame.Status.MATCHED;
+ }
+ else
+ {
+ next = RouteFrame.Status.PROCESS_CHILDREN;
+ }
+ }
+ else
+ {
+ next = RouteFrame.Status.END;
+ }
+
+ //
+ current.status = next;
+ }
+ else if (current.status == RouteFrame.Status.PROCESS_CHILDREN)
+ {
+ if (current.childIndex < current.route.children.length)
+ {
+ Route child = current.route.children[current.childIndex++];
+
+ // The next frame
+ RouteFrame next;
+
+ //
+ if (child instanceof SegmentRoute)
+ {
+ SegmentRoute segmentRoute = (SegmentRoute)child;
+
+ //
+ if (segmentRoute.name.length() == 0)
+ {
+ // Delegate the process to the next route
+ next = new RouteFrame(current, segmentRoute, current.path);
+ }
+ else
+ {
+ // Find the next '/' for determining the segment and next path
+ // JULIEN : this can be computed multiple times
+ int pos = current.path.indexOf('/', 1);
+ if (pos == -1)
+ {
+ pos = current.path.length();
+ }
+ String segment = current.path.getValue().substring(1, pos);
+
+ // Determine next path
+ if (segmentRoute.name.equals(segment))
+ {
+ // Lazy create next segment path
+ // JULIEN : this can be computed multiple times
+ Path nextSegmentPath;
+ if (pos == current.path.length())
+ {
+ // todo make a constant
+ nextSegmentPath = Path.SLASH;
+ }
+ else
+ {
+ nextSegmentPath = current.path.subPath(pos);
+ }
+
+ // Delegate the process to the next route
+ next = new RouteFrame(current, segmentRoute, nextSegmentPath);
+ }
+ else
+ {
+ next = null;
+ }
+ }
+ }
+ else if (child instanceof PatternRoute)
+ {
+ PatternRoute patternRoute = (PatternRoute)child;
+
+ //
+ Matcher matcher = patternRoute.pattern.matcher(current.path.getValue());
+
+ // We match
+ if (matcher.find())
+ {
+ // Build next controller context
+ int nextPos = matcher.end();
+ Path nextPath;
+ if (current.path.length() == nextPos)
+ {
+ nextPath = Path.SLASH;
+ }
+ else
+ {
+ if (nextPos > 0 && current.path.charAt(nextPos - 1) == '/')
+ {
+ nextPos--;
+ }
+
+ //
+ nextPath = current.path.subPath(nextPos);
+ }
+
+ // Delegate to next patternRoute
+ next = new RouteFrame(current, patternRoute, nextPath);
+
+ // JULIEN : this can be done lazily
+ // Append parameters
+ int group = 1;
+ for (int i = 0;i < patternRoute.params.length;i++)
+ {
+ PathParam param = patternRoute.params[i];
+
+ //
+ int end = matcher.end(group);
+
+ //
+ if (end != -1)
+ {
+ String value;
+ if (param.encodingMode == EncodingMode.FORM)
+ {
+ StringBuilder sb = new StringBuilder();
+ for (int from = matcher.start(group);from < end;from++)
+ {
+ char c = current.path.charAt(from);
+ if (c == child.router.separatorEscape && current.path.getRawLength(from) == 1)
+ {
+ c = '/';
+ }
+ sb.append(c);
+ }
+ value = sb.toString();
+ }
+ else
+ {
+ value = matcher.group(group);
+ }
+ if (next.matches == null)
+ {
+ next.matches = new HashMap<QualifiedName, String>();
+ }
+ next.matches.put(param.name, value);
+ }
+ else
+ {
+ // We have an optional match
+ }
+
+ //
+ group++;
+ }
+ }
+ else
+ {
+ next = null;
+ }
+ }
+ else
+ {
+ throw new AssertionError();
+ }
+
+ //
+ if (next != null)
+ {
+ current = next;
+ }
+ }
+ else
+ {
+ current.status = RouteFrame.Status.END;
+ }
+ }
+ else if (current.status == RouteFrame.Status.MATCHED)
+ {
+ // We found a solution
+ break;
+ }
+ else if (current.status == RouteFrame.Status.END)
+ {
+ if (current.parent != null)
+ {
+ current = current.parent;
+ }
+ else
+ {
+ // The end of the search
+ break;
+ }
+ }
+ else
+ {
+ throw new AssertionError();
+ }
+ }
+
+ //
+ return current;
+ }
+
+ final <R extends Route> R add(R route) throws MalformedRouteException
+ {
+ if (route == null)
+ {
+ throw new NullPointerException("No null route accepted");
+ }
+ if (route.parent != null)
+ {
+ throw new IllegalArgumentException("No route with an existing parent can be accepted");
+ }
+
+ //
+ LinkedList<Param> ancestorParams = new LinkedList<Param>();
+ findAncestorOrSelfParams(ancestorParams);
+ LinkedList<Param> descendantParams = new LinkedList<Param>();
+ for (Param param : ancestorParams)
+ {
+ route.findDescendantOrSelfParams(param.name, descendantParams);
+ if (descendantParams.size() > 0)
+ {
+ throw new MalformedRouteException("Duplicate parameter " + param.name);
+ }
+ }
+
+ //
+ if (route instanceof PatternRoute || route instanceof SegmentRoute)
+ {
+ children = Tools.appendTo(children, route);
+ terminal = false;
+ route.parent = this;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Only accept segment or pattern routes");
+ }
+
+ //
+ return route;
+ }
+
+ final Set<String> getSegmentNames()
+ {
+ Set<String> names = new HashSet<String>();
+ for (Route child : children)
+ {
+ if (child instanceof SegmentRoute)
+ {
+ SegmentRoute childSegment = (SegmentRoute)child;
+ names.add(childSegment.name);
+ }
+ }
+ return names;
+ }
+
+ final int getSegmentSize(String segmentName)
+ {
+ int size = 0;
+ for (Route child : children)
+ {
+ if (child instanceof SegmentRoute)
+ {
+ SegmentRoute childSegment = (SegmentRoute)child;
+ if (segmentName.equals(childSegment.name))
+ {
+ size++;
+ }
+ }
+ }
+ return size;
+ }
+
+ final SegmentRoute getSegment(String segmentName, int index)
+ {
+ for (Route child : children)
+ {
+ if (child instanceof SegmentRoute)
+ {
+ SegmentRoute childSegment = (SegmentRoute)child;
+ if (segmentName.equals(childSegment.name))
+ {
+ if (index == 0)
+ {
+ return childSegment;
+ }
+ else
+ {
+ index--;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ final int getPatternSize()
+ {
+ int size = 0;
+ for (Route route : children)
+ {
+ if (route instanceof PatternRoute)
+ {
+ size++;
+ }
+ }
+ return size;
+ }
+
+ final PatternRoute getPattern(int index)
+ {
+ for (Route route : children)
+ {
+ if (route instanceof PatternRoute)
+ {
+ if (index == 0)
+ {
+ return (PatternRoute)route;
+ }
+ else
+ {
+ index--;
+ }
+ }
+ }
+ return null;
+ }
+
+ final Route append(RouteDescriptor descriptor) throws MalformedRouteException
+ {
+ Route route = append(descriptor.getPathParams(), descriptor.getPath());
+
+ //
+ for (RouteParamDescriptor routeParamDesc : descriptor.getRouteParams())
+ {
+ route.add(RouteParam.create(routeParamDesc));
+ }
+
+ //
+ for (RequestParamDescriptor requestParamDesc : descriptor.getRequestParams())
+ {
+ route.add(RequestParam.create(requestParamDesc));
+ }
+
+ //
+ for (RouteDescriptor childDescriptor : descriptor.getChildren())
+ {
+ route.append(childDescriptor);
+ }
+
+ //
+ return route;
+ }
+
+ final Route add(RouteParam param) throws MalformedRouteException
+ {
+ Param existing = findParam(param.name);
+ if (existing != null)
+ {
+ throw new MalformedRouteException("Duplicate parameter " + param.name);
+ }
+ routeParams.put(param.name, param);
+ return this;
+ }
+
+ final Route add(RequestParam param) throws MalformedRouteException
+ {
+ Param existing = findParam(param.name);
+ if (existing != null)
+ {
+ throw new MalformedRouteException("Duplicate parameter " + param.name);
+ }
+ requestParams.put(param.matchName, param);
+ return this;
+ }
+
+ /**
+ * Append a path, creates the necessary routes and returns the last route added.
+ *
+ * @param pathParamDescriptors the path param descriptors
+ * @param path the path to append
+ * @return the last route added
+ */
+ private Route append(Map<QualifiedName, PathParamDescriptor> pathParamDescriptors, String path) throws MalformedRouteException
+ {
+ if (path.length() == 0 || path.charAt(0) != '/')
+ {
+ throw new MalformedRouteException();
+ }
+
+ //
+ int pos = path.length();
+ int level = 0;
+ List<Integer> start = new ArrayList<Integer>();
+ List<Integer> end = new ArrayList<Integer>();
+ for (int i = 1;i < path.length();i++)
+ {
+ char c = path.charAt(i);
+ if (c == '{')
+ {
+ if (level++ == 0)
+ {
+ start.add(i);
+ }
+ }
+ else if (c == '}')
+ {
+ if (--level == 0)
+ {
+ end.add(i);
+ }
+ }
+ else if (c == '/')
+ {
+ if (level == 0)
+ {
+ pos = i;
+ break;
+ }
+ }
+ }
+
+ //
+ Route next;
+ if (start.isEmpty())
+ {
+ String segment = path.substring(1, pos);
+ SegmentRoute route = new SegmentRoute(router, segment);
+ add(route);
+ next = route;
+ }
+ else
+ {
+ if (start.size() == end.size())
+ {
+ PatternBuilder builder = new PatternBuilder();
+ builder.expr("^").expr('/');
+ List<String> chunks = new ArrayList<String>();
+ List<PathParam> parameterPatterns = new ArrayList<PathParam>();
+
+ //
+ int previous = 1;
+ for (int i = 0;i < start.size();i++)
+ {
+ builder.litteral(path, previous, start.get(i));
+ chunks.add(path.substring(previous, start.get(i)));
+ String parameterName = path.substring(start.get(i) + 1, end.get(i));
+
+ //
+ QualifiedName parameterQName = QualifiedName.parse(parameterName);
+
+ // Now get path param metadata
+ PathParamDescriptor parameterDescriptor = pathParamDescriptors.get(parameterQName);
+
+ //
+ PathParam param;
+ if (parameterDescriptor != null)
+ {
+ param = PathParam.create(parameterDescriptor);
+ }
+ else
+ {
+ param = PathParam.create(parameterQName);
+ }
+
+ // Append routing regex to the route regex
+ builder.expr("(").expr(param.routingRegex).expr(")");
+
+ // Add the path param with the rendering regex
+ parameterPatterns.add(param);
+ previous = end.get(i) + 1;
+ }
+
+ //
+ builder.litteral(path, previous, pos);
+
+ // We want to satisfy one of the following conditions
+ // - the next char after the matched expression is '/'
+ // - the expression matched until the end
+ // - the match expression is the '/' expression
+ builder.expr("(?:(?<=^/)|(?=/)|$)");
+
+ //
+ chunks.add(path.substring(previous, pos));
+ PatternRoute route = new PatternRoute(router, builder.build(), parameterPatterns, chunks);
+
+ // Wire
+ add(route);
+
+ //
+ next = route;
+ }
+ else
+ {
+ throw new UnsupportedOperationException("Report error");
+ }
+ }
+
+ //
+ if (pos < path.length())
+ {
+ return next.append(pathParamDescriptors, path.substring(pos));
+ }
+ else
+ {
+ return next;
+ }
+ }
+
+ private Param getParam(QualifiedName name)
+ {
+ if (routeParams.containsKey(name))
+ {
+ return routeParams.get(name);
+ }
+ else
+ {
+ for (RequestParam param : requestParams.values())
+ {
+ if (param.name.equals(name))
+ {
+ return param;
+ }
+ }
+ }
+ if (this instanceof PatternRoute)
+ {
+ for (PathParam param : ((PatternRoute)this).params)
+ {
+ if (param.name.equals(name))
+ {
+ return param;
+ }
+ }
+ }
+ return null;
+ }
+
+ private Param findParam(QualifiedName name)
+ {
+ Param param = getParam(name);
+ if (param == null && parent != null)
+ {
+ param = parent.findParam(name);
+ }
+ return param;
+ }
+
+ private void findParams(List<Param> params)
+ {
+ for (RouteParam param : routeParams.values())
+ {
+ params.add(param);
+ }
+ for (RequestParam param : requestParams.values())
+ {
+ params.add(param);
+ }
+ if (this instanceof PatternRoute)
+ {
+ Collections.addAll(params, ((PatternRoute)this).params);
+ }
+ }
+
+ private void findAncestorOrSelfParams(List<Param> params)
+ {
+ findParams(params);
+ if (parent != null)
+ {
+ parent.findAncestorOrSelfParams(params);
+ }
+ }
+
+ /**
+ * Find the params having the specified <code>name</code> among this route or its descendants.
+ *
+ * @param name the name
+ * @param params the list collecting the found params
+ */
+ private void findDescendantOrSelfParams(QualifiedName name, List<Param> params)
+ {
+ Param param = getParam(name);
+ if (param != null)
+ {
+ params.add(param);
+ }
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteEscaper.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteEscaper.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteEscaper.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.exoplatform.web.controller.regexp.RENode;
-
-/**
- * The route escaper transformer a regular expression with the following rules:
- * <ul>
- * <li>substitute any char occurence of the source <i>s</i> by the destination <i>d</i></li>
- * <li>replace the <i>any</i> by the negated destination character <i>[^]</i></li>
- * <li>append <i>&&[^s]</i> to any top character class</li>
- * </ul>
- *
- * A few examples with <i>/</i> replaced by <i>_</i>:
- *
- * <ul>
- * <li><i>/</i> becomes <i>_</i></li>
- * <li><i>.</i> becomes <i>[^/]</i></li>
- * <li><i>[a/]</i> becomes <i>[a_&[^/]]</i></li>
- * <li><i>[,-1]</i> becomes <i>[,-.0-1_&&[^/]]</i></li>
- * </ul>
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class RouteEscaper
-{
-
- /** . */
- private final char src;
-
- /** . */
- private final char dst;
-
- public RouteEscaper(char src, char dst)
- {
- this.src = src;
- this.dst = dst;
- }
-
- public void visit(RENode.Disjunction disjunction) throws MalformedRouteException
- {
- visit(disjunction.getAlternative());
- RENode.Disjunction next = disjunction.getNext();
- if (next != null)
- {
- visit(next);
- }
- }
-
- public void visit(RENode.Alternative alternative) throws MalformedRouteException
- {
- visit(alternative.getExp());
- RENode.Alternative next = alternative.getNext();
- if (next != null)
- {
- visit(next);
- }
- }
-
- public void visit(RENode.Expr expr) throws MalformedRouteException
- {
- if (expr instanceof RENode.Char)
- {
- RENode.Char c = (RENode.Char)expr;
- if (c.getValue() == src)
- {
- c.setValue(dst);
- }
- }
- else if (expr instanceof RENode.Group)
- {
- RENode.Group group = (RENode.Group)expr;
-/*
- if (group.getType() == GroupType.CAPTURING_GROUP)
- {
- group.setType(GroupType.NON_CAPTURING_GROUP);
- }
-*/
- visit(group.getDisjunction());
- }
- else if (expr instanceof RENode.Any)
- {
- RENode.CharacterClass repl = new RENode.CharacterClass(new RENode.CharacterClassExpr.Not(new RENode.CharacterClassExpr.Char('/')));
- repl.setQuantifier(expr.getQuantifier());
- expr.replaceBy(repl);
- }
- else if (expr instanceof RENode.CharacterClass)
- {
- RENode.CharacterClass characterClass = (RENode.CharacterClass)expr;
- RENode.CharacterClassExpr ccExpr = characterClass.getExpr();
- ccExpr = ccExpr.replace(src, dst);
- RENode.CharacterClassExpr.And ccRepl = new RENode.CharacterClassExpr.And(null, new RENode.CharacterClassExpr.Not(new RENode.CharacterClassExpr.Char('/')));
- ccExpr.replaceBy(ccRepl);
- ccRepl.setLeft(ccExpr);
- }
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteEscaper.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteEscaper.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteEscaper.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteEscaper.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.web.controller.regexp.RENode;
+
+/**
+ * The route escaper transformer a regular expression with the following rules:
+ * <ul>
+ * <li>substitute any char occurence of the source <i>s</i> by the destination <i>d</i></li>
+ * <li>replace the <i>any</i> by the negated destination character <i>[^]</i></li>
+ * <li>append <i>&&[^s]</i> to any top character class</li>
+ * </ul>
+ *
+ * A few examples with <i>/</i> replaced by <i>_</i>:
+ *
+ * <ul>
+ * <li><i>/</i> becomes <i>_</i></li>
+ * <li><i>.</i> becomes <i>[^/]</i></li>
+ * <li><i>[a/]</i> becomes <i>[a_&[^/]]</i></li>
+ * <li><i>[,-1]</i> becomes <i>[,-.0-1_&&[^/]]</i></li>
+ * </ul>
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class RouteEscaper
+{
+
+ /** . */
+ private final char src;
+
+ /** . */
+ private final char dst;
+
+ public RouteEscaper(char src, char dst)
+ {
+ this.src = src;
+ this.dst = dst;
+ }
+
+ public void visit(RENode.Disjunction disjunction) throws MalformedRouteException
+ {
+ visit(disjunction.getAlternative());
+ RENode.Disjunction next = disjunction.getNext();
+ if (next != null)
+ {
+ visit(next);
+ }
+ }
+
+ public void visit(RENode.Alternative alternative) throws MalformedRouteException
+ {
+ visit(alternative.getExp());
+ RENode.Alternative next = alternative.getNext();
+ if (next != null)
+ {
+ visit(next);
+ }
+ }
+
+ public void visit(RENode.Expr expr) throws MalformedRouteException
+ {
+ if (expr instanceof RENode.Char)
+ {
+ RENode.Char c = (RENode.Char)expr;
+ if (c.getValue() == src)
+ {
+ c.setValue(dst);
+ }
+ }
+ else if (expr instanceof RENode.Group)
+ {
+ RENode.Group group = (RENode.Group)expr;
+/*
+ if (group.getType() == GroupType.CAPTURING_GROUP)
+ {
+ group.setType(GroupType.NON_CAPTURING_GROUP);
+ }
+*/
+ visit(group.getDisjunction());
+ }
+ else if (expr instanceof RENode.Any)
+ {
+ RENode.CharacterClass repl = new RENode.CharacterClass(new RENode.CharacterClassExpr.Not(new RENode.CharacterClassExpr.Char('/')));
+ repl.setQuantifier(expr.getQuantifier());
+ expr.replaceBy(repl);
+ }
+ else if (expr instanceof RENode.CharacterClass)
+ {
+ RENode.CharacterClass characterClass = (RENode.CharacterClass)expr;
+ RENode.CharacterClassExpr ccExpr = characterClass.getExpr();
+ ccExpr = ccExpr.replace(src, dst);
+ RENode.CharacterClassExpr.And ccRepl = new RENode.CharacterClassExpr.And(null, new RENode.CharacterClassExpr.Not(new RENode.CharacterClassExpr.Char('/')));
+ ccExpr.replaceBy(ccRepl);
+ ccRepl.setLeft(ccExpr);
+ }
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteParam.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteParam.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteParam.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.controller.metadata.RouteParamDescriptor;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-class RouteParam extends Param
-{
-
- static RouteParam create(RouteParamDescriptor descriptor)
- {
- if (descriptor == null)
- {
- throw new NullPointerException("No null descriptor accepted");
- }
-
- //
- return new RouteParam(descriptor.getQualifiedName(), descriptor.getValue());
- }
-
- /** . */
- final String value;
-
- RouteParam(QualifiedName name, String value)
- {
- super(name);
-
- //
- if (value == null)
- {
- throw new NullPointerException("No null value accepted");
- }
-
- //
- this.value = value;
- }
-
- @Override
- public String toString()
- {
- return "RouteParam[name=" + name + ",value=" + value + "]";
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteParam.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteParam.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteParam.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouteParam.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.web.controller.QualifiedName;
+import org.exoplatform.web.controller.metadata.RouteParamDescriptor;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+class RouteParam extends Param
+{
+
+ static RouteParam create(RouteParamDescriptor descriptor)
+ {
+ if (descriptor == null)
+ {
+ throw new NullPointerException("No null descriptor accepted");
+ }
+
+ //
+ return new RouteParam(descriptor.getQualifiedName(), descriptor.getValue());
+ }
+
+ /** . */
+ final String value;
+
+ RouteParam(QualifiedName name, String value)
+ {
+ super(name);
+
+ //
+ if (value == null)
+ {
+ throw new NullPointerException("No null value accepted");
+ }
+
+ //
+ this.value = value;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "RouteParam[name=" + name + ",value=" + value + "]";
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Router.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Router.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Router.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.controller.metadata.RouteDescriptor;
-import org.exoplatform.web.controller.metadata.ControllerDescriptor;
-import org.exoplatform.web.url.MimeType;
-import org.gatein.common.io.UndeclaredIOException;
-
-import java.io.IOException;
-import java.util.BitSet;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * The router takes care of mapping a request to a a map.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class Router
-{
-
- /** . */
- private static final BitSet escapeSet;
-
- static
- {
- // A subset of the path literals
- BitSet bs = new BitSet();
- bs.set('_');
- bs.set('.');
- bs.set('-');
- bs.set('~');
- bs.set('!');
- bs.set('$');
- bs.set('&');
- bs.set('+');
- bs.set(':');
- bs.set('@');
-
- //
- escapeSet = bs;
- }
-
- /** The root route. */
- final Route root;
-
- /** The slash escape char. */
- final char separatorEscape;
-
- /** . */
- final char separatorEscapeNible1;
-
- /** . */
- final char separatorEscapeNible2;
-
- public Router(ControllerDescriptor metaData) throws RouterConfigException
- {
- char separtorEscape = metaData.getSeparatorEscape();
-
- //
- int i = separtorEscape & ~0x7F;
- if (i > 0 || !escapeSet.get(separtorEscape))
- {
- throw new RouterConfigException("Char " + (int)separtorEscape + " cannot be used a separator escape");
- }
-
- //
- String s = Integer.toString(separtorEscape, 16).toUpperCase();
- separatorEscapeNible1 = s.charAt(0);
- separatorEscapeNible2 = s.charAt(1);
-
- //
- this.root = new Route(this);
- this.separatorEscape = separtorEscape;
-
- //
- for (RouteDescriptor routeMetaData : metaData.getRoutes())
- {
- addRoute(routeMetaData);
- }
- }
-
- public void addRoute(RouteDescriptor routeMetaData) throws RouterConfigException
- {
- root.append(routeMetaData);
- }
-
- public void render(Map<QualifiedName, String> parameters, URIWriter writer) throws IOException
- {
- root.render(parameters, writer);
- }
-
- public String render(Map<QualifiedName, String> parameters)
- {
- try
- {
- StringBuilder sb = new StringBuilder();
- URIWriter renderContext = new URIWriter(sb, MimeType.PLAIN);
- render(parameters, renderContext);
- return sb.toString();
- }
- catch (IOException e)
- {
- throw new UndeclaredIOException(e);
- }
- }
-
- public Map<QualifiedName, String> route(String path) throws IOException
- {
- return route(path, Collections.<String, String[]>emptyMap());
- }
-
- public Map<QualifiedName, String> route(String path, Map<String, String[]> queryParams)
- {
- Iterator<Map<QualifiedName, String>> matcher = matcher(path, queryParams);
- if (matcher.hasNext())
- {
- return matcher.next();
- }
- else
- {
- return null;
- }
- }
-
- public Iterator<Map<QualifiedName, String>> matcher(String path, Map<String, String[]> queryParams)
- {
- return root.route(path, queryParams);
- }
-
- @Override
- public String toString()
- {
- return "Router[" + root.toString() + "]";
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Router.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Router.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Router.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Router.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.web.controller.QualifiedName;
+import org.exoplatform.web.controller.metadata.RouteDescriptor;
+import org.exoplatform.web.controller.metadata.ControllerDescriptor;
+import org.exoplatform.web.url.MimeType;
+import org.gatein.common.io.UndeclaredIOException;
+
+import java.io.IOException;
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * The router takes care of mapping a request to a a map.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class Router
+{
+
+ /** . */
+ private static final BitSet escapeSet;
+
+ static
+ {
+ // A subset of the path literals
+ BitSet bs = new BitSet();
+ bs.set('_');
+ bs.set('.');
+ bs.set('-');
+ bs.set('~');
+ bs.set('!');
+ bs.set('$');
+ bs.set('&');
+ bs.set('+');
+ bs.set(':');
+ bs.set('@');
+
+ //
+ escapeSet = bs;
+ }
+
+ /** The root route. */
+ final Route root;
+
+ /** The slash escape char. */
+ final char separatorEscape;
+
+ /** . */
+ final char separatorEscapeNible1;
+
+ /** . */
+ final char separatorEscapeNible2;
+
+ public Router(ControllerDescriptor metaData) throws RouterConfigException
+ {
+ char separtorEscape = metaData.getSeparatorEscape();
+
+ //
+ int i = separtorEscape & ~0x7F;
+ if (i > 0 || !escapeSet.get(separtorEscape))
+ {
+ throw new RouterConfigException("Char " + (int)separtorEscape + " cannot be used a separator escape");
+ }
+
+ //
+ String s = Integer.toString(separtorEscape, 16).toUpperCase();
+ separatorEscapeNible1 = s.charAt(0);
+ separatorEscapeNible2 = s.charAt(1);
+
+ //
+ this.root = new Route(this);
+ this.separatorEscape = separtorEscape;
+
+ //
+ for (RouteDescriptor routeMetaData : metaData.getRoutes())
+ {
+ addRoute(routeMetaData);
+ }
+ }
+
+ public void addRoute(RouteDescriptor routeMetaData) throws RouterConfigException
+ {
+ root.append(routeMetaData);
+ }
+
+ public void render(Map<QualifiedName, String> parameters, URIWriter writer) throws IOException
+ {
+ root.render(parameters, writer);
+ }
+
+ public String render(Map<QualifiedName, String> parameters)
+ {
+ try
+ {
+ StringBuilder sb = new StringBuilder();
+ URIWriter renderContext = new URIWriter(sb, MimeType.PLAIN);
+ render(parameters, renderContext);
+ return sb.toString();
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+
+ public Map<QualifiedName, String> route(String path) throws IOException
+ {
+ return route(path, Collections.<String, String[]>emptyMap());
+ }
+
+ public Map<QualifiedName, String> route(String path, Map<String, String[]> queryParams)
+ {
+ Iterator<Map<QualifiedName, String>> matcher = matcher(path, queryParams);
+ if (matcher.hasNext())
+ {
+ return matcher.next();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public Iterator<Map<QualifiedName, String>> matcher(String path, Map<String, String[]> queryParams)
+ {
+ return root.route(path, queryParams);
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Router[" + root.toString() + "]";
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouterConfigException.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouterConfigException.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouterConfigException.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- */
-public class RouterConfigException extends Exception
-{
-
- public RouterConfigException()
- {
- }
-
- public RouterConfigException(String message)
- {
- super(message);
- }
-
- public RouterConfigException(String message, Throwable cause)
- {
- super(message, cause);
- }
-
- public RouterConfigException(Throwable cause)
- {
- super(cause);
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouterConfigException.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouterConfigException.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouterConfigException.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RouterConfigException.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public class RouterConfigException extends Exception
+{
+
+ public RouterConfigException()
+ {
+ }
+
+ public RouterConfigException(String message)
+ {
+ super(message);
+ }
+
+ public RouterConfigException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public RouterConfigException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/SegmentRoute.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/SegmentRoute.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/SegmentRoute.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-class SegmentRoute extends Route
-{
-
- /** . */
- final String name;
-
- /** . */
- final String encodedName;
-
- SegmentRoute(Router router, String name)
- {
- super(router);
-
- //
- this.name = name;
- this.encodedName = PercentEncoding.PATH_SEGMENT.encode(name);
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/SegmentRoute.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/SegmentRoute.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/SegmentRoute.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/SegmentRoute.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+class SegmentRoute extends Route
+{
+
+ /** . */
+ final String name;
+
+ /** . */
+ final String encodedName;
+
+ SegmentRoute(Router router, String name)
+ {
+ super(router);
+
+ //
+ this.name = name;
+ this.encodedName = PercentEncoding.PATH_SEGMENT.encode(name);
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/URIWriter.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/URIWriter.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/URIWriter.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,194 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.exoplatform.web.url.MimeType;
-
-import java.io.IOException;
-import java.util.EnumMap;
-import java.util.Map;
-
-/**
- * An uri writer.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- */
-public final class URIWriter
-{
-
- /** . */
- private static final Map<MimeType, String> AMP_MAP = new EnumMap<MimeType, String>(MimeType.class);
-
- static
- {
- AMP_MAP.put(MimeType.XHTML, "&");
- AMP_MAP.put(MimeType.PLAIN, "&");
- }
-
- /** . */
- private MimeType mimeType;
-
- /** . */
- private Appendable appendable;
-
- /** . */
- private boolean questionMarkDone;
-
- /** . */
- private String amp;
-
- /**
- * Create a new URI writer.
- *
- * @param appendable the appendable
- * @param mimeType the mime type
- * @throws NullPointerException if the appendable argument is null
- */
- public URIWriter(Appendable appendable, MimeType mimeType) throws NullPointerException
- {
- if (appendable == null)
- {
- throw new NullPointerException("No null appendable accepted");
- }
-
- //
- this.appendable = appendable;
- this.mimeType = mimeType;
- }
-
- /**
- * Create a new URI writer.
- *
- * @param appendable the appendable
- * @throws NullPointerException if the appendable argument is null
- */
- public URIWriter(Appendable appendable) throws NullPointerException
- {
- this(appendable, null);
- }
-
- public MimeType getMimeType()
- {
- return mimeType;
- }
-
- public void setMimeType(MimeType mimeType)
- {
- this.mimeType = mimeType;
- }
-
- public void append(char c) throws IOException
- {
- appendable.append(c);
- }
-
- public void append(String s) throws IOException
- {
- appendable.append(s);
- }
-
- /**
- * Append a segment to the path.
- *
- * @param c the char to append
- * @throws IllegalStateException if a query parameter was already appended
- * @throws IOException any IO exception
- */
- public void appendSegment(char c) throws IllegalStateException, IOException
- {
- if (questionMarkDone)
- {
- throw new IllegalStateException("Query separator already written");
- }
- PercentEncoding.PATH_SEGMENT.encode(c, appendable);
- }
-
- /**
- * Append a segment to the path.
- *
- * @param s the string to append.
- * @throws NullPointerException if any argument value is null
- * @throws IllegalStateException if a query parameter was already appended
- * @throws IOException any IO exception
- */
- public void appendSegment(String s) throws NullPointerException, IllegalStateException, IOException
- {
- if (s == null)
- {
- throw new NullPointerException("No null path accepted");
- }
- for (int len = s.length(), i = 0;i < len;i++)
- {
- char c = s.charAt(i);
- appendSegment(c);
- }
- }
-
- /**
- * Append a query parameter to the parameter set. Note that the query parameters are ordered
- * and the sequence of call to this method should be honoured when an URL is generated. Note also that
- * the same parameter name can be used multiple times.
- *
- * @param parameterName the parameter name
- * @param paramaterValue the parameter value
- * @throws NullPointerException if any argument value is null
- * @throws IOException any IOException
- */
- public void appendQueryParameter(String parameterName, String paramaterValue) throws NullPointerException, IOException
- {
- if (parameterName == null)
- {
- throw new NullPointerException("No null parameter name accepted");
- }
- if (paramaterValue == null)
- {
- throw new NullPointerException("No null parameter value accepted");
- }
-
- //
- if (amp == null)
- {
- MimeType mt = mimeType;
- if (mt == null)
- {
- mt = MimeType.XHTML;
- }
- amp = AMP_MAP.get(mt);
- }
-
- //
- appendable.append(questionMarkDone ? amp : "?");
- PercentEncoding.QUERY_PARAM.encode(parameterName, appendable);
- appendable.append('=');
- PercentEncoding.QUERY_PARAM.encode(paramaterValue, appendable);
- questionMarkDone = true;
- }
-
- /**
- * Reset the writer for reuse.
- *
- * @param appendable the used appendable
- */
- public void reset(Appendable appendable)
- {
- this.appendable = appendable;
- this.questionMarkDone = false;
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/URIWriter.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/URIWriter.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/URIWriter.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/URIWriter.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,194 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.web.url.MimeType;
+
+import java.io.IOException;
+import java.util.EnumMap;
+import java.util.Map;
+
+/**
+ * An uri writer.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public final class URIWriter
+{
+
+ /** . */
+ private static final Map<MimeType, String> AMP_MAP = new EnumMap<MimeType, String>(MimeType.class);
+
+ static
+ {
+ AMP_MAP.put(MimeType.XHTML, "&");
+ AMP_MAP.put(MimeType.PLAIN, "&");
+ }
+
+ /** . */
+ private MimeType mimeType;
+
+ /** . */
+ private Appendable appendable;
+
+ /** . */
+ private boolean questionMarkDone;
+
+ /** . */
+ private String amp;
+
+ /**
+ * Create a new URI writer.
+ *
+ * @param appendable the appendable
+ * @param mimeType the mime type
+ * @throws NullPointerException if the appendable argument is null
+ */
+ public URIWriter(Appendable appendable, MimeType mimeType) throws NullPointerException
+ {
+ if (appendable == null)
+ {
+ throw new NullPointerException("No null appendable accepted");
+ }
+
+ //
+ this.appendable = appendable;
+ this.mimeType = mimeType;
+ }
+
+ /**
+ * Create a new URI writer.
+ *
+ * @param appendable the appendable
+ * @throws NullPointerException if the appendable argument is null
+ */
+ public URIWriter(Appendable appendable) throws NullPointerException
+ {
+ this(appendable, null);
+ }
+
+ public MimeType getMimeType()
+ {
+ return mimeType;
+ }
+
+ public void setMimeType(MimeType mimeType)
+ {
+ this.mimeType = mimeType;
+ }
+
+ public void append(char c) throws IOException
+ {
+ appendable.append(c);
+ }
+
+ public void append(String s) throws IOException
+ {
+ appendable.append(s);
+ }
+
+ /**
+ * Append a segment to the path.
+ *
+ * @param c the char to append
+ * @throws IllegalStateException if a query parameter was already appended
+ * @throws IOException any IO exception
+ */
+ public void appendSegment(char c) throws IllegalStateException, IOException
+ {
+ if (questionMarkDone)
+ {
+ throw new IllegalStateException("Query separator already written");
+ }
+ PercentEncoding.PATH_SEGMENT.encode(c, appendable);
+ }
+
+ /**
+ * Append a segment to the path.
+ *
+ * @param s the string to append.
+ * @throws NullPointerException if any argument value is null
+ * @throws IllegalStateException if a query parameter was already appended
+ * @throws IOException any IO exception
+ */
+ public void appendSegment(String s) throws NullPointerException, IllegalStateException, IOException
+ {
+ if (s == null)
+ {
+ throw new NullPointerException("No null path accepted");
+ }
+ for (int len = s.length(), i = 0;i < len;i++)
+ {
+ char c = s.charAt(i);
+ appendSegment(c);
+ }
+ }
+
+ /**
+ * Append a query parameter to the parameter set. Note that the query parameters are ordered
+ * and the sequence of call to this method should be honoured when an URL is generated. Note also that
+ * the same parameter name can be used multiple times.
+ *
+ * @param parameterName the parameter name
+ * @param paramaterValue the parameter value
+ * @throws NullPointerException if any argument value is null
+ * @throws IOException any IOException
+ */
+ public void appendQueryParameter(String parameterName, String paramaterValue) throws NullPointerException, IOException
+ {
+ if (parameterName == null)
+ {
+ throw new NullPointerException("No null parameter name accepted");
+ }
+ if (paramaterValue == null)
+ {
+ throw new NullPointerException("No null parameter value accepted");
+ }
+
+ //
+ if (amp == null)
+ {
+ MimeType mt = mimeType;
+ if (mt == null)
+ {
+ mt = MimeType.XHTML;
+ }
+ amp = AMP_MAP.get(mt);
+ }
+
+ //
+ appendable.append(questionMarkDone ? amp : "?");
+ PercentEncoding.QUERY_PARAM.encode(parameterName, appendable);
+ appendable.append('=');
+ PercentEncoding.QUERY_PARAM.encode(paramaterValue, appendable);
+ questionMarkDone = true;
+ }
+
+ /**
+ * Reset the writer for reuse.
+ *
+ * @param appendable the used appendable
+ */
+ public void reset(Appendable appendable)
+ {
+ this.appendable = appendable;
+ this.questionMarkDone = false;
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ValueMapping.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ValueMapping.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ValueMapping.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- */
-public enum ValueMapping
-{
-
- /**
- * <ul>
- * <li>Any value is canonically mapped.</li>
- * </ul>
- */
- CANONICAL,
-
- /**
- * <ul>
- * <li>An empty value is considered as a null value.</li>
- * <li>Other values are mapped canonically.</li>
- * </ul>
- */
- NEVER_EMPTY,
-
- /**
- * <ul>
- * <li>A null value is considered as an empty value.</li>
- * <li>Other values are mapped canonically.</li>
- * </ul>
- */
- NEVER_NULL
-
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ValueMapping.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ValueMapping.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ValueMapping.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ValueMapping.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public enum ValueMapping
+{
+
+ /**
+ * <ul>
+ * <li>Any value is canonically mapped.</li>
+ * </ul>
+ */
+ CANONICAL,
+
+ /**
+ * <ul>
+ * <li>An empty value is considered as a null value.</li>
+ * <li>Other values are mapped canonically.</li>
+ * </ul>
+ */
+ NEVER_EMPTY,
+
+ /**
+ * <ul>
+ * <li>A null value is considered as an empty value.</li>
+ * <li>Other values are mapped canonically.</li>
+ * </ul>
+ */
+ NEVER_NULL
+
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ValueType.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ValueType.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ValueType.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- */
-public enum ValueType
-{
-
- PATTERN, LITERAL
-
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ValueType.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ValueType.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ValueType.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/controller/router/ValueType.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public enum ValueType
+{
+
+ PATTERN, LITERAL
+
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/MimeType.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/MimeType.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/MimeType.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.url;
-
-/**
- * A simple mime type enumeration that is used when a URL is generated.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public enum MimeType
-{
-
- XHTML, PLAIN
-
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/MimeType.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/MimeType.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/MimeType.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/MimeType.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.url;
+
+/**
+ * A simple mime type enumeration that is used when a URL is generated.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public enum MimeType
+{
+
+ XHTML, PLAIN
+
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/PortalURL.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/PortalURL.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/PortalURL.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,367 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.url;
-
-import org.exoplatform.web.controller.QualifiedName;
-import org.gatein.common.util.ParameterMap;
-
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * An URL for a resource managed by the portal.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public abstract class PortalURL<R, U extends PortalURL<R, U>>
-{
-
- /** . */
- private static final ParameterMap.AccessMode ACCES_MODE = ParameterMap.AccessMode.get(false, false);
-
- /** . */
- private boolean schemeUse;
-
- /** . */
- private boolean authorityUse;
-
- /** . */
- protected Boolean ajax;
-
- /** . */
- protected String confirm;
-
- /** . */
- protected ParameterMap queryParams;
-
- /** . */
- protected MimeType mimeType;
-
- /** . */
- private Locale locale;
-
- /** . */
- private final URLContext context;
-
- /**
- * Create a portal URL instance.
- *
- * @param context the url context
- * @throws NullPointerException if the context is null
- */
- public PortalURL(URLContext context) throws NullPointerException
- {
- if (context == null)
- {
- throw new NullPointerException("No context");
- }
-
- //
- this.authorityUse = false;
- this.schemeUse = false;
- this.context = context;
- this.ajax = null;
- this.locale = null;
- this.confirm = null;
- this.queryParams = null;
- this.mimeType = null;
- }
-
- /**
- * Returns the current scheme use.
- *
- * @return the scheme use
- */
- public boolean getSchemeUse()
- {
- return schemeUse;
- }
-
- /**
- * Control the scheme generation (<code>http</code> or <code>https</code> according to the request) of the URL.
- * If the scheme is enabled, the authority property will be set to true.
- *
- * @param schemeUse the scheme use value
- */
- public void setSchemeUse(boolean schemeUse)
- {
- if (schemeUse)
- {
- this.authorityUse = true;
- }
- this.schemeUse = schemeUse;
- }
-
- /**
- * Returns the current authority use.
- *
- * @return the authority use
- */
- public boolean getAuthorityUse()
- {
- return authorityUse;
- }
-
- /**
- * Control the authority generation (the server name appended with the port when its value is different than 80) of the
- * URL. If the authority is disabled, the scheme property will be set to false.
- *
- * @param authorityUse the authority use value
- */
- public void setAuthorityUse(boolean authorityUse)
- {
- if (!authorityUse)
- {
- schemeUse = false;
- }
- this.authorityUse = authorityUse;
- }
-
- /**
- * Returns the ajax mode.
- *
- * @return the ajax mode
- */
- public final Boolean getAjax()
- {
- return ajax;
- }
-
- /**
- * Update the ajax mode.
- *
- * @param ajax the new ajax mode
- * @return this object
- */
- public final U setAjax(Boolean ajax)
- {
- this.ajax = ajax;
- return (U)this;
- }
-
- /**
- * Returns the confirm message.
- *
- * @return the confirm message
- */
- public final String getConfirm()
- {
- return confirm;
- }
-
- /**
- * Updates the confirm message.
- *
- * @param confirm the new confirm message
- * @return this object
- */
- public final U setConfirm(String confirm)
- {
- this.confirm = confirm;
- return (U)this;
- }
-
- /**
- * Returns the current resource associated with this URL.
- *
- * @return the resource
- */
- public abstract R getResource();
-
- /**
- * Set a new resource on this URL.
- *
- * @param resource the new resource
- * @return this object
- */
- public abstract U setResource(R resource);
-
- /**
- * Returns the set of parameter names provided this url.
- *
- * @return the parameter names
- */
- public abstract Set<QualifiedName> getParameterNames();
-
- /**
- * Returns a specified parameter value or null when it is not available.
- *
- * @param parameterName the parameter name
- * @return the parameter value
- */
- public abstract String getParameterValue(QualifiedName parameterName);
-
- /**
- * Returns the current mime type that this URL will be generated for, or null if none is set (which means
- * there is no guarantees about the mime type that will be used as target but it's likely to be {@link MimeType#XHTML}}).
- *
- * @return the current mime type
- */
- public final MimeType getMimeType()
- {
- return mimeType;
- }
-
- /**
- * Set the mime type on this URL. The mime type will be used when URL is generated to encode the URL for the specified
- * mime type.
- *
- * @param mimeType the new mime type
- */
- public void setMimeType(MimeType mimeType)
- {
- this.mimeType = mimeType;
- }
-
- public Locale getLocale()
- {
- return locale;
- }
-
- public void setLocale(Locale locale)
- {
- this.locale = locale;
- }
-
- /**
- * Returns the query parameters. Null can be returned.
- *
- * @return the query parameters
- */
- public Map<String, String[]> getQueryParameters()
- {
- return queryParams;
- }
-
- /**
- * Returns a query parameter value or null if it does not exist.
- *
- * @param parameterName the parameter name
- * @return the parameter value
- * @throws NullPointerException if the parameter name is null
- */
- public String getQueryParameterValue(String parameterName) throws NullPointerException
- {
- if (parameterName == null)
- {
- throw new NullPointerException("No null parameter name");
- }
- else if (queryParams == null)
- {
- return null;
- }
- else
- {
- String[] parameterValues = queryParams.get(parameterName);
- return parameterValues != null ? parameterValues[0] : null;
- }
- }
-
- /**
- * Update the parameter value when the parameterValue argument is not null or remove it when the parameterValue
- * argument is null.
- *
- * @param parameterName the parameter name
- * @param parameterValue the parameter value
- * @throws NullPointerException if the parameter value is null
- */
- public final void setQueryParameterValue(String parameterName, String parameterValue) throws NullPointerException
- {
- if (parameterName == null)
- {
- throw new NullPointerException("No null parameter name");
- }
- if (parameterValue == null)
- {
- if (queryParams != null)
- {
- queryParams.remove(parameterName);
- }
- }
- else
- {
- if (queryParams == null)
- {
- queryParams = new ParameterMap(ACCES_MODE);
- }
- queryParams.setValue(parameterName, parameterValue);
- }
- }
-
- /**
- * Returns a query parameter value or null if it does not exist.
- *
- * @param parameterName the parameter name
- * @return the parameter value
- * @throws NullPointerException if the parameter name is null
- */
- public final String[] getQueryParameterValues(String parameterName) throws NullPointerException
- {
- if (parameterName == null)
- {
- throw new NullPointerException("No null parameter name");
- }
- return queryParams != null ? queryParams.getValues(parameterName) : null;
- }
-
- /**
- * Update the parameter value when the parameterValues argument is not null or remove it when the parameterValues
- * argument is null.
- *
- * @param parameterName the parameter name
- * @param parameterValues the parameter value
- * @throws NullPointerException if the parameter value is null
- */
- public final void setQueryParameterValues(String parameterName, String[] parameterValues) throws NullPointerException
- {
- if (parameterName == null)
- {
- throw new NullPointerException("No null parameter name");
- }
- if (parameterValues == null)
- {
- if (queryParams != null)
- {
- queryParams.remove(parameterName);
- }
- }
- else
- {
- if (queryParams == null)
- {
- queryParams = new ParameterMap(ACCES_MODE);
- }
- queryParams.setValues(parameterName, parameterValues);
- }
- }
-
- /**
- * Generates the URL value.
- *
- * @return the URL value
- */
- public final String toString()
- {
- PortalURL _this = this;
- return context.render(_this);
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/PortalURL.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/PortalURL.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/PortalURL.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/PortalURL.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,367 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.url;
+
+import org.exoplatform.web.controller.QualifiedName;
+import org.gatein.common.util.ParameterMap;
+
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * An URL for a resource managed by the portal.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class PortalURL<R, U extends PortalURL<R, U>>
+{
+
+ /** . */
+ private static final ParameterMap.AccessMode ACCES_MODE = ParameterMap.AccessMode.get(false, false);
+
+ /** . */
+ private boolean schemeUse;
+
+ /** . */
+ private boolean authorityUse;
+
+ /** . */
+ protected Boolean ajax;
+
+ /** . */
+ protected String confirm;
+
+ /** . */
+ protected ParameterMap queryParams;
+
+ /** . */
+ protected MimeType mimeType;
+
+ /** . */
+ private Locale locale;
+
+ /** . */
+ private final URLContext context;
+
+ /**
+ * Create a portal URL instance.
+ *
+ * @param context the url context
+ * @throws NullPointerException if the context is null
+ */
+ public PortalURL(URLContext context) throws NullPointerException
+ {
+ if (context == null)
+ {
+ throw new NullPointerException("No context");
+ }
+
+ //
+ this.authorityUse = false;
+ this.schemeUse = false;
+ this.context = context;
+ this.ajax = null;
+ this.locale = null;
+ this.confirm = null;
+ this.queryParams = null;
+ this.mimeType = null;
+ }
+
+ /**
+ * Returns the current scheme use.
+ *
+ * @return the scheme use
+ */
+ public boolean getSchemeUse()
+ {
+ return schemeUse;
+ }
+
+ /**
+ * Control the scheme generation (<code>http</code> or <code>https</code> according to the request) of the URL.
+ * If the scheme is enabled, the authority property will be set to true.
+ *
+ * @param schemeUse the scheme use value
+ */
+ public void setSchemeUse(boolean schemeUse)
+ {
+ if (schemeUse)
+ {
+ this.authorityUse = true;
+ }
+ this.schemeUse = schemeUse;
+ }
+
+ /**
+ * Returns the current authority use.
+ *
+ * @return the authority use
+ */
+ public boolean getAuthorityUse()
+ {
+ return authorityUse;
+ }
+
+ /**
+ * Control the authority generation (the server name appended with the port when its value is different than 80) of the
+ * URL. If the authority is disabled, the scheme property will be set to false.
+ *
+ * @param authorityUse the authority use value
+ */
+ public void setAuthorityUse(boolean authorityUse)
+ {
+ if (!authorityUse)
+ {
+ schemeUse = false;
+ }
+ this.authorityUse = authorityUse;
+ }
+
+ /**
+ * Returns the ajax mode.
+ *
+ * @return the ajax mode
+ */
+ public final Boolean getAjax()
+ {
+ return ajax;
+ }
+
+ /**
+ * Update the ajax mode.
+ *
+ * @param ajax the new ajax mode
+ * @return this object
+ */
+ public final U setAjax(Boolean ajax)
+ {
+ this.ajax = ajax;
+ return (U)this;
+ }
+
+ /**
+ * Returns the confirm message.
+ *
+ * @return the confirm message
+ */
+ public final String getConfirm()
+ {
+ return confirm;
+ }
+
+ /**
+ * Updates the confirm message.
+ *
+ * @param confirm the new confirm message
+ * @return this object
+ */
+ public final U setConfirm(String confirm)
+ {
+ this.confirm = confirm;
+ return (U)this;
+ }
+
+ /**
+ * Returns the current resource associated with this URL.
+ *
+ * @return the resource
+ */
+ public abstract R getResource();
+
+ /**
+ * Set a new resource on this URL.
+ *
+ * @param resource the new resource
+ * @return this object
+ */
+ public abstract U setResource(R resource);
+
+ /**
+ * Returns the set of parameter names provided this url.
+ *
+ * @return the parameter names
+ */
+ public abstract Set<QualifiedName> getParameterNames();
+
+ /**
+ * Returns a specified parameter value or null when it is not available.
+ *
+ * @param parameterName the parameter name
+ * @return the parameter value
+ */
+ public abstract String getParameterValue(QualifiedName parameterName);
+
+ /**
+ * Returns the current mime type that this URL will be generated for, or null if none is set (which means
+ * there is no guarantees about the mime type that will be used as target but it's likely to be {@link MimeType#XHTML}}).
+ *
+ * @return the current mime type
+ */
+ public final MimeType getMimeType()
+ {
+ return mimeType;
+ }
+
+ /**
+ * Set the mime type on this URL. The mime type will be used when URL is generated to encode the URL for the specified
+ * mime type.
+ *
+ * @param mimeType the new mime type
+ */
+ public void setMimeType(MimeType mimeType)
+ {
+ this.mimeType = mimeType;
+ }
+
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+ public void setLocale(Locale locale)
+ {
+ this.locale = locale;
+ }
+
+ /**
+ * Returns the query parameters. Null can be returned.
+ *
+ * @return the query parameters
+ */
+ public Map<String, String[]> getQueryParameters()
+ {
+ return queryParams;
+ }
+
+ /**
+ * Returns a query parameter value or null if it does not exist.
+ *
+ * @param parameterName the parameter name
+ * @return the parameter value
+ * @throws NullPointerException if the parameter name is null
+ */
+ public String getQueryParameterValue(String parameterName) throws NullPointerException
+ {
+ if (parameterName == null)
+ {
+ throw new NullPointerException("No null parameter name");
+ }
+ else if (queryParams == null)
+ {
+ return null;
+ }
+ else
+ {
+ String[] parameterValues = queryParams.get(parameterName);
+ return parameterValues != null ? parameterValues[0] : null;
+ }
+ }
+
+ /**
+ * Update the parameter value when the parameterValue argument is not null or remove it when the parameterValue
+ * argument is null.
+ *
+ * @param parameterName the parameter name
+ * @param parameterValue the parameter value
+ * @throws NullPointerException if the parameter value is null
+ */
+ public final void setQueryParameterValue(String parameterName, String parameterValue) throws NullPointerException
+ {
+ if (parameterName == null)
+ {
+ throw new NullPointerException("No null parameter name");
+ }
+ if (parameterValue == null)
+ {
+ if (queryParams != null)
+ {
+ queryParams.remove(parameterName);
+ }
+ }
+ else
+ {
+ if (queryParams == null)
+ {
+ queryParams = new ParameterMap(ACCES_MODE);
+ }
+ queryParams.setValue(parameterName, parameterValue);
+ }
+ }
+
+ /**
+ * Returns a query parameter value or null if it does not exist.
+ *
+ * @param parameterName the parameter name
+ * @return the parameter value
+ * @throws NullPointerException if the parameter name is null
+ */
+ public final String[] getQueryParameterValues(String parameterName) throws NullPointerException
+ {
+ if (parameterName == null)
+ {
+ throw new NullPointerException("No null parameter name");
+ }
+ return queryParams != null ? queryParams.getValues(parameterName) : null;
+ }
+
+ /**
+ * Update the parameter value when the parameterValues argument is not null or remove it when the parameterValues
+ * argument is null.
+ *
+ * @param parameterName the parameter name
+ * @param parameterValues the parameter value
+ * @throws NullPointerException if the parameter value is null
+ */
+ public final void setQueryParameterValues(String parameterName, String[] parameterValues) throws NullPointerException
+ {
+ if (parameterName == null)
+ {
+ throw new NullPointerException("No null parameter name");
+ }
+ if (parameterValues == null)
+ {
+ if (queryParams != null)
+ {
+ queryParams.remove(parameterName);
+ }
+ }
+ else
+ {
+ if (queryParams == null)
+ {
+ queryParams = new ParameterMap(ACCES_MODE);
+ }
+ queryParams.setValues(parameterName, parameterValues);
+ }
+ }
+
+ /**
+ * Generates the URL value.
+ *
+ * @return the URL value
+ */
+ public final String toString()
+ {
+ PortalURL _this = this;
+ return context.render(_this);
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceType.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceType.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceType.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.url;
-
-/**
- * The type of a resource.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- * @param <R> the resource parameter type
- * @param <U> the url parameter type
- */
-public abstract class ResourceType<R, U extends PortalURL<R, U>>
-{
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceType.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceType.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceType.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceType.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.url;
+
+/**
+ * The type of a resource.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ * @param <R> the resource parameter type
+ * @param <U> the url parameter type
+ */
+public abstract class ResourceType<R, U extends PortalURL<R, U>>
+{
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLContext.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/URLContext.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLContext.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.url;
-
-/**
- * A renderer for url.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- */
-public interface URLContext
-{
-
- /**
- * Renders the url.
- *
- * @param url the url to render
- * @param <R> the url resource type
- * @param <U> the url generic type
- * @return the rendered url
- */
- <R, U extends PortalURL<R, U>> String render(U url);
-
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLContext.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/URLContext.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLContext.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLContext.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.url;
+
+/**
+ * A renderer for url.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public interface URLContext
+{
+
+ /**
+ * Renders the url.
+ *
+ * @param url the url to render
+ * @param <R> the url resource type
+ * @param <U> the url generic type
+ * @return the rendered url
+ */
+ <R, U extends PortalURL<R, U>> String render(U url);
+
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactory.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactory.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactory.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.url;
-
-/**
- * A factory for urls.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public abstract class URLFactory
-{
-
- /**
- * Creates a new url or return null if the resource type cannot be resolved to an url.
- *
- * @param resourceType the resource type
- * @param context the context
- * @return the url
- * @throws NullPointerException if the resource type or the context is null
- */
- public abstract <R, U extends PortalURL<R, U>> U newURL(ResourceType<R, U> resourceType, URLContext context) throws NullPointerException;
-
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactory.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactory.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactory.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactory.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.url;
+
+/**
+ * A factory for urls.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class URLFactory
+{
+
+ /**
+ * Creates a new url or return null if the resource type cannot be resolved to an url.
+ *
+ * @param resourceType the resource type
+ * @param context the context
+ * @return the url
+ * @throws NullPointerException if the resource type or the context is null
+ */
+ public abstract <R, U extends PortalURL<R, U>> U newURL(ResourceType<R, U> resourceType, URLContext context) throws NullPointerException;
+
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactoryPlugin.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactoryPlugin.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactoryPlugin.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.url;
-
-import org.exoplatform.container.component.BaseComponentPlugin;
-
-import java.util.Locale;
-
-/**
- * A plugin for adding an url factory to the {@link URLFactoryService}.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public abstract class URLFactoryPlugin<R, U extends PortalURL<R, U>> extends BaseComponentPlugin
-{
-
- /**
- * Returns the resource type.
- *
- * @return the resource type
- */
- protected abstract ResourceType<R, U> getResourceType();
-
- /**
- * Returns a new url instance.
- *
- * @param context the context
- * @return a new url instance
- */
- protected abstract U newURL(URLContext context);
-
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactoryPlugin.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactoryPlugin.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactoryPlugin.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactoryPlugin.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.url;
+
+import org.exoplatform.container.component.BaseComponentPlugin;
+
+import java.util.Locale;
+
+/**
+ * A plugin for adding an url factory to the {@link URLFactoryService}.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class URLFactoryPlugin<R, U extends PortalURL<R, U>> extends BaseComponentPlugin
+{
+
+ /**
+ * Returns the resource type.
+ *
+ * @return the resource type
+ */
+ protected abstract ResourceType<R, U> getResourceType();
+
+ /**
+ * Returns a new url instance.
+ *
+ * @param context the context
+ * @return a new url instance
+ */
+ protected abstract U newURL(URLContext context);
+
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactoryService.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactoryService.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactoryService.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.url;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class URLFactoryService extends URLFactory
-{
-
- /** . */
- private final Map<ResourceType<?,?>, URLFactoryPlugin> plugins;
-
- public URLFactoryService()
- {
- this.plugins = new HashMap<ResourceType<?,?>, URLFactoryPlugin>();
- }
-
- @Override
- public <R, U extends PortalURL<R, U>> U newURL(
- ResourceType<R, U> resourceType,
- URLContext context) throws NullPointerException
- {
- if (resourceType == null)
- {
- throw new NullPointerException("No null resource type accepted");
- }
-
- // Can't really make that checked
- @SuppressWarnings("unchecked")
- URLFactoryPlugin<R, U> plugin = (URLFactoryPlugin<R,U>)plugins.get(resourceType);
-
- //
- return plugin != null ? plugin.newURL(context) : null;
- }
-
- public void addPlugin(URLFactoryPlugin plugin)
- {
- plugins.put(plugin.getResourceType(), plugin);
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactoryService.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactoryService.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactoryService.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/URLFactoryService.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.url;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class URLFactoryService extends URLFactory
+{
+
+ /** . */
+ private final Map<ResourceType<?,?>, URLFactoryPlugin> plugins;
+
+ public URLFactoryService()
+ {
+ this.plugins = new HashMap<ResourceType<?,?>, URLFactoryPlugin>();
+ }
+
+ @Override
+ public <R, U extends PortalURL<R, U>> U newURL(
+ ResourceType<R, U> resourceType,
+ URLContext context) throws NullPointerException
+ {
+ if (resourceType == null)
+ {
+ throw new NullPointerException("No null resource type accepted");
+ }
+
+ // Can't really make that checked
+ @SuppressWarnings("unchecked")
+ URLFactoryPlugin<R, U> plugin = (URLFactoryPlugin<R,U>)plugins.get(resourceType);
+
+ //
+ return plugin != null ? plugin.newURL(context) : null;
+ }
+
+ public void addPlugin(URLFactoryPlugin plugin)
+ {
+ plugins.put(plugin.getResourceType(), plugin);
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NavigationResource.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NavigationResource.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NavigationResource.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,80 +0,0 @@
-/**
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.web.url.navigation;
-
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.mop.SiteType;
-import org.exoplatform.portal.mop.user.UserNode;
-
-/**
- * A class that contains combination of a portal name and a page node
- * to determine the target URL
- *
- * @author <a href="trongtt(a)gmail.com">Trong Tran</a>
- * @version $Revision$
- */
-public class NavigationResource
-{
-
- /** . */
- private final SiteType siteType;
-
- /** . */
- private final String siteName;
-
- /** . */
- private final String nodeURI;
-
- public NavigationResource(String siteName)
- {
- this(null, siteName, null);
- }
-
- public NavigationResource(UserNode node)
- {
- this(node.getNavigation().getKey().getType(), node.getNavigation().getKey().getName(), node.getURI());
- }
-
- public NavigationResource(SiteKey siteKey, String nodeURI)
- {
- this(siteKey.getType(), siteKey.getName(), nodeURI);
- }
-
- public NavigationResource(SiteType siteType, String portalName, String nodeURI)
- {
- this.siteType = siteType;
- this.siteName = portalName;
- this.nodeURI = nodeURI;
- }
-
- public SiteType getSiteType()
- {
- return siteType;
- }
-
- public String getSiteName()
- {
- return siteName;
- }
-
- public String getNodeURI()
- {
- return nodeURI;
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NavigationResource.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NavigationResource.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NavigationResource.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NavigationResource.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,80 @@
+/**
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.web.url.navigation;
+
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.SiteType;
+import org.exoplatform.portal.mop.user.UserNode;
+
+/**
+ * A class that contains combination of a portal name and a page node
+ * to determine the target URL
+ *
+ * @author <a href="trongtt(a)gmail.com">Trong Tran</a>
+ * @version $Revision$
+ */
+public class NavigationResource
+{
+
+ /** . */
+ private final SiteType siteType;
+
+ /** . */
+ private final String siteName;
+
+ /** . */
+ private final String nodeURI;
+
+ public NavigationResource(String siteName)
+ {
+ this(null, siteName, null);
+ }
+
+ public NavigationResource(UserNode node)
+ {
+ this(node.getNavigation().getKey().getType(), node.getNavigation().getKey().getName(), node.getURI());
+ }
+
+ public NavigationResource(SiteKey siteKey, String nodeURI)
+ {
+ this(siteKey.getType(), siteKey.getName(), nodeURI);
+ }
+
+ public NavigationResource(SiteType siteType, String portalName, String nodeURI)
+ {
+ this.siteType = siteType;
+ this.siteName = portalName;
+ this.nodeURI = nodeURI;
+ }
+
+ public SiteType getSiteType()
+ {
+ return siteType;
+ }
+
+ public String getSiteName()
+ {
+ return siteName;
+ }
+
+ public String getNodeURI()
+ {
+ return nodeURI;
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURL.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURL.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURL.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.url.navigation;
-
-import org.exoplatform.portal.mop.user.UserNode;
-import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.url.PortalURL;
-import org.exoplatform.web.url.ResourceType;
-import org.exoplatform.web.url.URLContext;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * An url for navigation.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class NodeURL extends PortalURL<NavigationResource, NodeURL>
-{
-
- /** . */
- public static final QualifiedName PATH = QualifiedName.create("gtn", "path");
-
- /** . */
- public static final QualifiedName REQUEST_SITE_TYPE = QualifiedName.create("gtn", "sitetype");
-
- /** . */
- public static final QualifiedName REQUEST_SITE_NAME = QualifiedName.create("gtn", "sitename");
-
- /** . */
- public static final ResourceType<NavigationResource, NodeURL> TYPE = new ResourceType<NavigationResource, NodeURL>(){};
-
- /** . */
- private static final Set<QualifiedName> PARAMETER_NAMES = new HashSet<QualifiedName>();
-
- static
- {
- PARAMETER_NAMES.add(PATH);
- PARAMETER_NAMES.add(REQUEST_SITE_TYPE);
- PARAMETER_NAMES.add(REQUEST_SITE_NAME);
- }
-
- /** . */
- private NavigationResource resource;
-
- public NodeURL(URLContext context) throws NullPointerException
- {
- super(context);
- }
-
- public Set<QualifiedName> getParameterNames()
- {
- return PARAMETER_NAMES;
- }
-
- public String getParameterValue(QualifiedName parameterName)
- {
- if (PATH.equals(parameterName))
- {
- if (resource.getNodeURI() == null)
- {
- return "";
- }
- else
- {
- return resource.getNodeURI();
- }
- }
- else if (REQUEST_SITE_TYPE.equals(parameterName))
- {
- return resource.getSiteType().getName();
- }
- else if (REQUEST_SITE_NAME.equals(parameterName))
- {
- return resource.getSiteName();
- }
- return null;
- }
-
- public NavigationResource getResource()
- {
- return resource;
- }
-
- public NodeURL setResource(NavigationResource resource)
- {
- this.resource = resource;
- return this;
- }
-
- public NodeURL setNode(UserNode node)
- {
- this.resource = new NavigationResource(node);
- return this;
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURL.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURL.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURL.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURL.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.url.navigation;
+
+import org.exoplatform.portal.mop.user.UserNode;
+import org.exoplatform.web.controller.QualifiedName;
+import org.exoplatform.web.url.PortalURL;
+import org.exoplatform.web.url.ResourceType;
+import org.exoplatform.web.url.URLContext;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * An url for navigation.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class NodeURL extends PortalURL<NavigationResource, NodeURL>
+{
+
+ /** . */
+ public static final QualifiedName PATH = QualifiedName.create("gtn", "path");
+
+ /** . */
+ public static final QualifiedName REQUEST_SITE_TYPE = QualifiedName.create("gtn", "sitetype");
+
+ /** . */
+ public static final QualifiedName REQUEST_SITE_NAME = QualifiedName.create("gtn", "sitename");
+
+ /** . */
+ public static final ResourceType<NavigationResource, NodeURL> TYPE = new ResourceType<NavigationResource, NodeURL>(){};
+
+ /** . */
+ private static final Set<QualifiedName> PARAMETER_NAMES = new HashSet<QualifiedName>();
+
+ static
+ {
+ PARAMETER_NAMES.add(PATH);
+ PARAMETER_NAMES.add(REQUEST_SITE_TYPE);
+ PARAMETER_NAMES.add(REQUEST_SITE_NAME);
+ }
+
+ /** . */
+ private NavigationResource resource;
+
+ public NodeURL(URLContext context) throws NullPointerException
+ {
+ super(context);
+ }
+
+ public Set<QualifiedName> getParameterNames()
+ {
+ return PARAMETER_NAMES;
+ }
+
+ public String getParameterValue(QualifiedName parameterName)
+ {
+ if (PATH.equals(parameterName))
+ {
+ if (resource.getNodeURI() == null)
+ {
+ return "";
+ }
+ else
+ {
+ return resource.getNodeURI();
+ }
+ }
+ else if (REQUEST_SITE_TYPE.equals(parameterName))
+ {
+ return resource.getSiteType().getName();
+ }
+ else if (REQUEST_SITE_NAME.equals(parameterName))
+ {
+ return resource.getSiteName();
+ }
+ return null;
+ }
+
+ public NavigationResource getResource()
+ {
+ return resource;
+ }
+
+ public NodeURL setResource(NavigationResource resource)
+ {
+ this.resource = resource;
+ return this;
+ }
+
+ public NodeURL setNode(UserNode node)
+ {
+ this.resource = new NavigationResource(node);
+ return this;
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURLFactoryPlugin.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURLFactoryPlugin.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURLFactoryPlugin.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.url.navigation;
-
-import org.exoplatform.web.url.URLFactoryPlugin;
-import org.exoplatform.web.url.ResourceType;
-import org.exoplatform.web.url.URLContext;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class NodeURLFactoryPlugin extends URLFactoryPlugin<NavigationResource, NodeURL>
-{
-
- @Override
- protected ResourceType<NavigationResource, NodeURL> getResourceType()
- {
- return NodeURL.TYPE;
- }
-
- @Override
- protected NodeURL newURL(URLContext context)
- {
- return new NodeURL(context);
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURLFactoryPlugin.java (from rev 7117, portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURLFactoryPlugin.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURLFactoryPlugin.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/url/navigation/NodeURLFactoryPlugin.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.url.navigation;
+
+import org.exoplatform.web.url.URLFactoryPlugin;
+import org.exoplatform.web.url.ResourceType;
+import org.exoplatform.web.url.URLContext;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class NodeURLFactoryPlugin extends URLFactoryPlugin<NavigationResource, NodeURL>
+{
+
+ @Override
+ protected ResourceType<NavigationResource, NodeURL> getResourceType()
+ {
+ return NodeURL.TYPE;
+ }
+
+ @Override
+ protected NodeURL newURL(URLContext context)
+ {
+ return new NodeURL(context);
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestParser.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestParser.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestParser.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,240 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.regexp;
-
-import org.exoplatform.component.test.BaseGateInTest;
-
-import java.util.regex.Pattern;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class TestParser extends BaseGateInTest
-{
-
-
- public void testSomeStuff()
- {
- Pattern pattern = Pattern.compile("^[\\^a\b]$");
- assertTrue(pattern.matcher("^").matches());
- assertTrue(pattern.matcher("a").matches());
-
- }
-
- private static class ParserTester
- {
- private final RegExpParser parser;
- private ParserTester(CharSequence s)
- {
- this.parser = new RegExpParser(s);
- }
- ParserTester assertParseCharacterClass(String expectedValue)
- {
- try
- {
- RENode node = parser.parseExpression();
- assertTrue(node instanceof RENode.CharacterClass);
- assertEquals(expectedValue, node.toString());
- return this;
- }
- catch (SyntaxException e)
- {
- return fail(e);
- }
- }
- ParserTester assertParseDisjunction(String expectedValue)
- {
- try
- {
- RENode.Disjunction disjunction = parser.parseDisjunction();
- assertTrue(parser.isDone());
- if (expectedValue.length() == 0)
- {
- assertNull(disjunction);
- }
- else
- {
- assertNotNull(disjunction);
- assertEquals(expectedValue, disjunction.toString());
- }
- return this;
- }
- catch (SyntaxException e)
- {
- return fail(e);
- }
- }
- ParserTester assertNotParseDisjunction()
- {
- int expectedIndex = parser.getIndex();
- try
- {
- parser.parseDisjunction();
- fail();
- }
- catch (SyntaxException e)
- {
- assertEquals(expectedIndex, parser.getIndex());
- }
- return this;
- }
- ParserTester assertParseExpression(String expectedValue, int expectedIndex)
- {
- try
- {
- RENode.Expr exp = parser.parseExpression();
- assertEquals(expectedValue, exp.toString());
- assertEquals(expectedIndex, parser.getIndex());
- return this;
- }
- catch (SyntaxException e)
- {
- return fail(e);
- }
- }
- ParserTester assertNotParseExpression()
- {
- try
- {
- RENode.Expr expr = parser.parseExpression();
- assertNull(expr);
- }
- catch (SyntaxException e)
- {
- }
- return this;
- }
- ParserTester assertParseQuantifier(Quantifier expectedQuantifier)
- {
- Quantifier quantifier;
- try
- {
- quantifier = parser.parseQuantifier();
- }
- catch (SyntaxException e)
- {
- return fail(e);
- }
- if (expectedQuantifier != null)
- {
- assertEquals(expectedQuantifier, quantifier);
- }
- else
- {
- assertNull(quantifier);
- }
- return this;
- }
- }
-
- public void testExtendedRegexp()
- {
- new ParserTester("").assertParseDisjunction("");
- new ParserTester(".").assertParseDisjunction("<./>");
- new ParserTester("^").assertParseDisjunction("<^/>");
- new ParserTester("^$").assertParseDisjunction("<^/><$/>");
- new ParserTester("a").assertParseDisjunction("<c>a</c>");
- new ParserTester("a|b").assertParseDisjunction("<c>a</c>|<c>b</c>");
- new ParserTester("a|b|c").assertParseDisjunction("<c>a</c>|<c>b</c>|<c>c</c>");
- new ParserTester("a+|b*").assertParseDisjunction("<+><c>a</c></+>|<*><c>b</c></*>");
- new ParserTester("\\.").assertParseDisjunction("<c>.</c>");
- }
-
- public void testExpression()
- {
- new ParserTester("").assertNotParseExpression();
- new ParserTester("^").assertParseExpression("<^/>", 1);
- new ParserTester("^+").assertParseExpression("<+><^/></+>", 2);
- new ParserTester("$").assertParseExpression("<$/>", 1);
- new ParserTester("$+").assertParseExpression("<+><$/></+>", 2);
- new ParserTester("a").assertParseExpression("<c>a</c>", 1);
- new ParserTester("a+").assertParseExpression("<+><c>a</c></+>", 2);
- new ParserTester(".").assertParseExpression("<./>", 1);
- new ParserTester(".+").assertParseExpression("<+><./></+>", 2);
- new ParserTester("\\+").assertParseExpression("<c>+</c>", 2);
- new ParserTester("\\++").assertParseExpression("<+><c>+</c></+>", 3);
- new ParserTester("*").assertNotParseExpression();
- new ParserTester("+").assertNotParseExpression();
- new ParserTester("?").assertNotParseExpression();
- new ParserTester("{").assertNotParseExpression();
- new ParserTester("|").assertNotParseExpression();
- }
-
- public void testGroup()
- {
- new ParserTester("(a)").assertParseExpression("<(><c>a</c></(>", 3);
- new ParserTester("(a(b)c)").assertParseExpression("<(><c>a</c><(><c>b</c></(><c>c</c></(>", 7);
- new ParserTester("(?:a)").assertParseExpression("<(?:><c>a</c></(?:>", 5);
- new ParserTester("(?=a)").assertParseExpression("<(?=><c>a</c></(?=>", 5);
- new ParserTester("(?!a)").assertParseExpression("<(?!><c>a</c></(?!>", 5);
- new ParserTester("(?<=a)").assertParseExpression("<(?<=><c>a</c></(?<=>", 6);
- new ParserTester("(?<!a)").assertParseExpression("<(?<!><c>a</c></(?<!>", 6);
- new ParserTester("(?)").assertParseExpression("<(><c>?</c></(>", 3);
- new ParserTester("(?_)").assertNotParseExpression();
- new ParserTester("(?<_)").assertNotParseExpression();
- }
-
- // missing stuff:
- // escape in bracket
-
-
- public void testQuantifier()
- {
- new ParserTester("*").assertParseQuantifier(Quantifier.zeroOrMore(Quantifier.Mode.GREEDY));
- new ParserTester("+").assertParseQuantifier(Quantifier.oneOrMore(Quantifier.Mode.GREEDY));
- new ParserTester("?").assertParseQuantifier(Quantifier.onceOrNotAtAll(Quantifier.Mode.GREEDY));
- new ParserTester("*a").assertParseQuantifier(Quantifier.zeroOrMore(Quantifier.Mode.GREEDY));
- new ParserTester("+a").assertParseQuantifier(Quantifier.oneOrMore(Quantifier.Mode.GREEDY));
- new ParserTester("?a").assertParseQuantifier(Quantifier.onceOrNotAtAll(Quantifier.Mode.GREEDY));
- new ParserTester("*?").assertParseQuantifier(Quantifier.zeroOrMore(Quantifier.Mode.RELUCTANT));
- new ParserTester("+?").assertParseQuantifier(Quantifier.oneOrMore(Quantifier.Mode.RELUCTANT));
- new ParserTester("??").assertParseQuantifier(Quantifier.onceOrNotAtAll(Quantifier.Mode.RELUCTANT));
- new ParserTester("*+").assertParseQuantifier(Quantifier.zeroOrMore(Quantifier.Mode.POSSESSIVE));
- new ParserTester("++").assertParseQuantifier(Quantifier.oneOrMore(Quantifier.Mode.POSSESSIVE));
- new ParserTester("?+").assertParseQuantifier(Quantifier.onceOrNotAtAll(Quantifier.Mode.POSSESSIVE));
- new ParserTester("a").assertParseQuantifier(null);
- new ParserTester("").assertParseQuantifier(null);
- new ParserTester("{2}").assertParseQuantifier(Quantifier.exactly(Quantifier.Mode.GREEDY, 2));
- new ParserTester("{2,}").assertParseQuantifier(Quantifier.atLeast(Quantifier.Mode.GREEDY, 2));
- new ParserTester("{2,4}").assertParseQuantifier(Quantifier.between(Quantifier.Mode.GREEDY, 2, 4));
- }
-
- public void testParseBracketExpression()
- {
- new ParserTester("[a]").assertParseCharacterClass("[a]");
- new ParserTester("[^a]").assertParseCharacterClass("[^[a]]");
- new ParserTester("[^a-b]").assertParseCharacterClass("[^[a-b]]");
- new ParserTester("[a-b]").assertParseCharacterClass("[a-b]");
- new ParserTester("[ab]").assertParseCharacterClass("[[a]||[b]]");
- new ParserTester("[a&]").assertParseCharacterClass("[[a]||[&]]");
- new ParserTester("[a&&b]").assertParseCharacterClass("[[a]&&[b]]");
- new ParserTester("[a&&[^b]]").assertParseCharacterClass("[[a]&&[^[b]]]");
- new ParserTester("[a[^b]]").assertParseCharacterClass("[[a]||[^[b]]]");
- new ParserTester("[a[b]]").assertParseCharacterClass("[[a]||[b]]");
- new ParserTester("[a[b]c]").assertParseCharacterClass("[[a]||[[b]||[c]]]");
- new ParserTester("[[a]bc]").assertParseCharacterClass("[[a]||[[b]||[c]]]");
- new ParserTester("[-]").assertParseCharacterClass("[-]");
- new ParserTester("[a-]").assertParseCharacterClass("[[a]||[-]]");
-// new ParserTester("[---]").assertParseCharacterClass("[---]");
- new ParserTester("[#--]").assertParseCharacterClass("[#--]");
- }
-
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestParser.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestParser.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestParser.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestParser.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,240 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.regexp;
+
+import org.exoplatform.component.test.BaseGateInTest;
+
+import java.util.regex.Pattern;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestParser extends BaseGateInTest
+{
+
+
+ public void testSomeStuff()
+ {
+ Pattern pattern = Pattern.compile("^[\\^a\b]$");
+ assertTrue(pattern.matcher("^").matches());
+ assertTrue(pattern.matcher("a").matches());
+
+ }
+
+ private static class ParserTester
+ {
+ private final RegExpParser parser;
+ private ParserTester(CharSequence s)
+ {
+ this.parser = new RegExpParser(s);
+ }
+ ParserTester assertParseCharacterClass(String expectedValue)
+ {
+ try
+ {
+ RENode node = parser.parseExpression();
+ assertTrue(node instanceof RENode.CharacterClass);
+ assertEquals(expectedValue, node.toString());
+ return this;
+ }
+ catch (SyntaxException e)
+ {
+ return fail(e);
+ }
+ }
+ ParserTester assertParseDisjunction(String expectedValue)
+ {
+ try
+ {
+ RENode.Disjunction disjunction = parser.parseDisjunction();
+ assertTrue(parser.isDone());
+ if (expectedValue.length() == 0)
+ {
+ assertNull(disjunction);
+ }
+ else
+ {
+ assertNotNull(disjunction);
+ assertEquals(expectedValue, disjunction.toString());
+ }
+ return this;
+ }
+ catch (SyntaxException e)
+ {
+ return fail(e);
+ }
+ }
+ ParserTester assertNotParseDisjunction()
+ {
+ int expectedIndex = parser.getIndex();
+ try
+ {
+ parser.parseDisjunction();
+ fail();
+ }
+ catch (SyntaxException e)
+ {
+ assertEquals(expectedIndex, parser.getIndex());
+ }
+ return this;
+ }
+ ParserTester assertParseExpression(String expectedValue, int expectedIndex)
+ {
+ try
+ {
+ RENode.Expr exp = parser.parseExpression();
+ assertEquals(expectedValue, exp.toString());
+ assertEquals(expectedIndex, parser.getIndex());
+ return this;
+ }
+ catch (SyntaxException e)
+ {
+ return fail(e);
+ }
+ }
+ ParserTester assertNotParseExpression()
+ {
+ try
+ {
+ RENode.Expr expr = parser.parseExpression();
+ assertNull(expr);
+ }
+ catch (SyntaxException e)
+ {
+ }
+ return this;
+ }
+ ParserTester assertParseQuantifier(Quantifier expectedQuantifier)
+ {
+ Quantifier quantifier;
+ try
+ {
+ quantifier = parser.parseQuantifier();
+ }
+ catch (SyntaxException e)
+ {
+ return fail(e);
+ }
+ if (expectedQuantifier != null)
+ {
+ assertEquals(expectedQuantifier, quantifier);
+ }
+ else
+ {
+ assertNull(quantifier);
+ }
+ return this;
+ }
+ }
+
+ public void testExtendedRegexp()
+ {
+ new ParserTester("").assertParseDisjunction("");
+ new ParserTester(".").assertParseDisjunction("<./>");
+ new ParserTester("^").assertParseDisjunction("<^/>");
+ new ParserTester("^$").assertParseDisjunction("<^/><$/>");
+ new ParserTester("a").assertParseDisjunction("<c>a</c>");
+ new ParserTester("a|b").assertParseDisjunction("<c>a</c>|<c>b</c>");
+ new ParserTester("a|b|c").assertParseDisjunction("<c>a</c>|<c>b</c>|<c>c</c>");
+ new ParserTester("a+|b*").assertParseDisjunction("<+><c>a</c></+>|<*><c>b</c></*>");
+ new ParserTester("\\.").assertParseDisjunction("<c>.</c>");
+ }
+
+ public void testExpression()
+ {
+ new ParserTester("").assertNotParseExpression();
+ new ParserTester("^").assertParseExpression("<^/>", 1);
+ new ParserTester("^+").assertParseExpression("<+><^/></+>", 2);
+ new ParserTester("$").assertParseExpression("<$/>", 1);
+ new ParserTester("$+").assertParseExpression("<+><$/></+>", 2);
+ new ParserTester("a").assertParseExpression("<c>a</c>", 1);
+ new ParserTester("a+").assertParseExpression("<+><c>a</c></+>", 2);
+ new ParserTester(".").assertParseExpression("<./>", 1);
+ new ParserTester(".+").assertParseExpression("<+><./></+>", 2);
+ new ParserTester("\\+").assertParseExpression("<c>+</c>", 2);
+ new ParserTester("\\++").assertParseExpression("<+><c>+</c></+>", 3);
+ new ParserTester("*").assertNotParseExpression();
+ new ParserTester("+").assertNotParseExpression();
+ new ParserTester("?").assertNotParseExpression();
+ new ParserTester("{").assertNotParseExpression();
+ new ParserTester("|").assertNotParseExpression();
+ }
+
+ public void testGroup()
+ {
+ new ParserTester("(a)").assertParseExpression("<(><c>a</c></(>", 3);
+ new ParserTester("(a(b)c)").assertParseExpression("<(><c>a</c><(><c>b</c></(><c>c</c></(>", 7);
+ new ParserTester("(?:a)").assertParseExpression("<(?:><c>a</c></(?:>", 5);
+ new ParserTester("(?=a)").assertParseExpression("<(?=><c>a</c></(?=>", 5);
+ new ParserTester("(?!a)").assertParseExpression("<(?!><c>a</c></(?!>", 5);
+ new ParserTester("(?<=a)").assertParseExpression("<(?<=><c>a</c></(?<=>", 6);
+ new ParserTester("(?<!a)").assertParseExpression("<(?<!><c>a</c></(?<!>", 6);
+ new ParserTester("(?)").assertParseExpression("<(><c>?</c></(>", 3);
+ new ParserTester("(?_)").assertNotParseExpression();
+ new ParserTester("(?<_)").assertNotParseExpression();
+ }
+
+ // missing stuff:
+ // escape in bracket
+
+
+ public void testQuantifier()
+ {
+ new ParserTester("*").assertParseQuantifier(Quantifier.zeroOrMore(Quantifier.Mode.GREEDY));
+ new ParserTester("+").assertParseQuantifier(Quantifier.oneOrMore(Quantifier.Mode.GREEDY));
+ new ParserTester("?").assertParseQuantifier(Quantifier.onceOrNotAtAll(Quantifier.Mode.GREEDY));
+ new ParserTester("*a").assertParseQuantifier(Quantifier.zeroOrMore(Quantifier.Mode.GREEDY));
+ new ParserTester("+a").assertParseQuantifier(Quantifier.oneOrMore(Quantifier.Mode.GREEDY));
+ new ParserTester("?a").assertParseQuantifier(Quantifier.onceOrNotAtAll(Quantifier.Mode.GREEDY));
+ new ParserTester("*?").assertParseQuantifier(Quantifier.zeroOrMore(Quantifier.Mode.RELUCTANT));
+ new ParserTester("+?").assertParseQuantifier(Quantifier.oneOrMore(Quantifier.Mode.RELUCTANT));
+ new ParserTester("??").assertParseQuantifier(Quantifier.onceOrNotAtAll(Quantifier.Mode.RELUCTANT));
+ new ParserTester("*+").assertParseQuantifier(Quantifier.zeroOrMore(Quantifier.Mode.POSSESSIVE));
+ new ParserTester("++").assertParseQuantifier(Quantifier.oneOrMore(Quantifier.Mode.POSSESSIVE));
+ new ParserTester("?+").assertParseQuantifier(Quantifier.onceOrNotAtAll(Quantifier.Mode.POSSESSIVE));
+ new ParserTester("a").assertParseQuantifier(null);
+ new ParserTester("").assertParseQuantifier(null);
+ new ParserTester("{2}").assertParseQuantifier(Quantifier.exactly(Quantifier.Mode.GREEDY, 2));
+ new ParserTester("{2,}").assertParseQuantifier(Quantifier.atLeast(Quantifier.Mode.GREEDY, 2));
+ new ParserTester("{2,4}").assertParseQuantifier(Quantifier.between(Quantifier.Mode.GREEDY, 2, 4));
+ }
+
+ public void testParseBracketExpression()
+ {
+ new ParserTester("[a]").assertParseCharacterClass("[a]");
+ new ParserTester("[^a]").assertParseCharacterClass("[^[a]]");
+ new ParserTester("[^a-b]").assertParseCharacterClass("[^[a-b]]");
+ new ParserTester("[a-b]").assertParseCharacterClass("[a-b]");
+ new ParserTester("[ab]").assertParseCharacterClass("[[a]||[b]]");
+ new ParserTester("[a&]").assertParseCharacterClass("[[a]||[&]]");
+ new ParserTester("[a&&b]").assertParseCharacterClass("[[a]&&[b]]");
+ new ParserTester("[a&&[^b]]").assertParseCharacterClass("[[a]&&[^[b]]]");
+ new ParserTester("[a[^b]]").assertParseCharacterClass("[[a]||[^[b]]]");
+ new ParserTester("[a[b]]").assertParseCharacterClass("[[a]||[b]]");
+ new ParserTester("[a[b]c]").assertParseCharacterClass("[[a]||[[b]||[c]]]");
+ new ParserTester("[[a]bc]").assertParseCharacterClass("[[a]||[[b]||[c]]]");
+ new ParserTester("[-]").assertParseCharacterClass("[-]");
+ new ParserTester("[a-]").assertParseCharacterClass("[[a]||[-]]");
+// new ParserTester("[---]").assertParseCharacterClass("[---]");
+ new ParserTester("[#--]").assertParseCharacterClass("[#--]");
+ }
+
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpAnalyser.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpAnalyser.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpAnalyser.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.regexp;
-
-import org.exoplatform.component.test.BaseGateInTest;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class TestRegExpAnalyser extends BaseGateInTest
-{
-
- /** . */
- private RegExpRenderer renderer = new RegExpRenderer();
-
- private void assertAnalyse(String expectedPattern, String pattern)
- {
- try
- {
- RENode.Disjunction disjunction = new RegExpParser(pattern).parseDisjunction();
- assertEquals(expectedPattern, renderer.render(disjunction, new StringBuilder()).toString());
- }
- catch (Exception e)
- {
- fail(e);
- }
- }
-
- public void testCharacterClass()
- {
- assertAnalyse("[a]", "[a]");
- assertAnalyse("[ab]", "[ab]");
- assertAnalyse("[ab]", "[a[b]]");
- assertAnalyse("[abc]", "[abc]");
- assertAnalyse("[abc]", "[[a]bc]");
- assertAnalyse("[abc]", "[a[b]c]");
- assertAnalyse("[abc]", "[ab[c]]");
- assertAnalyse("[abc]", "[[ab]c]");
- assertAnalyse("[abc]", "[a[bc]]");
- assertAnalyse("[abc]", "[[abc]]");
- assertAnalyse("[^a]", "[^a]");
- }
-
- public void testGroupContainer()
- {
- assertAnalyse("(a)", "(a)");
- assertAnalyse("(a(?:b))", "(a(?:b))");
- assertAnalyse("(?:a(b))", "(?:a(b))");
- assertAnalyse("(a)(?:b)", "(a)(?:b)");
- assertAnalyse("(a(b))", "(a(b))");
- assertAnalyse("(a)(b)", "(a)(b)");
-
- //
- assertAnalyse("(?=a)", "(?=a)");
- assertAnalyse("(?!a)", "(?!a)");
- assertAnalyse("(?<=a)", "(?<=a)");
- assertAnalyse("(?<!a)", "(?<!a)");
- }
-
- public void testBilto()
- {
- assertAnalyse("[a]+", "[a]+");
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpAnalyser.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpAnalyser.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpAnalyser.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpAnalyser.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.regexp;
+
+import org.exoplatform.component.test.BaseGateInTest;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestRegExpAnalyser extends BaseGateInTest
+{
+
+ /** . */
+ private RegExpRenderer renderer = new RegExpRenderer();
+
+ private void assertAnalyse(String expectedPattern, String pattern)
+ {
+ try
+ {
+ RENode.Disjunction disjunction = new RegExpParser(pattern).parseDisjunction();
+ assertEquals(expectedPattern, renderer.render(disjunction, new StringBuilder()).toString());
+ }
+ catch (Exception e)
+ {
+ fail(e);
+ }
+ }
+
+ public void testCharacterClass()
+ {
+ assertAnalyse("[a]", "[a]");
+ assertAnalyse("[ab]", "[ab]");
+ assertAnalyse("[ab]", "[a[b]]");
+ assertAnalyse("[abc]", "[abc]");
+ assertAnalyse("[abc]", "[[a]bc]");
+ assertAnalyse("[abc]", "[a[b]c]");
+ assertAnalyse("[abc]", "[ab[c]]");
+ assertAnalyse("[abc]", "[[ab]c]");
+ assertAnalyse("[abc]", "[a[bc]]");
+ assertAnalyse("[abc]", "[[abc]]");
+ assertAnalyse("[^a]", "[^a]");
+ }
+
+ public void testGroupContainer()
+ {
+ assertAnalyse("(a)", "(a)");
+ assertAnalyse("(a(?:b))", "(a(?:b))");
+ assertAnalyse("(?:a(b))", "(?:a(b))");
+ assertAnalyse("(a)(?:b)", "(a)(?:b)");
+ assertAnalyse("(a(b))", "(a(b))");
+ assertAnalyse("(a)(b)", "(a)(b)");
+
+ //
+ assertAnalyse("(?=a)", "(?=a)");
+ assertAnalyse("(?!a)", "(?!a)");
+ assertAnalyse("(?<=a)", "(?<=a)");
+ assertAnalyse("(?<!a)", "(?<!a)");
+ }
+
+ public void testBilto()
+ {
+ assertAnalyse("[a]+", "[a]+");
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpParser.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpParser.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpParser.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,304 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.regexp;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- */
-public class TestRegExpParser extends TestCase
-{
-
- public void testParseDisjunction()
- {
- parseParse("|");
- parseParse("a|");
- parseParse("|a");
- parseParse("a|b");
- }
-
- public void testParseAlternative()
- {
- parseParse("ab");
- parseParse("^a$");
- }
-
- public void testParseAssertion()
- {
- parseParse("^");
- parseParse("$");
- }
-
- public void testParseAny()
- {
- parseParse(".");
- }
-
- public void testParseCharacterLiteral()
- {
- parseParse("a");
- parseParse("-");
- parseParse("]");
- parseParse("\\$");
- parseParse("\\00");
- parseParse("\\01");
- parseParse("\\018");
- parseParse("\\011");
- parseParse("\\0311");
- parseParse("\\x00");
- parseParse("\\xFF");
- parseParse("\\xff");
- parseParse("\\u0000");
- parseParse("\\uFFFF");
-
- //
- failFail("\\");
- failFail("\\k");
- failFail("\\0");
- failFail("\\08");
- failFail("\\x1");
- failFail("\\x1G");
- failFail("\\u1");
- failFail("\\u12");
- failFail("\\u123");
- failFail("\\u123G");
- }
-
- public void testCharacterClass() throws Exception
- {
- parseParse("[a]");
- parseParse("[{]");
- parseParse("[a{]");
- parseParse("[]a]");
- parseParse("[[a]]");
- parseParse("[a[b]]");
-
- //
- failFail("[a");
- failFail("[]");
- }
-
- public void testCharacterClassNegation() throws Exception
- {
- parseParse("[^a]");
- parseParse("[^]a]");
- parseParse("[^[a]]");
- parseParse("[^a[b]]");
-
- //
- failFail("[^a");
- failFail("[]");
- }
-
- public void testCharacterClassRange()
- {
- parseParse("[a-b]");
- parseParse("[-]");
- parseParse("[ --]");
- parseParse("[ --b]");
- parseParse("[--/]");
- parseParse("[a-]");
- parseParse("[---]");
- parseParse("[--]");
-
- //
- parseFail("[--[ab]]"); // Parse - or a or b
- }
-
- public void testCharacterClassAlternative()
- {
- parseParse("[&]");
- parseParse("[a&&b]");
- parseParse("[a&&]");
- parseParse("[a&&[b]]");
-
- //
- failFail("[&&]");
- failFail("[&&&]");
- failFail("[&&&&]");
-
- //
- parseFail("[&&b]");
- }
-
- public void testCharacterClassEscape()
- {
- parseParse("[\\\\]");
- parseParse("[\\[]");
- parseParse("[\\]]");
- parseParse("[\\.]");
- parseParse("[\\-]");
-
- //
- failFail("[\\k]");
- }
-
- public void testCharacterClassAny()
- {
- parseParse("[.]");
- parseParse("[^.]");
- }
-
- public void testCharacterClassAssert()
- {
- parseParse("[$]");
- parseParse("[^$]");
- parseParse("[^^]");
- parseParse("[$^]");
- }
-
- public void testParseGroup()
- {
- parseParse("()");
- parseParse("(?)");
- parseParse("(a)");
- parseParse("(|)");
- parseParse("(a|)");
- parseParse("(|a)");
- parseParse("(a|b)");
- parseParse("(()())");
-
- //
- parseParse("(?:)");
- parseParse("(?=)");
- parseParse("(?!)");
- parseParse("(?<=)");
- parseParse("(?<!)");
-
- //
- failFail("(?a)");
- failFail("(");
- failFail(")");
- failFail("(?<)");
- failFail("(?<a)");
- }
-
- public void testParseQuantifier()
- {
- parseParse("^?");
- parseParse("$?");
- parseParse("a?");
- parseParse("()?");
- parseParse("[a]?");
- parseParse("^*");
- parseParse("$*");
- parseParse("a*");
- parseParse("()*");
- parseParse("[a]*");
- parseParse("^+");
- parseParse("$+");
- parseParse("a+");
- parseParse("()+");
- parseParse("[a]+");
- parseParse("a{0}");
- parseParse("a{0,}");
- parseParse("a{0,1}");
-
- //
- failFail("?");
- failFail("+");
- failFail("*");
- failFail("{");
- failFail("a{");
- failFail("a{}");
- failFail("a{b");
- failFail("a{0");
- failFail("a{0,");
- failFail("a{0,1");
- }
-
- public void testParseQuantifierMode()
- {
- parseParse("a??");
- parseParse("a?+");
- parseParse("a+?");
- parseParse("a++");
- parseParse("a*?");
- parseParse("a*+");
- parseParse("a{0}?");
- parseParse("a{0}+");
- }
-
- void parseFail(String s)
- {
- parse(s, false, true);
- }
-
- void parseParse(String s)
- {
- parse(s, false, false);
- }
-
- void failFail(String s)
- {
- parse(s, true, true);
- }
-
- void parse(String s, boolean javaFail, boolean javaccFail)
- {
- try
- {
- Pattern.compile(s);
- if (javaFail)
- {
- throw new AssertionFailedError("Was expecting " + s + " to not be compilable");
- }
- }
- catch (PatternSyntaxException e)
- {
- if (!javaFail)
- {
- AssertionFailedError afe = new AssertionFailedError("Was expecting " + s + " to be compilable");
- afe.initCause(e);
- throw afe;
- }
- }
- try
- {
- Stream stream = new Stream(s);
- Lexer lexer = new Lexer(stream);
- RegExpParser parser = new RegExpParser(lexer);
- parser.parse();
- assertEquals(s.length(), stream.getIndex());
- if (lexer.hasNext())
- {
- throw new SyntaxException();
- }
- if (javaccFail)
- {
- throw new AssertionFailedError("Was expecting " + s + " to not be compilable");
- }
- }
- catch (SyntaxException e)
- {
- if (!javaccFail)
- {
- AssertionFailedError afe = new AssertionFailedError("Was expecting " + s + " to be compilable");
- afe.initCause(e);
- throw afe;
- }
- }
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpParser.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpParser.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpParser.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpParser.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,304 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.regexp;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public class TestRegExpParser extends TestCase
+{
+
+ public void testParseDisjunction()
+ {
+ parseParse("|");
+ parseParse("a|");
+ parseParse("|a");
+ parseParse("a|b");
+ }
+
+ public void testParseAlternative()
+ {
+ parseParse("ab");
+ parseParse("^a$");
+ }
+
+ public void testParseAssertion()
+ {
+ parseParse("^");
+ parseParse("$");
+ }
+
+ public void testParseAny()
+ {
+ parseParse(".");
+ }
+
+ public void testParseCharacterLiteral()
+ {
+ parseParse("a");
+ parseParse("-");
+ parseParse("]");
+ parseParse("\\$");
+ parseParse("\\00");
+ parseParse("\\01");
+ parseParse("\\018");
+ parseParse("\\011");
+ parseParse("\\0311");
+ parseParse("\\x00");
+ parseParse("\\xFF");
+ parseParse("\\xff");
+ parseParse("\\u0000");
+ parseParse("\\uFFFF");
+
+ //
+ failFail("\\");
+ failFail("\\k");
+ failFail("\\0");
+ failFail("\\08");
+ failFail("\\x1");
+ failFail("\\x1G");
+ failFail("\\u1");
+ failFail("\\u12");
+ failFail("\\u123");
+ failFail("\\u123G");
+ }
+
+ public void testCharacterClass() throws Exception
+ {
+ parseParse("[a]");
+ parseParse("[{]");
+ parseParse("[a{]");
+ parseParse("[]a]");
+ parseParse("[[a]]");
+ parseParse("[a[b]]");
+
+ //
+ failFail("[a");
+ failFail("[]");
+ }
+
+ public void testCharacterClassNegation() throws Exception
+ {
+ parseParse("[^a]");
+ parseParse("[^]a]");
+ parseParse("[^[a]]");
+ parseParse("[^a[b]]");
+
+ //
+ failFail("[^a");
+ failFail("[]");
+ }
+
+ public void testCharacterClassRange()
+ {
+ parseParse("[a-b]");
+ parseParse("[-]");
+ parseParse("[ --]");
+ parseParse("[ --b]");
+ parseParse("[--/]");
+ parseParse("[a-]");
+ parseParse("[---]");
+ parseParse("[--]");
+
+ //
+ parseFail("[--[ab]]"); // Parse - or a or b
+ }
+
+ public void testCharacterClassAlternative()
+ {
+ parseParse("[&]");
+ parseParse("[a&&b]");
+ parseParse("[a&&]");
+ parseParse("[a&&[b]]");
+
+ //
+ failFail("[&&]");
+ failFail("[&&&]");
+ failFail("[&&&&]");
+
+ //
+ parseFail("[&&b]");
+ }
+
+ public void testCharacterClassEscape()
+ {
+ parseParse("[\\\\]");
+ parseParse("[\\[]");
+ parseParse("[\\]]");
+ parseParse("[\\.]");
+ parseParse("[\\-]");
+
+ //
+ failFail("[\\k]");
+ }
+
+ public void testCharacterClassAny()
+ {
+ parseParse("[.]");
+ parseParse("[^.]");
+ }
+
+ public void testCharacterClassAssert()
+ {
+ parseParse("[$]");
+ parseParse("[^$]");
+ parseParse("[^^]");
+ parseParse("[$^]");
+ }
+
+ public void testParseGroup()
+ {
+ parseParse("()");
+ parseParse("(?)");
+ parseParse("(a)");
+ parseParse("(|)");
+ parseParse("(a|)");
+ parseParse("(|a)");
+ parseParse("(a|b)");
+ parseParse("(()())");
+
+ //
+ parseParse("(?:)");
+ parseParse("(?=)");
+ parseParse("(?!)");
+ parseParse("(?<=)");
+ parseParse("(?<!)");
+
+ //
+ failFail("(?a)");
+ failFail("(");
+ failFail(")");
+ failFail("(?<)");
+ failFail("(?<a)");
+ }
+
+ public void testParseQuantifier()
+ {
+ parseParse("^?");
+ parseParse("$?");
+ parseParse("a?");
+ parseParse("()?");
+ parseParse("[a]?");
+ parseParse("^*");
+ parseParse("$*");
+ parseParse("a*");
+ parseParse("()*");
+ parseParse("[a]*");
+ parseParse("^+");
+ parseParse("$+");
+ parseParse("a+");
+ parseParse("()+");
+ parseParse("[a]+");
+ parseParse("a{0}");
+ parseParse("a{0,}");
+ parseParse("a{0,1}");
+
+ //
+ failFail("?");
+ failFail("+");
+ failFail("*");
+ failFail("{");
+ failFail("a{");
+ failFail("a{}");
+ failFail("a{b");
+ failFail("a{0");
+ failFail("a{0,");
+ failFail("a{0,1");
+ }
+
+ public void testParseQuantifierMode()
+ {
+ parseParse("a??");
+ parseParse("a?+");
+ parseParse("a+?");
+ parseParse("a++");
+ parseParse("a*?");
+ parseParse("a*+");
+ parseParse("a{0}?");
+ parseParse("a{0}+");
+ }
+
+ void parseFail(String s)
+ {
+ parse(s, false, true);
+ }
+
+ void parseParse(String s)
+ {
+ parse(s, false, false);
+ }
+
+ void failFail(String s)
+ {
+ parse(s, true, true);
+ }
+
+ void parse(String s, boolean javaFail, boolean javaccFail)
+ {
+ try
+ {
+ Pattern.compile(s);
+ if (javaFail)
+ {
+ throw new AssertionFailedError("Was expecting " + s + " to not be compilable");
+ }
+ }
+ catch (PatternSyntaxException e)
+ {
+ if (!javaFail)
+ {
+ AssertionFailedError afe = new AssertionFailedError("Was expecting " + s + " to be compilable");
+ afe.initCause(e);
+ throw afe;
+ }
+ }
+ try
+ {
+ Stream stream = new Stream(s);
+ Lexer lexer = new Lexer(stream);
+ RegExpParser parser = new RegExpParser(lexer);
+ parser.parse();
+ assertEquals(s.length(), stream.getIndex());
+ if (lexer.hasNext())
+ {
+ throw new SyntaxException();
+ }
+ if (javaccFail)
+ {
+ throw new AssertionFailedError("Was expecting " + s + " to not be compilable");
+ }
+ }
+ catch (SyntaxException e)
+ {
+ if (!javaccFail)
+ {
+ AssertionFailedError afe = new AssertionFailedError("Was expecting " + s + " to be compilable");
+ afe.initCause(e);
+ throw afe;
+ }
+ }
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpRenderer.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpRenderer.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpRenderer.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,154 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.regexp;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- */
-public class TestRegExpRenderer extends TestCase
-{
-
- static void assertRender(RENode re, String expected)
- {
- try
- {
- String rendered;
- if (re != null)
- {
- RegExpRenderer renderer = new RegExpRenderer();
- rendered = renderer.render(re, new StringBuilder()).toString();
- }
- else
- {
- rendered = "";
- }
- assertEquals(expected, rendered);
- }
- catch (IOException e)
- {
- AssertionFailedError afe = new AssertionFailedError();
- afe.initCause(e);
- throw afe;
- }
- }
-
- static RENode.Disjunction disjunction(String regexp)
- {
- try
- {
- RegExpParser parser = new RegExpParser(regexp);
- RENode.Disjunction re = parser.parseDisjunction();
- assertTrue(parser.isDone());
- return re;
- }
- catch (SyntaxException e)
- {
- AssertionFailedError afe = new AssertionFailedError();
- afe.initCause(e);
- throw afe;
- }
- }
-
- static RENode.Alternative alternative(String regexp)
- {
- try
- {
- RegExpParser parser = new RegExpParser(regexp);
- RENode.Alternative re = parser.parseAlternative();
- assertTrue(parser.isDone());
- return re;
- }
- catch (SyntaxException e)
- {
- AssertionFailedError afe = new AssertionFailedError();
- afe.initCause(e);
- throw afe;
- }
- }
-
- static RENode.Expr expression(String regexp)
- {
- try
- {
- RegExpParser parser = new RegExpParser(regexp);
- RENode.Expr re = parser.parseExpression();
- assertTrue(parser.isDone());
- return re;
- }
- catch (SyntaxException e)
- {
- AssertionFailedError afe = new AssertionFailedError();
- afe.initCause(e);
- throw afe;
- }
- }
-
- static RENode.CharacterClass characterClass(String regexp)
- {
- try
- {
- RegExpParser parser = new RegExpParser(regexp);
- RENode.CharacterClass re = parser.parseCharacterClass();
- assertTrue(parser.isDone());
- return re;
- }
- catch (SyntaxException e)
- {
- AssertionFailedError afe = new AssertionFailedError();
- afe.initCause(e);
- throw afe;
- }
- }
-
- public void testSimple()
- {
- assertRender(expression("."), ".");
- assertRender(expression("^"), "^");
- assertRender(expression("\\."), "\\.");
- }
-
- public void testDisjunction()
- {
- assertRender(disjunction(""), "");
- assertRender(disjunction("|"), "");
- assertRender(disjunction("a|"), "a");
- assertRender(disjunction("|a"), "a");
- }
-
- public void testAlternative()
- {
- assertRender(alternative(""), "");
- assertRender(alternative("ab"), "ab");
- assertRender(alternative("abc"), "abc");
- }
-
- public void testCharacterClass()
- {
- assertRender(characterClass(""), "");
- assertRender(characterClass("[a]"), "[a]");
- assertRender(characterClass("[ab]"), "[ab]");
- assertRender(characterClass("[.\\]]"), "[\\.\\]]");
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpRenderer.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpRenderer.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpRenderer.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestRegExpRenderer.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.regexp;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public class TestRegExpRenderer extends TestCase
+{
+
+ static void assertRender(RENode re, String expected)
+ {
+ try
+ {
+ String rendered;
+ if (re != null)
+ {
+ RegExpRenderer renderer = new RegExpRenderer();
+ rendered = renderer.render(re, new StringBuilder()).toString();
+ }
+ else
+ {
+ rendered = "";
+ }
+ assertEquals(expected, rendered);
+ }
+ catch (IOException e)
+ {
+ AssertionFailedError afe = new AssertionFailedError();
+ afe.initCause(e);
+ throw afe;
+ }
+ }
+
+ static RENode.Disjunction disjunction(String regexp)
+ {
+ try
+ {
+ RegExpParser parser = new RegExpParser(regexp);
+ RENode.Disjunction re = parser.parseDisjunction();
+ assertTrue(parser.isDone());
+ return re;
+ }
+ catch (SyntaxException e)
+ {
+ AssertionFailedError afe = new AssertionFailedError();
+ afe.initCause(e);
+ throw afe;
+ }
+ }
+
+ static RENode.Alternative alternative(String regexp)
+ {
+ try
+ {
+ RegExpParser parser = new RegExpParser(regexp);
+ RENode.Alternative re = parser.parseAlternative();
+ assertTrue(parser.isDone());
+ return re;
+ }
+ catch (SyntaxException e)
+ {
+ AssertionFailedError afe = new AssertionFailedError();
+ afe.initCause(e);
+ throw afe;
+ }
+ }
+
+ static RENode.Expr expression(String regexp)
+ {
+ try
+ {
+ RegExpParser parser = new RegExpParser(regexp);
+ RENode.Expr re = parser.parseExpression();
+ assertTrue(parser.isDone());
+ return re;
+ }
+ catch (SyntaxException e)
+ {
+ AssertionFailedError afe = new AssertionFailedError();
+ afe.initCause(e);
+ throw afe;
+ }
+ }
+
+ static RENode.CharacterClass characterClass(String regexp)
+ {
+ try
+ {
+ RegExpParser parser = new RegExpParser(regexp);
+ RENode.CharacterClass re = parser.parseCharacterClass();
+ assertTrue(parser.isDone());
+ return re;
+ }
+ catch (SyntaxException e)
+ {
+ AssertionFailedError afe = new AssertionFailedError();
+ afe.initCause(e);
+ throw afe;
+ }
+ }
+
+ public void testSimple()
+ {
+ assertRender(expression("."), ".");
+ assertRender(expression("^"), "^");
+ assertRender(expression("\\."), "\\.");
+ }
+
+ public void testDisjunction()
+ {
+ assertRender(disjunction(""), "");
+ assertRender(disjunction("|"), "");
+ assertRender(disjunction("a|"), "a");
+ assertRender(disjunction("|a"), "a");
+ }
+
+ public void testAlternative()
+ {
+ assertRender(alternative(""), "");
+ assertRender(alternative("ab"), "ab");
+ assertRender(alternative("abc"), "abc");
+ }
+
+ public void testCharacterClass()
+ {
+ assertRender(characterClass(""), "");
+ assertRender(characterClass("[a]"), "[a]");
+ assertRender(characterClass("[ab]"), "[ab]");
+ assertRender(characterClass("[.\\]]"), "[\\.\\]]");
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestSubCharSequence.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestSubCharSequence.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestSubCharSequence.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.regexp;
-
-import junit.framework.TestCase;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class TestSubCharSequence extends TestCase
-{
-
- private final CharSequence seq = new SubCharSequence("abcdef", 1, 5);
-
- public void testState()
- {
- assertEquals(4, seq.length());
- assertEquals('b', seq.charAt(0));
- assertEquals('c', seq.charAt(1));
- assertEquals('d', seq.charAt(2));
- assertEquals('e', seq.charAt(3));
- assertEquals("bcde", seq.toString());
- }
-
- public void testSubSequence()
- {
- CharSequence sub = seq.subSequence(1, 3);
- assertEquals(2, sub.length());
- assertEquals('c', sub.charAt(0));
- assertEquals('d', sub.charAt(1));
- assertEquals("cd", sub.toString());
- }
-
- public void testSubSequenceThrowsIOOBE()
- {
- assertSubSequenceThrowsIIOBE(-1, 3);
- assertSubSequenceThrowsIIOBE(1, 5);
- assertSubSequenceThrowsIIOBE(1, -1);
- assertSubSequenceThrowsIIOBE(5, 1);
- }
-
- private void assertSubSequenceThrowsIIOBE(int start, int end)
- {
- try
- {
- seq.subSequence(start, end);
- fail();
- }
- catch (IndexOutOfBoundsException e)
- {
- }
- }
-
- public void testCharAtThrowsIOOBE()
- {
- try
- {
- seq.charAt(-1);
- fail();
- }
- catch (IndexOutOfBoundsException e)
- {
- }
- try
- {
- seq.charAt(4);
- fail();
- }
- catch (IndexOutOfBoundsException e)
- {
- }
- }
-
- public void testCtorThrowsNPE()
- {
- try
- {
- new SubCharSequence(null, 1, 5);
- fail();
- }
- catch (NullPointerException e)
- {
- }
- }
-
- public void testCtorThrowsIAE()
- {
- assertCtorThrowsIAE("a", -1, 1);
- assertCtorThrowsIAE("a", 0, 2);
- assertCtorThrowsIAE("a", 1, 0);
- }
-
- private void assertCtorThrowsIAE(String s, int from, int to)
- {
- try
- {
- new SubCharSequence(s, from, to);
- fail();
- }
- catch (IllegalArgumentException e)
- {
- }
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestSubCharSequence.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestSubCharSequence.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestSubCharSequence.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/regexp/TestSubCharSequence.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.regexp;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestSubCharSequence extends TestCase
+{
+
+ private final CharSequence seq = new SubCharSequence("abcdef", 1, 5);
+
+ public void testState()
+ {
+ assertEquals(4, seq.length());
+ assertEquals('b', seq.charAt(0));
+ assertEquals('c', seq.charAt(1));
+ assertEquals('d', seq.charAt(2));
+ assertEquals('e', seq.charAt(3));
+ assertEquals("bcde", seq.toString());
+ }
+
+ public void testSubSequence()
+ {
+ CharSequence sub = seq.subSequence(1, 3);
+ assertEquals(2, sub.length());
+ assertEquals('c', sub.charAt(0));
+ assertEquals('d', sub.charAt(1));
+ assertEquals("cd", sub.toString());
+ }
+
+ public void testSubSequenceThrowsIOOBE()
+ {
+ assertSubSequenceThrowsIIOBE(-1, 3);
+ assertSubSequenceThrowsIIOBE(1, 5);
+ assertSubSequenceThrowsIIOBE(1, -1);
+ assertSubSequenceThrowsIIOBE(5, 1);
+ }
+
+ private void assertSubSequenceThrowsIIOBE(int start, int end)
+ {
+ try
+ {
+ seq.subSequence(start, end);
+ fail();
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ }
+ }
+
+ public void testCharAtThrowsIOOBE()
+ {
+ try
+ {
+ seq.charAt(-1);
+ fail();
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ }
+ try
+ {
+ seq.charAt(4);
+ fail();
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ }
+ }
+
+ public void testCtorThrowsNPE()
+ {
+ try
+ {
+ new SubCharSequence(null, 1, 5);
+ fail();
+ }
+ catch (NullPointerException e)
+ {
+ }
+ }
+
+ public void testCtorThrowsIAE()
+ {
+ assertCtorThrowsIAE("a", -1, 1);
+ assertCtorThrowsIAE("a", 0, 2);
+ assertCtorThrowsIAE("a", 1, 0);
+ }
+
+ private void assertCtorThrowsIAE(String s, int from, int to)
+ {
+ try
+ {
+ new SubCharSequence(s, from, to);
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/AbstractTestController.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/AbstractTestController.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/AbstractTestController.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-import org.exoplatform.web.controller.QualifiedName;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public abstract class AbstractTestController extends TestCase
-{
- public static void assertEquals(Map<QualifiedName, String> expectedParameters, Map<QualifiedName, String> parameters)
- {
- assertNotNull("Was not expecting a null parameter set", parameters);
- Assert.assertEquals(expectedParameters.keySet(), parameters.keySet());
- for (Map.Entry<QualifiedName, String> expectedEntry : expectedParameters.entrySet())
- {
- Assert.assertEquals(expectedEntry.getValue(), parameters.get(expectedEntry.getKey()));
- }
- }
-
- public static void assertMapEquals(Map<String, String[]> expectedParameters, Map<String, String[]> parameters)
- {
- assertNotNull("Was not expecting a null parameter set", parameters);
- Assert.assertEquals(expectedParameters.keySet(), parameters.keySet());
- for (Map.Entry<String, String[]> expectedEntry : expectedParameters.entrySet())
- {
- Assert.assertEquals(Arrays.asList(expectedEntry.getValue()), Arrays.asList(parameters.get(expectedEntry.getKey())));
- }
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/AbstractTestController.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/AbstractTestController.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/AbstractTestController.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/AbstractTestController.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.exoplatform.web.controller.QualifiedName;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class AbstractTestController extends TestCase
+{
+ public static void assertEquals(Map<QualifiedName, String> expectedParameters, Map<QualifiedName, String> parameters)
+ {
+ assertNotNull("Was not expecting a null parameter set", parameters);
+ Assert.assertEquals(expectedParameters.keySet(), parameters.keySet());
+ for (Map.Entry<QualifiedName, String> expectedEntry : expectedParameters.entrySet())
+ {
+ Assert.assertEquals(expectedEntry.getValue(), parameters.get(expectedEntry.getKey()));
+ }
+ }
+
+ public static void assertMapEquals(Map<String, String[]> expectedParameters, Map<String, String[]> parameters)
+ {
+ assertNotNull("Was not expecting a null parameter set", parameters);
+ Assert.assertEquals(expectedParameters.keySet(), parameters.keySet());
+ for (Map.Entry<String, String[]> expectedEntry : expectedParameters.entrySet())
+ {
+ Assert.assertEquals(Arrays.asList(expectedEntry.getValue()), Arrays.asList(parameters.get(expectedEntry.getKey())));
+ }
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/Names.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/Names.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/Names.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.exoplatform.web.controller.QualifiedName;
-
-/**
- * Various predefined names for testing purpose.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- */
-public interface Names
-{
-
- QualifiedName Q_A = QualifiedName.parse("q:a");
- QualifiedName A = QualifiedName.parse("a");
- QualifiedName B = QualifiedName.parse("b");
- QualifiedName P = QualifiedName.parse("p");
- QualifiedName FOO = QualifiedName.parse("foo");
- QualifiedName BAR = QualifiedName.parse("bar");
- QualifiedName JUU = QualifiedName.parse("juu");
- QualifiedName GTN_HANDLER = QualifiedName.parse("gtn:handler");
- QualifiedName GTN_LANG = QualifiedName.parse("gtn:lang");
- QualifiedName GTN_SITENAME = QualifiedName.parse("gtn:sitename");
- QualifiedName GTN_SITETYPE = QualifiedName.parse("gtn:sitetype");
- QualifiedName GTN_ACCESS = QualifiedName.parse("gtn:access");
- QualifiedName GTN_PATH = QualifiedName.parse("gtn:path");
- QualifiedName GTN_COMPONENTID = QualifiedName.parse("gtn:componentid");
-
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/Names.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/Names.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/Names.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/Names.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.web.controller.QualifiedName;
+
+/**
+ * Various predefined names for testing purpose.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public interface Names
+{
+
+ QualifiedName Q_A = QualifiedName.parse("q:a");
+ QualifiedName A = QualifiedName.parse("a");
+ QualifiedName B = QualifiedName.parse("b");
+ QualifiedName P = QualifiedName.parse("p");
+ QualifiedName FOO = QualifiedName.parse("foo");
+ QualifiedName BAR = QualifiedName.parse("bar");
+ QualifiedName JUU = QualifiedName.parse("juu");
+ QualifiedName GTN_HANDLER = QualifiedName.parse("gtn:handler");
+ QualifiedName GTN_LANG = QualifiedName.parse("gtn:lang");
+ QualifiedName GTN_SITENAME = QualifiedName.parse("gtn:sitename");
+ QualifiedName GTN_SITETYPE = QualifiedName.parse("gtn:sitetype");
+ QualifiedName GTN_ACCESS = QualifiedName.parse("gtn:access");
+ QualifiedName GTN_PATH = QualifiedName.parse("gtn:path");
+ QualifiedName GTN_COMPONENTID = QualifiedName.parse("gtn:componentid");
+
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import junit.framework.TestCase;
-
-import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class TestBuildRoute extends TestCase
-{
-
- public void testParameterSegment() throws Exception
- {
- Router router = router().add(route("/{a}")).build();
-
- //
- assertEquals(0, router.root.getSegmentNames().size());
- assertEquals(1, router.root.getPatternSize());
- PatternRoute patternRoute = router.root.getPattern(0);
- assertEquals("^/([^/]+)(?:(?<=^/)|(?=/)|$)", patternRoute.pattern.toString());
- assertEquals(1, patternRoute.params.length);
- assertEquals(Names.A, patternRoute.params[0].name);
- assertEquals("^.+$", patternRoute.params[0].renderingPattern.toString());
- assertEquals(EncodingMode.FORM, patternRoute.params[0].encodingMode);
- assertEquals(2, patternRoute.chunks.length);
- assertEquals("", patternRoute.chunks[0]);
- assertEquals("", patternRoute.chunks[1]);
- }
-
- public void testQualifiedParameterSegment() throws Exception
- {
- Router router = router().add(route("/{q:a}")).build();
-
- //
- assertEquals(0, router.root.getSegmentNames().size());
- assertEquals(1, router.root.getPatternSize());
- PatternRoute patternRoute = router.root.getPattern(0);
- assertEquals("^/([^/]+)(?:(?<=^/)|(?=/)|$)", patternRoute.pattern.toString());
- assertEquals(1, patternRoute.params.length);
- assertEquals(Names.Q_A, patternRoute.params[0].name);
- assertEquals("^.+$", patternRoute.params[0].renderingPattern.toString());
- assertEquals(EncodingMode.FORM, patternRoute.params[0].encodingMode);
- assertEquals(2, patternRoute.chunks.length);
- assertEquals("", patternRoute.chunks[0]);
- assertEquals("", patternRoute.chunks[1]);
- }
-
- public void testPatternSegment() throws Exception
- {
- Router router = router().add(route("/{a}").with(pathParam("a").matchedBy(".*"))).build();
-
- //
- assertEquals(0, router.root.getSegmentNames().size());
- assertEquals(1, router.root.getPatternSize());
- PatternRoute patternRoute = router.root.getPattern(0);
- assertEquals("^/([^/]*)(?:(?<=^/)|(?=/)|$)", patternRoute.pattern.toString());
- assertEquals(1, patternRoute.params.length);
- assertEquals(Names.A, patternRoute.params[0].name);
- assertEquals("^.*$", patternRoute.params[0].renderingPattern.toString());
- assertEquals(EncodingMode.FORM, patternRoute.params[0].encodingMode);
- assertEquals(2, patternRoute.chunks.length);
- assertEquals("", patternRoute.chunks[0]);
- assertEquals("", patternRoute.chunks[1]);
- }
-
- public void testSamePrefix() throws Exception
- {
- Router router = router().add(route("/public/foo")).add(route("/public/bar")).build();
- assertEquals(2, router.root.getSegmentSize("public"));
- Route publicRoute1 = router.root.getSegment("public", 0);
- assertEquals(1, publicRoute1.getSegmentSize("foo"));
- Route publicRoute2 = router.root.getSegment("public", 1);
- assertEquals(1, publicRoute2.getSegmentSize("bar"));
- }
-
- private void assertEquals(Route expectedRoute, Route route)
- {
- assertEquals(expectedRoute.getClass(), route.getClass());
- assertEquals(expectedRoute.getSegmentNames(), route.getSegmentNames());
- for (String segmentName : expectedRoute.getSegmentNames())
- {
- assertEquals(expectedRoute.getSegmentSize(segmentName), route.getSegmentSize(segmentName));
- for (int segmentIndex = 0;segmentIndex < expectedRoute.getSegmentSize(segmentName);segmentIndex++)
- {
- SegmentRoute expectedSegmentRoute = expectedRoute.getSegment(segmentName, segmentIndex);
- SegmentRoute segmentRoute = route.getSegment(segmentName, segmentIndex);
- assertEquals(expectedSegmentRoute, segmentRoute);
- }
- }
- assertEquals(expectedRoute.getPatternSize(), route.getPatternSize());
- for (int i = 0;i < expectedRoute.getPatternSize();i++)
- {
- assertEquals(expectedRoute.getPattern(i), route.getPattern(i));
- }
- if (route instanceof PatternRoute)
- {
- assertEquals(((PatternRoute)expectedRoute).pattern.toString(), ((PatternRoute)route).pattern.toString());
- assertEquals(((PatternRoute)expectedRoute).params.length, ((PatternRoute)route).params.length);
- for (int i = 0;i < ((PatternRoute)expectedRoute).params.length;i++)
- {
- PathParam expectedParam = ((PatternRoute)expectedRoute).params[i];
- PathParam param = ((PatternRoute)route).params[i];
- assertEquals(expectedParam.name, param.name);
- assertEquals(expectedParam.renderingPattern.toString(), param.renderingPattern.toString());
- assertEquals(expectedParam.encodingMode, param.encodingMode);
- }
- }
- else if (route instanceof SegmentRoute)
- {
- assertEquals(((SegmentRoute)expectedRoute).name, ((SegmentRoute)route).name);
- }
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import junit.framework.TestCase;
+
+import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestBuildRoute extends TestCase
+{
+
+ public void testParameterSegment() throws Exception
+ {
+ Router router = router().add(route("/{a}")).build();
+
+ //
+ assertEquals(0, router.root.getSegmentNames().size());
+ assertEquals(1, router.root.getPatternSize());
+ PatternRoute patternRoute = router.root.getPattern(0);
+ assertEquals("^/([^/]+)(?:(?<=^/)|(?=/)|$)", patternRoute.pattern.toString());
+ assertEquals(1, patternRoute.params.length);
+ assertEquals(Names.A, patternRoute.params[0].name);
+ assertEquals("^.+$", patternRoute.params[0].renderingPattern.toString());
+ assertEquals(EncodingMode.FORM, patternRoute.params[0].encodingMode);
+ assertEquals(2, patternRoute.chunks.length);
+ assertEquals("", patternRoute.chunks[0]);
+ assertEquals("", patternRoute.chunks[1]);
+ }
+
+ public void testQualifiedParameterSegment() throws Exception
+ {
+ Router router = router().add(route("/{q:a}")).build();
+
+ //
+ assertEquals(0, router.root.getSegmentNames().size());
+ assertEquals(1, router.root.getPatternSize());
+ PatternRoute patternRoute = router.root.getPattern(0);
+ assertEquals("^/([^/]+)(?:(?<=^/)|(?=/)|$)", patternRoute.pattern.toString());
+ assertEquals(1, patternRoute.params.length);
+ assertEquals(Names.Q_A, patternRoute.params[0].name);
+ assertEquals("^.+$", patternRoute.params[0].renderingPattern.toString());
+ assertEquals(EncodingMode.FORM, patternRoute.params[0].encodingMode);
+ assertEquals(2, patternRoute.chunks.length);
+ assertEquals("", patternRoute.chunks[0]);
+ assertEquals("", patternRoute.chunks[1]);
+ }
+
+ public void testPatternSegment() throws Exception
+ {
+ Router router = router().add(route("/{a}").with(pathParam("a").matchedBy(".*"))).build();
+
+ //
+ assertEquals(0, router.root.getSegmentNames().size());
+ assertEquals(1, router.root.getPatternSize());
+ PatternRoute patternRoute = router.root.getPattern(0);
+ assertEquals("^/([^/]*)(?:(?<=^/)|(?=/)|$)", patternRoute.pattern.toString());
+ assertEquals(1, patternRoute.params.length);
+ assertEquals(Names.A, patternRoute.params[0].name);
+ assertEquals("^.*$", patternRoute.params[0].renderingPattern.toString());
+ assertEquals(EncodingMode.FORM, patternRoute.params[0].encodingMode);
+ assertEquals(2, patternRoute.chunks.length);
+ assertEquals("", patternRoute.chunks[0]);
+ assertEquals("", patternRoute.chunks[1]);
+ }
+
+ public void testSamePrefix() throws Exception
+ {
+ Router router = router().add(route("/public/foo")).add(route("/public/bar")).build();
+ assertEquals(2, router.root.getSegmentSize("public"));
+ Route publicRoute1 = router.root.getSegment("public", 0);
+ assertEquals(1, publicRoute1.getSegmentSize("foo"));
+ Route publicRoute2 = router.root.getSegment("public", 1);
+ assertEquals(1, publicRoute2.getSegmentSize("bar"));
+ }
+
+ private void assertEquals(Route expectedRoute, Route route)
+ {
+ assertEquals(expectedRoute.getClass(), route.getClass());
+ assertEquals(expectedRoute.getSegmentNames(), route.getSegmentNames());
+ for (String segmentName : expectedRoute.getSegmentNames())
+ {
+ assertEquals(expectedRoute.getSegmentSize(segmentName), route.getSegmentSize(segmentName));
+ for (int segmentIndex = 0;segmentIndex < expectedRoute.getSegmentSize(segmentName);segmentIndex++)
+ {
+ SegmentRoute expectedSegmentRoute = expectedRoute.getSegment(segmentName, segmentIndex);
+ SegmentRoute segmentRoute = route.getSegment(segmentName, segmentIndex);
+ assertEquals(expectedSegmentRoute, segmentRoute);
+ }
+ }
+ assertEquals(expectedRoute.getPatternSize(), route.getPatternSize());
+ for (int i = 0;i < expectedRoute.getPatternSize();i++)
+ {
+ assertEquals(expectedRoute.getPattern(i), route.getPattern(i));
+ }
+ if (route instanceof PatternRoute)
+ {
+ assertEquals(((PatternRoute)expectedRoute).pattern.toString(), ((PatternRoute)route).pattern.toString());
+ assertEquals(((PatternRoute)expectedRoute).params.length, ((PatternRoute)route).params.length);
+ for (int i = 0;i < ((PatternRoute)expectedRoute).params.length;i++)
+ {
+ PathParam expectedParam = ((PatternRoute)expectedRoute).params[i];
+ PathParam param = ((PatternRoute)route).params[i];
+ assertEquals(expectedParam.name, param.name);
+ assertEquals(expectedParam.renderingPattern.toString(), param.renderingPattern.toString());
+ assertEquals(expectedParam.encodingMode, param.encodingMode);
+ }
+ }
+ else if (route instanceof SegmentRoute)
+ {
+ assertEquals(((SegmentRoute)expectedRoute).name, ((SegmentRoute)route).name);
+ }
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import junit.framework.TestCase;
-import org.exoplatform.web.WebAppController;
-import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.controller.metadata.DescriptorBuilder;
-import org.exoplatform.web.controller.metadata.RouteDescriptor;
-import org.exoplatform.web.controller.metadata.ControllerDescriptor;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class TestDescriptorBuilder extends TestCase
-{
-
- public void testFoo() throws Exception
- {
-
- URL routerURL = TestDescriptorBuilder.class.getResource("router.xml");
- XMLStreamReader routerReader = XMLInputFactory.newInstance().createXMLStreamReader(routerURL.openStream());
- ControllerDescriptor routerDesc = new DescriptorBuilder().build(routerReader);
-
- //
- assertEquals('&', routerDesc.getSeparatorEscape());
-
- //
- Iterator<RouteDescriptor> i = routerDesc.getRoutes().iterator();
-
- //
- assertTrue(i.hasNext());
- RouteDescriptor route1 = i.next();
- assertEquals("/public/{gtn:sitetype}/{gtn:sitename}{gtn:path}", route1.getPath());
- assertEquals(Collections.singleton(WebAppController.HANDLER_PARAM), route1.getRouteParamNames());
- assertEquals(WebAppController.HANDLER_PARAM, route1.getRouteParam(WebAppController.HANDLER_PARAM).getQualifiedName());
- assertEquals("portal", route1.getRouteParam(WebAppController.HANDLER_PARAM).getValue());
- assertEquals(Collections.singleton(Names.GTN_PATH), route1.getPathParams().keySet());
- assertEquals(Names.GTN_PATH, route1.getPathParams().get(Names.GTN_PATH).getQualifiedName());
- assertEquals(".*", route1.getPathParams().get(Names.GTN_PATH).getPattern());
- assertEquals(EncodingMode.FORM, route1.getPathParams().get(Names.GTN_PATH).getEncodingMode());
-
- //
- assertTrue(i.hasNext());
- RouteDescriptor route2 = i.next();
- assertEquals("/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}", route2.getPath());
- assertEquals(Collections.singleton(WebAppController.HANDLER_PARAM), route2.getRouteParamNames());
- assertEquals(WebAppController.HANDLER_PARAM, route2.getRouteParam(WebAppController.HANDLER_PARAM).getQualifiedName());
- assertEquals("portal", route2.getRouteParam(WebAppController.HANDLER_PARAM).getValue());
- assertEquals(Collections.singleton(Names.GTN_PATH), route2.getPathParams().keySet());
- assertEquals(Names.GTN_PATH, route2.getPathParams().get(Names.GTN_PATH).getQualifiedName());
- assertEquals(".*", route2.getPathParams().get(Names.GTN_PATH).getPattern());
- assertEquals(EncodingMode.PRESERVE_PATH, route2.getPathParams().get(Names.GTN_PATH).getEncodingMode());
-
- //
- assertTrue(i.hasNext());
- RouteDescriptor route3 = i.next();
- assertEquals("/upload", route3.getPath());
- assertEquals(Collections.singleton(WebAppController.HANDLER_PARAM), route3.getRouteParamNames());
- assertEquals(WebAppController.HANDLER_PARAM, route3.getRouteParam(WebAppController.HANDLER_PARAM).getQualifiedName());
- assertEquals("upload", route3.getRouteParam(WebAppController.HANDLER_PARAM).getValue());
-
- //
- assertTrue(i.hasNext());
- RouteDescriptor route4 = i.next();
- assertEquals("/download", route4.getPath());
- assertEquals(Collections.singleton(WebAppController.HANDLER_PARAM), route4.getRouteParamNames());
- assertEquals(WebAppController.HANDLER_PARAM, route4.getRouteParam(WebAppController.HANDLER_PARAM).getQualifiedName());
- assertEquals("download", route4.getRouteParam(WebAppController.HANDLER_PARAM).getValue());
-
- //
- assertTrue(i.hasNext());
- RouteDescriptor route5 = i.next();
- assertEquals("/a", route5.getPath());
- assertEquals(Collections.singleton(Names.A), route5.getRouteParamNames());
- assertEquals(Names.A, route5.getRouteParam(Names.A).getQualifiedName());
- assertEquals("a_value", route5.getRouteParam(Names.A).getValue());
- assertEquals(1, route5.getChildren().size());
- RouteDescriptor route5_1 = route5.getChildren().get(0);
- assertEquals("/b", route5_1.getPath());
- assertEquals(Collections.singleton(Names.B), route5_1.getRouteParamNames());
- assertEquals(Names.B, route5_1.getRouteParam(Names.B).getQualifiedName());
- assertEquals("b_value", route5_1.getRouteParam(Names.B).getValue());
-
- //
- assertTrue(i.hasNext());
- RouteDescriptor route6 = i.next();
- assertEquals("/b", route6.getPath());
- assertEquals(new HashSet<String>(Arrays.asList("foo", "bar", "juu")), route6.getRequestParamMatchNames());
- assertEquals(Names.FOO, route6.getRequestParam("foo").getQualifiedName());
- assertEquals("foo", route6.getRequestParam("foo").getName());
- assertEquals(null, route6.getRequestParam("foo").getValue());
- assertEquals(ValueType.LITERAL, route6.getRequestParam("foo").getValueType());
- assertEquals(ControlMode.OPTIONAL, route6.getRequestParam("foo").getControlMode());
- assertEquals(Names.BAR, route6.getRequestParam("bar").getQualifiedName());
- assertEquals("bar", route6.getRequestParam("bar").getName());
- assertEquals("bar", route6.getRequestParam("bar").getValue());
- assertEquals(ValueType.LITERAL, route6.getRequestParam("bar").getValueType());
- assertEquals(ControlMode.OPTIONAL, route6.getRequestParam("bar").getControlMode());
- assertEquals(Names.JUU, route6.getRequestParam("juu").getQualifiedName());
- assertEquals("juu", route6.getRequestParam("juu").getName());
- assertEquals("juu", route6.getRequestParam("juu").getValue());
- assertEquals(ValueType.PATTERN, route6.getRequestParam("juu").getValueType());
- assertEquals(ControlMode.REQUIRED, route6.getRequestParam("juu").getControlMode());
-
- //
- assertFalse(i.hasNext());
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import junit.framework.TestCase;
+import org.exoplatform.web.WebAppController;
+import org.exoplatform.web.controller.QualifiedName;
+import org.exoplatform.web.controller.metadata.DescriptorBuilder;
+import org.exoplatform.web.controller.metadata.RouteDescriptor;
+import org.exoplatform.web.controller.metadata.ControllerDescriptor;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestDescriptorBuilder extends TestCase
+{
+
+ public void testFoo() throws Exception
+ {
+
+ URL routerURL = TestDescriptorBuilder.class.getResource("router.xml");
+ XMLStreamReader routerReader = XMLInputFactory.newInstance().createXMLStreamReader(routerURL.openStream());
+ ControllerDescriptor routerDesc = new DescriptorBuilder().build(routerReader);
+
+ //
+ assertEquals('&', routerDesc.getSeparatorEscape());
+
+ //
+ Iterator<RouteDescriptor> i = routerDesc.getRoutes().iterator();
+
+ //
+ assertTrue(i.hasNext());
+ RouteDescriptor route1 = i.next();
+ assertEquals("/public/{gtn:sitetype}/{gtn:sitename}{gtn:path}", route1.getPath());
+ assertEquals(Collections.singleton(WebAppController.HANDLER_PARAM), route1.getRouteParamNames());
+ assertEquals(WebAppController.HANDLER_PARAM, route1.getRouteParam(WebAppController.HANDLER_PARAM).getQualifiedName());
+ assertEquals("portal", route1.getRouteParam(WebAppController.HANDLER_PARAM).getValue());
+ assertEquals(Collections.singleton(Names.GTN_PATH), route1.getPathParams().keySet());
+ assertEquals(Names.GTN_PATH, route1.getPathParams().get(Names.GTN_PATH).getQualifiedName());
+ assertEquals(".*", route1.getPathParams().get(Names.GTN_PATH).getPattern());
+ assertEquals(EncodingMode.FORM, route1.getPathParams().get(Names.GTN_PATH).getEncodingMode());
+
+ //
+ assertTrue(i.hasNext());
+ RouteDescriptor route2 = i.next();
+ assertEquals("/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}", route2.getPath());
+ assertEquals(Collections.singleton(WebAppController.HANDLER_PARAM), route2.getRouteParamNames());
+ assertEquals(WebAppController.HANDLER_PARAM, route2.getRouteParam(WebAppController.HANDLER_PARAM).getQualifiedName());
+ assertEquals("portal", route2.getRouteParam(WebAppController.HANDLER_PARAM).getValue());
+ assertEquals(Collections.singleton(Names.GTN_PATH), route2.getPathParams().keySet());
+ assertEquals(Names.GTN_PATH, route2.getPathParams().get(Names.GTN_PATH).getQualifiedName());
+ assertEquals(".*", route2.getPathParams().get(Names.GTN_PATH).getPattern());
+ assertEquals(EncodingMode.PRESERVE_PATH, route2.getPathParams().get(Names.GTN_PATH).getEncodingMode());
+
+ //
+ assertTrue(i.hasNext());
+ RouteDescriptor route3 = i.next();
+ assertEquals("/upload", route3.getPath());
+ assertEquals(Collections.singleton(WebAppController.HANDLER_PARAM), route3.getRouteParamNames());
+ assertEquals(WebAppController.HANDLER_PARAM, route3.getRouteParam(WebAppController.HANDLER_PARAM).getQualifiedName());
+ assertEquals("upload", route3.getRouteParam(WebAppController.HANDLER_PARAM).getValue());
+
+ //
+ assertTrue(i.hasNext());
+ RouteDescriptor route4 = i.next();
+ assertEquals("/download", route4.getPath());
+ assertEquals(Collections.singleton(WebAppController.HANDLER_PARAM), route4.getRouteParamNames());
+ assertEquals(WebAppController.HANDLER_PARAM, route4.getRouteParam(WebAppController.HANDLER_PARAM).getQualifiedName());
+ assertEquals("download", route4.getRouteParam(WebAppController.HANDLER_PARAM).getValue());
+
+ //
+ assertTrue(i.hasNext());
+ RouteDescriptor route5 = i.next();
+ assertEquals("/a", route5.getPath());
+ assertEquals(Collections.singleton(Names.A), route5.getRouteParamNames());
+ assertEquals(Names.A, route5.getRouteParam(Names.A).getQualifiedName());
+ assertEquals("a_value", route5.getRouteParam(Names.A).getValue());
+ assertEquals(1, route5.getChildren().size());
+ RouteDescriptor route5_1 = route5.getChildren().get(0);
+ assertEquals("/b", route5_1.getPath());
+ assertEquals(Collections.singleton(Names.B), route5_1.getRouteParamNames());
+ assertEquals(Names.B, route5_1.getRouteParam(Names.B).getQualifiedName());
+ assertEquals("b_value", route5_1.getRouteParam(Names.B).getValue());
+
+ //
+ assertTrue(i.hasNext());
+ RouteDescriptor route6 = i.next();
+ assertEquals("/b", route6.getPath());
+ assertEquals(new HashSet<String>(Arrays.asList("foo", "bar", "juu")), route6.getRequestParamMatchNames());
+ assertEquals(Names.FOO, route6.getRequestParam("foo").getQualifiedName());
+ assertEquals("foo", route6.getRequestParam("foo").getName());
+ assertEquals(null, route6.getRequestParam("foo").getValue());
+ assertEquals(ValueType.LITERAL, route6.getRequestParam("foo").getValueType());
+ assertEquals(ControlMode.OPTIONAL, route6.getRequestParam("foo").getControlMode());
+ assertEquals(Names.BAR, route6.getRequestParam("bar").getQualifiedName());
+ assertEquals("bar", route6.getRequestParam("bar").getName());
+ assertEquals("bar", route6.getRequestParam("bar").getValue());
+ assertEquals(ValueType.LITERAL, route6.getRequestParam("bar").getValueType());
+ assertEquals(ControlMode.OPTIONAL, route6.getRequestParam("bar").getControlMode());
+ assertEquals(Names.JUU, route6.getRequestParam("juu").getQualifiedName());
+ assertEquals("juu", route6.getRequestParam("juu").getName());
+ assertEquals("juu", route6.getRequestParam("juu").getValue());
+ assertEquals(ValueType.PATTERN, route6.getRequestParam("juu").getValueType());
+ assertEquals(ControlMode.REQUIRED, route6.getRequestParam("juu").getControlMode());
+
+ //
+ assertFalse(i.hasNext());
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDuplicateParam.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDuplicateParam.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDuplicateParam.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,263 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- */
-public class TestDuplicateParam extends AbstractTestController
-{
-
- public void testPathParamDuplicatesRequestParam() throws Exception
- {
- try
- {
- router().add(
- route("/").with(requestParam("foo").named("a")).
- sub(route("/{foo}"))).build();
- fail();
- }
- catch (MalformedRouteException e)
- {
- }
-
- //
- try
- {
- router().add(
- route("/").with(requestParam("foo").named("a")).
- sub(route("/bar").sub(route("/{foo}")))).build();
- fail();
- }
- catch (MalformedRouteException e)
- {
- }
- }
-
- public void testPathParamDuplicatesRouteParam() throws Exception
- {
- try
- {
- router().add(
- route("/").with(routeParam("foo").withValue("bar")).
- sub(route("/{foo}"))).build();
- fail();
- }
- catch (MalformedRouteException e)
- {
- }
-
- //
- try
- {
- router().add(
- route("/").with(routeParam("foo").withValue("bar")).
- sub(route("/bar").sub(route("/{foo}")))).build();
- fail();
- }
- catch (MalformedRouteException e)
- {
- }
- }
-
- public void testPathParamDuplicatesPathParam() throws Exception
- {
- try
- {
- router().add(
- route("/{foo}").
- sub(route("/{foo}"))).build();
- fail();
- }
- catch (MalformedRouteException e)
- {
- }
-
- //
- try
- {
- router().add(
- route("/{foo}").
- sub(route("/bar").sub(route("/{foo}")))).build();
- fail();
- }
- catch (MalformedRouteException e)
- {
- }
- }
-
- public void testRequestParamDuplicatesRequestParam() throws Exception
- {
- try
- {
- router().add(
- route("/").with(requestParam("foo").named("a")).
- sub(route("/bar").with(routeParam("foo").withValue("b")))).build();
- fail();
- }
- catch (MalformedRouteException e)
- {
- }
-
- //
- try
- {
- router().add(
- route("/").with(requestParam("foo").named("a")).
- sub(route("/bar").sub(route("/foo").with(routeParam("foo").withValue("b"))))).build();
- fail();
- }
- catch (MalformedRouteException e)
- {
- }
- }
-
- public void testRequestParamDuplicatesRouteParam() throws Exception
- {
- try
- {
- router().add(
- route("/").with(routeParam("foo").withValue("bar")).
- sub(route("/bar").with(routeParam("foo").withValue("b")))).build();
- fail();
- }
- catch (MalformedRouteException e)
- {
- }
-
- //
- try
- {
- router().add(
- route("/").with(routeParam("foo").withValue("bar")).
- sub(route("/bar").sub(route("/foo").with(routeParam("foo").withValue("b"))))).build();
- fail();
- }
- catch (MalformedRouteException e)
- {
- }
- }
-
- public void testRequestParamDuplicatesPathParam() throws Exception
- {
- try
- {
- router().add(
- route("/{foo}").
- sub(route("/bar").with(routeParam("foo").withValue("b")))).build();
- fail();
- }
- catch (MalformedRouteException e)
- {
- }
-
- //
- try
- {
- router().add(
- route("/{foo}").
- sub(route("/bar").sub(route("/foo").with(routeParam("foo").withValue("b"))))).build();
- fail();
- }
- catch (MalformedRouteException e)
- {
- }
- }
-
- public void testRouteParamDuplicatesRequestParam() throws Exception
- {
- try
- {
- router().add(
- route("/").with(requestParam("foo").named("a")).
- sub(route("/bar").with(routeParam("foo").withValue("b")))).build();
- fail();
- }
- catch (MalformedRouteException e)
- {
- }
-
- //
- try
- {
- router().add(
- route("/").with(requestParam("foo").named("a")).
- sub(route("/bar").sub(route("/foo").with(routeParam("foo").withValue("b"))))).build();
- fail();
- }
- catch (MalformedRouteException e)
- {
- }
- }
-
- public void testRouteParamDuplicatesRouteParam() throws Exception
- {
- try
- {
- router().add(
- route("/").with(routeParam("foo").withValue("bar")).
- sub(route("/bar").with(routeParam("foo").withValue("b")))).build();
- fail();
- }
- catch (MalformedRouteException e)
- {
- }
-
- //
- try
- {
- router().add(
- route("/").with(routeParam("foo").withValue("bar")).
- sub(route("/bar").sub(route("/foo").with(routeParam("foo").withValue("b"))))).build();
- fail();
- }
- catch (MalformedRouteException e)
- {
- }
- }
-
- public void testRouteParamDuplicatesPathParam() throws Exception
- {
- try
- {
- router().add(
- route("/{foo}").
- sub(route("/bar").with(routeParam("foo").withValue("b")))).build();
- fail();
- }
- catch (MalformedRouteException e)
- {
- }
-
- //
- try
- {
- router().add(
- route("/{foo}").
- sub(route("/bar").sub(route("/foo").with(routeParam("foo").withValue("b"))))).build();
- fail();
- }
- catch (MalformedRouteException e)
- {
- }
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDuplicateParam.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDuplicateParam.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDuplicateParam.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDuplicateParam.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,263 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public class TestDuplicateParam extends AbstractTestController
+{
+
+ public void testPathParamDuplicatesRequestParam() throws Exception
+ {
+ try
+ {
+ router().add(
+ route("/").with(requestParam("foo").named("a")).
+ sub(route("/{foo}"))).build();
+ fail();
+ }
+ catch (MalformedRouteException e)
+ {
+ }
+
+ //
+ try
+ {
+ router().add(
+ route("/").with(requestParam("foo").named("a")).
+ sub(route("/bar").sub(route("/{foo}")))).build();
+ fail();
+ }
+ catch (MalformedRouteException e)
+ {
+ }
+ }
+
+ public void testPathParamDuplicatesRouteParam() throws Exception
+ {
+ try
+ {
+ router().add(
+ route("/").with(routeParam("foo").withValue("bar")).
+ sub(route("/{foo}"))).build();
+ fail();
+ }
+ catch (MalformedRouteException e)
+ {
+ }
+
+ //
+ try
+ {
+ router().add(
+ route("/").with(routeParam("foo").withValue("bar")).
+ sub(route("/bar").sub(route("/{foo}")))).build();
+ fail();
+ }
+ catch (MalformedRouteException e)
+ {
+ }
+ }
+
+ public void testPathParamDuplicatesPathParam() throws Exception
+ {
+ try
+ {
+ router().add(
+ route("/{foo}").
+ sub(route("/{foo}"))).build();
+ fail();
+ }
+ catch (MalformedRouteException e)
+ {
+ }
+
+ //
+ try
+ {
+ router().add(
+ route("/{foo}").
+ sub(route("/bar").sub(route("/{foo}")))).build();
+ fail();
+ }
+ catch (MalformedRouteException e)
+ {
+ }
+ }
+
+ public void testRequestParamDuplicatesRequestParam() throws Exception
+ {
+ try
+ {
+ router().add(
+ route("/").with(requestParam("foo").named("a")).
+ sub(route("/bar").with(routeParam("foo").withValue("b")))).build();
+ fail();
+ }
+ catch (MalformedRouteException e)
+ {
+ }
+
+ //
+ try
+ {
+ router().add(
+ route("/").with(requestParam("foo").named("a")).
+ sub(route("/bar").sub(route("/foo").with(routeParam("foo").withValue("b"))))).build();
+ fail();
+ }
+ catch (MalformedRouteException e)
+ {
+ }
+ }
+
+ public void testRequestParamDuplicatesRouteParam() throws Exception
+ {
+ try
+ {
+ router().add(
+ route("/").with(routeParam("foo").withValue("bar")).
+ sub(route("/bar").with(routeParam("foo").withValue("b")))).build();
+ fail();
+ }
+ catch (MalformedRouteException e)
+ {
+ }
+
+ //
+ try
+ {
+ router().add(
+ route("/").with(routeParam("foo").withValue("bar")).
+ sub(route("/bar").sub(route("/foo").with(routeParam("foo").withValue("b"))))).build();
+ fail();
+ }
+ catch (MalformedRouteException e)
+ {
+ }
+ }
+
+ public void testRequestParamDuplicatesPathParam() throws Exception
+ {
+ try
+ {
+ router().add(
+ route("/{foo}").
+ sub(route("/bar").with(routeParam("foo").withValue("b")))).build();
+ fail();
+ }
+ catch (MalformedRouteException e)
+ {
+ }
+
+ //
+ try
+ {
+ router().add(
+ route("/{foo}").
+ sub(route("/bar").sub(route("/foo").with(routeParam("foo").withValue("b"))))).build();
+ fail();
+ }
+ catch (MalformedRouteException e)
+ {
+ }
+ }
+
+ public void testRouteParamDuplicatesRequestParam() throws Exception
+ {
+ try
+ {
+ router().add(
+ route("/").with(requestParam("foo").named("a")).
+ sub(route("/bar").with(routeParam("foo").withValue("b")))).build();
+ fail();
+ }
+ catch (MalformedRouteException e)
+ {
+ }
+
+ //
+ try
+ {
+ router().add(
+ route("/").with(requestParam("foo").named("a")).
+ sub(route("/bar").sub(route("/foo").with(routeParam("foo").withValue("b"))))).build();
+ fail();
+ }
+ catch (MalformedRouteException e)
+ {
+ }
+ }
+
+ public void testRouteParamDuplicatesRouteParam() throws Exception
+ {
+ try
+ {
+ router().add(
+ route("/").with(routeParam("foo").withValue("bar")).
+ sub(route("/bar").with(routeParam("foo").withValue("b")))).build();
+ fail();
+ }
+ catch (MalformedRouteException e)
+ {
+ }
+
+ //
+ try
+ {
+ router().add(
+ route("/").with(routeParam("foo").withValue("bar")).
+ sub(route("/bar").sub(route("/foo").with(routeParam("foo").withValue("b"))))).build();
+ fail();
+ }
+ catch (MalformedRouteException e)
+ {
+ }
+ }
+
+ public void testRouteParamDuplicatesPathParam() throws Exception
+ {
+ try
+ {
+ router().add(
+ route("/{foo}").
+ sub(route("/bar").with(routeParam("foo").withValue("b")))).build();
+ fail();
+ }
+ catch (MalformedRouteException e)
+ {
+ }
+
+ //
+ try
+ {
+ router().add(
+ route("/{foo}").
+ sub(route("/bar").sub(route("/foo").with(routeParam("foo").withValue("b"))))).build();
+ fail();
+ }
+ catch (MalformedRouteException e)
+ {
+ }
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestHierarchy.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestHierarchy.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestHierarchy.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.exoplatform.web.controller.QualifiedName;
-import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class TestHierarchy extends AbstractTestController
-{
-
- public void testFoo() throws Exception
- {
- Router router = router().
- add(route("/a").with(routeParam("foo").withValue("bar")).
- sub(route("/b").with(routeParam("juu").withValue("daa")))).
- build();
-
- //
- // assertEquals(Collections.singletonMap(QualifiedName.create("foo"), "bar"), router.route("/a"));
- assertNull(router.route("/a"));
-
- //
- Map<QualifiedName, String> expected = new HashMap<QualifiedName, String>();
- expected.put(Names.FOO, "bar");
- expected.put(Names.JUU, "daa");
- assertEquals(expected, router.route("/a/b"));
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestHierarchy.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestHierarchy.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestHierarchy.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestHierarchy.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.web.controller.QualifiedName;
+import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestHierarchy extends AbstractTestController
+{
+
+ public void testFoo() throws Exception
+ {
+ Router router = router().
+ add(route("/a").with(routeParam("foo").withValue("bar")).
+ sub(route("/b").with(routeParam("juu").withValue("daa")))).
+ build();
+
+ //
+ // assertEquals(Collections.singletonMap(QualifiedName.create("foo"), "bar"), router.route("/a"));
+ assertNull(router.route("/a"));
+
+ //
+ Map<QualifiedName, String> expected = new HashMap<QualifiedName, String>();
+ expected.put(Names.FOO, "bar");
+ expected.put(Names.JUU, "daa");
+ assertEquals(expected, router.route("/a/b"));
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,141 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import junit.framework.TestCase;
-import org.exoplatform.web.controller.QualifiedName;
-import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class TestLegacyPortal extends TestCase
-{
-
- /** . */
- private Router router;
-
- @Override
- protected void setUp() throws Exception
- {
- this.router = router().
- add(route("/").
- with(
- routeParam("gtn:handler").withValue("portal"),
- requestParam("gtn:componentid").named("portal:componentId"),
- requestParam("gtn:action").named("portal:action"),
- requestParam("gtn:objectid").named("portal:objectId")).
- sub(route("/public/{gtn:sitename}{gtn:path}").
- with(
- routeParam("gtn:access").withValue("public"),
- pathParam("gtn:path").matchedBy(".*").preservePath())).
- sub(route("/private/{gtn:sitename}{gtn:path}").
- with(
- routeParam("gtn:access").withValue("private"),
- pathParam("gtn:path").matchedBy(".*").preservePath()))).
- build();
- }
-
- public void testPrivateClassicComponent() throws Exception
- {
- Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
- expectedParameters.put(Names.GTN_HANDLER, "portal");
- expectedParameters.put(Names.GTN_SITENAME, "classic");
- expectedParameters.put(Names.GTN_ACCESS, "private");
- expectedParameters.put(Names.GTN_PATH, "");
- expectedParameters.put(Names.GTN_COMPONENTID, "foo");
-
- //
- assertEquals(expectedParameters, router.route("/private/classic", Collections.singletonMap("portal:componentId", new String[]{"foo"})));
- assertEquals("/private/classic?portal:componentId=foo", router.render(expectedParameters));
- }
-
- public void testPrivateClassic() throws Exception
- {
- Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
- expectedParameters.put(Names.GTN_HANDLER, "portal");
- expectedParameters.put(Names.GTN_SITENAME, "classic");
- expectedParameters.put(Names.GTN_ACCESS, "private");
- expectedParameters.put(Names.GTN_PATH, "");
-
- //
- assertEquals(expectedParameters, router.route("/private/classic"));
- assertEquals("/private/classic", router.render(expectedParameters));
- }
-
- public void testPrivateClassicSlash() throws Exception
- {
- Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
- expectedParameters.put(Names.GTN_HANDLER, "portal");
- expectedParameters.put(Names.GTN_SITENAME, "classic");
- expectedParameters.put(Names.GTN_ACCESS, "private");
- expectedParameters.put(Names.GTN_PATH, "/");
-
- //
- assertEquals(expectedParameters, router.route("/private/classic/"));
- assertEquals("/private/classic/", router.render(expectedParameters));
- }
-
- public void testPrivateClassicSlashComponent() throws Exception
- {
- Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
- expectedParameters.put(Names.GTN_HANDLER, "portal");
- expectedParameters.put(Names.GTN_SITENAME, "classic");
- expectedParameters.put(Names.GTN_ACCESS, "private");
- expectedParameters.put(Names.GTN_PATH, "/");
- expectedParameters.put(Names.GTN_COMPONENTID, "foo");
-
- //
- assertEquals(expectedParameters, router.route("/private/classic/", Collections.singletonMap("portal:componentId", new String[]{"foo"})));
- assertEquals("/private/classic/?portal:componentId=foo", router.render(expectedParameters));
- }
-
- public void testPrivateClassicHome() throws Exception
- {
- Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
- expectedParameters.put(Names.GTN_HANDLER, "portal");
- expectedParameters.put(Names.GTN_SITENAME, "classic");
- expectedParameters.put(Names.GTN_ACCESS, "private");
- expectedParameters.put(Names.GTN_PATH, "/home");
-
- //
- assertEquals(expectedParameters, router.route("/private/classic/home"));
- assertEquals("/private/classic/home", router.render(expectedParameters));
- }
-
- public void testPrivateClassicHomeComponent() throws Exception
- {
- Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
- expectedParameters.put(Names.GTN_HANDLER, "portal");
- expectedParameters.put(Names.GTN_SITENAME, "classic");
- expectedParameters.put(Names.GTN_ACCESS, "private");
- expectedParameters.put(Names.GTN_PATH, "/home");
- expectedParameters.put(Names.GTN_COMPONENTID, "foo");
-
- //
- assertEquals(expectedParameters, router.route("/private/classic/home", Collections.singletonMap("portal:componentId", new String[]{"foo"})));
- assertEquals("/private/classic/home?portal:componentId=foo", router.render(expectedParameters));
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import junit.framework.TestCase;
+import org.exoplatform.web.controller.QualifiedName;
+import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestLegacyPortal extends TestCase
+{
+
+ /** . */
+ private Router router;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ this.router = router().
+ add(route("/").
+ with(
+ routeParam("gtn:handler").withValue("portal"),
+ requestParam("gtn:componentid").named("portal:componentId"),
+ requestParam("gtn:action").named("portal:action"),
+ requestParam("gtn:objectid").named("portal:objectId")).
+ sub(route("/public/{gtn:sitename}{gtn:path}").
+ with(
+ routeParam("gtn:access").withValue("public"),
+ pathParam("gtn:path").matchedBy(".*").preservePath())).
+ sub(route("/private/{gtn:sitename}{gtn:path}").
+ with(
+ routeParam("gtn:access").withValue("private"),
+ pathParam("gtn:path").matchedBy(".*").preservePath()))).
+ build();
+ }
+
+ public void testPrivateClassicComponent() throws Exception
+ {
+ Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
+ expectedParameters.put(Names.GTN_HANDLER, "portal");
+ expectedParameters.put(Names.GTN_SITENAME, "classic");
+ expectedParameters.put(Names.GTN_ACCESS, "private");
+ expectedParameters.put(Names.GTN_PATH, "");
+ expectedParameters.put(Names.GTN_COMPONENTID, "foo");
+
+ //
+ assertEquals(expectedParameters, router.route("/private/classic", Collections.singletonMap("portal:componentId", new String[]{"foo"})));
+ assertEquals("/private/classic?portal:componentId=foo", router.render(expectedParameters));
+ }
+
+ public void testPrivateClassic() throws Exception
+ {
+ Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
+ expectedParameters.put(Names.GTN_HANDLER, "portal");
+ expectedParameters.put(Names.GTN_SITENAME, "classic");
+ expectedParameters.put(Names.GTN_ACCESS, "private");
+ expectedParameters.put(Names.GTN_PATH, "");
+
+ //
+ assertEquals(expectedParameters, router.route("/private/classic"));
+ assertEquals("/private/classic", router.render(expectedParameters));
+ }
+
+ public void testPrivateClassicSlash() throws Exception
+ {
+ Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
+ expectedParameters.put(Names.GTN_HANDLER, "portal");
+ expectedParameters.put(Names.GTN_SITENAME, "classic");
+ expectedParameters.put(Names.GTN_ACCESS, "private");
+ expectedParameters.put(Names.GTN_PATH, "/");
+
+ //
+ assertEquals(expectedParameters, router.route("/private/classic/"));
+ assertEquals("/private/classic/", router.render(expectedParameters));
+ }
+
+ public void testPrivateClassicSlashComponent() throws Exception
+ {
+ Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
+ expectedParameters.put(Names.GTN_HANDLER, "portal");
+ expectedParameters.put(Names.GTN_SITENAME, "classic");
+ expectedParameters.put(Names.GTN_ACCESS, "private");
+ expectedParameters.put(Names.GTN_PATH, "/");
+ expectedParameters.put(Names.GTN_COMPONENTID, "foo");
+
+ //
+ assertEquals(expectedParameters, router.route("/private/classic/", Collections.singletonMap("portal:componentId", new String[]{"foo"})));
+ assertEquals("/private/classic/?portal:componentId=foo", router.render(expectedParameters));
+ }
+
+ public void testPrivateClassicHome() throws Exception
+ {
+ Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
+ expectedParameters.put(Names.GTN_HANDLER, "portal");
+ expectedParameters.put(Names.GTN_SITENAME, "classic");
+ expectedParameters.put(Names.GTN_ACCESS, "private");
+ expectedParameters.put(Names.GTN_PATH, "/home");
+
+ //
+ assertEquals(expectedParameters, router.route("/private/classic/home"));
+ assertEquals("/private/classic/home", router.render(expectedParameters));
+ }
+
+ public void testPrivateClassicHomeComponent() throws Exception
+ {
+ Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
+ expectedParameters.put(Names.GTN_HANDLER, "portal");
+ expectedParameters.put(Names.GTN_SITENAME, "classic");
+ expectedParameters.put(Names.GTN_ACCESS, "private");
+ expectedParameters.put(Names.GTN_PATH, "/home");
+ expectedParameters.put(Names.GTN_COMPONENTID, "foo");
+
+ //
+ assertEquals(expectedParameters, router.route("/private/classic/home", Collections.singletonMap("portal:componentId", new String[]{"foo"})));
+ assertEquals("/private/classic/home?portal:componentId=foo", router.render(expectedParameters));
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,277 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.exoplatform.web.controller.QualifiedName;
-import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class TestMatch extends AbstractTestController
-{
-
- public void testRoot() throws Exception
- {
- Router router = router().add(route("/")).build();
-
- //
- assertNull(router.route(""));
- assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/"));
- assertNull(router.route("/a"));
- assertNull(router.route("a"));
- }
-
- public void testA() throws Exception
- {
- Router router = router().add(route("/a")).build();
-
- //
- assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/a"));
- assertNull(router.route("a"));
- assertNull(router.route("a/"));
- assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/a/"));
- assertNull(router.route(""));
- assertNull(router.route("/"));
- assertNull(router.route("/b"));
- assertNull(router.route("b"));
- assertNull(router.route("/a/b"));
- }
-
- public void testAB() throws Exception
- {
- Router router = router().add(route("/a/b")).build();
-
- //
- assertNull(router.route("a/b"));
- assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/a/b"));
- assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/a/b/"));
- assertNull(router.route("a/b/"));
- assertNull(router.route(""));
- assertNull(router.route("/"));
- assertNull(router.route("/b"));
- assertNull(router.route("b"));
- assertNull(router.route("/a/b/c"));
- }
-
- public void testParameter() throws Exception
- {
- Router router = router().add(route("/{p}")).build();
-
- //
- assertEquals(Collections.singletonMap(Names.P, "a"), router.route("/a"));
- }
-
- public void testParameterPropagationToDescendants() throws Exception
- {
- Router router = router().
- add(
- route("/").
- with(routeParam("p").withValue("a")).
- sub(route("/a")))
- .build();
-
- //
- assertEquals(Collections.singletonMap(Names.P, "a"), router.route("/a"));
- }
-
- public void testSimplePattern() throws Exception
- {
- Router router = router().add(route("/{p}").with(pathParam("p").matchedBy("a"))).build();
-
- //
- assertEquals(Collections.singletonMap(Names.P, "a"), router.route("/a"));
- assertNull(router.route("a"));
- assertNull(router.route("/ab"));
- assertNull(router.route("ab"));
- }
-
- public void testPrecedence() throws Exception
- {
- Router router = router().
- add(route("/a")).
- add(route("/{p}/b").with(pathParam("p").matchedBy("a"))).
- build();
-
- //
- assertNull(router.route("a"));
- assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/a"));
- assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/a/"));
- assertEquals(Collections.singletonMap(Names.P, "a"), router.route("/a/b"));
- }
-
- public void testTwoRules1() throws Exception
- {
- Router router = router().
- add(route("/a").with(routeParam("b").withValue("b"))).
- add(route("/a/b")).
- build();
-
- //
- assertEquals(Collections.singletonMap(Names.B, "b"), router.route("/a"));
- assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/a/b"));
- }
-
- public void testTwoRules2() throws Exception
- {
- Router router = router().
- add(route("/{a}").with(routeParam("b").withValue("b"))).
- add(route("/{a}/b")).
- build();
-
- //
- Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
- expectedParameters.put(Names.A, "a");
- expectedParameters.put(Names.B, "b");
- assertEquals(expectedParameters, router.route("/a"));
- assertEquals(Collections.singletonMap(Names.A, "a"), router.route("/a/b"));
- }
-
- public void testLang() throws Exception
- {
- Router router = router().
- add(route("/{a}b").with(pathParam("a").matchedBy("(([A-Za-z]{2})/)?").preservePath())).
- build();
-
- //
- assertEquals(Collections.singletonMap(Names.A, "fr/"), router.route("/fr/b"));
- assertEquals(Collections.singletonMap(Names.A, ""), router.route("/b"));
- }
-
- public void testOptionalParameter() throws Exception
- {
- Router router = router().
- add(route("/{a}/b").
- with(
- pathParam("a").matchedBy("a?").preservePath(),
- routeParam("b").withValue("b"))
- ).build();
-
- //
- Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
- expectedParameters.put(Names.A, "a");
- expectedParameters.put(Names.B, "b");
- assertEquals(expectedParameters, router.route("/a/b"));
- assertEquals("/a/b", router.render(expectedParameters));
-
- //
- expectedParameters.put(Names.A, "");
- assertEquals(expectedParameters, router.route("/b"));
- assertEquals("/b", router.render(expectedParameters));
- }
-
- public void testAvoidMatchingPrefix() throws Exception
- {
- Router router = router().
- add(route("/{a}/ab/c").
- with(
- pathParam("a").matchedBy("a?").preservePath()
- )
- ) .build();
-
- //
- Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
- expectedParameters.put(Names.A, "");
- assertEquals(expectedParameters, router.route("/ab/c"));
- assertEquals("/ab/c", router.render(expectedParameters));
- }
-
- public void testPartialMatching() throws Exception
- {
- Router router = router().
- add(route("/{a}").
- with(
- pathParam("a").matchedBy("abc").preservePath())
- ).build();
-
- //
- assertNull(router.route("/abcdef"));
- }
-
-/*
- public void testLookAhead() throws Exception
- {
- Router router = router().
- add(route("/{a}").
- with(
- pathParam("a").matchedBy("(.(?=/))?").preservingPath()).
- sub(route("/{b}").
- with(pathParam("b").matchedBy(".").preservingPath()))
- ).build();
-
- //
- Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
- expectedParameters.put(Names.A, "");
- expectedParameters.put(Names.B, "b");
- assertEquals(expectedParameters, router.route("/b"));
- assertEquals("/b", router.render(expectedParameters));
-
- //
- expectedParameters.put(Names.A, "a");
- assertEquals(expectedParameters, router.route("/a/b"));
- assertEquals("/a/b", router.render(expectedParameters));
- }
-*/
-
- public void testZeroOrOneFollowedBySubRoute() throws Exception
- {
- Router router = router().
- add(route("/{a}").
- with(
- pathParam("a").matchedBy("a?").preservePath()).
- sub(route("/b").
- with(
- routeParam("b").withValue("b")))
- ).build();
-
- //
- Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
- expectedParameters.put(Names.A, "a");
- expectedParameters.put(Names.B, "b");
- assertEquals(expectedParameters, router.route("/a/b"));
- assertEquals("/a/b", router.render(expectedParameters));
-
- //
- expectedParameters.put(Names.A, "");
- assertEquals(expectedParameters, router.route("/b"));
- assertEquals("/b", router.render(expectedParameters));
- }
-
- public void testMatcher() throws Exception
- {
- Router router = router().
- add(route("/{a}")).
- add(route("/a").with(routeParam("b").withValue("b_value"))).
- build();
-
- Iterator<Map<QualifiedName, String>> i = router.root.route("/a", Collections.<String, String[]>emptyMap());
- Map<QualifiedName, String> s1 = i.next();
- assertEquals(Collections.singletonMap(Names.A, "a"), s1);
- Map<QualifiedName, String> s2 = i.next();
- assertEquals(Collections.singletonMap(Names.B, "b_value"), s2);
- assertFalse(i.hasNext());
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,277 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.web.controller.QualifiedName;
+import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestMatch extends AbstractTestController
+{
+
+ public void testRoot() throws Exception
+ {
+ Router router = router().add(route("/")).build();
+
+ //
+ assertNull(router.route(""));
+ assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/"));
+ assertNull(router.route("/a"));
+ assertNull(router.route("a"));
+ }
+
+ public void testA() throws Exception
+ {
+ Router router = router().add(route("/a")).build();
+
+ //
+ assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/a"));
+ assertNull(router.route("a"));
+ assertNull(router.route("a/"));
+ assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/a/"));
+ assertNull(router.route(""));
+ assertNull(router.route("/"));
+ assertNull(router.route("/b"));
+ assertNull(router.route("b"));
+ assertNull(router.route("/a/b"));
+ }
+
+ public void testAB() throws Exception
+ {
+ Router router = router().add(route("/a/b")).build();
+
+ //
+ assertNull(router.route("a/b"));
+ assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/a/b"));
+ assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/a/b/"));
+ assertNull(router.route("a/b/"));
+ assertNull(router.route(""));
+ assertNull(router.route("/"));
+ assertNull(router.route("/b"));
+ assertNull(router.route("b"));
+ assertNull(router.route("/a/b/c"));
+ }
+
+ public void testParameter() throws Exception
+ {
+ Router router = router().add(route("/{p}")).build();
+
+ //
+ assertEquals(Collections.singletonMap(Names.P, "a"), router.route("/a"));
+ }
+
+ public void testParameterPropagationToDescendants() throws Exception
+ {
+ Router router = router().
+ add(
+ route("/").
+ with(routeParam("p").withValue("a")).
+ sub(route("/a")))
+ .build();
+
+ //
+ assertEquals(Collections.singletonMap(Names.P, "a"), router.route("/a"));
+ }
+
+ public void testSimplePattern() throws Exception
+ {
+ Router router = router().add(route("/{p}").with(pathParam("p").matchedBy("a"))).build();
+
+ //
+ assertEquals(Collections.singletonMap(Names.P, "a"), router.route("/a"));
+ assertNull(router.route("a"));
+ assertNull(router.route("/ab"));
+ assertNull(router.route("ab"));
+ }
+
+ public void testPrecedence() throws Exception
+ {
+ Router router = router().
+ add(route("/a")).
+ add(route("/{p}/b").with(pathParam("p").matchedBy("a"))).
+ build();
+
+ //
+ assertNull(router.route("a"));
+ assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/a"));
+ assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/a/"));
+ assertEquals(Collections.singletonMap(Names.P, "a"), router.route("/a/b"));
+ }
+
+ public void testTwoRules1() throws Exception
+ {
+ Router router = router().
+ add(route("/a").with(routeParam("b").withValue("b"))).
+ add(route("/a/b")).
+ build();
+
+ //
+ assertEquals(Collections.singletonMap(Names.B, "b"), router.route("/a"));
+ assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/a/b"));
+ }
+
+ public void testTwoRules2() throws Exception
+ {
+ Router router = router().
+ add(route("/{a}").with(routeParam("b").withValue("b"))).
+ add(route("/{a}/b")).
+ build();
+
+ //
+ Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
+ expectedParameters.put(Names.A, "a");
+ expectedParameters.put(Names.B, "b");
+ assertEquals(expectedParameters, router.route("/a"));
+ assertEquals(Collections.singletonMap(Names.A, "a"), router.route("/a/b"));
+ }
+
+ public void testLang() throws Exception
+ {
+ Router router = router().
+ add(route("/{a}b").with(pathParam("a").matchedBy("(([A-Za-z]{2})/)?").preservePath())).
+ build();
+
+ //
+ assertEquals(Collections.singletonMap(Names.A, "fr/"), router.route("/fr/b"));
+ assertEquals(Collections.singletonMap(Names.A, ""), router.route("/b"));
+ }
+
+ public void testOptionalParameter() throws Exception
+ {
+ Router router = router().
+ add(route("/{a}/b").
+ with(
+ pathParam("a").matchedBy("a?").preservePath(),
+ routeParam("b").withValue("b"))
+ ).build();
+
+ //
+ Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
+ expectedParameters.put(Names.A, "a");
+ expectedParameters.put(Names.B, "b");
+ assertEquals(expectedParameters, router.route("/a/b"));
+ assertEquals("/a/b", router.render(expectedParameters));
+
+ //
+ expectedParameters.put(Names.A, "");
+ assertEquals(expectedParameters, router.route("/b"));
+ assertEquals("/b", router.render(expectedParameters));
+ }
+
+ public void testAvoidMatchingPrefix() throws Exception
+ {
+ Router router = router().
+ add(route("/{a}/ab/c").
+ with(
+ pathParam("a").matchedBy("a?").preservePath()
+ )
+ ) .build();
+
+ //
+ Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
+ expectedParameters.put(Names.A, "");
+ assertEquals(expectedParameters, router.route("/ab/c"));
+ assertEquals("/ab/c", router.render(expectedParameters));
+ }
+
+ public void testPartialMatching() throws Exception
+ {
+ Router router = router().
+ add(route("/{a}").
+ with(
+ pathParam("a").matchedBy("abc").preservePath())
+ ).build();
+
+ //
+ assertNull(router.route("/abcdef"));
+ }
+
+/*
+ public void testLookAhead() throws Exception
+ {
+ Router router = router().
+ add(route("/{a}").
+ with(
+ pathParam("a").matchedBy("(.(?=/))?").preservingPath()).
+ sub(route("/{b}").
+ with(pathParam("b").matchedBy(".").preservingPath()))
+ ).build();
+
+ //
+ Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
+ expectedParameters.put(Names.A, "");
+ expectedParameters.put(Names.B, "b");
+ assertEquals(expectedParameters, router.route("/b"));
+ assertEquals("/b", router.render(expectedParameters));
+
+ //
+ expectedParameters.put(Names.A, "a");
+ assertEquals(expectedParameters, router.route("/a/b"));
+ assertEquals("/a/b", router.render(expectedParameters));
+ }
+*/
+
+ public void testZeroOrOneFollowedBySubRoute() throws Exception
+ {
+ Router router = router().
+ add(route("/{a}").
+ with(
+ pathParam("a").matchedBy("a?").preservePath()).
+ sub(route("/b").
+ with(
+ routeParam("b").withValue("b")))
+ ).build();
+
+ //
+ Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
+ expectedParameters.put(Names.A, "a");
+ expectedParameters.put(Names.B, "b");
+ assertEquals(expectedParameters, router.route("/a/b"));
+ assertEquals("/a/b", router.render(expectedParameters));
+
+ //
+ expectedParameters.put(Names.A, "");
+ assertEquals(expectedParameters, router.route("/b"));
+ assertEquals("/b", router.render(expectedParameters));
+ }
+
+ public void testMatcher() throws Exception
+ {
+ Router router = router().
+ add(route("/{a}")).
+ add(route("/a").with(routeParam("b").withValue("b_value"))).
+ build();
+
+ Iterator<Map<QualifiedName, String>> i = router.root.route("/a", Collections.<String, String[]>emptyMap());
+ Map<QualifiedName, String> s1 = i.next();
+ assertEquals(Collections.singletonMap(Names.A, "a"), s1);
+ Map<QualifiedName, String> s2 = i.next();
+ assertEquals(Collections.singletonMap(Names.B, "b_value"), s2);
+ assertFalse(i.hasNext());
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPath.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPath.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPath.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,145 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import junit.framework.TestCase;
-import org.exoplatform.commons.utils.CharEncoder;
-
-import java.io.UnsupportedEncodingException;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- */
-public class TestPath extends TestCase
-{
-
- public void testFoo() throws Exception
- {
- assertEquals("", Path.parse("").getValue());
- assertEquals("a", Path.parse("a").getValue());
- assertEquals("?", Path.parse("%3F").getValue());
- assertEquals(" ", Path.parse("%20").getValue());
- assertEquals("? ", Path.parse("%3F%20").getValue());
-
- //
- Path p2 = Path.parse("_");
- assertEquals("_", p2.getValue());
- assertEquals(0, p2.getRawStart(0));
- assertEquals(1, p2.getRawEnd(0));
- assertEquals(1, p2.getRawLength(0));
-
- //
- Path p3 = Path.parse("a%5Fb%5Fc");
- assertEquals("a_b_c", p3.getValue());
- assertEquals(0, p3.getRawStart(0));
- assertEquals(1, p3.getRawEnd(0));
- assertEquals(1, p3.getRawLength(0));
- assertEquals(1, p3.getRawStart(1));
- assertEquals(4, p3.getRawEnd(1));
- assertEquals(3, p3.getRawLength(1));
- assertEquals(4, p3.getRawStart(2));
- assertEquals(5, p3.getRawEnd(2));
- assertEquals(1, p3.getRawLength(2));
- assertEquals(5, p3.getRawStart(3));
- assertEquals(8, p3.getRawEnd(3));
- assertEquals(3, p3.getRawLength(3));
- assertEquals(8, p3.getRawStart(4));
- assertEquals(9, p3.getRawEnd(4));
- assertEquals(1, p3.getRawLength(4));
-
- //
- Path p4 = p3.subPath(2);
- assertEquals(0, p4.getRawStart(0));
- assertEquals(1, p4.getRawEnd(0));
- assertEquals(1, p4.getRawLength(0));
-
- assertEquals(1, p4.getRawStart(1));
- assertEquals(4, p4.getRawEnd(1));
- assertEquals(3, p4.getRawLength(1));
-
- assertEquals(4, p4.getRawStart(2));
- assertEquals(5, p4.getRawEnd(2));
- assertEquals(1, p4.getRawLength(2));
- }
-
- public void testOtherChar()
- {
- assertInvalid("é");
- }
-
- public void testPercent1()
- {
- Path path = Path.parse("%5F");
- assertEquals("_", path.getValue());
- assertEquals(0, path.getRawStart(0));
- assertEquals(3, path.getRawEnd(0));
- assertEquals(3, path.getRawLength(0));
- }
-
- public void testPercent2()
- {
- Path path = Path.parse("%C2%A2");
- assertEquals(1, path.length());
- assertEquals('\u00A2', path.charAt(0));
- assertEquals(0, path.getRawStart(0));
- assertEquals(6, path.getRawEnd(0));
- assertEquals(6, path.getRawLength(0));
- }
-
- public void testPercent3()
- {
- Path path = Path.parse("%E2%82%AC");
- assertEquals(1, path.length());
- assertEquals('\u20AC', path.charAt(0));
- assertEquals(0, path.getRawStart(0));
- assertEquals(9, path.getRawEnd(0));
- assertEquals(9, path.getRawLength(0));
- }
-
- public void testInvalid()
- {
- // Not enough chars
- assertInvalid("%");
-
- // Third char should be hexadecimal value
- assertInvalid("%1z");
-
- // '_' should be '%'
- assertInvalid("%C2_A2");
-
- // Not enough chars
- assertInvalid("%C2%A");
-
- // Corrupted prefix 0xFF is illegal
- assertInvalid("%FF");
- }
-
- private void assertInvalid(String s)
- {
- try
- {
- Path.parse(s);
- fail("Was expecting " + s + " to be invalid");
- }
- catch (IllegalArgumentException ignore)
- {
- }
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPath.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPath.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPath.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPath.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import junit.framework.TestCase;
+import org.exoplatform.commons.utils.CharEncoder;
+
+import java.io.UnsupportedEncodingException;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public class TestPath extends TestCase
+{
+
+ public void testFoo() throws Exception
+ {
+ assertEquals("", Path.parse("").getValue());
+ assertEquals("a", Path.parse("a").getValue());
+ assertEquals("?", Path.parse("%3F").getValue());
+ assertEquals(" ", Path.parse("%20").getValue());
+ assertEquals("? ", Path.parse("%3F%20").getValue());
+
+ //
+ Path p2 = Path.parse("_");
+ assertEquals("_", p2.getValue());
+ assertEquals(0, p2.getRawStart(0));
+ assertEquals(1, p2.getRawEnd(0));
+ assertEquals(1, p2.getRawLength(0));
+
+ //
+ Path p3 = Path.parse("a%5Fb%5Fc");
+ assertEquals("a_b_c", p3.getValue());
+ assertEquals(0, p3.getRawStart(0));
+ assertEquals(1, p3.getRawEnd(0));
+ assertEquals(1, p3.getRawLength(0));
+ assertEquals(1, p3.getRawStart(1));
+ assertEquals(4, p3.getRawEnd(1));
+ assertEquals(3, p3.getRawLength(1));
+ assertEquals(4, p3.getRawStart(2));
+ assertEquals(5, p3.getRawEnd(2));
+ assertEquals(1, p3.getRawLength(2));
+ assertEquals(5, p3.getRawStart(3));
+ assertEquals(8, p3.getRawEnd(3));
+ assertEquals(3, p3.getRawLength(3));
+ assertEquals(8, p3.getRawStart(4));
+ assertEquals(9, p3.getRawEnd(4));
+ assertEquals(1, p3.getRawLength(4));
+
+ //
+ Path p4 = p3.subPath(2);
+ assertEquals(0, p4.getRawStart(0));
+ assertEquals(1, p4.getRawEnd(0));
+ assertEquals(1, p4.getRawLength(0));
+
+ assertEquals(1, p4.getRawStart(1));
+ assertEquals(4, p4.getRawEnd(1));
+ assertEquals(3, p4.getRawLength(1));
+
+ assertEquals(4, p4.getRawStart(2));
+ assertEquals(5, p4.getRawEnd(2));
+ assertEquals(1, p4.getRawLength(2));
+ }
+
+ public void testOtherChar()
+ {
+ assertInvalid("é");
+ }
+
+ public void testPercent1()
+ {
+ Path path = Path.parse("%5F");
+ assertEquals("_", path.getValue());
+ assertEquals(0, path.getRawStart(0));
+ assertEquals(3, path.getRawEnd(0));
+ assertEquals(3, path.getRawLength(0));
+ }
+
+ public void testPercent2()
+ {
+ Path path = Path.parse("%C2%A2");
+ assertEquals(1, path.length());
+ assertEquals('\u00A2', path.charAt(0));
+ assertEquals(0, path.getRawStart(0));
+ assertEquals(6, path.getRawEnd(0));
+ assertEquals(6, path.getRawLength(0));
+ }
+
+ public void testPercent3()
+ {
+ Path path = Path.parse("%E2%82%AC");
+ assertEquals(1, path.length());
+ assertEquals('\u20AC', path.charAt(0));
+ assertEquals(0, path.getRawStart(0));
+ assertEquals(9, path.getRawEnd(0));
+ assertEquals(9, path.getRawLength(0));
+ }
+
+ public void testInvalid()
+ {
+ // Not enough chars
+ assertInvalid("%");
+
+ // Third char should be hexadecimal value
+ assertInvalid("%1z");
+
+ // '_' should be '%'
+ assertInvalid("%C2_A2");
+
+ // Not enough chars
+ assertInvalid("%C2%A");
+
+ // Corrupted prefix 0xFF is illegal
+ assertInvalid("%FF");
+ }
+
+ private void assertInvalid(String s)
+ {
+ try
+ {
+ Path.parse(s);
+ fail("Was expecting " + s + " to be invalid");
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathEncoding.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathEncoding.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathEncoding.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.exoplatform.web.controller.QualifiedName;
-import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
-
-import java.util.Collections;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class TestPathEncoding extends AbstractTestController
-{
-
- public void testSegment1() throws Exception
- {
- Router router = router().add(route("/?")).build();
- assertEquals("/%3F", router.render(Collections.<QualifiedName, String>emptyMap()));
- }
-
- public void testSegment2() throws Exception
- {
- Router router = router().add(route("/?{p}?")).build();
- assertEquals("/%3Fa%3F", router.render(Collections.singletonMap(Names.P, "a")));
- }
-
- public void testSegment3() throws Exception
- {
- Router router = router().add(route("/{p}")).build();
- assertEquals("/%C2%A2", router.render(Collections.singletonMap(Names.P, "\u00A2")));
- }
-
- public void testParamDefaultForm() throws Exception
- {
- Router router = router().add(route("/{p}").with(pathParam("p").matchedBy(".+"))).build();
-
- // Route
- assertEquals(Collections.singletonMap(Names.P, "/"), router.route("/_"));
- assertEquals(Collections.singletonMap(Names.P, "_"), router.route("/%5F"));
- assertEquals(Collections.singletonMap(Names.P, "_/"), router.route("/%5F_"));
- assertEquals(Collections.singletonMap(Names.P, "/_"), router.route("/_%5F"));
- assertEquals(Collections.singletonMap(Names.P, "?"), router.route("/%3F"));
-
- // Render
- assertEquals("/_", router.render(Collections.singletonMap(Names.P, "/")));
- assertEquals("/%5F", router.render(Collections.singletonMap(Names.P, "_")));
- assertEquals("/%5F_", router.render(Collections.singletonMap(Names.P, "_/")));
- assertEquals("/_%5F", router.render(Collections.singletonMap(Names.P, "/_")));
- assertEquals("/%3F", router.render(Collections.singletonMap(Names.P, "?")));
- }
-
- public void testAlternativeSepartorEscape() throws Exception
- {
- Router router = router().separatorEscapedBy(':').add(route("/{p}").with(pathParam("p").matchedBy(".+"))).build();
-
- // Route
- assertEquals(Collections.singletonMap(Names.P, "/"), router.route("/:"));
- assertEquals(Collections.singletonMap(Names.P, "_"), router.route("/_"));
- assertEquals(Collections.singletonMap(Names.P, ":"), router.route("/%3A"));
-
- // Render
- assertEquals("/:", router.render(Collections.singletonMap(Names.P, "/")));
- assertEquals("/_", router.render(Collections.singletonMap(Names.P, "_")));
- assertEquals("/%3A", router.render(Collections.singletonMap(Names.P, ":")));
- }
-
- public void testBug() throws Exception
- {
- Router router = router().add(route("/{p}").with(pathParam("p").matchedBy("[^_]+"))).build();
-
- // This is a *known* bug
- assertNull(router.route("/_"));
-
- // This is expected
- assertEquals("/_", router.render(Collections.singletonMap(Names.P, "/")));
-
- // This is expected
- assertNull(router.route("/%5F"));
- assertEquals("", router.render(Collections.singletonMap(Names.P, "_")));
- }
-
- public void testParamPreservePath() throws Exception
- {
- Router router = router().add(route("/{p}").with(pathParam("p").matchedBy("[^/]+").preservePath())).build();
-
- // Route
- assertEquals(Collections.singletonMap(Names.P, "_"), router.route("/_"));
- assertNull(router.route("//"));
-
- // Render
- assertEquals("", router.render(Collections.singletonMap(Names.P, "/")));
- }
-
- public void testD() throws Exception
- {
- Router router = router().
- add(route("/{p}").
- with(pathParam("p").matchedBy("/[a-z]+/[a-z]+/?"))).
- build();
-
- // Route
- assertEquals(Collections.singletonMap(Names.P, "/platform/administrator"), router.route("/_platform_administrator"));
- assertEquals(Collections.singletonMap(Names.P, "/platform/administrator"), router.route("/_platform_administrator/"));
- assertEquals(Collections.singletonMap(Names.P, "/platform/administrator/"), router.route("/_platform_administrator_"));
- assertEquals(Collections.singletonMap(Names.P, "/platform/administrator/"), router.route("/_platform_administrator_/"));
-
- // Render
- assertEquals("/_platform_administrator", router.render(Collections.singletonMap(Names.P, "/platform/administrator")));
- assertEquals("/_platform_administrator_", router.render(Collections.singletonMap(Names.P, "/platform/administrator/")));
- assertEquals("", router.render(Collections.singletonMap(Names.P, "/platform/administrator//")));
- }
-
- public void testWildcardPathParamWithPreservePath() throws Exception
- {
- Router router = router().add(route("/{p}").with(pathParam("p").matchedBy(".*").preservePath())).build();
-
- // Render
- assertEquals("/", router.render(Collections.singletonMap(Names.P, "")));
- assertEquals("//", router.render(Collections.singletonMap(Names.P, "/")));
- assertEquals("/a", router.render(Collections.singletonMap(Names.P, "a")));
- assertEquals("/a/b", router.render(Collections.singletonMap(Names.P, "a/b")));
-
- // Route
- assertEquals(Collections.singletonMap(Names.P, ""), router.route("/"));
- assertEquals(Collections.singletonMap(Names.P, "/"), router.route("//"));
- assertEquals(Collections.singletonMap(Names.P, "a"), router.route("/a"));
- assertEquals(Collections.singletonMap(Names.P, "a/b"), router.route("/a/b"));
- }
-
- public void testWildcardParamPathWithDefaultForm() throws Exception
- {
- Router router = router().add(route("/{p}").with(pathParam("p").matchedBy(".*"))).build();
-
- //
- assertEquals("/_", router.render(Collections.singletonMap(Names.P, "/")));
- }
-
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathEncoding.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathEncoding.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathEncoding.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathEncoding.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.web.controller.QualifiedName;
+import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
+
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestPathEncoding extends AbstractTestController
+{
+
+ public void testSegment1() throws Exception
+ {
+ Router router = router().add(route("/?")).build();
+ assertEquals("/%3F", router.render(Collections.<QualifiedName, String>emptyMap()));
+ }
+
+ public void testSegment2() throws Exception
+ {
+ Router router = router().add(route("/?{p}?")).build();
+ assertEquals("/%3Fa%3F", router.render(Collections.singletonMap(Names.P, "a")));
+ }
+
+ public void testSegment3() throws Exception
+ {
+ Router router = router().add(route("/{p}")).build();
+ assertEquals("/%C2%A2", router.render(Collections.singletonMap(Names.P, "\u00A2")));
+ }
+
+ public void testParamDefaultForm() throws Exception
+ {
+ Router router = router().add(route("/{p}").with(pathParam("p").matchedBy(".+"))).build();
+
+ // Route
+ assertEquals(Collections.singletonMap(Names.P, "/"), router.route("/_"));
+ assertEquals(Collections.singletonMap(Names.P, "_"), router.route("/%5F"));
+ assertEquals(Collections.singletonMap(Names.P, "_/"), router.route("/%5F_"));
+ assertEquals(Collections.singletonMap(Names.P, "/_"), router.route("/_%5F"));
+ assertEquals(Collections.singletonMap(Names.P, "?"), router.route("/%3F"));
+
+ // Render
+ assertEquals("/_", router.render(Collections.singletonMap(Names.P, "/")));
+ assertEquals("/%5F", router.render(Collections.singletonMap(Names.P, "_")));
+ assertEquals("/%5F_", router.render(Collections.singletonMap(Names.P, "_/")));
+ assertEquals("/_%5F", router.render(Collections.singletonMap(Names.P, "/_")));
+ assertEquals("/%3F", router.render(Collections.singletonMap(Names.P, "?")));
+ }
+
+ public void testAlternativeSepartorEscape() throws Exception
+ {
+ Router router = router().separatorEscapedBy(':').add(route("/{p}").with(pathParam("p").matchedBy(".+"))).build();
+
+ // Route
+ assertEquals(Collections.singletonMap(Names.P, "/"), router.route("/:"));
+ assertEquals(Collections.singletonMap(Names.P, "_"), router.route("/_"));
+ assertEquals(Collections.singletonMap(Names.P, ":"), router.route("/%3A"));
+
+ // Render
+ assertEquals("/:", router.render(Collections.singletonMap(Names.P, "/")));
+ assertEquals("/_", router.render(Collections.singletonMap(Names.P, "_")));
+ assertEquals("/%3A", router.render(Collections.singletonMap(Names.P, ":")));
+ }
+
+ public void testBug() throws Exception
+ {
+ Router router = router().add(route("/{p}").with(pathParam("p").matchedBy("[^_]+"))).build();
+
+ // This is a *known* bug
+ assertNull(router.route("/_"));
+
+ // This is expected
+ assertEquals("/_", router.render(Collections.singletonMap(Names.P, "/")));
+
+ // This is expected
+ assertNull(router.route("/%5F"));
+ assertEquals("", router.render(Collections.singletonMap(Names.P, "_")));
+ }
+
+ public void testParamPreservePath() throws Exception
+ {
+ Router router = router().add(route("/{p}").with(pathParam("p").matchedBy("[^/]+").preservePath())).build();
+
+ // Route
+ assertEquals(Collections.singletonMap(Names.P, "_"), router.route("/_"));
+ assertNull(router.route("//"));
+
+ // Render
+ assertEquals("", router.render(Collections.singletonMap(Names.P, "/")));
+ }
+
+ public void testD() throws Exception
+ {
+ Router router = router().
+ add(route("/{p}").
+ with(pathParam("p").matchedBy("/[a-z]+/[a-z]+/?"))).
+ build();
+
+ // Route
+ assertEquals(Collections.singletonMap(Names.P, "/platform/administrator"), router.route("/_platform_administrator"));
+ assertEquals(Collections.singletonMap(Names.P, "/platform/administrator"), router.route("/_platform_administrator/"));
+ assertEquals(Collections.singletonMap(Names.P, "/platform/administrator/"), router.route("/_platform_administrator_"));
+ assertEquals(Collections.singletonMap(Names.P, "/platform/administrator/"), router.route("/_platform_administrator_/"));
+
+ // Render
+ assertEquals("/_platform_administrator", router.render(Collections.singletonMap(Names.P, "/platform/administrator")));
+ assertEquals("/_platform_administrator_", router.render(Collections.singletonMap(Names.P, "/platform/administrator/")));
+ assertEquals("", router.render(Collections.singletonMap(Names.P, "/platform/administrator//")));
+ }
+
+ public void testWildcardPathParamWithPreservePath() throws Exception
+ {
+ Router router = router().add(route("/{p}").with(pathParam("p").matchedBy(".*").preservePath())).build();
+
+ // Render
+ assertEquals("/", router.render(Collections.singletonMap(Names.P, "")));
+ assertEquals("//", router.render(Collections.singletonMap(Names.P, "/")));
+ assertEquals("/a", router.render(Collections.singletonMap(Names.P, "a")));
+ assertEquals("/a/b", router.render(Collections.singletonMap(Names.P, "a/b")));
+
+ // Route
+ assertEquals(Collections.singletonMap(Names.P, ""), router.route("/"));
+ assertEquals(Collections.singletonMap(Names.P, "/"), router.route("//"));
+ assertEquals(Collections.singletonMap(Names.P, "a"), router.route("/a"));
+ assertEquals(Collections.singletonMap(Names.P, "a/b"), router.route("/a/b"));
+ }
+
+ public void testWildcardParamPathWithDefaultForm() throws Exception
+ {
+ Router router = router().add(route("/{p}").with(pathParam("p").matchedBy(".*"))).build();
+
+ //
+ assertEquals("/_", router.render(Collections.singletonMap(Names.P, "/")));
+ }
+
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPatternBuilder.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPatternBuilder.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPatternBuilder.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import junit.framework.TestCase;
-
-import java.util.regex.Pattern;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class TestPatternBuilder extends TestCase
-{
-
- public void testEscapeReservedChar() throws Exception
- {
- assertLiteral('^');
- assertLiteral('*');
- assertLiteral('$');
- assertLiteral('[');
- assertLiteral(']');
- assertLiteral('.');
- assertLiteral('|');
- assertLiteral('+');
- assertLiteral('(');
- assertLiteral(')');
- assertLiteral('?');
- }
-
- private void assertLiteral(char c)
- {
- PatternBuilder pb = new PatternBuilder();
- pb.expr("^");
- pb.literal(c);
- pb.expr("$");
- Pattern pattern = pb.build();
- assertTrue(pattern.matcher(Character.toString(c)).matches());
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPatternBuilder.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPatternBuilder.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPatternBuilder.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPatternBuilder.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import junit.framework.TestCase;
+
+import java.util.regex.Pattern;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestPatternBuilder extends TestCase
+{
+
+ public void testEscapeReservedChar() throws Exception
+ {
+ assertLiteral('^');
+ assertLiteral('*');
+ assertLiteral('$');
+ assertLiteral('[');
+ assertLiteral(']');
+ assertLiteral('.');
+ assertLiteral('|');
+ assertLiteral('+');
+ assertLiteral('(');
+ assertLiteral(')');
+ assertLiteral('?');
+ }
+
+ private void assertLiteral(char c)
+ {
+ PatternBuilder pb = new PatternBuilder();
+ pb.expr("^");
+ pb.literal(c);
+ pb.expr("$");
+ Pattern pattern = pb.build();
+ assertTrue(pattern.matcher(Character.toString(c)).matches());
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortal.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortal.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortal.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.exoplatform.web.controller.QualifiedName;
-
-import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class TestPortal extends AbstractTestController
-{
-
- /** . */
- public static final String LANG_PATTERN = "([A-Za-z]{2}(-[A-Za-z]{2})?)?";
-
- public void testLanguage1() throws Exception
- {
- Router router = router().add(
- route("/public/{gtn:lang}").
- with(pathParam("gtn:lang").matchedBy(LANG_PATTERN).preservePath())).
- build();
-
- //
- assertEquals(Collections.singletonMap(Names.GTN_LANG, ""), router.route("/public"));
- assertEquals(Collections.singletonMap(Names.GTN_LANG, "fr"), router.route("/public/fr"));
- assertEquals(Collections.singletonMap(Names.GTN_LANG, "fr-FR"), router.route("/public/fr-FR"));
- }
-
- public void testLanguage2() throws Exception
- {
- Router router = router().
- add(route("/{gtn:lang}/public").
- with(pathParam("gtn:lang").matchedBy(LANG_PATTERN))).
- build();
-
- //
- assertEquals(Collections.singletonMap(Names.GTN_LANG, ""), router.route("/public"));
- assertNull(router.route("/f/public"));
- assertEquals(Collections.singletonMap(Names.GTN_LANG, "fr"), router.route("/fr/public"));
- assertEquals("/public", router.render(Collections.singletonMap(Names.GTN_LANG, "")));
- assertEquals("", router.render(Collections.singletonMap(Names.GTN_LANG, "f")));
- assertEquals("/fr/public", router.render(Collections.singletonMap(Names.GTN_LANG, "fr")));
- assertEquals("/fr-FR/public", router.render(Collections.singletonMap(Names.GTN_LANG, "fr-FR")));
- }
-
- public void testLanguage3() throws Exception
- {
- Router router = router().
- add(route("/public/{gtn:lang}/{gtn:sitename}{gtn:path}")
- .with(pathParam("gtn:lang").matchedBy(LANG_PATTERN).preservePath())
- .with(pathParam("gtn:path").matchedBy(".*").preservePath())).
- build();
-
- Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
- expectedParameters.put(Names.GTN_LANG, "fr");
- expectedParameters.put(Names.GTN_SITENAME, "classic");
- expectedParameters.put(Names.GTN_PATH, "/home");
-
- //
-// assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/public"));
- assertEquals(expectedParameters, router.route("/public/fr/classic/home"));
-
- expectedParameters.put(Names.GTN_PATH, "");
- assertEquals(expectedParameters, router.route("/public/fr/classic"));
-
- expectedParameters.put(Names.GTN_LANG, "");
- expectedParameters.put(Names.GTN_PATH, "/home");
- assertEquals(expectedParameters, router.route("/public/classic/home"));
- }
-
- public void testDuplicateRouteWithDifferentRouteParam() throws Exception
- {
- Router router = router().add(
- route("/").with(routeParam("foo").withValue("foo_1")).with(requestParam("bar").named("bar").matchedByLiteral("bar_value")),
- route("/").with(routeParam("foo").withValue("foo_2"))
- ).build();
-
- //
- Map<QualifiedName, String> expected = new HashMap<QualifiedName, String>();
- expected.put(Names.FOO, "foo_1");
- expected.put(Names.BAR, "bar_value");
- assertEquals(expected, router.route("/", Collections.singletonMap("bar", new String[]{"bar_value"})));
- URIHelper rc = new URIHelper();
- router.render(expected, rc.writer);
- assertEquals("/", rc.getPath());
- assertMapEquals(Collections.<String, String[]>singletonMap("bar", new String[]{"bar_value"}), rc.getQueryParams());
-
- //
- expected = new HashMap<QualifiedName, String>();
- expected.put(Names.FOO, "foo_2");
- assertEquals(expected, router.route("/", Collections.singletonMap("bar", new String[]{"flabbergast"})));
- rc = new URIHelper();
- router.render(expected, rc.writer);
- assertEquals("/", rc.getPath());
- assertEquals(null, rc.getQueryParams());
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortal.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortal.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortal.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortal.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.web.controller.QualifiedName;
+
+import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestPortal extends AbstractTestController
+{
+
+ /** . */
+ public static final String LANG_PATTERN = "([A-Za-z]{2}(-[A-Za-z]{2})?)?";
+
+ public void testLanguage1() throws Exception
+ {
+ Router router = router().add(
+ route("/public/{gtn:lang}").
+ with(pathParam("gtn:lang").matchedBy(LANG_PATTERN).preservePath())).
+ build();
+
+ //
+ assertEquals(Collections.singletonMap(Names.GTN_LANG, ""), router.route("/public"));
+ assertEquals(Collections.singletonMap(Names.GTN_LANG, "fr"), router.route("/public/fr"));
+ assertEquals(Collections.singletonMap(Names.GTN_LANG, "fr-FR"), router.route("/public/fr-FR"));
+ }
+
+ public void testLanguage2() throws Exception
+ {
+ Router router = router().
+ add(route("/{gtn:lang}/public").
+ with(pathParam("gtn:lang").matchedBy(LANG_PATTERN))).
+ build();
+
+ //
+ assertEquals(Collections.singletonMap(Names.GTN_LANG, ""), router.route("/public"));
+ assertNull(router.route("/f/public"));
+ assertEquals(Collections.singletonMap(Names.GTN_LANG, "fr"), router.route("/fr/public"));
+ assertEquals("/public", router.render(Collections.singletonMap(Names.GTN_LANG, "")));
+ assertEquals("", router.render(Collections.singletonMap(Names.GTN_LANG, "f")));
+ assertEquals("/fr/public", router.render(Collections.singletonMap(Names.GTN_LANG, "fr")));
+ assertEquals("/fr-FR/public", router.render(Collections.singletonMap(Names.GTN_LANG, "fr-FR")));
+ }
+
+ public void testLanguage3() throws Exception
+ {
+ Router router = router().
+ add(route("/public/{gtn:lang}/{gtn:sitename}{gtn:path}")
+ .with(pathParam("gtn:lang").matchedBy(LANG_PATTERN).preservePath())
+ .with(pathParam("gtn:path").matchedBy(".*").preservePath())).
+ build();
+
+ Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
+ expectedParameters.put(Names.GTN_LANG, "fr");
+ expectedParameters.put(Names.GTN_SITENAME, "classic");
+ expectedParameters.put(Names.GTN_PATH, "/home");
+
+ //
+// assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/public"));
+ assertEquals(expectedParameters, router.route("/public/fr/classic/home"));
+
+ expectedParameters.put(Names.GTN_PATH, "");
+ assertEquals(expectedParameters, router.route("/public/fr/classic"));
+
+ expectedParameters.put(Names.GTN_LANG, "");
+ expectedParameters.put(Names.GTN_PATH, "/home");
+ assertEquals(expectedParameters, router.route("/public/classic/home"));
+ }
+
+ public void testDuplicateRouteWithDifferentRouteParam() throws Exception
+ {
+ Router router = router().add(
+ route("/").with(routeParam("foo").withValue("foo_1")).with(requestParam("bar").named("bar").matchedByLiteral("bar_value")),
+ route("/").with(routeParam("foo").withValue("foo_2"))
+ ).build();
+
+ //
+ Map<QualifiedName, String> expected = new HashMap<QualifiedName, String>();
+ expected.put(Names.FOO, "foo_1");
+ expected.put(Names.BAR, "bar_value");
+ assertEquals(expected, router.route("/", Collections.singletonMap("bar", new String[]{"bar_value"})));
+ URIHelper rc = new URIHelper();
+ router.render(expected, rc.writer);
+ assertEquals("/", rc.getPath());
+ assertMapEquals(Collections.<String, String[]>singletonMap("bar", new String[]{"bar_value"}), rc.getQueryParams());
+
+ //
+ expected = new HashMap<QualifiedName, String>();
+ expected.put(Names.FOO, "foo_2");
+ assertEquals(expected, router.route("/", Collections.singletonMap("bar", new String[]{"flabbergast"})));
+ rc = new URIHelper();
+ router.render(expected, rc.writer);
+ assertEquals("/", rc.getPath());
+ assertEquals(null, rc.getQueryParams());
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.exoplatform.web.controller.QualifiedName;
-import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class TestPortalConfiguration extends AbstractTestController
-{
-
- /** . */
- private Router router;
-
- @Override
- protected void setUp() throws Exception
- {
- this.router = router().
- add(
- route("/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}").
- with(
- routeParam("gtn:handler").withValue("site"),
- routeParam("gtn:handler").withValue("site"),
- requestParam("gtn:componentid").named("portal:componentId"),
- pathParam("gtn:path").matchedBy(".*").preservePath()),
- route("/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}").
- with(
- routeParam("gtn:handler").withValue("site"),
- pathParam("gtn:path").matchedBy(".*").preservePath()),
- route("/groups/{gtn:sitetype}/{gtn:sitename}{gtn:path}").
- with(
- routeParam("gtn:handler").withValue("site"),
- pathParam("gtn:path").matchedBy(".*").preservePath()),
- route("/users/{gtn:sitetype}/{gtn:sitename}{gtn:path}").
- with(
- routeParam("gtn:handler").withValue("site"),
- pathParam("gtn:path").matchedBy(".*").preservePath())).
- build();
- }
-
- public void testComponent() throws Exception
- {
- Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
- expectedParameters.put(Names.GTN_HANDLER, "site");
- expectedParameters.put(Names.GTN_SITENAME, "classic");
- expectedParameters.put(Names.GTN_SITETYPE, "portal");
- expectedParameters.put(Names.GTN_PATH, "/");
- expectedParameters.put(Names.GTN_COMPONENTID, "foo");
-
- //
- assertEquals(expectedParameters, router.route("/private/portal/classic/", Collections.singletonMap("portal:componentId", new String[]{"foo"})));
- assertEquals("/private/portal/classic/?portal:componentId=foo", router.render(expectedParameters));
- }
-
- public void testPrivateClassic() throws Exception
- {
- Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
- expectedParameters.put(Names.GTN_HANDLER, "site");
- expectedParameters.put(Names.GTN_SITENAME, "classic");
- expectedParameters.put(Names.GTN_SITETYPE, "portal");
- expectedParameters.put(Names.GTN_PATH, "");
-
- //
- assertEquals(expectedParameters, router.route("/private/portal/classic"));
- assertEquals("/private/portal/classic", router.render(expectedParameters));
- }
-
- public void testPrivateClassicSlash() throws Exception
- {
- Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
- expectedParameters.put(Names.GTN_HANDLER, "site");
- expectedParameters.put(Names.GTN_SITENAME, "classic");
- expectedParameters.put(Names.GTN_SITETYPE, "portal");
- expectedParameters.put(Names.GTN_PATH, "/");
-
- //
- assertEquals(expectedParameters, router.route("/private/portal/classic/"));
- assertEquals("/private/portal/classic/", router.render(expectedParameters));
- }
-
- public void testPrivateClassicHome() throws Exception
- {
- Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
- expectedParameters.put(Names.GTN_HANDLER, "site");
- expectedParameters.put(Names.GTN_SITENAME, "classic");
- expectedParameters.put(Names.GTN_SITETYPE, "portal");
- expectedParameters.put(Names.GTN_PATH, "/home");
-
- //
- assertEquals(expectedParameters, router.route("/private/portal/classic/home"));
- assertEquals("/private/portal/classic/home", router.render(expectedParameters));
- }
-
- public void testSiteType() throws Exception
- {
- Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
- expectedParameters.put(Names.GTN_HANDLER, "site");
- expectedParameters.put(Names.GTN_SITETYPE, "group");
- expectedParameters.put(Names.GTN_SITENAME, "platform");
- expectedParameters.put(Names.GTN_PATH, "/administration/registry");
-
- //
- assertEquals(expectedParameters, router.route("/private/group/platform/administration/registry"));
- assertEquals("/private/group/platform/administration/registry", router.render(expectedParameters));
-
- Map<QualifiedName, String> expectedParameters1 = new HashMap<QualifiedName, String>();
- expectedParameters1.put(Names.GTN_HANDLER, "site");
- expectedParameters1.put(Names.GTN_SITETYPE, "user");
- expectedParameters1.put(Names.GTN_SITENAME, "root");
- expectedParameters1.put(Names.GTN_PATH, "/tab_0");
-
- //
- assertEquals(expectedParameters1, router.route("/private/user/root/tab_0"));
- assertEquals("/private/user/root/tab_0", router.render(expectedParameters1));
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.web.controller.QualifiedName;
+import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestPortalConfiguration extends AbstractTestController
+{
+
+ /** . */
+ private Router router;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ this.router = router().
+ add(
+ route("/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}").
+ with(
+ routeParam("gtn:handler").withValue("site"),
+ routeParam("gtn:handler").withValue("site"),
+ requestParam("gtn:componentid").named("portal:componentId"),
+ pathParam("gtn:path").matchedBy(".*").preservePath()),
+ route("/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}").
+ with(
+ routeParam("gtn:handler").withValue("site"),
+ pathParam("gtn:path").matchedBy(".*").preservePath()),
+ route("/groups/{gtn:sitetype}/{gtn:sitename}{gtn:path}").
+ with(
+ routeParam("gtn:handler").withValue("site"),
+ pathParam("gtn:path").matchedBy(".*").preservePath()),
+ route("/users/{gtn:sitetype}/{gtn:sitename}{gtn:path}").
+ with(
+ routeParam("gtn:handler").withValue("site"),
+ pathParam("gtn:path").matchedBy(".*").preservePath())).
+ build();
+ }
+
+ public void testComponent() throws Exception
+ {
+ Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
+ expectedParameters.put(Names.GTN_HANDLER, "site");
+ expectedParameters.put(Names.GTN_SITENAME, "classic");
+ expectedParameters.put(Names.GTN_SITETYPE, "portal");
+ expectedParameters.put(Names.GTN_PATH, "/");
+ expectedParameters.put(Names.GTN_COMPONENTID, "foo");
+
+ //
+ assertEquals(expectedParameters, router.route("/private/portal/classic/", Collections.singletonMap("portal:componentId", new String[]{"foo"})));
+ assertEquals("/private/portal/classic/?portal:componentId=foo", router.render(expectedParameters));
+ }
+
+ public void testPrivateClassic() throws Exception
+ {
+ Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
+ expectedParameters.put(Names.GTN_HANDLER, "site");
+ expectedParameters.put(Names.GTN_SITENAME, "classic");
+ expectedParameters.put(Names.GTN_SITETYPE, "portal");
+ expectedParameters.put(Names.GTN_PATH, "");
+
+ //
+ assertEquals(expectedParameters, router.route("/private/portal/classic"));
+ assertEquals("/private/portal/classic", router.render(expectedParameters));
+ }
+
+ public void testPrivateClassicSlash() throws Exception
+ {
+ Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
+ expectedParameters.put(Names.GTN_HANDLER, "site");
+ expectedParameters.put(Names.GTN_SITENAME, "classic");
+ expectedParameters.put(Names.GTN_SITETYPE, "portal");
+ expectedParameters.put(Names.GTN_PATH, "/");
+
+ //
+ assertEquals(expectedParameters, router.route("/private/portal/classic/"));
+ assertEquals("/private/portal/classic/", router.render(expectedParameters));
+ }
+
+ public void testPrivateClassicHome() throws Exception
+ {
+ Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
+ expectedParameters.put(Names.GTN_HANDLER, "site");
+ expectedParameters.put(Names.GTN_SITENAME, "classic");
+ expectedParameters.put(Names.GTN_SITETYPE, "portal");
+ expectedParameters.put(Names.GTN_PATH, "/home");
+
+ //
+ assertEquals(expectedParameters, router.route("/private/portal/classic/home"));
+ assertEquals("/private/portal/classic/home", router.render(expectedParameters));
+ }
+
+ public void testSiteType() throws Exception
+ {
+ Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
+ expectedParameters.put(Names.GTN_HANDLER, "site");
+ expectedParameters.put(Names.GTN_SITETYPE, "group");
+ expectedParameters.put(Names.GTN_SITENAME, "platform");
+ expectedParameters.put(Names.GTN_PATH, "/administration/registry");
+
+ //
+ assertEquals(expectedParameters, router.route("/private/group/platform/administration/registry"));
+ assertEquals("/private/group/platform/administration/registry", router.render(expectedParameters));
+
+ Map<QualifiedName, String> expectedParameters1 = new HashMap<QualifiedName, String>();
+ expectedParameters1.put(Names.GTN_HANDLER, "site");
+ expectedParameters1.put(Names.GTN_SITETYPE, "user");
+ expectedParameters1.put(Names.GTN_SITENAME, "root");
+ expectedParameters1.put(Names.GTN_PATH, "/tab_0");
+
+ //
+ assertEquals(expectedParameters1, router.route("/private/user/root/tab_0"));
+ assertEquals("/private/user/root/tab_0", router.render(expectedParameters1));
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestQualifiedName.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestQualifiedName.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestQualifiedName.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,189 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import junit.framework.TestCase;
-import org.exoplatform.web.controller.QualifiedName;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class TestQualifiedName extends TestCase
-{
-
- public void testSame()
- {
- QualifiedName qd1 = QualifiedName.create("a", "bc");
- assertEquals("a", qd1.getQualifier());
- assertEquals("bc", qd1.getName());
- assertEquals("a:bc", qd1.getValue());
-
- //
- QualifiedName qd2 = QualifiedName.parse("a:bc");
- assertEquals("a", qd2.getQualifier());
- assertEquals("bc", qd2.getName());
- assertEquals("a:bc", qd2.getValue());
-
- //
- assertTrue(qd1.equals(qd2));
- assertTrue(qd2.equals(qd1));
- assertTrue(qd1.equals(qd1));
- assertTrue(qd2.equals(qd2));
-
- //
- assertEquals(qd1.hashCode(), qd2.hashCode());
- }
-
- public void testSameQualifierComparison()
- {
- QualifiedName qd1 = QualifiedName.create("a", "b");
- QualifiedName qd2 = QualifiedName.create("a", "c");
- assertEquals(Math.signum(qd1.compareTo(qd2)), Math.signum("b".compareTo("c")));
- assertEquals(Math.signum(qd2.compareTo(qd1)), Math.signum("c".compareTo("b")));
- }
-
- public void testEmptyQualifierComparison()
- {
- QualifiedName qd1 = QualifiedName.create("a");
- QualifiedName qd2 = QualifiedName.create("b");
- assertEquals(Math.signum(qd1.compareTo(qd2)), Math.signum("a".compareTo("b")));
- assertEquals(Math.signum(qd2.compareTo(qd1)), Math.signum("b".compareTo("a")));
- }
-
- public void testDifferentQualifierSameNameComparison()
- {
- QualifiedName qd1 = QualifiedName.create("a", "c");
- QualifiedName qd2 = QualifiedName.create("b", "c");
- assertEquals(Math.signum(qd1.compareTo(qd2)), Math.signum("a".compareTo("b")));
- assertEquals(Math.signum(qd2.compareTo(qd1)), Math.signum("b".compareTo("a")));
- }
-
- public void testSameWithEmptyQualifier()
- {
- QualifiedName qd1 = QualifiedName.create("abc");
- assertEquals("", qd1.getQualifier());
- assertEquals("abc", qd1.getName());
- assertEquals("abc", qd1.getValue());
-
- //
- QualifiedName qd2 = QualifiedName.parse("abc");
- assertEquals("", qd2.getQualifier());
- assertEquals("abc", qd2.getName());
- assertEquals("abc", qd2.getValue());
-
- //
- assertTrue(qd1.equals(qd2));
- assertTrue(qd2.equals(qd1));
- assertTrue(qd1.equals(qd1));
- assertTrue(qd2.equals(qd2));
-
- //
- assertEquals(qd1.hashCode(), qd2.hashCode());
- }
-
- public void testNPEInCtor()
- {
- try
- {
- QualifiedName.create(null);
- fail();
- }
- catch (NullPointerException ignore)
- {
- }
- try
- {
- QualifiedName.create("a", null);
- fail();
- }
- catch (NullPointerException ignore)
- {
- }
- try
- {
- QualifiedName.create(null, "a");
- fail();
- }
- catch (NullPointerException ignore)
- {
- }
- try
- {
- QualifiedName.create(null, null);
- fail();
- }
- catch (NullPointerException ignore)
- {
- }
- try
- {
- QualifiedName.parse(null);
- fail();
- }
- catch (NullPointerException ignore)
- {
- }
- }
-
- public void testIAEInCtor()
- {
- try
- {
- QualifiedName.create("a:b");
- fail();
- }
- catch (IllegalArgumentException ignore)
- {
- }
- try
- {
- QualifiedName.create(":", "a");
- fail();
- }
- catch (IllegalArgumentException ignore)
- {
- }
- try
- {
- QualifiedName.create("a", ":");
- fail();
- }
- catch (IllegalArgumentException ignore)
- {
- }
- try
- {
- QualifiedName.create(":", ":");
- fail();
- }
- catch (IllegalArgumentException ignore)
- {
- }
- try
- {
- QualifiedName.parse("::");
- fail();
- }
- catch (IllegalArgumentException ignore)
- {
- }
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestQualifiedName.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestQualifiedName.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestQualifiedName.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestQualifiedName.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import junit.framework.TestCase;
+import org.exoplatform.web.controller.QualifiedName;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestQualifiedName extends TestCase
+{
+
+ public void testSame()
+ {
+ QualifiedName qd1 = QualifiedName.create("a", "bc");
+ assertEquals("a", qd1.getQualifier());
+ assertEquals("bc", qd1.getName());
+ assertEquals("a:bc", qd1.getValue());
+
+ //
+ QualifiedName qd2 = QualifiedName.parse("a:bc");
+ assertEquals("a", qd2.getQualifier());
+ assertEquals("bc", qd2.getName());
+ assertEquals("a:bc", qd2.getValue());
+
+ //
+ assertTrue(qd1.equals(qd2));
+ assertTrue(qd2.equals(qd1));
+ assertTrue(qd1.equals(qd1));
+ assertTrue(qd2.equals(qd2));
+
+ //
+ assertEquals(qd1.hashCode(), qd2.hashCode());
+ }
+
+ public void testSameQualifierComparison()
+ {
+ QualifiedName qd1 = QualifiedName.create("a", "b");
+ QualifiedName qd2 = QualifiedName.create("a", "c");
+ assertEquals(Math.signum(qd1.compareTo(qd2)), Math.signum("b".compareTo("c")));
+ assertEquals(Math.signum(qd2.compareTo(qd1)), Math.signum("c".compareTo("b")));
+ }
+
+ public void testEmptyQualifierComparison()
+ {
+ QualifiedName qd1 = QualifiedName.create("a");
+ QualifiedName qd2 = QualifiedName.create("b");
+ assertEquals(Math.signum(qd1.compareTo(qd2)), Math.signum("a".compareTo("b")));
+ assertEquals(Math.signum(qd2.compareTo(qd1)), Math.signum("b".compareTo("a")));
+ }
+
+ public void testDifferentQualifierSameNameComparison()
+ {
+ QualifiedName qd1 = QualifiedName.create("a", "c");
+ QualifiedName qd2 = QualifiedName.create("b", "c");
+ assertEquals(Math.signum(qd1.compareTo(qd2)), Math.signum("a".compareTo("b")));
+ assertEquals(Math.signum(qd2.compareTo(qd1)), Math.signum("b".compareTo("a")));
+ }
+
+ public void testSameWithEmptyQualifier()
+ {
+ QualifiedName qd1 = QualifiedName.create("abc");
+ assertEquals("", qd1.getQualifier());
+ assertEquals("abc", qd1.getName());
+ assertEquals("abc", qd1.getValue());
+
+ //
+ QualifiedName qd2 = QualifiedName.parse("abc");
+ assertEquals("", qd2.getQualifier());
+ assertEquals("abc", qd2.getName());
+ assertEquals("abc", qd2.getValue());
+
+ //
+ assertTrue(qd1.equals(qd2));
+ assertTrue(qd2.equals(qd1));
+ assertTrue(qd1.equals(qd1));
+ assertTrue(qd2.equals(qd2));
+
+ //
+ assertEquals(qd1.hashCode(), qd2.hashCode());
+ }
+
+ public void testNPEInCtor()
+ {
+ try
+ {
+ QualifiedName.create(null);
+ fail();
+ }
+ catch (NullPointerException ignore)
+ {
+ }
+ try
+ {
+ QualifiedName.create("a", null);
+ fail();
+ }
+ catch (NullPointerException ignore)
+ {
+ }
+ try
+ {
+ QualifiedName.create(null, "a");
+ fail();
+ }
+ catch (NullPointerException ignore)
+ {
+ }
+ try
+ {
+ QualifiedName.create(null, null);
+ fail();
+ }
+ catch (NullPointerException ignore)
+ {
+ }
+ try
+ {
+ QualifiedName.parse(null);
+ fail();
+ }
+ catch (NullPointerException ignore)
+ {
+ }
+ }
+
+ public void testIAEInCtor()
+ {
+ try
+ {
+ QualifiedName.create("a:b");
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ try
+ {
+ QualifiedName.create(":", "a");
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ try
+ {
+ QualifiedName.create("a", ":");
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ try
+ {
+ QualifiedName.create(":", ":");
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ try
+ {
+ QualifiedName.parse("::");
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.exoplatform.web.controller.QualifiedName;
-import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
-
-import java.util.Collections;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class TestRender extends AbstractTestController
-{
-
- public void testRoot() throws Exception
- {
- Router router = router().add(route("/")).build();
-
- //
- assertEquals("/", router.render(Collections.<QualifiedName, String>emptyMap()));
- }
-
- public void testA() throws Exception
- {
- Router router = router().add(route("/a")).build();
-
- //
- assertEquals("/a", router.render(Collections.<QualifiedName, String>emptyMap()));
- }
-
- public void testAB() throws Exception
- {
- Router router = router().add(route("/a/b")).build();
-
- //
- assertEquals("/a/b", router.render(Collections.<QualifiedName, String>emptyMap()));
- }
-
- public void testPathParam() throws Exception
- {
- Router router = router().add(route("/{p}")).build();
-
- //
- assertEquals("/a", router.render(Collections.singletonMap(Names.P, "a")));
- assertEquals("", router.render(Collections.<QualifiedName, String>emptyMap()));
- }
-
- public void testSimplePatternPathParam() throws Exception
- {
- Router router = router().add(route("/{p}").with(pathParam("p").matchedBy("a"))).build();
-
- //
- assertEquals("/a", router.render(Collections.singletonMap(Names.P, "a")));
- assertEquals("", router.render(Collections.singletonMap(Names.P, "ab")));
- }
-
- public void testPrecedence() throws Exception
- {
- Router router = router().
- add(route("/a")).
- add(route("/{p}/b").
- with(pathParam("p").matchedBy("a"))).
- build();
-
- //
- assertEquals("/a", router.render(Collections.<QualifiedName, String>emptyMap()));
-
- //
- assertEquals("/a/b", router.render(Collections.singletonMap(Names.P, "a")));
- }
-
- public void testLang() throws Exception
- {
- Router router = router().
- add(route("/{a}b").
- with(pathParam("a").matchedBy("(([A-Za-z]{2})/)?").preservePath())).
- build();
-
- //
- assertEquals("/fr/b", router.render(Collections.singletonMap(Names.A, "fr/")));
- assertEquals("/b", router.render(Collections.singletonMap(Names.A, "")));
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.web.controller.QualifiedName;
+import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
+
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestRender extends AbstractTestController
+{
+
+ public void testRoot() throws Exception
+ {
+ Router router = router().add(route("/")).build();
+
+ //
+ assertEquals("/", router.render(Collections.<QualifiedName, String>emptyMap()));
+ }
+
+ public void testA() throws Exception
+ {
+ Router router = router().add(route("/a")).build();
+
+ //
+ assertEquals("/a", router.render(Collections.<QualifiedName, String>emptyMap()));
+ }
+
+ public void testAB() throws Exception
+ {
+ Router router = router().add(route("/a/b")).build();
+
+ //
+ assertEquals("/a/b", router.render(Collections.<QualifiedName, String>emptyMap()));
+ }
+
+ public void testPathParam() throws Exception
+ {
+ Router router = router().add(route("/{p}")).build();
+
+ //
+ assertEquals("/a", router.render(Collections.singletonMap(Names.P, "a")));
+ assertEquals("", router.render(Collections.<QualifiedName, String>emptyMap()));
+ }
+
+ public void testSimplePatternPathParam() throws Exception
+ {
+ Router router = router().add(route("/{p}").with(pathParam("p").matchedBy("a"))).build();
+
+ //
+ assertEquals("/a", router.render(Collections.singletonMap(Names.P, "a")));
+ assertEquals("", router.render(Collections.singletonMap(Names.P, "ab")));
+ }
+
+ public void testPrecedence() throws Exception
+ {
+ Router router = router().
+ add(route("/a")).
+ add(route("/{p}/b").
+ with(pathParam("p").matchedBy("a"))).
+ build();
+
+ //
+ assertEquals("/a", router.render(Collections.<QualifiedName, String>emptyMap()));
+
+ //
+ assertEquals("/a/b", router.render(Collections.singletonMap(Names.P, "a")));
+ }
+
+ public void testLang() throws Exception
+ {
+ Router router = router().
+ add(route("/{a}b").
+ with(pathParam("a").matchedBy("(([A-Za-z]{2})/)?").preservePath())).
+ build();
+
+ //
+ assertEquals("/fr/b", router.render(Collections.singletonMap(Names.A, "fr/")));
+ assertEquals("/b", router.render(Collections.singletonMap(Names.A, "")));
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRequestParam.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRequestParam.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRequestParam.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,336 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.exoplatform.web.controller.QualifiedName;
-import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class TestRequestParam extends AbstractTestController
-{
-
- public void testRoot() throws Exception
- {
- Router router = router().add(route("/").with(requestParam("foo").named("a").matchedByLiteral("a").required())).build();
-
- //
- assertNull(router.route("/"));
- assertEquals(Collections.singletonMap(Names.FOO, "a"), router.route("/", Collections.singletonMap("a", new String[]{"a"})));
-
- //
- assertEquals("", router.render(Collections.<QualifiedName, String>emptyMap()));
- URIHelper renderContext = new URIHelper();
- router.render(Collections.singletonMap(Names.FOO, "a"), renderContext.writer);
- assertEquals("/", renderContext.getPath());
- assertMapEquals(Collections.singletonMap("a", new String[]{"a"}), renderContext.getQueryParams());
- }
-
- public void testSegment() throws Exception
- {
- Router router = router().add(route("/a").with(requestParam("foo").named("a").matchedByLiteral("a").required())).build();
-
- //
- assertNull(router.route("/a"));
- assertEquals(Collections.singletonMap(Names.FOO, "a"), router.route("/a", Collections.singletonMap("a", new String[]{"a"})));
-
- //
- assertEquals("", router.render(Collections.<QualifiedName, String>emptyMap()));
- URIHelper renderContext = new URIHelper();
- router.render(Collections.singletonMap(Names.FOO, "a"), renderContext.writer);
- assertEquals("/a", renderContext.getPath());
- assertMapEquals(Collections.singletonMap("a", new String[]{"a"}), renderContext.getQueryParams());
- }
-
- public void testValuePattern() throws Exception
- {
- Router router = router().add(route("/a").with(requestParam("foo").named("a").matchedByPattern("[0-9]+").required())).build();
-
- //
- assertNull(router.route("/a"));
- assertNull(router.route("/a", Collections.singletonMap("a", new String[]{"a"})));
- assertEquals(Collections.singletonMap(Names.FOO, "0123"), router.route("/a", Collections.singletonMap("a", new String[]{"0123"})));
-
- //
- assertEquals("", router.render(Collections.<QualifiedName, String>emptyMap()));
- assertEquals("", router.render(Collections.singletonMap(Names.FOO, "a")));
- URIHelper renderContext = new URIHelper();
- router.render(Collections.singletonMap(Names.FOO, "12"), renderContext.writer);
- assertEquals("/a", renderContext.getPath());
- assertMapEquals(Collections.singletonMap("a", new String[]{"12"}), renderContext.getQueryParams());
- }
-
- public void testPrecedence() throws Exception
- {
- Router router = router().
- add(route("/a").with(requestParam("foo").named("a").matchedByLiteral("a").required())).
- add(route("/a").with(requestParam("bar").named("b").matchedByLiteral("b").required())).
- build();
-
- //
- assertNull(router.route("/a"));
- assertEquals(Collections.singletonMap(Names.FOO, "a"), router.route("/a", Collections.singletonMap("a", new String[]{"a"})));
- assertEquals(Collections.singletonMap(Names.BAR, "b"), router.route("/a", Collections.singletonMap("b", new String[]{"b"})));
-
- //
- assertEquals("", router.render(Collections.<QualifiedName, String>emptyMap()));
- URIHelper renderContext1 = new URIHelper();
- router.render(Collections.singletonMap(Names.FOO, "a"), renderContext1.writer);
- assertEquals("/a", renderContext1.getPath());
- assertMapEquals(Collections.singletonMap("a", new String[]{"a"}), renderContext1.getQueryParams());
- URIHelper renderContext2 = new URIHelper();
- router.render(Collections.singletonMap(Names.BAR, "b"), renderContext2.writer);
- assertEquals("/a", renderContext2.getPath());
- assertMapEquals(Collections.singletonMap("b", new String[]{"b"}), renderContext2.getQueryParams());
- }
-
- public void testInheritance() throws Exception
- {
- Router router = router().
- add(route("/a").with(requestParam("foo").named("a").matchedByLiteral("a").required()).
- sub(route("/b").with(requestParam("bar").named("b").matchedByLiteral("b").required()))).
- build();
-
- //
- assertNull(router.route("/a"));
- // assertEquals(Collections.singletonMap(Names.FOO, "a"), router.route("/a", Collections.singletonMap("a", new String[]{"a"})));
- assertNull(router.route("/a", Collections.singletonMap("a", new String[]{"a"})));
- assertNull(router.route("/a/b"));
- Map<String, String[]> requestParameters = new HashMap<String, String[]>();
- requestParameters.put("a", new String[]{"a"});
- requestParameters.put("b", new String[]{"b"});
- Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
- expectedParameters.put(Names.FOO, "a");
- expectedParameters.put(Names.BAR, "b");
- assertEquals(expectedParameters, router.route("/a/b", requestParameters));
-
- //
- assertEquals("", router.render(Collections.<QualifiedName, String>emptyMap()));
- URIHelper renderContext1 = new URIHelper();
- router.render(Collections.singletonMap(Names.FOO, "a"), renderContext1.writer);
- // assertEquals("/a", renderContext1.getPath());
- // assertEquals(Collections.singletonMap("a", "a"), renderContext1.getQueryParams());
- assertEquals("", renderContext1.getPath());
- URIHelper renderContext2 = new URIHelper();
- router.render(expectedParameters, renderContext2.writer);
- assertEquals("/a/b", renderContext2.getPath());
- Map<String, String[]> expectedRequestParameters = new HashMap<String, String[]>();
- expectedRequestParameters.put("a", new String[]{"a"});
- expectedRequestParameters.put("b", new String[]{"b"});
- assertMapEquals(expectedRequestParameters, renderContext2.getQueryParams());
- }
-
- public void testOptional() throws Exception
- {
- Router router = router().add(route("/").
- with(requestParam("foo").named("a").matchedByLiteral("a"))).build();
-
- //
- assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/", Collections.<String, String[]>emptyMap()));
- assertEquals(Collections.singletonMap(Names.FOO, "a"), router.route("/", Collections.singletonMap("a", new String[]{"a"})));
-
- //
- URIHelper renderContext1 = new URIHelper();
- router.render(Collections.<QualifiedName, String>emptyMap(), renderContext1.writer);
- assertEquals("/", renderContext1.getPath());
- assertEquals(null, renderContext1.getQueryParams());
- URIHelper renderContext2 = new URIHelper();
- router.render(Collections.singletonMap(Names.FOO, "a"), renderContext2.writer);
- assertEquals("/", renderContext2.getPath());
- assertMapEquals(Collections.singletonMap("a", new String[]{"a"}), renderContext2.getQueryParams());
- }
-
- public void testMatchDescendantOfRootParameters() throws Exception
- {
- Router router = router().
- add(route("/").with(requestParam("foo").named("a").matchedByLiteral("a")).
- sub(route("/a").with(requestParam("bar").named("b").matchedByLiteral("b")))).
- build();
-
- //
- URIHelper renderContext = new URIHelper();
- Map<QualifiedName, String> parameters = new HashMap<QualifiedName, String>();
- parameters.put(Names.FOO, "a");
- parameters.put(Names.BAR, "b");
- router.render(parameters, renderContext.writer);
- assertEquals("/a", renderContext.getPath());
- Map<String, String[]> expectedRequestParameters = new HashMap<String, String[]>();
- expectedRequestParameters.put("a", new String[]{"a"});
- expectedRequestParameters.put("b", new String[]{"b"});
- assertMapEquals(expectedRequestParameters, renderContext.getQueryParams());
- }
-
- public void testLiteralMatch() throws Exception
- {
- Router router = router().
- add(route("/").with(requestParam("foo").canonical().optional().named("a").matchedByLiteral("foo_value"))).
- build();
-
- //
- Map<QualifiedName, String> parameters = new HashMap<QualifiedName, String>();
- parameters.put(Names.FOO, "foo_value");
- URIHelper rc = new URIHelper();
- router.render(parameters, rc.writer);
- assertEquals("/", rc.getPath());
- assertEquals(Collections.singleton("a"), rc.getQueryParams().keySet());
- assertEquals(Collections.singletonList("foo_value"), Arrays.asList(rc.getQueryParams().get("a")));
- Map<QualifiedName, String> a = router.route("/", Collections.singletonMap("a", new String[]{"foo_value"}));
- assertNotNull(a);
- assertEquals(Collections.singleton(Names.FOO), a.keySet());
- assertEquals("foo_value", a.get(Names.FOO));
-
- //
- parameters = new HashMap<QualifiedName, String>();
- parameters.put(Names.FOO, "bar_value");
- rc.reset();
- router.render(parameters, rc.writer);
- assertEquals("", rc.getPath());
- assertEquals(null, rc.getQueryParams());
- a = router.route("/", Collections.singletonMap("a", new String[]{"bar_value"}));
- assertNull(a);
- }
-
- public void testCanonical() throws Exception
- {
- Router router = router().
- add(route("/").with(requestParam("foo").canonical().optional().named("a"))).
- build();
-
- //
- Map<QualifiedName, String> parameters = new HashMap<QualifiedName, String>();
- parameters.put(Names.FOO, "bar");
- URIHelper rc = new URIHelper();
- router.render(parameters, rc.writer);
- assertEquals(Collections.singleton("a"), rc.getQueryParams().keySet());
- assertEquals(Collections.singletonList("bar"), Arrays.asList(rc.getQueryParams().get("a")));
- Map<QualifiedName, String> a = router.route("/", Collections.singletonMap("a", new String[]{"bar"}));
- assertNotNull(a);
- assertEquals(Collections.singleton(Names.FOO), a.keySet());
- assertEquals("bar", a.get(Names.FOO));
-
- //
- parameters = new HashMap<QualifiedName, String>();
- parameters.put(Names.FOO, "");
- rc.reset();
- router.render(parameters, rc.writer);
- assertEquals(Collections.singleton("a"), rc.getQueryParams().keySet());
- assertEquals(Collections.singletonList(""), Arrays.asList(rc.getQueryParams().get("a")));
- a = router.route("/", Collections.singletonMap("a", new String[]{""}));
- assertNotNull(a);
- assertEquals(Collections.singleton(Names.FOO), a.keySet());
- assertEquals("", a.get(Names.FOO));
-
- //
- parameters = new HashMap<QualifiedName, String>();
- rc.reset();
- router.render(parameters, rc.writer);
- assertEquals(null, rc.getQueryParams());
- a = router.route("/");
- assertNotNull(a);
- assertEquals(Collections.<QualifiedName>emptySet(), a.keySet());
- }
-
- public void testNeverEmpty() throws Exception
- {
- Router router = router().
- add(route("/").with(requestParam("foo").neverEmpty().optional().named("a"))).
- build();
-
- //
- Map<QualifiedName, String> parameters = new HashMap<QualifiedName, String>();
- parameters.put(Names.FOO, "bar");
- URIHelper rc = new URIHelper();
- router.render(parameters, rc.writer);
- assertEquals(Collections.singleton("a"), rc.getQueryParams().keySet());
- assertEquals(Collections.singletonList("bar"), Arrays.asList(rc.getQueryParams().get("a")));
- Map<QualifiedName, String> a = router.route("/", Collections.singletonMap("a", new String[]{"bar"}));
- assertNotNull(a);
- assertEquals(Collections.singleton(Names.FOO), a.keySet());
- assertEquals("bar", a.get(Names.FOO));
-
- //
- parameters = new HashMap<QualifiedName, String>();
- parameters.put(Names.FOO, "");
- rc.reset();
- router.render(parameters, rc.writer);
- assertEquals(null, rc.getQueryParams());
- a = router.route("/", Collections.singletonMap("a", new String[]{""}));
- assertNotNull(a);
- assertEquals(Collections.<QualifiedName>emptySet(), a.keySet());
-
- //
- parameters = new HashMap<QualifiedName, String>();
- rc.reset();
- router.render(parameters, rc.writer);
- assertEquals(null, rc.getQueryParams());
- a = router.route("/");
- assertNotNull(a);
- assertEquals(Collections.<QualifiedName>emptySet(), a.keySet());
- }
-
- public void testNeverNull() throws Exception
- {
- Router router = router().
- add(route("/").with(requestParam("foo").neverNull().optional().named("a"))).
- build();
-
- //
- Map<QualifiedName, String> parameters = new HashMap<QualifiedName, String>();
- parameters.put(Names.FOO, "bar");
- URIHelper rc = new URIHelper();
- router.render(parameters, rc.writer);
- assertEquals(Collections.singleton("a"), rc.getQueryParams().keySet());
- assertEquals(Collections.singletonList("bar"), Arrays.asList(rc.getQueryParams().get("a")));
- Map<QualifiedName, String> a = router.route("/", Collections.singletonMap("a", new String[]{"bar"}));
- assertNotNull(a);
- assertEquals(Collections.singleton(Names.FOO), a.keySet());
- assertEquals("bar", a.get(Names.FOO));
-
- //
- parameters = new HashMap<QualifiedName, String>();
- parameters.put(Names.FOO, "");
- rc.reset();
- router.render(parameters, rc.writer);
- assertEquals(Collections.singleton("a"), rc.getQueryParams().keySet());
- assertEquals(Collections.singletonList(""), Arrays.asList(rc.getQueryParams().get("a")));
- a = router.route("/", Collections.singletonMap("a", new String[]{""}));
- assertNotNull(a);
- assertEquals(Collections.singleton(Names.FOO), a.keySet());
- assertEquals("", a.get(Names.FOO));
-
- //
- parameters = new HashMap<QualifiedName, String>();
- rc.reset();
- router.render(parameters, rc.writer);
- assertEquals(Collections.singleton("a"), rc.getQueryParams().keySet());
- assertEquals(Collections.singletonList(""), Arrays.asList(rc.getQueryParams().get("a")));
- a = router.route("/");
- assertNotNull(a);
- assertEquals(Collections.singleton(Names.FOO), a.keySet());
- assertEquals("", a.get(Names.FOO));
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRequestParam.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRequestParam.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRequestParam.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRequestParam.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,336 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.web.controller.QualifiedName;
+import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestRequestParam extends AbstractTestController
+{
+
+ public void testRoot() throws Exception
+ {
+ Router router = router().add(route("/").with(requestParam("foo").named("a").matchedByLiteral("a").required())).build();
+
+ //
+ assertNull(router.route("/"));
+ assertEquals(Collections.singletonMap(Names.FOO, "a"), router.route("/", Collections.singletonMap("a", new String[]{"a"})));
+
+ //
+ assertEquals("", router.render(Collections.<QualifiedName, String>emptyMap()));
+ URIHelper renderContext = new URIHelper();
+ router.render(Collections.singletonMap(Names.FOO, "a"), renderContext.writer);
+ assertEquals("/", renderContext.getPath());
+ assertMapEquals(Collections.singletonMap("a", new String[]{"a"}), renderContext.getQueryParams());
+ }
+
+ public void testSegment() throws Exception
+ {
+ Router router = router().add(route("/a").with(requestParam("foo").named("a").matchedByLiteral("a").required())).build();
+
+ //
+ assertNull(router.route("/a"));
+ assertEquals(Collections.singletonMap(Names.FOO, "a"), router.route("/a", Collections.singletonMap("a", new String[]{"a"})));
+
+ //
+ assertEquals("", router.render(Collections.<QualifiedName, String>emptyMap()));
+ URIHelper renderContext = new URIHelper();
+ router.render(Collections.singletonMap(Names.FOO, "a"), renderContext.writer);
+ assertEquals("/a", renderContext.getPath());
+ assertMapEquals(Collections.singletonMap("a", new String[]{"a"}), renderContext.getQueryParams());
+ }
+
+ public void testValuePattern() throws Exception
+ {
+ Router router = router().add(route("/a").with(requestParam("foo").named("a").matchedByPattern("[0-9]+").required())).build();
+
+ //
+ assertNull(router.route("/a"));
+ assertNull(router.route("/a", Collections.singletonMap("a", new String[]{"a"})));
+ assertEquals(Collections.singletonMap(Names.FOO, "0123"), router.route("/a", Collections.singletonMap("a", new String[]{"0123"})));
+
+ //
+ assertEquals("", router.render(Collections.<QualifiedName, String>emptyMap()));
+ assertEquals("", router.render(Collections.singletonMap(Names.FOO, "a")));
+ URIHelper renderContext = new URIHelper();
+ router.render(Collections.singletonMap(Names.FOO, "12"), renderContext.writer);
+ assertEquals("/a", renderContext.getPath());
+ assertMapEquals(Collections.singletonMap("a", new String[]{"12"}), renderContext.getQueryParams());
+ }
+
+ public void testPrecedence() throws Exception
+ {
+ Router router = router().
+ add(route("/a").with(requestParam("foo").named("a").matchedByLiteral("a").required())).
+ add(route("/a").with(requestParam("bar").named("b").matchedByLiteral("b").required())).
+ build();
+
+ //
+ assertNull(router.route("/a"));
+ assertEquals(Collections.singletonMap(Names.FOO, "a"), router.route("/a", Collections.singletonMap("a", new String[]{"a"})));
+ assertEquals(Collections.singletonMap(Names.BAR, "b"), router.route("/a", Collections.singletonMap("b", new String[]{"b"})));
+
+ //
+ assertEquals("", router.render(Collections.<QualifiedName, String>emptyMap()));
+ URIHelper renderContext1 = new URIHelper();
+ router.render(Collections.singletonMap(Names.FOO, "a"), renderContext1.writer);
+ assertEquals("/a", renderContext1.getPath());
+ assertMapEquals(Collections.singletonMap("a", new String[]{"a"}), renderContext1.getQueryParams());
+ URIHelper renderContext2 = new URIHelper();
+ router.render(Collections.singletonMap(Names.BAR, "b"), renderContext2.writer);
+ assertEquals("/a", renderContext2.getPath());
+ assertMapEquals(Collections.singletonMap("b", new String[]{"b"}), renderContext2.getQueryParams());
+ }
+
+ public void testInheritance() throws Exception
+ {
+ Router router = router().
+ add(route("/a").with(requestParam("foo").named("a").matchedByLiteral("a").required()).
+ sub(route("/b").with(requestParam("bar").named("b").matchedByLiteral("b").required()))).
+ build();
+
+ //
+ assertNull(router.route("/a"));
+ // assertEquals(Collections.singletonMap(Names.FOO, "a"), router.route("/a", Collections.singletonMap("a", new String[]{"a"})));
+ assertNull(router.route("/a", Collections.singletonMap("a", new String[]{"a"})));
+ assertNull(router.route("/a/b"));
+ Map<String, String[]> requestParameters = new HashMap<String, String[]>();
+ requestParameters.put("a", new String[]{"a"});
+ requestParameters.put("b", new String[]{"b"});
+ Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
+ expectedParameters.put(Names.FOO, "a");
+ expectedParameters.put(Names.BAR, "b");
+ assertEquals(expectedParameters, router.route("/a/b", requestParameters));
+
+ //
+ assertEquals("", router.render(Collections.<QualifiedName, String>emptyMap()));
+ URIHelper renderContext1 = new URIHelper();
+ router.render(Collections.singletonMap(Names.FOO, "a"), renderContext1.writer);
+ // assertEquals("/a", renderContext1.getPath());
+ // assertEquals(Collections.singletonMap("a", "a"), renderContext1.getQueryParams());
+ assertEquals("", renderContext1.getPath());
+ URIHelper renderContext2 = new URIHelper();
+ router.render(expectedParameters, renderContext2.writer);
+ assertEquals("/a/b", renderContext2.getPath());
+ Map<String, String[]> expectedRequestParameters = new HashMap<String, String[]>();
+ expectedRequestParameters.put("a", new String[]{"a"});
+ expectedRequestParameters.put("b", new String[]{"b"});
+ assertMapEquals(expectedRequestParameters, renderContext2.getQueryParams());
+ }
+
+ public void testOptional() throws Exception
+ {
+ Router router = router().add(route("/").
+ with(requestParam("foo").named("a").matchedByLiteral("a"))).build();
+
+ //
+ assertEquals(Collections.<QualifiedName, String>emptyMap(), router.route("/", Collections.<String, String[]>emptyMap()));
+ assertEquals(Collections.singletonMap(Names.FOO, "a"), router.route("/", Collections.singletonMap("a", new String[]{"a"})));
+
+ //
+ URIHelper renderContext1 = new URIHelper();
+ router.render(Collections.<QualifiedName, String>emptyMap(), renderContext1.writer);
+ assertEquals("/", renderContext1.getPath());
+ assertEquals(null, renderContext1.getQueryParams());
+ URIHelper renderContext2 = new URIHelper();
+ router.render(Collections.singletonMap(Names.FOO, "a"), renderContext2.writer);
+ assertEquals("/", renderContext2.getPath());
+ assertMapEquals(Collections.singletonMap("a", new String[]{"a"}), renderContext2.getQueryParams());
+ }
+
+ public void testMatchDescendantOfRootParameters() throws Exception
+ {
+ Router router = router().
+ add(route("/").with(requestParam("foo").named("a").matchedByLiteral("a")).
+ sub(route("/a").with(requestParam("bar").named("b").matchedByLiteral("b")))).
+ build();
+
+ //
+ URIHelper renderContext = new URIHelper();
+ Map<QualifiedName, String> parameters = new HashMap<QualifiedName, String>();
+ parameters.put(Names.FOO, "a");
+ parameters.put(Names.BAR, "b");
+ router.render(parameters, renderContext.writer);
+ assertEquals("/a", renderContext.getPath());
+ Map<String, String[]> expectedRequestParameters = new HashMap<String, String[]>();
+ expectedRequestParameters.put("a", new String[]{"a"});
+ expectedRequestParameters.put("b", new String[]{"b"});
+ assertMapEquals(expectedRequestParameters, renderContext.getQueryParams());
+ }
+
+ public void testLiteralMatch() throws Exception
+ {
+ Router router = router().
+ add(route("/").with(requestParam("foo").canonical().optional().named("a").matchedByLiteral("foo_value"))).
+ build();
+
+ //
+ Map<QualifiedName, String> parameters = new HashMap<QualifiedName, String>();
+ parameters.put(Names.FOO, "foo_value");
+ URIHelper rc = new URIHelper();
+ router.render(parameters, rc.writer);
+ assertEquals("/", rc.getPath());
+ assertEquals(Collections.singleton("a"), rc.getQueryParams().keySet());
+ assertEquals(Collections.singletonList("foo_value"), Arrays.asList(rc.getQueryParams().get("a")));
+ Map<QualifiedName, String> a = router.route("/", Collections.singletonMap("a", new String[]{"foo_value"}));
+ assertNotNull(a);
+ assertEquals(Collections.singleton(Names.FOO), a.keySet());
+ assertEquals("foo_value", a.get(Names.FOO));
+
+ //
+ parameters = new HashMap<QualifiedName, String>();
+ parameters.put(Names.FOO, "bar_value");
+ rc.reset();
+ router.render(parameters, rc.writer);
+ assertEquals("", rc.getPath());
+ assertEquals(null, rc.getQueryParams());
+ a = router.route("/", Collections.singletonMap("a", new String[]{"bar_value"}));
+ assertNull(a);
+ }
+
+ public void testCanonical() throws Exception
+ {
+ Router router = router().
+ add(route("/").with(requestParam("foo").canonical().optional().named("a"))).
+ build();
+
+ //
+ Map<QualifiedName, String> parameters = new HashMap<QualifiedName, String>();
+ parameters.put(Names.FOO, "bar");
+ URIHelper rc = new URIHelper();
+ router.render(parameters, rc.writer);
+ assertEquals(Collections.singleton("a"), rc.getQueryParams().keySet());
+ assertEquals(Collections.singletonList("bar"), Arrays.asList(rc.getQueryParams().get("a")));
+ Map<QualifiedName, String> a = router.route("/", Collections.singletonMap("a", new String[]{"bar"}));
+ assertNotNull(a);
+ assertEquals(Collections.singleton(Names.FOO), a.keySet());
+ assertEquals("bar", a.get(Names.FOO));
+
+ //
+ parameters = new HashMap<QualifiedName, String>();
+ parameters.put(Names.FOO, "");
+ rc.reset();
+ router.render(parameters, rc.writer);
+ assertEquals(Collections.singleton("a"), rc.getQueryParams().keySet());
+ assertEquals(Collections.singletonList(""), Arrays.asList(rc.getQueryParams().get("a")));
+ a = router.route("/", Collections.singletonMap("a", new String[]{""}));
+ assertNotNull(a);
+ assertEquals(Collections.singleton(Names.FOO), a.keySet());
+ assertEquals("", a.get(Names.FOO));
+
+ //
+ parameters = new HashMap<QualifiedName, String>();
+ rc.reset();
+ router.render(parameters, rc.writer);
+ assertEquals(null, rc.getQueryParams());
+ a = router.route("/");
+ assertNotNull(a);
+ assertEquals(Collections.<QualifiedName>emptySet(), a.keySet());
+ }
+
+ public void testNeverEmpty() throws Exception
+ {
+ Router router = router().
+ add(route("/").with(requestParam("foo").neverEmpty().optional().named("a"))).
+ build();
+
+ //
+ Map<QualifiedName, String> parameters = new HashMap<QualifiedName, String>();
+ parameters.put(Names.FOO, "bar");
+ URIHelper rc = new URIHelper();
+ router.render(parameters, rc.writer);
+ assertEquals(Collections.singleton("a"), rc.getQueryParams().keySet());
+ assertEquals(Collections.singletonList("bar"), Arrays.asList(rc.getQueryParams().get("a")));
+ Map<QualifiedName, String> a = router.route("/", Collections.singletonMap("a", new String[]{"bar"}));
+ assertNotNull(a);
+ assertEquals(Collections.singleton(Names.FOO), a.keySet());
+ assertEquals("bar", a.get(Names.FOO));
+
+ //
+ parameters = new HashMap<QualifiedName, String>();
+ parameters.put(Names.FOO, "");
+ rc.reset();
+ router.render(parameters, rc.writer);
+ assertEquals(null, rc.getQueryParams());
+ a = router.route("/", Collections.singletonMap("a", new String[]{""}));
+ assertNotNull(a);
+ assertEquals(Collections.<QualifiedName>emptySet(), a.keySet());
+
+ //
+ parameters = new HashMap<QualifiedName, String>();
+ rc.reset();
+ router.render(parameters, rc.writer);
+ assertEquals(null, rc.getQueryParams());
+ a = router.route("/");
+ assertNotNull(a);
+ assertEquals(Collections.<QualifiedName>emptySet(), a.keySet());
+ }
+
+ public void testNeverNull() throws Exception
+ {
+ Router router = router().
+ add(route("/").with(requestParam("foo").neverNull().optional().named("a"))).
+ build();
+
+ //
+ Map<QualifiedName, String> parameters = new HashMap<QualifiedName, String>();
+ parameters.put(Names.FOO, "bar");
+ URIHelper rc = new URIHelper();
+ router.render(parameters, rc.writer);
+ assertEquals(Collections.singleton("a"), rc.getQueryParams().keySet());
+ assertEquals(Collections.singletonList("bar"), Arrays.asList(rc.getQueryParams().get("a")));
+ Map<QualifiedName, String> a = router.route("/", Collections.singletonMap("a", new String[]{"bar"}));
+ assertNotNull(a);
+ assertEquals(Collections.singleton(Names.FOO), a.keySet());
+ assertEquals("bar", a.get(Names.FOO));
+
+ //
+ parameters = new HashMap<QualifiedName, String>();
+ parameters.put(Names.FOO, "");
+ rc.reset();
+ router.render(parameters, rc.writer);
+ assertEquals(Collections.singleton("a"), rc.getQueryParams().keySet());
+ assertEquals(Collections.singletonList(""), Arrays.asList(rc.getQueryParams().get("a")));
+ a = router.route("/", Collections.singletonMap("a", new String[]{""}));
+ assertNotNull(a);
+ assertEquals(Collections.singleton(Names.FOO), a.keySet());
+ assertEquals("", a.get(Names.FOO));
+
+ //
+ parameters = new HashMap<QualifiedName, String>();
+ rc.reset();
+ router.render(parameters, rc.writer);
+ assertEquals(Collections.singleton("a"), rc.getQueryParams().keySet());
+ assertEquals(Collections.singletonList(""), Arrays.asList(rc.getQueryParams().get("a")));
+ a = router.route("/");
+ assertNotNull(a);
+ assertEquals(Collections.singleton(Names.FOO), a.keySet());
+ assertEquals("", a.get(Names.FOO));
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRouteEscaper.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRouteEscaper.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRouteEscaper.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.exoplatform.component.test.BaseGateInTest;
-import org.exoplatform.web.controller.regexp.RegExpRenderer;
-import org.exoplatform.web.controller.regexp.RENode;
-import org.exoplatform.web.controller.regexp.RegExpParser;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class TestRouteEscaper extends BaseGateInTest
-{
-
- private void match(String pattern, String test, String expectedValue) throws Exception
- {
- RegExpParser parser = new RegExpParser(pattern);
- RouteEscaper escaper = new RouteEscaper('/', '_');
- RENode.Disjunction re = parser.parseDisjunction();
- escaper.visit(re);
- Pattern p = Pattern.compile(new RegExpRenderer().render(re, new StringBuilder()).toString());
- Matcher matcher = p.matcher(test);
- assertTrue(matcher.find());
- assertEquals(expectedValue, matcher.group());
- }
-
- public void testMatch() throws Exception
- {
- match(".*", "_", "_");
- match(".*", "_/", "_");
- match(".*", "_/_", "_");
- match("/", "_/", "_");
- match("/*", "_/_", "_");
- match("[/a]*", "_a_/_", "_a_");
- match("[,-1&&[^/]]*", "_/_", "");
- }
-
- public void testGroup() throws Exception
- {
- match("(/)", "_", "_");
- match("(?:/)", "_", "_");
- match(".(?=/)", "a_", "a");
- match("a(?!/)", "ab", "a");
- match(".(?<=/)a", "ba_a", "_a");
- match(".(?<!/)a", "_aba", "ba");
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRouteEscaper.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRouteEscaper.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRouteEscaper.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRouteEscaper.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.component.test.BaseGateInTest;
+import org.exoplatform.web.controller.regexp.RegExpRenderer;
+import org.exoplatform.web.controller.regexp.RENode;
+import org.exoplatform.web.controller.regexp.RegExpParser;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestRouteEscaper extends BaseGateInTest
+{
+
+ private void match(String pattern, String test, String expectedValue) throws Exception
+ {
+ RegExpParser parser = new RegExpParser(pattern);
+ RouteEscaper escaper = new RouteEscaper('/', '_');
+ RENode.Disjunction re = parser.parseDisjunction();
+ escaper.visit(re);
+ Pattern p = Pattern.compile(new RegExpRenderer().render(re, new StringBuilder()).toString());
+ Matcher matcher = p.matcher(test);
+ assertTrue(matcher.find());
+ assertEquals(expectedValue, matcher.group());
+ }
+
+ public void testMatch() throws Exception
+ {
+ match(".*", "_", "_");
+ match(".*", "_/", "_");
+ match(".*", "_/_", "_");
+ match("/", "_/", "_");
+ match("/*", "_/_", "_");
+ match("[/a]*", "_a_/_", "_a_");
+ match("[,-1&&[^/]]*", "_/_", "");
+ }
+
+ public void testGroup() throws Exception
+ {
+ match("(/)", "_", "_");
+ match("(?:/)", "_", "_");
+ match(".(?=/)", "a_", "a");
+ match("a(?!/)", "ab", "a");
+ match(".(?<=/)a", "ba_a", "_a");
+ match(".(?<!/)a", "_aba", "ba");
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRoutePriority.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRoutePriority.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRoutePriority.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.exoplatform.web.controller.QualifiedName;
-
-import java.util.Collections;
-
-import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- */
-public class TestRoutePriority extends AbstractTestController
-{
-
- public void testExactMatchingAfterWildcard() throws Exception
- {
-
- Router router = router().
- add(route("/{foo}")).
- add(route("/foo").with(routeParam("foo").withValue("b"))).
- build();
-
- assertEquals(Collections.singletonMap(Names.FOO, "foo"), router.route("/foo"));
- assertEquals("/foo", router.render(Collections.singletonMap(Names.FOO, "foo")));
- assertEquals("/b", router.render(Collections.singletonMap(Names.FOO, "b")));
- }
-
- public void testExactMatchingBeforeWildcard() throws Exception
- {
-
- Router router = router().
- add(route("/foo").with(routeParam("foo").withValue("b"))).
- add(route("/{foo}")).
- build();
-
- assertEquals(Collections.singletonMap(Names.FOO, "b"), router.route("/foo"));
- assertEquals("/foo", router.render(Collections.singletonMap(Names.FOO, "b")));
- assertEquals("/foo", router.render(Collections.singletonMap(Names.FOO, "foo")));
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRoutePriority.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRoutePriority.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRoutePriority.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRoutePriority.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.web.controller.QualifiedName;
+
+import java.util.Collections;
+
+import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public class TestRoutePriority extends AbstractTestController
+{
+
+ public void testExactMatchingAfterWildcard() throws Exception
+ {
+
+ Router router = router().
+ add(route("/{foo}")).
+ add(route("/foo").with(routeParam("foo").withValue("b"))).
+ build();
+
+ assertEquals(Collections.singletonMap(Names.FOO, "foo"), router.route("/foo"));
+ assertEquals("/foo", router.render(Collections.singletonMap(Names.FOO, "foo")));
+ assertEquals("/b", router.render(Collections.singletonMap(Names.FOO, "b")));
+ }
+
+ public void testExactMatchingBeforeWildcard() throws Exception
+ {
+
+ Router router = router().
+ add(route("/foo").with(routeParam("foo").withValue("b"))).
+ add(route("/{foo}")).
+ build();
+
+ assertEquals(Collections.singletonMap(Names.FOO, "b"), router.route("/foo"));
+ assertEquals("/foo", router.render(Collections.singletonMap(Names.FOO, "b")));
+ assertEquals("/foo", router.render(Collections.singletonMap(Names.FOO, "foo")));
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/URIHelper.java
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/URIHelper.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/URIHelper.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.exoplatform.web.url.MimeType;
-
-import javax.servlet.http.HttpUtils;
-import java.io.IOException;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class URIHelper implements Appendable
-{
-
- /** . */
- private StringBuilder sb;
-
- /** . */
- final URIWriter writer;
-
- public URIHelper()
- {
- this(new StringBuilder());
- }
-
- public URIHelper(StringBuilder sb)
- {
- this.sb = sb;
- this.writer = new URIWriter(this, MimeType.PLAIN);
- }
-
- public String getPath()
- {
- if (sb != null)
- {
- int index = sb.indexOf("?");
- if (index != -1)
- {
- return sb.substring(0, index);
- }
- else
- {
- return sb.toString();
- }
- }
- return null;
- }
-
- public Map<String, String[]> getQueryParams()
- {
- if (sb != null)
- {
- int index = sb.indexOf("?");
- if (index != -1)
- {
- String query = sb.substring(index + 1);
- return HttpUtils.parseQueryString(query);
- }
- }
- return null;
- }
-
- public void reset()
- {
- if (sb != null)
- {
- sb.setLength(0);
- }
- writer.reset(sb);
- }
-
- public Appendable append(CharSequence csq) throws IOException
- {
- sb.append(csq);
- return this;
- }
-
- public Appendable append(CharSequence csq, int start, int end) throws IOException
- {
- sb.append(csq, start, end);
- return this;
- }
-
- public Appendable append(char c) throws IOException
- {
- sb.append(c);
- return this;
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/URIHelper.java (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/URIHelper.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/URIHelper.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/URIHelper.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.web.url.MimeType;
+
+import javax.servlet.http.HttpUtils;
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class URIHelper implements Appendable
+{
+
+ /** . */
+ private StringBuilder sb;
+
+ /** . */
+ final URIWriter writer;
+
+ public URIHelper()
+ {
+ this(new StringBuilder());
+ }
+
+ public URIHelper(StringBuilder sb)
+ {
+ this.sb = sb;
+ this.writer = new URIWriter(this, MimeType.PLAIN);
+ }
+
+ public String getPath()
+ {
+ if (sb != null)
+ {
+ int index = sb.indexOf("?");
+ if (index != -1)
+ {
+ return sb.substring(0, index);
+ }
+ else
+ {
+ return sb.toString();
+ }
+ }
+ return null;
+ }
+
+ public Map<String, String[]> getQueryParams()
+ {
+ if (sb != null)
+ {
+ int index = sb.indexOf("?");
+ if (index != -1)
+ {
+ String query = sb.substring(index + 1);
+ return HttpUtils.parseQueryString(query);
+ }
+ }
+ return null;
+ }
+
+ public void reset()
+ {
+ if (sb != null)
+ {
+ sb.setLength(0);
+ }
+ writer.reset(sb);
+ }
+
+ public Appendable append(CharSequence csq) throws IOException
+ {
+ sb.append(csq);
+ return this;
+ }
+
+ public Appendable append(CharSequence csq, int start, int end) throws IOException
+ {
+ sb.append(csq, start, end);
+ return this;
+ }
+
+ public Appendable append(char c) throws IOException
+ {
+ sb.append(c);
+ return this;
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml
===================================================================
--- portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,58 +0,0 @@
-<controller
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_controller_1_0 http://www.gatein.org/xml/ns/gatein_controller_1_0"
- xmlns="http://www.gatein.org/xml/ns/gatein_controller_1_0"
- separator-escape="&">
-
- <route path="/public/{gtn:sitetype}/{gtn:sitename}{gtn:path}">
- <route-param qname="gtn:handler">
- <value>portal</value>
- </route-param>
- <path-param qname="gtn:path">
- <pattern>.*</pattern>
- </path-param>
- </route>
-
- <route path="/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}">
- <route-param qname="gtn:handler">
- <value>portal</value>
- </route-param>
- <path-param qname="gtn:path" encoding="preserve-path">
- <pattern>.*</pattern>
- </path-param>
- </route>
-
- <route path="/upload">
- <route-param qname="gtn:handler">
- <value>upload</value>
- </route-param>
- </route>
-
- <route path="/download">
- <route-param qname="gtn:handler">
- <value>download</value>
- </route-param>
- </route>
-
- <route path="/a">
- <route-param qname="a">
- <value>a_value</value>
- </route-param>
- <route path="/b">
- <route-param qname="b">
- <value>b_value</value>
- </route-param>
- </route>
- </route>
-
- <route path="/b">
- <request-param qname="foo" name="foo"/>
- <request-param qname="bar" name="bar">
- <value>bar</value>
- </request-param>
- <request-param qname="juu" name="juu" control-mode="required">
- <pattern>juu</pattern>
- </request-param>
- </route>
-
-</controller>
\ No newline at end of file
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml (from rev 7117, portal/trunk/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,58 @@
+<controller
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_controller_1_0 http://www.gatein.org/xml/ns/gatein_controller_1_0"
+ xmlns="http://www.gatein.org/xml/ns/gatein_controller_1_0"
+ separator-escape="&">
+
+ <route path="/public/{gtn:sitetype}/{gtn:sitename}{gtn:path}">
+ <route-param qname="gtn:handler">
+ <value>portal</value>
+ </route-param>
+ <path-param qname="gtn:path">
+ <pattern>.*</pattern>
+ </path-param>
+ </route>
+
+ <route path="/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}">
+ <route-param qname="gtn:handler">
+ <value>portal</value>
+ </route-param>
+ <path-param qname="gtn:path" encoding="preserve-path">
+ <pattern>.*</pattern>
+ </path-param>
+ </route>
+
+ <route path="/upload">
+ <route-param qname="gtn:handler">
+ <value>upload</value>
+ </route-param>
+ </route>
+
+ <route path="/download">
+ <route-param qname="gtn:handler">
+ <value>download</value>
+ </route-param>
+ </route>
+
+ <route path="/a">
+ <route-param qname="a">
+ <value>a_value</value>
+ </route-param>
+ <route path="/b">
+ <route-param qname="b">
+ <value>b_value</value>
+ </route-param>
+ </route>
+ </route>
+
+ <route path="/b">
+ <request-param qname="foo" name="foo"/>
+ <request-param qname="bar" name="bar">
+ <value>bar</value>
+ </request-param>
+ <request-param qname="juu" name="juu" control-mode="required">
+ <pattern>juu</pattern>
+ </request-param>
+ </route>
+
+</controller>
\ No newline at end of file
Modified: epp/portal/branches/EPP_5_2_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -111,6 +111,8 @@
/** One hour caching. */
private static final int ONE_HOUR = 3600;
+ public static final String DEFAULT_SKIN = "Default";
+
/** The deployer. */
private final AbstractResourceHandler deployer;
@@ -668,13 +670,13 @@
* Get SkinConfig by module and skin name
* @param module
* @param skinName
- * @return SkinConfig by SkinKey(module, skinName), or SkinConfig by SkinKey(module, "Default")
+ * @return SkinConfig by SkinKey(module, skinName), or SkinConfig by SkinKey(module, SkinService.DEFAULT_SKIN)
*/
public SkinConfig getSkin(String module, String skinName)
{
SkinConfig config = skinConfigs_.get(new SkinKey(module, skinName));
if (config == null)
- skinConfigs_.get(new SkinKey(module, "Default"));
+ skinConfigs_.get(new SkinKey(module, SkinService.DEFAULT_SKIN));
return config;
}
@@ -734,7 +736,7 @@
{
SkinKey key;
if (skinName.length() == 0)
- key = new SkinKey(module, "Default");
+ key = new SkinKey(module, DEFAULT_SKIN);
else
key = new SkinKey(module, skinName);
skinConfigs_.remove(key);
Modified: epp/portal/branches/EPP_5_2_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/config/tasks/PortalSkinTask.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/config/tasks/PortalSkinTask.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/config/tasks/PortalSkinTask.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -40,13 +40,11 @@
private static final String DEFAULT_MODULE_NAME = "CoreSkin";
- private static final String DEFAULT_SKIN_NAME = "Default";
-
private String moduleName;
public PortalSkinTask()
{
- super(DEFAULT_SKIN_NAME);
+ super(SkinService.DEFAULT_SKIN);
this.overwrite = true;
this.moduleName = DEFAULT_MODULE_NAME;
}
Modified: epp/portal/branches/EPP_5_2_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/config/tasks/PortletSkinTask.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/config/tasks/PortletSkinTask.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/resources/src/main/java/org/exoplatform/portal/resource/config/tasks/PortletSkinTask.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -44,7 +44,7 @@
public PortletSkinTask()
{
- super("Default");
+ super(SkinService.DEFAULT_SKIN);
this.overwrite = true;
}
Modified: epp/portal/branches/EPP_5_2_Branch/component/web/security/pom.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/security/pom.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/security/pom.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -51,6 +51,10 @@
<artifactId>exo.portal.component.common</artifactId>
</dependency>
<dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web.controller</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.chromattic</groupId>
<artifactId>chromattic.apt</artifactId>
<scope>compile</scope>
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/conf/portal/configuration.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/conf/portal/configuration.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/conf/portal/configuration.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-
-<configuration
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
- xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
-
- <component>
- <key>org.exoplatform.web.application.javascript.JavascriptConfigService</key>
- <type>org.exoplatform.web.application.javascript.JavascriptConfigService</type>
- </component>
-
- <component>
- <type>org.exoplatform.web.filter.ExtensibleFilter</type>
- </component>
-
-</configuration>
Copied: epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/login/DoLoginServlet.java (from rev 7117, portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/DoLoginServlet.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/login/DoLoginServlet.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/login/DoLoginServlet.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.login;
+
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public class DoLoginServlet extends HttpServlet
+{
+
+ /** . */
+ private static final Logger log = LoggerFactory.getLogger(DoLoginServlet.class);
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ String initialURI = req.getParameter("initialURI");
+ log.debug("Performing the do login send redirect with initialURI=" + initialURI + " and remoteUser=" + req.getRemoteUser());
+ if (initialURI == null || initialURI.length() == 0)
+ {
+ initialURI = req.getContextPath();
+ }
+
+ //
+ resp.sendRedirect(resp.encodeRedirectURL(initialURI));
+ }
+}
Modified: epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/login/ErrorLoginServlet.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/login/ErrorLoginServlet.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/login/ErrorLoginServlet.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -28,7 +28,6 @@
import org.gatein.wci.security.WCIController;
import java.io.IOException;
-import java.util.Enumeration;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
@@ -69,7 +68,7 @@
// Clear the token cookie
clearTokenCookie(req, resp);
// This allows the customer to define another login page without changing the portal
- wciController.showLoginForm(req, resp);
+ wciController.showErrorLoginForm(req, resp);
}
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
Modified: epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/login/GateinWCIController.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/login/GateinWCIController.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/login/GateinWCIController.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -66,14 +66,13 @@
public void showErrorLoginForm(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
- String initialURI = getInitialURI(req);
-
- int jsecurityIndex = initialURI.lastIndexOf("/j_security_check");
- if (jsecurityIndex != -1)
+ String initialURI = req.getHeader("referer");
+ if (initialURI == null || initialURI.length() == 0)
{
- initialURI = initialURI.substring(0, jsecurityIndex);
- }
+ initialURI = req.getContextPath();
+ }
+ //
try
{
req.setAttribute("org.gatein.portal.login.initial_uri", initialURI);
@@ -82,7 +81,7 @@
finally
{
req.removeAttribute("org.gatein.portal.login.initial_uri");
- }
+ }
}
@Override
@@ -93,7 +92,7 @@
@Override
public String getHomeURI(final HttpServletRequest req)
- {
- return "/portal/private/classic";
+ {
+ return req.getContextPath();
}
}
Modified: epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/login/RememberMeFilter.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/login/RememberMeFilter.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/login/RememberMeFilter.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -22,6 +22,7 @@
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.web.AbstractFilter;
import org.exoplatform.web.security.security.CookieTokenService;
+import org.exoplatform.web.controller.router.PercentEncoding;
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;
import org.gatein.common.text.FastURLEncoder;
@@ -92,14 +93,7 @@
private String privateUri(HttpServletRequest req)
{
- StringBuilder builder = new StringBuilder();
- builder.append(req.getContextPath());
- builder.append("/private");
- String pathInfo = req.getPathInfo();
- if (pathInfo != null)
- {
- builder.append(pathInfo);
- }
+ StringBuilder builder = new StringBuilder(req.getRequestURI());
char sep = '?';
for (Enumeration<String> e = req.getParameterNames();e.hasMoreElements();)
{
@@ -113,7 +107,7 @@
builder.append(CONVERTER.encode(parameteValue));
}
}
- return builder.toString();
+ return PercentEncoding.QUERY_PARAM.encode(builder);
}
private String loginUrl(String context, String initUrl)
Modified: epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginController.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginController.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginController.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -24,13 +24,15 @@
import org.exoplatform.web.security.security.CookieTokenService;
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;
+import org.gatein.wci.security.Credentials;
import org.gatein.wci.security.WCILoginController;
+import java.io.IOException;
+
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
/**
* @author <a href="mailto:alain.defrance@exoplatform.com">Alain Defrance</a>
@@ -42,9 +44,38 @@
private static final Logger log = LoggerFactory.getLogger(PortalLoginController.class);
@Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
super.doGet(req, resp);
+
+ String username = req.getParameter("username");
+ String password = req.getParameter("password");
+
+ //
+ if (username != null && password != null)
+ {
+ // if we do have a remember me
+ String rememberme = req.getParameter("rememberme");
+ if ("true".equals(rememberme))
+ {
+ boolean isRemember = "true".equals(req.getParameter(InitiateLoginServlet.COOKIE_NAME));
+ if (isRemember)
+ {
+ //Create token
+ AbstractTokenService tokenService = AbstractTokenService.getInstance(CookieTokenService.class);
+ Credentials credentials = (Credentials)req.getSession().getAttribute(Credentials.CREDENTIALS);
+ String cookieToken = tokenService.createToken(credentials);
+ log.debug("Found a remember me request parameter, created a persistent token " + cookieToken + " for it and set it up " +
+ "in the next response");
+ Cookie cookie = new Cookie(InitiateLoginServlet.COOKIE_NAME, cookieToken);
+ cookie.setPath(req.getContextPath());
+ cookie.setMaxAge((int)tokenService.getValidityTime());
+ resp.addCookie(cookie);
+ }
+ }
+ }
+
// Obtain initial URI
String uri = req.getParameter("initialURI");
@@ -59,27 +90,8 @@
log.debug("Found initial URI " + uri);
}
- // if we do have a remember me
- String rememberme = req.getParameter("rememberme");
- if ("true".equals(rememberme))
- {
- boolean isRemember = "true".equals(req.getParameter(InitiateLoginServlet.COOKIE_NAME));
- if (isRemember)
- {
- //Create token
- AbstractTokenService tokenService = AbstractTokenService.getInstance(CookieTokenService.class);
- String cookieToken = tokenService.createToken(credentials);
-
- log.debug("Found a remember me request parameter, created a persistent token " + cookieToken + " for it and set it up " +
- "in the next response");
- Cookie cookie = new Cookie(InitiateLoginServlet.COOKIE_NAME, cookieToken);
- cookie.setPath(req.getContextPath());
- cookie.setMaxAge((int)tokenService.getValidityTime());
- resp.addCookie(cookie);
- }
- }
-
//
- resp.sendRedirect(uri);
+ String redirectURI = req.getContextPath() + "/dologin?initialURI=" + uri;
+ resp.sendRedirect(resp.encodeRedirectURL(redirectURI));
}
}
Deleted: epp/portal/branches/EPP_5_2_Branch/component/web/server/src/main/java/conf/portal/configuration.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/server/src/main/java/conf/portal/configuration.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/server/src/main/java/conf/portal/configuration.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
- <!--
-
- Copyright (C) 2009 eXo Platform SAS. This is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This software is
- distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
- this software; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site:
- http://www.fsf.org.
- -->
-
-<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
- xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
- <component>
- <type>org.exoplatform.upload.UploadService</type>
- <init-params>
- <value-param>
- <name>upload.limit.size</name>
- <description>Maximum size of the file to upload in MB</description>
- <value>10</value>
- </value-param>
- </init-params>
- </component>
-
- <component>
- <type>org.exoplatform.download.DownloadService</type>
- <init-params>
- <value-param>
- <name>download.resource.cache.size</name>
- <description>Maximun number of the download can be in the cache</description>
- <value>500</value>
- </value-param>
- </init-params>
- </component>
-
- <external-component-plugins>
- <target-component>org.exoplatform.services.listener.ListenerService</target-component>
- <component-plugin>
- <name>org.exoplatform.web.GenericHttpListener.sessionDestroyed</name>
- <set-method>addListener</set-method>
- <type>org.exoplatform.upload.UploadSessionListener</type>
- </component-plugin>
- </external-component-plugins>
-
- <external-component-plugins>
- <target-component>org.exoplatform.web.WebAppController</target-component>
- <component-plugin>
- <name>UploadHandler</name>
- <set-method>register</set-method>
- <type>org.exoplatform.web.handler.UploadHandler</type>
- </component-plugin>
- </external-component-plugins>
-
- <external-component-plugins>
- <target-component>org.exoplatform.web.WebAppController</target-component>
- <component-plugin>
- <name>DownloadHandler</name>
- <set-method>register</set-method>
- <type>org.exoplatform.web.handler.DownloadHandler</type>
- </component-plugin>
- </external-component-plugins>
-</configuration>
Modified: epp/portal/branches/EPP_5_2_Branch/component/web/server/src/main/java/org/exoplatform/web/handler/DownloadHandler.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/server/src/main/java/org/exoplatform/web/handler/DownloadHandler.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/server/src/main/java/org/exoplatform/web/handler/DownloadHandler.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -23,6 +23,7 @@
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.download.DownloadResource;
import org.exoplatform.download.DownloadService;
+import org.exoplatform.web.ControllerContext;
import org.exoplatform.web.WebAppController;
import org.exoplatform.web.WebRequestHandler;
@@ -42,10 +43,15 @@
public class DownloadHandler extends WebRequestHandler
{
+ public String getHandlerName()
+ {
+ return "download";
+ }
+
@Override
- public String[] getPath()
+ public void execute(ControllerContext context) throws Exception
{
- return new String[]{"/download"};
+ execute(context.getController(), context.getRequest(), context.getResponse());
}
public void execute(WebAppController controller, HttpServletRequest req, HttpServletResponse res) throws Exception
Modified: epp/portal/branches/EPP_5_2_Branch/component/web/server/src/main/java/org/exoplatform/web/handler/UploadHandler.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/server/src/main/java/org/exoplatform/web/handler/UploadHandler.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/server/src/main/java/org/exoplatform/web/handler/UploadHandler.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -24,6 +24,7 @@
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.upload.UploadResource;
import org.exoplatform.upload.UploadService;
+import org.exoplatform.web.ControllerContext;
import org.exoplatform.web.WebAppController;
import org.exoplatform.web.WebRequestHandler;
@@ -46,10 +47,15 @@
PROGRESS, UPLOAD, DELETE, ABORT
}
+ public String getHandlerName()
+ {
+ return "upload";
+ }
+
@Override
- public String[] getPath()
+ public void execute(ControllerContext context) throws Exception
{
- return new String[]{"/upload"};
+ execute(context.getController(), context.getRequest(), context.getResponse());
}
public void execute(WebAppController controller, HttpServletRequest req, HttpServletResponse res) throws Exception
Added: epp/portal/branches/EPP_5_2_Branch/distribution/jboss-epp/serverAddon/src/main/resources/conf/gatein/controller.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/distribution/jboss-epp/serverAddon/src/main/resources/conf/gatein/controller.xml (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/distribution/jboss-epp/serverAddon/src/main/resources/conf/gatein/controller.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,130 @@
+<!--
+ ~ Copyright (C) 2011 eXo Platform SAS.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+
+<controller
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_controller_1_0 http://www.gatein.org/xml/ns/gatein_controller_1_0"
+ xmlns="http://www.gatein.org/xml/ns/gatein_controller_1_0"
+ separator-escape=":">
+
+ <route path="/upload">
+ <route-param qname="gtn:handler">
+ <value>upload</value>
+ </route-param>
+ </route>
+
+ <route path="/download">
+ <route-param qname="gtn:handler">
+ <value>download</value>
+ </route-param>
+ </route>
+
+ <!-- The legacy route -->
+ <route path="/public">
+ <route path="/">
+ <route-param qname="gtn:handler">
+ <value>default</value>
+ </route-param>
+ </route>
+ <route path="/{gtn:sitename}/{gtn:path}">
+ <route-param qname="gtn:handler">
+ <value>legacy</value>
+ </route-param>
+ <path-param qname="gtn:path" encoding="preserve-path">
+ <pattern>.*</pattern>
+ </path-param>
+ </route>
+ </route>
+ <route path="/private">
+ <route path="/">
+ <route-param qname="gtn:handler">
+ <value>default</value>
+ </route-param>
+ </route>
+ <route path="/{gtn:sitename}/{gtn:path}">
+ <route-param qname="gtn:handler">
+ <value>legacy</value>
+ </route-param>
+ <path-param qname="gtn:path" encoding="preserve-path">
+ <pattern>.*</pattern>
+ </path-param>
+ </route>
+ </route>
+
+ <route path="/">
+
+ <!-- The portal handler -->
+ <route-param qname="gtn:handler">
+ <value>portal</value>
+ </route-param>
+
+ <!-- Webui parameters -->
+ <request-param qname="gtn:componentid" name="portal:componentId"/>
+ <request-param qname="gtn:action" name="portal:action"/>
+ <request-param qname="gtn:objectid" name="objectId"/>
+
+ <!-- The group access -->
+ <route path="/groups/{gtn:sitename}/{gtn:path}">
+ <request-param qname="gtn:lang" name="lang" value-mapping="never-empty">
+ <pattern>([A-Za-z]{2}(-[A-Za-z]{2})?)?</pattern>
+ </request-param>
+ <route-param qname="gtn:sitetype">
+ <value>group</value>
+ </route-param>
+ <path-param qname="gtn:path" encoding="preserve-path">
+ <pattern>.*</pattern>
+ </path-param>
+ </route>
+
+ <!-- The user access -->
+ <route path="/users/{gtn:sitename}/{gtn:path}">
+ <request-param qname="gtn:lang" name="lang" value-mapping="never-empty">
+ <pattern>([A-Za-z]{2}(-[A-Za-z]{2})?)?</pattern>
+ </request-param>
+ <route-param qname="gtn:sitetype">
+ <value>user</value>
+ </route-param>
+ <path-param qname="gtn:path" encoding="preserve-path">
+ <pattern>.*</pattern>
+ </path-param>
+ </route>
+
+ <!-- The portal access -->
+ <route path="/{gtn:lang}/{gtn:sitename}/{gtn:path}">
+ <route-param qname="gtn:sitetype">
+ <value>portal</value>
+ </route-param>
+ <path-param qname="gtn:lang" encoding="preserve-path">
+ <pattern>([A-Za-z]{2}(-[A-Za-z]{2})?)?</pattern>
+ </path-param>
+ <path-param qname="gtn:path" encoding="preserve-path">
+ <pattern>.*</pattern>
+ </path-param>
+ </route>
+
+ </route>
+
+ <!-- Default handler -->
+ <route path="/">
+ <route-param qname="gtn:handler">
+ <value>default</value>
+ </route-param>
+ </route>
+
+</controller>
Modified: epp/portal/branches/EPP_5_2_Branch/examples/extension/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/examples/extension/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/examples/extension/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,98 +1,98 @@
<%
- String initialURI = _ctx.getRequestContext().getParentAppRequestContext().getRequestContextPath() + "/private/" + _ctx.getRequestContext().getParentAppRequestContext().getPortalOwner();
-%>
-<div class="UIHomePagePortlet" id="$uicomponent.id">
- <div class="TRContainer">
- <div class="PortletDecoration">
- <div class="GuideText">GateIn is the new generation of Open Source portal, jointly led by Red Hat and eXo Platform who partner to gather the best portal experts and communities around a robust and intuitive portal that brings rich administration functionalities to IT systems. <br /> This is the Home Page of the "sample-ext" (skin has changed, new pages, customized resource bundles) :</div>
- <a class="VersionIcon" href="http://www.jboss.org/gatein/" target="_blank"></a>
- <div class="DotLine"><span></span></div>
- <div class="GuideText"><%=_ctx.appRes("UIHomePagePortlet.Label.GuideText")%></div>
- <a class="ContactIcon" href="http://community.jboss.org/en/gatein?view=discussions" target="_blank"></a>
-
- </div>
- </div>
- <div class="TLContainer">
- <div class="PortletDecoration">
-
- <div class="HomePortletAdBackround">
- <div class="AdImageLeft">
- <div class="AdImageRight">
- <div class="EmptyBlock"><%=_ctx.appRes("UIHomePagePortlet.Label.Slogan")%></div>
- </div>
- </div>
- </div>
-
- <div class="HomePortletContent">
- <div class="LeftAccountsContainer">
- <div class="RightAccountsContainer">
- <div class="MiddleAccountsContainer">
- <div class="InstructionTitle"><%=_ctx.appRes("UIHomePagePortlet.Label.Title")%></div>
- <div class="AccountsContainerDeco">
- <div class="AccountBlock AdministratorUser">
- <div class="AccountInfos">
- <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=root&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Administrator")%></a></div>
- <div class="Username">
- <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>root</span>
- <div class="ClearBoth"><span></span></div>
- </div>
- <div class="Passwords">
- <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Password")%></div><span>gtn</span>
- <div class="ClearBoth"><span></span></div>
- </div>
- </div>
- </div>
- <div class="SeparatorLine"><span></span></div>
- <div class="AccountBlock ManagerUser">
- <div class="AccountInfos">
- <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=john&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Manager")%></a></div>
- <div class="Username">
- <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>john</span>
- <div class="ClearBoth"><span></span></div>
- </div>
- <div class="Passwords">
- <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Password")%></div><span>gtn</span>
- <div class="ClearBoth"><span></span></div>
- </div>
- </div>
- </div>
- <div class="SeparatorLine"><span></span></div>
- <div class="AccountBlock NormalUser">
- <div class="AccountInfos">
- <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=mary&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.User")%></a></div>
- <div class="Username">
- <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>mary</span>
- <div class="ClearBoth"><span></span></div>
- </div>
- <div class="Passwords">
- <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Password")%></div><span>gtn</span>
- <div class="ClearBoth"><span></span></div>
- </div>
- </div>
- </div>
- <div class="SeparatorLine"><span></span></div>
- <div class="AccountBlock DemoUser" style="margin-right: 0px;">
- <div class="AccountInfos">
- <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=demo&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Demo")%></a></div>
- <div class="Username">
- <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>demo</span>
- <div class="ClearBoth"><span></span></div>
- </div>
- <div class="Passwords">
- <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Password")%></div><span>gtn</span>
- <div class="ClearBoth"><span></span></div>
- </div>
- </div>
- </div>
- <div class="ClearBoth"><span></span></div>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- </div>
- </div>
- <div class="ClearBoth"><span></span></div>
-</div>
-
+ String initialURI = _ctx.getRequestContext().getParentAppRequestContext().getInitialURI();
+%>
+<div class="UIHomePagePortlet" id="$uicomponent.id">
+ <div class="TRContainer">
+ <div class="PortletDecoration">
+ <div class="GuideText"><%=_ctx.appRes("UIHomePagePortlet.Label.IntroText")%> <br /> <%=_ctx.appRes("UIHomePagePortlet.Label.ExtendedHomePage")%></div>
+ <a class="VersionIcon" href="http://www.jboss.org/gatein/" target="_blank"></a>
+ <div class="DotLine"><span></span></div>
+ <div class="GuideText"><%=_ctx.appRes("UIHomePagePortlet.Label.GuideText")%></div>
+ <a class="ContactIcon" href="http://community.jboss.org/en/gatein?view=discussions" target="_blank"></a>
+
+ </div>
+ </div>
+ <div class="TLContainer">
+ <div class="PortletDecoration">
+
+ <div class="HomePortletAdBackround">
+ <div class="AdImageLeft">
+ <div class="AdImageRight">
+ <div class="EmptyBlock"><%=_ctx.appRes("UIHomePagePortlet.Label.Slogan")%></div>
+ </div>
+ </div>
+ </div>
+
+ <div class="HomePortletContent">
+ <div class="LeftAccountsContainer">
+ <div class="RightAccountsContainer">
+ <div class="MiddleAccountsContainer">
+ <div class="InstructionTitle"><%=_ctx.appRes("UIHomePagePortlet.Label.Title")%></div>
+ <div class="AccountsContainerDeco">
+ <div class="AccountBlock AdministratorUser">
+ <div class="AccountInfos">
+ <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=root&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Administrator")%></a></div>
+ <div class="Username">
+ <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>root</span>
+ <div class="ClearBoth"><span></span></div>
+ </div>
+ <div class="Passwords">
+ <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Password")%></div><span>gtn</span>
+ <div class="ClearBoth"><span></span></div>
+ </div>
+ </div>
+ </div>
+ <div class="SeparatorLine"><span></span></div>
+ <div class="AccountBlock ManagerUser">
+ <div class="AccountInfos">
+ <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=john&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Manager")%></a></div>
+ <div class="Username">
+ <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>john</span>
+ <div class="ClearBoth"><span></span></div>
+ </div>
+ <div class="Passwords">
+ <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Password")%></div><span>gtn</span>
+ <div class="ClearBoth"><span></span></div>
+ </div>
+ </div>
+ </div>
+ <div class="SeparatorLine"><span></span></div>
+ <div class="AccountBlock NormalUser">
+ <div class="AccountInfos">
+ <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=mary&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.User")%></a></div>
+ <div class="Username">
+ <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>mary</span>
+ <div class="ClearBoth"><span></span></div>
+ </div>
+ <div class="Passwords">
+ <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Password")%></div><span>gtn</span>
+ <div class="ClearBoth"><span></span></div>
+ </div>
+ </div>
+ </div>
+ <div class="SeparatorLine"><span></span></div>
+ <div class="AccountBlock DemoUser" style="margin-right: 0px;">
+ <div class="AccountInfos">
+ <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=demo&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Demo")%></a></div>
+ <div class="Username">
+ <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>demo</span>
+ <div class="ClearBoth"><span></span></div>
+ </div>
+ <div class="Passwords">
+ <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Password")%></div><span>gtn</span>
+ <div class="ClearBoth"><span></span></div>
+ </div>
+ </div>
+ </div>
+ <div class="ClearBoth"><span></span></div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ </div>
+ </div>
+ <div class="ClearBoth"><span></span></div>
+</div>
+
Modified: epp/portal/branches/EPP_5_2_Branch/examples/portal/war/src/main/webapp/WEB-INF/web.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/examples/portal/war/src/main/webapp/WEB-INF/web.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/examples/portal/war/src/main/webapp/WEB-INF/web.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -58,6 +58,10 @@
<filter>
<filter-name>SetCurrentIdentityFilter</filter-name>
<filter-class>org.exoplatform.services.security.web.SetCurrentIdentityFilter</filter-class>
+ <init-param>
+ <param-name>restoreIdentity</param-name>
+ <param-value>true</param-value>
+ </init-param>
</filter>
<filter>
@@ -185,6 +189,10 @@
<servlet-class>org.exoplatform.web.login.InitiateLoginServlet</servlet-class>
</servlet>
<servlet>
+ <servlet-name>DoLoginServlet</servlet-name>
+ <servlet-class>org.exoplatform.web.login.DoLoginServlet</servlet-class>
+ </servlet>
+ <servlet>
<servlet-name>ErrorLoginServlet</servlet-name>
<servlet-class>org.exoplatform.web.login.ErrorLoginServlet</servlet-class>
</servlet>
@@ -209,58 +217,62 @@
<url-pattern>/login</url-pattern>
</servlet-mapping>
<servlet-mapping>
+ <servlet-name>DoLoginServlet</servlet-name>
+ <url-pattern>/dologin</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
<servlet-name>javascript</servlet-name>
<url-pattern>/javascript/*</url-pattern>
- </servlet-mapping>
+ </servlet-mapping>
<servlet-mapping>
- <servlet-name>portal</servlet-name>
- <url-pattern>/private/*</url-pattern>
+ <servlet-name>RestServer</servlet-name>
+ <url-pattern>/rest/*</url-pattern>
</servlet-mapping>
+
<servlet-mapping>
- <servlet-name>portal</servlet-name>
- <url-pattern>/public/*</url-pattern>
+ <servlet-name>Controller</servlet-name>
+ <url-pattern>/connector</url-pattern>
</servlet-mapping>
+
<servlet-mapping>
- <servlet-name>portal</servlet-name>
- <url-pattern>/admin/*</url-pattern>
+ <servlet-name>GateInServlet</servlet-name>
+ <url-pattern>/gateinservlet</url-pattern>
</servlet-mapping>
+
<servlet-mapping>
- <servlet-name>portal</servlet-name>
- <url-pattern>/service</url-pattern>
- </servlet-mapping>
+ <servlet-name>portal</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
+
+ <!-- Explicit mappings (due to portal servlet on '/') for UIHomePagePortlet, need to find out how to improve that -->
<servlet-mapping>
- <servlet-name>portal</servlet-name>
- <url-pattern>/upload/*</url-pattern>
+ <servlet-name>default</servlet-name>
+ <url-pattern>*.jpg</url-pattern>
</servlet-mapping>
<servlet-mapping>
- <servlet-name>portal</servlet-name>
- <url-pattern>/download/*</url-pattern>
+ <servlet-name>default</servlet-name>
+ <url-pattern>*.png</url-pattern>
</servlet-mapping>
<servlet-mapping>
- <servlet-name>RestServer</servlet-name>
- <url-pattern>/rest/*</url-pattern>
+ <servlet-name>default</servlet-name>
+ <url-pattern>*.gif</url-pattern>
</servlet-mapping>
-
<servlet-mapping>
- <servlet-name>Controller</servlet-name>
- <url-pattern>/connector</url-pattern>
+ <servlet-name>default</servlet-name>
+ <url-pattern>*.ico</url-pattern>
</servlet-mapping>
-
<servlet-mapping>
- <servlet-name>GateInServlet</servlet-name>
- <url-pattern>/gateinservlet</url-pattern>
+ <servlet-name>default</servlet-name>
+ <url-pattern>*.css</url-pattern>
</servlet-mapping>
-
- <!-- The Welcome File List for IBM WebSphere -->
-
- <welcome-file-list>
- <welcome-file>/index.jsp</welcome-file>
- </welcome-file-list>
-
+
<security-constraint>
<web-resource-collection>
<web-resource-name>user authentication</web-resource-name>
+ <url-pattern>/dologin</url-pattern>
<url-pattern>/private/*</url-pattern>
+ <url-pattern>/groups/*</url-pattern>
+ <url-pattern>/users/*</url-pattern>
<http-method>POST</http-method>
<http-method>GET</http-method>
</web-resource-collection>
Deleted: epp/portal/branches/EPP_5_2_Branch/examples/portal/war/src/main/webapp/index.jsp
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/examples/portal/war/src/main/webapp/index.jsp 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/examples/portal/war/src/main/webapp/index.jsp 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,29 +0,0 @@
-<%--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
---%>
-
-<%@ page import="org.exoplatform.container.PortalContainer"%>
-<%@ page import="org.exoplatform.portal.config.UserPortalConfigService"%>
-<%
- PortalContainer manager = PortalContainer.getCurrentInstance(session.getServletContext()) ;
- UserPortalConfigService userPortalConfigService = (UserPortalConfigService) manager.getComponentInstanceOfType(UserPortalConfigService.class) ;
- response.sendRedirect(request.getContextPath() + "/public/"+userPortalConfigService.getDefaultPortal()+"/");
-%>
-
Deleted: epp/portal/branches/EPP_5_2_Branch/examples/portal/war/src/main/webapp/portal-unavailable.jsp
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/examples/portal/war/src/main/webapp/portal-unavailable.jsp 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/examples/portal/war/src/main/webapp/portal-unavailable.jsp 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,126 +0,0 @@
-<%--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
---%>
-
-<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
- <title>Portal Warning </title>
- </head>
- <style>
- .UIPortalWarning {
- width: 600px;
- margin: 200px auto auto auto;
- font-family: tahoma;
- font-size: 12px;
- }
-
- .UIPortalWarning .LeftTopWarning {
- background: url('/eXoResources/skin/sharedImages/LeftTopWarning7x58.gif') no-repeat left center;
- height: 58px;
- padding-left: 7px;
- }
-
- .UIPortalWarning .RightTopWarning {
- background: url('/eXoResources/skin/sharedImages/RightTopWarning7x58.gif') no-repeat right center;
- height: 58px;
- padding-right: 7px;
- }
-
- .UIPortalWarning .CenterTopWaring {
- background: url('/eXoResources/skin/sharedImages/CenterTopWarning1x58.gif') repeat-x center;
- height: 58px;
- line-height: 58px;
- }
-
- .UIPortalWarning .CenterTopWaring .TitleWaring {
- background: url('/eXoResources/skin/sharedImages/WarningIcon.gif') no-repeat left center;
- padding-left: 50px;
- font-size: 18px;
- font-weight: bold;
- line-height: 58px;
- text-align: left;
- margin-left: 20px;
- }
-
- .UIPortalWarning .LeftMiddleWarning {
- background: url('/eXoResources/skin/sharedImages/LeftMiddleWarning7x1.gif') repeat-y left;
- padding-left: 7px;
- }
-
- .UIPortalWarning .RightMiddleWarning {
- background: url('/eXoResources/skin/sharedImages/RightMiddleWarning7x1.gif') repeat-y right;
- text-align: left;
- padding: 30px 30px 50px 30px;
- }
-
- .UIPortalWarning .RightMiddleWarning .Icon {
- background: url('/eXoResources/skin/sharedImages/BlueNextArrow.gif') no-repeat left 5px;
- padding: 6px 0px 6px 20px;
- text-align: left;
- }
-
- .UIPortalWarning .LeftBottomWarning {
- background: url('/eXoResources/skin/sharedImages/LeftBottomWarning7x7.gif') no-repeat left center;
- height: 7px;
- padding-left: 7px;
- }
-
- .UIPortalWarning .RightBottomWarning {
- background: url('/eXoResources/skin/sharedImages/RightBottomWarning7x7.gif') no-repeat right center;
- height: 7px;
- padding-right: 7px;
- }
-
- .UIPortalWarning .CenterBottomWaring {
- background: url('/eXoResources/skin/sharedImages/CenterBottomWarning1x7.gif') repeat-x center;
- height: 7px;
- }
-
- </style>
- <% String contextPath = request.getContextPath() ; %>
- <body style="text-align: center;">
- <div class="UIPortalWarning">
-
- <div class="LeftTopWarning">
- <div class="RightTopWarning">
- <div class="CenterTopWaring">
- <div class="TitleWaring">Can not connect to this portal</div>
- </div>
- </div>
- </div>
- <div class="LeftMiddleWarning">
- <div class="RightMiddleWarning">
- <div class="WarningContent">
- <div class="Icon">Try private mode by URL format: <strong>http://$hostname$<%=contextPath%>/private/$portalname$/</strong></div>
- <div class="Icon">Try another Portal or user URL "<strong>http://$hostname$<%=contextPath%></strong> for default portal.</div>
- </div>
- </div>
- </div>
- <div class="LeftBottomWarning">
- <div class="RightBottomWarning">
- <div class="CenterBottomWaring"><span></span></div>
- </div>
- </div>
-
- </div>
- </body>
-</html>
-
\ No newline at end of file
Deleted: epp/portal/branches/EPP_5_2_Branch/examples/portal/war/src/main/webapp/portal-warning.jsp
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/examples/portal/war/src/main/webapp/portal-warning.jsp 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/examples/portal/war/src/main/webapp/portal-warning.jsp 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,126 +0,0 @@
-<%--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
---%>
-
-<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
- <title>Portal Warning </title>
- </head>
- <style>
- .UIPortalWarning {
- width: 600px;
- margin: 200px auto auto auto;
- font-family: tahoma;
- font-size: 12px;
- }
-
- .UIPortalWarning .LeftTopWarning {
- background: url('/eXoResources/skin/sharedImages/LeftTopWarning7x58.gif') no-repeat left center;
- height: 58px;
- padding-left: 7px;
- }
-
- .UIPortalWarning .RightTopWarning {
- background: url('/eXoResources/skin/sharedImages/RightTopWarning7x58.gif') no-repeat right center;
- height: 58px;
- padding-right: 7px;
- }
-
- .UIPortalWarning .CenterTopWaring {
- background: url('/eXoResources/skin/sharedImages/CenterTopWarning1x58.gif') repeat-x center;
- height: 58px;
- line-height: 58px;
- }
-
- .UIPortalWarning .CenterTopWaring .TitleWaring {
- background: url('/eXoResources/skin/sharedImages/WarningIcon.gif') no-repeat left center;
- padding-left: 50px;
- font-size: 18px;
- font-weight: bold;
- line-height: 58px;
- text-align: left;
- margin-left: 20px;
- }
-
- .UIPortalWarning .LeftMiddleWarning {
- background: url('/eXoResources/skin/sharedImages/LeftMiddleWarning7x1.gif') repeat-y left;
- padding-left: 7px;
- }
-
- .UIPortalWarning .RightMiddleWarning {
- background: url('/eXoResources/skin/sharedImages/RightMiddleWarning7x1.gif') repeat-y right;
- text-align: left;
- padding: 30px 30px 50px 30px;
- }
-
- .UIPortalWarning .RightMiddleWarning .Icon {
- background: url('/eXoResources/skin/sharedImages/BlueNextArrow.gif') no-repeat left 5px;
- padding: 6px 0px 6px 20px;
- text-align: left;
- }
-
- .UIPortalWarning .LeftBottomWarning {
- background: url('/eXoResources/skin/sharedImages/LeftBottomWarning7x7.gif') no-repeat left center;
- height: 7px;
- padding-left: 7px;
- }
-
- .UIPortalWarning .RightBottomWarning {
- background: url('/eXoResources/skin/sharedImages/RightBottomWarning7x7.gif') no-repeat right center;
- height: 7px;
- padding-right: 7px;
- }
-
- .UIPortalWarning .CenterBottomWaring {
- background: url('/eXoResources/skin/sharedImages/CenterBottomWarning1x7.gif') repeat-x center;
- height: 7px;
- }
-
- </style>
- <% String contextPath = request.getContextPath() ; %>
- <body style="text-align: center;">
- <div class="UIPortalWarning">
-
- <div class="LeftTopWarning">
- <div class="RightTopWarning">
- <div class="CenterTopWaring">
- <div class="TitleWaring">Resources not found</div>
- </div>
- </div>
- </div>
- <div class="LeftMiddleWarning">
- <div class="RightMiddleWarning">
- <div class="WarningContent">
- <div class="Icon">Try private mode by URL format: <strong>http://$hostname$<%=contextPath%>/private/$portalname$/</strong></div>
- <div class="Icon">Try another Portal.</div>
- </div>
- </div>
- </div>
- <div class="LeftBottomWarning">
- <div class="RightBottomWarning">
- <div class="CenterBottomWaring"><span></span></div>
- </div>
- </div>
-
- </div>
- </body>
-</html>
-
\ No newline at end of file
Modified: epp/portal/branches/EPP_5_2_Branch/examples/portal/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/examples/portal/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/examples/portal/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,109 +1,109 @@
<%
- String initialURI = _ctx.getRequestContext().getParentAppRequestContext().getRequestContextPath() + "/private/" + _ctx.getRequestContext().getParentAppRequestContext().getPortalOwner();
-%>
-<div class="UIHomePagePortlet" id="$uicomponent.id">
- <div class="TRContainer">
- <div class="PortletDecoration">
- <div class="GuideText">This is the Home Page of the "sample-portal" contained in gatein-sample-extension.ear/war, as you can see the skin has changed, we added new pages, we use our customized resource bundles as you can see below:
- <ul>
- <li><b><%=_ctx.appRes("UIHomePagePortlet.Label.SampleKey")%></b></li>
- <li><b><%=_ctx.appRes("UIHomePagePortlet.Label.SampleRB.SampleKey")%></b></li>
- </ul>
- </div>
- <a class="VersionIcon" href="http://www.jboss.org/gatein/" target="_blank"></a>
- <div class="DotLine"><span></span></div>
- <div class="GuideText"><%=_ctx.appRes("UIHomePagePortlet.Label.GuideText")%></div>
- <a class="ContactIcon" href="http://community.jboss.org/en/gatein?view=discussions" target="_blank"></a>
-
- </div>
- </div>
- <div class="TLContainer">
- <div class="PortletDecoration">
-
- <div class="HomePortletAdBackround">
- <div class="AdImageLeft">
- <div class="AdImageRight">
- <div class="EmptyBlock"><%=_ctx.appRes("UIHomePagePortlet.Label.Slogan")%></div>
- </div>
- </div>
- </div>
-
- <div class="HomePortletContent">
- <div class="LeftAccountsContainer">
- <div class="RightAccountsContainer">
- <div class="MiddleAccountsContainer">
- <div class="InstructionTitle"><%=_ctx.appRes("UIHomePagePortlet.Label.Title")%></div>
- <div class="AccountsContainerDeco">
- <div class="AccountBlock AdministratorUser">
- <div class="AccountInfos">
- <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=root&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Administrator")%></a></div>
- <div class="Username">
- <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>root</span>
- <div class="ClearBoth"><span></span></div>
- </div>
- <div class="Passwords">
- <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Password")%></div><span>gtn</span>
- <div class="ClearBoth"><span></span></div>
- </div>
- </div>
- </div>
- <div class="SeparatorLine"><span></span></div>
- <div class="AccountBlock ManagerUser">
- <div class="AccountInfos">
- <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=john&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Manager")%></a></div>
- <div class="Username">
- <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>john</span>
- <div class="ClearBoth"><span></span></div>
- </div>
- <div class="Passwords">
- <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Password")%></div><span>gtn</span>
- <div class="ClearBoth"><span></span></div>
- </div>
- </div>
- </div>
- <div class="SeparatorLine"><span></span></div>
- <div class="AccountBlock NormalUser">
- <div class="AccountInfos">
- <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=mary&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.User")%></a></div>
- <div class="Username">
- <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>mary</span>
- <div class="ClearBoth"><span></span></div>
- </div>
- <div class="Passwords">
- <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Password")%></div><span>gtn</span>
- <div class="ClearBoth"><span></span></div>
- </div>
- </div>
- </div>
- <div class="SeparatorLine"><span></span></div>
- <div class="AccountBlock DemoUser" style="margin-right: 0px;">
- <div class="AccountInfos">
- <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=demo&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Demo")%></a></div>
- <div class="Username">
- <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>demo</span>
- <div class="ClearBoth"><span></span></div>
- </div>
- <div class="Passwords">
- <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Password")%></div><span>gtn</span>
- <div class="ClearBoth"><span></span></div>
- </div>
- </div>
- </div>
- <div class="ClearBoth"><span></span></div>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- </div>
- </div>
- <div class="ClearBoth"><span></span></div>
-</div>
-<div class="BottomDecoratorHome">
- <div class="BottomDecoratorLeft">
- <div class="BottomDecoratorRight">
- <div class="BottomDecoratorMiddle"><span></span></div>
- </div>
- </div>
-</div>
+ String initialURI = _ctx.getRequestContext().getParentAppRequestContext().getInitialURI();
+%>
+<div class="UIHomePagePortlet" id="$uicomponent.id">
+ <div class="TRContainer">
+ <div class="PortletDecoration">
+ <div class="GuideText"><%=_ctx.appRes("UIHomePagePortlet.Label.ExtendedHomePage")%>
+ <ul>
+ <li><b><%=_ctx.appRes("UIHomePagePortlet.Label.SampleKey")%></b></li>
+ <li><b><%=_ctx.appRes("UIHomePagePortlet.Label.SampleRB.SampleKey")%></b></li>
+ </ul>
+ </div>
+ <a class="VersionIcon" href="http://www.jboss.org/gatein/" target="_blank"></a>
+ <div class="DotLine"><span></span></div>
+ <div class="GuideText"><%=_ctx.appRes("UIHomePagePortlet.Label.GuideText")%></div>
+ <a class="ContactIcon" href="http://community.jboss.org/en/gatein?view=discussions" target="_blank"></a>
+
+ </div>
+ </div>
+ <div class="TLContainer">
+ <div class="PortletDecoration">
+
+ <div class="HomePortletAdBackround">
+ <div class="AdImageLeft">
+ <div class="AdImageRight">
+ <div class="EmptyBlock"><%=_ctx.appRes("UIHomePagePortlet.Label.Slogan")%></div>
+ </div>
+ </div>
+ </div>
+
+ <div class="HomePortletContent">
+ <div class="LeftAccountsContainer">
+ <div class="RightAccountsContainer">
+ <div class="MiddleAccountsContainer">
+ <div class="InstructionTitle"><%=_ctx.appRes("UIHomePagePortlet.Label.Title")%></div>
+ <div class="AccountsContainerDeco">
+ <div class="AccountBlock AdministratorUser">
+ <div class="AccountInfos">
+ <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=root&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Administrator")%></a></div>
+ <div class="Username">
+ <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>root</span>
+ <div class="ClearBoth"><span></span></div>
+ </div>
+ <div class="Passwords">
+ <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Password")%></div><span>gtn</span>
+ <div class="ClearBoth"><span></span></div>
+ </div>
+ </div>
+ </div>
+ <div class="SeparatorLine"><span></span></div>
+ <div class="AccountBlock ManagerUser">
+ <div class="AccountInfos">
+ <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=john&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Manager")%></a></div>
+ <div class="Username">
+ <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>john</span>
+ <div class="ClearBoth"><span></span></div>
+ </div>
+ <div class="Passwords">
+ <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Password")%></div><span>gtn</span>
+ <div class="ClearBoth"><span></span></div>
+ </div>
+ </div>
+ </div>
+ <div class="SeparatorLine"><span></span></div>
+ <div class="AccountBlock NormalUser">
+ <div class="AccountInfos">
+ <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=mary&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.User")%></a></div>
+ <div class="Username">
+ <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>mary</span>
+ <div class="ClearBoth"><span></span></div>
+ </div>
+ <div class="Passwords">
+ <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Password")%></div><span>gtn</span>
+ <div class="ClearBoth"><span></span></div>
+ </div>
+ </div>
+ </div>
+ <div class="SeparatorLine"><span></span></div>
+ <div class="AccountBlock DemoUser" style="margin-right: 0px;">
+ <div class="AccountInfos">
+ <div class="AccountTitle"><a href="${_ctx.getPortalContextPath()}/login?username=demo&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Demo")%></a></div>
+ <div class="Username">
+ <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>demo</span>
+ <div class="ClearBoth"><span></span></div>
+ </div>
+ <div class="Passwords">
+ <div class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Password")%></div><span>gtn</span>
+ <div class="ClearBoth"><span></span></div>
+ </div>
+ </div>
+ </div>
+ <div class="ClearBoth"><span></span></div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ </div>
+ </div>
+ <div class="ClearBoth"><span></span></div>
+</div>
+<div class="BottomDecoratorHome">
+ <div class="BottomDecoratorLeft">
+ <div class="BottomDecoratorRight">
+ <div class="BottomDecoratorMiddle"><span></span></div>
+ </div>
+ </div>
+</div>
Copied: epp/portal/branches/EPP_5_2_Branch/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/LocaleURLPortlet.java (from rev 7117, portal/trunk/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/LocaleURLPortlet.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/LocaleURLPortlet.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/LocaleURLPortlet.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.gatein.portal.samples.api;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletException;
+import javax.portlet.PortletURL;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import javax.portlet.ResourceURL;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Locale;
+
+/**
+ * This portlet shows how to leverage the portlet URL <code>gtn:lang</code> property to set the language
+ * for render urls.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public class LocaleURLPortlet extends GenericPortlet
+{
+
+ @Override
+ public void serveResource(ResourceRequest req, ResourceResponse resp) throws PortletException, IOException
+ {
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+ String namespace = "n_" + resp.getNamespace();
+ ResourceURL resourceURL = resp.createResourceURL();
+ resourceURL.setCacheability(ResourceURL.PAGE);
+ PortletURL renderURL = resp.createRenderURL();
+ Locale current = req.getLocale();
+
+ //
+ writer.print(
+ "<html>" +
+ "<head>" +
+ "<script type='text/javascript'>" +
+ "function openLinkInParent(){" +
+ "var e = document.getElementById(\"" + namespace + "\");" +
+ "var url = e.options[e.selectedIndex].value;" +
+ "window.open(url,'" + namespace + "_parent');" +
+ "window.focus();" +
+ "}\n");
+
+ writer.print(
+ "</script>" +
+ "</head>" +
+ "<body>");
+
+ writer.print("<p>Selecting a language will update the main portal window with the language in URL</p>");
+
+ writer.print("<p><form action=\"javascript:openLinkInParent()\">");
+ writer.print("<select id=\"" + namespace + "\">");
+ renderURL.setProperty("gtn:lang", "");
+ writer.print("<option value='" + renderURL + "'> </option>");
+ for (String lang : new String[]{"en","fr","it","vi"})
+ {
+ renderURL.setProperty("gtn:lang", lang);
+ writer.print("<option value=\"" + renderURL + "\">" + new Locale(lang).getDisplayName(current) + "</option>");
+ }
+ writer.print("</select>");
+ writer.print("<input type='submit' value=\"Change\"/>");
+ writer.print("</form></p>");
+ writer.print("</body></html>");
+ }
+
+ @Override
+ protected void doView(RenderRequest req, RenderResponse resp) throws PortletException, IOException
+ {
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+ Locale current = req.getLocale();
+ ResourceURL resource = resp.createResourceURL();
+ resource.setCacheability(ResourceURL.PAGE);
+ String namespace = "n_" + resp.getNamespace();
+ String remoteWindowName = namespace + "_remote";
+
+ writer.print(
+ "<script type='text/javascript'>" +
+ "var " + remoteWindowName + "; function " + namespace + "_popup(url){" +
+ "window.name='" + namespace + "_parent';" +
+ "window.open(url, '" + remoteWindowName + "', 'width=256,height=128,scrollable=yes')" +
+ "}" +
+ "onload = function() {" +
+ "if (typeof " + remoteWindowName + " != 'undefined') " +
+ "{" + remoteWindowName + ".location.reload(true);" +
+ "}" +
+ "}" +
+ "</script>");
+
+ writer.print(
+ "<p><a href='#' onclick=\"" + namespace + "_remote=" + namespace + "_popup('" + resource + "')\">" +
+ "Language controller</a></p>");
+
+ writer.print("<p>Current locale is " + current.getDisplayName(current) + "</p>");
+
+ //
+ writer.close();
+ }
+}
Modified: epp/portal/branches/EPP_5_2_Branch/examples/portlets/api/src/main/webapp/WEB-INF/portlet.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/examples/portlets/api/src/main/webapp/WEB-INF/portlet.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/examples/portlets/api/src/main/webapp/WEB-INF/portlet.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -84,4 +84,78 @@
<qname xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:window_show_info_bar</qname>
</public-render-parameter>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+
+ <portlet-info>
+ <title>API Navigation Portlet</title>
+ <short-title>Navigation Portlet</short-title>
+ <keywords>Sample</keywords>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <description xml:lang="EN">Content Registry Portlet Example using GateIn's public API</description>
+ <portlet-name>ContentRegistryAPIPortlet</portlet-name>
+ <display-name xml:lang="EN">API Content Registry Portlet</display-name>
+ <portlet-class>org.gatein.portal.samples.api.ContentRegistryPortlet</portlet-class>
+
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+
+ <portlet-info>
+ <title>API Content Registry Portlet</title>
+ <short-title>Content Registry Portlet</short-title>
+ <keywords>Sample</keywords>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <description xml:lang="EN">Locale URL Portlet</description>
+ <portlet-name>LocaleURLPortlet</portlet-name>
+ <display-name xml:lang="EN">A Portlet example demonstrating locale selection in URL</display-name>
+ <portlet-class>org.gatein.portal.samples.api.LocaleURLPortlet</portlet-class>
+
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+
+ <portlet-info>
+ <title>Locale URL Portlet</title>
+ <short-title>Locale URL Portlet</short-title>
+ <keywords>Sample</keywords>
+ </portlet-info>
+ </portlet>
+
+ <public-render-parameter>
+ <identifier>navigation_uri</identifier>
+ <qname xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:navigation_uri</qname>
+ </public-render-parameter>
+ <public-render-parameter>
+ <identifier>page_name</identifier>
+ <qname xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:page_name</qname>
+ </public-render-parameter>
+ <public-render-parameter>
+ <identifier>site_type</identifier>
+ <qname xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:site_type</qname>
+ </public-render-parameter>
+ <public-render-parameter>
+ <identifier>site_name</identifier>
+ <qname xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:site_name</qname>
+ </public-render-parameter>
+ <public-render-parameter>
+ <identifier>window_width</identifier>
+ <qname xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:window_width</qname>
+ </public-render-parameter>
+ <public-render-parameter>
+ <identifier>window_height</identifier>
+ <qname xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:window_height</qname>
+ </public-render-parameter>
+ <public-render-parameter>
+ <identifier>window_show_info_bar</identifier>
+ <qname xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:window_show_info_bar</qname>
+ </public-render-parameter>
+
</portlet-app>
Deleted: epp/portal/branches/EPP_5_2_Branch/gadgets/core/src/main/java/conf/configuration.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/gadgets/core/src/main/java/conf/configuration.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/gadgets/core/src/main/java/conf/configuration.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-
-<configuration
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
- xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
-</configuration>
\ No newline at end of file
Deleted: epp/portal/branches/EPP_5_2_Branch/gadgets/core/src/main/java/conf/portal/configuration.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/gadgets/core/src/main/java/conf/portal/configuration.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/gadgets/core/src/main/java/conf/portal/configuration.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,82 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-
-<configuration
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
- xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
-<component>
- <key>org.exoplatform.portal.gadget.core.SecurityTokenGenerator</key>
- <type>org.exoplatform.portal.gadget.core.ExoDefaultSecurityTokenGenerator</type>
- </component>
- <component>
- <type>org.exoplatform.portal.gadget.core.GadgetTokenInfoService</type>
- <init-params>
- <values-param>
- <name>service.configuration</name>
- <value>gadget-token</value>
- <value>7</value>
- <value>DAY</value>
- </values-param>
- </init-params>
- </component>
-
- <external-component-plugins>
- <target-component>org.exoplatform.commons.chromattic.ChromatticManager</target-component>
- <component-plugin>
- <name>chromattic</name>
- <set-method>addLifeCycle</set-method>
- <type>org.exoplatform.commons.chromattic.ChromatticLifeCycle</type>
- <init-params>
- <value-param>
- <name>domain-name</name>
- <value>gadgettokens</value>
- </value-param>
- <value-param>
- <name>workspace-name</name>
- <value>portal-work</value>
- </value-param>
- <values-param>
- <name>entities</name>
- <value>org.exoplatform.portal.gadget.core.GadgetTokenContainer</value>
- <value>org.exoplatform.portal.gadget.core.GadgetTokenEntry</value>
- </values-param>
- </init-params>
- </component-plugin>
- </external-component-plugins>
-
- <external-component-plugins>
- <target-component>org.exoplatform.services.jcr.RepositoryService</target-component>
- <component-plugin>
- <name>add.nodeType</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.jcr.impl.AddNodeTypePlugin</type>
- <init-params>
- <values-param>
- <name>autoCreatedInNewRepository</name>
- <description>Node types configuration file</description>
- <value>jar:/conf/gadgettoken-nodetypes.xml</value>
- </values-param>
- </init-params>
- </component-plugin>
- </external-component-plugins>
-</configuration>
\ No newline at end of file
Modified: epp/portal/branches/EPP_5_2_Branch/pom.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/pom.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/pom.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -45,7 +45,7 @@
<org.shindig.version>2.0.2-Beta02</org.shindig.version>
<nl.captcha.simplecaptcha.version>1.1.1-GA-Patch01</nl.captcha.simplecaptcha.version>
<org.gatein.common.version>2.0.4-Beta03</org.gatein.common.version>
- <org.gatein.wci.version>2.1.0-Beta04</org.gatein.wci.version>
+ <org.gatein.wci.version>2.1.0-Beta06</org.gatein.wci.version>
<org.gatein.pc.version>2.3.0-Beta04</org.gatein.pc.version>
<org.picketlink.idm>1.3.0.Alpha03</org.picketlink.idm>
<org.gatein.wsrp.version>2.1.0-Beta04</org.gatein.wsrp.version>
@@ -60,6 +60,7 @@
<version.reflect>1.1.0-beta12</version.reflect>
<org.staxnav.version>0.9.4</org.staxnav.version>
<jcip.version>1.0</jcip.version>
+ <commons-dbcp.version>1.2.2</commons-dbcp.version>
<!-- ************** -->
<!-- Build settings -->
@@ -779,7 +780,7 @@
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20070829</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
@@ -915,13 +916,14 @@
<artifactId>simplecaptcha</artifactId>
<version>${nl.captcha.simplecaptcha.version}</version>
</dependency>
- <!-- needed for the IBM jdk, should be remove in the future when IBM fixes its jdk (see GTNPORTAL-636) -->
+
+ <!-- needed for the IBM jdk, should be remove in the future when IBM fixes its jdk (see GTNPORTAL-636) -->
<dependency>
<groupId>net.jcip</groupId>
<artifactId>jcip-annotations</artifactId>
<version>${jcip.version}</version>
</dependency>
-
+
</dependencies>
</dependencyManagement>
@@ -954,11 +956,15 @@
</resources>
<testResources>
<testResource>
- <directory>src/test/resources</directory>
+ <directory>src/test/java</directory>
<includes>
- <include>**/*.*</include>
+ <include>**/*.properties</include>
+ <include>**/*.xml</include>
</includes>
</testResource>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
</testResources>
<pluginManagement>
<plugins>
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardPortlet.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardPortlet.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardPortlet.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -68,7 +68,7 @@
PortletRequestContext context = (PortletRequestContext)WebuiRequestContext.getCurrentInstance();
PortalRequestContext prc = (PortalRequestContext)context.getParentAppRequestContext();
UIPortalApplication portalApp = (UIPortalApplication)prc.getUIApplication();
- UIPortal portal = portalApp.getShowedUIPortal();
+ UIPortal portal = portalApp.getCurrentSite();
//
try
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UITabPaneDashboard.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UITabPaneDashboard.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UITabPaneDashboard.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -19,13 +19,6 @@
package org.exoplatform.dashboard.webui.component;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.config.UserPortalConfigService;
@@ -38,6 +31,7 @@
import org.exoplatform.portal.mop.user.UserNode;
import org.exoplatform.portal.mop.user.UserNodeFilterConfig;
import org.exoplatform.portal.mop.user.UserPortal;
+import org.exoplatform.web.url.navigation.NodeURL;
import org.exoplatform.portal.webui.page.UIPageBody;
import org.exoplatform.portal.webui.portal.UIPortal;
import org.exoplatform.portal.webui.util.Util;
@@ -54,6 +48,11 @@
import org.exoplatform.webui.event.Event;
import org.exoplatform.webui.event.EventListener;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
/**
*
* Created by eXoPlatform SAS
@@ -101,7 +100,7 @@
uiPortal = Util.getUIPortal();
UserNodeFilterConfig.Builder scopeBuilder = UserNodeFilterConfig.builder();
- scopeBuilder.withAuthorizationCheck().withVisibility(Visibility.DISPLAYED, Visibility.TEMPORAL);
+ scopeBuilder.withReadWriteCheck().withVisibility(Visibility.DISPLAYED, Visibility.TEMPORAL);
scopeBuilder.withTemporalCheck();
filterConfig = scopeBuilder.build();
}
@@ -249,7 +248,7 @@
}
}
- public String createNewPageNode(String nodeLabel)
+ public UserNode createNewPageNode(String nodeLabel)
{
try
{
@@ -285,7 +284,7 @@
getUserPortal().saveNode(parentNode, null);
- return tabNode.getURI();
+ return tabNode;
}
catch (Exception ex)
{
@@ -317,7 +316,7 @@
return true;
}
- public String renamePageNode(String nodeName, String newNodeLabel)
+ public UserNode renamePageNode(String nodeName, String newNodeLabel)
{
try
{
@@ -344,7 +343,7 @@
}
getUserPortal().saveNode(parentNode, null);
- return renamedNode.getURI();
+ return renamedNode;
}
catch (Exception ex)
{
@@ -381,25 +380,6 @@
}
}
- private String encodeURI(String uri) throws UnsupportedEncodingException
- {
- if (uri == null || uri.isEmpty())
- {
- return "";
- }
- String[] path = uri.split("/");
- StringBuilder uriBuilder = new StringBuilder();
- for (String name : path)
- {
- uriBuilder.append("/").append(URLEncoder.encode(name, "UTF-8"));
- }
- if (uriBuilder.indexOf("/") == 0)
- {
- uriBuilder.deleteCharAt(0);
- }
- return uriBuilder.toString();
- }
-
static public class DeleteTabActionListener extends EventListener<UITabPaneDashboard>
{
public void execute(Event<UITabPaneDashboard> event) throws Exception
@@ -407,7 +387,7 @@
UITabPaneDashboard source = event.getSource();
WebuiRequestContext context = event.getRequestContext();
String nodeName = context.getRequestParameter(UIComponent.OBJECTID);
- String newUri = source.getFirstAvailableURI();
+ UserNode nextNode = source.getFirstAvailableNode();
UserNode selectedNode = source.removePageNode(nodeName);
//If the node is removed successfully, then redirect to the node specified by tab on the left
@@ -420,12 +400,13 @@
{
uiPageBody.setMaximizedUIComponent(null);
}
- newUri = selectedNode.getURI();
+ nextNode = selectedNode;
}
PortalRequestContext prContext = Util.getPortalRequestContext();
- prContext.setResponseComplete(true);
- prContext.getResponse().sendRedirect(prContext.getPortalURI() + source.encodeURI(newUri));
+ NodeURL nodeURL = prContext.createURL(NodeURL.TYPE).setNode(nextNode);
+
+ prContext.sendRedirect(nodeURL.toString());
}
}
@@ -436,7 +417,7 @@
UITabPaneDashboard tabPane = event.getSource();
WebuiRequestContext context = event.getRequestContext();
String newTabLabel = context.getRequestParameter(UIComponent.OBJECTID);
- String newUri = tabPane.getFirstAvailableURI();
+ UserNode node = tabPane.getFirstAvailableNode();
if (!tabPane.validateName(newTabLabel))
{
Object[] args = {newTabLabel};
@@ -444,16 +425,17 @@
}
else
{
- String uri = tabPane.createNewPageNode(newTabLabel);
- if (uri != null)
+ UserNode createdNode = tabPane.createNewPageNode(newTabLabel);
+ if (createdNode != null)
{
- newUri = uri;
+ node = createdNode;
}
}
PortalRequestContext prContext = Util.getPortalRequestContext();
- prContext.setResponseComplete(true);
- prContext.getResponse().sendRedirect(prContext.getPortalURI() + tabPane.encodeURI(newUri));
+ NodeURL nodeURL = prContext.createURL(NodeURL.TYPE).setNode(node);
+
+ prContext.sendRedirect(nodeURL.toString());
}
}
@@ -476,7 +458,7 @@
UIApplication rootUI = context.getUIApplication();
String newTabLabel = context.getRequestParameter(RENAMED_TAB_LABEL_PARAMETER);
- String newUri = tabPane.getFirstAvailableURI();
+ UserNode node = tabPane.getFirstAvailableNode();
if (!tabPane.validateName(newTabLabel))
{
Object[] args = {newTabLabel};
@@ -485,15 +467,16 @@
else
{
String nodeName = context.getRequestParameter(UIComponent.OBJECTID);
- String returnUri = tabPane.renamePageNode(nodeName, newTabLabel);
- if (returnUri != null)
+ UserNode renamedNode = tabPane.renamePageNode(nodeName, newTabLabel);
+ if (renamedNode != null)
{
- newUri = returnUri;
+ node = renamedNode;
}
}
PortalRequestContext prContext = Util.getPortalRequestContext();
- prContext.getResponse().sendRedirect(prContext.getPortalURI() + tabPane.encodeURI(newUri));
- prContext.setResponseComplete(true);
+ NodeURL nodeURL = prContext.createURL(NodeURL.TYPE).setNode(node);
+
+ prContext.sendRedirect(nodeURL.toString());
}
}
@@ -522,7 +505,7 @@
* if there is no node remain, return default path
* @throws Exception
*/
- public String getFirstAvailableURI() throws Exception
+ public UserNode getFirstAvailableNode() throws Exception
{
UserNode parentTab = getParentTab();
if (parentTab != null)
@@ -530,19 +513,19 @@
UserNode currNode = Util.getUIPortal().getSelectedUserNode();
if (parentTab.getChildren().size() == 0 && parentTab.getURI() != null)
{
- return parentTab.getURI();
+ return parentTab;
}
if (parentTab.getChild(currNode.getName()) != null)
{
- return currNode.getURI();
+ return currNode;
}
else
{
- return parentTab.getChild(0).getURI();
+ return parentTab.getChild(0);
}
}
- return getUserPortal().getDefaultPath(null).getURI();
+ return getUserPortal().getDefaultPath(null);
}
}
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/dashboard/src/main/webapp/groovy/dashboard/webui/component/UITabPaneDashboard.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/dashboard/src/main/webapp/groovy/dashboard/webui/component/UITabPaneDashboard.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/dashboard/src/main/webapp/groovy/dashboard/webui/component/UITabPaneDashboard.gtmpl 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,81 +1,80 @@
<%
- import org.exoplatform.portal.webui.util.Util;
- import org.exoplatform.portal.webui.portal.UIPortal;
- import org.exoplatform.portal.application.PortalRequestContext;
- import org.exoplatform.web.application.JavascriptManager;
- import org.gatein.common.text.EntityEncoder;
- import org.exoplatform.portal.mop.user.UserNode;
-
- def nodes = uicomponent.getSameSiblingsNode();
- def tabNbs = nodes.size();
-
- PortalRequestContext pcontext = Util.getPortalRequestContext();
- def portalURI = pcontext.getPortalURI();
-
- def selectedNode = Util.getUIPortal().getSelectedUserNode();
-
- JavascriptManager jsManager = pcontext.getJavascriptManager();
- jsManager.importJavascript("eXo.webui.UITabbedDashboard");
-%>
-
-<div id="$uicomponent.id" class="UITabPaneDashboard">
- <div class="LtTabDashboard">
- <div class="RtTabDashboard">
+ import org.exoplatform.portal.webui.util.Util;
+ import org.exoplatform.portal.webui.portal.UIPortal;
+ import org.exoplatform.portal.application.PortalRequestContext;
+ import org.exoplatform.web.application.JavascriptManager;
+ import org.exoplatform.portal.mop.user.UserNode;
+ import org.exoplatform.web.url.PortalURL;
+ import org.exoplatform.web.url.navigation.NavigationResource;
+
+ def nodes = uicomponent.getSameSiblingsNode();
+ def tabNbs = nodes.size();
+
+ PortalRequestContext pcontext = Util.getPortalRequestContext();
+ PortalURL nodeURL = nodeurl();
+
+ def selectedNode = Util.getUIPortal().getSelectedUserNode();
+
+ JavascriptManager jsManager = pcontext.getJavascriptManager();
+ jsManager.importJavascript("eXo.webui.UITabbedDashboard");
+%>
+<div id="$uicomponent.id" class="UITabPaneDashboard">
+ <div class="LtTabDashboard">
+ <div class="RtTabDashboard">
<div class="CtTabDashboard">
<div class="UIHorizontalTabs">
- <div class="TabsContainer ClearFix">
- <%
- int i = 0;
- for(UserNode node : nodes){
- def tabLabel = node.getLabel();
- if ("Tab_Default".equals(node.getName()))
- {
- tabLabel = _ctx.appRes("UIUserToolBarDashboard.page." + node.getLabel());
- }
- EntityEncoder encoder = EntityEncoder.FULL;
- tabLabel = encoder.encode(tabLabel);
- String param = node.getName();
- if(node.getURI().equals(selectedNode.getURI())){
- %>
- <div class="UITab GrayTabStyle">
- <div class="SelectedTab">
- <div class="LeftTab">
- <div class="RightTab">
- <div class="MiddleTab">
- <%
- String ondblclick = "eXo.webui.UITabbedDashboard.showEditLabelInput(this,\"" + param + "\",\"" + tabLabel + "\")";
- %>
- <span ondblclick='$ondblclick'>$tabLabel</span>
- <a href="<%= uicomponent.url("DeleteTab",param); %>">
- <img class="CloseIcon" src="/eXoResources/skin/sharedImages/Blank.gif" alt="DEL" />
- </a>
- </div>
- </div>
- </div>
- </div>
- </div>
- <%}else{ %>
- <div class="UITab GrayTabStyle">
- <div class="NormalTab">
- <div class="LeftTab">
- <div class="RightTab">
- <div class="MiddleTab">
- <a href="<%= portalURI + node.getURI(); %>"><span>$tabLabel</span></a>
- <a href="<%= uicomponent.url("DeleteTab",param); %>">
- <img class="CloseIcon" src="/eXoResources/skin/sharedImages/Blank.gif" alt="DEL" />
- </a>
- </div>
- </div>
- </div>
- </div>
- </div>
- <%} %>
- <% } %>
- <div class="AddDashboard" onclick="eXo.webui.UITabbedDashboard.createTabDashboard(this)"><span></span></div>
- </div>
- </div>
-
- </div>
- </div>
- </div>
-</div>
+ <div class="TabsContainer ClearFix">
+ <%
+ int i = 0;
+ for(UserNode node : nodes){
+ def tabLabel = node.getEncodedResolvedLabel();
+ nodeURL.setNode(node);
+ if ("Tab_Default".equals(node.getName()))
+ {
+ tabLabel = _ctx.appRes("UIUserToolBarDashboard.page." + tabLabel);
+ }
+ String param = node.getName();
+ if(node.getURI().equals(selectedNode.getURI())){
+ %>
+ <div class="UITab GrayTabStyle">
+ <div class="SelectedTab">
+ <div class="LeftTab">
+ <div class="RightTab">
+ <div class="MiddleTab">
+ <%
+ String ondblclick = "eXo.webui.UITabbedDashboard.showEditLabelInput(this,\"" + param + "\",this.innerHTML)";
+ %>
+ <span ondblclick='$ondblclick'>$tabLabel</span>
+ <a href="<%= uicomponent.url("DeleteTab",param); %>">
+ <img class="CloseIcon" src="/eXoResources/skin/sharedImages/Blank.gif" alt="DEL" />
+ </a>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <%}else{ %>
+ <div class="UITab GrayTabStyle">
+ <div class="NormalTab">
+ <div class="LeftTab">
+ <div class="RightTab">
+ <div class="MiddleTab">
+ <a href="<%= nodeURL.toString()%>"><span>$tabLabel</span></a>
+ <a href="<%= uicomponent.url("DeleteTab",param); %>">
+ <img class="CloseIcon" src="/eXoResources/skin/sharedImages/Blank.gif" alt="DEL" />
+ </a>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <%} %>
+ <% } %>
+ <div class="AddDashboard" onclick="eXo.webui.UITabbedDashboard.createTabDashboard(this)"><span></span></div>
+ </div>
+ </div>
+
+ </div>
+ </div>
+ </div>
+</div>
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIApplicationOrganizer.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIApplicationOrganizer.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIApplicationOrganizer.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -98,6 +98,7 @@
PortalRequestContext portalContext = org.exoplatform.portal.webui.util.Util.getPortalRequestContext();
UIPortal uiPortal = org.exoplatform.portal.webui.util.Util.getUIPortal();
+ //TODO why use MonitorEvent that not just Event
MonitorEvent<UIPortal> pnevent = new MonitorEvent<UIPortal>(uiPortal, "ChangeApplicationList", portalContext);
uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
}
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIGroupNavigationManagement.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -200,8 +200,7 @@
UINavigationManagement naviManager = popUp.createUIComponent(UINavigationManagement.class, null, null, popUp);
uicomp.naviManager = naviManager;
- naviManager.setOwner(siteKey.getName());
- naviManager.setOwnerType(siteKey.getTypeName());
+ naviManager.setSiteKey(siteKey);
UINavigationNodeSelector selector = naviManager.getChild(UINavigationNodeSelector.class);
selector.setEdittedNavigation(nav);
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UINavigationManagement.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UINavigationManagement.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UINavigationManagement.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -22,9 +22,8 @@
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.config.UserPortalConfig;
import org.exoplatform.portal.config.UserPortalConfigService;
-import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.mop.navigation.NavigationServiceException;
+import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.mop.user.UserNavigation;
import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.portal.webui.workspace.UIPortalApplication;
@@ -47,23 +46,21 @@
public class UINavigationManagement extends UIContainer
{
- private String owner;
+ private SiteKey siteKey;
- private String ownerType;
-
public UINavigationManagement() throws Exception
{
addChild(UINavigationNodeSelector.class, null, null);
}
- public void setOwner(String owner)
+ public SiteKey getSiteKey()
{
- this.owner = owner;
+ return siteKey;
}
-
- public String getOwner()
+
+ public void setSiteKey(SiteKey key)
{
- return this.owner;
+ siteKey = key;
}
public <T extends UIComponent> T setRendered(boolean b)
@@ -78,16 +75,6 @@
uiTree.createEvent("ChangeNode", event.getExecutionPhase(), event.getRequestContext()).broadcast();
}
- public void setOwnerType(String ownerType)
- {
- this.ownerType = ownerType;
- }
-
- public String getOwnerType()
- {
- return this.ownerType;
- }
-
static public class SaveActionListener extends EventListener<UINavigationManagement>
{
@@ -112,7 +99,7 @@
// Check existed
UserPortalConfig userPortalConfig;
- if (PortalConfig.PORTAL_TYPE.equals(siteKey.getTypeName()))
+ if (SiteType.PORTAL.equals(siteKey.getType()))
{
userPortalConfig = portalConfigService.getUserPortalConfig(editedOwnerId, event.getRequestContext().getRemoteUser());
if (userPortalConfig == null)
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UINavigationNodeSelector.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UINavigationNodeSelector.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UINavigationNodeSelector.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -278,7 +278,7 @@
public void setUserPortal(UserPortal userPortal) throws Exception
{
this.userPortal = userPortal;
- setFilterConfig(UserNodeFilterConfig.builder().withAuthorizationCheck().build());
+ setFilterConfig(UserNodeFilterConfig.builder().withReadWriteCheck().build());
}
private void setFilterConfig(UserNodeFilterConfig config)
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIPageNodeForm.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIPageNodeForm.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UIPageNodeForm.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -29,6 +29,7 @@
import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.mop.Described;
+import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.mop.Visibility;
import org.exoplatform.portal.mop.user.UserNavigation;
import org.exoplatform.portal.webui.page.UIPageSelector;
@@ -438,9 +439,9 @@
return contextPageNavigation.getKey().getName();
}
- public String getOwnerType()
+ public SiteType getOwnerType()
{
- return contextPageNavigation.getKey().getTypeName();
+ return contextPageNavigation.getKey().getType();
}
public void setContextPageNavigation(UserNavigation _contextPageNav)
@@ -693,7 +694,7 @@
accessPermission[0] = "*:" + ownerId;
String editPermission = userACL.getMakableMT() + ":" + ownerId;
- if (PortalConfig.PORTAL_TYPE.equals(uiForm.getOwnerType()))
+ if (SiteType.PORTAL.equals(uiForm.getOwnerType()))
{
UIPortal uiPortal = Util.getUIPortal();
accessPermission = uiPortal.getAccessPermissions();
@@ -705,7 +706,7 @@
UIFormStringInput uiPageTitle = uiInputSet.getChildById("pageTitle");
Page page = new Page();
- page.setOwnerType(uiForm.getOwnerType());
+ page.setOwnerType(uiForm.getOwnerType().getName());
page.setOwnerId(ownerId);
page.setName(uiPageName.getValue());
String title = uiPageTitle.getValue();
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -85,7 +85,7 @@
public static String[] ACTIONS = {"EditNavigation", "DeletePortal", "EditPortalLayout"};
- private LazyPageList pageList;
+ private LazyPageList<PortalConfig> pageList;
private UINavigationManagement naviManager;
@@ -145,7 +145,7 @@
}
}
- this.pageList = new LazyPageList(new ListAccess<PortalConfig>()
+ this.pageList = new LazyPageList<PortalConfig>(new ListAccess<PortalConfig>()
{
public int getSize() throws Exception
@@ -201,7 +201,7 @@
UISiteManagement uicomp = event.getSource();
String portalName = event.getRequestContext().getRequestParameter(OBJECTID);
- UserPortalConfigService service = event.getSource().getApplicationComponent(UserPortalConfigService.class);
+ UserPortalConfigService service = uicomp.getApplicationComponent(UserPortalConfigService.class);
String defaultPortalName = service.getDefaultPortal();
PortalRequestContext prContext = Util.getPortalRequestContext();
@@ -214,17 +214,23 @@
return;
}
- UserPortalConfig config = service.getUserPortalConfig(portalName, prContext.getRemoteUser());
- if (config != null && config.getPortalConfig().isModifiable())
+ DataStorage dataStorage = uicomp.getApplicationComponent(DataStorage.class);
+ UserACL acl = uicomp.getApplicationComponent(UserACL.class);
+
+ PortalConfig pConfig = dataStorage.getPortalConfig(portalName);
+ if (pConfig != null)
{
- service.removeUserPortalConfig(portalName);
+ if (acl.hasPermission(pConfig))
+ {
+ service.removeUserPortalConfig(portalName);
+ }
+ else
+ {
+ uiPortalApp.addMessage(new ApplicationMessage("UISiteManagement.msg.Invalid-deletePermission",
+ new String[]{pConfig.getName()}));;
+ return;
+ }
}
- else if (config != null)
- {
- uiPortalApp.addMessage(new ApplicationMessage("UISiteManagement.msg.Invalid-deletePermission",
- new String[]{config.getPortalConfig().getName()}));;
- return;
- }
else
{
if (uicomp.stillKeptInPageList(portalName))
@@ -235,14 +241,14 @@
return;
}
- if (config == null && !Util.getUIPortal().getName().equals(portalName))
+ if (pConfig == null && !Util.getUIPortal().getName().equals(portalName))
{
uiPortalApp.addMessage(new ApplicationMessage("UISiteManagement.msg.Invalid-deletePermission",
new String[]{portalName}));
return;
}
- if (config == null || Util.getUIPortal().getName().equals(portalName))
+ if (pConfig == null || Util.getUIPortal().getName().equals(portalName))
{
HttpServletRequest request = prContext.getRequest();
LogoutControl.wantLogout();
@@ -264,26 +270,26 @@
UISiteManagement uicomp = event.getSource();
String portalName = event.getRequestContext().getRequestParameter(OBJECTID);
UserPortalConfigService service = uicomp.getApplicationComponent(UserPortalConfigService.class);
+ DataStorage dataStorage = uicomp.getApplicationComponent(DataStorage.class);
PortalRequestContext prContext = Util.getPortalRequestContext();
UIPortalApplication portalApp = (UIPortalApplication)prContext.getUIApplication();
UIWorkingWorkspace uiWorkingWS = portalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
- UserPortalConfig userConfig = service.getUserPortalConfig(portalName, prContext.getRemoteUser());
+ PortalConfig pConfig = dataStorage.getPortalConfig(portalName);
- if (userConfig == null)
+ if (pConfig == null)
{
portalApp.addMessage(new ApplicationMessage("UISiteManagement.msg.portal-not-exist",
new String[]{portalName}));
uiWorkingWS.updatePortletsByName("UserToolbarSitePortlet");
return;
}
- PortalConfig portalConfig = userConfig.getPortalConfig();
UserACL userACL = portalApp.getApplicationComponent(UserACL.class);
- if (!userACL.hasEditPermission(portalConfig))
+ if (!userACL.hasEditPermission(pConfig))
{
portalApp.addMessage(new ApplicationMessage("UISiteManagement.msg.Invalid-editPermission",
- new String[]{portalConfig.getName()}));
+ new String[]{pConfig.getName()}));
return;
}
@@ -294,13 +300,13 @@
uiComposer.setCollapse(false);
uiComposer.setShowControl(true);
uiComposer.setComponentConfig(UIPortalComposer.class, null);
- uiComposer.setId("UIPortalComposer");
+ uiComposer.setId(UIPortalComposer.UIPORTAL_COMPOSER);
UIPortal uiPortal = Util.getUIPortal();
uiWorkingWS.setBackupUIPortal(uiPortal);
UIPortal editPortal = uiWorkingWS.createUIComponent(UIPortal.class, null, null);
- PortalDataMapper.toUIPortal(editPortal, userConfig);
+ PortalDataMapper.toUIPortal(editPortal, pConfig);
uiEditWS.setUIComponent(editPortal);
// Check if edit current portal
@@ -375,8 +381,7 @@
UINavigationManagement naviManager = popUp.createUIComponent(UINavigationManagement.class, null, null, popUp);
uicomp.naviManager = naviManager;
- naviManager.setOwner(portalName);
- naviManager.setOwnerType(PortalConfig.PORTAL_TYPE);
+ naviManager.setSiteKey(SiteKey.portal(portalName));
UserPortal userPortal = userPortalConfig.getUserPortal();
UserNavigation edittedNavigation = userPortal.getNavigation(SiteKey.portal(portalName));
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/BasePartialUpdateToolbar.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/BasePartialUpdateToolbar.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/BasePartialUpdateToolbar.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -37,6 +37,8 @@
import org.exoplatform.portal.mop.user.UserNode;
import org.exoplatform.portal.mop.user.UserNodeFilterConfig;
import org.exoplatform.portal.mop.user.UserPortal;
+import org.exoplatform.web.url.navigation.NodeURL;
+import org.exoplatform.web.url.navigation.NavigationResource;
import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.portal.webui.workspace.UIPortalApplication;
import org.exoplatform.webui.application.WebuiRequestContext;
@@ -171,7 +173,13 @@
ResourceURL rsURL = res.createResourceURL();
rsURL.setResourceID(res.encodeURL(getResourceIdFromNode(node, navId)));
json.put("getNodeURL", rsURL.toString());
- json.put("actionLink", Util.getPortalRequestContext().getPortalURI() + node.getURI());
+
+ if (node.getPageRef() != null)
+ {
+ NavigationResource resource = new NavigationResource(node);
+ NodeURL url = Util.getPortalRequestContext().createURL(NodeURL.TYPE, resource);
+ json.put("actionLink", url.setAjax(false).toString());
+ }
JSONArray childs = new JSONArray();
for (UserNode child : node.getChildren())
@@ -213,4 +221,4 @@
protected abstract String getResourceIdFromNode(UserNode node, String navId) throws Exception;
protected abstract UserNode getNodeFromResourceID(String resourceId) throws Exception;
-}
\ No newline at end of file
+}
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIAdminToolbarPortlet.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIAdminToolbarPortlet.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIAdminToolbarPortlet.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -76,7 +76,7 @@
UIPortalApplication portalApp = Util.getUIPortalApplication();
UIPortal currentUIPortal = portalApp.<UIWorkingWorkspace>findComponentById(UIPortalApplication.UI_WORKING_WS_ID).findFirstComponentOfType(UIPortal.class);
UserACL userACL = portalApp.getApplicationComponent(UserACL.class);
- return userACL.hasEditPermissionOnPortal(currentUIPortal.getOwnerType(), currentUIPortal.getOwner(), currentUIPortal.getEditPermission());
+ return userACL.hasEditPermissionOnPortal(currentUIPortal.getSiteType().getName(), currentUIPortal.getName(), currentUIPortal.getEditPermission());
}
private boolean hasEditPermissionOnPage() throws Exception
@@ -84,12 +84,17 @@
UIPortalApplication portalApp = Util.getUIPortalApplication();
UIWorkingWorkspace uiWorkingWS = portalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
UIPageBody pageBody = uiWorkingWS.findFirstComponentOfType(UIPageBody.class);
+ if (pageBody == null)
+ {
+ return false;
+ }
+
UIPage uiPage = (UIPage)pageBody.getUIComponent();
UserACL userACL = portalApp.getApplicationComponent(UserACL.class);
if(uiPage != null)
{
- return userACL.hasEditPermissionOnPage(uiPage.getOwnerType(), uiPage.getOwnerId(), uiPage.getEditPermission());
+ return userACL.hasEditPermissionOnPage(uiPage.getSiteKey().getTypeName(), uiPage.getSiteKey().getName(), uiPage.getEditPermission());
}
else
{
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarDashboardPortlet.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarDashboardPortlet.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarDashboardPortlet.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -19,33 +19,21 @@
package org.exoplatform.toolbar.webui.component;
-import java.util.Collection;
-
-import javax.portlet.EventRequest;
-
-import org.exoplatform.portal.application.PortalRequestContext;
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.UserPortalConfigService;
-import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.mop.SiteKey;
import org.exoplatform.portal.mop.Visibility;
-import org.exoplatform.portal.mop.navigation.Scope;
import org.exoplatform.portal.mop.user.UserNavigation;
import org.exoplatform.portal.mop.user.UserNode;
import org.exoplatform.portal.mop.user.UserNodeFilterConfig;
import org.exoplatform.portal.mop.user.UserPortal;
-import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.EventConfig;
-import org.exoplatform.webui.core.UIComponent;
import org.exoplatform.webui.core.lifecycle.UIApplicationLifecycle;
import org.exoplatform.webui.event.Event;
import org.exoplatform.webui.event.EventListener;
-import java.util.List;
import javax.portlet.EventRequest;
/**
@@ -55,8 +43,7 @@
* May 26, 2009
*/
@ComponentConfig(lifecycle = UIApplicationLifecycle.class, template = "app:/groovy/admintoolbar/webui/component/UIUserToolBarDashboardPortlet.gtmpl",
- events = {@EventConfig(name = "AddDefaultDashboard", listeners = UIUserToolBarDashboardPortlet.AddDashboardActionListener.class),
- @EventConfig(listeners = UIUserToolBarDashboardPortlet.NavigationChangeActionListener.class)})
+ events = {@EventConfig(listeners = UIUserToolBarDashboardPortlet.NavigationChangeActionListener.class)})
public class UIUserToolBarDashboardPortlet extends BasePartialUpdateToolbar
{
@@ -65,7 +52,7 @@
public UIUserToolBarDashboardPortlet() throws Exception
{
UserNodeFilterConfig.Builder builder = UserNodeFilterConfig.builder();
- builder.withAuthorizationCheck().withVisibility(Visibility.DISPLAYED, Visibility.TEMPORAL);
+ builder.withReadWriteCheck().withVisibility(Visibility.DISPLAYED, Visibility.TEMPORAL);
builder.withTemporalCheck();
toolbarFilterConfig = builder.build();
}
@@ -101,6 +88,12 @@
return null;
}
+ /**
+ * An empty action listener for trigger update portlet by ajax via Portlet Event
+ *
+ * @author <a href="trongtt(a)gmail.com">Trong Tran</a>
+ * @version $Revision$
+ */
static public class NavigationChangeActionListener extends EventListener<UIUserToolBarDashboardPortlet>
{
private Log log = ExoLogger.getExoLogger(NavigationChangeActionListener.class);
@@ -111,81 +104,4 @@
log.debug("PageNode : " + ((EventRequest)event.getRequestContext().getRequest()).getEvent().getValue() + " is deleted");
}
}
-
- static public class UserPageNodeDeletedActionListener extends EventListener<UIUserToolBarDashboardPortlet>
- {
- private Log log = ExoLogger.getExoLogger(UserPageNodeDeletedActionListener.class);
-
- @Override
- public void execute(Event<UIUserToolBarDashboardPortlet> event) throws Exception
- {
- log.debug("PageNode : " + ((EventRequest)event.getRequestContext().getRequest()).getEvent().getValue() + " is deleted");
- }
- }
-
- static public class AddDashboardActionListener extends EventListener<UIUserToolBarDashboardPortlet>
- {
-
- private final static String PAGE_TEMPLATE = "dashboard";
-
- private static Log logger = ExoLogger.getExoLogger(AddDashboardActionListener.class);
-
- public void execute(Event<UIUserToolBarDashboardPortlet> event) throws Exception
- {
- UIUserToolBarDashboardPortlet toolBarPortlet = event.getSource();
- String nodeName = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
-
- Collection<UserNode> nodes = toolBarPortlet.getNavigationNodes(toolBarPortlet.getCurrentUserNavigation());
- if (nodes.size() < 1)
- {
- createDashboard(nodeName, toolBarPortlet);
- }
- else
- {
- PortalRequestContext prContext = Util.getPortalRequestContext();
- prContext.getResponse().sendRedirect(
- prContext.getPortalURI() + nodes.iterator().next().getURI());
- }
- }
-
- private static void createDashboard(String _nodeName, UIUserToolBarDashboardPortlet toolBarPortlet)
- {
- try
- {
- PortalRequestContext prContext = Util.getPortalRequestContext();
- if (_nodeName == null)
- {
- logger.debug("Parsed nodeName is null, hence use Tab_0 as default name");
- _nodeName = DEFAULT_TAB_NAME;
- }
-
- UserPortal userPortal = toolBarPortlet.getUserPortal();
- UserNavigation userNav = toolBarPortlet.getCurrentUserNavigation();
- if (userNav == null)
- {
- return;
- }
- SiteKey siteKey = userNav.getKey();
-
- UserPortalConfigService _configService = toolBarPortlet.getApplicationComponent(UserPortalConfigService.class);
- Page page =
- _configService.createPageTemplate(PAGE_TEMPLATE, siteKey.getTypeName(), siteKey.getName());
- page.setTitle(_nodeName);
- page.setName(_nodeName);
- toolBarPortlet.getApplicationComponent(DataStorage.class).create(page);
-
- UserNode rootNode = userPortal.getNode(userNav, Scope.CHILDREN, toolBarPortlet.toolbarFilterConfig, null);
- UserNode tabNode = rootNode.addChild(_nodeName);
- tabNode.setLabel(_nodeName);
- tabNode.setPageRef(page.getPageId());
-
- userPortal.saveNode(rootNode, null);
- prContext.getResponse().sendRedirect(prContext.getPortalURI() + tabNode.getURI());
- }
- catch (Exception ex)
- {
- logger.info("Could not create default dashboard page", ex);
- }
- }
- }
}
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarGroupPortlet.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarGroupPortlet.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarGroupPortlet.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -42,10 +42,7 @@
* thanhtungty(a)gmail.com
* May 26, 2009
*/
-@ComponentConfig(lifecycle = UIApplicationLifecycle.class, template = "app:/groovy/admintoolbar/webui/component/UIUserToolBarGroupPortlet.gtmpl",
- events = {
- @EventConfig(listeners = UIUserToolBarGroupPortlet.NavigationChangeActionListener.class)
- }
+@ComponentConfig(lifecycle = UIApplicationLifecycle.class, template = "app:/groovy/admintoolbar/webui/component/UIUserToolBarGroupPortlet.gtmpl"
)
public class UIUserToolBarGroupPortlet extends BasePartialUpdateToolbar
{
@@ -55,7 +52,7 @@
public UIUserToolBarGroupPortlet() throws Exception
{
UserNodeFilterConfig.Builder builder = UserNodeFilterConfig.builder();
- builder.withAuthorizationCheck().withVisibility(Visibility.DISPLAYED, Visibility.TEMPORAL);
+ builder.withReadWriteCheck().withVisibility(Visibility.DISPLAYED, Visibility.TEMPORAL);
builder.withTemporalCheck();
toolbarFilterConfig = builder.build();
}
@@ -117,6 +114,12 @@
return null;
}
+ /**
+ * An empty action listener for trigger update portlet by ajax via Portlet Event
+ *
+ * @author <a href="trongtt(a)gmail.com">Trong Tran</a>
+ * @version $Revision$
+ */
public static class NavigationChangeActionListener extends EventListener<UIUserToolBarGroupPortlet>
{
@Override
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarSitePortlet.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarSitePortlet.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarSitePortlet.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -22,6 +22,7 @@
import java.util.List;
import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.config.UserPortalConfigService;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.mop.SiteKey;
@@ -31,6 +32,7 @@
import org.exoplatform.portal.mop.user.UserNodeFilterConfig;
import org.exoplatform.portal.mop.user.UserPortal;
import org.exoplatform.portal.webui.util.Util;
+import org.exoplatform.portal.webui.workspace.UIPortalApplication;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.core.lifecycle.UIApplicationLifecycle;
@@ -47,7 +49,7 @@
public UIUserToolBarSitePortlet() throws Exception
{
UserNodeFilterConfig.Builder builder = UserNodeFilterConfig.builder();
- builder.withAuthorizationCheck().withVisibility(Visibility.DISPLAYED, Visibility.TEMPORAL);
+ builder.withReadWriteCheck().withVisibility(Visibility.DISPLAYED, Visibility.TEMPORAL);
builder.withTemporalCheck();
toolbarFilterConfig = builder.build();
}
@@ -71,17 +73,6 @@
return portalName;
}
- public String getCurrentPortal()
- {
- return Util.getPortalRequestContext().getPortalOwner();
- }
-
- public String getPortalURI(String portalName)
- {
- String currentPortalURI = Util.getPortalRequestContext().getPortalURI();
- return currentPortalURI.substring(0, currentPortalURI.lastIndexOf(getCurrentPortal())) + portalName + "/";
- }
-
@Override
protected UserNode getNodeFromResourceID(String resourceId) throws Exception
{
@@ -97,6 +88,11 @@
return null;
}
+ private String getCurrentPortal()
+ {
+ return Util.getPortalRequestContext().getPortalOwner();
+ }
+
@Override
protected String getResourceIdFromNode(UserNode node, String navId) throws Exception
{
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarDashboardPortlet.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarDashboardPortlet.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarDashboardPortlet.gtmpl 2011-08-18 21:24:33 UTC (rev 7183)
@@ -5,6 +5,11 @@
import java.util.Collection;
import javax.portlet.MimeResponse;
import javax.portlet.ResourceURL;
+ import org.exoplatform.portal.application.PortalRequestContext;
+ import org.exoplatform.web.url.PortalURL;
+ import org.exoplatform.web.url.navigation.NavigationResource;
+ import org.exoplatform.portal.config.model.PortalConfig;
+ import org.exoplatform.portal.mop.SiteType;
def rcontext = _ctx.getRequestContext() ;
JavascriptManager jsmanager = rcontext.getJavascriptManager();
@@ -12,17 +17,15 @@
jsmanager.importJavascript('eXo.portal.UIAdminToolbar');
jsmanager.addCustomizedOnLoadScript('eXo.portal.UIAdminToolbar.onLoad("' + uicomponent.id + '");');
- def portalURI = Util.getPortalRequestContext().getPortalURI();
- void renderDashboards(Collection nodes) {
- String clazz = "";
-
+ PortalRequestContext pcontext = Util.getPortalRequestContext();
+ PortalURL nodeURL = nodeurl();
+ void renderDashboards(PortalURL nodeURL, PortalRequestContext pcontext, Collection nodes) {
print """
<div style="display:none" class="MenuItemContainer">
<div class="SubBlock">
""";
- int idx = 0;
for(UserNode node : nodes) {
- renderPageNode(node, idx++ % 2 == 0);
+ renderPageNode(nodeURL, pcontext, node);
}
print """
</div>
@@ -30,20 +33,20 @@
""" ;
}
- void renderPageNode(UserNode node, boolean flag) {
+ void renderPageNode(PortalURL nodeURL, PortalRequestContext pcontext, UserNode node) {
UserNode selectedNode = uicomponent.getSelectedNode();
String tabStyleNavigation = "";
- if(selectedNode != null && node.getURI() == selectedNode.getURI()) {
+ if(selectedNode != null && node.getId().equals(selectedNode.getId())) {
tabStyleNavigation = "SelectedItem";
}
boolean hasChild = (node.getChildrenCount() > 0);
String clazz = "";
if(hasChild) clazz = "ArrowIcon";
- String href = Util.getPortalRequestContext().getPortalURI() + node.getURI();
+ String href = nodeURL.setNode(node);
String icon = node.getIcon();
if(icon == null) icon = "DefaultPageIcon";
- def resolvedLabel = node.getLabel();
+ def resolvedLabel = node.getEncodedResolvedLabel();
if ("Tab_Default".equals(node.getName()))
{
resolvedLabel = _ctx.appRes("UIUserToolBarDashboard.page." + node.getLabel());
@@ -80,9 +83,8 @@
<div class="MenuItemContainer">
<div class="SubBlock">
""" ;
- int idx = 0;
for(UserNode child : node.getChildren()) {
- renderPageNode(child, idx++ % 2 == 0);
+ renderPageNode(nodeURL, pcontext, child);
}
print """
</div>
@@ -98,16 +100,15 @@
<%
def userNodes = uicomponent.getNavigationNodes(uicomponent.getCurrentUserNavigation());
- String defaultDashboardPage;
if(userNodes.size() < 1) {
- defaultDashboardPage = org.exoplatform.toolbar.webui.component.UIUserToolBarDashboardPortlet.DEFAULT_TAB_NAME;
+ String createDashboardLink = nodeURL.setResource(new NavigationResource(SiteType.USER, rcontext.getRemoteUser(), null)).toString();
%>
<div class="UIUserToolBarDashboardPortlet" id="$uicomponent.id">
<div class="UIHorizontalTabs">
<div class="TabsContainer">
<div class="UITab NormalToolbarTab">
<div class="">
- <a class="DashboardIcon TBIcon" href="<%= uicomponent.url("AddDefaultDashboard", defaultDashboardPage); %>">Dashboard</a>
+ <a class="DashboardIcon TBIcon" href="<%= createDashboardLink%>">Dashboard</a>
</div>
</div>
</div>
@@ -115,16 +116,16 @@
</div>
<%
}else{
- defaultDashboardPage =userNodes.iterator().next().getName();
+ String link = nodeURL.setResource(new NavigationResource(SiteType.USER, rcontext.getRemoteUser(), null)).toString();
%>
<div class="UIUserToolBarDashboardPortlet" id="$uicomponent.id" >
<div class="UIHorizontalTabs">
<div class="TabsContainer" >
<div class="UITab NormalToolbarTab">
<div class="">
- <a class="DashboardIcon TBIcon" href="<%= portalURI + defaultDashboardPage %>">Dashboard</a>
+ <a class="DashboardIcon TBIcon" href="<%= link%>">Dashboard</a>
</div>
- <% renderDashboards(userNodes); %>
+ <% renderDashboards(nodeURL, pcontext, userNodes); %>
</div>
</div>
</div>
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarGroupPortlet.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarGroupPortlet.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarGroupPortlet.gtmpl 2011-08-18 21:24:33 UTC (rev 7183)
@@ -2,40 +2,46 @@
import org.exoplatform.web.application.JavascriptManager;
import org.exoplatform.portal.webui.util.Util ;
import org.exoplatform.webui.organization.OrganizationUtils;
- import org.gatein.common.text.EntityEncoder;
import org.exoplatform.portal.mop.user.UserNode;
import org.exoplatform.portal.mop.user.UserNavigation;
import javax.portlet.MimeResponse;
import javax.portlet.ResourceURL;
-
- def rcontext = _ctx.getRequestContext() ;
+ import org.exoplatform.portal.application.PortalRequestContext;
+ import org.exoplatform.web.url.PortalURL;
+ import org.exoplatform.web.url.navigation.NavigationResource;
+ import org.exoplatform.portal.mop.SiteKey;
+ import org.exoplatform.portal.mop.SiteType;
+
+ def rcontext = _ctx.getRequestContext();
JavascriptManager jsmanager = rcontext.getJavascriptManager();
jsmanager.importJavascript('eXo.portal.UIPortalNavigation');
jsmanager.importJavascript('eXo.portal.UIAdminToolbar');
jsmanager.addCustomizedOnLoadScript('eXo.portal.UIAdminToolbar.onLoad("' + uicomponent.id + '");');
def groupNavigations = uicomponent.getGroupNavigations();
- def portalURI = Util.getPortalRequestContext().getPortalURI();
- void renderGroupPageNavigation(UserNavigation navigation) {
+
+ PortalRequestContext pcontext = Util.getPortalRequestContext();
+ PortalURL nodeURL = nodeurl();
+
+ void renderGroupPageNavigation(UserNavigation navigation, PortalURL nodeURL) {
def nodes = uicomponent.getNavigationNodes(navigation);
if(nodes.size() < 1) return ;
- String navTitle = _ctx.appRes("UIPageNavigation.label.titleBar") ;
- def ownerId = navigation.getKey().getName();
- navTitle = navTitle.replace("{0}", OrganizationUtils.getGroupLabel(ownerId));
- print """
+ String navTitle = _ctx.appRes("UIPageNavigation.label.titleBar") ;
+ def ownerId = navigation.getKey().getName();
+ navTitle = navTitle.replace("{0}", OrganizationUtils.getGroupLabel(ownerId));
+ print """
<div class="TitleBar portlet-menu-description"><div style="width: 99%" title="$ownerId">$navTitle</div></div>
<div class="SubBlock">
- """ ;
- int idx = 0;
+ """ ;
for(UserNode node : nodes) {
- renderPageNode(node, ownerId, idx++ % 2 == 0);
+ renderPageNode(node, nodeURL);
}
print """
</div>
""" ;
}
- void renderPageNode(UserNode node, String groupId, boolean flag) {
+ void renderPageNode(UserNode node, PortalURL nodeURL) {
UserNode selectedNode = uicomponent.getSelectedNode();
String tabStyleNavigation = "";
if(selectedNode != null && node.getURI() == selectedNode.getURI()) {
@@ -45,31 +51,30 @@
boolean hasChild = node.getChildrenCount() > 0;
String clazz = "";
if(hasChild) clazz = "ArrowIcon";
- String href = Util.getPortalRequestContext().getPortalURI() + node.getURI();
+ String actionLink = nodeURL.setNode(node).toString();
String icon = node.getIcon();
if(icon == null) icon = "DefaultPageIcon";
- boolean toolong = (node.resolvedLabel.length() > 60);
- String label = ( toolong ? node.resolvedLabel.substring(0, 57) + "..." : node.resolvedLabel);
- String title = "";
- if(toolong) title = "title='$node.resolvedLabel'";
- else title = "";
- EntityEncoder entityEncoder = EntityEncoder.FULL;
- label = entityEncoder.encode(label);
+ boolean toolong = (node.getEncodedResolvedLabel().length() > 60);
+ String label = ( toolong ? node.getEncodedResolvedLabel().substring(0, 57) + "..." : node.getEncodedResolvedLabel());
+ String title = "";
+ if(toolong) title = "title='$node.encodedResolvedLabel'";
+ else title = "";
def getNodeURL = "";
if (hasChild) {
+ def groupId = node.getNavigation().getKey().getName();
MimeResponse res = _ctx.getRequestContext().getResponse();
- ResourceURL resourceURL = res.createResourceURL();
+ ResourceURL resourceURL = res.createResourceURL();
resourceURL.setResourceID(res.encodeURL(groupId + "::" + node.getURI()));
getNodeURL = "exo:getNodeURL='" + resourceURL.toString() + "'";
- }
-
- print """
+ }
+
+ print """
<div class="MenuItem $tabStyleNavigation portlet-menu-cascade-item" $getNodeURL>
- <div class="$clazz">
+ <div class="$clazz">
""";
if(node.pageRef != null) {
- print """<a class="ItemIcon $icon" href="$href" $title>$label</a>""";
+ print """<a class="ItemIcon $icon" href="$actionLink" $title>$label</a>""";
} else {
print """<a class="ItemIcon $icon" href="#" $title>$label</a>""";
}
@@ -81,38 +86,38 @@
<div class="MenuItemContainer" style="position: absolute; display:none">
<div class="SubBlock">
""" ;
- int idx = 0;
for(UserNode child : node.getChildren()) {
- renderPageNode(child, groupId, idx++ % 2 == 0);
- }
+ renderPageNode(child, nodeURL);
+ }
print """
- </div>
+ </div>
</div>
- """ ;
-
- }
- print """
+ """ ;
+
+ }
+ print """
</div>
- """ ;
+ """ ;
}
-%>
+ def currentPortal = pcontext.getPortalOwner();
+%>
<div class="UIUserToolBarGroupPortlet" id="$uicomponent.id" >
<div class="UIHorizontalTabs">
<div class="TabsContainer">
<div class="UITab NormalToolbarTab">
<div class="">
- <a class="GroupIcon TBIcon" href="<%= portalURI + "groupnavigation" %>">Group</a>
+ <a class="GroupIcon TBIcon" href="<%=nodeURL.setResource(new NavigationResource(SiteType.PORTAL, currentPortal, "groupnavigation")).toString() %>" ><%=_ctx.appRes("UIUserToolBarGroupPortlet.header.group")%></a>
</div>
<%
if (!groupNavigations.isEmpty()) {
%>
<div style="display:none" class="MenuItemContainer">
- <% for(navigation in groupNavigations) {
- renderGroupPageNavigation(navigation);
+ <% for(nav in groupNavigations) {
+ renderGroupPageNavigation(nav, nodeURL);
} %>
</div>
<% } %>
</div>
- </div>
+ </div>
</div>
-</div>
+</div>
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarSitePortlet.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarSitePortlet.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarSitePortlet.gtmpl 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,52 +1,58 @@
<%
import org.exoplatform.web.application.JavascriptManager;
import org.exoplatform.portal.webui.util.Util ;
- import org.exoplatform.webui.organization.OrganizationUtils;
import org.gatein.common.text.EntityEncoder;
import org.exoplatform.portal.mop.user.UserNode;
- import java.util.Collection;
import javax.portlet.MimeResponse;
import javax.portlet.ResourceURL;
import org.exoplatform.portal.mop.SiteKey;
-
+ import org.exoplatform.portal.mop.SiteType;
+ import org.exoplatform.portal.application.PortalRequestContext;
+ import org.exoplatform.web.url.PortalURL;
+ import org.exoplatform.web.url.navigation.NavigationResource;
+ import org.exoplatform.portal.config.model.PortalConfig;
+
def rcontext = _ctx.getRequestContext() ;
JavascriptManager jsmanager = rcontext.getJavascriptManager();
- jsmanager.importJavascript('eXo.portal.UIPortalNavigation') ;
- jsmanager.importJavascript('eXo.portal.UIAdminToolbar') ;
- jsmanager.addCustomizedOnLoadScript('eXo.portal.UIAdminToolbar.onLoad("' + uicomponent.id + '");');
- def portalURI = Util.getPortalRequestContext().getPortalURI();
-
- void renderPortalNavigations() {
- def currentPortal = uicomponent.getCurrentPortal()
- def nodes = uicomponent.getNavigationNodes(uicomponent.getNavigation(SiteKey.portal(currentPortal)));
- print """
+ jsmanager.importJavascript('eXo.portal.UIPortalNavigation') ;
+ jsmanager.importJavascript('eXo.portal.UIAdminToolbar') ;
+ jsmanager.addCustomizedOnLoadScript('eXo.portal.UIAdminToolbar.onLoad("' + uicomponent.id + '");');
+
+ PortalRequestContext pcontext = Util.getPortalRequestContext();
+ PortalURL nodeURL = nodeurl();
+
+ void renderPortalNavigations(PortalURL nodeURL) {
+ print """
<div style="position: absolute; display:none" class="MenuItemContainer">
- <div class="SubBlock">
+ <div class="SubBlock">
""";
boolean isCurrent = false;
String clazz = "";
- String href = "#";
+ String href = "#";
for(int i = 0; i < uicomponent.getAllPortalNames().size(); i++) {
- String portal = uicomponent.getAllPortalNames().get(i);
- if(portal.equals(currentPortal)) {
- isCurrent = true;
- } else isCurrent = false;
-
- if(isCurrent && nodes.size() > 0) clazz = "class='ArrowIcon'";
+ String portalName = uicomponent.getAllPortalNames().get(i);
+ if(portalName.equals(uicomponent.getCurrentPortal())) {
+ isCurrent = true;
+ } else isCurrent = false;
+
+ nodeURL.setResource(new NavigationResource(SiteType.PORTAL, portalName, null));
+
+ if(isCurrent) clazz = "ArrowIcon";
else clazz = "";
- href = uicomponent.getPortalURI(portal);
- label = uicomponent.getPortalLabel(portal);
- EntityEncoder entityEncoder = EntityEncoder.FULL;
- portal = entityEncoder.encode(portal);
- print """
- <div class="MenuItem">
- <div $clazz>
+
+ href = nodeURL.toString();
+ EntityEncoder entityEncoder = EntityEncoder.FULL;
+ label = uicomponent.getPortalLabel(portalName);
+ label = entityEncoder.encode(label);
+ print """
+ <div class="MenuItem portlet-menu-cascade-item">
+ <div class="$clazz">
<a href="$href" class="ItemIcon SiteIcon">$label</a>
- </div>
+ </div>
""";
if(isCurrent) {
- renderCurrentPortal(nodes);
+ renderCurrentPortal(nodeURL);
}
print """
</div>
@@ -57,42 +63,40 @@
</div>
""";
}
-
- void renderCurrentPortal(Collection nodes) {
- print """
+
+ void renderCurrentPortal(PortalURL nodeURL) {
+ def nodes = _ctx.getRequestContext().getAttribute("nodes");
+ print """
<div style="position: absolute; display:none" class="MenuItemContainer">
- <div class="SubBlock">
- """;
- int idx = 0;
+ <div class="SubBlock">
+ """;
for(UserNode node : nodes) {
- renderPageNode(node, idx++ % 2 == 0);
+ renderPageNode(nodeURL, node);
}
print """
</div>
</div>
""";
- }
+ }
- void renderPageNode(UserNode node, boolean flag) {
- UserNode selectedNode = uicomponent.getSelectedNode();
- String tabStyleNavigation = "";
- if(selectedNode != null && node.getId() == selectedNode.getId()) {
- tabStyleNavigation = "SelectedItem portlet-menu-cascade-item-selected";
+ void renderPageNode(PortalURL nodeURL, UserNode node) {
+ UserNode selectedNode = uicomponent.getSelectedNode();
+ String tabStyleNavigation = "";
+ if(selectedNode != null && node.getId().equals(selectedNode.getId())) {
+ tabStyleNavigation = "SelectedItem portlet-menu-cascade-item-selected";
}
boolean hasChild = node.getChildrenCount() > 0;
String clazz = "";
if(hasChild) clazz = "ArrowIcon";
- String href = Util.getPortalRequestContext().getPortalURI() + node.getURI();
+ String href = nodeURL.setNode(node).toString();
String icon = node.getIcon();
if(icon == null) icon = "DefaultPageIcon";
- boolean toolong = (node.resolvedLabel.length() > 60);
- String label = ( toolong ? node.resolvedLabel.substring(0, 57) + "..." : node.resolvedLabel);
+ boolean toolong = (node.getEncodedResolvedLabel().length() > 60);
+ String label = ( toolong ? node.getEncodedResolvedLabel().substring(0, 57) + "..." : node.getEncodedResolvedLabel());
String title = "";
- if(toolong) title = "title='$node.resolvedLabel'";
+ if(toolong) title = "title='$node.encodedResolvedLabel()'";
else title = "";
- EntityEncoder entityEncoder = EntityEncoder.FULL;
- label = entityEncoder.encode(label);
def getNodeURL = "";
if (hasChild) {
@@ -100,52 +104,56 @@
ResourceURL resourceURL = res.createResourceURL();
resourceURL.setResourceID(res.encodeURL(node.getURI()));
getNodeURL = "exo:getNodeURL='" + resourceURL.toString() + "'";
- }
-
- print """
+ }
+
+ print """
<div class="MenuItem $tabStyleNavigation portlet-menu-cascade-item" $getNodeURL>
- <div class="$clazz">
+ <div class="$clazz">
""";
if(node.pageRef != null) {
- print """<a class="ItemIcon $icon" href="$href" $title>$label</a>""";
- } else {
- print """<a class="ItemIcon $icon" href="#" $title>$label</a>""";
- }
+ print """<a class="ItemIcon $icon" href="$href" $title>$label</a>""";
+ } else {
+ print """<a class="ItemIcon $icon" href="#" $title>$label</a>""";
+ }
print """
- </div>
- """ ;
- if(hasChild) {
- print """
- <div class="MenuItemContainer" style="position: absolute; display:none">
+ </div>
+ """ ;
+ if(hasChild) {
+ print """
+ <div class="MenuItemContainer portlet-menu-indicator" style="position: absolute; display:none">
<div class="SubBlock">
- """ ;
- int idx = 0;
+ """ ;
for(UserNode child : node.getChildren()) {
- renderPageNode(child, idx++ % 2 == 0);
+ renderPageNode(nodeURL, child);
}
- print """
+ print """
</div>
</div>
- """ ;
-
- }
+ """ ;
+
+ }
print """
</div>
- """ ;
+ """ ;
}
-%>
-
+
+ def currentPortal = uicomponent.getCurrentPortal();
+ def navigation = uicomponent.getNavigation(SiteKey.portal(currentPortal));
+ def nodes = uicomponent.getNavigationNodes(navigation);
+ _ctx.getRequestContext().setAttribute("nodes", nodes);
+%>
+
<div class="UIUserToolBarSitePortlet" id="$uicomponent.id" >
<div class="UIHorizontalTabs">
<div class="TabsContainer">
<div class="UITab NormalToolbarTab">
<div class="">
- <a class="SitesIcon TBIcon" href="<%= portalURI + "portalnavigation" %>">
+ <a class="SitesIcon TBIcon" href="<%= nodeURL.setResource(new NavigationResource(SiteType.PORTAL, currentPortal, "portalnavigation")).toString() %>">
Site
</a>
</div>
- <% renderPortalNavigations() %>
+ <% renderPortalNavigations(nodeURL) %>
</div>
- </div>
+ </div>
</div>
-</div>
+</div>
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/groovy/navigation/webui/component/UINavigationManagement.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/groovy/navigation/webui/component/UINavigationManagement.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/groovy/navigation/webui/component/UINavigationManagement.gtmpl 2011-08-18 21:24:33 UTC (rev 7183)
@@ -11,7 +11,7 @@
</div>
<div class="MiddleLeftBar">
<div class="MiddleCenterBar" style="background-image: none;">
- <%= uicomponent.getOwner();%>
+ <%= uicomponent.getSiteKey().getName();%>
</div>
</div>
<div class="BottomLeftBar">
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIBreadcumbsPortlet.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIBreadcumbsPortlet.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIBreadcumbsPortlet.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -20,19 +20,12 @@
package org.exoplatform.portal.webui.component;
import org.exoplatform.portal.mop.user.UserNode;
-import org.exoplatform.portal.webui.portal.PageNodeEvent;
-import org.exoplatform.portal.webui.portal.UIPortal;
import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.application.portlet.PortletRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
-import org.exoplatform.webui.config.annotation.EventConfig;
-import org.exoplatform.webui.core.UIBreadcumbs;
-import org.exoplatform.webui.core.UIBreadcumbs.LocalPath;
import org.exoplatform.webui.core.UIPortletApplication;
import org.exoplatform.webui.core.lifecycle.UIApplicationLifecycle;
-import org.exoplatform.webui.event.Event;
-import org.exoplatform.webui.event.EventListener;
import java.util.ArrayList;
import java.util.Collections;
@@ -47,63 +40,49 @@
* May 30, 2006
* @version:: $Id$
*/
-@ComponentConfig(lifecycle = UIApplicationLifecycle.class, events = @EventConfig(listeners = UIBreadcumbsPortlet.SelectPathActionListener.class))
+@ComponentConfig(
+ lifecycle = UIApplicationLifecycle.class
+)
public class UIBreadcumbsPortlet extends UIPortletApplication
{
+ private final String template;
+
public UIBreadcumbsPortlet() throws Exception
{
PortletRequestContext context = (PortletRequestContext)WebuiRequestContext.getCurrentInstance();
PortletRequest prequest = context.getRequest();
PortletPreferences prefers = prequest.getPreferences();
- String template = prefers.getValue("template", "system:/groovy/webui/core/UIBreadcumbs.gtmpl");
-
- UIBreadcumbs uiBreadCumbs = addChild(UIBreadcumbs.class, null, null);
- uiBreadCumbs.setTemplate(template);
+ template = prefers.getValue("template", "app:/groovy/portal/webui/component/UIBreadcumbsPortlet.gtmpl");
}
- private void loadSelectedPath() throws Exception
+ public String getTemplate()
{
+ return template != null ? template : super.getTemplate();
+ }
+
+ public boolean isUseAjax() throws Exception
+ {
+ WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
+ PortletRequest prequest = context.getRequest();
+ PortletPreferences prefers = prequest.getPreferences();
+ return Boolean.valueOf(prefers.getValue("useAJAX", "true"));
+ }
+
+ public List<UserNode> getSelectedPath() throws Exception
+ {
UserNode node = Util.getUIPortal().getSelectedUserNode();
- List<LocalPath> paths = new ArrayList<LocalPath>();
+ List<UserNode> paths = new ArrayList<UserNode>();
do
{
- if (node.getPageRef() == null)
- {
- paths.add(new LocalPath(null, node.getResolvedLabel()));
- }
- else
- {
- paths.add(new LocalPath(node.getURI(), node.getResolvedLabel()));
- }
+ paths.add(node);
node = node.getParent();
}
- while (node != null && node.getParent() != null);
-
+ while (node != null && node.getParent() != null);
Collections.reverse(paths);
- UIBreadcumbs uiBreadCumbs = getChild(UIBreadcumbs.class);
- uiBreadCumbs.setPath(paths);
+ return paths;
}
- @Override
- public void renderChildren() throws Exception
- {
- loadSelectedPath();
- super.renderChildren();
- }
-
- static public class SelectPathActionListener extends EventListener<UIBreadcumbs>
- {
- @Override
- public void execute(Event<UIBreadcumbs> event) throws Exception
- {
- String uri = event.getRequestContext().getRequestParameter(OBJECTID);
- UIPortal uiPortal = Util.getUIPortal();
- PageNodeEvent<UIPortal> pnevent = new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, uri);
- uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
- }
- }
-
}
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UINavigationPortlet.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UINavigationPortlet.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UINavigationPortlet.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -30,14 +30,14 @@
import org.exoplatform.portal.mop.navigation.GenericScope;
import org.exoplatform.portal.mop.navigation.Scope;
import org.exoplatform.portal.mop.user.UserNode;
-import org.exoplatform.portal.mop.user.UserPortal;
+import org.exoplatform.web.url.navigation.NodeURL;
+import org.exoplatform.web.url.navigation.NavigationResource;
import org.exoplatform.portal.webui.navigation.UIPortalNavigation;
import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.application.portlet.PortletRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.ComponentConfigs;
-import org.exoplatform.webui.config.annotation.EventConfig;
import org.exoplatform.webui.core.UIPortletApplication;
import org.exoplatform.webui.core.lifecycle.UIApplicationLifecycle;
import org.json.JSONArray;
@@ -45,7 +45,7 @@
@ComponentConfigs({
@ComponentConfig(lifecycle = UIApplicationLifecycle.class),
- @ComponentConfig(type = UIPortalNavigation.class, id = "UIHorizontalNavigation", events = @EventConfig(listeners = UIPortalNavigation.SelectNodeActionListener.class))})
+ @ComponentConfig(type = UIPortalNavigation.class, id = "UIHorizontalNavigation")})
public class UINavigationPortlet extends UIPortletApplication
{
public static final int DEFAULT_LEVEL = 2;
@@ -144,21 +144,14 @@
ResourceURL rsURL = res.createResourceURL();
rsURL.setResourceID(res.encodeURL(node.getURI()));
json.put("getNodeURL", rsURL.toString());
-
- String actionLink;
- if (node.getPageRef() == null)
+
+ if (node.getPageRef() != null)
{
- actionLink = null;
+ NavigationResource resource = new NavigationResource(node);
+ NodeURL url = Util.getPortalRequestContext().createURL(NodeURL.TYPE, resource);
+ url.setAjax(isUseAjax());
+ json.put("actionLink", url.toString());
}
- else if (isUseAjax())
- {
- actionLink = event("SelectNode", nodeId);
- }
- else
- {
- actionLink = Util.getPortalRequestContext().getPortalURI() + node.getURI();
- }
- json.put("actionLink", actionLink);
JSONArray childs = new JSONArray();
for (UserNode child : node.getChildren())
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UISitemapPortlet.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UISitemapPortlet.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UISitemapPortlet.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -30,6 +30,8 @@
import org.exoplatform.portal.mop.navigation.GenericScope;
import org.exoplatform.portal.mop.navigation.Scope;
import org.exoplatform.portal.mop.user.UserNode;
+import org.exoplatform.web.url.navigation.NodeURL;
+import org.exoplatform.web.url.navigation.NavigationResource;
import org.exoplatform.portal.webui.navigation.TreeNode;
import org.exoplatform.portal.webui.navigation.UIPortalNavigation;
import org.exoplatform.portal.webui.util.Util;
@@ -52,7 +54,6 @@
@ComponentConfigs({
@ComponentConfig(lifecycle = UIApplicationLifecycle.class, template = "system:/groovy/webui/core/UISitemap.gtmpl"),
@ComponentConfig(type = UIPortalNavigation.class, id = "UISiteMap", events = {
- @EventConfig(listeners = UIPortalNavigation.SelectNodeActionListener.class),
// @EventConfig(listeners = UIPortalNavigation.ExpandAllNodeActionListener.class),
@EventConfig(listeners = UIPortalNavigation.CollapseAllNodeActionListener.class),
@EventConfig(listeners = UIPortalNavigation.CollapseNodeActionListener.class)})})
@@ -160,20 +161,13 @@
rsURL.setResourceID(nodeId);
json.put("getNodeURL", rsURL.toString());
- String actionLink;
- if (node.getPageRef() == null)
+ if (node.getPageRef() != null)
{
- actionLink = null;
+ NavigationResource resource = new NavigationResource(node);
+ NodeURL url = Util.getPortalRequestContext().createURL(NodeURL.TYPE, resource);
+ url.setAjax(isUseAjax());
+ json.put("actionLink", url.toString());
}
- else if (isUseAjax())
- {
- actionLink = uiPortalNavigation.event("SelectNode", nodeId);
- }
- else
- {
- actionLink = Util.getPortalRequestContext().getPortalURI() + node.getURI();
- }
- json.put("actionLink", actionLink);
JSONArray childs = new JSONArray();
for (TreeNode child : tnode.getChildren())
Deleted: epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/WEB-INF/conf/portlet/web/FCKEditorPortlet/webui/configuration.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/WEB-INF/conf/portlet/web/FCKEditorPortlet/webui/configuration.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/WEB-INF/conf/portlet/web/FCKEditorPortlet/webui/configuration.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,29 +0,0 @@
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-
-<webui-configuration>
- <application>
- <ui-component-root>org.exoplatform.fck.webui.component.UIFCKEditorPortlet</ui-component-root>
- <state-manager>org.exoplatform.webui.application.portlet.ParentAppStateManager</state-manager>
- <application-lifecycle-listeners>
- </application-lifecycle-listeners>
- </application>
-</webui-configuration>
\ No newline at end of file
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/WEB-INF/portlet.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/WEB-INF/portlet.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/WEB-INF/portlet.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -157,7 +157,7 @@
</preference>
<preference>
<name>template</name>
- <value>system:/groovy/webui/core/UIBreadcumbs.gtmpl</value>
+ <value>app:/groovy/portal/webui/component/UIBreadcumbsPortlet.gtmpl</value>
<read-only>false</read-only>
</preference>
</portlet-preferences>
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/groovy/groovy/webui/component/UIBannerPortlet.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/groovy/groovy/webui/component/UIBannerPortlet.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/groovy/groovy/webui/component/UIBannerPortlet.gtmpl 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,7 +1,10 @@
<%
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.webui.util.Util;
-
+ import org.exoplatform.web.url.PortalURL;
+ import org.exoplatform.web.url.navigation.NavigationResource;
+ import org.exoplatform.portal.mop.SiteType;
+
def prContext = _ctx.getRequestContext().getParentAppRequestContext();
String signInAction = "if(document.getElementById('UIMaskWorkspace')) ajaxGet(eXo.env.server.createPortalURL('UIPortal', 'ShowLoginForm', true));" ;
String changeLanguageAction = "if(document.getElementById('UIMaskWorkspace')) ajaxGet(eXo.env.server.createPortalURL('UIPortal', 'ChangeLanguage', true));" ;
@@ -17,7 +20,10 @@
<div class="MiddleBanner">
<div class="BannerTitle"><span></span></div>
<%} else {
- String registerURI = Util.getPortalRequestContext().getPortalURI() + "register";
+ PortalRequestContext pcontext = Util.getPortalRequestContext();
+ PortalURL nodeURL = nodeurl();
+ NavigationResource resource = new NavigationResource(SiteType.PORTAL, pcontext.getPortalOwner(), "register");
+ String registerURI = nodeURL.setResource(resource).toString();
%>
<div class="MiddleBanner MiddleBannerSignin">
<div class="BannerTitle"><span></span></div>
Copied: epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/groovy/portal/webui/component/UIBreadcumbsPortlet.gtmpl (from rev 7117, portal/trunk/portlet/web/src/main/webapp/groovy/portal/webui/component/UIBreadcumbsPortlet.gtmpl)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/groovy/portal/webui/component/UIBreadcumbsPortlet.gtmpl (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/groovy/portal/webui/component/UIBreadcumbsPortlet.gtmpl 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,43 @@
+<%
+ import java.util.List;
+ import org.exoplatform.portal.webui.util.Util;
+ import org.exoplatform.portal.application.PortalRequestContext;
+ import org.gatein.common.text.EntityEncoder;
+ import org.exoplatform.web.url.PortalURL;
+ import org.exoplatform.web.url.navigation.NavigationResource;
+
+ List list = uicomponent.getSelectedPath();
+
+ PortalRequestContext pcontext = Util.getPortalRequestContext();
+ PortalURL nodeURL = nodeurl();
+ nodeURL.setAjax(uicomponent.isUseAjax());
+%>
+<div class="UIBreadcumbsPortlet" id="$uicomponent.id">
+ <div class="UIBreadcumbs">
+ <div class="LeftBreadcumbsBar">
+ <div class="RightBreadcumbsBar">
+ <div class="BreadcumbsInfoBar">
+ <div class="HomeIcon LeftBlock BCHome16x16Icon"><span></span></div>
+ <%if(list.size() > 0) {
+ String note = "LeftBlock";
+ for(i in 0 .. list.size()-1) {
+ def node = list.get(i);
+ String actionLink = nodeURL.setNode(node);
+ if(i == list.size()-1) note = "Selected";
+ %>
+ <a href="<%=(node.getPageRef() == null) ? "#" : actionLink%>" class="$note"><%=node.getEncodedResolvedLabel();%></a>
+ <%
+ if(i != list.size()-1) {
+ %>
+ <div class="RightBlackGridArrowIcon LeftBlock RightBlackGridArrow16x16Icon"><span></span></div>
+ <%
+ }
+ }
+ }
+ %>
+ <div class="ClearLeft"><span></span></div>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
\ No newline at end of file
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/groovy/portal/webui/component/UILogoPortlet.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/groovy/portal/webui/component/UILogoPortlet.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/groovy/portal/webui/component/UILogoPortlet.gtmpl 2011-08-18 21:24:33 UTC (rev 7183)
@@ -2,14 +2,16 @@
import javax.portlet.PortletMode ;
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.webui.util.Util;
- import org.gatein.common.text.EntityEncoder;
-
+ import org.gatein.common.text.EntityEncoder;
+ import org.exoplatform.web.url.PortalURL;
+ import org.exoplatform.web.url.navigation.NavigationResource;
+ import org.exoplatform.portal.mop.SiteType;
+
def prContext = _ctx.getRequestContext().getParentAppRequestContext();
String signInAction = "if(document.getElementById('UIMaskWorkspace')) ajaxGet(eXo.env.server.createPortalURL('UIPortal', 'ShowLoginForm', true));" ;
String changeLanguageAction = "if(document.getElementById('UIMaskWorkspace')) ajaxGet(eXo.env.server.createPortalURL('UIPortal', 'ChangeLanguage', true));" ;
String portletId = uicomponent.getId() ;
- String accountSetting = "javascript:if(document.getElementById('UIMaskWorkspace')) ajaxGet(eXo.env.server.createPortalURL('UIPortal', 'AccountSettings', true));"
- String registerURI = Util.getPortalRequestContext().getPortalURI() + "register";
+ String accountSetting = "javascript:if(document.getElementById('UIMaskWorkspace')) ajaxGet(eXo.env.server.createPortalURL('UIPortal', 'AccountSettings', true));"
String navTitle = uicomponent.getNavigationTitle();
EntityEncoder encoder = EntityEncoder.FULL;
navTitle = encoder.encode(navTitle);
@@ -29,7 +31,13 @@
</a>
<div class="BannerTitle">$navTitle</div>
<!-- ACTIONs -->
- <% if(prContext.getRemoteUser() == null) { %>
+ <%
+ if(prContext.getRemoteUser() == null) {
+ PortalRequestContext pcontext = Util.getPortalRequestContext();
+ PortalURL nodeURL = nodeurl();
+ NavigationResource resource = new NavigationResource(SiteType.PORTAL, pcontext.getPortalOwner(), "register");
+ String registerURI = nodeURL.setResource(resource).toString();
+ %>
<div class="Signin ClearFix">
<a onclick="$changeLanguageAction"><%=_ctx.appRes("UILogoPortlet.action.changeLanguage")%></a>
<a href="$registerURI"><%=_ctx.appRes("UILogoPortlet.action.Register")%></a>
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/groovy/portal/webui/component/UIPortalNavigation.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/groovy/portal/webui/component/UIPortalNavigation.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/web/src/main/webapp/groovy/portal/webui/component/UIPortalNavigation.gtmpl 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,207 +1,181 @@
<%
- import org.exoplatform.portal.mop.user.UserNode;
- import org.exoplatform.web.application.JavascriptManager;
- import org.exoplatform.portal.webui.util.Util;
- import org.gatein.common.text.EntityEncoder;
- import javax.portlet.MimeResponse;
- import javax.portlet.ResourceURL;
+ import org.exoplatform.portal.mop.user.UserNode;
+ import org.exoplatform.web.application.JavascriptManager;
+ import org.exoplatform.portal.webui.util.Util;
+ import org.gatein.common.text.EntityEncoder;
+ import javax.portlet.MimeResponse;
+ import org.exoplatform.portal.application.PortalRequestContext;
+ import org.exoplatform.web.url.PortalURL;
+ import org.exoplatform.web.url.navigation.NavigationResource;
def rcontext = _ctx.getRequestContext();
JavascriptManager jsmanager = rcontext.getJavascriptManager();
jsmanager.importJavascript('eXo.webui.UIHorizontalTabs');
- jsmanager.importJavascript('eXo.portal.UIPortalNavigation');
- jsmanager.addOnLoadJavascript('eXo.portal.UIPortalNavigation.onLoad');
-
- jsmanager.addOnLoadJavascript('eXo.portal.UIPortalNavigation.loadScroll');
- //jsmanager.addOnResizeJavascript('eXo.portal.UIPortalNavigation.initScroll');
-
- public void renderChildrenContainer(UserNode node) {
- print """
- <div class="MenuItemContainer" style="display: none;">
- <div class="MenuItemDecorator">
- <div class="LeftTopMenuDecorator">
- <div class="RightTopMenuDecorator">
- <div class="CenterTopMenuDecorator"><span></span></div>
- </div>
- </div>
- <div class="LeftMiddleMenuDecorator">
- <div class="RightMiddleMenuDecorator">
- <div class="CenterMiddleMenuDecorator">
- """;
- for(child in node.getChildren()) {
- renderChildNode(child);
- }
- print """
- </div>
- </div>
- </div>
- <div class="LeftBottomMenuDecorator">
- <div class="RightBottomMenuDecorator">
- <div class="CenterBottomMenuDecorator"><span></span></div>
- </div>
- </div>
- </div>
- </div>
- """;
- }
-
- public void renderChildNode(UserNode node) {
- UserNode selectedNode = uicomponent.getSelectedNode();
- String tabStyleNavigation = "NormalItem"; // OverItem
- if(selectedNode != null && node.getId() == selectedNode.getId()) {
- tabStyleNavigation = "SelectedItem";
- }
-
- String icon = node.getIcon();
- if(icon == null) icon = "DefaultPageIcon";
- String arrowIcon = "";
- String getNodeURL = "";
- if (node.getChildrenCount() > 0) {
- arrowIcon = "ArrowIcon";
- MimeResponse res = _ctx.getRequestContext().getResponse();
- ResourceURL resourceURL = res.createResourceURL();
- resourceURL.setResourceID(res.encodeURL(node.getURI()));
- getNodeURL = "exo:getNodeURL='" + resourceURL.toString() + "'";
- }
-
- String label = node.getResolvedLabel();
- String title = "";
- if(label.length() > 40) {
- title = label;
- label = label.substring(0,37) + "...";
- }
- EntityEncoder entityEncoder = EntityEncoder.FULL;
- label = entityEncoder.encode(label);
- String pageURI = Util.getPortalRequestContext().getPortalURI() + node.getURI();
- if(node.getPageRef() != null) {
- if(uicomponent.isUseAjax()) {
- String onclickEvt = uicomponent.event("SelectNode", node.getId()) + ";return false;" ;
- print """
- <div class="MenuItem $tabStyleNavigation" $getNodeURL>
- <div class="$arrowIcon" title="$title">
- <div class="ItemIcon $icon">
- <a href="$pageURI" onclick="$onclickEvt">$label</a>
- </div>
- </div>
- """;
- } else {
- print """
- <div class="MenuItem $tabStyleNavigation" $getNodeURL>
- <div class="$arrowIcon" title="$title">
- <div class="ItemIcon $icon">
- <a href="$pageURI">$label</a>
- </div>
- </div>
- """;
- }
- } else {
- print """
- <div class="MenuItem $tabStyleNavigation" $getNodeURL>
- <div class="$arrowIcon" title="$title">
- <div class="ItemIcon $icon">
- <a href="#">$label</a>
- </div>
- </div>
- """;
- }
-
- if (node.getChildren().size() > 0) {
- renderChildrenContainer(node);
- }
- print "</div>";
- }
-%>
-
-<div class="UINavigationBar <%=uicomponent.getCssClassName()%>">
- <div class="LeftNavigationBar">
- <div class="RightNavigationBar">
- <div class="MiddleNavigationBar">
- <div class="UIHorizontalTabs">
- <div class="TabsContainer">
- <%
- MimeResponse res = _ctx.getRequestContext().getResponse();
-
- def rootNodes = uicomponent.getNavigations();
- UserNode selectedNode = uicomponent.getSelectedNode();
- if(rootNodes != null) {
- for(nav in rootNodes) {
-
- def childs = nav.getChildren();
-
- for(Node node in childs) {
- String tabStyleNavigation = "NormalNavigationTab";
- if(selectedNode != null && node.getId() == selectedNode.getId()) {
- tabStyleNavigation = "SelectedNavigationTab";
- }
-
- if (node.getChildrenCount() > 0) {
- ResourceURL resourceURL = res.createResourceURL();
- resourceURL.setResourceID(res.encodeURL(node.getURI()));
- %>
- <div class="UITab" exo:getNodeURL="<%=resourceURL.toString() %>">
- <% } else { %>
- <div class="UITab">
- <% } %>
- <div class="$tabStyleNavigation">
- <div class="LeftTab">
- <div class="RightTab">
- <div class="MiddleTab">
- <div class="TabIcon">
- <%
- String arrowIcon = "";
- if (node.getChildrenCount() > 0) {
- arrowIcon = "DropDownArrowIcon";
- }
- String iconType = node.getIcon();
- if(iconType == null) iconType = "DefaultPageIcon";
- %>
- <div class="$arrowIcon">
- <%
- String pageURI = Util.getPortalRequestContext().getPortalURI() + node.getURI();
- String label = node.getResolvedLabel();
- if(label.length() > 30) label = label.substring(0,29) + "...";
- EntityEncoder entityEncoder = EntityEncoder.FULL;
- label=entityEncoder.encode(label);
- if(node.getPageRef() != null) {
- if(uicomponent.isUseAjax()) {
- String onclickEvt = uicomponent.event("SelectNode", node.getId()) + ";return false;";
- %>
- <a class="TabLabel ${iconType}" onclick="$onclickEvt" href="$pageURI">$label</a>
- <%
- } else {
- %>
- <a class="TabLabel ${iconType}" href="$pageURI">$label</a>
- <% }
- } else {%>
- <a class="TabLabel ${iconType}">$label</a>
- <%}%>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <%
- /*Render Popup Menu*/
- if (node.getChildren().size() > 0) {
- renderChildrenContainer(node);
- }
- %>
- </div>
- <%
- }
- }
- }
- %>
- <div class="ScrollButtons">
- <div class="ScrollLeftButton" title="<%= _ctx.appRes("UIPortalNavigation.Label.Previous") %>">
- <div class="ScrollRightButton" title="<%= _ctx.appRes("UIPortalNavigation.Label.Next") %>"><span></span></div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
-</div>
-
+ jsmanager.importJavascript('eXo.portal.UIPortalNavigation');
+ jsmanager.addOnLoadJavascript('eXo.portal.UIPortalNavigation.onLoad');
+ jsmanager.addOnLoadJavascript('eXo.portal.UIPortalNavigation.loadScroll');
+ //jsmanager.addOnResizeJavascript('eXo.portal.UIPortalNavigation.initScroll');
+
+ PortalRequestContext pcontext = Util.getPortalRequestContext();
+ PortalURL nodeURL = nodeurl();
+
+ public void renderChildrenContainer(UserNode node, PortalURL nodeURL) {
+ print """
+ <div class="MenuItemContainer" style="display: none;">
+ <div class="MenuItemDecorator">
+ <div class="LeftTopMenuDecorator">
+ <div class="RightTopMenuDecorator">
+ <div class="CenterTopMenuDecorator"><span></span></div>
+ </div>
+ </div>
+ <div class="LeftMiddleMenuDecorator">
+ <div class="RightMiddleMenuDecorator">
+ <div class="CenterMiddleMenuDecorator">
+ """;
+ for(child in node.getChildren()) {
+ renderChildNode(child, nodeURL);
+ }
+ print """
+ </div>
+ </div>
+ </div>
+ <div class="LeftBottomMenuDecorator">
+ <div class="RightBottomMenuDecorator">
+ <div class="CenterBottomMenuDecorator"><span></span></div>
+ </div>
+ </div>
+ </div>
+ </div>
+ """;
+ }
+
+ public void renderChildNode(UserNode node, PortalURL nodeURL) {
+ UserNode selectedNode = uicomponent.getSelectedNode();
+ String tabStyleNavigation = "NormalItem"; // OverItem
+ if(selectedNode != null && node.getId() == selectedNode.getId()) {
+ tabStyleNavigation = "SelectedItem";
+ }
+
+ String icon = node.getIcon();
+ if(icon == null) icon = "DefaultPageIcon";
+ String arrowIcon = "";
+ String getNodeURL = "";
+ if (node.getChildrenCount() > 0) {
+ arrowIcon = "ArrowIcon";
+ MimeResponse res = _ctx.getRequestContext().getResponse();
+ javax.portlet.ResourceURL resourceURL = res.createResourceURL();
+ resourceURL.setResourceID(res.encodeURL(node.getURI()));
+ getNodeURL = "exo:getNodeURL='" + resourceURL.toString() + "'";
+ }
+
+ String label = node.getEncodedResolvedLabel();
+ String title = "";
+ if(label.length() > 40) {
+ title = label;
+ label = label.substring(0,37) + "...";
+ }
+
+ def actionLink = "#";
+ if(node.getPageRef() != null) {
+ nodeURL.setNode(node);
+ nodeURL.setAjax(uicomponent.isUseAjax());
+ actionLink = nodeURL.toString();
+ }
+ print """
+ <div class="MenuItem $tabStyleNavigation" $getNodeURL>
+ <div class="$arrowIcon" title="$title">
+ <div class="ItemIcon $icon">
+ <a href="$actionLink">$label</a>
+ </div>
+ </div>
+ """;
+
+ if (node.getChildren().size() > 0) {
+ renderChildrenContainer(node, nodeURL);
+ }
+ print "</div>";
+ }
+%>
+<div class="UINavigationBar <%=uicomponent.getCssClassName()%>">
+ <div class="LeftNavigationBar">
+ <div class="RightNavigationBar">
+ <div class="MiddleNavigationBar">
+ <div class="UIHorizontalTabs">
+ <div class="TabsContainer">
+ <%
+ MimeResponse res = _ctx.getRequestContext().getResponse();
+
+ def rootNodes = uicomponent.getNavigations();
+ UserNode selectedNode = uicomponent.getSelectedNode();
+ if(rootNodes != null) {
+ for(nav in rootNodes) {
+ def childs = nav.getChildren();
+ for(Node node in childs) {
+ String tabStyleNavigation = "NormalNavigationTab";
+ if(selectedNode != null && node.getId() == selectedNode.getId()) {
+ tabStyleNavigation = "SelectedNavigationTab";
+ }
+
+ if (node.getChildrenCount() > 0) {
+ javax.portlet.ResourceURL resourceURL = res.createResourceURL();
+ resourceURL.setResourceID(res.encodeURL(node.getURI()));
+ %>
+ <div class="UITab" exo:getNodeURL="<%=resourceURL.toString() %>">
+ <% } else { %>
+ <div class="UITab">
+ <% } %>
+ <div class="$tabStyleNavigation">
+ <div class="LeftTab">
+ <div class="RightTab">
+ <div class="MiddleTab">
+ <div class="TabIcon">
+ <%
+ String arrowIcon = "";
+ if (node.getChildrenCount() > 0) {
+ arrowIcon = "DropDownArrowIcon";
+ }
+ String iconType = node.getIcon();
+ if(iconType == null) iconType = "DefaultPageIcon";
+ %>
+ <div class="$arrowIcon">
+ <%
+ String label = node.getEncodedResolvedLabel();
+ if(label.length() > 30) label = label.substring(0,29) + "...";
+ if(node.getPageRef() != null) {
+ nodeURL.setNode(node);
+ nodeURL.setAjax(uicomponent.isUseAjax());
+ print """
+ <a class="TabLabel ${iconType}" href="$nodeURL">$label</a>
+ """;
+ } else {%>
+ <a class="TabLabel ${iconType}" href="javascript:void(0)">$label</a>
+ <%}%>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <%
+ /*Render Popup Menu*/
+ if (node.getChildren().size() > 0) {
+ renderChildrenContainer(node, nodeURL);
+ }
+ %>
+ </div>
+ <%
+ }
+ }
+ }
+ %>
+ <div class="ScrollButtons">
+ <div class="ScrollLeftButton" title="<%= _ctx.appRes("UIPortalNavigation.Label.Previous") %>">
+ <div class="ScrollRightButton" title="<%= _ctx.appRes("UIPortalNavigation.Label.Next") %>"><span></span></div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
\ No newline at end of file
Modified: epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalHttpRequest.js
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalHttpRequest.js 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalHttpRequest.js 2011-08-18 21:24:33 UTC (rev 7183)
@@ -574,16 +574,12 @@
doRequest("Get", url, null, callback) ;
} ;
-/*
-* This method is called when a HTTP POST should be done but in an AJAX
-* case some maniputalions are needed
-* Once the content of the form is placed into a string object, the call
-* is delegated to the doRequest() method
-*/
-function ajaxPost(formElement, callback) {
+/**
+ * Do a POST request in AJAX with given <code>url</code> and <code>queryString</code>.
+ * The call is delegated to the doRequest() method with a callback function
+ */
+function ajaxPost(url, queryString, callback) {
if (!callback) callback = null ;
- var queryString = eXo.webui.UIForm.serializeForm(formElement) ;
- var url = formElement.action + "&ajaxRequest=true" ;
doRequest("POST", url, queryString, callback) ;
} ;
@@ -613,6 +609,7 @@
eXo.session.itvInit() ;
}
} ;
+
/**
* Abort an ajax request
* @return
@@ -625,6 +622,7 @@
eXo.portal.CurrentRequest.aborted = true ;
eXo.portal.CurrentRequest = null ;
} ;
+
/**
* Create a ajax GET request
* @param {String} url - Url
@@ -654,6 +652,7 @@
}
if(!async) return request.responseText ;
}
+
/**
* Redirect browser to url
* @param url
Modified: epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/portal/UIPortal.js
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/portal/UIPortal.js 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/portal/UIPortal.js 2011-08-18 21:24:33 UTC (rev 7183)
@@ -672,27 +672,6 @@
}
};
-/*
-* This method will start the creation of a new javascript application such as a widget
-*
-* - The application parameter is the full javascript class for the application (for example "eXo.widget.web.info.UIInfoWidget")
-* - The application id is an id shared among all the application instance
-* - The instance id is unique among all the javascript application deployed in the layout
-* - The appLocation is the root path location of the jstmpl file on the server (for example /eXoWidgetWeb/javascript/)
-*
-* If the application class name is not null, the associated .js file on the server is loaded using the eXo.require() method
-*
-* Once loaded the initApplication() method is called; in other words, the application is lazy instantiated and initialized
-* on the client browser
-*/
-//UIPortal.prototype.createJSApplication = function(application, applicationId, instanceId, appLocation) {
-// if(application) {
-// eXo.require(application, appLocation);
-// var createApplication = application + '.initApplication(\''+applicationId+'\',\''+instanceId+'\');' ;
-// eval(createApplication);
-// }
-//} ;
-
eXo.portal.UIPortalComponent = UIComponent.prototype.constructor ;
eXo.portal.UIPortal = new UIPortal() ;
eXo.portal.UIComponent = UIPortal.prototype.constructor ;
Modified: epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIForm.js
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIForm.js 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIForm.js 2011-08-18 21:24:33 UTC (rev 7183)
@@ -22,7 +22,21 @@
*/
function UIForm() {
};
+
/**
+ * This method is called when a HTTP POST should be done but in an AJAX
+ * case some maniputalions are needed
+ * Once the content of the form is placed into a string object, the call
+ * is delegated to the doRequest() method
+ */
+UIForm.prototype.ajaxPost = function(formElement, callback) {
+ if (!callback) callback = null ;
+ var queryString = eXo.webui.UIForm.serializeForm(formElement) ;
+ var url = formElement.action + "&ajaxRequest=true" ;
+ doRequest("POST", url, queryString, callback) ;
+} ;
+
+/**
* Get form element with pattern condition
* @param {String} pattern
* The pattern can be Id#Id, example: Account#UIAccountForm
@@ -36,7 +50,7 @@
/**
* A function that submits the form identified by formId, with the specified action
- * If useAjax is true, calls the ajaxPost function from PortalHttpRequest, with the given callback function
+ * If useAjax is true, calls the ajaxPost function, with the given callback function
* Note: ie bug you cannot have more than one button tag
*/
UIForm.prototype.submitForm = function(formId, action, useAjax, callback) {
@@ -60,13 +74,13 @@
} catch(e) {}
form.elements['formOp'].value = action ;
- if(useAjax) ajaxPost(form, callback) ;
+ if(useAjax) this.ajaxPost(form, callback) ;
else form.submit();
} ;
/**
* Submits a form by Ajax, with the given action and the given parameters
- * Calls ajaxPost of PortalHttpRequest
+ * Calls ajaxPost
* Note: ie bug you cannot have more than one button tag
*/
UIForm.prototype.submitEvent = function(formId, action, params) {
@@ -84,7 +98,7 @@
form.elements['formOp'].value = action ;
if(!form.originalAction) form.originalAction = form.action ;
form.action = form.originalAction + encodeURI(params) ;
- ajaxPost(form) ;
+ this.ajaxPost(form) ;
} ;
UIForm.prototype.selectBoxOnChange = function(formId, elemt) {
Modified: epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIRightClickPopupMenu.js
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIRightClickPopupMenu.js 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIRightClickPopupMenu.js 2011-08-18 21:24:33 UTC (rev 7183)
@@ -58,23 +58,49 @@
document.oncontextmenu = function() {return true} ;
}
};
+
/**
- * Prepare something for context menu
- * @param {Object} evt event
- * @param {Object} elemt document object that contains context menu
- */
+* Prepare objectId for context menu
+* Make ajaxPost request if needed
+* @param {Object} evt event
+* @param {Object} elemt document object that contains context menu
+*/
UIRightClickPopupMenu.prototype.prepareObjectId = function(evt, elemt) {
+ eXo.core.MouseEventManager.docMouseDownEvt(evt) ;
var contextMenu = eXo.core.DOMUtil.findAncestorByClass(elemt, "UIRightClickPopupMenu") ;
contextMenu.style.display = "none" ;
- var href = elemt.getAttribute('href') ;
- if(href.indexOf("javascript") == 0) {
- eval(unescape(href).replace('_objectid_', encodeURI(contextMenu.objId.replace(/'/g, "\\'")))) ;
- eXo.core.MouseEventManager.docMouseDownEvt(evt) ;
- return false;
+ var href = elemt.getAttribute('href') ;
+ if (!href) {
+ return;
}
- elemt.setAttribute('href', href.replace('_objectid_', encodeURI(contextMenu.objId.replace(/'/g, "\\'")))) ;
- return true;
-}
+ if(href.indexOf("ajaxGet") != -1) {
+ href = href.replace("ajaxGet", "ajaxPost");
+ elemt.setAttribute('href', href) ;
+ }
+ if (href.indexOf("objectId") != -1 || !contextMenu.objId) {
+ return;
+ }
+ var objId = encodeURI(contextMenu.objId.replace(/'/g, "\\'"));
+
+ if (href.indexOf("javascript") == -1) {
+ elemt.setAttribute('href', href + "&objectId=" + objId) ;
+ return;
+ } else if(href.indexOf("window.location") != -1) {
+ href = href.substr(0, href.length - 1) + "&objectId=" + objId + "'" ;
+ } else if (href.indexOf("ajaxPost") != -1) {
+ href = href.substr(0, href.length - 2) + "', 'objectId=" + objId + "')";
+ } else {
+ href = href.substr(0, href.length - 2) + "&objectId=" + objId + "')";
+ }
+
+ eval(href);
+ if ( evt && evt.preventDefault )
+ evt.preventDefault();
+ else
+ window.event.returnValue = false;
+ return false;
+};
+
/**
* Mouse click on element, If click is right-click, the context menu will be shown
* @param {Object} event
@@ -180,4 +206,4 @@
contextMenu.style.top = intTop + 1 + "px";
};
-eXo.webui.UIRightClickPopupMenu = new UIRightClickPopupMenu() ;
\ No newline at end of file
+eXo.webui.UIRightClickPopupMenu = new UIRightClickPopupMenu() ;
Modified: epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo.js
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo.js 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo.js 2011-08-18 21:24:33 UTC (rev 7183)
@@ -107,17 +107,22 @@
* @return full url request
*/
eXo.env.server.createPortalURL = function(targetComponentId, actionName, useAjax, params) {
- var href = eXo.env.server.portalBaseURL + "?portal:componentId=" + targetComponentId + "&portal:action=" + actionName ;
-
+ var url = eXo.env.server.portalURLTemplate.replace("{portal:componentId}", targetComponentId);
+ url = url.replace("{portal:action}", actionName);
+
if(params != null) {
var len = params.length ;
for(var i = 0 ; i < len ; i++) {
- href += "&" + params[i].name + "=" + params[i].value ;
+ var paramName = encodeURIComponent(params[i].name);
+ var paramValue = encodeURIComponent(params[i].value);
+ url += "&" + paramName + "=" + paramValue ;
}
}
- if(useAjax) href += "&ajaxRequest=true" ;
- return href ;
+ if(useAjax) url += "&ajaxRequest=true" ;
+
+ return url ;
} ;
+
/**
* log out of user session
*/
@@ -151,4 +156,4 @@
message = "DEBUG: " + message;
eXo.webui.UINotification.addMessage(message);
}
-}
\ No newline at end of file
+}
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/configuration.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/configuration.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/configuration.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -53,9 +53,14 @@
<import>war:/conf/organization/organization-configuration.xml</import>
<import>war:/conf/jcr/component-plugins-configuration.xml</import>
<import>war:/conf/mail/portal-mail-configuration.xml</import>
+
+ <!-- Portal related services -->
<import>war:/conf/portal/portal-configuration.xml</import>
<import>war:/conf/portal/application-registry-configuration.xml</import>
<!-- Administration improvements -->
<import>war:/conf/admin/admin-configuration.xml</import>
+ <import>war:/conf/portal/controller-configuration.xml</import>
+ <import>war:/conf/portal/web-configuration.xml</import>
+ <import>war:/conf/portal/gadget-configuration.xml</import>
</configuration>
Copied: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/controller-configuration.xml (from rev 7117, portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/controller-configuration.xml)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/controller-configuration.xml (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/controller-configuration.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+
+<configuration
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd http://www.exoplaform.org/xml/ns/kernel_1_2.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd">
+
+ <component>
+ <type>org.exoplatform.web.WebAppController</type>
+ <init-params>
+ <value-param>
+ <name>controller.config</name>
+ <value>${gatein.portal.controller.config}</value>
+ </value-param>
+ </init-params>
+ </component>
+
+ <component>
+ <type>org.exoplatform.upload.UploadService</type>
+ <init-params>
+ <value-param>
+ <name>upload.limit.size</name>
+ <description>Maximum size of the file to upload in MB</description>
+ <value>10</value>
+ </value-param>
+ </init-params>
+ </component>
+
+ <component>
+ <type>org.exoplatform.download.DownloadService</type>
+ <init-params>
+ <value-param>
+ <name>download.resource.cache.size</name>
+ <description>Maximun number of the download can be in the cache</description>
+ <value>500</value>
+ </value-param>
+ </init-params>
+ </component>
+
+ <component>
+ <type>org.exoplatform.web.url.URLFactoryService</type>
+ <component-plugins>
+ <component-plugin>
+ <name>navigation.urlfactory.plugin</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.web.url.navigation.NodeURLFactoryPlugin</type>
+ </component-plugin>
+ <component-plugin>
+ <name>navigation.urlfactory.plugin</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.portal.url.component.ComponentURLFactoryPlugin</type>
+ </component-plugin>
+ </component-plugins>
+ </component>
+
+ <external-component-plugins>
+ <target-component>org.exoplatform.services.listener.ListenerService</target-component>
+ <component-plugin>
+ <name>org.exoplatform.web.GenericHttpListener.sessionDestroyed</name>
+ <set-method>addListener</set-method>
+ <type>org.exoplatform.upload.UploadSessionListener</type>
+ </component-plugin>
+ </external-component-plugins>
+
+ <external-component-plugins>
+ <target-component>org.exoplatform.web.WebAppController</target-component>
+ <component-plugin>
+ <name>UploadHandler</name>
+ <set-method>register</set-method>
+ <type>org.exoplatform.web.handler.UploadHandler</type>
+ </component-plugin>
+ <component-plugin>
+ <name>DownloadHandler</name>
+ <set-method>register</set-method>
+ <type>org.exoplatform.web.handler.DownloadHandler</type>
+ </component-plugin>
+ <component-plugin>
+ <name>PortalRequestHandler</name>
+ <set-method>register</set-method>
+ <type>org.exoplatform.portal.application.PortalRequestHandler</type>
+ </component-plugin>
+ <component-plugin>
+ <name>LegacyRequestHandler</name>
+ <set-method>register</set-method>
+ <type>org.exoplatform.portal.application.LegacyRequestHandler</type>
+ </component-plugin>
+ <component-plugin>
+ <name>DefaultRequestHandler</name>
+ <set-method>register</set-method>
+ <type>org.exoplatform.portal.application.DefaultRequestHandler</type>
+ </component-plugin>
+ </external-component-plugins>
+
+</configuration>
Copied: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/gadget-configuration.xml (from rev 7117, portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/gadget-configuration.xml)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/gadget-configuration.xml (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/gadget-configuration.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+
+<configuration
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd http://www.exoplaform.org/xml/ns/kernel_1_2.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd">
+<component>
+ <key>org.exoplatform.portal.gadget.core.SecurityTokenGenerator</key>
+ <type>org.exoplatform.portal.gadget.core.ExoDefaultSecurityTokenGenerator</type>
+ </component>
+ <component>
+ <type>org.exoplatform.portal.gadget.core.GadgetTokenInfoService</type>
+ <init-params>
+ <values-param>
+ <name>service.configuration</name>
+ <value>gadget-token</value>
+ <value>7</value>
+ <value>DAY</value>
+ </values-param>
+ </init-params>
+ </component>
+
+ <external-component-plugins>
+ <target-component>org.exoplatform.commons.chromattic.ChromatticManager</target-component>
+ <component-plugin>
+ <name>chromattic</name>
+ <set-method>addLifeCycle</set-method>
+ <type>org.exoplatform.commons.chromattic.ChromatticLifeCycle</type>
+ <init-params>
+ <value-param>
+ <name>domain-name</name>
+ <value>gadgettokens</value>
+ </value-param>
+ <value-param>
+ <name>workspace-name</name>
+ <value>portal-work</value>
+ </value-param>
+ <values-param>
+ <name>entities</name>
+ <value>org.exoplatform.portal.gadget.core.GadgetTokenContainer</value>
+ <value>org.exoplatform.portal.gadget.core.GadgetTokenEntry</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+
+ <external-component-plugins>
+ <target-component>org.exoplatform.services.jcr.RepositoryService</target-component>
+ <component-plugin>
+ <name>add.nodeType</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.jcr.impl.AddNodeTypePlugin</type>
+ <init-params>
+ <values-param>
+ <name>autoCreatedInNewRepository</name>
+ <description>Node types configuration file</description>
+ <value>jar:/conf/gadgettoken-nodetypes.xml</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+</configuration>
\ No newline at end of file
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/group/platform/guests/navigation.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/group/platform/guests/navigation.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/group/platform/guests/navigation.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -27,15 +27,7 @@
<priority>9</priority>
<page-nodes>
- <!--
- <node>
- <uri>register</uri>
- <name>register</name>
- <label>#{platform.guests.register}</label>
- <page-reference>group::/platform/guests::register</page-reference>
- </node>
- -->
-
+
<node>
<uri>link</uri>
<name>link</name>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/group/template/group/group.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/group/template/group/group.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/group/template/group/group.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -26,7 +26,7 @@
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_0">
<portal-name>@owner@</portal-name>
<locale>en</locale>
- <access-permissions>Everyone</access-permissions>
+ <access-permissions>*:@owner@</access-permissions>
<edit-permission>manager:@owner@</edit-permission>
<properties>
<entry key="sessionAlive">onDemand</entry>
@@ -60,6 +60,11 @@
<value>GroupNavigation</value>
<read-only>true</read-only>
</preference>
+ <preference>
+ <name>useAJAX</name>
+ <value>false</value>
+ <read-only>false</read-only>
+ </preference>
</preferences>
</portlet>
<access-permissions>Everyone</access-permissions>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/classic/pages.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/classic/pages.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/classic/pages.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -106,6 +106,13 @@
<portlet>
<application-ref>web</application-ref>
<portlet-ref>SiteMapPortlet</portlet-ref>
+ <preferences>
+ <preference>
+ <name>useAJAX</name>
+ <value>false</value>
+ <read-only>false</read-only>
+ </preference>
+ </preferences>
</portlet>
<title>SiteMap</title>
<access-permissions>Everyone</access-permissions>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/classic/portal.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/classic/portal.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/classic/portal.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -53,6 +53,13 @@
<portlet>
<application-ref>web</application-ref>
<portlet-ref>NavigationPortlet</portlet-ref>
+ <preferences>
+ <preference>
+ <name>useAJAX</name>
+ <value>false</value>
+ <read-only>false</read-only>
+ </preference>
+ </preferences>
</portlet>
<access-permissions>Everyone</access-permissions>
<show-info-bar>false</show-info-bar>
@@ -62,6 +69,13 @@
<portlet>
<application-ref>web</application-ref>
<portlet-ref>BreadcumbsPortlet</portlet-ref>
+ <preferences>
+ <preference>
+ <name>useAJAX</name>
+ <value>false</value>
+ <read-only>false</read-only>
+ </preference>
+ </preferences>
</portlet>
<access-permissions>Everyone</access-permissions>
<show-info-bar>false</show-info-bar>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/template/classic/portal.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/template/classic/portal.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/template/classic/portal.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -62,6 +62,13 @@
<portlet>
<application-ref>web</application-ref>
<portlet-ref>BreadcumbsPortlet</portlet-ref>
+ <preferences>
+ <preference>
+ <name>useAJAX</name>
+ <value>false</value>
+ <read-only>false</read-only>
+ </preference>
+ </preferences>
</portlet>
<access-permissions>Everyone</access-permissions>
<show-info-bar>false</show-info-bar>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -22,8 +22,8 @@
<configuration
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
- xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
+ xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd http://www.exoplaform.org/xml/ns/kernel_1_2.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd">
<component>
<key>org.exoplatform.portal.pom.config.POMSessionManager</key>
@@ -114,7 +114,7 @@
<component>
<key>org.exoplatform.portal.config.UserPortalConfigService</key>
<type>org.exoplatform.portal.config.UserPortalConfigService</type>
- <component-plugins>
+ <component-plugins>
<component-plugin>
<name>new.portal.config.user.listener</name>
<set-method>initListener</set-method>
@@ -207,10 +207,6 @@
<field name="predefinedOwner">
<collection type="java.util.HashSet">
<value><string>root</string></value>
- <value><string>john</string></value>
- <value><string>mary</string></value>
- <value><string>demo</string></value>
- <value><string>user</string></value>
</collection>
</field>
<field name="ownerType"><string>user</string></field>
@@ -221,6 +217,16 @@
</init-params>
</component-plugin>
</component-plugins>
+ <init-params>
+ <value-param>
+ <name>create.user.portal</name>
+ <value>${gatein.portal.idm.createuserportal}</value>
+ </value-param>
+ <value-param>
+ <name>destroy.user.portal</name>
+ <value>${gatein.portal.idm.destroyserportal}</value>
+ </value-param>
+ </init-params>
</component>
<external-component-plugins>
Deleted: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/demo/navigation.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/demo/navigation.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/demo/navigation.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-
-<node-navigation>
- <priority>3</priority>
-
- <page-nodes />
-</node-navigation>
Deleted: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/demo/pages.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/demo/pages.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/demo/pages.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-
-<page-set
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_0 http://www.gatein.org/xml/ns/gatein_objects_1_0"
- xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_0">
-</page-set>
\ No newline at end of file
Deleted: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/john/navigation.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/john/navigation.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/john/navigation.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-
-<node-navigation>
- <priority>3</priority>
-
- <page-nodes />
-</node-navigation>
Deleted: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/john/pages.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/john/pages.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/john/pages.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-
-<page-set
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_0 http://www.gatein.org/xml/ns/gatein_objects_1_0"
- xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_0">
-</page-set>
Deleted: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/marry/navigation.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/marry/navigation.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/marry/navigation.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-
-<node-navigation>
- <priority>3</priority>
-
- <page-nodes />
-</node-navigation>
Deleted: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/marry/pages.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/marry/pages.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/marry/pages.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-
-<page-set
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_0 http://www.gatein.org/xml/ns/gatein_objects_1_0"
- xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_0">
-</page-set>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/root/navigation.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/root/navigation.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/root/navigation.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -20,31 +20,9 @@
-->
-<node-navigation>
+<node-navigation
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2 http://www.gatein.org/xml/ns/gatein_objects_1_2"
+ xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2">
<priority>3</priority>
-
- <page-nodes>
- <!--
- <node>
- <uri>sales</uri>
- <name>sales</name>
- <label>Sales BI</label>
- <page-reference>user::root::sales</page-reference>
- </node>
-
- <node>
- <uri>scrum</uri>
- <name>scrum</name>
- <label>Scrum</label>
- <page-reference>user::root::scrum</page-reference>
- </node>
-
- <node>
- <uri>development</uri>
- <name>development</name>
- <label>Development</label>
- <page-reference>user::root::development</page-reference>
- </node>
- -->
- </page-nodes>
</node-navigation>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/template/user/navigation.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/template/user/navigation.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/template/user/navigation.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -20,9 +20,17 @@
-->
-<node-navigation>
+<node-navigation
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2 http://www.gatein.org/xml/ns/gatein_objects_1_2"
+ xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2">
<priority>3</priority>
-
<page-nodes>
+ <!-- The default dashboard tab -->
+ <node>
+ <name>Tab_Default</name>
+ <label>Tab_Default</label>
+ <page-reference>user::@owner@::Tab_Default</page-reference>
+ </node>
</page-nodes>
</node-navigation>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/template/user/pages.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/template/user/pages.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/user/template/user/pages.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -24,5 +24,22 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_0 http://www.gatein.org/xml/ns/gatein_objects_1_0"
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_0">
+
+ <!-- The default dashboard page -->
+ <page>
+ <name>Tab_Default</name>
+ <title>Tab_Default</title>
+ <portlet-application>
+ <portlet>
+ <application-ref>dashboard</application-ref>
+ <portlet-ref>DashboardPortlet</portlet-ref>
+ <preferences/>
+ </portlet>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ <show-application-state>true</show-application-state>
+ </portlet-application>
+ </page>
+
</page-set>
Copied: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/web-configuration.xml (from rev 7117, portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/web-configuration.xml)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/web-configuration.xml (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/portal/web-configuration.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+
+<configuration
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd http://www.exoplaform.org/xml/ns/kernel_1_2.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd">
+
+ <component>
+ <type>org.exoplatform.web.filter.ExtensibleFilter</type>
+ </component>
+
+ <component>
+ <key>org.exoplatform.web.application.javascript.JavascriptConfigService</key>
+ <type>org.exoplatform.web.application.javascript.JavascriptConfigService</type>
+ </component>
+
+ <component>
+ <type>org.exoplatform.portal.application.ApplicationStatisticService</type>
+ </component>
+
+ <component>
+ <type>org.exoplatform.portal.application.PortalStatisticService</type>
+ </component>
+
+ <component>
+ <type>org.exoplatform.web.application.javascript.JavascriptConfigService</type>
+ </component>
+
+ <component>
+ <key>org.exoplatform.services.resources.LocalePolicy</key>
+ <type>org.exoplatform.portal.application.localization.DefaultLocalePolicyService</type>
+ </component>
+
+ <component>
+ <key>org.exoplatform.portal.application.state.ContextualPropertyManager</key>
+ <type>org.exoplatform.portal.application.state.ContextualPropertyManagerImpl</type>
+ <component-plugins>
+ <component-plugin>
+ <name>PublicPropertiesPlugin</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.portal.application.state.PublicPropertiesPlugin</type>
+ <init-params>
+ <value-param>
+ <name>namespaceURI</name>
+ <description>Namespace URI</description>
+ <value>http://www.gatein.org/xml/ns/prp_1_0</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>InternalPropertiesPlugin</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.portal.application.state.InternalPropertiesPlugin</type>
+ <init-params>
+ <value-param>
+ <name>namespaceURI</name>
+ <description>Namespace URI</description>
+ <value>http://www.gatein.org/xml/ns/internal_prp_1_0</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ </component-plugins>
+ </component>
+
+</configuration>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/web.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/web.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/web.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -69,8 +69,6 @@
<filter-class>org.exoplatform.services.security.web.SetCurrentIdentityFilter</filter-class>
</filter>
-
-
<filter>
<filter-name>RestEncodingFilter</filter-name>
<filter-class>org.exoplatform.services.rest.servlet.RestEncodingFilter</filter-class>
@@ -94,10 +92,6 @@
<filter-name>ClusteredSSOFilter</filter-name>
<filter-class>org.exoplatform.web.login.ClusteredSSOFilter</filter-class>
</filter>
- <filter>
- <filter-name>PortalContainerFilter</filter-name>
- <filter-class>org.exoplatform.container.web.PortalContainerFilter</filter-class>
- </filter>
<!-- Uncomment ErrorLoginFilter and LoginDetectorFilter for sending mail after successive number of bad login attempts. -->
<!--
@@ -111,13 +105,23 @@
</filter>
-->
+ <filter>
+ <filter-name>PortalContainerFilter</filter-name>
+ <filter-class>org.exoplatform.container.web.PortalContainerFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>PortalContainerFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
<filter-mapping>
<filter-name>PortalContainerFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>RememberMeFilter</filter-name>
- <url-pattern>/public/*</url-pattern>
+ <servlet-name>portal</servlet-name>
</filter-mapping>
<filter-mapping>
@@ -180,11 +184,10 @@
</filter-mapping>
<filter-mapping>
- <filter-name>GenericFilter</filter-name>
- <url-pattern>/*</url-pattern>
+ <filter-name>GenericFilter</filter-name>
+ <url-pattern>/*</url-pattern>
</filter-mapping>
-
<!-- ================================================================== -->
<!-- LISTENER -->
<!-- ================================================================== -->
@@ -235,6 +238,10 @@
<servlet-name>InitiateLoginServlet</servlet-name>
<servlet-class>org.exoplatform.web.login.InitiateLoginServlet</servlet-class>
</servlet>
+ <servlet>
+ <servlet-name>DoLoginServlet</servlet-name>
+ <servlet-class>org.exoplatform.web.login.DoLoginServlet</servlet-class>
+ </servlet>
<servlet>
<servlet-name>ErrorLoginServlet</servlet-name>
<servlet-class>org.exoplatform.web.login.ErrorLoginServlet</servlet-class>
@@ -247,6 +254,7 @@
</servlet>
<!-- ================================================================= -->
+
<servlet-mapping>
<servlet-name>InitiateLoginServlet</servlet-name>
<url-pattern>/initiatelogin</url-pattern>
@@ -259,34 +267,16 @@
<servlet-name>PortalLoginController</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>DoLoginServlet</servlet-name>
+ <url-pattern>/dologin</url-pattern>
+ </servlet-mapping>
+
<servlet-mapping>
<servlet-name>javascript</servlet-name>
<url-pattern>/javascript/*</url-pattern>
</servlet-mapping>
- <servlet-mapping>
- <servlet-name>portal</servlet-name>
- <url-pattern>/private/*</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>portal</servlet-name>
- <url-pattern>/public/*</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>portal</servlet-name>
- <url-pattern>/admin/*</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>portal</servlet-name>
- <url-pattern>/service</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>portal</servlet-name>
- <url-pattern>/upload/*</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>portal</servlet-name>
- <url-pattern>/download/*</url-pattern>
- </servlet-mapping>
+
<servlet-mapping>
<servlet-name>RestServer</servlet-name>
<url-pattern>/rest/*</url-pattern>
@@ -298,20 +288,44 @@
</servlet-mapping>
<servlet-mapping>
+ <servlet-name>portal</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
+
+ <!-- Explicit mappings (due to portal servlet on '/') for UIHomePagePortlet, need to find out how to improve that -->
+ <servlet-mapping>
+ <servlet-name>default</servlet-name>
+ <url-pattern>*.jpg</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>default</servlet-name>
+ <url-pattern>*.png</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>default</servlet-name>
+ <url-pattern>*.gif</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>default</servlet-name>
+ <url-pattern>*.ico</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>default</servlet-name>
+ <url-pattern>*.css</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
<servlet-name>GateInServlet</servlet-name>
<url-pattern>/gateinservlet</url-pattern>
</servlet-mapping>
- <!-- The Welcome File List for IBM WebSphere -->
-
- <welcome-file-list>
- <welcome-file>/index.jsp</welcome-file>
- </welcome-file-list>
-
<security-constraint>
<web-resource-collection>
<web-resource-name>user authentication</web-resource-name>
+ <url-pattern>/dologin</url-pattern>
<url-pattern>/private/*</url-pattern>
+ <url-pattern>/groups/*</url-pattern>
+ <url-pattern>/users/*</url-pattern>
<http-method>POST</http-method>
<http-method>GET</http-method>
</web-resource-collection>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -38,7 +38,6 @@
<listener>org.exoplatform.portal.application.PortalApplicationLifecycle</listener>
<listener>org.exoplatform.webui.application.MonitorApplicationLifecycle</listener>
<listener>org.exoplatform.portal.application.UserProfileLifecycle</listener>
- <listener>org.exoplatform.portal.application.concurrent.PortalConcurrencyMonitorLifecycle</listener>
<listener>org.exoplatform.portal.application.localization.LocalizationLifecycle</listener>
</application-lifecycle-listeners>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/UILoginForm.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/UILoginForm.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/UILoginForm.gtmpl 2011-08-18 21:24:33 UTC (rev 7183)
@@ -6,7 +6,7 @@
jsmanager.importJavascript('eXo.portal.UIPortalControl');
jsmanager.addCustomizedOnLoadScript('document.getElementById("UIPortalComponentLogin").username.focus();');
HttpSession session = rcontext.getRequest().getSession();
- String requestPath = rcontext.getRequestContextPath() + "/private/" + rcontext.getPortalOwner();
+ String requestPath = rcontext.getInitialURI();
//session.setAttribute("initialURI", requestPath);
%>
<div class="UILoginForm">
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl 2011-08-18 21:24:33 UTC (rev 7183)
@@ -83,6 +83,7 @@
eXo.env.portal.portalName = "<%=rcontext.getPortalOwner()%>" ;
eXo.env.server.context = "<%=docBase%>" ;
eXo.env.server.portalBaseURL = "<%=rcontext.getRequest().getRequestURI()%>" ;
+ eXo.env.server.portalURLTemplate = "<%=uicomponent.getPortalURLTemplate()%>" ;
eXo.env.client.skin = "$skin" ;
<%
UIPortal portal = uicomponent.findFirstComponentOfType(UIPortal.class);
@@ -98,17 +99,17 @@
<script type="text/javascript" src="/eXoResources/javascript/eXo/i18n/I18NMessage.js"></script>
<script type="text/javascript" src="/eXoResources/javascript/eXo/i18n/MessageResource_<%=lang%>.js"></script>
- <%
- def headerElements = rcontext.getExtraMarkupHeadersAsStrings();
- if (headerElements != null)
- {
- for (element in headerElements)
- { %>
- <%=element%>
- <% }
- }
- %>
- </head>
+ <%
+ def headerElements = rcontext.getExtraMarkupHeadersAsStrings();
+ if (headerElements != null)
+ {
+ for (element in headerElements)
+ {
+ print(element);
+ }
+ }
+ %>
+ </head>
<body style="height: 100%;">
<%
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/webui/core/UIRightClickPopupMenu.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/webui/core/UIRightClickPopupMenu.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/webui/core/UIRightClickPopupMenu.gtmpl 2011-08-18 21:24:33 UTC (rev 7183)
@@ -18,12 +18,12 @@
<%for(action in uicomponent.getActions()) {%>
<div class="MenuItem">
- <a exo:attr="$action" href="<%=uicomponent.event(action,"_objectid_");%>" onclick="return eXo.webui.UIRightClickPopupMenu.prepareObjectId(event, this);" class="ItemIcon ${action}16x16Icon" >
+ <a exo:attr="$action" href="<%= uicomponent.event(action)%>" onclick="eXo.webui.UIRightClickPopupMenu.prepareObjectId(event, this);" class="ItemIcon ${action}16x16Icon" >
<%=_ctx.appRes(uicomponent.getId() + ".event." + action) %>
</a>
</div>
<%}%>
- <div class="RightClickCustomItem"><span></span></div>
+ <div class="RightClickCustomItem"><span></span></div>
</div>
</div>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/webui/core/UISitemap.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/webui/core/UISitemap.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/webui/core/UISitemap.gtmpl 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,7 +1,7 @@
-<%
+<%
import org.exoplatform.portal.webui.navigation.UIPortalNavigation;
def uiPortalNavigation = uicomponent.getChild(UIPortalNavigation.class);
- uiPortalNavigation.loadTreeNodes();
+ uiPortalNavigation.loadTreeNodes();
uicomponent.renderChildren();
%>
\ No newline at end of file
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/webui/core/UISitemapTree.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/webui/core/UISitemapTree.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/webui/core/UISitemapTree.gtmpl 2011-08-18 21:24:33 UTC (rev 7183)
@@ -2,19 +2,17 @@
import org.exoplatform.web.application.JavascriptManager;
import org.exoplatform.webui.core.UIPortletApplication;
import org.exoplatform.portal.mop.user.UserNode;
+ import javax.portlet.MimeResponse;
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.portal.webui.navigation.TreeNode;
- import org.exoplatform.portal.mop.SiteKey;
- import javax.portlet.MimeResponse;
+ import org.exoplatform.web.url.PortalURL;
+ import org.exoplatform.web.url.navigation.NavigationResource;
import javax.portlet.ResourceURL;
-%>
-<%
+
PortalRequestContext pcontext = Util.getPortalRequestContext();
JavascriptManager jsmanager = pcontext.getJavascriptManager();
jsmanager.importJavascript('eXo.webui.UISiteMap') ;
-
- def portalURI = pcontext.getPortalURI();
UIPortletApplication siteMapPortlet = uicomponent.getParent();
def useAJAX = siteMapPortlet.isUseAjax();
@@ -22,24 +20,28 @@
def actionExpandAll = uicomponent.event("ExpandAllNode");
def actionCollapseAll = uicomponent.event("CollapseAllNode");
- public void renderNodes(TreeNode rootTree, String portalUri, boolean useAjax) {
- def childrenNodes=rootTree.getChildren();
- int childrenSize = childrenNodes.size() ;
- int size = 0;
- for(treeNode in childrenNodes) {
-
+ PortalURL nodeURL = nodeurl();
+
+ public void renderNodes(TreeNode rootTree, PortalURL nodeURL, boolean useAjax) {
+ List childrenNodes = rootTree.getChildren();
+ int childrenSize = childrenNodes.size() ;
+ int size = 0;
+ for(treeNode in childrenNodes) {
+
// count size;
size++;
-
+
def node = treeNode.getNode();
- def treePath = node.getId();
- String label = node.getEncodedResolvedLabel();
- if(useAjax){
- actionLink = uicomponent.event("SelectNode", treePath);
- }else{
- actionLink = portalUri + node.getURI();
+ def treePath = node.getId();
+ String label = node.encodedResolvedLabel;
+
+ def actionLink = "#";
+ if(treeNode.getNode().getPageRef() != null) {
+ nodeURL.setNode(node);
+ nodeURL.setAjax(useAjax);
+ actionLink = nodeURL.toString();
}
-
+
lastNode = '';
if (size == childrenSize) {
lastNode = 'LastNode';
@@ -53,15 +55,14 @@
<div class="$lastNode Node">
<div class="CollapseIcon ClearFix" onclick="eXo.portal.UIPortal.collapseExpand(this); $actionCollapse">
""";
- if(treeNode.getNode().getPageRef() == null) println "<a class='NodeIcon DefaultPageIcon' href='javascript:void(0);'>$label</a>";
- else println "<a class='NodeIcon DefaultPageIcon' href='$actionLink'>$label</a>";
+ println "<a class='NodeIcon DefaultPageIcon' href=\"$actionLink\">$label</a>";
println """
</div>
<div class="ChildrenContainer" style="display: block">
""";
-
- renderNodes(treeNode, portalUri, useAjax);
-
+
+ renderNodes(treeNode, nodeURL, useAjax);
+
} else {
MimeResponse res = _ctx.getRequestContext().getResponse();
ResourceURL resourceURL = res.createResourceURL();
@@ -73,14 +74,13 @@
<div class="$lastNode Node">
<div class="ExpandIcon ClearFix" onclick="eXo.portal.UIPortal.collapseExpand(this); $actionExpand">
""";
- if(treeNode.getNode().getPageRef() == null) println "<a class='NodeIcon DefaultPageIcon' href='javascript:void(0);'>$label</a>";
- else println "<a class='NodeIcon DefaultPageIcon' href='$actionLink'>$label</a>";
+ println "<a class='NodeIcon DefaultPageIcon' href=\"$actionLink\">$label</a>";
println """
</div>
<div class="ChildrenContainer" style="display: none">
""";
- renderNodes(treeNode, portalUri, useAjax);
+ renderNodes(treeNode, nodeURL, useAjax);
}
@@ -103,11 +103,11 @@
}
- }
- }
+ }
+ }
%>
-<div id="UISiteMap" class="UISitemap" >
+<div id="$uicomponent.id" class="UISitemap" >
<div class="ClearFix">
<div class="CollapseAll FloatLeft" onclick="$actionCollapseAll">
<%=_ctx.appRes(siteMapPortlet.getName() + ".label.CollapseAll")%>
@@ -119,7 +119,7 @@
<div class="SitemapContent">
<div class="UISiteTree">
<% TreeNode treeNodeRoot = uicomponent.getTreeNodes() ;%>
- <% renderNodes(treeNodeRoot,portalURI,useAJAX); %>
+ <% renderNodes(treeNodeRoot,nodeURL,useAJAX); %>
</div>
</div>
-</div>
+</div>
\ No newline at end of file
Deleted: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/index.jsp
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/index.jsp 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/index.jsp 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,35 +0,0 @@
-<%--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
---%>
-
-<%@ page import="org.exoplatform.container.PortalContainer"%>
-<%@ page import="org.exoplatform.portal.config.UserPortalConfigService"%>
-<%
- PortalContainer manager = PortalContainer.getCurrentInstance(session.getServletContext());
- UserPortalConfigService userPortalConfigService = (UserPortalConfigService)manager.getComponentInstanceOfType(UserPortalConfigService.class);
- String remoteUser = request.getRemoteUser();
- String accessMode = "public";
- if (remoteUser != null && remoteUser.trim().length() > 0)
- {
- accessMode = "private";
- }
- response.sendRedirect(request.getContextPath() + "/" + accessMode + "/" + userPortalConfigService.getDefaultPortal() + "/");
-%>
-
Deleted: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/portal-unavailable.jsp
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/portal-unavailable.jsp 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/portal-unavailable.jsp 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,126 +0,0 @@
-<%--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
---%>
-
-<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
- <title>Portal Warning </title>
- </head>
- <style>
- .UIPortalWarning {
- width: 600px;
- margin: 200px auto auto auto;
- font-family: tahoma;
- font-size: 12px;
- }
-
- .UIPortalWarning .LeftTopWarning {
- background: url('/eXoResources/skin/sharedImages/LeftTopWarning7x58.gif') no-repeat left center;
- height: 58px;
- padding-left: 7px;
- }
-
- .UIPortalWarning .RightTopWarning {
- background: url('/eXoResources/skin/sharedImages/RightTopWarning7x58.gif') no-repeat right center;
- height: 58px;
- padding-right: 7px;
- }
-
- .UIPortalWarning .CenterTopWaring {
- background: url('/eXoResources/skin/sharedImages/CenterTopWarning1x58.gif') repeat-x center;
- height: 58px;
- line-height: 58px;
- }
-
- .UIPortalWarning .CenterTopWaring .TitleWaring {
- background: url('/eXoResources/skin/sharedImages/WarningIcon.gif') no-repeat left center;
- padding-left: 50px;
- font-size: 18px;
- font-weight: bold;
- line-height: 58px;
- text-align: left;
- margin-left: 20px;
- }
-
- .UIPortalWarning .LeftMiddleWarning {
- background: url('/eXoResources/skin/sharedImages/LeftMiddleWarning7x1.gif') repeat-y left;
- padding-left: 7px;
- }
-
- .UIPortalWarning .RightMiddleWarning {
- background: url('/eXoResources/skin/sharedImages/RightMiddleWarning7x1.gif') repeat-y right;
- text-align: left;
- padding: 30px 30px 50px 30px;
- }
-
- .UIPortalWarning .RightMiddleWarning .Icon {
- background: url('/eXoResources/skin/sharedImages/BlueNextArrow.gif') no-repeat left 5px;
- padding: 6px 0px 6px 20px;
- text-align: left;
- }
-
- .UIPortalWarning .LeftBottomWarning {
- background: url('/eXoResources/skin/sharedImages/LeftBottomWarning7x7.gif') no-repeat left center;
- height: 7px;
- padding-left: 7px;
- }
-
- .UIPortalWarning .RightBottomWarning {
- background: url('/eXoResources/skin/sharedImages/RightBottomWarning7x7.gif') no-repeat right center;
- height: 7px;
- padding-right: 7px;
- }
-
- .UIPortalWarning .CenterBottomWaring {
- background: url('/eXoResources/skin/sharedImages/CenterBottomWarning1x7.gif') repeat-x center;
- height: 7px;
- }
-
- </style>
- <% String contextPath = request.getContextPath() ; %>
- <body style="text-align: center;">
- <div class="UIPortalWarning">
-
- <div class="LeftTopWarning">
- <div class="RightTopWarning">
- <div class="CenterTopWaring">
- <div class="TitleWaring">Can not connect to this portal</div>
- </div>
- </div>
- </div>
- <div class="LeftMiddleWarning">
- <div class="RightMiddleWarning">
- <div class="WarningContent">
- <div class="Icon">Try private mode by URL format: <strong>http://$hostname$<%=contextPath%>/private/$portalname$/</strong></div>
- <div class="Icon">Try another Portal or user URL "<strong>http://$hostname$<%=contextPath%></strong> for default portal.</div>
- </div>
- </div>
- </div>
- <div class="LeftBottomWarning">
- <div class="RightBottomWarning">
- <div class="CenterBottomWaring"><span></span></div>
- </div>
- </div>
-
- </div>
- </body>
-</html>
-
\ No newline at end of file
Deleted: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/portal-warning.jsp
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/portal-warning.jsp 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/portal-warning.jsp 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,126 +0,0 @@
-<%--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
---%>
-
-<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
- <title>Portal Warning </title>
- </head>
- <style>
- .UIPortalWarning {
- width: 600px;
- margin: 200px auto auto auto;
- font-family: tahoma;
- font-size: 12px;
- }
-
- .UIPortalWarning .LeftTopWarning {
- background: url('/eXoResources/skin/sharedImages/LeftTopWarning7x58.gif') no-repeat left center;
- height: 58px;
- padding-left: 7px;
- }
-
- .UIPortalWarning .RightTopWarning {
- background: url('/eXoResources/skin/sharedImages/RightTopWarning7x58.gif') no-repeat right center;
- height: 58px;
- padding-right: 7px;
- }
-
- .UIPortalWarning .CenterTopWaring {
- background: url('/eXoResources/skin/sharedImages/CenterTopWarning1x58.gif') repeat-x center;
- height: 58px;
- line-height: 58px;
- }
-
- .UIPortalWarning .CenterTopWaring .TitleWaring {
- background: url('/eXoResources/skin/sharedImages/WarningIcon.gif') no-repeat left center;
- padding-left: 50px;
- font-size: 18px;
- font-weight: bold;
- line-height: 58px;
- text-align: left;
- margin-left: 20px;
- }
-
- .UIPortalWarning .LeftMiddleWarning {
- background: url('/eXoResources/skin/sharedImages/LeftMiddleWarning7x1.gif') repeat-y left;
- padding-left: 7px;
- }
-
- .UIPortalWarning .RightMiddleWarning {
- background: url('/eXoResources/skin/sharedImages/RightMiddleWarning7x1.gif') repeat-y right;
- text-align: left;
- padding: 30px 30px 50px 30px;
- }
-
- .UIPortalWarning .RightMiddleWarning .Icon {
- background: url('/eXoResources/skin/sharedImages/BlueNextArrow.gif') no-repeat left 5px;
- padding: 6px 0px 6px 20px;
- text-align: left;
- }
-
- .UIPortalWarning .LeftBottomWarning {
- background: url('/eXoResources/skin/sharedImages/LeftBottomWarning7x7.gif') no-repeat left center;
- height: 7px;
- padding-left: 7px;
- }
-
- .UIPortalWarning .RightBottomWarning {
- background: url('/eXoResources/skin/sharedImages/RightBottomWarning7x7.gif') no-repeat right center;
- height: 7px;
- padding-right: 7px;
- }
-
- .UIPortalWarning .CenterBottomWaring {
- background: url('/eXoResources/skin/sharedImages/CenterBottomWarning1x7.gif') repeat-x center;
- height: 7px;
- }
-
- </style>
- <% String contextPath = request.getContextPath() ; %>
- <body style="text-align: center;">
- <div class="UIPortalWarning">
-
- <div class="LeftTopWarning">
- <div class="RightTopWarning">
- <div class="CenterTopWaring">
- <div class="TitleWaring">Resources not found</div>
- </div>
- </div>
- </div>
- <div class="LeftMiddleWarning">
- <div class="RightMiddleWarning">
- <div class="WarningContent">
- <div class="Icon">Try private mode by URL format: <strong>http://$hostname$<%=contextPath%>/private/$portalname$/</strong></div>
- <div class="Icon">Try another Portal.</div>
- </div>
- </div>
- </div>
- <div class="LeftBottomWarning">
- <div class="RightBottomWarning">
- <div class="CenterBottomWaring"><span></span></div>
- </div>
- </div>
-
- </div>
- </body>
-</html>
-
\ No newline at end of file
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,6 +1,9 @@
<%
- //TODO: nguyenanhkien2a(a)gmail.com
- String initialURI = _ctx.getRequestContext().getParentAppRequestContext().getRequestContextPath() + "/private/" + _ctx.getRequestContext().getParentAppRequestContext().getPortalOwner();
+ import org.exoplatform.portal.webui.util.Util;
+ import org.exoplatform.portal.application.PortalRequestContext;
+
+ PortalRequestContext pcontext = Util.getPortalRequestContext();
+ String initialURI = pcontext.getInitialURI();
%>
<div class="UIHomePagePortlet" id="$uicomponent.id">
Modified: epp/portal/branches/EPP_5_2_Branch/webui/framework/pom.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/framework/pom.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/framework/pom.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -33,6 +33,10 @@
<dependencies>
<dependency>
+ <groupId>org.gatein.common</groupId>
+ <artifactId>common-logging</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.exoplatform.portal</groupId>
<artifactId>exo.portal.component.web.controller</artifactId>
</dependency>
@@ -44,6 +48,11 @@
<groupId>org.exoplatform.portal</groupId>
<artifactId>exo.portal.component.scripting</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.test.core</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
Modified: epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/application/WebuiRequestContext.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/application/WebuiRequestContext.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/application/WebuiRequestContext.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -69,6 +69,11 @@
super(app);
}
+ protected WebuiRequestContext(RequestContext parentAppRequestContext, Application app_)
+ {
+ super(parentAppRequestContext, app_);
+ }
+
public String getSessionId()
{
return sessionId_;
Modified: epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/core/UIApplication.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/core/UIApplication.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/core/UIApplication.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -51,11 +51,13 @@
uiPopupMessages_.setId("_" + uiPopupMessages_.hashCode());
}
+ //TODO this looks like not to be used anymore
public String getOwner()
{
return owner;
}
+ //TODO this looks like not to be used anymore
public void setOwner(String s)
{
owner = s;
@@ -125,10 +127,9 @@
}
catch (Throwable t)
{
- Object[] args = {t.getMessage()};
ApplicationMessage msg =
- new ApplicationMessage("UIApplication.msg.unknown-error", args, ApplicationMessage.ERROR);
- getUIPopupMessages().addMessage(msg);
+ new ApplicationMessage("UIApplication.msg.unknown-error", null, ApplicationMessage.ERROR);
+ uiPopupMessages_.addMessage(msg);
log.error("Error during the processAction phase", t);
}
}
Modified: epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponent.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponent.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponent.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -19,6 +19,7 @@
package org.exoplatform.webui.core;
+import org.exoplatform.commons.serialization.api.annotations.Serialized;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.resolver.ResourceResolver;
import org.exoplatform.services.log.ExoLogger;
@@ -27,7 +28,6 @@
import org.exoplatform.web.application.URLBuilder;
import org.exoplatform.webui.application.WebuiApplication;
import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.commons.serialization.api.annotations.Serialized;
import org.exoplatform.webui.config.Component;
import org.exoplatform.webui.core.lifecycle.Lifecycle;
import org.exoplatform.webui.event.Event;
Modified: epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/core/lifecycle/WebuiBindingContext.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/core/lifecycle/WebuiBindingContext.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/core/lifecycle/WebuiBindingContext.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -19,12 +19,14 @@
package org.exoplatform.webui.core.lifecycle;
+import groovy.lang.Closure;
import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.groovyscript.text.BindingContext;
import org.exoplatform.resolver.ResourceResolver;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.services.resources.Orientation;
+import org.exoplatform.web.url.navigation.NodeURL;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.core.UIComponent;
import org.exoplatform.webui.core.UIComponentDecorator;
@@ -45,12 +47,22 @@
private WebuiRequestContext rcontext_;
- public WebuiBindingContext(ResourceResolver resolver, Writer w, UIComponent uicomponent, WebuiRequestContext context)
+ public WebuiBindingContext(ResourceResolver resolver, Writer w, UIComponent uicomponent, final WebuiRequestContext context)
{
super(resolver, w);
uicomponent_ = uicomponent;
rcontext_ = context;
+ // Closure nodeurl()
+ put("nodeurl", new Closure(this)
+ {
+ @Override
+ public Object call(Object[] args)
+ {
+ return context.createURL(NodeURL.TYPE);
+ }
+ });
+
// Add Orientation specific information
Orientation orientation = context.getOrientation();
this.put("orientation", orientation);
Deleted: epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/url/ComponentURL.java
===================================================================
--- portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/url/ComponentURL.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/url/ComponentURL.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.webui.url;
-
-import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.url.PortalURL;
-import org.exoplatform.web.url.ResourceType;
-import org.exoplatform.web.url.URLContext;
-import org.exoplatform.webui.core.UIComponent;
-import org.gatein.common.util.Tools;
-
-import java.util.Collections;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class ComponentURL extends PortalURL<UIComponent, ComponentURL>
-{
-
- /** . */
- public static final ResourceType<UIComponent, ComponentURL> TYPE = new ResourceType<UIComponent, ComponentURL>() {};
-
- /** . */
- public static final QualifiedName COMPONENT = QualifiedName.create("gtn", "componentid");
-
- /** . */
- public static final QualifiedName ACTION = QualifiedName.create("gtn", "action");
-
- /** . */
- public static final QualifiedName TARGET = QualifiedName.create("gtn", "objectid");
-
- /** . */
- public static final QualifiedName PATH = QualifiedName.create("gtn", "path");
-
- /** . */
- private static final Set<QualifiedName> NAMES = Collections.unmodifiableSet(Tools.toSet(COMPONENT, ACTION, TARGET, PATH));
-
- /** . */
- private UIComponent resource;
-
- /** . */
- private String action;
-
- /** . */
- private String targetBeanId;
-
- /** . */
- private String path;
-
- public ComponentURL(URLContext context) throws NullPointerException
- {
- super(context);
- }
-
- public UIComponent getResource()
- {
- return resource;
- }
-
- public ComponentURL setResource(UIComponent resource)
- {
- this.resource = resource;
- return this;
- }
-
- public Set<QualifiedName> getParameterNames()
- {
- return NAMES;
- }
-
- public String getParameterValue(QualifiedName parameterName)
- {
- if (COMPONENT.equals(parameterName))
- {
- return resource != null ? resource.getId() : null;
- }
- else if (ACTION.equals(parameterName))
- {
- return action;
- }
- else if (TARGET.equals(parameterName))
- {
- return targetBeanId;
- }
- else if (PATH.equals(parameterName))
- {
- return path;
- }
- else
- {
- return null;
- }
- }
-
- public String getAction()
- {
- return action;
- }
-
- public void setAction(String action)
- {
- this.action = action;
- }
-
- public String getTargetBeanId()
- {
- return targetBeanId;
- }
-
- public void setTargetBeanId(String targetBeanId)
- {
- this.targetBeanId = targetBeanId;
- }
-
- public String getPath()
- {
- return path;
- }
-
- public void setPath(String path)
- {
- this.path = path;
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/url/ComponentURL.java (from rev 7117, portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/url/ComponentURL.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/url/ComponentURL.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/webui/framework/src/main/java/org/exoplatform/webui/url/ComponentURL.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.webui.url;
+
+import org.exoplatform.web.controller.QualifiedName;
+import org.exoplatform.web.url.PortalURL;
+import org.exoplatform.web.url.ResourceType;
+import org.exoplatform.web.url.URLContext;
+import org.exoplatform.webui.core.UIComponent;
+import org.gatein.common.util.Tools;
+
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ComponentURL extends PortalURL<UIComponent, ComponentURL>
+{
+
+ /** . */
+ public static final ResourceType<UIComponent, ComponentURL> TYPE = new ResourceType<UIComponent, ComponentURL>() {};
+
+ /** . */
+ public static final QualifiedName COMPONENT = QualifiedName.create("gtn", "componentid");
+
+ /** . */
+ public static final QualifiedName ACTION = QualifiedName.create("gtn", "action");
+
+ /** . */
+ public static final QualifiedName TARGET = QualifiedName.create("gtn", "objectid");
+
+ /** . */
+ public static final QualifiedName PATH = QualifiedName.create("gtn", "path");
+
+ /** . */
+ private static final Set<QualifiedName> NAMES = Collections.unmodifiableSet(Tools.toSet(COMPONENT, ACTION, TARGET, PATH));
+
+ /** . */
+ private UIComponent resource;
+
+ /** . */
+ private String action;
+
+ /** . */
+ private String targetBeanId;
+
+ /** . */
+ private String path;
+
+ public ComponentURL(URLContext context) throws NullPointerException
+ {
+ super(context);
+ }
+
+ public UIComponent getResource()
+ {
+ return resource;
+ }
+
+ public ComponentURL setResource(UIComponent resource)
+ {
+ this.resource = resource;
+ return this;
+ }
+
+ public Set<QualifiedName> getParameterNames()
+ {
+ return NAMES;
+ }
+
+ public String getParameterValue(QualifiedName parameterName)
+ {
+ if (COMPONENT.equals(parameterName))
+ {
+ return resource != null ? resource.getId() : null;
+ }
+ else if (ACTION.equals(parameterName))
+ {
+ return action;
+ }
+ else if (TARGET.equals(parameterName))
+ {
+ return targetBeanId;
+ }
+ else if (PATH.equals(parameterName))
+ {
+ return path;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public String getAction()
+ {
+ return action;
+ }
+
+ public void setAction(String action)
+ {
+ this.action = action;
+ }
+
+ public String getTargetBeanId()
+ {
+ return targetBeanId;
+ }
+
+ public void setTargetBeanId(String targetBeanId)
+ {
+ this.targetBeanId = targetBeanId;
+ }
+
+ public String getPath()
+ {
+ return path;
+ }
+
+ public void setPath(String path)
+ {
+ this.path = path;
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/conf/configuration.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/conf/configuration.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/conf/configuration.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-
-<configuration
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
- xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
-
-</configuration>
Deleted: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/conf/portal/configuration.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/conf/portal/configuration.xml 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/conf/portal/configuration.xml 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,71 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-
-<configuration
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
- xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
- <component>
- <type>org.exoplatform.portal.application.ApplicationStatisticService</type>
- </component>
-
- <component>
- <type>org.exoplatform.portal.application.PortalStatisticService</type>
- </component>
-
- <component>
- <key>org.exoplatform.services.resources.LocalePolicy</key>
- <!--type>org.exoplatform.portal.application.NoBrowserLocalePolicyService</type-->
- <type>org.exoplatform.portal.application.localization.DefaultLocalePolicyService</type>
- </component>
-
- <component>
- <key>org.exoplatform.portal.application.state.ContextualPropertyManager</key>
- <type>org.exoplatform.portal.application.state.ContextualPropertyManagerImpl</type>
- <component-plugins>
- <component-plugin>
- <name>PublicPropertiesPlugin</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.portal.application.state.PublicPropertiesPlugin</type>
- <init-params>
- <value-param>
- <name>namespaceURI</name>
- <description>Namespace URI</description>
- <value>http://www.gatein.org/xml/ns/prp_1_0</value>
- </value-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>InternalPropertiesPlugin</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.portal.application.state.InternalPropertiesPlugin</type>
- <init-params>
- <value-param>
- <name>namespaceURI</name>
- <description>Namespace URI</description>
- <value>http://www.gatein.org/xml/ns/internal_prp_1_0</value>
- </value-param>
- </init-params>
- </component-plugin>
- </component-plugins>
- </component>
-</configuration>
Copied: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/DefaultRequestHandler.java (from rev 7117, portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/DefaultRequestHandler.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/DefaultRequestHandler.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/DefaultRequestHandler.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.application;
+
+import org.exoplatform.portal.config.UserPortalConfigService;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.SiteType;
+import org.exoplatform.portal.url.PortalURLContext;
+import org.exoplatform.web.ControllerContext;
+import org.exoplatform.web.WebRequestHandler;
+import org.exoplatform.web.url.URLFactoryService;
+import org.exoplatform.web.url.navigation.NavigationResource;
+import org.exoplatform.web.url.navigation.NodeURL;
+
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public class DefaultRequestHandler extends WebRequestHandler
+{
+
+ /** . */
+ private final UserPortalConfigService configService;
+
+ /** . */
+ private final URLFactoryService urlFactory;
+
+ public DefaultRequestHandler(UserPortalConfigService configService, URLFactoryService urlFactory)
+ {
+ this.configService = configService;
+ this.urlFactory = urlFactory;
+ }
+
+ @Override
+ public String getHandlerName()
+ {
+ return "default";
+ }
+
+ @Override
+ public void execute(ControllerContext context) throws Exception
+ {
+ String defaultPortal = configService.getDefaultPortal();
+ PortalURLContext urlContext = new PortalURLContext(context, SiteKey.portal(defaultPortal));
+ NodeURL url = urlFactory.newURL(NodeURL.TYPE, urlContext);
+ String s = url.setResource(new NavigationResource(SiteType.PORTAL, defaultPortal, "")).toString();
+ HttpServletResponse resp = context.getResponse();
+ resp.sendRedirect(resp.encodeRedirectURL(s));
+ }
+}
Copied: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/LegacyRequestHandler.java (from rev 7117, portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/LegacyRequestHandler.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/LegacyRequestHandler.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/LegacyRequestHandler.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.application;
+
+import org.exoplatform.portal.config.UserPortalConfig;
+import org.exoplatform.portal.config.UserPortalConfigService;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.user.UserNavigation;
+import org.exoplatform.portal.mop.user.UserNode;
+import org.exoplatform.portal.mop.user.UserNodeFilterConfig;
+import org.exoplatform.portal.mop.user.UserPortal;
+import org.exoplatform.portal.mop.user.UserPortalContext;
+import org.exoplatform.portal.url.PortalURLContext;
+import org.exoplatform.web.ControllerContext;
+import org.exoplatform.web.WebRequestHandler;
+import org.exoplatform.web.url.MimeType;
+import org.exoplatform.web.url.URLFactoryService;
+import org.exoplatform.web.url.navigation.NavigationResource;
+import org.exoplatform.web.url.navigation.NodeURL;
+
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * This handler resolves legacy request and redirect them to the new URL computed dynamically against the
+ * routing table.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public class LegacyRequestHandler extends WebRequestHandler
+{
+
+ /** . */
+ private final URLFactoryService urlFactory;
+
+ /** . */
+ private final UserPortalConfigService userPortalService;
+
+ /** . */
+ private final UserPortalContext userPortalContext = new UserPortalContext()
+ {
+ public ResourceBundle getBundle(UserNavigation navigation)
+ {
+ return null;
+ }
+
+ public Locale getUserLocale()
+ {
+ return Locale.ENGLISH;
+ }
+ };
+
+ public LegacyRequestHandler(URLFactoryService urlFactory, UserPortalConfigService userPortalService)
+ {
+ this.urlFactory = urlFactory;
+ this.userPortalService = userPortalService;
+ }
+
+ @Override
+ public String getHandlerName()
+ {
+ return "legacy";
+ }
+
+ @Override
+ public void execute(ControllerContext context) throws Exception
+ {
+ String requestSiteName = context.getParameter(PortalRequestHandler.REQUEST_SITE_NAME);
+ String requestPath = context.getParameter(PortalRequestHandler.REQUEST_PATH);
+
+ // Resolve the user node
+ UserPortalConfig cfg = userPortalService.getUserPortalConfig(requestSiteName, context.getRequest().getRemoteUser(), userPortalContext);
+ UserPortal userPortal = cfg.getUserPortal();
+ UserNodeFilterConfig.Builder builder = UserNodeFilterConfig.builder().withAuthMode(UserNodeFilterConfig.AUTH_READ);
+ UserNode userNode = userPortal.resolvePath(builder.build(), requestPath);
+
+ //
+ SiteKey siteKey;
+ String uri;
+ if (userNode != null)
+ {
+ siteKey = userNode.getNavigation().getKey();
+ uri = userNode.getURI();
+ }
+ else
+ {
+ siteKey = SiteKey.portal("classic");
+ uri = "";
+ }
+
+ //
+ PortalURLContext urlContext = new PortalURLContext(context, siteKey);
+ NodeURL url = urlFactory.newURL(NodeURL.TYPE, urlContext);
+
+ // For now we redirect on the default classic site
+ url.setResource(new NavigationResource(siteKey.getType(), siteKey.getName(), uri));
+ url.setMimeType(MimeType.PLAIN);
+
+ HttpServletRequest request = context.getRequest();
+ Enumeration paraNames = request.getParameterNames();
+ while (paraNames.hasMoreElements())
+ {
+ String parameter = paraNames.nextElement().toString();
+ url.setQueryParameterValues(parameter, request.getParameterValues(parameter));
+ }
+
+ String s = url.toString();
+
+ HttpServletResponse resp = context.getResponse();
+ resp.sendRedirect(resp.encodeRedirectURL(s));
+ }
+}
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -25,11 +25,19 @@
import org.exoplatform.commons.xml.DOMSerializer;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.portal.config.UserPortalConfig;
import org.exoplatform.portal.config.UserPortalConfigService;
import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.mop.user.UserNavigation;
import org.exoplatform.portal.mop.user.UserNode;
import org.exoplatform.portal.mop.user.UserPortalContext;
+import org.exoplatform.web.url.navigation.NodeURL;
+import org.exoplatform.web.url.navigation.NavigationResource;
+import org.exoplatform.web.url.URLFactoryService;
+import org.exoplatform.portal.url.PortalURLContext;
import org.exoplatform.portal.webui.portal.UIPortal;
import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.portal.webui.workspace.UIPortalApplication;
@@ -37,11 +45,16 @@
import org.exoplatform.services.log.Log;
import org.exoplatform.services.resources.Orientation;
import org.exoplatform.services.resources.ResourceBundleManager;
+import org.exoplatform.web.ControllerContext;
import org.exoplatform.web.application.JavascriptManager;
import org.exoplatform.web.application.URLBuilder;
+import org.exoplatform.web.url.PortalURL;
+import org.exoplatform.web.url.URLFactory;
+import org.exoplatform.web.url.ResourceType;
import org.exoplatform.webui.application.WebuiApplication;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.core.UIComponent;
+import org.exoplatform.webui.url.ComponentURL;
import org.gatein.common.http.QueryStringParser;
import org.w3c.dom.Element;
@@ -49,7 +62,6 @@
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
-import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -61,6 +73,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
/**
* This class extends the abstract WebuiRequestContext which itself extends the RequestContext one
@@ -69,7 +82,6 @@
*/
public class PortalRequestContext extends WebuiRequestContext
{
-
protected static Log log = ExoLogger.getLogger("portal:PortalRequestContext");
final static public int PUBLIC_ACCESS = 0;
@@ -80,26 +92,37 @@
final static public String UI_COMPONENT_ID = "portal:componentId";
+ final static public String TARGET_NODE = "portal:targetNode";
+
final static public String CACHE_LEVEL = "portal:cacheLevel";
final static public String REQUEST_TITLE = "portal:requestTitle".intern();
final static public String REQUEST_METADATA = "portal:requestMetadata".intern();
- private String portalOwner_;
+ final static private String LAST_PORTAL_NAME = "prc.lastPortalName";
- private String nodePath_;
+ /** The path decoded from the request. */
+ private final String nodePath_;
- private String requestURI_;
+ /** . */
+ private final String requestURI_;
- private String portalURI;
+ /** . */
+ private final String portalURI;
- private int accessPath = -1;
+ /** . */
+ private final SiteKey siteKey;
- private HttpServletRequest request_;
+ /** The locale from the request. */
+ private final Locale requestLocale;
- private HttpServletResponse response_;
+ /** . */
+ private final HttpServletRequest request_;
+ /** . */
+ private final HttpServletResponse response_;
+
private String cacheLevel_ = "cacheLevelPortlet";
private boolean ajaxRequest_ = true;
@@ -113,28 +136,55 @@
private List<Element> extraMarkupHeaders;
private final PortalURLBuilder urlBuilder;
-
+
private Map<String, String[]> parameterMap;
private Locale locale = Locale.ENGLISH;
+ /** . */
+ private final URLFactoryService urlFactory;
+
+ /** . */
+ private final ControllerContext controllerContext;
+
+ private UserPortalConfig userPortalConfig;
+
public JavascriptManager getJavascriptManager()
{
return jsmanager_;
}
- public PortalRequestContext(WebuiApplication app, HttpServletRequest req, HttpServletResponse res) throws Exception
+ /**
+ * Analyze a request and split this request's URI to get useful information
+ * then keep it in following properties of PortalRequestContext :<br/>
+ * 1. <code>requestURI</code> : The decoded URI of this request <br/>
+ * 2. <code>portalOwner</code> : The portal name ( "classic" for instance )<br/>
+ * 3. <code>portalURI</code> : The URI to current portal ( "/portal/public/classic/ for instance )<br/>
+ * 4. <code>nodePath</code> : The path that is used to reflect to a navigation node
+ */
+ public PortalRequestContext(
+ WebuiApplication app,
+ ControllerContext controllerContext,
+ String requestSiteType,
+ String requestSiteName,
+ String requestPath,
+ Locale requestLocale) throws Exception
{
super(app);
- request_ = req;
- response_ = res;
+
+ //
+ this.urlFactory = (URLFactoryService)PortalContainer.getComponent(URLFactoryService.class);
+ this.controllerContext = controllerContext;
+
+ //
+ request_ = controllerContext.getRequest();
+ response_ = controllerContext.getResponse();
response_.setBufferSize(1024 * 100);
- setSessionId(req.getSession().getId());
-
-
+ setSessionId(request_.getSession().getId());
+
//The encoding needs to be set before reading any of the parameters since the parameters's encoding
//is set at the first access.
-
+
//TODO use the encoding from the locale-config.xml file
response_.setContentType("text/html; charset=UTF-8");
try
@@ -145,33 +195,34 @@
{
log.error("Encoding not supported", e);
}
-
+
// Query parameters from the request will be set in the servlet container url encoding and not
// necessarly in utf-8 format. So we need to directly parse the parameters from the query string.
parameterMap = new HashMap<String, String[]>();
parameterMap.putAll(request_.getParameterMap());
- String queryString = req.getQueryString();
+ String queryString = request_.getQueryString();
if (queryString != null)
{
Map<String, String[]> queryParams = QueryStringParser.getInstance().parseQueryString(queryString);
parameterMap.putAll(queryParams);
}
-
- ajaxRequest_ = "true".equals(req.getParameter("ajaxRequest"));
- String cache = req.getParameter(CACHE_LEVEL);
+
+ ajaxRequest_ = "true".equals(request_.getParameter("ajaxRequest"));
+ String cache = request_.getParameter(CACHE_LEVEL);
if (cache != null)
{
cacheLevel_ = cache;
}
- requestURI_ = req.getRequestURI();
+ requestURI_ = request_.getRequestURI();
+/*
String decodedURI = URLDecoder.decode(requestURI_, "UTF-8");
// req.getPathInfo will already have the encoding set from the server.
// We need to use the UTF-8 value since this is how we store the portal name.
// Reconstructing the getPathInfo from the non server decoded values.
- String servletPath = URLDecoder.decode(req.getServletPath(), "UTF-8");
- String contextPath = URLDecoder.decode(req.getContextPath(), "UTF-8");
+ String servletPath = URLDecoder.decode(request_.getServletPath(), "UTF-8");
+ String contextPath = URLDecoder.decode(request_.getContextPath(), "UTF-8");
String pathInfo = "/";
if (decodedURI.length() > servletPath.length() + contextPath.length())
pathInfo = decodedURI.substring(servletPath.length() + contextPath.length());
@@ -183,21 +234,93 @@
}
portalOwner_ = pathInfo.substring(1, colonIndex);
nodePath_ = pathInfo.substring(colonIndex, pathInfo.length());
+*/
+ //
+ this.siteKey = new SiteKey(SiteType.valueOf(requestSiteType.toUpperCase()), requestSiteName);
+ this.nodePath_ = requestPath;
+ this.requestLocale = requestLocale;
- portalURI = decodedURI.substring(0, decodedURI.lastIndexOf(nodePath_)) + "/";
+ //
+ NodeURL url = createURL(NodeURL.TYPE);
+ url.setResource(new NavigationResource(siteKey, ""));
+ portalURI = url.toString();
- if (decodedURI.indexOf("/public/") >= 0)
+ //
+ urlBuilder = new PortalURLBuilder(this, createURL(ComponentURL.TYPE));
+ }
+
+ @Override
+ public <R, U extends PortalURL<R, U>> U newURL(ResourceType<R, U> resourceType, URLFactory urlFactory)
+ {
+ PortalURLContext urlContext = new PortalURLContext(controllerContext, siteKey);
+ U url = urlFactory.newURL(resourceType, urlContext);
+ if (url != null)
{
- accessPath = PUBLIC_ACCESS;
+ url.setAjax(false);
+ url.setLocale(requestLocale);
}
- else if (decodedURI.indexOf("/private/") >= 0)
+ return url;
+ }
+
+ public UserPortalConfig getUserPortalConfig()
+ {
+ if (userPortalConfig == null)
{
- accessPath = PRIVATE_ACCESS;
+ String portalName = null;
+ String remoteUser = getRemoteUser();
+ SiteType siteType = getSiteType();
+
+ ExoContainer appContainer = getApplication().getApplicationServiceContainer();
+ UserPortalConfigService service_ =
+ (UserPortalConfigService)appContainer.getComponentInstanceOfType(UserPortalConfigService.class);
+ if (SiteType.PORTAL == siteType)
+ {
+ portalName = getSiteName();
+ }
+
+ HttpSession session = request_.getSession();
+ if (portalName == null)
+ {
+ if (session != null)
+ {
+ portalName = (String)session.getAttribute(LAST_PORTAL_NAME);
+ }
+ }
+
+ if (portalName == null)
+ {
+ portalName = service_.getDefaultPortal();
+ }
+ try
+ {
+ userPortalConfig =
+ service_.getUserPortalConfig(portalName, remoteUser, PortalRequestContext.USER_PORTAL_CONTEXT);
+ session.setAttribute(LAST_PORTAL_NAME, portalName);
+ }
+ catch (Exception e)
+ {
+ return null;
+ }
}
+
+ return userPortalConfig;
+ }
+
+ public void setUserPortalConfig(UserPortalConfig upc)
+ {
+ userPortalConfig = upc;
+ }
- urlBuilder = new PortalURLBuilder(requestURI_);
+ public String getInitialURI()
+ {
+ return request_.getRequestURI();
}
+ public ControllerContext getControllerContext()
+ {
+ return controllerContext;
+ }
+
public void refreshResourceBundle() throws Exception
{
appRes_ = getApplication().getResourceBundle(getLocale());
@@ -238,11 +361,22 @@
return title;
}
+ @Override
+ public URLFactory getURLFactory()
+ {
+ return urlFactory;
+ }
+
public Orientation getOrientation()
{
return ((UIPortalApplication)uiApplication_).getOrientation();
}
+ public Locale getRequestLocale()
+ {
+ return requestLocale;
+ }
+
public void setLocale(Locale locale)
{
this.locale = locale;
@@ -317,11 +451,34 @@
return PortalRequestContext.UI_COMPONENT_ID;
}
+ public SiteType getSiteType()
+ {
+ return siteKey.getType();
+ }
+
+ public String getSiteName()
+ {
+ return siteKey.getName();
+ }
+
+ public SiteKey getSiteKey()
+ {
+ return siteKey;
+ }
+
public String getPortalOwner()
{
- return portalOwner_;
+ UserPortalConfig userPortalConfig = getUserPortalConfig();
+ if (userPortalConfig != null)
+ {
+ return userPortalConfig.getPortalName();
+ }
+ else
+ {
+ return null;
+ }
}
-
+
public String getNodePath()
{
return nodePath_;
@@ -344,7 +501,7 @@
public int getAccessPath()
{
- return accessPath;
+ return request_.getRemoteUser() != null ? PRIVATE_ACCESS : PUBLIC_ACCESS;
}
final public String getRemoteUser()
@@ -365,10 +522,10 @@
}
return writer_;
}
-
+
final public void setWriter(Writer writer)
{
- this.writer_ = writer;
+ this.writer_ = writer;
}
final public boolean useAjax()
@@ -432,6 +589,12 @@
this.forceFullUpdate = ignoreAJAXUpdateOnPortlets;
}
+ final public void sendError(int sc) throws IOException
+ {
+ setResponseComplete(true);
+ response_.sendError(sc);
+ }
+
final public void sendRedirect(String url) throws IOException
{
setResponseComplete(true);
@@ -447,10 +610,11 @@
response_.setHeader(key, headers.get(key));
}
}
-
+
public List<String> getExtraMarkupHeadersAsStrings() throws Exception
{
List<String> markupHeaders = new ArrayList<String>();
+
if (extraMarkupHeaders != null && !extraMarkupHeaders.isEmpty())
{
for (Element element : extraMarkupHeaders)
@@ -460,18 +624,19 @@
markupHeaders.add(sw.toString());
}
}
+
return markupHeaders;
}
-
+
/**
* Get the extra markup headers to add to the head of the html.
* @return The markup to be added.
*/
public List<Element> getExtraMarkupHeaders()
{
- return this.extraMarkupHeaders;
+ return this.extraMarkupHeaders;
}
-
+
/**
* Add an extra markup to the head of the html page.
* @param element The element to add
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -19,20 +19,24 @@
package org.exoplatform.portal.application;
+import org.exoplatform.commons.utils.I18N;
import org.exoplatform.commons.utils.Safe;
import org.exoplatform.portal.config.StaleModelException;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import org.exoplatform.web.ControllerContext;
import org.exoplatform.web.WebAppController;
import org.exoplatform.web.WebRequestHandler;
import org.exoplatform.web.application.ApplicationLifecycle;
import org.exoplatform.web.application.ApplicationRequestPhaseLifecycle;
import org.exoplatform.web.application.Phase;
import org.exoplatform.web.application.RequestFailure;
+import org.exoplatform.web.controller.QualifiedName;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.core.UIApplication;
import java.util.List;
+import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -49,11 +53,21 @@
protected static Log log = ExoLogger.getLogger("portal:PortalRequestHandler");
- private String[] PATHS = {"/public", "/private"};
+ /** . */
+ public static final QualifiedName REQUEST_PATH = QualifiedName.create("gtn", "path");
- public String[] getPath()
+ /** . */
+ public static final QualifiedName REQUEST_SITE_TYPE = QualifiedName.create("gtn", "sitetype");
+
+ /** . */
+ public static final QualifiedName REQUEST_SITE_NAME = QualifiedName.create("gtn", "sitename");
+
+ /** . */
+ public static final QualifiedName LANG = QualifiedName.create("gtn", "lang");
+
+ public String getHandlerName()
{
- return PATHS;
+ return "portal";
}
/**
@@ -80,30 +94,69 @@
*
*/
@SuppressWarnings("unchecked")
- public void execute(WebAppController controller, HttpServletRequest req, HttpServletResponse res) throws Exception
+ @Override
+ public void execute(ControllerContext controllerContext) throws Exception
{
+ HttpServletRequest req = controllerContext.getRequest();
+ HttpServletResponse res = controllerContext.getResponse();
+
+
log.debug("Session ID = " + req.getSession().getId());
res.setHeader("Cache-Control", "no-cache");
- PortalApplication app = controller.getApplication(PortalApplication.PORTAL_APPLICATION_ID);
- PortalRequestContext context = new PortalRequestContext(app, req, res);
- if (context.getPortalOwner().length() == 0) {
+ //
+ String requestPath = controllerContext.getParameter(REQUEST_PATH);
+ String requestSiteType = controllerContext.getParameter(REQUEST_SITE_TYPE);
+ String requestSiteName = controllerContext.getParameter(REQUEST_SITE_NAME);
+
+ //
+ Locale requestLocale;
+ String lang = controllerContext.getParameter(LANG);
+ if (lang == null || lang.length() == 0)
+ {
+ requestLocale = null;
+ }
+ else
+ {
+ requestLocale = I18N.parseTagIdentifier(lang);
+ }
+
+ if (requestSiteName == null) {
res.sendRedirect(req.getContextPath());
return;
}
+
+ PortalApplication app = controllerContext.getController().getApplication(PortalApplication.PORTAL_APPLICATION_ID);
+ PortalRequestContext context = new PortalRequestContext(app, controllerContext, requestSiteType, requestSiteName, requestPath, requestLocale);
+ if (context.getUserPortalConfig() == null)
+ {
+ context.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+ else
+ {
+ processRequest(context, app);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void processRequest(PortalRequestContext context, PortalApplication app) throws Exception
+ {
WebuiRequestContext.setCurrentInstance(context);
+ UIApplication uiApp = app.getStateManager().restoreUIRootComponent(context);
+
List<ApplicationLifecycle> lifecycles = app.getApplicationLifecycle();
try
{
for (ApplicationLifecycle lifecycle : lifecycles)
lifecycle.onStartRequest(app, context);
- UIApplication uiApp = app.getStateManager().restoreUIRootComponent(context);
if (context.getUIApplication() != uiApp)
context.setUIApplication(uiApp);
-
+
if (uiApp != null)
+ {
uiApp.processDecode(context);
-
+ }
+
if (!context.isResponseComplete() && !context.getProcessRender())
{
startRequestPhaseLifecycle(app, context, lifecycles, Phase.ACTION);
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStateManager.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStateManager.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStateManager.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -24,6 +24,7 @@
import org.exoplatform.portal.application.replication.ApplicationState;
import org.exoplatform.portal.config.UserPortalConfig;
import org.exoplatform.portal.config.UserPortalConfigService;
+import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.webui.application.ConfigurationManager;
import org.exoplatform.webui.application.StateManager;
import org.exoplatform.webui.application.WebuiApplication;
@@ -34,7 +35,6 @@
import org.gatein.common.logging.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class PortalStateManager extends StateManager
@@ -63,43 +63,23 @@
appState = (ApplicationState)session.getAttribute(APPLICATION_ATTRIBUTE_PREFIX + key);
}
- //
-
- //
UIApplication uiapp = null;
if (appState != null)
{
+ if (log.isDebugEnabled())
+ {
+ log.debug("Found application " + key + " :" + appState.getApplication());
+ }
if (Safe.equals(context.getRemoteUser(), appState.getUserName()))
{
uiapp = appState.getApplication();
}
}
-
- //
- if (appState != null)
- {
- log.debug("Found application " + key + " :" + appState.getApplication());
- }
else
{
log.debug("Application " + key + " not found");
}
- // Looks like some necessary hacking
- if (context instanceof PortalRequestContext)
- {
- PortalRequestContext portalRC = (PortalRequestContext)context;
- UserPortalConfig config = getUserPortalConfig(portalRC);
- if (config == null)
- {
- HttpServletResponse response = portalRC.getResponse();
- response.sendRedirect(portalRC.getRequest().getContextPath() + "/portal-unavailable.jsp");
- portalRC.setResponseComplete(true);
- return null;
- }
- portalRC.setAttribute(UserPortalConfig.class, config);
- }
-
//
if (uiapp == null)
{
@@ -141,15 +121,6 @@
// For now do nothing....
}
- public static UserPortalConfig getUserPortalConfig(PortalRequestContext context) throws Exception
- {
- ExoContainer appContainer = context.getApplication().getApplicationServiceContainer();
- UserPortalConfigService service_ = (UserPortalConfigService)appContainer.getComponentInstanceOfType(UserPortalConfigService.class);
- String remoteUser = context.getRemoteUser();
- String ownerUser = context.getPortalOwner();
- return service_.getUserPortalConfig(ownerUser, remoteUser, PortalRequestContext.USER_PORTAL_CONTEXT);
- }
-
private String getKey(WebuiRequestContext webuiRC)
{
if (webuiRC instanceof PortletRequestContext)
@@ -159,9 +130,7 @@
}
else
{
- PortalRequestContext portalRC = (PortalRequestContext)webuiRC;
- String portalOwner = portalRC.getPortalOwner();
- return "portal_" + portalOwner;
+ return PortalApplication.PORTAL_APPLICATION_ID;
}
}
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStatisticLifecycle.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStatisticLifecycle.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStatisticLifecycle.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -52,9 +52,13 @@
{
PortalStatisticService service =
(PortalStatisticService)PortalContainer.getInstance().getComponentInstanceOfType(PortalStatisticService.class);
- PortalStatistic appStatistic = service.getPortalStatistic(((PortalRequestContext)rcontext).getPortalOwner());
- long startTime = Long.valueOf(app.getAttribute(ATTRIBUTE_NAME).toString());
- appStatistic.logTime(System.currentTimeMillis() - startTime);
+ String portalOwner = ((PortalRequestContext)rcontext).getPortalOwner();
+ if (portalOwner != null)
+ {
+ PortalStatistic appStatistic = service.getPortalStatistic(portalOwner);
+ long startTime = Long.valueOf(app.getAttribute(ATTRIBUTE_NAME).toString());
+ appStatistic.logTime(System.currentTimeMillis() - startTime);
+ }
}
@SuppressWarnings("unused")
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalURLBuilder.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalURLBuilder.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalURLBuilder.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -22,8 +22,9 @@
import org.exoplatform.web.application.Parameter;
import org.exoplatform.web.application.URLBuilder;
import org.exoplatform.webui.core.UIComponent;
+import org.exoplatform.webui.url.ComponentURL;
-import java.net.URLEncoder;
+import java.util.Map;
/**
* Created by The eXo Platform SAS
@@ -32,53 +33,67 @@
public class PortalURLBuilder extends URLBuilder<UIComponent>
{
- public PortalURLBuilder(String baseURL)
+ /** . */
+ private final ComponentURL url;
+
+ public PortalURLBuilder(PortalRequestContext ctx, ComponentURL url)
{
- super(baseURL);
+ String path = ctx.getNodePath();
+ url.setPath(path);
+
+ //
+ this.url = url;
}
- @SuppressWarnings("unused")
- public String createURL(String action, Parameter[] params)
+ @Override
+ public String createAjaxURL(UIComponent targetComponent, String action, String confirm, String targetBeanId, Parameter[] params)
{
- return null;
+ return createURL(true, targetComponent, action, confirm, targetBeanId, params);
}
- @SuppressWarnings("unused")
- public String createURL(String action, String objectId, Parameter[] params)
+ @Override
+ public String createURL(UIComponent targetComponent, String action, String confirm, String targetBeanId, Parameter[] params)
{
- return null;
+ return createURL(false, targetComponent, action, confirm, targetBeanId, params);
}
- protected void createURL(StringBuilder builder, UIComponent targetComponent, String action, String targetBeanId,
- Parameter[] params)
+ private String createURL(boolean ajax, UIComponent targetComponent, String action, String confirm, String targetBeanId, Parameter[] params)
{
- builder.append(getBaseURL()).append("?").append(PortalRequestContext.UI_COMPONENT_ID).append('=').append(
- targetComponent.getId());
- if (action != null && action.trim().length() > 0)
+ Map<String,String[]> queryParameters = url.getQueryParameters();
+ if (queryParameters != null)
{
- builder.append("&").append(PortalRequestContext.UI_COMPONENT_ACTION).append('=').append(action);
+ queryParameters.clear();
}
- if (targetBeanId != null && targetBeanId.trim().length() > 0)
- {
- builder.append("&").append(UIComponent.OBJECTID).append('=').append(targetBeanId);
- }
+ //
+ url.setAjax(ajax);
+ url.setConfirm(confirm);
+ url.setResource(targetComponent);
- if (params == null || params.length < 1)
- return;
- for (Parameter param : params)
+ //
+ url.setAction(action);
+ url.setTargetBeanId(targetBeanId);
+
+ //
+ if (params != null)
{
- try
+ for (Parameter param : params)
{
- param.setValue(URLEncoder.encode(param.getValue(), "utf-8"));
+ url.setQueryParameterValue(param.getName(), param.getValue());
}
- catch (Exception e)
- {
- System.err.println(e.toString());
- }
- builder.append("&").append(param.getName()).append('=').append(param.getValue());
}
+ //
+ if (removeLocale)
+ {
+ url.setLocale(null);
+ }
+ else if (locale != null)
+ {
+ url.setLocale(locale);
+ }
+
+ //
+ return url.toString();
}
-
}
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/UserSiteLifeCycle.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/UserSiteLifeCycle.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/UserSiteLifeCycle.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -21,8 +21,17 @@
import org.exoplatform.container.PortalContainer;
import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.UserPortalConfig;
import org.exoplatform.portal.config.UserPortalConfigService;
+import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.SiteType;
+import org.exoplatform.portal.mop.navigation.Scope;
+import org.exoplatform.portal.mop.user.UserNavigation;
+import org.exoplatform.portal.mop.user.UserNode;
+import org.exoplatform.portal.mop.user.UserNodeFilterConfig;
+import org.exoplatform.portal.mop.user.UserPortal;
import org.exoplatform.web.application.Application;
import org.exoplatform.web.application.ApplicationLifecycle;
import org.exoplatform.web.application.RequestFailure;
@@ -39,6 +48,10 @@
/** . */
private final Logger log = LoggerFactory.getLogger(UserSiteLifeCycle.class);
+ private final static String DEFAULT_TAB_NAME = "Tab_Default";
+
+ private final static String PAGE_TEMPLATE = "dashboard";
+
public void onInit(Application app) throws Exception
{
}
@@ -46,18 +59,47 @@
public void onStartRequest(Application app, PortalRequestContext context) throws Exception
{
String userName = context.getRemoteUser();
- if (userName != null)
+ if (userName != null && SiteType.USER == context.getSiteType() && userName.equals(context.getSiteName()))
{
DataStorage storage = (DataStorage)PortalContainer.getComponent(DataStorage.class);
+ UserPortalConfigService configService = (UserPortalConfigService)PortalContainer.getComponent(UserPortalConfigService.class);
PortalConfig portalConfig = storage.getPortalConfig("user", userName);
//
if (portalConfig == null)
{
log.debug("About to create user site for user " + userName);
- UserPortalConfigService configService = (UserPortalConfigService)PortalContainer.getComponent(UserPortalConfigService.class);
configService.createUserSite(userName);
}
+
+ UserPortalConfig userPortalConfig = context.getUserPortalConfig();
+ UserPortal userPortal = userPortalConfig.getUserPortal();
+ SiteKey siteKey = context.getSiteKey();
+ UserNavigation nav = userPortal.getNavigation(siteKey);
+
+ try
+ {
+ UserNode rootNode = userPortal.getNode(nav, Scope.CHILDREN, UserNodeFilterConfig.builder().build(), null);
+ if (rootNode.getChildren().size() < 1)
+ {
+ //TODO: Retrieve tab name from request
+ Page page = configService.createPageTemplate(PAGE_TEMPLATE, siteKey.getTypeName(), siteKey.getName());
+ page.setName(DEFAULT_TAB_NAME);
+ page.setTitle(DEFAULT_TAB_NAME);
+ storage.save(page);
+
+ UserNode tabNode = rootNode.addChild(DEFAULT_TAB_NAME);
+ tabNode.setLabel(DEFAULT_TAB_NAME);
+ tabNode.setPageRef(page.getPageId());
+
+ userPortal.saveNode(tabNode, null);
+ }
+ }
+ catch (Exception ex)
+ {
+ log.warn("Navigation " + nav.getKey().getName() + " does not exist!", ex);
+ }
+
}
}
Deleted: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/concurrent/PortalConcurrencyMonitorLifecycle.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/concurrent/PortalConcurrencyMonitorLifecycle.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/concurrent/PortalConcurrencyMonitorLifecycle.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.portal.application.concurrent;
-
-import org.exoplatform.portal.application.PortalRequestContext;
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.UserPortalConfig;
-import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.webui.page.UISiteBody;
-import org.exoplatform.portal.webui.portal.PageNodeEvent;
-import org.exoplatform.portal.webui.portal.UIPortal;
-import org.exoplatform.portal.webui.util.PortalDataMapper;
-import org.exoplatform.portal.webui.util.Util;
-import org.exoplatform.portal.webui.workspace.UIEditInlineWorkspace;
-import org.exoplatform.portal.webui.workspace.UIPortalApplication;
-import org.exoplatform.portal.webui.workspace.UIWorkingWorkspace;
-import org.exoplatform.web.application.Application;
-import org.exoplatform.web.application.ApplicationLifecycle;
-import org.exoplatform.web.application.JavascriptManager;
-import org.exoplatform.web.application.RequestFailure;
-import org.exoplatform.webui.event.Event;
-import org.gatein.common.logging.Logger;
-import org.gatein.common.logging.LoggerFactory;
-
-/**
- * @author <a href="mailto:hoang281283@gmail.com">Minh Hoang TO</a>
- * @version $Id$
- *
- */
-public class PortalConcurrencyMonitorLifecycle implements ApplicationLifecycle<PortalRequestContext>
-{
-
- private final Logger log = LoggerFactory.getLogger(PortalConcurrencyMonitorLifecycle.class);
-
- /**
- * @see org.exoplatform.web.application.ApplicationLifecycle#onDestroy(org.exoplatform.web.application.Application)
- */
- public void onDestroy(Application app) throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * @see org.exoplatform.web.application.ApplicationLifecycle#onEndRequest(org.exoplatform.web.application.Application, org.exoplatform.web.application.RequestContext)
- */
- public void onEndRequest(Application app, PortalRequestContext context) throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * @see org.exoplatform.web.application.ApplicationLifecycle#onFailRequest(org.exoplatform.web.application.Application, org.exoplatform.web.application.RequestContext, org.exoplatform.web.application.RequestFailure)
- */
- public void onFailRequest(Application app, PortalRequestContext context, RequestFailure failureType) throws Exception
- {
- if(failureType == RequestFailure.CONCURRENCY_FAILURE)
- {
- //Concurrency-related handling should be put here in the future
- log.error("Error in editing resources concurrently: " + context.getRequestURI().toString());
- }
- }
-
- /**
- * @see org.exoplatform.web.application.ApplicationLifecycle#onInit(org.exoplatform.web.application.Application)
- */
- public void onInit(Application app) throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * @see org.exoplatform.web.application.ApplicationLifecycle#onStartRequest(org.exoplatform.web.application.Application, org.exoplatform.web.application.RequestContext)
- */
- public void onStartRequest(Application app, PortalRequestContext context) throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
-}
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/DefaultLocalePolicyService.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/DefaultLocalePolicyService.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/DefaultLocalePolicyService.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -55,6 +55,12 @@
*/
public Locale determineLocale(LocaleContextInfo context)
{
+ if (context.getRequestLocale() != null)
+ {
+ return context.getRequestLocale();
+ }
+
+ //
Locale locale = null;
if (context.getRemoteUser() == null)
locale = getLocaleConfigForAnonymous(context);
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationLifecycle.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationLifecycle.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationLifecycle.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -24,9 +24,10 @@
import org.exoplatform.container.ExoContainer;
import org.exoplatform.portal.Constants;
import org.exoplatform.portal.application.PortalRequestContext;
-import org.exoplatform.portal.application.PortalStateManager;
import org.exoplatform.portal.application.UserProfileLifecycle;
-import org.exoplatform.portal.config.UserPortalConfig;
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.webui.workspace.UIPortalApplication;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -114,7 +115,7 @@
LocaleContextInfo localeCtx = new LocaleContextInfo();
- Set<Locale> supportedLocales = new HashSet();
+ Set<Locale> supportedLocales = new HashSet<Locale>();
for (LocaleConfig lc: localeConfigService.getLocalConfigs())
{
supportedLocales.add(lc.getLocale());
@@ -128,11 +129,12 @@
localeCtx.setUserProfileLocale(getUserProfileLocale(reqCtx));
localeCtx.setRemoteUser(reqCtx.getRemoteUser());
- UserPortalConfig userPortalConfig = null;
+ DataStorage dataStorage = (DataStorage)container.getComponentInstanceOfType(DataStorage.class);
+ PortalConfig pConfig = null;
try
{
- userPortalConfig = PortalStateManager.getUserPortalConfig(reqCtx);
- if (userPortalConfig == null)
+ pConfig = dataStorage.getPortalConfig(SiteType.PORTAL.getName(), reqCtx.getPortalOwner());
+ if (pConfig == null)
log.warn("No UserPortalConfig available! Portal locale set to 'en'");
}
catch(Exception ignored)
@@ -142,12 +144,14 @@
}
String portalLocaleName = "en";
- if (userPortalConfig != null)
- portalLocaleName = userPortalConfig.getPortalConfig().getLocale();
+ if (pConfig != null)
+ portalLocaleName = pConfig.getLocale();
Locale portalLocale = LocaleContextInfo.getLocale(portalLocaleName);
localeCtx.setPortalLocale(portalLocale);
+ localeCtx.setRequestLocale(reqCtx.getRequestLocale());
+
Locale locale = localePolicy.determineLocale(localeCtx);
boolean supported = supportedLocales.contains(locale);
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/state/PublicPropertiesPlugin.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/state/PublicPropertiesPlugin.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/state/PublicPropertiesPlugin.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -78,7 +78,7 @@
{
try
{
- UIPortal currentSite = Util.getUIPortalApplication().getShowedUIPortal();
+ UIPortal currentSite = Util.getUIPortalApplication().getCurrentSite();
UserNode currentNode = currentSite.getSelectedUserNode();
// Navigation related properties
@@ -92,8 +92,8 @@
}
// Site related properties
- addProperty(properties, siteTypeQName, currentSite.getOwnerType());
- addProperty(properties, siteNameQName, currentSite.getOwner());
+ addProperty(properties, siteTypeQName, currentSite.getSiteType().getName());
+ addProperty(properties, siteNameQName, currentSite.getName());
// Window related properties
addProperty(properties, windowShowInfoBarQName, Boolean.toString(portletWindow.getShowInfoBar()));
Deleted: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURLContext.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURLContext.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURLContext.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,210 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.portal.url;
-
-import org.exoplatform.commons.utils.I18N;
-import org.exoplatform.portal.application.PortalRequestHandler;
-import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.web.ControllerContext;
-import org.exoplatform.web.WebAppController;
-import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.controller.router.URIWriter;
-import org.exoplatform.web.url.PortalURL;
-import org.exoplatform.web.url.URLContext;
-import org.gatein.common.io.UndeclaredIOException;
-
-import javax.servlet.http.HttpServletRequest;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- */
-public class PortalURLContext implements URLContext
-{
-
- /** . */
- private final ControllerContext controllerContext;
-
- /** . */
- private final SiteKey siteKey;
-
- /** . */
- private URIWriter writer;
-
- /** . */
- private StringBuilder buffer;
-
- public PortalURLContext(
- ControllerContext controllerContext,
- SiteKey siteKey)
- {
- if (controllerContext == null)
- {
- throw new NullPointerException("No null controller context");
- }
-
- //
- this.controllerContext = controllerContext;
- this.siteKey = siteKey;
- this.writer = null;
- this.buffer = null;
- }
-
- public <R, U extends PortalURL<R, U>> String render(U url)
- {
- try
- {
- return _render(url);
- }
- catch (IOException e)
- {
- throw new UndeclaredIOException(e);
- }
- }
-
- private <R, U extends PortalURL<R, U>> String _render(U url) throws IOException
- {
- if (url.getResource() == null)
- {
- throw new IllegalStateException("No resource set on portal URL");
- }
-
- //
- if (writer == null)
- {
- writer = new URIWriter(buffer = new StringBuilder());
- }
- else
- {
- buffer.setLength(0);
- writer.reset(buffer);
- }
-
- //
- HttpServletRequest req = controllerContext.getRequest();
- if (url.getSchemeUse())
- {
- buffer.append(req.getScheme());
- buffer.append("://");
- }
- if (url.getAuthorityUse())
- {
- buffer.append(req.getServerName());
- int port = req.getServerPort();
- if (port != 80)
- {
- buffer.append(':').append(port);
- }
- }
-
- //
- writer.setMimeType(url.getMimeType());
-
- //
- String confirm = url.getConfirm();
- boolean hasConfirm = confirm != null && confirm.length() > 0;
-
- //
- boolean ajax = url.getAjax() != null && url.getAjax();
- if (ajax)
- {
- writer.append("javascript:");
- if (hasConfirm)
- {
- writer.append("if(confirm('");
- writer.append(confirm.replaceAll("'", "\\\\'"));
- writer.append("'))");
- }
- writer.append("ajaxGet('");
- }
- else
- {
- if (hasConfirm)
- {
- writer.append("javascript:");
- writer.append("if(confirm('");
- writer.append(confirm.replaceAll("'", "\\\\'"));
- writer.append("'))");
- writer.append("window.location=\'");
- }
- }
-
- //
- Map<QualifiedName, String> parameters = new HashMap<QualifiedName, String>();
- parameters.put(WebAppController.HANDLER_PARAM, "portal");
- parameters.put(PortalRequestHandler.REQUEST_SITE_TYPE, siteKey.getTypeName());
- parameters.put(PortalRequestHandler.REQUEST_SITE_NAME, siteKey.getName());
-
- //
- String lang = "";
- Locale locale = url.getLocale();
- if (locale != null && locale.getLanguage().length() > 0)
- {
- lang = I18N.toTagIdentifier(locale);
- }
- parameters.put(PortalRequestHandler.LANG, lang);
-
- //
- for (QualifiedName parameterName : url.getParameterNames())
- {
- String parameterValue = url.getParameterValue(parameterName);
- if (parameterValue != null)
- {
- parameters.put(parameterName, parameterValue);
- }
- }
-
- // Render url via controller
- controllerContext.renderURL(parameters, writer);
-
- // Now append generic query parameters
- Map<String, String[]> queryParameters = url.getQueryParameters();
- if (queryParameters != null)
- {
- for (Map.Entry<String, String[]> entry : queryParameters.entrySet())
- {
- for (String value : entry.getValue())
- {
- writer.appendQueryParameter(entry.getKey(), value);
- }
- }
- }
-
- //
- if (ajax)
- {
- writer.appendQueryParameter("ajaxRequest", "true");
- writer.append("')");
- }
- else
- {
- if (hasConfirm)
- {
- writer.append("\'");
- }
- }
-
- //
- return buffer.toString();
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURLContext.java (from rev 7117, portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURLContext.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURLContext.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURLContext.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,210 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.url;
+
+import org.exoplatform.commons.utils.I18N;
+import org.exoplatform.portal.application.PortalRequestHandler;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.web.ControllerContext;
+import org.exoplatform.web.WebAppController;
+import org.exoplatform.web.controller.QualifiedName;
+import org.exoplatform.web.controller.router.URIWriter;
+import org.exoplatform.web.url.PortalURL;
+import org.exoplatform.web.url.URLContext;
+import org.gatein.common.io.UndeclaredIOException;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public class PortalURLContext implements URLContext
+{
+
+ /** . */
+ private final ControllerContext controllerContext;
+
+ /** . */
+ private final SiteKey siteKey;
+
+ /** . */
+ private URIWriter writer;
+
+ /** . */
+ private StringBuilder buffer;
+
+ public PortalURLContext(
+ ControllerContext controllerContext,
+ SiteKey siteKey)
+ {
+ if (controllerContext == null)
+ {
+ throw new NullPointerException("No null controller context");
+ }
+
+ //
+ this.controllerContext = controllerContext;
+ this.siteKey = siteKey;
+ this.writer = null;
+ this.buffer = null;
+ }
+
+ public <R, U extends PortalURL<R, U>> String render(U url)
+ {
+ try
+ {
+ return _render(url);
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+
+ private <R, U extends PortalURL<R, U>> String _render(U url) throws IOException
+ {
+ if (url.getResource() == null)
+ {
+ throw new IllegalStateException("No resource set on portal URL");
+ }
+
+ //
+ if (writer == null)
+ {
+ writer = new URIWriter(buffer = new StringBuilder());
+ }
+ else
+ {
+ buffer.setLength(0);
+ writer.reset(buffer);
+ }
+
+ //
+ HttpServletRequest req = controllerContext.getRequest();
+ if (url.getSchemeUse())
+ {
+ buffer.append(req.getScheme());
+ buffer.append("://");
+ }
+ if (url.getAuthorityUse())
+ {
+ buffer.append(req.getServerName());
+ int port = req.getServerPort();
+ if (port != 80)
+ {
+ buffer.append(':').append(port);
+ }
+ }
+
+ //
+ writer.setMimeType(url.getMimeType());
+
+ //
+ String confirm = url.getConfirm();
+ boolean hasConfirm = confirm != null && confirm.length() > 0;
+
+ //
+ boolean ajax = url.getAjax() != null && url.getAjax();
+ if (ajax)
+ {
+ writer.append("javascript:");
+ if (hasConfirm)
+ {
+ writer.append("if(confirm('");
+ writer.append(confirm.replaceAll("'", "\\\\'"));
+ writer.append("'))");
+ }
+ writer.append("ajaxGet('");
+ }
+ else
+ {
+ if (hasConfirm)
+ {
+ writer.append("javascript:");
+ writer.append("if(confirm('");
+ writer.append(confirm.replaceAll("'", "\\\\'"));
+ writer.append("'))");
+ writer.append("window.location=\'");
+ }
+ }
+
+ //
+ Map<QualifiedName, String> parameters = new HashMap<QualifiedName, String>();
+ parameters.put(WebAppController.HANDLER_PARAM, "portal");
+ parameters.put(PortalRequestHandler.REQUEST_SITE_TYPE, siteKey.getTypeName());
+ parameters.put(PortalRequestHandler.REQUEST_SITE_NAME, siteKey.getName());
+
+ //
+ String lang = "";
+ Locale locale = url.getLocale();
+ if (locale != null && locale.getLanguage().length() > 0)
+ {
+ lang = I18N.toTagIdentifier(locale);
+ }
+ parameters.put(PortalRequestHandler.LANG, lang);
+
+ //
+ for (QualifiedName parameterName : url.getParameterNames())
+ {
+ String parameterValue = url.getParameterValue(parameterName);
+ if (parameterValue != null)
+ {
+ parameters.put(parameterName, parameterValue);
+ }
+ }
+
+ // Render url via controller
+ controllerContext.renderURL(parameters, writer);
+
+ // Now append generic query parameters
+ Map<String, String[]> queryParameters = url.getQueryParameters();
+ if (queryParameters != null)
+ {
+ for (Map.Entry<String, String[]> entry : queryParameters.entrySet())
+ {
+ for (String value : entry.getValue())
+ {
+ writer.appendQueryParameter(entry.getKey(), value);
+ }
+ }
+ }
+
+ //
+ if (ajax)
+ {
+ writer.appendQueryParameter("ajaxRequest", "true");
+ writer.append("')");
+ }
+ else
+ {
+ if (hasConfirm)
+ {
+ writer.append("\'");
+ }
+ }
+
+ //
+ return buffer.toString();
+ }
+}
Deleted: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/url/component/ComponentURLFactoryPlugin.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/url/component/ComponentURLFactoryPlugin.java 2011-08-14 18:06:46 UTC (rev 7117)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/url/component/ComponentURLFactoryPlugin.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.portal.url.component;
-
-import org.exoplatform.web.url.URLFactoryPlugin;
-import org.exoplatform.web.url.ResourceType;
-import org.exoplatform.web.url.URLContext;
-import org.exoplatform.webui.core.UIComponent;
-import org.exoplatform.webui.url.ComponentURL;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class ComponentURLFactoryPlugin extends URLFactoryPlugin<UIComponent, ComponentURL>
-{
-
- @Override
- protected ResourceType<UIComponent, ComponentURL> getResourceType()
- {
- return ComponentURL.TYPE;
- }
-
- @Override
- protected ComponentURL newURL(URLContext context)
- {
- return new ComponentURL(context);
- }
-}
Copied: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/url/component/ComponentURLFactoryPlugin.java (from rev 7117, portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/url/component/ComponentURLFactoryPlugin.java)
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/url/component/ComponentURLFactoryPlugin.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/url/component/ComponentURLFactoryPlugin.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.url.component;
+
+import org.exoplatform.web.url.URLFactoryPlugin;
+import org.exoplatform.web.url.ResourceType;
+import org.exoplatform.web.url.URLContext;
+import org.exoplatform.webui.core.UIComponent;
+import org.exoplatform.webui.url.ComponentURL;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ComponentURLFactoryPlugin extends URLFactoryPlugin<UIComponent, ComponentURL>
+{
+
+ @Override
+ protected ResourceType<UIComponent, ComponentURL> getResourceType()
+ {
+ return ComponentURL.TYPE;
+ }
+
+ @Override
+ protected ComponentURL newURL(URLContext context)
+ {
+ return new ComponentURL(context);
+ }
+}
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -20,7 +20,13 @@
package org.exoplatform.portal.webui.application;
import org.exoplatform.Constants;
+import org.exoplatform.commons.utils.I18N;
import org.exoplatform.portal.application.PortalRequestContext;
+import org.exoplatform.web.url.PortalURL;
+import org.exoplatform.webui.core.UIComponent;
+import org.exoplatform.webui.url.ComponentURL;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
import org.gatein.common.net.media.MediaType;
import org.gatein.common.util.MarkupInfo;
import org.gatein.common.util.ParameterValidation;
@@ -35,9 +41,11 @@
import org.gatein.pc.api.cache.CacheLevel;
import org.gatein.pc.portlet.impl.spi.AbstractPortletInvocationContext;
+import java.util.Locale;
+import java.util.Map;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.util.Map;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
@@ -46,30 +54,35 @@
class ExoPortletInvocationContext extends AbstractPortletInvocationContext
{
- private HttpServletResponse response;
+ static final String INTERACTION_STATE_PARAM_NAME = "interactionstate";
+ static final String NAVIGATIONAL_STATE_PARAM_NAME = "navigationalstate";
+ static final String RESOURCE_STATE_PARAM_NAME = "resourcestate";
- private HttpServletRequest request;
+ /** . */
+ private static final Logger log = LoggerFactory.getLogger(ExoPortletInvocationContext.class);
- private String portalRequestURI;
+ /** . */
+ private final HttpServletResponse response;
- private String portletId;
+ /** . */
+ private final HttpServletRequest request;
- static final String INTERACTION_STATE_PARAM_NAME = "interactionstate";
- static final String NAVIGATIONAL_STATE_PARAM_NAME = "navigationalstate";
- static final String RESOURCE_STATE_PARAM_NAME = "resourcestate";
- private static final String QMARK = "?";
- private static final String EQ = "=";
- private static final String AMP = "&";
- private static final String XMLAMP = "&";
+ /** . */
+ private final PortalURL<UIComponent, ComponentURL> url;
public ExoPortletInvocationContext(PortalRequestContext portalRequestContext, UIPortlet portlet)
{
super(new MarkupInfo(MediaType.TEXT_HTML, "UTF-8"));
+ //
+ ComponentURL url = portalRequestContext.createURL(ComponentURL.TYPE, portlet);
+ String path = portalRequestContext.getNodePath();
+ url.setPath(path);
+
+ //
this.request = portalRequestContext.getRequest();
this.response = portalRequestContext.getResponse();
- this.portalRequestURI = portalRequestContext.getRequestURI();
- this.portletId = portlet.getId();
+ this.url = url;
}
@Override
@@ -96,16 +109,19 @@
public String renderURL(ContainerURL containerURL, URLFormat format)
{
- boolean wantEscapeXML = false;
- if (format != null && format.getWantEscapeXML() != null)
+/*
+ // todo: shouldn't we be using URLFormat to decide on the path to use at the beginning of the URL?
+ StringBuilder baseURL = new StringBuilder(this.portalRequestURI).append("?")
+ .append(PortalRequestContext.UI_COMPONENT_ID).append("=").append(this.portletId);
+*/
+
+ //Clear URL parameters
+ Map<String, String[]> queryParameters = url.getQueryParameters();
+ if (queryParameters != null)
{
- wantEscapeXML = format.getWantEscapeXML();
+ queryParameters.clear();
}
- // todo: shouldn't we be using URLFormat to decide on the path to use at the beginning of the URL?
- StringBuilder baseURL = new StringBuilder(this.portalRequestURI).append(QMARK)
- .append(PortalRequestContext.UI_COMPONENT_ID).append(EQ).append(this.portletId);
-
String type;
if (containerURL instanceof RenderURL)
{
@@ -126,32 +142,14 @@
if (!type.equals(Constants.PORTAL_RENDER))
{
- appendParameter(baseURL, Constants.TYPE_PARAMETER, type, wantEscapeXML);
+ url.setQueryParameterValue(Constants.TYPE_PARAMETER, type);
}
if (format != null && format.getWantSecure() != null)
{
- appendParameter(baseURL, Constants.SECURE_PARAMETER, format.getWantSecure().toString(), wantEscapeXML);
+ url.setQueryParameterValue(Constants.SECURE_PARAMETER, format.getWantSecure().toString());
}
- StateString navigationalState = containerURL.getNavigationalState();
- if (navigationalState != null && !navigationalState.getStringValue().equals(StateString.JBPNS_PREFIX))
- {
- appendParameter(baseURL, NAVIGATIONAL_STATE_PARAM_NAME, navigationalState.getStringValue(), wantEscapeXML);
- }
-
- WindowState windowState = containerURL.getWindowState();
- if (windowState != null)
- {
- appendParameter(baseURL, Constants.WINDOW_STATE_PARAMETER, windowState.toString(), wantEscapeXML);
- }
-
- Mode mode = containerURL.getMode();
- if (mode != null)
- {
- appendParameter(baseURL, Constants.PORTLET_MODE_PARAMETER, mode.toString(), wantEscapeXML);
- }
-
if (containerURL instanceof ActionURL)
{
ActionURL actionURL = (ActionURL)containerURL;
@@ -159,31 +157,79 @@
StateString state = actionURL.getInteractionState();
if (state != null && !state.getStringValue().equals(StateString.JBPNS_PREFIX))
{
- appendParameter(baseURL, INTERACTION_STATE_PARAM_NAME, state.getStringValue(), wantEscapeXML);
+ url.setQueryParameterValue(INTERACTION_STATE_PARAM_NAME, state.getStringValue());
}
+
+ state = actionURL.getNavigationalState();
+ if (state != null && !state.getStringValue().equals(StateString.JBPNS_PREFIX))
+ {
+ url.setQueryParameterValue(NAVIGATIONAL_STATE_PARAM_NAME, state.getStringValue());
+ }
+
+ WindowState windowState = actionURL.getWindowState();
+ if (windowState != null)
+ {
+ url.setQueryParameterValue(Constants.WINDOW_STATE_PARAMETER, windowState.toString());
+ }
+
+ Mode mode = actionURL.getMode();
+ if (mode != null)
+ {
+ url.setQueryParameterValue(Constants.PORTLET_MODE_PARAMETER, mode.toString());
+ }
}
else if (containerURL instanceof ResourceURL)
{
ResourceURL resourceURL = (ResourceURL)containerURL;
- appendParameter(baseURL, Constants.RESOURCE_ID_PARAMETER, resourceURL.getResourceId(), wantEscapeXML);
+ url.setQueryParameterValue(Constants.RESOURCE_ID_PARAMETER, resourceURL.getResourceId());
CacheLevel cachability = resourceURL.getCacheability();
if (cachability != null)
{
- appendParameter(baseURL, Constants.CACHELEVEL_PARAMETER, cachability.name(), wantEscapeXML);
+ url.setQueryParameterValue(Constants.CACHELEVEL_PARAMETER, cachability.name());
}
StateString resourceState = resourceURL.getResourceState();
if (resourceState != null && !resourceState.getStringValue().equals(StateString.JBPNS_PREFIX))
{
- appendParameter(baseURL, RESOURCE_STATE_PARAM_NAME, resourceState.getStringValue(), wantEscapeXML);
+ url.setQueryParameterValue(RESOURCE_STATE_PARAM_NAME, resourceState.getStringValue());
}
+
+ resourceState = resourceURL.getNavigationalState();
+ if (resourceState != null && !resourceState.getStringValue().equals(StateString.JBPNS_PREFIX))
+ {
+ url.setQueryParameterValue(NAVIGATIONAL_STATE_PARAM_NAME, resourceState.getStringValue());
+ }
+
+ WindowState windowState = resourceURL.getWindowState();
+ if (windowState != null)
+ {
+ url.setQueryParameterValue(Constants.WINDOW_STATE_PARAMETER, windowState.toString());
+ }
+
+ Mode mode = resourceURL.getMode();
+ if (mode != null)
+ {
+ url.setQueryParameterValue(Constants.PORTLET_MODE_PARAMETER, mode.toString());
+ }
}
else
{
RenderURL renderURL = (RenderURL)containerURL;
+ WindowState windowState = renderURL.getWindowState();
+ if (windowState != null)//&& !windowState.equals(WindowState.NORMAL))
+ {
+ url.setQueryParameterValue(Constants.WINDOW_STATE_PARAMETER, windowState.toString());
+ }
+
+ Mode mode = renderURL.getMode();
+ if (mode != null)
+ {
+ url.setQueryParameterValue(Constants.PORTLET_MODE_PARAMETER, mode.toString());
+ }
+
Map<String, String[]> publicNSChanges = renderURL.getPublicNavigationalStateChanges();
if (ParameterValidation.existsAndIsNotEmpty(publicNSChanges))
{
@@ -194,32 +240,53 @@
{
for (String value : values)
{
- appendParameter(baseURL, key, value, wantEscapeXML);
+ url.setQueryParameterValue(key, value);
}
}
else
{
- appendParameter(baseURL, "removePP", key, wantEscapeXML);
+ url.setQueryParameterValue("removePP", key);
}
}
}
+
+ StateString state = renderURL.getNavigationalState();
+ if (state != null && !state.getStringValue().equals(StateString.JBPNS_PREFIX))
+ {
+ url.setQueryParameterValue(NAVIGATIONAL_STATE_PARAM_NAME, state.getStringValue());
+ }
}
- return baseURL.toString();
- }
-
- private void appendParameter(StringBuilder builder, String name, String value, boolean wantEscapeXML)
- {
- if (value != null)
+ //
+ Map<String, String> props = containerURL.getProperties();
+ String lang = props.get("gtn:lang");
+ if (lang != null)
{
- if (wantEscapeXML)
+ if (lang.length() == 0)
{
- builder.append(XMLAMP).append(name).append(EQ).append(value);
+ url.setLocale(null);
}
else
{
- builder.append(AMP).append(name).append(EQ).append(value);
+ try
+ {
+ Locale locale = I18N.parseJavaIdentifier(lang);
+ url.setLocale(locale);
+ }
+ catch (IllegalArgumentException e)
+ {
+ log.debug("Unparsable locale string: " + lang, e);
+ }
}
}
+
+ // Ajax support
+ url.setAjax("true".equals(props.get("gtn:ajax")));
+
+ // Confirm messsage
+ url.setConfirm(props.get("gtn:confirm"));
+
+ //
+ return url.toString();
}
}
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -259,7 +259,7 @@
if ("title".equals(element.getNodeName().toLowerCase())
&& element.getFirstChild() != null)
{
- String title = element.getFirstChild().getTextContent();
+ String title = element.getFirstChild().getNodeValue();
prcontext.getRequest().setAttribute(PortalRequestContext.REQUEST_TITLE, title);
}
else
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -36,6 +36,7 @@
import org.exoplatform.portal.webui.portal.PageNodeEvent;
import org.exoplatform.portal.webui.portal.UIPortal;
import org.exoplatform.portal.webui.util.Util;
+import org.exoplatform.portal.webui.workspace.UIPortalApplication;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.webui.application.WebuiRequestContext;
@@ -68,7 +69,7 @@
public UIPortalNavigation()
{
UserNodeFilterConfig.Builder filterConfigBuilder = UserNodeFilterConfig.builder();
- filterConfigBuilder.withAuthorizationCheck().withVisibility(Visibility.DISPLAYED, Visibility.TEMPORAL);
+ filterConfigBuilder.withReadWriteCheck().withVisibility(Visibility.DISPLAYED, Visibility.TEMPORAL);
filterConfigBuilder.withTemporalCheck();
NAVIGATION_FILTER_CONFIG = filterConfigBuilder.build();
}
@@ -162,7 +163,7 @@
List<UserNode> childNodes = new LinkedList<UserNode>();
for (UserNavigation nav : rearrangeNavigations(listNavigations))
{
- if (!showUserNavigation && nav.getKey().getTypeName().equals(PortalConfig.USER_TYPE))
+ if (!showUserNavigation && nav.getKey().getType().equals(SiteType.USER))
{
continue;
}
@@ -260,19 +261,19 @@
for (UserNavigation nav : listNavigation)
{
- String ownerType = nav.getKey().getTypeName();
- if (PortalConfig.PORTAL_TYPE.equals(ownerType))
+ SiteType siteType = nav.getKey().getType();
+ switch (siteType)
{
- portalNavs.add(nav);
+ case PORTAL:
+ portalNavs.add(nav);
+ break;
+ case GROUP:
+ groupNavs.add(nav);
+ break;
+ case USER:
+ userNavs.add(nav);
+ break;
}
- else if (PortalConfig.GROUP_TYPE.equals(ownerType))
- {
- groupNavs.add(nav);
- }
- else if (PortalConfig.USER_TYPE.equals(ownerType))
- {
- userNavs.add(nav);
- }
}
returnNavs.addAll(portalNavs);
@@ -317,28 +318,7 @@
{
this.navigationScope = scope;
}
-
- static public class SelectNodeActionListener extends EventListener<UIPortalNavigation>
- {
- public void execute(Event<UIPortalNavigation> event) throws Exception
- {
- UIPortal uiPortal = Util.getUIPortal();
- String treePath = event.getRequestContext().getRequestParameter(OBJECTID);
- TreeNode selectedNode = event.getSource().getTreeNodes().findNodes(treePath);
- //There're may be interuption between browser and server
- if (selectedNode == null)
- {
- event.getRequestContext().addUIComponentToUpdateByAjax(event.getSource());
- return;
- }
-
- PageNodeEvent<UIPortal> pnevent;
- pnevent = new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, selectedNode.getNode().getURI());
- uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
- }
- }
-
//Now we use serveSource method to expand a node
/*
static public class ExpandNodeActionListener extends EventListener<UIPortalNavigation>
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPage.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPage.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPage.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -22,6 +22,7 @@
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.mop.SiteKey;
import org.exoplatform.portal.webui.application.UIPortlet;
import org.exoplatform.portal.webui.container.UIContainer;
import org.exoplatform.portal.webui.portal.UIPortalComponentActionListener.MoveChildActionListener;
@@ -49,10 +50,8 @@
/** . */
private String pageId;
- private String ownerId;
+ private SiteKey siteKey;
- private String ownerType;
-
private String editPermission;
private boolean showMaxWindow = false;
@@ -61,15 +60,37 @@
public static String DEFAULT_FACTORY_ID = "Default";
- public String getOwnerId()
+ public SiteKey getSiteKey()
{
- return ownerId;
+ return siteKey;
}
+
+ public void setSiteKey(SiteKey key)
+ {
+ siteKey = key;
+ }
- public void setOwnerId(String s)
+ /**
+ * @deprecated use {@link #getSiteKey()} instead
+ *
+ * @return
+ */
+ @Deprecated
+ public String getOwnerType()
{
- ownerId = s;
+ return getSiteKey().getTypeName();
}
+
+ /**
+ * @deprecated use {@link #getSiteKey()} instead
+ *
+ * @return
+ */
+ @Deprecated
+ public String getOwnerId()
+ {
+ return getSiteKey().getName();
+ }
public boolean isShowMaxWindow()
{
@@ -106,16 +127,6 @@
return maximizedUIPortlet;
}
- public String getOwnerType()
- {
- return ownerType;
- }
-
- public void setOwnerType(String ownerType)
- {
- this.ownerType = ownerType;
- }
-
public void setMaximizedUIPortlet(UIPortlet maximizedUIPortlet)
{
this.maximizedUIPortlet = maximizedUIPortlet;
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -27,7 +27,7 @@
import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.mop.Visibility;
+import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.mop.user.UserNavigation;
import org.exoplatform.portal.mop.user.UserNode;
import org.exoplatform.portal.mop.user.UserNodeFilterConfig;
@@ -36,7 +36,6 @@
import org.exoplatform.portal.webui.portal.PageNodeEvent;
import org.exoplatform.portal.webui.portal.UIPortal;
import org.exoplatform.portal.webui.util.PortalDataMapper;
-import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.portal.webui.workspace.UIPortalApplication;
import org.exoplatform.portal.webui.workspace.UIWorkingWorkspace;
import org.exoplatform.web.application.ApplicationMessage;
@@ -49,34 +48,86 @@
import java.util.List;
/**
- * Created by The eXo Platform SAS Author : Tran The Trong trongtt(a)gmail.com Jun
- * 14, 2006
+ * Just a class that contains the Page related action listeners
+ *
+ * @author <a href="mailto:trongtt@gmail.com">Tran The Trong</a>
+ * @version $Revision$
*/
public class UIPageActionListener
{
- static public class ChangePageNodeActionListener extends EventListener<UIPortal>
+ static public class ChangeNodeActionListener extends EventListener<UIPortalApplication>
{
- public void execute(Event<UIPortal> event) throws Exception
+ public void execute(Event<UIPortalApplication> event) throws Exception
{
- UIPortal showedUIPortal = event.getSource();
- UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
-
+ UIPortalApplication uiPortalApp = event.getSource();
UserPortal userPortal = uiPortalApp.getUserPortalConfig().getUserPortal();
-
- String uri = ((PageNodeEvent<UIPortal>)event).getTargetNodeUri();
+ UIPortal showedUIPortal = uiPortalApp.getCurrentSite();
+ PortalRequestContext pcontext = PortalRequestContext.getCurrentInstance();
+
UserNodeFilterConfig.Builder builder = UserNodeFilterConfig.builder();
- builder.withAuthorizationCheck();
- UserNode naviPath = userPortal.resolvePath(builder.build(), uri);
- UserNavigation targetNav = naviPath.getNavigation();
+ builder.withReadCheck();
+
+ PageNodeEvent<UIPortalApplication> pageNodeEvent = (PageNodeEvent<UIPortalApplication>)event;
+ String nodePath = pageNodeEvent.getTargetNodeUri();
+
+ UserNode targetNode = null;
+ SiteKey siteKey = pageNodeEvent.getSiteKey();
+ if (siteKey != null)
+ {
+ UserNavigation navigation = userPortal.getNavigation(siteKey);
+ if (navigation != null)
+ {
+ targetNode = userPortal.resolvePath(navigation, builder.build(), nodePath);
+ if (targetNode == null)
+ {
+ // If unauthenticated users have no permission on PORTAL node and URL is valid, they will be required to login
+ if (pcontext.getRemoteUser() == null && siteKey.getType().equals(SiteType.PORTAL))
+ {
+ targetNode = userPortal.resolvePath(navigation, builder.withAuthMode(UserNodeFilterConfig.AUTH_NO_CHECK).build(), nodePath);
+ if (targetNode != null)
+ {
+ uiPortalApp.setLastRequestURI(null);
+ String doLoginPath = pcontext.getRequest().getContextPath() + "/dologin?initialURI=" + pcontext.getRequestURI();
+ pcontext.sendRedirect(doLoginPath);
+ return;
+ }
+ }
+ else
+ {
+ // If path to node is invalid, get the default node instead of.
+ targetNode = userPortal.getDefaultPath(navigation, builder.build());
+ }
+ }
+ }
+ }
- UserNode currentNavPath = showedUIPortal.getNavPath();
+ if (targetNode == null)
+ {
+ targetNode = userPortal.getDefaultPath(builder.build());
+ if (targetNode == null)
+ {
+ if (showedUIPortal != null)
+ {
+ UIPageBody uiPageBody = showedUIPortal.findFirstComponentOfType(UIPageBody.class);
+ uiPageBody.setUIComponent(null);
+ }
+ return;
+ }
+ }
+
+ UserNavigation targetNav = targetNode.getNavigation();
+ UserNode currentNavPath = null;
+ if (showedUIPortal != null)
+ {
+ currentNavPath = showedUIPortal.getNavPath();
+ }
- if(currentNavPath != null && currentNavPath.getNavigation().getKey().equals(targetNav.getKey()))
+ if (currentNavPath != null && currentNavPath.getNavigation().getKey().equals(targetNav.getKey()))
{
- //Case 1: Both navigation type and id are not changed, but current page node is changed
- if(!currentNavPath.getURI().equals(naviPath.getURI()))
+ //Case 1: Both navigation type and id are not changed, but current page node is changed and it is not a first request.
+ if (!currentNavPath.getURI().equals(targetNode.getURI()))
{
- showedUIPortal.setNavPath(naviPath);
+ showedUIPortal.setNavPath(targetNode);
}
}
else
@@ -89,16 +140,15 @@
showedUIPortal = uiPortalApp.getCachedUIPortal(targetNav.getKey());
if (showedUIPortal != null)
{
- showedUIPortal.setNavPath(naviPath);
- uiPortalApp.setShowedUIPortal(showedUIPortal);
+ showedUIPortal.setNavPath(targetNode);
+ uiPortalApp.setCurrentSite(showedUIPortal);
- //Temporary solution to fix edit inline error while switching between navigations
DataStorage storageService = uiPortalApp.getApplicationComponent(DataStorage.class);
PortalConfig associatedPortalConfig = storageService.getPortalConfig(targetNav.getKey().getTypeName(), targetNav.getKey().getName());
UserPortalConfig userPortalConfig = uiPortalApp.getUserPortalConfig();
//Update layout-related data on UserPortalConfig
- userPortalConfig.setPortal(associatedPortalConfig);
+ userPortalConfig.setPortalConfig(associatedPortalConfig);
}
else
{
@@ -107,35 +157,36 @@
{
return;
}
- showedUIPortal.setNavPath(naviPath);
- uiPortalApp.setShowedUIPortal(showedUIPortal);
+ showedUIPortal.setNavPath(targetNode);
+ uiPortalApp.setCurrentSite(showedUIPortal);
uiPortalApp.putCachedUIPortal(showedUIPortal);
}
}
showedUIPortal.refreshUIPage();
+ pcontext.setFullRender(true);
+ pcontext.addUIComponentToUpdateByAjax(uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID));
}
- private UIPortal buildUIPortal(SiteKey newPageNav, UIPortalApplication uiPortalApp, UserPortalConfig userPortalConfig) throws Exception
+ private UIPortal buildUIPortal(SiteKey siteKey, UIPortalApplication uiPortalApp, UserPortalConfig userPortalConfig) throws Exception
{
DataStorage storage = uiPortalApp.getApplicationComponent(DataStorage.class);
if(storage == null){
return null;
}
- PortalConfig portalConfig = storage.getPortalConfig(newPageNav.getTypeName(), newPageNav.getName());
+ PortalConfig portalConfig = storage.getPortalConfig(siteKey.getTypeName(), siteKey.getName());
Container layout = portalConfig.getPortalLayout();
if(layout != null)
{
- userPortalConfig.setPortal(portalConfig);
+ userPortalConfig.setPortalConfig(portalConfig);
}
UIPortal uiPortal = uiPortalApp.createUIComponent(UIPortal.class, null, null);
//Reset selected navigation on userPortalConfig
- PortalDataMapper.toUIPortal(uiPortal, userPortalConfig);
+ PortalDataMapper.toUIPortal(uiPortal, userPortalConfig.getPortalConfig());
return uiPortal;
}
}
-
static public class DeleteGadgetActionListener extends EventListener<UIPage>
{
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -32,11 +32,13 @@
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.config.Query;
+import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.config.UserPortalConfigService;
import org.exoplatform.portal.config.model.ModelObject;
import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.mop.navigation.Scope;
import org.exoplatform.portal.mop.user.UserNavigation;
import org.exoplatform.portal.mop.user.UserNode;
@@ -60,7 +62,6 @@
import org.exoplatform.webui.core.UIContainer;
import org.exoplatform.webui.core.UIPopupWindow;
import org.exoplatform.webui.core.UIRepeater;
-import org.exoplatform.webui.core.UISearch;
import org.exoplatform.webui.core.UIVirtualList;
import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
import org.exoplatform.webui.core.model.SelectItemOption;
@@ -70,11 +71,16 @@
import org.exoplatform.webui.form.UIForm;
import org.exoplatform.webui.form.UIFormInputItemSelector;
import org.exoplatform.webui.form.UIFormInputSet;
-import org.exoplatform.webui.form.UIFormRadioBoxInput;
import org.exoplatform.webui.form.UIFormSelectBox;
import org.exoplatform.webui.form.UIFormStringInput;
-import org.exoplatform.webui.form.UISearchForm;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ResourceBundle;
+
+import javax.portlet.ActionResponse;
+import javax.xml.namespace.QName;
+
@ComponentConfigs({
@ComponentConfig(template = "system:/groovy/portal/webui/page/UIPageBrowser.gtmpl", events = {
@EventConfig(listeners = UIPageBrowser.DeleteActionListener.class, confirm = "UIPageBrowse.deletePage"),
@@ -252,32 +258,32 @@
public void execute(Event<UIPageBrowser> event) throws Exception
{
UIPageBrowser uiPageBrowser = event.getSource();
- PortalRequestContext pcontext = Util.getPortalRequestContext();
- String id = pcontext.getRequestParameter(OBJECTID);
+ WebuiRequestContext context = event.getRequestContext();
+ String id = context.getRequestParameter(OBJECTID);
UserPortalConfigService service = uiPageBrowser.getApplicationComponent(UserPortalConfigService.class);
DataStorage dataService = uiPageBrowser.getApplicationComponent(DataStorage.class);
- UIPortalApplication uiPortalApp = (UIPortalApplication)pcontext.getUIApplication();
+ UIApplication uiApp = context.getUIApplication();
if (service.getPage(id) == null)
{
- uiPortalApp.addMessage(new ApplicationMessage("UIPageBrowser.msg.PageNotExist", new String[]{id}, 1));
- pcontext.addUIComponentToUpdateByAjax(uiPortalApp.getUIPopupMessages());
+ uiApp.addMessage(new ApplicationMessage("UIPageBrowser.msg.PageNotExist", new String[]{id}, 1));
+ context.addUIComponentToUpdateByAjax(uiApp.getUIPopupMessages());
return;
}
- Page page = service.getPage(id, pcontext.getRemoteUser());
+ Page page = service.getPage(id, context.getRemoteUser());
if (page == null || !page.isModifiable() ||
- (page.getOwnerType().equals(PortalConfig.USER_TYPE) && !page.getOwnerId().equals(pcontext.getRemoteUser())))
+ (page.getOwnerType().equals(SiteType.USER.getName()) && !page.getOwnerId().equals(context.getRemoteUser())))
{
- uiPortalApp.addMessage(new ApplicationMessage("UIPageBrowser.msg.delete.NotDelete", new String[]{id}, 1));
- pcontext.addUIComponentToUpdateByAjax(uiPortalApp.getUIPopupMessages());
+ uiApp.addMessage(new ApplicationMessage("UIPageBrowser.msg.delete.NotDelete", new String[]{id}, 1));
+ context.addUIComponentToUpdateByAjax(uiApp.getUIPopupMessages());
return;
}
UIPortal uiPortal = Util.getUIPortal();
UserNode userNode = uiPortal.getSelectedUserNode();
boolean isDeleteCurrentPage = userNode.getPageRef().equals(page.getPageId());
- if (isDeleteCurrentPage && page.getOwnerType().equals(PortalConfig.USER_TYPE))
+ if (isDeleteCurrentPage && page.getOwnerType().equals(SiteType.USER.getName()))
{
ApplicationMessage msg = new ApplicationMessage("UIPageBrowser.msg.delete.DeleteCurrentUserPage", null, ApplicationMessage.WARNING);
event.getRequestContext().getUIApplication().addMessage(msg);
@@ -290,7 +296,7 @@
int currentPage = datasource.getCurrentPage();
//Update navigation and UserToolbarGroupPortlet if deleted page is dashboard page
- if(page.getOwnerType().equals(PortalConfig.USER_TYPE)){
+ if(page.getOwnerType().equals(SiteType.USER.getName())){
removePageNode(page, event);
}
@@ -302,8 +308,9 @@
if (isDeleteCurrentPage)
{
- PageNodeEvent<UIPortal> pnevent =
- new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, userNode.getURI());
+ SiteKey siteKey = userNode.getNavigation().getKey();
+ PageNodeEvent<UIPortalApplication> pnevent =
+ new PageNodeEvent<UIPortalApplication>(Util.getUIPortalApplication(), PageNodeEvent.CHANGE_NODE, siteKey, userNode.getURI());
uiPortal.broadcast(pnevent, Phase.PROCESS);
}
else
@@ -376,16 +383,28 @@
{
UIPageBrowser uiPageBrowser = event.getSource();
WebuiRequestContext context = event.getRequestContext();
- String pageID = context.getRequestParameter(OBJECTID);
- DataStorage service = uiPageBrowser.getApplicationComponent(DataStorage.class);
+ PortalRequestContext pcontext = (PortalRequestContext)context.getParentAppRequestContext();
+ UIPortalApplication uiPortalApp = (UIPortalApplication)pcontext.getUIApplication();
+ String id = context.getRequestParameter(OBJECTID);
+ UserPortalConfigService service = uiPageBrowser.getApplicationComponent(UserPortalConfigService.class);
//Check existence of the page
- Page page = service.getPage(pageID);
+ Page page = service.getPage(id);
if (page == null)
{
- context.getUIApplication().addMessage(new ApplicationMessage("UIPageBrowser.msg.PageNotExist", new String[]{pageID}, 1));
+ uiPortalApp.addMessage(new ApplicationMessage("UIPageBrowser.msg.PageNotExist", new String[]{id}, 1));
+ context.addUIComponentToUpdateByAjax(uiPortalApp.getUIPopupMessages());
return;
}
+
+ //Check current user 's permissions on the page
+ UserACL userACL = uiPageBrowser.getApplicationComponent(UserACL.class);
+ if (!userACL.hasEditPermission(page))
+ {
+ uiPortalApp.addMessage(new ApplicationMessage("UIPageBrowser.msg.edit.NotEditPage", new String[]{id}, 1));
+ context.addUIComponentToUpdateByAjax(uiPortalApp.getUIPopupMessages());
+ return;
+ }
//Need this code to override editpage action in extension project
UIPageFactory clazz = UIPageFactory.getInstance(page.getFactoryId());
@@ -443,7 +462,7 @@
return;
}
- page.setOwnerType(uiPage.getOwnerType());
+ page.setOwnerType(uiPage.getSiteKey().getTypeName());
List<UIPortlet> uiPortlets = new ArrayList<UIPortlet>();
findAllPortlet(uiPortlets, uiPage);
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -31,11 +31,14 @@
import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.mop.Described;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.mop.description.DescriptionService;
import org.exoplatform.portal.mop.navigation.NavigationServiceException;
import org.exoplatform.portal.mop.user.UserNavigation;
import org.exoplatform.portal.mop.user.UserNode;
import org.exoplatform.portal.mop.user.UserPortal;
+import org.exoplatform.web.url.navigation.NodeURL;
import org.exoplatform.portal.webui.navigation.UIPageNodeSelector;
import org.exoplatform.portal.webui.portal.UIPortal;
import org.exoplatform.portal.webui.portal.UIPortalComposer;
@@ -86,7 +89,7 @@
{
UIPageNodeSelector nodeSelector = findFirstComponentOfType(UIPageNodeSelector.class);
nodeSelector.configure(node);
- if (node.getNavigation().getKey().getTypeName().equals(PortalConfig.USER_TYPE))
+ if (node.getNavigation().getKey().getType().equals(SiteType.USER))
{
nodeSelector.setRendered(false);
}
@@ -266,20 +269,20 @@
static public class ViewStep3ActionListener extends EventListener<UIPageCreationWizard>
{
- private void setDefaultPermission(Page page, String ownerType, String ownerId)
+ private void setDefaultPermission(Page page, SiteKey siteKey)
{
UIPortal uiPortal = Util.getUIPortal();
- if (PortalConfig.PORTAL_TYPE.equals(ownerType))
+ if (SiteType.PORTAL.equals(siteKey.getType()))
{
page.setAccessPermissions(uiPortal.getAccessPermissions());
page.setEditPermission(uiPortal.getEditPermission());
}
- else if (PortalConfig.GROUP_TYPE.equals(ownerType))
+ else if (SiteType.GROUP.equals(siteKey.getType()))
{
UserACL acl = Util.getUIPortalApplication().getApplicationComponent(UserACL.class);
- ownerId = ownerId.startsWith("/") ? ownerId : "/" + ownerId;
- page.setAccessPermissions(new String[]{"*:" + ownerId});
- page.setEditPermission(acl.getMakableMT() + ":" + ownerId);
+ String siteName = siteKey.getName().startsWith("/") ? siteKey.getName() : "/" + siteKey.getName();
+ page.setAccessPermissions(new String[]{"*:" + siteName});
+ page.setEditPermission(acl.getMakableMT() + ":" + siteName);
}
}
@@ -332,7 +335,7 @@
page.setModifiable(true);
// Set default permissions on the page
- setDefaultPermission(page, ownerType, ownerId);
+ setDefaultPermission(page, pageNavi.getKey());
if (page.getTitle() == null || page.getTitle().trim().length() == 0)
{
@@ -372,23 +375,21 @@
uiWorkingWS.setRenderedChild(UIPortalApplication.UI_VIEWING_WS_ID);
PortalRequestContext pcontext = Util.getPortalRequestContext();
- String uri = pcontext.getPortalURI();
try
{
UserNode newNode = uiWizard.saveData();
- uri += newNode.getURI();
+ NodeURL nodeURL = pcontext.createURL(NodeURL.TYPE).setNode(newNode);
+ UIPortalToolPanel toolPanel = uiWorkingWS.findFirstComponentOfType(UIPortalToolPanel.class);
+ toolPanel.setUIComponent(null);
+ uiWizard.updateUIPortal(event);
+ pcontext.sendRedirect(nodeURL.toString());
}
catch (NavigationServiceException ex)
{
pcontext.getUIApplication().addMessage(
new ApplicationMessage("UIPageCreationWizard.msg." + ex.getError().name(), null));
}
-
- UIPortalToolPanel toolPanel = uiWorkingWS.findFirstComponentOfType(UIPortalToolPanel.class);
- toolPanel.setUIComponent(null);
- uiWizard.updateUIPortal(event);
- pcontext.getResponse().sendRedirect(uri);
}
}
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -26,13 +26,15 @@
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.portal.application.PortalRequestContext;
+import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.config.NoSuchDataException;
import org.exoplatform.portal.config.UserACL;
-import org.exoplatform.portal.config.UserPortalConfig;
import org.exoplatform.portal.config.UserPortalConfigService;
+import org.exoplatform.portal.config.UserPortalConfig;
import org.exoplatform.portal.config.model.ModelObject;
import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.webui.application.UIPortlet;
import org.exoplatform.portal.webui.container.UIContainer;
import org.exoplatform.portal.webui.portal.UIPortal;
@@ -69,6 +71,10 @@
import org.exoplatform.webui.organization.UIListPermissionSelector.EmptyIteratorValidator;
import org.exoplatform.webui.organization.UIPermissionSelector;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
@ComponentConfigs({
@ComponentConfig(lifecycle = UIFormLifecycle.class, template = "system:/groovy/webui/form/UIFormTabPane.gtmpl", events = {
@EventConfig(listeners = UIPageForm.SaveActionListener.class),
@@ -100,8 +106,9 @@
super("UIPageForm");
PortalRequestContext pcontext = Util.getPortalRequestContext();
UserPortalConfigService configService = getApplicationComponent(UserPortalConfigService.class);
+ DataStorage dataStorage = getApplicationComponent(DataStorage.class);
List<SelectItemOption<String>> ownerTypes = new ArrayList<SelectItemOption<String>>();
- ownerTypes.add(new SelectItemOption<String>(PortalConfig.USER_TYPE));
+ ownerTypes.add(new SelectItemOption<String>(SiteType.USER.getName()));
ownerIdInput = new UIFormStringInput(OWNER_ID, OWNER_ID, null);
ownerIdInput.setEditable(false).setValue(pcontext.getRemoteUser());
@@ -157,7 +164,7 @@
}
if(portalsItem.size() > 0)
{
- ownerTypes.add(new SelectItemOption<String>(PortalConfig.PORTAL_TYPE));
+ ownerTypes.add(new SelectItemOption<String>(SiteType.PORTAL.getName()));
portalIdSelectBox = new UIFormSelectBox(OWNER_ID, OWNER_ID, portalsItem);
portalIdSelectBox.setOnChange("ChangeOwnerId");
portalIdSelectBox.setParent(uiSettingSet);
@@ -167,7 +174,7 @@
if (groups.size() > 0)
{
Collections.sort(groups);
- ownerTypes.add(new SelectItemOption<String>(PortalConfig.GROUP_TYPE));
+ ownerTypes.add(new SelectItemOption<String>(SiteType.GROUP.getName()));
List<SelectItemOption<String>> groupsItem = new ArrayList<SelectItemOption<String>>();
for (String group : groups)
{
@@ -191,7 +198,7 @@
{
uiPage_ = uiPage;
Page page = (Page)PortalDataMapper.buildModelObject(uiPage);
- if (uiPage.getOwnerType().equals(PortalConfig.USER_TYPE))
+ if (uiPage.getSiteKey().getType().equals(SiteType.USER))
{
removeChildById("PermissionSetting");
}
@@ -205,7 +212,7 @@
getUIStringInput("pageId").setValue(uiPage.getPageId());
getUIStringInput("title").setValue(uiPage.getTitle());
getUIFormCheckBoxInput("showMaxWindow").setValue(uiPage.isShowMaxWindow());
- getUIFormSelectBox(OWNER_TYPE).setEnable(false).setValue(uiPage.getOwnerType());
+ getUIFormSelectBox(OWNER_TYPE).setEnable(false).setValue(uiPage.getSiteKey().getTypeName());
removeChild(UIPageTemplateOptions.class);
UIFormInputItemSelector uiTemplate = getChild(UIFormInputItemSelector.class);
@@ -225,7 +232,7 @@
String ownerId = getUIStringInput("ownerId").getValue();
//As ownerId is now normalized, we have to maker sure that owenerId of 'group' type starts with a '/'
- if (PortalConfig.GROUP_TYPE.equals(ownerType) && ownerId.charAt(0) != '/')
+ if (SiteType.GROUP.getName().equals(ownerType) && ownerId.charAt(0) != '/')
{
ownerId = "/" + ownerId;
}
@@ -244,7 +251,7 @@
{
page.setShowMaxWindow((Boolean)getUIFormCheckBoxInput("showMaxWindow").getValue());
}
- if (!PortalConfig.USER_TYPE.equals(page.getOwnerType()))
+ if (!SiteType.USER.getName().equals(page.getOwnerType()))
{
page.setAccessPermissions(uiPermissionSetting.getChild(UIListPermissionSelector.class).getValue());
page.setEditPermission(uiPermissionSetting.getChild(UIPermissionSelector.class).getValue());
@@ -291,7 +298,7 @@
Page page = new Page();
page.setPageId(uiPage.getPageId());
uiPageForm.invokeSetBindingBean(page);
- page.setOwnerType(uiPage.getOwnerType());
+ page.setOwnerType(uiPage.getSiteKey().getTypeName());
List<UIPortlet> uiPortlets = new ArrayList<UIPortlet>();
findAllPortlet(uiPortlets, uiPage);
ArrayList<ModelObject> applications = new ArrayList<ModelObject>();
@@ -300,43 +307,6 @@
applications.add(PortalDataMapper.buildModelObject(uiPortlet));
}
- if (Page.DESKTOP_PAGE.equals(uiPage.getFactoryId()) && !Page.DESKTOP_PAGE.equals(page.getFactoryId()))
- {
- page.setShowMaxWindow(false);
- uiPage.getChildren().clear();
- page.setChildren(applications);
-
- PortalDataMapper.toUIPage(uiPage, page);
- if (page.getChildren() == null)
- page.setChildren(new ArrayList<ModelObject>());
-
- pcontext.setFullRender(true);
- UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
- pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
- pcontext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
- return;
- }
-
- if (Page.DESKTOP_PAGE.equals(page.getFactoryId()))
- {
- uiPage.getChildren().clear();
- page.setChildren(applications);
-
- PortalDataMapper.toUIPage(uiPage, page);
- if (page.getChildren() == null)
- page.setChildren(new ArrayList<ModelObject>());
-
- UIPortalToolPanel toolPanel = Util.getUIPortalToolPanel();
- toolPanel.setShowMaskLayer(true);
- pcontext.setFullRender(true);
- UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
- pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
- pcontext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
- DataStorage dataService = uiPageForm.getApplicationComponent(DataStorage.class);
- dataService.save(page);
- return;
- }
-
List<UIComponent> uiChildren = uiPage.getChildren();
if (uiChildren == null)
{
@@ -358,7 +328,7 @@
pcontext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
} catch(NoSuchDataException de){
uiPortalApp.addMessage(new ApplicationMessage("UIPageForm.msg.notExistOrDeleted", null, ApplicationMessage.ERROR));
- UIPortalComposer uiPortalComposer = (UIPortalComposer)uiPortalApp.findComponentById("UIPageEditor");
+ UIPortalComposer uiPortalComposer = (UIPortalComposer)uiPortalApp.findComponentById(UIPortalComposer.UIPAGE_EDITOR);
if(uiPortalComposer != null){
Event aboutEvent = new Event<UIPortalComposer>(uiPortalComposer, "Abort", event.getRequestContext());
uiPortalComposer.broadcast(aboutEvent, event.getExecutionPhase());
@@ -394,7 +364,7 @@
UIFormInputSet uiSettingSet = uiForm.getChildById("PageSetting");
uiForm.setSelectedTab("PageSetting");
List<UIComponent> list = uiSettingSet.getChildren();
- if (PortalConfig.USER_TYPE.equals(ownerType))
+ if (SiteType.USER.getName().equals(ownerType))
{
uiForm.removeChildById("PermissionSetting");
list.remove(2);
@@ -408,7 +378,7 @@
uiForm.addUIComponentInput(uiForm.uiPermissionSetting);
}
- if (PortalConfig.PORTAL_TYPE.equals(ownerType))
+ if (SiteType.PORTAL.getName().equals(ownerType))
{
list.remove(2);
list.add(2, uiForm.portalIdSelectBox);
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIWizardPageSetInfo.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIWizardPageSetInfo.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIWizardPageSetInfo.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -22,6 +22,7 @@
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.mop.Visibility;
import org.exoplatform.portal.mop.navigation.NavigationServiceException;
import org.exoplatform.portal.mop.user.UserNode;
@@ -140,7 +141,7 @@
addUIFormInput(startPubDateInput);
addUIFormInput(endPubDateInput);
- boolean isUserNav = Util.getUIPortal().getOwnerType().equals(PortalConfig.USER_TYPE);
+ boolean isUserNav = Util.getUIPortal().getSiteType().equals(SiteType.USER);
if (isUserNav)
{
uiVisibleCheck.setRendered(false);
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/PageNodeEvent.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/PageNodeEvent.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/PageNodeEvent.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -19,6 +19,7 @@
package org.exoplatform.portal.webui.portal;
+import org.exoplatform.portal.mop.SiteKey;
import org.exoplatform.webui.core.UIComponent;
import org.exoplatform.webui.event.Event;
@@ -26,20 +27,27 @@
* Jun 5, 2006
*/
public class PageNodeEvent<T extends UIComponent> extends Event<T>
-{
+{
+ final static public String CHANGE_NODE = "ChangeNode";
- final static public String CHANGE_PAGE_NODE = "ChangePageNode";
-
private String targetNodeUri;
+
+ private SiteKey siteKey;
- public PageNodeEvent(T source, String name, String targetNodeUri)
+ public PageNodeEvent(T source, String name, SiteKey siteKey, String targetNodeUri)
{
super(source, name, null);
this.targetNodeUri = targetNodeUri;
+ this.siteKey = siteKey;
}
-
+
public String getTargetNodeUri()
{
return targetNodeUri;
}
+
+ public SiteKey getSiteKey()
+ {
+ return siteKey;
+ }
}
\ No newline at end of file
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UILanguageSelector.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UILanguageSelector.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UILanguageSelector.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -28,6 +28,8 @@
import org.exoplatform.services.resources.LocaleConfig;
import org.exoplatform.services.resources.LocaleConfigService;
import org.exoplatform.services.resources.ResourceBundleService;
+import org.exoplatform.web.url.ResourceType;
+import org.exoplatform.web.url.navigation.NodeURL;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.EventConfig;
import org.exoplatform.webui.core.UIContainer;
@@ -172,12 +174,20 @@
if (language == null || language.trim().length() < 1)
return;
// if(!uiPortal.isModifiable()) return;
+
LocaleConfigService localeConfigService = event.getSource().getApplicationComponent(LocaleConfigService.class);
LocaleConfig localeConfig = localeConfigService.getLocaleConfig(language);
if (localeConfig == null)
localeConfig = localeConfigService.getDefaultLocaleConfig();
PortalRequestContext prqCtx = PortalRequestContext.getCurrentInstance();
prqCtx.setLocale(localeConfig.getLocale());
+
+ if (prqCtx.getRequestLocale() != null)
+ {
+ NodeURL url = prqCtx.createURL(NodeURL.TYPE).setNode(Util.getUIPortal().getNavPath());
+ url.setLocale(prqCtx.getLocale());
+ prqCtx.sendRedirect(url.toString());
+ }
}
}
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -24,12 +24,14 @@
import org.exoplatform.portal.config.model.PortalProperties;
import org.exoplatform.portal.config.model.Properties;
import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.mop.user.UserNavigation;
import org.exoplatform.portal.mop.user.UserNode;
+import org.exoplatform.web.url.navigation.NodeURL;
+import org.exoplatform.web.url.navigation.NavigationResource;
import org.exoplatform.portal.webui.application.UIPortlet;
import org.exoplatform.portal.webui.container.UIContainer;
import org.exoplatform.portal.webui.page.UIPage;
-import org.exoplatform.portal.webui.page.UIPageActionListener.ChangePageNodeActionListener;
import org.exoplatform.portal.webui.page.UIPageBody;
import org.exoplatform.portal.webui.portal.UIPortalComponentActionListener.ChangeApplicationListActionListener;
import org.exoplatform.portal.webui.portal.UIPortalComponentActionListener.ChangeLanguageActionListener;
@@ -55,7 +57,6 @@
import org.exoplatform.webui.event.Event;
import org.exoplatform.webui.event.EventListener;
-import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
@@ -64,7 +65,6 @@
import javax.servlet.http.HttpServletRequest;
@ComponentConfig(lifecycle = UIPortalLifecycle.class, template = "system:/groovy/portal/webui/portal/UIPortal.gtmpl", events = {
- @EventConfig(listeners = ChangePageNodeActionListener.class),
@EventConfig(listeners = ChangeApplicationListActionListener.class),
@EventConfig(listeners = MoveChildActionListener.class),
@EventConfig(listeners = UIPortal.ChangeWindowStateActionListener.class),
@@ -78,11 +78,8 @@
@EventConfig(listeners = UIPortalActionListener.PingActionListener.class)})
public class UIPortal extends UIContainer
{
+ private SiteKey siteKey;
- private String owner;
-
- private String ownerType;
-
private String locale;
private String label;
@@ -105,19 +102,14 @@
public SiteKey getSiteKey()
{
- return new SiteKey(ownerType, name_);
+ return siteKey;
}
- public String getOwner()
+ public void setSiteKey(SiteKey key)
{
- return owner;
+ siteKey = key;
}
-
- public void setOwner(String s)
- {
- owner = s;
- }
-
+
public String getLocale()
{
return locale;
@@ -148,14 +140,20 @@
skin = s;
}
+ /**
+ * @deprecated Use {@link #getSiteType()} instead
+ *
+ * @return
+ */
+ @Deprecated
public String getOwnerType()
{
- return ownerType;
+ return siteKey.getTypeName();
}
-
- public void setOwnerType(String ownerType)
+
+ public SiteType getSiteType()
{
- this.ownerType = ownerType;
+ return siteKey.getType();
}
public Map<String, String[]> getPublicParameters()
@@ -217,7 +215,6 @@
public UserNavigation getUserNavigation() throws Exception
{
UIPortalApplication uiPortalApp = getAncestorOfType(UIPortalApplication.class);
- SiteKey siteKey = new SiteKey(ownerType, owner);
return uiPortalApp.getUserPortalConfig().getUserPortal().getNavigation(siteKey);
}
@@ -341,22 +338,24 @@
//Delete the token from JCR
String token = getTokenCookie(req);
- if(token != null){
+ if(token != null)
+ {
AbstractTokenService tokenService = AbstractTokenService.getInstance(CookieTokenService.class);
tokenService.deleteToken(token);
}
+ String portalName = prContext.getPortalOwner();
+ NodeURL createURL =
+ prContext.createURL(NodeURL.TYPE);
+ createURL.setResource(new NavigationResource(SiteType.PORTAL, portalName, null));
+
LogoutControl.wantLogout();
Cookie cookie = new Cookie(InitiateLoginServlet.COOKIE_NAME, "");
cookie.setPath(req.getContextPath());
cookie.setMaxAge(0);
prContext.getResponse().addCookie(cookie);
- // String portalName = URLEncoder.encode(Util.getUIPortal().getName(),
- // "UTF-8") ;
- String portalName = URLEncoder.encode(prContext.getPortalOwner(), "UTF-8");
- String redirect = req.getContextPath() + "/public/" + portalName + "/";
- prContext.getResponse().sendRedirect(redirect);
- prContext.setResponseComplete(true);
+
+ prContext.sendRedirect(createURL.toString());
}
private String getTokenCookie(HttpServletRequest req)
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalActionListener.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalActionListener.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalActionListener.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -55,6 +55,7 @@
}
}
+ //TODO This method seems not to be used
static public class ChangeWindowStateActionListener extends EventListener<UIPortal>
{
public void execute(Event<UIPortal> event) throws Exception
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -23,11 +23,15 @@
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.config.StaleModelException;
+import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.config.UserPortalConfig;
import org.exoplatform.portal.config.UserPortalConfigService;
import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.config.model.PortalProperties;
+import org.exoplatform.portal.mop.SiteKey;
+import org.exoplatform.portal.mop.SiteType;
+import org.exoplatform.portal.mop.user.UserNode;
import org.exoplatform.portal.resource.SkinService;
import org.exoplatform.portal.webui.application.UIPortlet;
import org.exoplatform.portal.webui.page.UIPage;
@@ -68,18 +72,18 @@
/** Created by The eXo Platform SAS Author : Pham Thanh Tung thanhtungty(a)gmail.com Jun 10, 2009 */
@ComponentConfigs({
@ComponentConfig(template = "app:/groovy/portal/webui/portal/UIPortalComposer.gtmpl", events = {
- @EventConfig(listeners = UIPortalComposer.ViewPropertiesActionListener.class),
+ @EventConfig(name = "ViewProperties", listeners = UIPortalComposer.ViewSitePropertiesActionListener.class),
@EventConfig(listeners = UIPortalComposer.CloseComposerActionListener.class),
- @EventConfig(listeners = UIPortalComposer.AbortActionListener.class),
- @EventConfig(listeners = UIPortalComposer.FinishActionListener.class),
+ @EventConfig(name = "Abort", listeners = UIPortalComposer.AbortSiteEditionActionListener.class),
+ @EventConfig(name = "Finish", listeners = UIPortalComposer.FinishSiteEditionActionListener.class),
@EventConfig(listeners = UIPortalComposer.SwitchModeActionListener.class),
@EventConfig(listeners = UIPortalComposer.ChangeEdittedStateActionListener.class),
@EventConfig(listeners = UIPortalComposer.ToggleActionListener.class)}),
- @ComponentConfig(id = "UIPageEditor", template = "app:/groovy/portal/webui/portal/UIPortalComposer.gtmpl", events = {
- @EventConfig(name = "ViewProperties", listeners = UIPortalComposer.ViewProperties2ActionListener.class),
+ @ComponentConfig(id = UIPortalComposer.UIPAGE_EDITOR, template = "app:/groovy/portal/webui/portal/UIPortalComposer.gtmpl", events = {
+ @EventConfig(name = "ViewProperties", listeners = UIPortalComposer.ViewPagePropertiesActionListener.class),
@EventConfig(listeners = UIPortalComposer.CloseComposerActionListener.class),
- @EventConfig(name = "Abort", listeners = UIPortalComposer.Abort2ActionListener.class),
- @EventConfig(name = "Finish", listeners = UIPortalComposer.Finish2ActionListener.class),
+ @EventConfig(name = "Abort", listeners = UIPortalComposer.AbortPageEditionActionListener.class),
+ @EventConfig(name = "Finish", listeners = UIPortalComposer.FinishPageEditionActionListener.class),
@EventConfig(name = "Back", listeners = UIPortalComposer.BackActionListener.class),
@EventConfig(listeners = UIPortalComposer.SwitchModeActionListener.class),
@EventConfig(listeners = UIPortalComposer.ChangeEdittedStateActionListener.class),
@@ -87,7 +91,10 @@
@ComponentConfig(id = "UIPortalComposerTab", type = UITabPane.class, template = "app:/groovy/portal/webui/portal/UIPortalComposerContent.gtmpl", events = {@EventConfig(listeners = UIPortalComposer.SelectTabActionListener.class)})})
public class UIPortalComposer extends UIContainer
{
-
+ final static public String UIPORTAL_COMPOSER = "UIPortalComposer";
+
+ final static public String UIPAGE_EDITOR = "UIPageEditor";
+
private boolean isEditted = false;
private boolean isCollapsed = false;
@@ -182,11 +189,11 @@
UIPortal editPortal = (UIPortal)uiEditWS.getUIComponent();
UIPortal uiPortal = Util.getUIPortal();
String remoteUser = prContext.getRemoteUser();
- String ownerUser = prContext.getPortalOwner();
+ String portalName = prContext.getPortalOwner();
PortalConfig portalConfig = (PortalConfig)PortalDataMapper.buildModelObject(editPortal);
- UserPortalConfigService configService = getApplicationComponent(UserPortalConfigService.class);
DataStorage dataStorage = getApplicationComponent(DataStorage.class);
+ UserACL acl = getApplicationComponent(UserACL.class);
if (!isPortalExist(editPortal))
{
@@ -205,11 +212,11 @@
//caught in the ApplicationLifecycle
rebuildUIPortal(uiPortalApp, editPortal, dataStorage);
}
- uiPortalApp.getUserPortalConfig().setPortal(portalConfig);
- UserPortalConfig userPortalConfig = configService.getUserPortalConfig(ownerUser, remoteUser);
- if (userPortalConfig != null)
+ uiPortalApp.getUserPortalConfig().setPortalConfig(portalConfig);
+ PortalConfig pConfig = dataStorage.getPortalConfig(portalName);
+ if (pConfig != null)
{
- editPortal.setModifiable(userPortalConfig.getPortalConfig().isModifiable());
+ editPortal.setModifiable(acl.hasEditPermission(pConfig));
}
else
{
@@ -246,11 +253,11 @@
private void rebuildUIPortal(UIPortalApplication uiPortalApp, UIPortal uiPortal, DataStorage storage) throws Exception
{
- PortalConfig portalConfig = storage.getPortalConfig(uiPortal.getOwnerType(), uiPortal.getOwner());
+ PortalConfig portalConfig = storage.getPortalConfig(uiPortal.getSiteType().getName(), uiPortal.getName());
UserPortalConfig userPortalConfig = uiPortalApp.getUserPortalConfig();
- userPortalConfig.setPortal(portalConfig);
+ userPortalConfig.setPortalConfig(portalConfig);
uiPortal.getChildren().clear();
- PortalDataMapper.toUIPortal(uiPortal, userPortalConfig);
+ PortalDataMapper.toUIPortal(uiPortal, userPortalConfig.getPortalConfig());
uiPortalApp.putCachedUIPortal(uiPortal);
@@ -267,9 +274,9 @@
String remoteUser = Util.getPortalRequestContext().getRemoteUser();
String portalOwner = null;
- if (editPortal.getOwnerType().equals(PortalConfig.PORTAL_TYPE))
+ if (editPortal.getSiteType().equals(SiteType.PORTAL))
{
- portalOwner = editPortal.getOwner();
+ portalOwner = editPortal.getName();
}
else
{
@@ -355,7 +362,7 @@
super.processRender(context);
}
- static public class ViewPropertiesActionListener extends EventListener<UIPortalComposer>
+ static public class ViewSitePropertiesActionListener extends EventListener<UIPortalComposer>
{
public void execute(Event<UIPortalComposer> event) throws Exception
@@ -368,9 +375,9 @@
if (temp != null && (temp instanceof UIPortal))
{
uiPortal = (UIPortal)temp;
- if (uiPortal.getOwnerType().equals(PortalConfig.PORTAL_TYPE))
+ if (uiPortal.getSiteType().equals(SiteType.PORTAL))
{
- portalOwner = uiPortal.getOwner();
+ portalOwner = uiPortal.getName();
}
else
{
@@ -388,7 +395,7 @@
UIPortalForm portalForm = uiMaskWS.createUIComponent(UIPortalForm.class, null, "UIPortalForm");
portalForm.setPortalOwner(portalOwner);
portalForm.setBindingBean();
- if (PortalConfig.USER_TYPE.equals(uiPortal.getOwnerType()))
+ if (SiteType.USER.equals(uiPortal.getSiteType()))
{
portalForm.removeChildById("PermissionSetting");
}
@@ -397,7 +404,7 @@
}
}
- static public class AbortActionListener extends EventListener<UIPortalComposer>
+ static public class AbortSiteEditionActionListener extends EventListener<UIPortalComposer>
{
public void execute(Event<UIPortalComposer> event) throws Exception
{
@@ -415,9 +422,12 @@
UIPortal uiPortal = uiWorkingWS.getBackupUIPortal();
siteBody.setUIComponent(uiPortal);
- String uri = uiPortal.getSelectedUserNode() != null ? uiPortal.getSelectedUserNode().getURI() : null;
- PageNodeEvent<UIPortal> pnevent = new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, uri);
- uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
+ UserNode currentNode = uiPortal.getSelectedUserNode();
+ SiteKey siteKey = currentNode.getNavigation().getKey();
+ PageNodeEvent<UIPortalApplication> pnevent =
+ new PageNodeEvent<UIPortalApplication>(uiPortalApp, PageNodeEvent.CHANGE_NODE, siteKey, currentNode.getURI());
+ uiPortalApp.broadcast(pnevent, Event.Phase.PROCESS);
+
prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
JavascriptManager jsManager = prContext.getJavascriptManager();
jsManager.addJavascript("eXo.portal.portalMode=" + UIPortalApplication.NORMAL_MODE + ";");
@@ -431,7 +441,7 @@
* @author <a href="trong.tran(a)exoplatform.com">Trong Tran</a>
* @version $Revision$
*/
- static public class FinishActionListener extends EventListener<UIPortalComposer>
+ static public class FinishSiteEditionActionListener extends EventListener<UIPortalComposer>
{
public void execute(Event<UIPortalComposer> event) throws Exception
@@ -460,9 +470,7 @@
uiPortalApp.setSessionOpen(PortalProperties.SESSION_ALWAYS.equals(uiPortal.getSessionAlive()));
uiPortalApp.setModeState(UIPortalApplication.NORMAL_MODE);
uiWorkingWS.setRenderedChild(UIPortalApplication.UI_VIEWING_WS_ID);
- prContext.ignoreAJAXUpdateOnPortlets(true);
-
- String uri = (uiPortal.getSelectedUserNode() != null)? (uiPortal.getSelectedUserNode().getURI()) : null;
+ prContext.ignoreAJAXUpdateOnPortlets(true);
if (uiComposer.isPortalExist(editPortal))
{
@@ -471,30 +479,33 @@
storage.getPortalConfig(uiPortal.getSiteKey().getTypeName(), uiPortal.getSiteKey().getName());
if (pConfig != null)
{
- uiPortalApp.getUserPortalConfig().setPortal(pConfig);
+ uiPortalApp.getUserPortalConfig().setPortalConfig(pConfig);
}
uiPortal.getChildren().clear();
- PortalDataMapper.toUIPortal(uiPortal, uiPortalApp.getUserPortalConfig());
+ PortalDataMapper.toUIPortal(uiPortal, uiPortalApp.getUserPortalConfig().getPortalConfig());
//Update the cache of UIPortal from UIPortalApplication
uiPortalApp.putCachedUIPortal(uiPortal);
- uiPortalApp.setShowedUIPortal(uiPortal);
+ uiPortalApp.setCurrentSite(uiPortal);
//To init the UIPage, that fixed a bug on AdminToolbarPortlet when edit the layout. Here is only a
//temporal solution. Complete solution is to avoid mapping UIPortal -- model, that requires
//multiple UIPortal (already available) and concept of SiteConfig
uiPortal.refreshUIPage();
- PageNodeEvent<UIPortal> pnevent =
- new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, uri);
- uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
+ UserNode currentNode = uiPortal.getSelectedUserNode();
+ SiteKey siteKey = currentNode.getNavigation().getKey();
+ PageNodeEvent<UIPortalApplication> pnevent =
+ new PageNodeEvent<UIPortalApplication>(uiPortalApp, PageNodeEvent.CHANGE_NODE, siteKey, currentNode.getURI());
+ uiPortalApp.broadcast(pnevent, Event.Phase.PROCESS);
+
prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
JavascriptManager jsManager = prContext.getJavascriptManager();
jsManager.addJavascript("eXo.portal.portalMode=" + UIPortalApplication.NORMAL_MODE + ";");
}
else
{
- if (editPortal.getOwner().equals(prContext.getPortalOwner()))
+ if (editPortal.getName().equals(prContext.getPortalOwner()))
{
HttpServletRequest request = prContext.getRequest();
LogoutControl.wantLogout();
@@ -605,7 +616,7 @@
}
}
- static public class ViewProperties2ActionListener extends EventListener<UIPortalComposer>
+ static public class ViewPagePropertiesActionListener extends EventListener<UIPortalComposer>
{
public void execute(Event<UIPortalComposer> event) throws Exception
{
@@ -644,7 +655,7 @@
}
}
- static public class Abort2ActionListener extends EventListener<UIPortalComposer>
+ static public class AbortPageEditionActionListener extends EventListener<UIPortalComposer>
{
public void execute(Event<UIPortalComposer> event) throws Exception
{
@@ -658,17 +669,18 @@
PortalRequestContext prContext = Util.getPortalRequestContext();
prContext.ignoreAJAXUpdateOnPortlets(true);
- UIPortal uiPortal = uiPortalApp.getShowedUIPortal();
+ UIPortal uiPortal = uiPortalApp.getCurrentSite();
uiPortal.setRenderSibling(UIPortal.class);
UIPortalComposer composer = uiWorkingWS.findFirstComponentOfType(UIPortalComposer.class).setRendered(false);
composer.setEditted(false);
uiPortal.refreshUIPage();
- PageNodeEvent<UIPortal> pnevent =
- new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, (uiPortal.getSelectedUserNode() != null
- ? uiPortal.getSelectedUserNode().getURI() : null));
- uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
+ UserNode currentNode = uiPortal.getSelectedUserNode();
+ SiteKey siteKey = currentNode.getNavigation().getKey();
+ PageNodeEvent<UIPortalApplication> pnevent =
+ new PageNodeEvent<UIPortalApplication>(uiPortalApp, PageNodeEvent.CHANGE_NODE, siteKey, currentNode.getURI());
+ uiPortalApp.broadcast(pnevent, Event.Phase.PROCESS);
prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
JavascriptManager jsManager = event.getRequestContext().getJavascriptManager();
jsManager.addJavascript("eXo.portal.portalMode=" + UIPortalApplication.NORMAL_MODE + ";");
@@ -681,12 +693,12 @@
* @author <a href="trong.tran(a)exoplatform.com">Trong Tran</a>
* @version $Revision$
*/
- static public class Finish2ActionListener extends EventListener<UIPortalComposer>
+ static public class FinishPageEditionActionListener extends EventListener<UIPortalComposer>
{
public void execute(Event<UIPortalComposer> event) throws Exception
{
UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
- UIPortal uiPortal = uiPortalApp.getShowedUIPortal();
+ UIPortal uiPortal = uiPortalApp.getCurrentSite();
UIEditInlineWorkspace editInlineWS = event.getSource().getParent();
UIWorkingWorkspace uiWorkingWS = editInlineWS.getParent();
UIPortalToolPanel uiToolPanel = uiWorkingWS.findFirstComponentOfType(UIPortalToolPanel.class);
@@ -700,18 +712,22 @@
uiWorkingWS.getApplicationComponent(UserPortalConfigService.class);
/*
- * if it is a edition of the current page
+ * if it is a edition of the current page and it is not available to current remote user anymore.
*/
+ PortalRequestContext pContext = Util.getPortalRequestContext();
if (page.getStorageId() != null && portalConfigService.getPage(pageId) == null)
{
- uiPortalApp.addMessage(new ApplicationMessage("UIPageBrowser.msg.PageNotExist", new String[]{pageId}, 1));
+ uiPortalApp.addMessage(new ApplicationMessage("UIPageBrowser.msg.PageNotExist", new String[]{pageId}, ApplicationMessage.WARNING));
uiPortalApp.setModeState(UIPortalApplication.NORMAL_MODE);
uiWorkingWS.setRenderedChild(UIPortalApplication.UI_VIEWING_WS_ID);
Util.getPortalRequestContext().ignoreAJAXUpdateOnPortlets(true);
- PageNodeEvent<UIPortal> pnevent =
- new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE,
- (uiPortal.getSelectedUserNode() != null ? uiPortal.getSelectedUserNode().getURI() : null));
- uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
+
+ UserNode currentNode = uiPortal.getSelectedUserNode();
+ SiteKey siteKey = currentNode.getNavigation().getKey();
+ PageNodeEvent<UIPortalApplication> pnevent =
+ new PageNodeEvent<UIPortalApplication>(uiPortalApp, PageNodeEvent.CHANGE_NODE, siteKey, currentNode.getURI());
+ uiPortalApp.broadcast(pnevent, Event.Phase.PROCESS);
+
JavascriptManager jsManager = event.getRequestContext().getJavascriptManager();
jsManager.addJavascript("eXo.portal.portalMode=" + UIPortalApplication.NORMAL_MODE + ";");
return;
@@ -765,10 +781,13 @@
uiPortalApp.setModeState(UIPortalApplication.NORMAL_MODE);
uiWorkingWS.setRenderedChild(UIPortalApplication.UI_VIEWING_WS_ID);
Util.getPortalRequestContext().ignoreAJAXUpdateOnPortlets(true);
- PageNodeEvent<UIPortal> pnevent =
- new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, (uiPortal.getSelectedUserNode() != null
- ? uiPortal.getSelectedUserNode().getURI() : null));
- uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
+
+ UserNode currentNode = uiPortal.getSelectedUserNode();
+ SiteKey siteKey = currentNode.getNavigation().getKey();
+ PageNodeEvent<UIPortalApplication> pnevent =
+ new PageNodeEvent<UIPortalApplication>(uiPortalApp, PageNodeEvent.CHANGE_NODE, siteKey, currentNode.getURI());
+ uiPortalApp.broadcast(pnevent, Event.Phase.PROCESS);
+
JavascriptManager jsManager = event.getRequestContext().getJavascriptManager();
jsManager.addJavascript("eXo.portal.portalMode=" + UIPortalApplication.NORMAL_MODE + ";");
}
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -23,10 +23,11 @@
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.UserPortalConfig;
+import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.config.UserPortalConfigService;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.config.model.PortalProperties;
+import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.resource.SkinService;
import org.exoplatform.portal.webui.util.PortalDataMapper;
import org.exoplatform.portal.webui.util.Util;
@@ -149,8 +150,7 @@
public void setBindingBean() throws Exception
{
- UserPortalConfigService service = this.getApplicationComponent(UserPortalConfigService.class);
- PortalRequestContext prContext = Util.getPortalRequestContext();
+ DataStorage dataStorage = this.getApplicationComponent(DataStorage.class);
UIPortal editPortal = null;
UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
@@ -164,9 +164,9 @@
}
else
{
- UserPortalConfig userConfig = service.getUserPortalConfig(getPortalOwner(), prContext.getRemoteUser());
+ PortalConfig pConfig = dataStorage.getPortalConfig(getPortalOwner());
editPortal = this.createUIComponent(UIPortal.class, null, null);
- PortalDataMapper.toUIPortal(editPortal, userConfig);
+ PortalDataMapper.toUIPortal(editPortal, pConfig);
}
invokeGetBindingBean(editPortal);
@@ -304,15 +304,15 @@
UIPortalForm uiForm = event.getSource();
DataStorage dataService = uiForm.getApplicationComponent(DataStorage.class);
- UserPortalConfigService service = uiForm.getApplicationComponent(UserPortalConfigService.class);
+ UserACL acl = uiForm.getApplicationComponent(UserACL.class);
PortalRequestContext prContext = Util.getPortalRequestContext();
UIPortalApplication uiPortalApp = (UIPortalApplication)prContext.getUIApplication();
- UserPortalConfig userConfig = service.getUserPortalConfig(uiForm.getPortalOwner(), prContext.getRemoteUser());
- if (userConfig != null)
+ PortalConfig pConfig = dataService.getPortalConfig(uiForm.getPortalOwner());
+ if (pConfig != null && acl.hasPermission(pConfig))
{
UIPortal uiPortal = uiForm.createUIComponent(UIPortal.class, null, null);
- PortalDataMapper.toUIPortal(uiPortal, userConfig);
+ PortalDataMapper.toUIPortal(uiPortal, pConfig);
uiForm.invokeSetBindingBean(uiPortal);
//uiPortal.refreshNavigation(localeConfigService.getLocaleConfig(uiPortal.getLocale()).getLocale()) ;
@@ -320,11 +320,17 @@
{
PortalConfig portalConfig = (PortalConfig)PortalDataMapper.buildModelObject(uiPortal);
dataService.save(portalConfig);
- prContext.setAttribute(UserPortalConfig.class, service.getUserPortalConfig(uiForm.getPortalOwner(), prContext.getRemoteUser(), PortalRequestContext.USER_PORTAL_CONTEXT));
- uiPortalApp.reloadSkinPortal(prContext);
+ UserPortalConfigService service = uiForm.getApplicationComponent(UserPortalConfigService.class);
+ if (prContext.getPortalOwner().equals(uiForm.getPortalOwner()))
+ {
+ uiPortalApp.setUserPortalConfig(service.getUserPortalConfig(uiForm.getPortalOwner(), prContext.getRemoteUser(), PortalRequestContext.USER_PORTAL_CONTEXT));
+ uiPortalApp.reloadPortalProperties();
+ }
// We should use IPC to update some portlets in the future instead of
UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChild(UIWorkingWorkspace.class);
+
+ // TODO: Raise Portlet Event instead
uiWorkingWS.updatePortletsByName("PortalNavigationPortlet");
uiWorkingWS.updatePortletsByName("UserToolbarSitePortlet");
}
@@ -375,9 +381,9 @@
}
UserPortalConfigService service = uiForm.getApplicationComponent(UserPortalConfigService.class);
- service.createUserPortalConfig(PortalConfig.PORTAL_TYPE, portalName, template);
- UserPortalConfig userPortalConfig = service.getUserPortalConfig(portalName, pcontext.getRemoteUser());
- PortalConfig pconfig = userPortalConfig.getPortalConfig();
+ service.createUserPortalConfig(SiteType.PORTAL.getName(), portalName, template);
+
+ PortalConfig pconfig = dataService.getPortalConfig(portalName);
uiForm.invokeSetBindingBean(pconfig);
dataService.save(pconfig);
UIPortalApplication uiPortalApp = event.getSource().getAncestorOfType(UIPortalApplication.class);
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UISkinSelector.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UISkinSelector.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UISkinSelector.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -65,7 +65,7 @@
String currentSkin = uiPortalApp.getSkin();
if (currentSkin == null)
- currentSkin = "Default";
+ currentSkin = SkinService.DEFAULT_SKIN;
for (SelectItemCategory ele : itemCategories)
{
if (ele.getName().equals(currentSkin))
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -29,6 +29,7 @@
import org.exoplatform.portal.config.model.PageBody;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.config.model.SiteBody;
+import org.exoplatform.portal.mop.SiteKey;
import org.exoplatform.portal.pom.spi.gadget.Gadget;
import org.exoplatform.portal.webui.application.PortletState;
import org.exoplatform.portal.webui.application.UIGadget;
@@ -179,8 +180,8 @@
{
Page model = new Page(uiPage.getStorageId());
toContainer(model, uiPage);
- model.setOwnerId(uiPage.getOwnerId());
- model.setOwnerType(uiPage.getOwnerType());
+ model.setOwnerId(uiPage.getSiteKey().getName());
+ model.setOwnerType(uiPage.getSiteKey().getTypeName());
model.setIcon(uiPage.getIcon());
model.setPageId(uiPage.getPageId());
model.setTitle(uiPage.getTitle());
@@ -194,7 +195,7 @@
static private PortalConfig toPortal(UIPortal uiPortal)
{
- PortalConfig model = new PortalConfig(uiPortal.getOwnerType(), uiPortal.getName(), uiPortal.getStorageId());
+ PortalConfig model = new PortalConfig(uiPortal.getSiteType().getName(), uiPortal.getName(), uiPortal.getStorageId());
model.setAccessPermissions(uiPortal.getAccessPermissions());
model.setEditPermission(uiPortal.getEditPermission());
model.setLabel(uiPortal.getLabel());
@@ -317,8 +318,7 @@
static public void toUIPage(UIPage uiPage, Page model) throws Exception
{
toUIContainer(uiPage, model);
- uiPage.setOwnerId(model.getOwnerId());
- uiPage.setOwnerType(model.getOwnerType());
+ uiPage.setSiteKey(new SiteKey(model.getOwnerType(), model.getOwnerId()));
uiPage.setIcon(model.getIcon());
uiPage.setAccessPermissions(model.getAccessPermissions());
uiPage.setEditPermission(model.getEditPermission());
@@ -336,16 +336,13 @@
}
}
- static public void toUIPortal(UIPortal uiPortal, UserPortalConfig userPortalConfig) throws Exception
+ static public void toUIPortal(UIPortal uiPortal, PortalConfig model) throws Exception
{
- PortalConfig model = userPortalConfig.getPortalConfig();
-
- uiPortal.setOwnerType(model.getType());
+ uiPortal.setSiteKey(new SiteKey(model.getType(), model.getName()));
uiPortal.setStorageId(model.getStorageId());
uiPortal.setName(model.getName());
uiPortal.setId("UIPortal");
// uiPortal.setFactoryId(model.getFactoryId());
- uiPortal.setOwner(model.getName());
uiPortal.setModifiable(model.isModifiable());
uiPortal.setLabel(model.getLabel());
@@ -364,8 +361,6 @@
buildUIContainer(uiPortal, child, false);
}
}
- //uiPortal.setNavigation(userPortalConfig.getNavigations());
-// uiPortal.setNavigation(userPortalConfig.getSelectedNavigation());
}
private static void buildUIContainer(UIContainer uiContainer, Object model, boolean dashboard) throws Exception
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/util/Util.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/util/Util.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/util/Util.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -23,7 +23,6 @@
import org.exoplatform.portal.config.UserPortalConfigService;
import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.config.model.PageNode;
-import org.exoplatform.portal.webui.application.UIPortlet;
import org.exoplatform.portal.webui.container.UIContainer;
import org.exoplatform.portal.webui.page.UIPage;
import org.exoplatform.portal.webui.page.UIPageFactory;
@@ -64,7 +63,7 @@
{
//return getUIPortalApplication().<UIWorkingWorkspace> getChildById(UIPortalApplication.UI_WORKING_WS_ID)
// .findFirstComponentOfType(UIPortal.class);
- return getUIPortalApplication().getShowedUIPortal();
+ return getUIPortalApplication().getCurrentSite();
}
static public UIPortalToolPanel getUIPortalToolPanel()
@@ -121,56 +120,6 @@
return uiWork;
}
- static public void showPortalComponentLayoutMode(UIPortalApplication uiPortalApp)
- {
- UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
- uiWorkingWS.setRenderedChild(UIPortal.class);
- UIPortal uiPortal = uiWorkingWS.findFirstComponentOfType(UIPortal.class);
-
- UIContainer uiContainer = Util.findUIComponent(uiPortal, UIContainer.class, UIPage.class);
- UIPage uiPage = uiPortal.findFirstComponentOfType(UIPage.class);
- UIPortlet uiPortlet = Util.findUIComponent(uiPortal, UIPortlet.class, UIPage.class);
-
- String name = "";
- if (uiContainer != null && uiContainer.isShowEditControl())
- name = "'UIContainer'";
- else if (uiPage != null && uiPage.isShowEditControl())
- name = "'UIPage'";
- else if (uiPortlet != null && uiPortlet.isShowEditControl())
- name = "'UIPortlet'";
-
- getPortalRequestContext().getJavascriptManager().addCustomizedOnLoadScript(
- "eXo.portal.UIPortal.showLayoutModeForPortal(" + name + ");");
- }
-
- // public UIPortlet getFirstUIPortlet(UIContainer uiContainer){
- // return
- // }
-
- // public UIContainer getFirstUIContainer(){
- // return (UIContainer)Util.findUIComponent(UIContainer uiContainer, UIContainer.class, UIPage.class);
- // }
-
- static public void showPageComponentLayoutMode(UIPortalApplication uiPortalApp)
- {
- UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
- uiWorkingWS.setRenderedChild(UIPortalToolPanel.class);
- UIPortalToolPanel uiPortalToolPanel = uiWorkingWS.findFirstComponentOfType(UIPortalToolPanel.class);
-
- UIPage uiPage = uiPortalToolPanel.findFirstComponentOfType(UIPage.class);
- UIContainer uiContainer = uiPage.findFirstComponentOfType(UIContainer.class);
- UIPortlet uiPortlet = uiPage.findFirstComponentOfType(UIPortlet.class);
-
- String name = "";
- if (uiContainer != null && uiContainer.isShowEditControl())
- name = "UIContainer";
- else if (uiPortlet != null && uiPortlet.isShowEditControl())
- name = "UIPortlet";
-
- getPortalRequestContext().getJavascriptManager().addCustomizedOnLoadScript(
- "eXo.portal.UIPortal.showLayoutModeForPage('" + name + "');");
- }
-
@SuppressWarnings("unchecked")
static public <T extends UIComponent> T findUIComponent(UIComponent uiComponent, Class<T> clazz, Class ignoreClazz)
{
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIMainActionListener.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIMainActionListener.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIMainActionListener.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -19,14 +19,12 @@
package org.exoplatform.portal.webui.workspace;
-import java.lang.reflect.Method;
-
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.config.UserPortalConfig;
import org.exoplatform.portal.config.UserPortalConfigService;
import org.exoplatform.portal.config.model.Page;
-import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.mop.navigation.Scope;
import org.exoplatform.portal.mop.user.UserNavigation;
import org.exoplatform.portal.mop.user.UserNode;
@@ -50,6 +48,8 @@
import org.exoplatform.webui.event.Event;
import org.exoplatform.webui.event.EventListener;
+import java.lang.reflect.Method;
+
/**
* Created by The eXo Platform SAS
*
@@ -87,8 +87,8 @@
UIPortalComposer portalComposer =
uiWorkingWS.findFirstComponentOfType(UIPortalComposer.class).setRendered(true);
- portalComposer.setComponentConfig(UIPortalComposer.class, "UIPageEditor");
- portalComposer.setId("UIPageEditor");
+ portalComposer.setComponentConfig(UIPortalComposer.class, UIPortalComposer.UIPAGE_EDITOR);
+ portalComposer.setId(UIPortalComposer.UIPAGE_EDITOR);
portalComposer.setShowControl(true);
portalComposer.setEditted(false);
portalComposer.setCollapse(false);
@@ -150,8 +150,8 @@
UIPortalComposer portalComposer = uiWorkingWS.findFirstComponentOfType(UIPortalComposer.class);
portalComposer.setRendered(false);
- portalComposer.setComponentConfig(UIPortalComposer.class, "UIPageEditor");
- portalComposer.setId("UIPageEditor");
+ portalComposer.setComponentConfig(UIPortalComposer.class, UIPortalComposer.UIPAGE_EDITOR);
+ portalComposer.setId(UIPortalComposer.UIPAGE_EDITOR);
portalComposer.setShowControl(true);
portalComposer.setEditted(true);
portalComposer.setCollapse(false);
@@ -171,7 +171,7 @@
{
UserNavigation currNav = selectedNode.getNavigation();
UserPortal userPortal = Util.getUIPortalApplication().getUserPortalConfig().getUserPortal();
- if (currNav.getKey().getTypeName().equals(PortalConfig.USER_TYPE))
+ if (currNav.getKey().getType().equals(SiteType.USER))
{
return userPortal.getNode(currNav, Scope.CHILDREN, filterConfig, null);
}
@@ -184,7 +184,7 @@
private UserNodeFilterConfig createFilterConfig()
{
UserNodeFilterConfig.Builder filterConfigBuilder = UserNodeFilterConfig.builder();
- filterConfigBuilder.withAuthorizationCheck();
+ filterConfigBuilder.withReadWriteCheck();
return filterConfigBuilder.build();
}
}
@@ -195,7 +195,7 @@
{
UIPortalApplication uiApp = Util.getUIPortalApplication();
- UIPortal uiPortal = uiApp.getShowedUIPortal();
+ UIPortal uiPortal = uiApp.getCurrentSite();
UserPortalConfigService service = uiApp.getApplicationComponent(UserPortalConfigService.class);
UserPortalConfig userConfig =
@@ -209,7 +209,7 @@
UIPortal currentUIPortal = portalApp.<UIWorkingWorkspace>findComponentById(
UIPortalApplication.UI_WORKING_WS_ID).findFirstComponentOfType(UIPortal.class);
UserACL userACL = portalApp.getApplicationComponent(UserACL.class);
- if(!userACL.hasEditPermissionOnPortal(currentUIPortal.getOwnerType(), currentUIPortal.getOwner(),
+ if(!userACL.hasEditPermissionOnPortal(currentUIPortal.getSiteType().getName(), currentUIPortal.getName(),
currentUIPortal.getEditPermission()))
{
uiApp.addMessage(new ApplicationMessage("UIPortalManagement.msg.Invalid-EditLayout-Permission",
@@ -223,7 +223,7 @@
uiApp.setModeState(UIPortalApplication.APP_BLOCK_EDIT_MODE);
UIPortal newPortal = uiWorkingWS.createUIComponent(UIPortal.class, null, null);
- PortalDataMapper.toUIPortal(newPortal, userConfig);
+ PortalDataMapper.toUIPortal(newPortal, userConfig.getPortalConfig());
// newPortal.setSelectedNode(uiPortal.getSelectedNode());
// newPortal.setNavigation(uiPortal.getNavigation());
// newPortal.setSelectedPath(uiPortal.getSelectedPath());
@@ -240,7 +240,7 @@
uiComposer.setShowControl(true);
uiComposer.setEditted(false);
uiComposer.setCollapse(false);
- uiComposer.setId("UIPortalComposer");
+ uiComposer.setId(UIPortalComposer.UIPORTAL_COMPOSER);
uiWorkingWS.setRenderedChild(UIEditInlineWorkspace.class);
pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -19,22 +19,21 @@
package org.exoplatform.portal.webui.workspace;
-import org.exoplatform.container.ExoContainer;
+import org.exoplatform.commons.utils.Safe;
import org.exoplatform.portal.Constants;
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.NoSuchDataException;
import org.exoplatform.portal.config.UserPortalConfig;
-import org.exoplatform.portal.config.UserPortalConfigService;
import org.exoplatform.portal.config.model.Container;
-import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.mop.SiteKey;
-import org.exoplatform.portal.mop.user.UserNode;
import org.exoplatform.portal.resource.Skin;
import org.exoplatform.portal.resource.SkinConfig;
import org.exoplatform.portal.resource.SkinService;
import org.exoplatform.portal.resource.SkinURL;
+import org.exoplatform.web.url.MimeType;
+import org.exoplatform.web.url.navigation.NodeURL;
import org.exoplatform.portal.webui.application.UIPortlet;
+import org.exoplatform.portal.webui.page.UIPageActionListener.ChangeNodeActionListener;
import org.exoplatform.portal.webui.page.UISiteBody;
import org.exoplatform.portal.webui.portal.PageNodeEvent;
import org.exoplatform.portal.webui.portal.UIPortal;
@@ -50,13 +49,17 @@
import org.exoplatform.web.application.javascript.JavascriptConfigService;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
+import org.exoplatform.webui.config.annotation.EventConfig;
import org.exoplatform.webui.core.UIApplication;
import org.exoplatform.webui.core.UIComponent;
import org.exoplatform.webui.core.UIComponentDecorator;
import org.exoplatform.webui.core.UIContainer;
import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.url.ComponentURL;
+import java.io.UnsupportedEncodingException;
import java.io.Writer;
+import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -68,6 +71,7 @@
import java.util.Map;
import java.util.Set;
+import javax.servlet.http.HttpServletResponse;
/**
* This extends the UIApplication and hence is a sibling of UIPortletApplication
@@ -78,7 +82,8 @@
* display the normal or webos portal layouts - UIPopupWindow: a popup window
* that display or not
*/
-@ComponentConfig(lifecycle = UIPortalApplicationLifecycle.class, template = "system:/groovy/portal/webui/workspace/UIPortalApplication.gtmpl")
+@ComponentConfig(lifecycle = UIPortalApplicationLifecycle.class, template = "system:/groovy/portal/webui/workspace/UIPortalApplication.gtmpl", events = {
+ @EventConfig(listeners = ChangeNodeActionListener.class)})
public class UIPortalApplication extends UIApplication
{
public static final int NORMAL_MODE = 0;
@@ -90,10 +95,14 @@
public static final int CONTAINER_BLOCK_EDIT_MODE = 3;
public static final int CONTAINER_VIEW_EDIT_MODE = 4;
+
+ public static final UIComponent EMPTY_COMPONENT = new UIComponent(){
+ public String getId() { return "{portal:componentId}"; };
+ };
private int modeState = NORMAL_MODE;
- private String nodePath_;
+ private String lastRequestURI;
private Orientation orientation_ = Orientation.LT;
@@ -105,15 +114,19 @@
final static public String UI_MASK_WS_ID = "UIMaskWorkspace";
- private String skin_ = "Default";
+ private String skin_ = SkinService.DEFAULT_SKIN;
- private UserPortalConfig userPortalConfig_;
-
private boolean isSessionOpen = false;
private Map<SiteKey, UIPortal> all_UIPortals;
- private UIPortal showedUIPortal;
+ private UIPortal currentSite;
+
+ private boolean isAjaxInLastRequest;
+
+ private String lastNonAjaxRequestUri;
+
+ private String lastPortal;
/**
* The constructor of this class is used to build the tree of UI components
@@ -133,18 +146,16 @@
{
log = ExoLogger.getLogger("portal:UIPortalApplication");
PortalRequestContext context = PortalRequestContext.getCurrentInstance();
+
+// userPortalConfig_ = (UserPortalConfig)context.getAttribute(UserPortalConfig.class);
+// if (userPortalConfig_ == null)
+// throw new Exception("Can't load user portal config");
- userPortalConfig_ = (UserPortalConfig)context.getAttribute(UserPortalConfig.class);
- if (userPortalConfig_ == null)
- throw new Exception("Can't load user portal config");
-
- // Get portal skin
- this.reloadSkinPortal(context);
-
// dang.tung - set portal language by user preference -> browser ->
// default
// ------------------------------------------------------------------------------
LocaleConfigService localeConfigService = getApplicationComponent(LocaleConfigService.class);
+
Locale locale = context.getLocale();
if (locale == null)
{
@@ -168,11 +179,7 @@
this.all_UIPortals = new HashMap<SiteKey, UIPortal>(5);
- addWorkingWorkspace();
-
- setOwner(context.getPortalOwner());
-
- //Minh Hoang TO: Localizes navigations, need to put this code snippet below 'setLocale' block
+ initWorkspaces();
}
/**
@@ -180,28 +187,28 @@
*
* @param uiPortal
*/
- public void setShowedUIPortal(UIPortal uiPortal)
+ public void setCurrentSite(UIPortal uiPortal)
{
- this.showedUIPortal = uiPortal;
+ this.currentSite = uiPortal;
UISiteBody siteBody = this.findFirstComponentOfType(UISiteBody.class);
- if(siteBody != null)
+ if (siteBody != null)
{
//TODO: Check this part carefully
siteBody.setUIComponent(uiPortal);
}
}
-
+
/**
* Returns current UIPortal which being showed in normal mode
*
* @return
*/
- public UIPortal getShowedUIPortal()
+ public UIPortal getCurrentSite()
{
- return showedUIPortal;
+ return currentSite;
}
-
+
/**
* Returns a cached UIPortal matching to OwnerType and OwnerId if any
*
@@ -211,7 +218,7 @@
*/
public UIPortal getCachedUIPortal(String ownerType, String ownerId)
{
- if(ownerType == null || ownerId == null)
+ if (ownerType == null || ownerId == null)
{
return null;
}
@@ -226,7 +233,7 @@
}
return this.all_UIPortals.get(key);
}
-
+
/**
* Associates the specified UIPortal to a cache map with specified key which bases on OwnerType and OwnerId
*
@@ -234,15 +241,14 @@
*/
public void putCachedUIPortal(UIPortal uiPortal)
{
- String ownerType = uiPortal.getOwnerType();
- String ownerId = uiPortal.getOwner();
-
- if(ownerType != null && ownerId != null)
+ SiteKey siteKey = uiPortal.getSiteKey();
+
+ if (siteKey != null)
{
- this.all_UIPortals.put(new SiteKey(ownerType, ownerId), uiPortal);
+ this.all_UIPortals.put(siteKey, uiPortal);
}
}
-
+
/**
* Remove the UIPortal from the cache map
*
@@ -251,13 +257,13 @@
*/
public void removeCachedUIPortal(String ownerType, String ownerId)
{
- if(ownerType == null || ownerId == null)
+ if (ownerType == null || ownerId == null)
{
return;
}
this.all_UIPortals.remove(new SiteKey(ownerType, ownerId));
}
-
+
public boolean isSessionOpen()
{
return isSessionOpen;
@@ -293,6 +299,11 @@
return modeState;
}
+ public void setLastRequestURI(String uri)
+ {
+ this.lastRequestURI = uri;
+ }
+
/**
* @deprecated use the Mode State instead
*
@@ -434,14 +445,14 @@
String portletId = portlet.getSkinId();
if (portletId != null)
{
- return getSkin(portletId, "Default");
+ return getSkin(portletId, SkinService.DEFAULT_SKIN);
}
else
{
return null;
}
}
-
+
private SkinConfig getPortletSkinConfig(UIPortlet portlet)
{
String portletId = portlet.getSkinId();
@@ -454,7 +465,7 @@
return null;
}
}
-
+
/**
* The central area is called the WorkingWorkspace. It is composed of: 1) A
* UIPortal child which is filled with portal data using the PortalDataMapper
@@ -463,7 +474,7 @@
*
* @throws Exception
*/
- private void addWorkingWorkspace() throws Exception
+ private void initWorkspaces() throws Exception
{
UIWorkingWorkspace uiWorkingWorkspace =
addChild(UIWorkingWorkspace.class, UIPortalApplication.UI_WORKING_WS_ID, null);
@@ -471,12 +482,7 @@
DataStorage dataStorage = getApplicationComponent(DataStorage.class);
Container container = dataStorage.getSharedLayout();
- UIPortal uiPortal = createUIComponent(UIPortal.class, null, null);
- PortalDataMapper.toUIPortal(uiPortal, userPortalConfig_);
-
- this.putCachedUIPortal(uiPortal);
- this.showedUIPortal = uiPortal;
-
+
uiWorkingWorkspace.addChild(UIEditInlineWorkspace.class, null, UI_EDITTING_WS_ID).setRendered(false);
if (container != null)
{
@@ -484,46 +490,95 @@
createUIComponent(org.exoplatform.portal.webui.container.UIContainer.class, null, null);
uiContainer.setStorageId(container.getStorageId());
PortalDataMapper.toUIContainer(uiContainer, container);
- UISiteBody uiSiteBody = uiContainer.findFirstComponentOfType(UISiteBody.class);
- //uiSiteBody.setUIComponent(uiPortal);
- uiSiteBody.setUIComponent(this.showedUIPortal);
uiContainer.setRendered(true);
uiViewWS.setUIComponent(uiContainer);
}
- else
+ addChild(UIMaskWorkspace.class, UIPortalApplication.UI_MASK_WS_ID, null);
+ }
+
+ @Override
+ public void processDecode(WebuiRequestContext context) throws Exception
+ {
+ PortalRequestContext prc = (PortalRequestContext)context;
+ String portalName = prc.getUserPortalConfig().getPortalName();
+ if (!Safe.equals(portalName, lastPortal))
{
- //uiViewWS.setUIComponent(uiPortal);
- uiViewWS.setUIComponent(this.showedUIPortal);
+ reloadPortalProperties();
+ lastPortal = portalName;
}
- // uiWorkingWorkspace.addChild(UIPortalToolPanel.class, null,
- // null).setRendered(false);
- // editInlineWS.addChild(UIPortalToolPanel.class, null,
- // null).setRendered(false);
- addChild(UIMaskWorkspace.class, UIPortalApplication.UI_MASK_WS_ID, null);
+ super.processDecode(context);
}
-
+
/**
- * The processDecode() method is doing 3 actions:
- * 1) if the nodePath is null (case of the first request) a call to
- * super.processDecode(context) is made and we end the method here
+ * The processAction() method is doing 3 actions: <br/>
+ * 1) if this is a non ajax request and the last is an ajax one,
+ * then we check if the requested nodePath is equal to last non ajax nodePath and
+ * is not equal to the last nodePath, the server performs a 302 redirect on the last nodePath.<br/>
* 2) if the nodePath exist but is equals to the current one
- * then we also call super and stops here
+ * then we also call super and stops here.<br/>
* 3) if the requested nodePath is not equals to the current one or current
- * page no longer exists, then an event of type PageNodeEvent.CHANGE_PAGE_NODE
- * is sent to the associated EventListener; a call to super is then done
+ * page no longer exists, then an event of type PageNodeEvent.CHANGE_NODE
+ * is sent to the associated EventListener; a call to super is then done.
*/
- public void processDecode(WebuiRequestContext context) throws Exception
+ @Override
+ public void processAction(WebuiRequestContext context) throws Exception
{
PortalRequestContext pcontext = (PortalRequestContext)context;
- String nodePath = pcontext.getNodePath().trim();
+ String requestURI = pcontext.getRequestURI();
+ boolean isAjax = pcontext.useAjax();
+
+ if (!isAjax)
+ {
+ if (isAjaxInLastRequest)
+ {
+ isAjaxInLastRequest = false;
+ if (requestURI.equals(lastNonAjaxRequestUri) && !requestURI.equals(lastRequestURI))
+ {
+ NodeURL nodeURL = pcontext.createURL(NodeURL.TYPE).setNode(getCurrentSite().getSelectedUserNode());
+ pcontext.sendRedirect(nodeURL.toString());
+ return;
+ }
+ }
+ lastNonAjaxRequestUri = requestURI;
+ }
+
+ isAjaxInLastRequest = isAjax;
+
+ if (!requestURI.equals(lastRequestURI))
+ {
+ lastRequestURI = requestURI;
+
+ StringBuilder js = new StringBuilder("eXo.env.server.portalBaseURL=\"");
+ js.append(pcontext.getRequestURI()).append("\";\n");
+
+ String url = getPortalURLTemplate();
+ js.append("eXo.env.server.portalURLTemplate=\"");
+ js.append(url).append("\";");
+
+ pcontext.getJavascriptManager().addCustomizedOnLoadScript(js.toString());
+
+ SiteKey siteKey = new SiteKey(pcontext.getSiteType(), pcontext.getSiteName());
+ PageNodeEvent<UIPortalApplication> pnevent =
+ new PageNodeEvent<UIPortalApplication>(this, PageNodeEvent.CHANGE_NODE, siteKey, pcontext.getNodePath());
+ broadcast(pnevent, Event.Phase.PROCESS);
+ }
+
+ if (!isAjax)
+ {
+ lastNonAjaxRequestUri = requestURI;
+ }
- if (!nodePath.equals(nodePath_) || !isPageExist())
+ if (pcontext.isResponseComplete())
{
- nodePath_ = nodePath;
- PageNodeEvent<UIPortal> pnevent = new PageNodeEvent<UIPortal>(showedUIPortal, PageNodeEvent.CHANGE_PAGE_NODE, nodePath_);
- showedUIPortal.broadcast(pnevent, Event.Phase.PROCESS);
+ return;
}
- super.processDecode(context);
+
+ if (currentSite == null || currentSite.getSelectedUserNode() == null)
+ {
+ pcontext.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+
+ super.processAction(pcontext);
}
/**
@@ -674,50 +729,36 @@
return b.toString();
}
+ /**
+ * Use {@link PortalRequestContext#getUserPortalConfig()} instead
+ *
+ * @return
+ */
+ @Deprecated
public UserPortalConfig getUserPortalConfig()
{
- return userPortalConfig_;
+ return Util.getPortalRequestContext().getUserPortalConfig();
}
+ /**
+ * Use {@link PortalRequestContext#setUserPortalConfig(UserPortalConfig)} instead
+ *
+ * @return
+ */
+ @Deprecated
public void setUserPortalConfig(UserPortalConfig userPortalConfig)
{
- this.userPortalConfig_ = userPortalConfig;
+ Util.getPortalRequestContext().setUserPortalConfig(userPortalConfig);
}
-
- private boolean isPageExist() throws Exception
- {
- WebuiRequestContext context = Util.getPortalRequestContext();
- ExoContainer appContainer = context.getApplication().getApplicationServiceContainer();
- UserPortalConfigService userPortalConfigService =
- (UserPortalConfigService)appContainer.getComponentInstanceOfType(UserPortalConfigService.class);
- Page page = null;
- UserNode pageNode = Util.getUIPortal().getSelectedUserNode();
- if (pageNode != null)
- {
- try
- {
- if (pageNode.getPageRef() != null)
- {
- page = userPortalConfigService.getPage(pageNode.getPageRef(), context.getRemoteUser());
- }
- }
- catch (NoSuchDataException nsde)
- {
- return false;
- }
- }
- return (page != null);
- }
/**
- * Get portal skin from {@link UserProfile} or from {@link UserPortalConfig}
+ * Reload portal properties. This is needed to be called when it is changing Portal site
*
- * @param context PortalRequestContext
- * @throws Exception
- *
+ * @throws Exception
*/
- public void reloadSkinPortal(PortalRequestContext context) throws Exception
+ public void reloadPortalProperties() throws Exception
{
+ PortalRequestContext context = Util.getPortalRequestContext();
String user = context.getRemoteUser();
String portalSkin = null;
OrganizationService orgService = getApplicationComponent(OrganizationService.class);
@@ -743,10 +784,31 @@
}
else
{
- UserPortalConfig userPortalConfig = (UserPortalConfig)context.getAttribute(UserPortalConfig.class);
- String userPortalConfigSkin = userPortalConfig .getPortalConfig().getSkin();
+ String userPortalConfigSkin = context.getUserPortalConfig().getPortalConfig().getSkin();
if (userPortalConfigSkin != null && userPortalConfigSkin.trim().length() > 0)
skin_ = userPortalConfigSkin;
}
}
+
+ /**
+ * Return the portal url template which will be sent to client ( browser )
+ * and used for JS based portal url generation.
+ *
+ * <p>The portal url template are calculated base on the current request and site state.
+ * Something like : <code>"/portal/groups/:platform:administrators/administration/registry?portal:componentId={portal:uicomponentId}&portal:action={portal:action}" ;</code>
+ *
+ * @return return portal url template
+ * @throws UnsupportedEncodingException
+ */
+ public String getPortalURLTemplate() throws UnsupportedEncodingException
+ {
+ PortalRequestContext pcontext = Util.getPortalRequestContext();
+ ComponentURL urlTemplate = pcontext.createURL(ComponentURL.TYPE);
+ urlTemplate.setMimeType(MimeType.PLAIN);
+ urlTemplate.setPath(pcontext.getNodePath());
+ urlTemplate.setResource(EMPTY_COMPONENT);
+ urlTemplate.setAction("{portal:action}");
+
+ return URLDecoder.decode(urlTemplate.toString(), "UTF-8");
+ }
}
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplicationLifecycle.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplicationLifecycle.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplicationLifecycle.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -51,8 +51,13 @@
return;
}
if (uiTarget == uicomponent)
- super.processDecode(uicomponent, context);
- uiTarget.processDecode(context);
+ {
+ super.processDecode(uicomponent, context);
+ }
+ else
+ {
+ uiTarget.processDecode(context);
+ }
}
/**
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/test/java/org/exoplatform/portal/webui/test/ComponentConfigConcurrentTest.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/test/java/org/exoplatform/portal/webui/test/ComponentConfigConcurrentTest.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/test/java/org/exoplatform/portal/webui/test/ComponentConfigConcurrentTest.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -22,6 +22,11 @@
******************************************************************************/
package org.exoplatform.portal.webui.test;
+import org.exoplatform.component.test.AbstractGateInTest;
+import org.exoplatform.portal.webui.portal.UIPortal;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.config.Event;
+
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
@@ -29,12 +34,6 @@
import java.util.List;
import java.util.Map;
-import org.exoplatform.portal.webui.portal.PageNodeEvent;
-import org.exoplatform.portal.webui.portal.UIPortal;
-import org.exoplatform.webui.config.Event;
-
-import org.exoplatform.component.test.AbstractGateInTest;
-
/**
* Unit test for concurrent read of event from UI component configuration.
*
@@ -102,8 +101,8 @@
{
try
{
- UIPortal uiPortal = mockApplication.createUIComponent(UIPortal.class, null, null, null);
- eventConfig = uiPortal.getComponentConfig().getUIComponentEventConfig(PageNodeEvent.CHANGE_PAGE_NODE);
+ UIPortal uiPortal = mockApplication.createUIComponent(UIPortal.class, null, null, null);
+ eventConfig = uiPortal.getComponentConfig().getUIComponentEventConfig("Ping");
// log message now if eventConfig is null, so that we know about all failed workers. Test will be failed later.
if (eventConfig == null)
@@ -114,7 +113,8 @@
catch (Exception e)
{
log.error("Exception occured during concurrent test in worker " + getName(), e);
- }
+ }
+
}
}
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplication.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplication.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplication.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -353,10 +353,9 @@
}
else
{
- context = new PortletRequestContext(this, w, req, res);
+ context = new PortletRequestContext(parentAppRequestContext, this, w, req, res);
parentAppRequestContext.setAttribute(attributeName, context);
}
- context.setParentAppRequestContext(parentAppRequestContext);
return context;
}
}
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -19,6 +19,18 @@
package org.exoplatform.webui.application.portlet;
+import org.exoplatform.commons.utils.WriterPrinter;
+import org.exoplatform.services.resources.Orientation;
+import org.exoplatform.web.application.RequestContext;
+import org.exoplatform.web.application.URLBuilder;
+import org.exoplatform.web.url.URLFactory;
+import org.exoplatform.web.url.ResourceType;
+import org.exoplatform.web.url.PortalURL;
+import org.exoplatform.webui.application.WebuiApplication;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.core.UIApplication;
+import org.exoplatform.webui.core.UIComponent;
+
import java.io.Writer;
import javax.portlet.ActionResponse;
@@ -29,15 +41,10 @@
import javax.portlet.PortletResponse;
import javax.portlet.StateAwareResponse;
-import org.exoplatform.commons.utils.WriterPrinter;
-import org.exoplatform.services.resources.Orientation;
-import org.exoplatform.web.application.URLBuilder;
-import org.exoplatform.webui.application.WebuiApplication;
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.webui.core.UIApplication;
-import org.exoplatform.webui.core.UIComponent;
-
/**
+ * todo (julien) : there is an issue here (small) as the PRC seems to be stored in http session
+ * and keep a pointer on request and response object.
+ *
* The request context of a portlet
*
*/
@@ -62,15 +69,20 @@
private boolean hasProcessAction_ = false;
- private final PortletURLBuilder urlBuilder;
+ /** . */
+ private PortletURLBuilder urlBuilder;
- public PortletRequestContext(WebuiApplication app, Writer writer, PortletRequest req, PortletResponse res)
+ public PortletRequestContext(RequestContext parentAppRequestContext, WebuiApplication app, Writer writer, PortletRequest req, PortletResponse res)
{
- super(app);
+ super(parentAppRequestContext, app);
init(writer, req, res);
setSessionId(req.getPortletSession(true).getId());
+ }
- urlBuilder = new PortletURLBuilder();
+ @Override
+ public <R, U extends PortalURL<R, U>> U newURL(ResourceType<R, U> resourceType, URLFactory urlFactory)
+ {
+ return parentAppRequestContext_.newURL(resourceType, urlFactory);
}
public void init(Writer writer, PortletRequest req, PortletResponse res)
@@ -79,6 +91,16 @@
response_ = res;
writer_ = new WriterPrinter(writer);
windowId_ = req.getWindowID();
+
+ //
+ if (res instanceof MimeResponse)
+ {
+ this.urlBuilder = new PortletURLBuilder(((MimeResponse)res).createActionURL());
+ }
+ else
+ {
+ this.urlBuilder = null;
+ }
}
public void setUIApplication(UIApplication uiApplication) throws Exception
@@ -132,6 +154,12 @@
return response_;
}
+ @Override
+ public URLFactory getURLFactory()
+ {
+ return parentAppRequestContext_.getURLFactory();
+ }
+
public String getRemoteUser()
{
return parentAppRequestContext_.getRemoteUser();
@@ -195,8 +223,10 @@
public URLBuilder<UIComponent> getURLBuilder()
{
- MimeResponse renderRes = (MimeResponse)response_;
- urlBuilder.setBaseURL(renderRes.createActionURL().toString());
+ if (urlBuilder == null)
+ {
+ throw new IllegalStateException("Cannot create portlet URL during action/event phase");
+ }
return urlBuilder;
}
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletURLBuilder.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletURLBuilder.java 2011-08-18 21:10:07 UTC (rev 7182)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletURLBuilder.java 2011-08-18 21:24:33 UTC (rev 7183)
@@ -24,61 +24,81 @@
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.core.UIComponent;
+import javax.portlet.PortletURL;
+
/**
- * julien todo : use PortletURL parameter instead of appending them to the url returned by the PortletURL
- *
* Created by The eXo Platform SAS
* Apr 3, 2007
*/
public class PortletURLBuilder extends URLBuilder<UIComponent>
{
- private static final String AMP = "&";
- private static final char EQUALS = '=';
- public PortletURLBuilder()
- {
- super(null);
- }
+ /** . */
+ private final PortletURL url;
- public PortletURLBuilder(String baseURL)
+ public PortletURLBuilder(PortletURL url)
{
- super(baseURL);
+ this.url = url;
}
- public String createURL(String action, Parameter[] params)
+ public String createAjaxURL(UIComponent targetComponent, String action, String confirm, String targetBeanId, Parameter[] params)
{
- return null;
+ return createURL(true, confirm, targetComponent, action, targetBeanId, params);
}
- public String createURL(String action, String objectId, Parameter[] params)
+ public String createURL(UIComponent targetComponent, String action, String confirm, String targetBeanId, Parameter[] params)
{
- return null;
+ return createURL(false, confirm, targetComponent, action, targetBeanId, params);
}
- protected void createURL(StringBuilder builder, UIComponent targetComponent, String action, String targetBeanId,
+ private String createURL(
+ boolean ajax,
+ String confirm,
+ UIComponent targetComponent, String action, String targetBeanId,
Parameter[] params)
{
- String baseUrl = getBaseURL();
- builder.append(baseUrl).append(AMP).append(UIComponent.UICOMPONENT).append(EQUALS).append(
- targetComponent.getId());
+ // Clear URL
+ url.getParameterMap().clear();
+ //
+ url.setProperty("gtn:ajax", Boolean.toString(ajax));
+ url.setProperty("gtn:confirm", confirm);
+
+ //
+ url.setParameter(UIComponent.UICOMPONENT, targetComponent.getId());
+
+ //
if (action != null && action.trim().length() > 0)
{
- builder.append(AMP).append(WebuiRequestContext.ACTION).append(EQUALS).append(action);
+ url.setParameter(WebuiRequestContext.ACTION, action);
}
+ //
if (targetBeanId != null && targetBeanId.trim().length() > 0)
{
- builder.append(AMP).append(UIComponent.OBJECTID).append(EQUALS).append(targetBeanId);
+ url.setParameter(UIComponent.OBJECTID, targetBeanId);
}
- if (params == null || params.length < 1)
- return;
- for (Parameter param : params)
+ //
+ if (params != null && params.length > 0)
{
- builder.append(AMP).append(param.getName()).append(EQUALS).append(param.getValue());
+ for (Parameter param : params)
+ {
+ url.setParameter(param.getName(), param.getValue());
+ }
}
+ //
+ if (removeLocale)
+ {
+ url.setProperty("gtn:lang", "");
+ }
+ else if (locale != null)
+ {
+ url.setProperty("gtn:lang", locale.toString());
+ }
+
+ //
+ return url.toString();
}
-
}
13 years, 4 months
gatein SVN: r7182 - in epp/portal/branches/EPP_5_2_Branch: web/portal/src/main/webapp/groovy/portal/webui/application and 6 other directories.
by do-not-reply@jboss.org
Author: theute
Date: 2011-08-18 17:10:07 -0400 (Thu, 18 Aug 2011)
New Revision: 7182
Modified:
epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIContainer.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableAutofitColumnContainer.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableColumnContainer.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIToolbarContainer.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalComposer.gtmpl
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletForm.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerForm.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java
Log:
reapplying rollback of r7181
Modified: epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js 2011-08-18 20:46:44 UTC (rev 7181)
+++ epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js 2011-08-18 21:10:07 UTC (rev 7182)
@@ -196,6 +196,38 @@
DragDrop.dropCallback = function(dndEvent) {
this.origDragObjectStyle.setProperties(dndEvent.dragObject.style, false) ;
+
+ var hasChanged = true;
+ //When press esc key, we want to cancel the dragdrop, but now it only works with FF
+ if (dndEvent.backupMouseEvent && dndEvent.backupMouseEvent.keyCode == 27 && eXo.core.Browser.isFF()) {
+ hasChanged = false;
+ }
+ //When dragObject is outside
+ var targetElement = dndEvent.foundTargetObject;
+ if(!targetElement || targetElement.foundIndex == null) {
+ hasChanged = false;
+ }
+ //When dragobject is next to preview object (position is not changed)
+ if(!dndEvent.dragObject.isAddingNewly) {
+ var DOMUtil = eXo.core.DOMUtil;
+ var previewClass = "DragAndDropPreview";
+ var previewTagName = "div";
+ var previewSibling = dndEvent.dragObject;
+ if (dndEvent.dragObject.parentNode.tagName.toLowerCase() == "td") {
+ previewSibling = dndEvent.dragObject.parentNode;
+ previewClass = "PreviewTDBlock";
+ previewTagName = "td";
+ }
+ var tempObj = DOMUtil.findNextElementByTagName(previewSibling, previewTagName);
+ if (tempObj != null && tempObj.className == previewClass) {
+ hasChanged = false;
+ } else {
+ tempObj = DOMUtil.findPreviousElementByTagName(previewSibling, previewTagName);
+ if (tempObj != null && tempObj.className == previewClass) {
+ hasChanged = false;
+ }
+ }
+ }
if(dndEvent.foundTargetObject != null || (dndEvent.backupMouseEvent && dndEvent.backupMouseEvent.keyCode != 27)) {
eXo.portal.PortalDragDrop.doDropCallback(dndEvent) ;
@@ -219,7 +251,9 @@
previewBlock = previewTD = null;
eXo.portal.isInDragging = false;
- eXo.portal.UIPortal.changeComposerSaveButton();
+ if (hasChanged) {
+ eXo.portal.UIPortal.changeComposerSaveButton();
+ }
// fix bug WEBOS-196
dndEvent.dragObject.style.width = "auto" ;
};
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2011-08-18 20:46:44 UTC (rev 7181)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
@@ -263,7 +263,7 @@
%>
<div class="PortletIcon $portletIcon"><%=hasPermission ? title : _ctx.appRes("UIPortlet.label.protectedContent")%></div>
<%if(hasPermission) {%>
- <a href="<%=uicomponent.event("EditPortlet","$uicomponent.id")%>;eXo.portal.UIPortal.changeComposerSaveButton()" class="EditPortletPropertiesIcon" title="<%=_ctx.appRes("UIPortlet.tooltip.editPortlet");%>"></a>
+ <a href="<%=uicomponent.event("EditPortlet","$uicomponent.id")%>;" class="EditPortletPropertiesIcon" title="<%=_ctx.appRes("UIPortlet.tooltip.editPortlet");%>"></a>
<a href="<%=uicomponent.event("DeleteComponent","$uicomponent.id")%>" class="DeletePortletIcon" title="<%=_ctx.appRes("UIPortlet.tooltip.deletePortlet");%>"></a>
<%}%>
</div>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIContainer.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIContainer.gtmpl 2011-08-18 20:46:44 UTC (rev 7181)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIContainer.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
@@ -42,9 +42,9 @@
<div class="VIEW-CONTAINER VIEW-BLOCK">
<%} %>
<%if(hasPermission) {%>
- <div class="UIRowContainer <%=(portalMode != UIPortalApplication.NORMAL_MODE && uicomponent.getChildren().size() == 0) ? "EmptyContainer" : ""%>">
- <div>
- <%uicomponent.renderChildren();%>
+ <div>
+ <div class="UIRowContainer <%=(portalMode != UIPortalApplication.NORMAL_MODE && uicomponent.getChildren().size() == 0) ? "EmptyContainer" : ""%>">
+ <%uicomponent.renderChildren();%>
</div>
</div>
<%} else out.print("<div class='ProtectedContent'>"+_ctx.appRes("UIPortlet.label.protectedContent")+"</div>");%>
@@ -72,7 +72,7 @@
%>
<div class="ContainerIcon"><%=hasPermission ? strTitle : _ctx.appRes("UIPortlet.label.protectedContent")%></div>
<%if(hasPermission) {%>
- <a href="<%=uicomponent.event("EditContainer")%>;eXo.portal.UIPortal.changeComposerSaveButton()" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
+ <a href="<%=uicomponent.event("EditContainer")%>" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
<a href="<%=uicomponent.event("DeleteComponent")%>" class="DeleteContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.closeContainer")%>"><span></span></a>
<%}%>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableAutofitColumnContainer.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableAutofitColumnContainer.gtmpl 2011-08-18 20:46:44 UTC (rev 7181)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableAutofitColumnContainer.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
@@ -73,7 +73,7 @@
%>
<div class="ContainerIcon DefaultContainer16x16Icon"><%=hasPermission ? strTitle : _ctx.appRes("UIPortlet.label.protectedContent")%></div>
<%if(hasPermission) {%>
- <a href="<%=uicomponent.event("EditContainer","$uicomponent.id")%>;eXo.portal.UIPortal.changeComposerSaveButton()" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
+ <a href="<%=uicomponent.event("EditContainer","$uicomponent.id")%>" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
<a href="<%=uicomponent.event("DeleteComponent","$uicomponent.id")%>" class="DeleteContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.closeContainer")%>"><span></span></a>
<%}%>
</div>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableColumnContainer.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableColumnContainer.gtmpl 2011-08-18 20:46:44 UTC (rev 7181)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableColumnContainer.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
@@ -73,7 +73,7 @@
%>
<div class="ContainerIcon DefaultContainer16x16Icon"><%=hasPermission ? strTitle : _ctx.appRes("UIPortlet.label.protectedContent")%></div>
<%if(hasPermission) {%>
- <a href="<%=uicomponent.event("EditContainer","$uicomponent.id")%>;eXo.portal.UIPortal.changeComposerSaveButton()" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
+ <a href="<%=uicomponent.event("EditContainer","$uicomponent.id")%>" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
<a href="<%=uicomponent.event("DeleteComponent","$uicomponent.id")%>" class="DeleteContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.closeContainer")%>"><span></span></a>
<%}%>
</div>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIToolbarContainer.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIToolbarContainer.gtmpl 2011-08-18 20:46:44 UTC (rev 7181)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIToolbarContainer.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
@@ -70,7 +70,7 @@
%>
<div class="ContainerIcon DefaultContainer16x16Icon"><%=hasPermission ? strTitle : _ctx.appRes("UIPortlet.label.protectedContent")%></div>
<%if(hasPermission) {%>
- <a href="<%=uicomponent.event("EditContainer","$uicomponent.id")%>;eXo.portal.UIPortal.changeComposerSaveButton()" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
+ <a href="<%=uicomponent.event("EditContainer","$uicomponent.id")%>;" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
<a href="<%=uicomponent.event("DeleteComponent","$uicomponent.id")%>" class="DeleteContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.closeContainer")%>"><span></span></a>
<%}%>
</div>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalComposer.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalComposer.gtmpl 2011-08-18 20:46:44 UTC (rev 7181)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalComposer.gtmpl 2011-08-18 21:10:07 UTC (rev 7182)
@@ -52,7 +52,7 @@
<tr>
<td>
- <div onclick="<%= uicomponent.event("ViewProperties") %>;eXo.portal.UIPortal.changeComposerSaveButton()" class="ActionButton SimpleStyle1">
+ <div onclick="<%= uicomponent.event("ViewProperties") %>;" class="ActionButton SimpleStyle1">
<div class="ButtonLeft">
<div class="ButtonRight">
<div class="ButtonMiddle">
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletForm.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletForm.java 2011-08-18 20:46:44 UTC (rev 7181)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletForm.java 2011-08-18 21:10:07 UTC (rev 7182)
@@ -397,6 +397,7 @@
}
PortalRequestContext pcontext = (PortalRequestContext)event.getRequestContext();
+ pcontext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
pcontext.addUIComponentToUpdateByAjax(uiMaskWorkspace);
UIPortalApplication uiPortalApp = uiPortlet.getAncestorOfType(UIPortalApplication.class);
UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerForm.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerForm.java 2011-08-18 20:46:44 UTC (rev 7181)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerForm.java 2011-08-18 21:10:07 UTC (rev 7182)
@@ -143,6 +143,7 @@
UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
+ pcontext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
pcontext.ignoreAJAXUpdateOnPortlets(true);
Util.showComponentLayoutMode(UIContainer.class);
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java 2011-08-18 20:46:44 UTC (rev 7181)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java 2011-08-18 21:10:07 UTC (rev 7182)
@@ -35,6 +35,8 @@
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.webui.application.UIPortlet;
import org.exoplatform.portal.webui.container.UIContainer;
+import org.exoplatform.portal.webui.portal.UIPortal;
+import org.exoplatform.portal.webui.portal.UIPortalComponent;
import org.exoplatform.portal.webui.portal.UIPortalComposer;
import org.exoplatform.portal.webui.util.PortalDataMapper;
import org.exoplatform.portal.webui.util.Util;
@@ -83,6 +85,8 @@
protected UIFormInputSet uiPermissionSetting;
protected UIFormSelectBox groupIdSelectBox = null;
+
+ protected UIFormSelectBox portalIdSelectBox = null;
protected UIFormStringInput ownerIdInput = null;
@@ -99,14 +103,6 @@
List<SelectItemOption<String>> ownerTypes = new ArrayList<SelectItemOption<String>>();
ownerTypes.add(new SelectItemOption<String>(PortalConfig.USER_TYPE));
- UserPortalConfig userPortalConfig =
- configService.getUserPortalConfig(pcontext.getPortalOwner(), pcontext.getRemoteUser());
- ExoContainer container = ExoContainerContext.getCurrentContainer();
- UserACL acl = (UserACL)container.getComponentInstanceOfType(UserACL.class);
- if (acl.hasEditPermission(userPortalConfig.getPortalConfig()))
- {
- ownerTypes.add(new SelectItemOption<String>(PortalConfig.PORTAL_TYPE));
- }
ownerIdInput = new UIFormStringInput(OWNER_ID, OWNER_ID, null);
ownerIdInput.setEditable(false).setValue(pcontext.getRemoteUser());
@@ -146,6 +142,27 @@
//TODO: This following line is fixed for bug PORTAL-2127
uiListPermissionSelector.getChild(UIFormPopupWindow.class).setId("UIPageFormPopupGroupMembershipSelector");
+ List<String> portals = configService.getAllPortalNames();
+ Collections.sort(portals);
+ List<SelectItemOption<String>> portalsItem = new ArrayList<SelectItemOption<String>>();
+ ExoContainer container = ExoContainerContext.getCurrentContainer();
+ UserACL acl = (UserACL)container.getComponentInstanceOfType(UserACL.class);
+ for (String p : portals)
+ {
+ UserPortalConfig userPortalConfig = configService.getUserPortalConfig(p, pcontext.getRemoteUser());
+ if (acl.hasEditPermission(userPortalConfig.getPortalConfig()))
+ {
+ portalsItem.add(new SelectItemOption<String>(p));
+ }
+ }
+ if(portalsItem.size() > 0)
+ {
+ ownerTypes.add(new SelectItemOption<String>(PortalConfig.PORTAL_TYPE));
+ portalIdSelectBox = new UIFormSelectBox(OWNER_ID, OWNER_ID, portalsItem);
+ portalIdSelectBox.setOnChange("ChangeOwnerId");
+ portalIdSelectBox.setParent(uiSettingSet);
+ }
+
List<String> groups = configService.getMakableNavigations(pcontext.getRemoteUser(), true);
if (groups.size() > 0)
{
@@ -160,6 +177,7 @@
groupIdSelectBox.setOnChange("ChangeOwnerId");
groupIdSelectBox.setParent(uiSettingSet);
}
+
setActions(new String[]{"Save", "Close"});
}
@@ -201,11 +219,6 @@
uiTemplate.setValue(uiPage.getFactoryId());
}
- public void setEditPermission(String per)
- {
-
- }
-
public void invokeSetBindingBean(Object bean) throws Exception
{
String ownerType = getUIFormSelectBox("ownerType").getValue();
@@ -268,7 +281,7 @@
PortalRequestContext pcontext = Util.getPortalRequestContext();
UIMaskWorkspace uiMaskWS = uiPortalApp.getChildById(UIPortalApplication.UI_MASK_WS_ID);
uiMaskWS.setUIComponent(null);
- uiMaskWS.setShow(false);
+ uiMaskWS.setShow(false);
pcontext.addUIComponentToUpdateByAjax(uiMaskWS);
UIPage uiPage = uiPageForm.getUIPage();
@@ -287,6 +300,43 @@
applications.add(PortalDataMapper.buildModelObject(uiPortlet));
}
+ if (Page.DESKTOP_PAGE.equals(uiPage.getFactoryId()) && !Page.DESKTOP_PAGE.equals(page.getFactoryId()))
+ {
+ page.setShowMaxWindow(false);
+ uiPage.getChildren().clear();
+ page.setChildren(applications);
+
+ PortalDataMapper.toUIPage(uiPage, page);
+ if (page.getChildren() == null)
+ page.setChildren(new ArrayList<ModelObject>());
+
+ pcontext.setFullRender(true);
+ UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
+ pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
+ pcontext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
+ return;
+ }
+
+ if (Page.DESKTOP_PAGE.equals(page.getFactoryId()))
+ {
+ uiPage.getChildren().clear();
+ page.setChildren(applications);
+
+ PortalDataMapper.toUIPage(uiPage, page);
+ if (page.getChildren() == null)
+ page.setChildren(new ArrayList<ModelObject>());
+
+ UIPortalToolPanel toolPanel = Util.getUIPortalToolPanel();
+ toolPanel.setShowMaskLayer(true);
+ pcontext.setFullRender(true);
+ UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
+ pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
+ pcontext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
+ DataStorage dataService = uiPageForm.getApplicationComponent(DataStorage.class);
+ dataService.save(page);
+ return;
+ }
+
List<UIComponent> uiChildren = uiPage.getChildren();
if (uiChildren == null)
{
@@ -305,6 +355,7 @@
try{
PortalDataMapper.toUIPage(uiPage, page);
+ pcontext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
} catch(NoSuchDataException de){
uiPortalApp.addMessage(new ApplicationMessage("UIPageForm.msg.notExistOrDeleted", null, ApplicationMessage.ERROR));
UIPortalComposer uiPortalComposer = (UIPortalComposer)uiPortalApp.findComponentById("UIPageEditor");
@@ -315,7 +366,6 @@
}
uiPage.setStorageId(storageId);
- // if(page.getTemplate() == null) page.setTemplate(uiPage.getTemplate()) ;
if (page.getChildren() == null)
page.setChildren(new ArrayList<ModelObject>());
}
@@ -361,12 +411,28 @@
if (PortalConfig.PORTAL_TYPE.equals(ownerType))
{
list.remove(2);
- list.add(2, uiForm.ownerIdInput);
- uiForm.ownerIdInput.setValue(prContext.getPortalOwner());
- uiForm.findFirstComponentOfType(UIListPermissionSelector.class).setValue(
- Util.getUIPortal().getAccessPermissions());
- uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(
- Util.getUIPortal().getEditPermission());
+ list.add(2, uiForm.portalIdSelectBox);
+ String portalIdSelected = uiForm.portalIdSelectBox.getValue();
+ String[] accessPermissions = {};
+ String editPermission = "";
+
+ UserPortalConfigService service = uiForm.getApplicationComponent(UserPortalConfigService.class);
+ UserPortalConfig userConfig = service.getUserPortalConfig(portalIdSelected, prContext.getRemoteUser());
+ if (userConfig != null)
+ {
+ PortalConfig config = userConfig.getPortalConfig();
+ accessPermissions = config.getAccessPermissions();
+ editPermission = config.getEditPermission();
+ }
+ else
+ {
+ UIPortal uiPortal = Util.getUIPortalApplication().getCachedUIPortal(ownerType, portalIdSelected);
+ accessPermissions = uiPortal.getAccessPermissions();
+ editPermission = uiPortal.getEditPermission();
+ }
+
+ uiForm.findFirstComponentOfType(UIListPermissionSelector.class).setValue(accessPermissions);
+ uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(editPermission);
}
else
{
@@ -390,13 +456,33 @@
public void execute(Event<UIPageForm> event) throws Exception
{
UIPageForm uiForm = event.getSource();
- String groupIdSelected = uiForm.groupIdSelectBox.getValue();
- groupIdSelected = groupIdSelected.startsWith("/") ? groupIdSelected : "/" + groupIdSelected;
- String permission = "*:" + groupIdSelected;
- uiForm.findFirstComponentOfType(UIListPermissionSelector.class).setValue(new String[]{permission});
- UserACL userACL = uiForm.getApplicationComponent(UserACL.class);
- permission = userACL.getMakableMT() + ":" + groupIdSelected;
- uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(permission);
+ UIFormSelectBox uiSelectBox = uiForm.getUIFormSelectBox(OWNER_TYPE);
+ String ownerType = uiSelectBox.getValue();
+ if(PortalConfig.PORTAL_TYPE.equals(ownerType)) {
+ String[] accessPermissions = {};
+ String editPermission = "";
+ String portalIdSelected = uiForm.portalIdSelectBox.getValue();
+ UserPortalConfigService service = uiForm.getApplicationComponent(UserPortalConfigService.class);
+ UserPortalConfig userConfig = service.getUserPortalConfig(portalIdSelected, Util.getPortalRequestContext().getRemoteUser());
+ if (userConfig != null)
+ {
+ PortalConfig config = userConfig.getPortalConfig();
+ accessPermissions = config.getAccessPermissions();
+ editPermission = config.getEditPermission();
+ uiForm.findFirstComponentOfType(UIListPermissionSelector.class).setValue(accessPermissions);
+ uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(editPermission);
+ }
+ }
+ else
+ {
+ String groupIdSelected = uiForm.groupIdSelectBox.getValue();
+ groupIdSelected = groupIdSelected.startsWith("/") ? groupIdSelected : "/" + groupIdSelected;
+ String permission = "*:" + groupIdSelected;
+ uiForm.findFirstComponentOfType(UIListPermissionSelector.class).setValue(new String[]{permission});
+ UserACL userACL = uiForm.getApplicationComponent(UserACL.class);
+ permission = userACL.getMakableMT() + ":" + groupIdSelected;
+ uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(permission);
+ }
event.getRequestContext().addUIComponentToUpdateByAjax(uiForm.getParent());
}
}
@@ -406,13 +492,6 @@
public void execute(Event<UIGroupMembershipSelector> event) throws Exception
{
UIPageForm uiForm = event.getSource().getAncestorOfType(UIPageForm.class);
- /*if (!uiForm.getUIStringInput(OWNER_TYPE).getValue().equals(PortalConfig.GROUP_TYPE))
- return;
- String editPer = uiForm.findFirstComponentOfType(UIPermissionSelector.class).getValue();
- if (editPer == null || editPer.length() < 1)
- return;
- String group = editPer.substring(editPer.indexOf("/") + 1);
- uiForm.ownerIdInput.setValue(group);*/
event.getRequestContext().addUIComponentToUpdateByAjax(uiForm.getParent());
}
}
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java 2011-08-18 20:46:44 UTC (rev 7181)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java 2011-08-18 21:10:07 UTC (rev 7182)
@@ -348,7 +348,12 @@
UIMaskWorkspace uiMaskWorkspace = uiForm.getParent();
uiMaskWorkspace.setUIComponent(null);
- event.getRequestContext().addUIComponentToUpdateByAjax(uiMaskWorkspace);
+ WebuiRequestContext rContext = event.getRequestContext();
+ if (!uiForm.getId().equals("CreatePortal"))
+ {
+ rContext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
+ }
+ rContext.addUIComponentToUpdateByAjax(uiMaskWorkspace);
}
}
13 years, 4 months
gatein SVN: r7181 - in epp/portal/branches/EPP_5_2_Branch: component and 8 other directories.
by do-not-reply@jboss.org
Author: theute
Date: 2011-08-18 16:46:44 -0400 (Thu, 18 Aug 2011)
New Revision: 7181
Modified:
epp/portal/branches/EPP_5_2_Branch/
epp/portal/branches/EPP_5_2_Branch/component/
epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIContainer.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableAutofitColumnContainer.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableColumnContainer.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIToolbarContainer.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalComposer.gtmpl
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletForm.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerForm.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java
Log:
Rolling back for now
Property changes on: epp/portal/branches/EPP_5_2_Branch
___________________________________________________________________
Modified: svn:mergeinfo
- /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795:5868
/portal/branches/branch-GTNPORTAL-1537:4700
/portal/branches/branch-GTNPORTAL-1592:4894
/portal/branches/branch-GTNPORTAL-1643:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731:5622,5668
/portal/branches/branch-GTNPORTAL-1745:5765
/portal/branches/branch-GTNPORTAL-1822:5943,5952
/portal/branches/branch-GTNPORTAL-1832:6030,6063
/portal/branches/branch-GTNPORTAL-1872:6400,6551
/portal/branches/branch-GTNPORTAL-1921:6603
/portal/branches/branch-GTNPORTAL-1963:6904,6915-6916
/portal/branches/decoupled-webos:6214-6243
/portal/branches/gatein-management:6920-6958
/portal/branches/global-portlet-metadata:6298-6384
/portal/branches/site-describability:6171-6235
/portal/trunk:4891,5744,5822,5943,6168,6196,6201-6203,6205-6206,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061
+ /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795:5868
/portal/branches/branch-GTNPORTAL-1592:4894
/portal/branches/branch-GTNPORTAL-1643:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731:5622,5668
/portal/branches/branch-GTNPORTAL-1745:5765
/portal/branches/branch-GTNPORTAL-1822:5943,5952
/portal/branches/branch-GTNPORTAL-1832:6030,6063
/portal/branches/branch-GTNPORTAL-1872:6400,6551
/portal/branches/branch-GTNPORTAL-1921:6603
/portal/branches/branch-GTNPORTAL-1963:6904,6915-6916
/portal/branches/decoupled-webos:6214-6243
/portal/branches/gatein-management:6920-6958
/portal/branches/global-portlet-metadata:6298-6384
/portal/branches/site-describability:6171-6235
/portal/trunk:4891,5744,5822,5943,6168,6196,6201-6203,6205-6206,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061
Property changes on: epp/portal/branches/EPP_5_2_Branch/component
___________________________________________________________________
Modified: svn:mergeinfo
- /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795/component:5868
/portal/branches/branch-GTNPORTAL-1537/component:4700
/portal/branches/branch-GTNPORTAL-1592/component:4894
/portal/branches/branch-GTNPORTAL-1643/component:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700/component:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731/component:5622,5668
/portal/branches/branch-GTNPORTAL-1745/component:5765
/portal/branches/branch-GTNPORTAL-1822/component:5943,5952
/portal/branches/branch-GTNPORTAL-1832/component:6030,6063
/portal/branches/branch-GTNPORTAL-1872/component:6400,6551
/portal/branches/branch-GTNPORTAL-1921/component:6603
/portal/branches/branch-GTNPORTAL-1963/component:6904,6915-6916
/portal/trunk/component:4891,5744,5822,5943,6031,6033,6168,6196,6201-6203,6205-6206,6292,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061
+ /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795/component:5868
/portal/branches/branch-GTNPORTAL-1592/component:4894
/portal/branches/branch-GTNPORTAL-1643/component:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700/component:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731/component:5622,5668
/portal/branches/branch-GTNPORTAL-1745/component:5765
/portal/branches/branch-GTNPORTAL-1822/component:5943,5952
/portal/branches/branch-GTNPORTAL-1832/component:6030,6063
/portal/branches/branch-GTNPORTAL-1872/component:6400,6551
/portal/branches/branch-GTNPORTAL-1921/component:6603
/portal/branches/branch-GTNPORTAL-1963/component:6904,6915-6916
/portal/trunk/component:4891,5744,5822,5943,6031,6033,6168,6196,6201-6203,6205-6206,6292,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061
Modified: epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js 2011-08-18 20:12:46 UTC (rev 7180)
+++ epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js 2011-08-18 20:46:44 UTC (rev 7181)
@@ -196,38 +196,6 @@
DragDrop.dropCallback = function(dndEvent) {
this.origDragObjectStyle.setProperties(dndEvent.dragObject.style, false) ;
-
- var hasChanged = true;
- //When press esc key, we want to cancel the dragdrop, but now it only works with FF
- if (dndEvent.backupMouseEvent && dndEvent.backupMouseEvent.keyCode == 27 && eXo.core.Browser.isFF()) {
- hasChanged = false;
- }
- //When dragObject is outside
- var targetElement = dndEvent.foundTargetObject;
- if(!targetElement || targetElement.foundIndex == null) {
- hasChanged = false;
- }
- //When dragobject is next to preview object (position is not changed)
- if(!dndEvent.dragObject.isAddingNewly) {
- var DOMUtil = eXo.core.DOMUtil;
- var previewClass = "DragAndDropPreview";
- var previewTagName = "div";
- var previewSibling = dndEvent.dragObject;
- if (dndEvent.dragObject.parentNode.tagName.toLowerCase() == "td") {
- previewSibling = dndEvent.dragObject.parentNode;
- previewClass = "PreviewTDBlock";
- previewTagName = "td";
- }
- var tempObj = DOMUtil.findNextElementByTagName(previewSibling, previewTagName);
- if (tempObj != null && tempObj.className == previewClass) {
- hasChanged = false;
- } else {
- tempObj = DOMUtil.findPreviousElementByTagName(previewSibling, previewTagName);
- if (tempObj != null && tempObj.className == previewClass) {
- hasChanged = false;
- }
- }
- }
if(dndEvent.foundTargetObject != null || (dndEvent.backupMouseEvent && dndEvent.backupMouseEvent.keyCode != 27)) {
eXo.portal.PortalDragDrop.doDropCallback(dndEvent) ;
@@ -251,9 +219,7 @@
previewBlock = previewTD = null;
eXo.portal.isInDragging = false;
- if (hasChanged) {
- eXo.portal.UIPortal.changeComposerSaveButton();
- }
+ eXo.portal.UIPortal.changeComposerSaveButton();
// fix bug WEBOS-196
dndEvent.dragObject.style.width = "auto" ;
};
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2011-08-18 20:12:46 UTC (rev 7180)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2011-08-18 20:46:44 UTC (rev 7181)
@@ -263,7 +263,7 @@
%>
<div class="PortletIcon $portletIcon"><%=hasPermission ? title : _ctx.appRes("UIPortlet.label.protectedContent")%></div>
<%if(hasPermission) {%>
- <a href="<%=uicomponent.event("EditPortlet","$uicomponent.id")%>;" class="EditPortletPropertiesIcon" title="<%=_ctx.appRes("UIPortlet.tooltip.editPortlet");%>"></a>
+ <a href="<%=uicomponent.event("EditPortlet","$uicomponent.id")%>;eXo.portal.UIPortal.changeComposerSaveButton()" class="EditPortletPropertiesIcon" title="<%=_ctx.appRes("UIPortlet.tooltip.editPortlet");%>"></a>
<a href="<%=uicomponent.event("DeleteComponent","$uicomponent.id")%>" class="DeletePortletIcon" title="<%=_ctx.appRes("UIPortlet.tooltip.deletePortlet");%>"></a>
<%}%>
</div>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIContainer.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIContainer.gtmpl 2011-08-18 20:12:46 UTC (rev 7180)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIContainer.gtmpl 2011-08-18 20:46:44 UTC (rev 7181)
@@ -42,9 +42,9 @@
<div class="VIEW-CONTAINER VIEW-BLOCK">
<%} %>
<%if(hasPermission) {%>
- <div>
- <div class="UIRowContainer <%=(portalMode != UIPortalApplication.NORMAL_MODE && uicomponent.getChildren().size() == 0) ? "EmptyContainer" : ""%>">
- <%uicomponent.renderChildren();%>
+ <div class="UIRowContainer <%=(portalMode != UIPortalApplication.NORMAL_MODE && uicomponent.getChildren().size() == 0) ? "EmptyContainer" : ""%>">
+ <div>
+ <%uicomponent.renderChildren();%>
</div>
</div>
<%} else out.print("<div class='ProtectedContent'>"+_ctx.appRes("UIPortlet.label.protectedContent")+"</div>");%>
@@ -72,7 +72,7 @@
%>
<div class="ContainerIcon"><%=hasPermission ? strTitle : _ctx.appRes("UIPortlet.label.protectedContent")%></div>
<%if(hasPermission) {%>
- <a href="<%=uicomponent.event("EditContainer")%>" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
+ <a href="<%=uicomponent.event("EditContainer")%>;eXo.portal.UIPortal.changeComposerSaveButton()" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
<a href="<%=uicomponent.event("DeleteComponent")%>" class="DeleteContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.closeContainer")%>"><span></span></a>
<%}%>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableAutofitColumnContainer.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableAutofitColumnContainer.gtmpl 2011-08-18 20:12:46 UTC (rev 7180)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableAutofitColumnContainer.gtmpl 2011-08-18 20:46:44 UTC (rev 7181)
@@ -73,7 +73,7 @@
%>
<div class="ContainerIcon DefaultContainer16x16Icon"><%=hasPermission ? strTitle : _ctx.appRes("UIPortlet.label.protectedContent")%></div>
<%if(hasPermission) {%>
- <a href="<%=uicomponent.event("EditContainer","$uicomponent.id")%>" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
+ <a href="<%=uicomponent.event("EditContainer","$uicomponent.id")%>;eXo.portal.UIPortal.changeComposerSaveButton()" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
<a href="<%=uicomponent.event("DeleteComponent","$uicomponent.id")%>" class="DeleteContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.closeContainer")%>"><span></span></a>
<%}%>
</div>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableColumnContainer.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableColumnContainer.gtmpl 2011-08-18 20:12:46 UTC (rev 7180)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableColumnContainer.gtmpl 2011-08-18 20:46:44 UTC (rev 7181)
@@ -73,7 +73,7 @@
%>
<div class="ContainerIcon DefaultContainer16x16Icon"><%=hasPermission ? strTitle : _ctx.appRes("UIPortlet.label.protectedContent")%></div>
<%if(hasPermission) {%>
- <a href="<%=uicomponent.event("EditContainer","$uicomponent.id")%>" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
+ <a href="<%=uicomponent.event("EditContainer","$uicomponent.id")%>;eXo.portal.UIPortal.changeComposerSaveButton()" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
<a href="<%=uicomponent.event("DeleteComponent","$uicomponent.id")%>" class="DeleteContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.closeContainer")%>"><span></span></a>
<%}%>
</div>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIToolbarContainer.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIToolbarContainer.gtmpl 2011-08-18 20:12:46 UTC (rev 7180)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIToolbarContainer.gtmpl 2011-08-18 20:46:44 UTC (rev 7181)
@@ -70,7 +70,7 @@
%>
<div class="ContainerIcon DefaultContainer16x16Icon"><%=hasPermission ? strTitle : _ctx.appRes("UIPortlet.label.protectedContent")%></div>
<%if(hasPermission) {%>
- <a href="<%=uicomponent.event("EditContainer","$uicomponent.id")%>;" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
+ <a href="<%=uicomponent.event("EditContainer","$uicomponent.id")%>;eXo.portal.UIPortal.changeComposerSaveButton()" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
<a href="<%=uicomponent.event("DeleteComponent","$uicomponent.id")%>" class="DeleteContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.closeContainer")%>"><span></span></a>
<%}%>
</div>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalComposer.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalComposer.gtmpl 2011-08-18 20:12:46 UTC (rev 7180)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalComposer.gtmpl 2011-08-18 20:46:44 UTC (rev 7181)
@@ -52,7 +52,7 @@
<tr>
<td>
- <div onclick="<%= uicomponent.event("ViewProperties") %>;" class="ActionButton SimpleStyle1">
+ <div onclick="<%= uicomponent.event("ViewProperties") %>;eXo.portal.UIPortal.changeComposerSaveButton()" class="ActionButton SimpleStyle1">
<div class="ButtonLeft">
<div class="ButtonRight">
<div class="ButtonMiddle">
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletForm.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletForm.java 2011-08-18 20:12:46 UTC (rev 7180)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletForm.java 2011-08-18 20:46:44 UTC (rev 7181)
@@ -397,7 +397,6 @@
}
PortalRequestContext pcontext = (PortalRequestContext)event.getRequestContext();
- pcontext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
pcontext.addUIComponentToUpdateByAjax(uiMaskWorkspace);
UIPortalApplication uiPortalApp = uiPortlet.getAncestorOfType(UIPortalApplication.class);
UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerForm.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerForm.java 2011-08-18 20:12:46 UTC (rev 7180)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerForm.java 2011-08-18 20:46:44 UTC (rev 7181)
@@ -143,7 +143,6 @@
UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
- pcontext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
pcontext.ignoreAJAXUpdateOnPortlets(true);
Util.showComponentLayoutMode(UIContainer.class);
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java 2011-08-18 20:12:46 UTC (rev 7180)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java 2011-08-18 20:46:44 UTC (rev 7181)
@@ -35,8 +35,6 @@
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.webui.application.UIPortlet;
import org.exoplatform.portal.webui.container.UIContainer;
-import org.exoplatform.portal.webui.portal.UIPortal;
-import org.exoplatform.portal.webui.portal.UIPortalComponent;
import org.exoplatform.portal.webui.portal.UIPortalComposer;
import org.exoplatform.portal.webui.util.PortalDataMapper;
import org.exoplatform.portal.webui.util.Util;
@@ -85,8 +83,6 @@
protected UIFormInputSet uiPermissionSetting;
protected UIFormSelectBox groupIdSelectBox = null;
-
- protected UIFormSelectBox portalIdSelectBox = null;
protected UIFormStringInput ownerIdInput = null;
@@ -103,6 +99,14 @@
List<SelectItemOption<String>> ownerTypes = new ArrayList<SelectItemOption<String>>();
ownerTypes.add(new SelectItemOption<String>(PortalConfig.USER_TYPE));
+ UserPortalConfig userPortalConfig =
+ configService.getUserPortalConfig(pcontext.getPortalOwner(), pcontext.getRemoteUser());
+ ExoContainer container = ExoContainerContext.getCurrentContainer();
+ UserACL acl = (UserACL)container.getComponentInstanceOfType(UserACL.class);
+ if (acl.hasEditPermission(userPortalConfig.getPortalConfig()))
+ {
+ ownerTypes.add(new SelectItemOption<String>(PortalConfig.PORTAL_TYPE));
+ }
ownerIdInput = new UIFormStringInput(OWNER_ID, OWNER_ID, null);
ownerIdInput.setEditable(false).setValue(pcontext.getRemoteUser());
@@ -142,27 +146,6 @@
//TODO: This following line is fixed for bug PORTAL-2127
uiListPermissionSelector.getChild(UIFormPopupWindow.class).setId("UIPageFormPopupGroupMembershipSelector");
- List<String> portals = configService.getAllPortalNames();
- Collections.sort(portals);
- List<SelectItemOption<String>> portalsItem = new ArrayList<SelectItemOption<String>>();
- ExoContainer container = ExoContainerContext.getCurrentContainer();
- UserACL acl = (UserACL)container.getComponentInstanceOfType(UserACL.class);
- for (String p : portals)
- {
- UserPortalConfig userPortalConfig = configService.getUserPortalConfig(p, pcontext.getRemoteUser());
- if (acl.hasEditPermission(userPortalConfig.getPortalConfig()))
- {
- portalsItem.add(new SelectItemOption<String>(p));
- }
- }
- if(portalsItem.size() > 0)
- {
- ownerTypes.add(new SelectItemOption<String>(PortalConfig.PORTAL_TYPE));
- portalIdSelectBox = new UIFormSelectBox(OWNER_ID, OWNER_ID, portalsItem);
- portalIdSelectBox.setOnChange("ChangeOwnerId");
- portalIdSelectBox.setParent(uiSettingSet);
- }
-
List<String> groups = configService.getMakableNavigations(pcontext.getRemoteUser(), true);
if (groups.size() > 0)
{
@@ -177,7 +160,6 @@
groupIdSelectBox.setOnChange("ChangeOwnerId");
groupIdSelectBox.setParent(uiSettingSet);
}
-
setActions(new String[]{"Save", "Close"});
}
@@ -219,6 +201,11 @@
uiTemplate.setValue(uiPage.getFactoryId());
}
+ public void setEditPermission(String per)
+ {
+
+ }
+
public void invokeSetBindingBean(Object bean) throws Exception
{
String ownerType = getUIFormSelectBox("ownerType").getValue();
@@ -281,7 +268,7 @@
PortalRequestContext pcontext = Util.getPortalRequestContext();
UIMaskWorkspace uiMaskWS = uiPortalApp.getChildById(UIPortalApplication.UI_MASK_WS_ID);
uiMaskWS.setUIComponent(null);
- uiMaskWS.setShow(false);
+ uiMaskWS.setShow(false);
pcontext.addUIComponentToUpdateByAjax(uiMaskWS);
UIPage uiPage = uiPageForm.getUIPage();
@@ -300,43 +287,6 @@
applications.add(PortalDataMapper.buildModelObject(uiPortlet));
}
- if (Page.DESKTOP_PAGE.equals(uiPage.getFactoryId()) && !Page.DESKTOP_PAGE.equals(page.getFactoryId()))
- {
- page.setShowMaxWindow(false);
- uiPage.getChildren().clear();
- page.setChildren(applications);
-
- PortalDataMapper.toUIPage(uiPage, page);
- if (page.getChildren() == null)
- page.setChildren(new ArrayList<ModelObject>());
-
- pcontext.setFullRender(true);
- UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
- pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
- pcontext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
- return;
- }
-
- if (Page.DESKTOP_PAGE.equals(page.getFactoryId()))
- {
- uiPage.getChildren().clear();
- page.setChildren(applications);
-
- PortalDataMapper.toUIPage(uiPage, page);
- if (page.getChildren() == null)
- page.setChildren(new ArrayList<ModelObject>());
-
- UIPortalToolPanel toolPanel = Util.getUIPortalToolPanel();
- toolPanel.setShowMaskLayer(true);
- pcontext.setFullRender(true);
- UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
- pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
- pcontext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
- DataStorage dataService = uiPageForm.getApplicationComponent(DataStorage.class);
- dataService.save(page);
- return;
- }
-
List<UIComponent> uiChildren = uiPage.getChildren();
if (uiChildren == null)
{
@@ -355,7 +305,6 @@
try{
PortalDataMapper.toUIPage(uiPage, page);
- pcontext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
} catch(NoSuchDataException de){
uiPortalApp.addMessage(new ApplicationMessage("UIPageForm.msg.notExistOrDeleted", null, ApplicationMessage.ERROR));
UIPortalComposer uiPortalComposer = (UIPortalComposer)uiPortalApp.findComponentById("UIPageEditor");
@@ -366,6 +315,7 @@
}
uiPage.setStorageId(storageId);
+ // if(page.getTemplate() == null) page.setTemplate(uiPage.getTemplate()) ;
if (page.getChildren() == null)
page.setChildren(new ArrayList<ModelObject>());
}
@@ -411,28 +361,12 @@
if (PortalConfig.PORTAL_TYPE.equals(ownerType))
{
list.remove(2);
- list.add(2, uiForm.portalIdSelectBox);
- String portalIdSelected = uiForm.portalIdSelectBox.getValue();
- String[] accessPermissions = {};
- String editPermission = "";
-
- UserPortalConfigService service = uiForm.getApplicationComponent(UserPortalConfigService.class);
- UserPortalConfig userConfig = service.getUserPortalConfig(portalIdSelected, prContext.getRemoteUser());
- if (userConfig != null)
- {
- PortalConfig config = userConfig.getPortalConfig();
- accessPermissions = config.getAccessPermissions();
- editPermission = config.getEditPermission();
- }
- else
- {
- UIPortal uiPortal = Util.getUIPortalApplication().getCachedUIPortal(ownerType, portalIdSelected);
- accessPermissions = uiPortal.getAccessPermissions();
- editPermission = uiPortal.getEditPermission();
- }
-
- uiForm.findFirstComponentOfType(UIListPermissionSelector.class).setValue(accessPermissions);
- uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(editPermission);
+ list.add(2, uiForm.ownerIdInput);
+ uiForm.ownerIdInput.setValue(prContext.getPortalOwner());
+ uiForm.findFirstComponentOfType(UIListPermissionSelector.class).setValue(
+ Util.getUIPortal().getAccessPermissions());
+ uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(
+ Util.getUIPortal().getEditPermission());
}
else
{
@@ -456,33 +390,13 @@
public void execute(Event<UIPageForm> event) throws Exception
{
UIPageForm uiForm = event.getSource();
- UIFormSelectBox uiSelectBox = uiForm.getUIFormSelectBox(OWNER_TYPE);
- String ownerType = uiSelectBox.getValue();
- if(PortalConfig.PORTAL_TYPE.equals(ownerType)) {
- String[] accessPermissions = {};
- String editPermission = "";
- String portalIdSelected = uiForm.portalIdSelectBox.getValue();
- UserPortalConfigService service = uiForm.getApplicationComponent(UserPortalConfigService.class);
- UserPortalConfig userConfig = service.getUserPortalConfig(portalIdSelected, Util.getPortalRequestContext().getRemoteUser());
- if (userConfig != null)
- {
- PortalConfig config = userConfig.getPortalConfig();
- accessPermissions = config.getAccessPermissions();
- editPermission = config.getEditPermission();
- uiForm.findFirstComponentOfType(UIListPermissionSelector.class).setValue(accessPermissions);
- uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(editPermission);
- }
- }
- else
- {
- String groupIdSelected = uiForm.groupIdSelectBox.getValue();
- groupIdSelected = groupIdSelected.startsWith("/") ? groupIdSelected : "/" + groupIdSelected;
- String permission = "*:" + groupIdSelected;
- uiForm.findFirstComponentOfType(UIListPermissionSelector.class).setValue(new String[]{permission});
- UserACL userACL = uiForm.getApplicationComponent(UserACL.class);
- permission = userACL.getMakableMT() + ":" + groupIdSelected;
- uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(permission);
- }
+ String groupIdSelected = uiForm.groupIdSelectBox.getValue();
+ groupIdSelected = groupIdSelected.startsWith("/") ? groupIdSelected : "/" + groupIdSelected;
+ String permission = "*:" + groupIdSelected;
+ uiForm.findFirstComponentOfType(UIListPermissionSelector.class).setValue(new String[]{permission});
+ UserACL userACL = uiForm.getApplicationComponent(UserACL.class);
+ permission = userACL.getMakableMT() + ":" + groupIdSelected;
+ uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(permission);
event.getRequestContext().addUIComponentToUpdateByAjax(uiForm.getParent());
}
}
@@ -492,6 +406,13 @@
public void execute(Event<UIGroupMembershipSelector> event) throws Exception
{
UIPageForm uiForm = event.getSource().getAncestorOfType(UIPageForm.class);
+ /*if (!uiForm.getUIStringInput(OWNER_TYPE).getValue().equals(PortalConfig.GROUP_TYPE))
+ return;
+ String editPer = uiForm.findFirstComponentOfType(UIPermissionSelector.class).getValue();
+ if (editPer == null || editPer.length() < 1)
+ return;
+ String group = editPer.substring(editPer.indexOf("/") + 1);
+ uiForm.ownerIdInput.setValue(group);*/
event.getRequestContext().addUIComponentToUpdateByAjax(uiForm.getParent());
}
}
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java 2011-08-18 20:12:46 UTC (rev 7180)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java 2011-08-18 20:46:44 UTC (rev 7181)
@@ -348,12 +348,7 @@
UIMaskWorkspace uiMaskWorkspace = uiForm.getParent();
uiMaskWorkspace.setUIComponent(null);
- WebuiRequestContext rContext = event.getRequestContext();
- if (!uiForm.getId().equals("CreatePortal"))
- {
- rContext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
- }
- rContext.addUIComponentToUpdateByAjax(uiMaskWorkspace);
+ event.getRequestContext().addUIComponentToUpdateByAjax(uiMaskWorkspace);
}
}
13 years, 4 months
gatein SVN: r7180 - epp/portal/branches.
by do-not-reply@jboss.org
Author: ghjboss
Date: 2011-08-18 16:12:46 -0400 (Thu, 18 Aug 2011)
New Revision: 7180
Added:
epp/portal/branches/EPP_5_1_0_GA_JBEPP-1090/
Log:
create branch for support patch JBEPP-1090
13 years, 4 months
gatein SVN: r7179 - in epp/portal/branches/EPP_5_2_Branch: component and 8 other directories.
by do-not-reply@jboss.org
Author: theute
Date: 2011-08-18 16:04:11 -0400 (Thu, 18 Aug 2011)
New Revision: 7179
Modified:
epp/portal/branches/EPP_5_2_Branch/
epp/portal/branches/EPP_5_2_Branch/component/
epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIContainer.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableAutofitColumnContainer.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableColumnContainer.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIToolbarContainer.gtmpl
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalComposer.gtmpl
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletForm.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerForm.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java
Log:
JBEPP-1089 Show Status of Finish button is not correct in Edition page when don't do anything on this page
Property changes on: epp/portal/branches/EPP_5_2_Branch
___________________________________________________________________
Modified: svn:mergeinfo
- /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795:5868
/portal/branches/branch-GTNPORTAL-1592:4894
/portal/branches/branch-GTNPORTAL-1643:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731:5622,5668
/portal/branches/branch-GTNPORTAL-1745:5765
/portal/branches/branch-GTNPORTAL-1822:5943,5952
/portal/branches/branch-GTNPORTAL-1832:6030,6063
/portal/branches/branch-GTNPORTAL-1872:6400,6551
/portal/branches/branch-GTNPORTAL-1921:6603
/portal/branches/branch-GTNPORTAL-1963:6904,6915-6916
/portal/branches/decoupled-webos:6214-6243
/portal/branches/gatein-management:6920-6958
/portal/branches/global-portlet-metadata:6298-6384
/portal/branches/site-describability:6171-6235
/portal/trunk:4891,5744,5822,5943,6168,6196,6201-6203,6205-6206,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061
+ /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795:5868
/portal/branches/branch-GTNPORTAL-1537:4700
/portal/branches/branch-GTNPORTAL-1592:4894
/portal/branches/branch-GTNPORTAL-1643:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731:5622,5668
/portal/branches/branch-GTNPORTAL-1745:5765
/portal/branches/branch-GTNPORTAL-1822:5943,5952
/portal/branches/branch-GTNPORTAL-1832:6030,6063
/portal/branches/branch-GTNPORTAL-1872:6400,6551
/portal/branches/branch-GTNPORTAL-1921:6603
/portal/branches/branch-GTNPORTAL-1963:6904,6915-6916
/portal/branches/decoupled-webos:6214-6243
/portal/branches/gatein-management:6920-6958
/portal/branches/global-portlet-metadata:6298-6384
/portal/branches/site-describability:6171-6235
/portal/trunk:4891,5744,5822,5943,6168,6196,6201-6203,6205-6206,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061
Property changes on: epp/portal/branches/EPP_5_2_Branch/component
___________________________________________________________________
Modified: svn:mergeinfo
- /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795/component:5868
/portal/branches/branch-GTNPORTAL-1592/component:4894
/portal/branches/branch-GTNPORTAL-1643/component:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700/component:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731/component:5622,5668
/portal/branches/branch-GTNPORTAL-1745/component:5765
/portal/branches/branch-GTNPORTAL-1822/component:5943,5952
/portal/branches/branch-GTNPORTAL-1832/component:6030,6063
/portal/branches/branch-GTNPORTAL-1872/component:6400,6551
/portal/branches/branch-GTNPORTAL-1921/component:6603
/portal/branches/branch-GTNPORTAL-1963/component:6904,6915-6916
/portal/trunk/component:4891,5744,5822,5943,6031,6033,6168,6196,6201-6203,6205-6206,6292,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061
+ /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795/component:5868
/portal/branches/branch-GTNPORTAL-1537/component:4700
/portal/branches/branch-GTNPORTAL-1592/component:4894
/portal/branches/branch-GTNPORTAL-1643/component:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700/component:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731/component:5622,5668
/portal/branches/branch-GTNPORTAL-1745/component:5765
/portal/branches/branch-GTNPORTAL-1822/component:5943,5952
/portal/branches/branch-GTNPORTAL-1832/component:6030,6063
/portal/branches/branch-GTNPORTAL-1872/component:6400,6551
/portal/branches/branch-GTNPORTAL-1921/component:6603
/portal/branches/branch-GTNPORTAL-1963/component:6904,6915-6916
/portal/trunk/component:4891,5744,5822,5943,6031,6033,6168,6196,6201-6203,6205-6206,6292,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061
Modified: epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js 2011-08-18 19:06:18 UTC (rev 7178)
+++ epp/portal/branches/EPP_5_2_Branch/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js 2011-08-18 20:04:11 UTC (rev 7179)
@@ -196,6 +196,38 @@
DragDrop.dropCallback = function(dndEvent) {
this.origDragObjectStyle.setProperties(dndEvent.dragObject.style, false) ;
+
+ var hasChanged = true;
+ //When press esc key, we want to cancel the dragdrop, but now it only works with FF
+ if (dndEvent.backupMouseEvent && dndEvent.backupMouseEvent.keyCode == 27 && eXo.core.Browser.isFF()) {
+ hasChanged = false;
+ }
+ //When dragObject is outside
+ var targetElement = dndEvent.foundTargetObject;
+ if(!targetElement || targetElement.foundIndex == null) {
+ hasChanged = false;
+ }
+ //When dragobject is next to preview object (position is not changed)
+ if(!dndEvent.dragObject.isAddingNewly) {
+ var DOMUtil = eXo.core.DOMUtil;
+ var previewClass = "DragAndDropPreview";
+ var previewTagName = "div";
+ var previewSibling = dndEvent.dragObject;
+ if (dndEvent.dragObject.parentNode.tagName.toLowerCase() == "td") {
+ previewSibling = dndEvent.dragObject.parentNode;
+ previewClass = "PreviewTDBlock";
+ previewTagName = "td";
+ }
+ var tempObj = DOMUtil.findNextElementByTagName(previewSibling, previewTagName);
+ if (tempObj != null && tempObj.className == previewClass) {
+ hasChanged = false;
+ } else {
+ tempObj = DOMUtil.findPreviousElementByTagName(previewSibling, previewTagName);
+ if (tempObj != null && tempObj.className == previewClass) {
+ hasChanged = false;
+ }
+ }
+ }
if(dndEvent.foundTargetObject != null || (dndEvent.backupMouseEvent && dndEvent.backupMouseEvent.keyCode != 27)) {
eXo.portal.PortalDragDrop.doDropCallback(dndEvent) ;
@@ -219,7 +251,9 @@
previewBlock = previewTD = null;
eXo.portal.isInDragging = false;
- eXo.portal.UIPortal.changeComposerSaveButton();
+ if (hasChanged) {
+ eXo.portal.UIPortal.changeComposerSaveButton();
+ }
// fix bug WEBOS-196
dndEvent.dragObject.style.width = "auto" ;
};
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2011-08-18 19:06:18 UTC (rev 7178)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2011-08-18 20:04:11 UTC (rev 7179)
@@ -263,7 +263,7 @@
%>
<div class="PortletIcon $portletIcon"><%=hasPermission ? title : _ctx.appRes("UIPortlet.label.protectedContent")%></div>
<%if(hasPermission) {%>
- <a href="<%=uicomponent.event("EditPortlet","$uicomponent.id")%>;eXo.portal.UIPortal.changeComposerSaveButton()" class="EditPortletPropertiesIcon" title="<%=_ctx.appRes("UIPortlet.tooltip.editPortlet");%>"></a>
+ <a href="<%=uicomponent.event("EditPortlet","$uicomponent.id")%>;" class="EditPortletPropertiesIcon" title="<%=_ctx.appRes("UIPortlet.tooltip.editPortlet");%>"></a>
<a href="<%=uicomponent.event("DeleteComponent","$uicomponent.id")%>" class="DeletePortletIcon" title="<%=_ctx.appRes("UIPortlet.tooltip.deletePortlet");%>"></a>
<%}%>
</div>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIContainer.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIContainer.gtmpl 2011-08-18 19:06:18 UTC (rev 7178)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIContainer.gtmpl 2011-08-18 20:04:11 UTC (rev 7179)
@@ -42,9 +42,9 @@
<div class="VIEW-CONTAINER VIEW-BLOCK">
<%} %>
<%if(hasPermission) {%>
- <div class="UIRowContainer <%=(portalMode != UIPortalApplication.NORMAL_MODE && uicomponent.getChildren().size() == 0) ? "EmptyContainer" : ""%>">
- <div>
- <%uicomponent.renderChildren();%>
+ <div>
+ <div class="UIRowContainer <%=(portalMode != UIPortalApplication.NORMAL_MODE && uicomponent.getChildren().size() == 0) ? "EmptyContainer" : ""%>">
+ <%uicomponent.renderChildren();%>
</div>
</div>
<%} else out.print("<div class='ProtectedContent'>"+_ctx.appRes("UIPortlet.label.protectedContent")+"</div>");%>
@@ -72,7 +72,7 @@
%>
<div class="ContainerIcon"><%=hasPermission ? strTitle : _ctx.appRes("UIPortlet.label.protectedContent")%></div>
<%if(hasPermission) {%>
- <a href="<%=uicomponent.event("EditContainer")%>;eXo.portal.UIPortal.changeComposerSaveButton()" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
+ <a href="<%=uicomponent.event("EditContainer")%>" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
<a href="<%=uicomponent.event("DeleteComponent")%>" class="DeleteContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.closeContainer")%>"><span></span></a>
<%}%>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableAutofitColumnContainer.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableAutofitColumnContainer.gtmpl 2011-08-18 19:06:18 UTC (rev 7178)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableAutofitColumnContainer.gtmpl 2011-08-18 20:04:11 UTC (rev 7179)
@@ -73,7 +73,7 @@
%>
<div class="ContainerIcon DefaultContainer16x16Icon"><%=hasPermission ? strTitle : _ctx.appRes("UIPortlet.label.protectedContent")%></div>
<%if(hasPermission) {%>
- <a href="<%=uicomponent.event("EditContainer","$uicomponent.id")%>;eXo.portal.UIPortal.changeComposerSaveButton()" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
+ <a href="<%=uicomponent.event("EditContainer","$uicomponent.id")%>" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
<a href="<%=uicomponent.event("DeleteComponent","$uicomponent.id")%>" class="DeleteContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.closeContainer")%>"><span></span></a>
<%}%>
</div>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableColumnContainer.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableColumnContainer.gtmpl 2011-08-18 19:06:18 UTC (rev 7178)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UITableColumnContainer.gtmpl 2011-08-18 20:04:11 UTC (rev 7179)
@@ -73,7 +73,7 @@
%>
<div class="ContainerIcon DefaultContainer16x16Icon"><%=hasPermission ? strTitle : _ctx.appRes("UIPortlet.label.protectedContent")%></div>
<%if(hasPermission) {%>
- <a href="<%=uicomponent.event("EditContainer","$uicomponent.id")%>;eXo.portal.UIPortal.changeComposerSaveButton()" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
+ <a href="<%=uicomponent.event("EditContainer","$uicomponent.id")%>" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
<a href="<%=uicomponent.event("DeleteComponent","$uicomponent.id")%>" class="DeleteContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.closeContainer")%>"><span></span></a>
<%}%>
</div>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIToolbarContainer.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIToolbarContainer.gtmpl 2011-08-18 19:06:18 UTC (rev 7178)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/container/UIToolbarContainer.gtmpl 2011-08-18 20:04:11 UTC (rev 7179)
@@ -70,7 +70,7 @@
%>
<div class="ContainerIcon DefaultContainer16x16Icon"><%=hasPermission ? strTitle : _ctx.appRes("UIPortlet.label.protectedContent")%></div>
<%if(hasPermission) {%>
- <a href="<%=uicomponent.event("EditContainer","$uicomponent.id")%>;eXo.portal.UIPortal.changeComposerSaveButton()" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
+ <a href="<%=uicomponent.event("EditContainer","$uicomponent.id")%>;" class="EditContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.editContainer")%>"><span></span></a>
<a href="<%=uicomponent.event("DeleteComponent","$uicomponent.id")%>" class="DeleteContainerIcon" title="<%=_ctx.appRes("UIContainer.tooltip.closeContainer")%>"><span></span></a>
<%}%>
</div>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalComposer.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalComposer.gtmpl 2011-08-18 19:06:18 UTC (rev 7178)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalComposer.gtmpl 2011-08-18 20:04:11 UTC (rev 7179)
@@ -52,7 +52,7 @@
<tr>
<td>
- <div onclick="<%= uicomponent.event("ViewProperties") %>;eXo.portal.UIPortal.changeComposerSaveButton()" class="ActionButton SimpleStyle1">
+ <div onclick="<%= uicomponent.event("ViewProperties") %>;" class="ActionButton SimpleStyle1">
<div class="ButtonLeft">
<div class="ButtonRight">
<div class="ButtonMiddle">
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletForm.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletForm.java 2011-08-18 19:06:18 UTC (rev 7178)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletForm.java 2011-08-18 20:04:11 UTC (rev 7179)
@@ -397,6 +397,7 @@
}
PortalRequestContext pcontext = (PortalRequestContext)event.getRequestContext();
+ pcontext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
pcontext.addUIComponentToUpdateByAjax(uiMaskWorkspace);
UIPortalApplication uiPortalApp = uiPortlet.getAncestorOfType(UIPortalApplication.class);
UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerForm.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerForm.java 2011-08-18 19:06:18 UTC (rev 7178)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerForm.java 2011-08-18 20:04:11 UTC (rev 7179)
@@ -143,6 +143,7 @@
UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
+ pcontext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
pcontext.ignoreAJAXUpdateOnPortlets(true);
Util.showComponentLayoutMode(UIContainer.class);
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java 2011-08-18 19:06:18 UTC (rev 7178)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java 2011-08-18 20:04:11 UTC (rev 7179)
@@ -281,7 +281,7 @@
PortalRequestContext pcontext = Util.getPortalRequestContext();
UIMaskWorkspace uiMaskWS = uiPortalApp.getChildById(UIPortalApplication.UI_MASK_WS_ID);
uiMaskWS.setUIComponent(null);
- uiMaskWS.setShow(false);
+ uiMaskWS.setShow(false);
pcontext.addUIComponentToUpdateByAjax(uiMaskWS);
UIPage uiPage = uiPageForm.getUIPage();
@@ -355,6 +355,7 @@
try{
PortalDataMapper.toUIPage(uiPage, page);
+ pcontext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
} catch(NoSuchDataException de){
uiPortalApp.addMessage(new ApplicationMessage("UIPageForm.msg.notExistOrDeleted", null, ApplicationMessage.ERROR));
UIPortalComposer uiPortalComposer = (UIPortalComposer)uiPortalApp.findComponentById("UIPageEditor");
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java 2011-08-18 19:06:18 UTC (rev 7178)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java 2011-08-18 20:04:11 UTC (rev 7179)
@@ -348,7 +348,12 @@
UIMaskWorkspace uiMaskWorkspace = uiForm.getParent();
uiMaskWorkspace.setUIComponent(null);
- event.getRequestContext().addUIComponentToUpdateByAjax(uiMaskWorkspace);
+ WebuiRequestContext rContext = event.getRequestContext();
+ if (!uiForm.getId().equals("CreatePortal"))
+ {
+ rContext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
+ }
+ rContext.addUIComponentToUpdateByAjax(uiMaskWorkspace);
}
}
13 years, 4 months