gatein SVN: r3702 - portal/trunk/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-07-23 18:50:45 -0400 (Fri, 23 Jul 2010)
New Revision: 3702
Modified:
portal/trunk/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletURLBuilder.java
Log:
todo
Modified: portal/trunk/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletURLBuilder.java
===================================================================
--- portal/trunk/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletURLBuilder.java 2010-07-23 22:43:16 UTC (rev 3701)
+++ portal/trunk/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletURLBuilder.java 2010-07-23 22:50:45 UTC (rev 3702)
@@ -25,6 +25,8 @@
import org.exoplatform.webui.core.UIComponent;
/**
+ * 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
*/
14 years, 5 months
gatein SVN: r3701 - in portal/trunk/component: resources and 7 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-07-23 18:43:16 -0400 (Fri, 23 Jul 2010)
New Revision: 3701
Modified:
portal/trunk/component/pc/pom.xml
portal/trunk/component/resources/pom.xml
portal/trunk/component/scripting/pom.xml
portal/trunk/component/web/api/pom.xml
portal/trunk/component/web/controller/pom.xml
portal/trunk/component/web/resources/pom.xml
portal/trunk/component/web/security/pom.xml
portal/trunk/component/web/server/pom.xml
portal/trunk/component/wsrp/pom.xml
Log:
- improve maven dependencies
- put description on maven modules that were created
Modified: portal/trunk/component/pc/pom.xml
===================================================================
--- portal/trunk/component/pc/pom.xml 2010-07-23 21:58:05 UTC (rev 3700)
+++ portal/trunk/component/pc/pom.xml 2010-07-23 22:43:16 UTC (rev 3701)
@@ -30,7 +30,7 @@
<artifactId>exo.portal.component.pc</artifactId>
<packaging>jar</packaging>
<name>GateIn Portal Component PC integration</name>
-
+
<dependencies>
<dependency>
Modified: portal/trunk/component/resources/pom.xml
===================================================================
--- portal/trunk/component/resources/pom.xml 2010-07-23 21:58:05 UTC (rev 3700)
+++ portal/trunk/component/resources/pom.xml 2010-07-23 22:43:16 UTC (rev 3701)
@@ -30,65 +30,19 @@
<artifactId>exo.portal.component.resources</artifactId>
<packaging>jar</packaging>
<name>GateIn Portal Component Resources</name>
- <description>resources data service...</description>
+ <description>Internationalization and localization resources</description>
<dependencies>
<dependency>
<groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.commons</artifactId>
+ <artifactId>exo.kernel.container</artifactId>
</dependency>
-
<dependency>
<groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.component.common</artifactId>
+ <artifactId>exo.kernel.component.cache</artifactId>
</dependency>
-
- <dependency>
- <groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.component.command</artifactId>
- </dependency>
<dependency>
- <groupId>org.exoplatform.core</groupId>
- <artifactId>exo.core.component.database</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.exoplatform.core</groupId>
- <artifactId>exo.core.component.security.core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.exoplatform.core</groupId>
- <artifactId>exo.core.component.document</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.exoplatform.jcr</groupId>
- <artifactId>exo.jcr.component.core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.exoplatform.jcr</groupId>
- <artifactId>exo.jcr.component.ext</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.common</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.gatein.wci</groupId>
- <artifactId>wci-wci</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
-
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
Modified: portal/trunk/component/scripting/pom.xml
===================================================================
--- portal/trunk/component/scripting/pom.xml 2010-07-23 21:58:05 UTC (rev 3700)
+++ portal/trunk/component/scripting/pom.xml 2010-07-23 22:43:16 UTC (rev 3701)
@@ -30,6 +30,7 @@
<artifactId>exo.portal.component.scripting</artifactId>
<packaging>jar</packaging>
<name>GateIn Portal Component Scripting</name>
+ <description>GateIn scripting and template engine</description>
<dependencies>
<dependency>
@@ -43,11 +44,6 @@
</dependency>
<dependency>
- <groupId>rhino</groupId>
- <artifactId>js</artifactId>
- </dependency>
-
- <dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
</dependency>
Modified: portal/trunk/component/web/api/pom.xml
===================================================================
--- portal/trunk/component/web/api/pom.xml 2010-07-23 21:58:05 UTC (rev 3700)
+++ portal/trunk/component/web/api/pom.xml 2010-07-23 22:43:16 UTC (rev 3701)
@@ -28,15 +28,16 @@
<artifactId>exo.portal.component.web.api</artifactId>
<packaging>jar</packaging>
<name>GateIn Portal Component Web API</name>
+ <description>Various API supported by GateIn related to web serving</description>
<dependencies>
<dependency>
<groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.container</artifactId>
+ <artifactId>exo.kernel.component.common</artifactId>
</dependency>
<dependency>
- <groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.common</artifactId>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.container</artifactId>
</dependency>
<dependency>
<groupId>org.exoplatform.portal</groupId>
Modified: portal/trunk/component/web/controller/pom.xml
===================================================================
--- portal/trunk/component/web/controller/pom.xml 2010-07-23 21:58:05 UTC (rev 3700)
+++ portal/trunk/component/web/controller/pom.xml 2010-07-23 22:43:16 UTC (rev 3701)
@@ -28,13 +28,10 @@
<artifactId>exo.portal.component.web.controller</artifactId>
<packaging>jar</packaging>
<name>GateIn Portal Component Web Controller</name>
+ <description>The GateIn web controller takes care of managing portal requests and delegate the processing to
+ the appropriate subsystem.</description>
- <properties>
- <maven.test.skip>true</maven.test.skip>
- </properties>
-
<dependencies>
-
<dependency>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>exo.kernel.container</artifactId>
Modified: portal/trunk/component/web/resources/pom.xml
===================================================================
--- portal/trunk/component/web/resources/pom.xml 2010-07-23 21:58:05 UTC (rev 3700)
+++ portal/trunk/component/web/resources/pom.xml 2010-07-23 22:43:16 UTC (rev 3701)
@@ -28,13 +28,26 @@
<artifactId>exo.portal.component.web.resources</artifactId>
<packaging>jar</packaging>
<name>GateIn Portal Component Web Resources</name>
+ <description>GateIn web resource serving services such as Javascript, skins and stylesheets</description>
<dependencies>
<dependency>
<groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
<artifactId>exo.portal.component.resources</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.gatein.wci</groupId>
+ <artifactId>wci-wci</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
</dependencies>
</project>
Modified: portal/trunk/component/web/security/pom.xml
===================================================================
--- portal/trunk/component/web/security/pom.xml 2010-07-23 21:58:05 UTC (rev 3700)
+++ portal/trunk/component/web/security/pom.xml 2010-07-23 22:43:16 UTC (rev 3701)
@@ -28,16 +28,13 @@
<artifactId>exo.portal.component.web.security</artifactId>
<packaging>jar</packaging>
<name>GateIn Portal Component Web Security</name>
+ <description>GateIn web security services</description>
- <properties>
- <maven.test.skip>true</maven.test.skip>
- </properties>
-
<dependencies>
<dependency>
- <groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.container</artifactId>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.container</artifactId>
</dependency>
<dependency>
<groupId>org.exoplatform.core</groupId>
@@ -47,17 +44,7 @@
<groupId>org.exoplatform.portal</groupId>
<artifactId>exo.portal.component.common</artifactId>
</dependency>
-<!--
<dependency>
- <groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.web.controller</artifactId>
- </dependency>
- <dependency>
- <groupId>org.gatein.wci</groupId>
- <artifactId>wci-wci</artifactId>
- </dependency>
--->
- <dependency>
<groupId>org.chromattic</groupId>
<artifactId>chromattic.apt</artifactId>
<scope>compile</scope>
Modified: portal/trunk/component/web/server/pom.xml
===================================================================
--- portal/trunk/component/web/server/pom.xml 2010-07-23 21:58:05 UTC (rev 3700)
+++ portal/trunk/component/web/server/pom.xml 2010-07-23 22:43:16 UTC (rev 3701)
@@ -28,11 +28,8 @@
<artifactId>exo.portal.component.web.server</artifactId>
<packaging>jar</packaging>
<name>GateIn Portal Component Web Server</name>
+ <description>GateIn web server services</description>
- <properties>
- <maven.test.skip>true</maven.test.skip>
- </properties>
-
<dependencies>
<dependency>
<groupId>org.exoplatform.kernel</groupId>
Modified: portal/trunk/component/wsrp/pom.xml
===================================================================
--- portal/trunk/component/wsrp/pom.xml 2010-07-23 21:58:05 UTC (rev 3700)
+++ portal/trunk/component/wsrp/pom.xml 2010-07-23 22:43:16 UTC (rev 3701)
@@ -70,6 +70,11 @@
<artifactId>exo.portal.component.pc</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.common</artifactId>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.exoplatform.jcr</groupId>
14 years, 5 months
gatein SVN: r3700 - in portal/trunk: component/resources/src/main/java and 17 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-07-23 17:58:05 -0400 (Fri, 23 Jul 2010)
New Revision: 3700
Added:
portal/trunk/component/web/resources/
portal/trunk/component/web/resources/pom.xml
portal/trunk/component/web/resources/src/
portal/trunk/component/web/resources/src/main/
portal/trunk/component/web/resources/src/main/java/
portal/trunk/component/web/resources/src/main/java/gatein_resources_1_0.xsd
portal/trunk/component/web/resources/src/main/java/gatein_resources_1_1.xsd
portal/trunk/component/web/resources/src/main/java/org/
portal/trunk/component/web/resources/src/main/java/org/exoplatform/
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/
portal/trunk/component/web/resources/src/main/java/org/exoplatform/web/
portal/trunk/component/web/resources/src/main/java/org/exoplatform/web/application/JavascriptManager.java
portal/trunk/component/web/resources/src/test/
portal/trunk/component/web/resources/src/test/java/
portal/trunk/component/web/resources/src/test/java/org/
portal/trunk/component/web/resources/src/test/java/org/exoplatform/
portal/trunk/component/web/resources/src/test/java/org/exoplatform/portal/
Removed:
portal/trunk/component/resources/src/main/java/gatein_resources_1_0.xsd
portal/trunk/component/resources/src/main/java/gatein_resources_1_1.xsd
portal/trunk/component/resources/src/main/java/org/exoplatform/portal/
portal/trunk/component/resources/src/main/java/org/exoplatform/web/
portal/trunk/component/resources/src/test/java/org/exoplatform/portal/
Modified:
portal/trunk/component/web/controller/pom.xml
portal/trunk/component/web/pom.xml
portal/trunk/packaging/jboss-as/ear/pom.xml
portal/trunk/packaging/module/src/main/javascript/portal.packaging.module.js
portal/trunk/pom.xml
Log:
GTNPORTAL-1374 : component.web modularization / move resource for web into the component.web.resources module (putting them in component.resources in the first place was a mistake)
Deleted: portal/trunk/component/resources/src/main/java/gatein_resources_1_0.xsd
===================================================================
--- portal/trunk/component/resources/src/main/java/gatein_resources_1_0.xsd 2010-07-23 21:22:58 UTC (rev 3699)
+++ portal/trunk/component/resources/src/main/java/gatein_resources_1_0.xsd 2010-07-23 21:58:05 UTC (rev 3700)
@@ -1,117 +0,0 @@
-<?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_resources_1_0"
- xmlns="http://www.gatein.org/xml/ns/gatein_resources_1_0"
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified"
- version="1.0">
-
- <!-- The root element type that contains the various resource declarations -->
- <xs:element name="gatein-resources">
- <xs:complexType>
- <xs:choice minOccurs="0" maxOccurs="unbounded">
- <xs:element name="portal-skin" type="portal-skin" />
- <xs:element name="portlet-skin" type="portlet-skin" />
- <xs:element name="window-style" type="window-style" />
- <xs:element name="javascript" type="javascript" />
- <xs:element name="resource-bundle" type="resource-bundle" />
- </xs:choice>
- </xs:complexType>
- </xs:element>
-
- <!-- Declares a portal skin resource -->
- <xs:complexType name="portal-skin">
- <xs:sequence>
- <xs:element name="skin-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
- <xs:element name="css-path" type="xs:string" minOccurs="1" maxOccurs="1"/>
- <xs:element name="overwrite" type="xs:string" minOccurs="0" maxOccurs="1"/>
- </xs:sequence>
- </xs:complexType>
-
- <!-- Declares a portlet skin resource -->
- <xs:complexType name="portlet-skin">
- <xs:sequence>
- <!-- The portlet application name -->
- <xs:element name="application-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
-
- <!-- The portlet name -->
- <xs:element name="portlet-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
-
- <!-- The name of the skin to load -->
- <xs:element name="skin-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
-
- <!-- The css path of the skin relative to the application context -->
- <xs:element name="css-path" type="xs:string" minOccurs="1" maxOccurs="1"/>
-
- <!-- Overwrite -->
- <xs:element name="overwrite" type="xs:string" minOccurs="0" maxOccurs="1"/>
- </xs:sequence>
- </xs:complexType>
-
- <!-- Declares a window style -->
- <xs:complexType name="window-style" mixed="true">
- <xs:sequence>
-
- <!-- The window style name -->
- <xs:element name="style-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
-
- <!-- The window style theme -->
- <xs:element name="style-theme" type="style-theme" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- </xs:complexType>
-
- <!-- The window style theme -->
- <xs:complexType name="style-theme">
- <xs:sequence>
- <!-- The theme name -->
- <xs:element name="theme-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
- </xs:sequence>
- </xs:complexType>
-
- <!-- Declares a javascript resource -->
- <xs:complexType name="javascript">
- <xs:sequence>
- <xs:element name="param" type="param" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="param">
- <xs:sequence>
- <!-- The javascript module -->
- <xs:element name="js-module" type="xs:string" minOccurs="1" maxOccurs="1"/>
-
- <!-- The javascript path -->
- <xs:element name="js-path" type="xs:string" minOccurs="1" maxOccurs="1"/>
-
- <!-- The javascript priority -->
- <xs:element name="js-priority" type="xs:string" minOccurs="0" maxOccurs="1"/>
- </xs:sequence>
- </xs:complexType>
-
- <!-- Declares a resource bundle -->
- <xs:complexType name="resource-bundle">
- </xs:complexType>
-
-</xs:schema>
\ No newline at end of file
Deleted: portal/trunk/component/resources/src/main/java/gatein_resources_1_1.xsd
===================================================================
--- portal/trunk/component/resources/src/main/java/gatein_resources_1_1.xsd 2010-07-23 21:22:58 UTC (rev 3699)
+++ portal/trunk/component/resources/src/main/java/gatein_resources_1_1.xsd 2010-07-23 21:58:05 UTC (rev 3700)
@@ -1,116 +0,0 @@
-<?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_resources_1_1"
- xmlns="http://www.gatein.org/xml/ns/gatein_resources_1_1"
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified"
- version="1.0">
-
- <!-- The root element type that contains the various resource declarations -->
- <xs:element name="gatein-resources">
- <xs:complexType>
- <xs:choice minOccurs="0" maxOccurs="unbounded">
- <xs:element name="portal-skin" type="portal-skin" />
- <xs:element name="portlet-skin" type="portlet-skin" />
- <xs:element name="window-style" type="window-style" />
- <xs:element name="javascript" type="javascript" />
- <xs:element name="resource-bundle" type="resource-bundle" />
- </xs:choice>
- </xs:complexType>
- </xs:element>
-
- <!-- Declares a portal skin resource -->
- <xs:complexType name="portal-skin">
- <xs:sequence>
- <xs:element name="skin-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
- <xs:element name="skin-module" type="xs:string" minOccurs="0" maxOccurs="1"/>
- <xs:element name="css-path" type="xs:string" minOccurs="1" maxOccurs="1"/>
- <xs:element name="overwrite" type="xs:string" minOccurs="0" maxOccurs="1"/>
- </xs:sequence>
- </xs:complexType>
-
- <!-- Declares a portlet skin resource -->
- <xs:complexType name="portlet-skin">
- <xs:sequence>
- <!-- The portlet application name -->
- <xs:element name="application-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
-
- <!-- The portlet name -->
- <xs:element name="portlet-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
-
- <!-- The name of the skin to load -->
- <xs:element name="skin-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
-
- <!-- The css path of the skin relative to the application context -->
- <xs:element name="css-path" type="xs:string" minOccurs="1" maxOccurs="1"/>
-
- <!-- Overwrite -->
- <xs:element name="overwrite" type="xs:string" minOccurs="0" maxOccurs="1"/>
- </xs:sequence>
- </xs:complexType>
-
- <!-- Declares a window style -->
- <xs:complexType name="window-style" mixed="true">
- <xs:sequence>
-
- <!-- The window style name -->
- <xs:element name="style-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
-
- <!-- The window style theme -->
- <xs:element name="style-theme" type="style-theme" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- </xs:complexType>
-
- <!-- The window style theme -->
- <xs:complexType name="style-theme">
- <xs:sequence>
- <!-- The theme name -->
- <xs:element name="theme-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
- </xs:sequence>
- </xs:complexType>
-
- <!-- Declares a javascript resource -->
- <xs:complexType name="javascript">
- <xs:sequence>
- <xs:element name="param" type="param" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="param">
- <xs:sequence>
- <!-- The javascript module -->
- <xs:element name="js-module" type="xs:string" minOccurs="1" maxOccurs="1"/>
-
- <!-- The javascript path -->
- <xs:element name="js-path" type="xs:string" minOccurs="1" maxOccurs="1"/>
-
- <!-- The javascript priority -->
- <xs:element name="js-priority" type="xs:string" minOccurs="0" maxOccurs="1"/>
- </xs:sequence>
- </xs:complexType>
-
- <!-- Declares a resource bundle -->
- <xs:complexType name="resource-bundle">
- </xs:complexType>
-
-</xs:schema>
\ No newline at end of file
Modified: portal/trunk/component/web/controller/pom.xml
===================================================================
--- portal/trunk/component/web/controller/pom.xml 2010-07-23 21:22:58 UTC (rev 3699)
+++ portal/trunk/component/web/controller/pom.xml 2010-07-23 21:58:05 UTC (rev 3700)
@@ -41,7 +41,7 @@
</dependency>
<dependency>
<groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.resources</artifactId>
+ <artifactId>exo.portal.component.web.resources</artifactId>
</dependency>
</dependencies>
</project>
Modified: portal/trunk/component/web/pom.xml
===================================================================
--- portal/trunk/component/web/pom.xml 2010-07-23 21:22:58 UTC (rev 3699)
+++ portal/trunk/component/web/pom.xml 2010-07-23 21:58:05 UTC (rev 3700)
@@ -35,6 +35,7 @@
<module>controller</module>
<module>security</module>
<module>server</module>
+ <module>resources</module>
<module>api</module>
</modules>
</project>
Added: portal/trunk/component/web/resources/pom.xml
===================================================================
--- portal/trunk/component/web/resources/pom.xml (rev 0)
+++ portal/trunk/component/web/resources/pom.xml 2010-07-23 21:58:05 UTC (rev 3700)
@@ -0,0 +1,40 @@
+<!--
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web</artifactId>
+ <version>3.2.0-Beta01-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>exo.portal.component.web.resources</artifactId>
+ <packaging>jar</packaging>
+ <name>GateIn Portal Component Web Resources</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.resources</artifactId>
+ </dependency>
+
+ </dependencies>
+</project>
Copied: portal/trunk/component/web/resources/src/main/java/gatein_resources_1_0.xsd (from rev 3698, portal/trunk/component/resources/src/main/java/gatein_resources_1_0.xsd)
===================================================================
--- portal/trunk/component/web/resources/src/main/java/gatein_resources_1_0.xsd (rev 0)
+++ portal/trunk/component/web/resources/src/main/java/gatein_resources_1_0.xsd 2010-07-23 21:58:05 UTC (rev 3700)
@@ -0,0 +1,117 @@
+<?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_resources_1_0"
+ xmlns="http://www.gatein.org/xml/ns/gatein_resources_1_0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0">
+
+ <!-- The root element type that contains the various resource declarations -->
+ <xs:element name="gatein-resources">
+ <xs:complexType>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="portal-skin" type="portal-skin" />
+ <xs:element name="portlet-skin" type="portlet-skin" />
+ <xs:element name="window-style" type="window-style" />
+ <xs:element name="javascript" type="javascript" />
+ <xs:element name="resource-bundle" type="resource-bundle" />
+ </xs:choice>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- Declares a portal skin resource -->
+ <xs:complexType name="portal-skin">
+ <xs:sequence>
+ <xs:element name="skin-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
+ <xs:element name="css-path" type="xs:string" minOccurs="1" maxOccurs="1"/>
+ <xs:element name="overwrite" type="xs:string" minOccurs="0" maxOccurs="1"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!-- Declares a portlet skin resource -->
+ <xs:complexType name="portlet-skin">
+ <xs:sequence>
+ <!-- The portlet application name -->
+ <xs:element name="application-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
+
+ <!-- The portlet name -->
+ <xs:element name="portlet-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
+
+ <!-- The name of the skin to load -->
+ <xs:element name="skin-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
+
+ <!-- The css path of the skin relative to the application context -->
+ <xs:element name="css-path" type="xs:string" minOccurs="1" maxOccurs="1"/>
+
+ <!-- Overwrite -->
+ <xs:element name="overwrite" type="xs:string" minOccurs="0" maxOccurs="1"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!-- Declares a window style -->
+ <xs:complexType name="window-style" mixed="true">
+ <xs:sequence>
+
+ <!-- The window style name -->
+ <xs:element name="style-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
+
+ <!-- The window style theme -->
+ <xs:element name="style-theme" type="style-theme" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!-- The window style theme -->
+ <xs:complexType name="style-theme">
+ <xs:sequence>
+ <!-- The theme name -->
+ <xs:element name="theme-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!-- Declares a javascript resource -->
+ <xs:complexType name="javascript">
+ <xs:sequence>
+ <xs:element name="param" type="param" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="param">
+ <xs:sequence>
+ <!-- The javascript module -->
+ <xs:element name="js-module" type="xs:string" minOccurs="1" maxOccurs="1"/>
+
+ <!-- The javascript path -->
+ <xs:element name="js-path" type="xs:string" minOccurs="1" maxOccurs="1"/>
+
+ <!-- The javascript priority -->
+ <xs:element name="js-priority" type="xs:string" minOccurs="0" maxOccurs="1"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!-- Declares a resource bundle -->
+ <xs:complexType name="resource-bundle">
+ </xs:complexType>
+
+</xs:schema>
\ No newline at end of file
Copied: portal/trunk/component/web/resources/src/main/java/gatein_resources_1_1.xsd (from rev 3698, portal/trunk/component/resources/src/main/java/gatein_resources_1_1.xsd)
===================================================================
--- portal/trunk/component/web/resources/src/main/java/gatein_resources_1_1.xsd (rev 0)
+++ portal/trunk/component/web/resources/src/main/java/gatein_resources_1_1.xsd 2010-07-23 21:58:05 UTC (rev 3700)
@@ -0,0 +1,116 @@
+<?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_resources_1_1"
+ xmlns="http://www.gatein.org/xml/ns/gatein_resources_1_1"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0">
+
+ <!-- The root element type that contains the various resource declarations -->
+ <xs:element name="gatein-resources">
+ <xs:complexType>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="portal-skin" type="portal-skin" />
+ <xs:element name="portlet-skin" type="portlet-skin" />
+ <xs:element name="window-style" type="window-style" />
+ <xs:element name="javascript" type="javascript" />
+ <xs:element name="resource-bundle" type="resource-bundle" />
+ </xs:choice>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- Declares a portal skin resource -->
+ <xs:complexType name="portal-skin">
+ <xs:sequence>
+ <xs:element name="skin-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
+ <xs:element name="skin-module" type="xs:string" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="css-path" type="xs:string" minOccurs="1" maxOccurs="1"/>
+ <xs:element name="overwrite" type="xs:string" minOccurs="0" maxOccurs="1"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!-- Declares a portlet skin resource -->
+ <xs:complexType name="portlet-skin">
+ <xs:sequence>
+ <!-- The portlet application name -->
+ <xs:element name="application-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
+
+ <!-- The portlet name -->
+ <xs:element name="portlet-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
+
+ <!-- The name of the skin to load -->
+ <xs:element name="skin-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
+
+ <!-- The css path of the skin relative to the application context -->
+ <xs:element name="css-path" type="xs:string" minOccurs="1" maxOccurs="1"/>
+
+ <!-- Overwrite -->
+ <xs:element name="overwrite" type="xs:string" minOccurs="0" maxOccurs="1"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!-- Declares a window style -->
+ <xs:complexType name="window-style" mixed="true">
+ <xs:sequence>
+
+ <!-- The window style name -->
+ <xs:element name="style-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
+
+ <!-- The window style theme -->
+ <xs:element name="style-theme" type="style-theme" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!-- The window style theme -->
+ <xs:complexType name="style-theme">
+ <xs:sequence>
+ <!-- The theme name -->
+ <xs:element name="theme-name" type="xs:string" minOccurs="1" maxOccurs="1"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!-- Declares a javascript resource -->
+ <xs:complexType name="javascript">
+ <xs:sequence>
+ <xs:element name="param" type="param" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="param">
+ <xs:sequence>
+ <!-- The javascript module -->
+ <xs:element name="js-module" type="xs:string" minOccurs="1" maxOccurs="1"/>
+
+ <!-- The javascript path -->
+ <xs:element name="js-path" type="xs:string" minOccurs="1" maxOccurs="1"/>
+
+ <!-- The javascript priority -->
+ <xs:element name="js-priority" type="xs:string" minOccurs="0" maxOccurs="1"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!-- Declares a resource bundle -->
+ <xs:complexType name="resource-bundle">
+ </xs:complexType>
+
+</xs:schema>
\ No newline at end of file
Copied: portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal (from rev 3698, portal/trunk/component/resources/src/main/java/org/exoplatform/portal)
Copied: portal/trunk/component/web/resources/src/main/java/org/exoplatform/web (from rev 3698, portal/trunk/component/resources/src/main/java/org/exoplatform/web)
Copied: portal/trunk/component/web/resources/src/main/java/org/exoplatform/web/application/JavascriptManager.java (from rev 3699, portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/JavascriptManager.java)
===================================================================
--- portal/trunk/component/web/resources/src/main/java/org/exoplatform/web/application/JavascriptManager.java (rev 0)
+++ portal/trunk/component/web/resources/src/main/java/org/exoplatform/web/application/JavascriptManager.java 2010-07-23 21:58:05 UTC (rev 3700)
@@ -0,0 +1,166 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.application;
+
+import org.exoplatform.commons.utils.PropertyManager;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.web.application.javascript.JavascriptConfigService;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+
+/**
+ * Created by The eXo Platform SAS
+ * Mar 27, 2007
+ */
+public class JavascriptManager
+{
+
+ /** . */
+ private ArrayList<String> data = new ArrayList<String>(100);
+
+ /** . */
+ private ArrayList<String> customizedOnloadJavascript = null;
+
+ /** . */
+ private JavascriptConfigService jsSrevice_;
+
+ public JavascriptManager()
+ {
+ jsSrevice_ =
+ (JavascriptConfigService)ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(
+ JavascriptConfigService.class);
+ }
+
+ public void addJavascript(CharSequence s)
+ {
+ if (s != null)
+ {
+ data.add(s instanceof String ? (String)s : s.toString());
+ data.add(" \n");
+ }
+ }
+
+ public void importJavascript(CharSequence s)
+ {
+ if (s != null)
+ {
+ if (!jsSrevice_.isModuleLoaded(s) || PropertyManager.isDevelopping())
+ {
+ data.add("eXo.require('");
+ data.add(s instanceof String ? (String)s : s.toString());
+ data.add("'); \n");
+ }
+ }
+ }
+
+ public void importJavascript(String s, String location)
+ {
+ if (s != null && location != null)
+ {
+ if (!jsSrevice_.isModuleLoaded(s) || PropertyManager.isDevelopping())
+ {
+ data.add("eXo.require('");
+ data.add(s);
+ data.add("', '");
+ data.add(location);
+ if (!location.endsWith("/"))
+ {
+ data.add("/");
+ }
+ data.add("'); \n");
+ }
+ }
+ }
+
+ public void addOnLoadJavascript(CharSequence s)
+ {
+ if (s != null)
+ {
+ String id = Integer.toString(Math.abs(s.hashCode()));
+ data.add("eXo.core.Browser.addOnLoadCallback('mid");
+ data.add(id);
+ data.add("',");
+ data.add(s instanceof String ? (String)s : s.toString());
+ data.add("); \n");
+ }
+ }
+
+ public void addOnResizeJavascript(CharSequence s)
+ {
+ if (s != null)
+ {
+ String id = Integer.toString(Math.abs(s.hashCode()));
+ data.add("eXo.core.Browser.addOnResizeCallback('mid");
+ data.add(id);
+ data.add("',");
+ data.add(s instanceof String ? (String)s : s.toString());
+ data.add("); \n");
+ }
+ }
+
+ public void addOnScrollJavascript(CharSequence s)
+ {
+ if (s != null)
+ {
+ String id = Integer.toString(Math.abs(s.hashCode()));
+ data.add("eXo.core.Browser.addOnScrollCallback('mid");
+ data.add(id);
+ data.add("',");
+ data.add(s instanceof String ? (String)s : s.toString());
+ data.add("); \n");
+ }
+ }
+
+ public void writeJavascript(Writer writer) throws IOException
+ {
+ for (int i = 0;i < data.size();i++)
+ {
+ String s = data.get(i);
+ writer.write(s);
+ }
+ }
+
+ public void addCustomizedOnLoadScript(CharSequence s)
+ {
+ if (s != null)
+ {
+ if (customizedOnloadJavascript == null)
+ {
+ customizedOnloadJavascript = new ArrayList<String>(30);
+ }
+ customizedOnloadJavascript.add(s instanceof String ? (String)s : s.toString());
+ customizedOnloadJavascript.add("\n");
+ }
+ }
+
+ public void writeCustomizedOnLoadScript(Writer writer) throws IOException
+ {
+ if (customizedOnloadJavascript != null)
+ {
+ for (int i = 0;i < customizedOnloadJavascript.size();i++)
+ {
+ String s = customizedOnloadJavascript.get(i);
+ writer.write(s);
+ }
+ }
+ }
+}
Copied: portal/trunk/component/web/resources/src/test/java/org/exoplatform/portal (from rev 3698, portal/trunk/component/resources/src/test/java/org/exoplatform/portal)
Modified: portal/trunk/packaging/jboss-as/ear/pom.xml
===================================================================
--- portal/trunk/packaging/jboss-as/ear/pom.xml 2010-07-23 21:22:58 UTC (rev 3699)
+++ portal/trunk/packaging/jboss-as/ear/pom.xml 2010-07-23 21:58:05 UTC (rev 3700)
@@ -104,6 +104,10 @@
</dependency>
<dependency>
<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>
<dependency>
Modified: portal/trunk/packaging/module/src/main/javascript/portal.packaging.module.js
===================================================================
--- portal/trunk/packaging/module/src/main/javascript/portal.packaging.module.js 2010-07-23 21:22:58 UTC (rev 3699)
+++ portal/trunk/packaging/module/src/main/javascript/portal.packaging.module.js 2010-07-23 21:58:05 UTC (rev 3700)
@@ -112,6 +112,9 @@
addDependency(module.component.web.controller).
addDependency(module.component.scripting);
+ module.component.web.resources =
+ new Project("org.exoplatform.portal", "exo.portal.component.web.resources", "jar", module.version);;
+
module.component.web.api =
new Project("org.exoplatform.portal", "exo.portal.component.web.api", "jar", module.version);
@@ -155,6 +158,7 @@
addDependency(module.component.web.server).
addDependency(module.component.web.security).
addDependency(module.component.web.api).
+ addDependency(module.component.web.resources).
addDependency(module.component.web.controller);
module.webui.portlet =
Modified: portal/trunk/pom.xml
===================================================================
--- portal/trunk/pom.xml 2010-07-23 21:22:58 UTC (rev 3699)
+++ portal/trunk/pom.xml 2010-07-23 21:58:05 UTC (rev 3700)
@@ -391,6 +391,11 @@
</dependency>
<dependency>
<groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web.resources</artifactId>
+ <version>3.2.0-Beta01-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
<artifactId>exo.portal.component.portal</artifactId>
<version>3.2.0-Beta01-SNAPSHOT</version>
</dependency>
14 years, 5 months
gatein SVN: r3699 - in portal/trunk: component/application-registry and 66 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-07-23 17:22:58 -0400 (Fri, 23 Jul 2010)
New Revision: 3699
Added:
portal/trunk/component/common/src/main/java/org/exoplatform/resolver/
portal/trunk/component/common/src/main/java/org/exoplatform/resolver/ApplicationResourceResolver.java
portal/trunk/component/common/src/main/java/org/exoplatform/resolver/ClasspathResourceResolver.java
portal/trunk/component/common/src/main/java/org/exoplatform/resolver/FileResourceResolver.java
portal/trunk/component/common/src/main/java/org/exoplatform/resolver/MockResourceResolver.java
portal/trunk/component/common/src/main/java/org/exoplatform/resolver/PortletResourceResolver.java
portal/trunk/component/common/src/main/java/org/exoplatform/resolver/ResourceKey.java
portal/trunk/component/common/src/main/java/org/exoplatform/resolver/ResourceResolver.java
portal/trunk/component/common/src/main/java/org/exoplatform/resolver/ServletResourceResolver.java
portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/JavascriptManager.java
portal/trunk/component/web/api/
portal/trunk/component/web/api/pom.xml
portal/trunk/component/web/api/src/
portal/trunk/component/web/api/src/main/
portal/trunk/component/web/api/src/main/java/
portal/trunk/component/web/api/src/main/java/org/
portal/trunk/component/web/api/src/main/java/org/exoplatform/
portal/trunk/component/web/api/src/main/java/org/exoplatform/web/
portal/trunk/component/web/api/src/main/java/org/exoplatform/web/GenericHttpListener.java
portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/
portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/ExtensibleFilter.java
portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/Filter.java
portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/FilterDefinition.java
portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/FilterDefinitionPlugin.java
portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/FilterMapping.java
portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/GenericFilter.java
portal/trunk/component/web/api/src/main/java/org/exoplatform/web/resource/
portal/trunk/component/web/api/src/test/
portal/trunk/component/web/api/src/test/java/
portal/trunk/component/web/api/src/test/java/conf/
portal/trunk/component/web/api/src/test/java/conf/portal/
portal/trunk/component/web/api/src/test/java/conf/portal/test-configuration.xml
portal/trunk/component/web/api/src/test/java/org/
portal/trunk/component/web/api/src/test/java/org/exoplatform/
portal/trunk/component/web/api/src/test/java/org/exoplatform/web/
portal/trunk/component/web/api/src/test/java/org/exoplatform/web/command/
portal/trunk/component/web/api/src/test/java/org/exoplatform/web/command/TestCommandHandler.java
portal/trunk/component/web/api/src/test/java/org/exoplatform/web/filter/
portal/trunk/component/web/api/src/test/java/org/exoplatform/web/filter/TestExtensibleFilter.java
portal/trunk/component/web/api/src/test/java/org/exoplatform/web/filter/TestFilterDefinition.java
portal/trunk/component/web/api/src/test/resources/
portal/trunk/component/web/api/src/test/resources/TestJSonFormat.html
portal/trunk/component/web/controller/
portal/trunk/component/web/controller/pom.xml
portal/trunk/component/web/controller/src/
portal/trunk/component/web/controller/src/main/
portal/trunk/component/web/controller/src/main/java/
portal/trunk/component/web/controller/src/main/java/org/
portal/trunk/component/web/controller/src/main/java/org/exoplatform/
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/WebAppController.java
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/WebRequestHandler.java
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/Application.java
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationLifecycle.java
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationMessage.java
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationSession.java
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/Parameter.java
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/RequestContext.java
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/RequestFailure.java
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/URLBuilder.java
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/command/
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/command/Command.java
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/command/CommandHandler.java
portal/trunk/component/web/security/
portal/trunk/component/web/security/pom.xml
portal/trunk/component/web/security/src/
portal/trunk/component/web/security/src/main/
portal/trunk/component/web/security/src/main/java/
portal/trunk/component/web/security/src/main/java/conf/
portal/trunk/component/web/security/src/main/java/conf/autologin-nodetypes.xml
portal/trunk/component/web/security/src/main/java/conf/portal/
portal/trunk/component/web/security/src/main/java/conf/portal/configuration.xml
portal/trunk/component/web/security/src/main/java/org/
portal/trunk/component/web/security/src/main/java/org/exoplatform/
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/CacheUserProfileFilter.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/ClusteredSSOFilter.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/ErrorLoginServlet.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/PortalLoginController.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/RememberMeFilter.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/CaptchaServlet.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/Credentials.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/GateInToken.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginModule.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/Token.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/TokenStore.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/AbstractTokenService.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/CookieTokenService.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/RemindPasswordTokenService.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/TokenContainer.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/TokenEntry.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/TransientTokenService.java
portal/trunk/component/web/server/
portal/trunk/component/web/server/pom.xml
portal/trunk/component/web/server/src/
portal/trunk/component/web/server/src/main/
portal/trunk/component/web/server/src/main/java/
portal/trunk/component/web/server/src/main/java/org/
portal/trunk/component/web/server/src/main/java/org/exoplatform/
portal/trunk/component/web/server/src/main/java/org/exoplatform/download/
portal/trunk/component/web/server/src/main/java/org/exoplatform/services/
portal/trunk/component/web/server/src/main/java/org/exoplatform/upload/
portal/trunk/component/web/server/src/main/java/org/exoplatform/web/
portal/trunk/component/web/server/src/main/java/org/exoplatform/web/handler/
portal/trunk/component/web/server/src/main/java/org/exoplatform/web/handler/DownloadHandler.java
portal/trunk/component/web/server/src/main/java/org/exoplatform/web/handler/UploadHandler.java
Removed:
portal/trunk/component/web/src/
Modified:
portal/trunk/component/application-registry/pom.xml
portal/trunk/component/portal/pom.xml
portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/ApplicationResourceResolver.java
portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/ClasspathResourceResolver.java
portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/FileResourceResolver.java
portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/MockResourceResolver.java
portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/PortletResourceResolver.java
portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/ResourceKey.java
portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/ResourceResolver.java
portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/ServletResourceResolver.java
portal/trunk/component/web/pom.xml
portal/trunk/examples/extension/ear/pom.xml
portal/trunk/examples/extension/jar/pom.xml
portal/trunk/examples/portal/ear/pom.xml
portal/trunk/examples/portal/jar/pom.xml
portal/trunk/gadgets/core/pom.xml
portal/trunk/gadgets/eXoGadgets/pom.xml
portal/trunk/packaging/jboss-as/ear/pom.xml
portal/trunk/packaging/module/src/main/javascript/portal.packaging.module.js
portal/trunk/pom.xml
portal/trunk/webui/core/pom.xml
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/wysiwyg/FCKEditor.java
portal/trunk/webui/framework/pom.xml
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponent.java
portal/trunk/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplication.java
Log:
GTNPORTAL-1374 : component.web modularization
Modified: portal/trunk/component/application-registry/pom.xml
===================================================================
--- portal/trunk/component/application-registry/pom.xml 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/component/application-registry/pom.xml 2010-07-23 21:22:58 UTC (rev 3699)
@@ -48,6 +48,11 @@
</dependency>
<dependency>
+ <groupId>org.gatein.shindig</groupId>
+ <artifactId>shindig-gadgets</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.chromattic</groupId>
<artifactId>chromattic.ext</artifactId>
</dependency>
Added: portal/trunk/component/common/src/main/java/org/exoplatform/resolver/ApplicationResourceResolver.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/resolver/ApplicationResourceResolver.java (rev 0)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/resolver/ApplicationResourceResolver.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,124 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.resolver;
+
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * This class is an aggregation of ResourceResolver object and extends itself the ResourceResover class.
+ *
+ * Hence every call to this ResourceResolver will in fact be delegated to one of the resolver it aggregates.
+ *
+ * Created by The eXo Platform SAS
+ * Oct 24, 2006
+ */
+public class ApplicationResourceResolver extends ResourceResolver
+{
+
+ protected static Log log = ExoLogger.getLogger("portal:ApplicationResourceResolver");
+
+ private Map<String, ResourceResolver> resolvers_ = new HashMap<String, ResourceResolver>();
+
+ /**
+ * There are by default 2 resolvers already aggregated:
+ * 1) FileResourceResolver
+ * 2) ClasspathResourceResolver
+ */
+ public ApplicationResourceResolver()
+ {
+ addResourceResolver(new FileResourceResolver());
+ addResourceResolver(new ClasspathResourceResolver());
+ }
+
+ public ResourceResolver getResourceResolverByScheme(String scheme)
+ {
+ return resolvers_.get(scheme);
+ }
+
+ public ResourceResolver getResourceResolver(String url)
+ {
+ String scheme = "app:";
+ int index = url.indexOf(":");
+ if (index > 0)
+ scheme = url.substring(0, index + 1);
+ if (log.isDebugEnabled())
+ log.debug("Try to extract resource resolver for the url: " + url);
+ return resolvers_.get(scheme);
+ }
+
+ public void addResourceResolver(ResourceResolver resolver)
+ {
+ if (log.isDebugEnabled())
+ log.debug("Add a resource resolver for the scheme: " + resolver.getResourceScheme());
+ resolvers_.put(resolver.getResourceScheme(), resolver);
+ }
+
+ public URL getResource(String url) throws Exception
+ {
+ return getResourceResolver(url).getResource(url);
+ }
+
+ public InputStream getInputStream(String url) throws Exception
+ {
+ return getResourceResolver(url).getInputStream(url);
+ }
+
+ public List<URL> getResources(String url) throws Exception
+ {
+ return getResourceResolver(url).getResources(url);
+ }
+
+ public List<InputStream> getInputStreams(String url) throws Exception
+ {
+ return getResourceResolver(url).getInputStreams(url);
+ }
+
+ public boolean isModified(String url, long lastAccess)
+ {
+ return getResourceResolver(url).isModified(url, lastAccess);
+ }
+
+ public boolean isResolvable(String url)
+ {
+ return getResourceResolver(url) != null;
+ }
+
+ public String getResourceIdPrefix()
+ {
+ return Integer.toString(hashCode());
+ }
+
+ public String createResourceId(String url)
+ {
+ return hashCode() + ":" + url;
+ }
+
+ public String getResourceScheme()
+ {
+ return "app:";
+ }
+}
Added: portal/trunk/component/common/src/main/java/org/exoplatform/resolver/ClasspathResourceResolver.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/resolver/ClasspathResourceResolver.java (rev 0)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/resolver/ClasspathResourceResolver.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,80 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.resolver;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+/**
+ * Created by The eXo Platform SARL
+ * Author : Tuan Nguyen
+ * tuan08(a)users.sourceforge.net
+ * Mar 15, 2006
+ */
+public class ClasspathResourceResolver extends ResourceResolver
+{
+
+ public URL getResource(String url) throws Exception
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ return cl.getResource(removeScheme(url));
+ }
+
+ public InputStream getInputStream(String url) throws Exception
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ return cl.getResourceAsStream(removeScheme(url));
+ }
+
+ public List<URL> getResources(String url) throws Exception
+ {
+ ArrayList<URL> urlList = new ArrayList<URL>();
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ Enumeration<URL> e = cl.getResources(removeScheme(url));
+ while (e.hasMoreElements())
+ urlList.add(e.nextElement());
+ return urlList;
+ }
+
+ public List<InputStream> getInputStreams(String url) throws Exception
+ {
+ ArrayList<InputStream> inputStreams = new ArrayList<InputStream>();
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ Enumeration<URL> e = cl.getResources(removeScheme(url));
+ while (e.hasMoreElements())
+ inputStreams.add(e.nextElement().openStream());
+ return inputStreams;
+ }
+
+ @SuppressWarnings("unused")
+ public boolean isModified(String url, long lastAccess)
+ {
+ return false;
+ }
+
+ public String getResourceScheme()
+ {
+ return "classpath:";
+ }
+
+}
\ No newline at end of file
Added: portal/trunk/component/common/src/main/java/org/exoplatform/resolver/FileResourceResolver.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/resolver/FileResourceResolver.java (rev 0)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/resolver/FileResourceResolver.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,94 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.resolver;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by The eXo Platform SARL
+ * Author : Tuan Nguyen
+ * tuan08(a)users.sourceforge.net
+ * Mar 15, 2006
+ */
+public class FileResourceResolver extends ResourceResolver
+{
+
+ static String FILE_PREFIX = "file:";
+
+ public URL getResource(String url) throws Exception
+ {
+ String path = removeScheme(url);
+ File file = new File(path);
+ if (file.exists() && file.isFile())
+ return file.toURL();
+ return null;
+ }
+
+ public InputStream getInputStream(String url) throws Exception
+ {
+ String path = removeScheme(url);
+ File file = new File(path);
+ if (file.exists() && file.isFile())
+ {
+ FileInputStream is = new FileInputStream(file);
+ return is;
+ }
+ return null;
+ }
+
+ public List<URL> getResources(String url) throws Exception
+ {
+ ArrayList<URL> urlList = new ArrayList<URL>();
+ urlList.add(getResource(url));
+ return urlList;
+ }
+
+ public List<InputStream> getInputStreams(String url) throws Exception
+ {
+ ArrayList<InputStream> inputStreams = new ArrayList<InputStream>();
+ inputStreams.add(getInputStream(url));
+ return inputStreams;
+ }
+
+ public String getRealPath(String url)
+ {
+ String path = removeScheme(url);
+ return path;
+ }
+
+ public boolean isModified(String url, long lastAccess)
+ {
+ File file = new File(getRealPath(url));
+ if (file.exists() && file.lastModified() > lastAccess)
+ return true;
+ return false;
+ }
+
+ public String getResourceScheme()
+ {
+ return "file:";
+ }
+
+}
\ No newline at end of file
Added: portal/trunk/component/common/src/main/java/org/exoplatform/resolver/MockResourceResolver.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/resolver/MockResourceResolver.java (rev 0)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/resolver/MockResourceResolver.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,73 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.resolver;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+public class MockResourceResolver extends ResourceResolver
+{
+
+ private Map<String, URL> resources_;
+
+ public MockResourceResolver(Map<String, URL> mapResources)
+ {
+ resources_ = mapResources;
+ }
+
+ public URL getResource(String url) throws Exception
+ {
+ return resources_.get(url);
+ }
+
+ public InputStream getInputStream(String url) throws Exception
+ {
+ URL result = resources_.get(url);
+ if (result != null)
+ return result.openStream();
+ return null;
+ }
+
+ @SuppressWarnings("unused")
+ public List<URL> getResources(String url) throws Exception
+ {
+ return null;
+ }
+
+ @SuppressWarnings("unused")
+ public List<InputStream> getInputStreams(String url) throws Exception
+ {
+ return null;
+ }
+
+ @SuppressWarnings("unused")
+ public boolean isModified(String url, long lastAccess)
+ {
+ return false;
+ }
+
+ public String getResourceScheme()
+ {
+ return null;
+ }
+
+}
Added: portal/trunk/component/common/src/main/java/org/exoplatform/resolver/PortletResourceResolver.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/resolver/PortletResourceResolver.java (rev 0)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/resolver/PortletResourceResolver.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,106 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.resolver;
+
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.portlet.PortletContext;
+
+/**
+ * Created by The eXo Platform SAS
+ * Mar 15, 2006
+ */
+public class PortletResourceResolver extends ResourceResolver
+{
+
+ protected static Log log = ExoLogger.getLogger(PortletResourceResolver.class);
+
+ private PortletContext pcontext_;
+
+ private String scheme_;
+
+ public PortletResourceResolver(PortletContext context, String scheme)
+ {
+ pcontext_ = context;
+ scheme_ = scheme;
+ }
+
+ public URL getResource(String url) throws Exception
+ {
+ String path = removeScheme(url);
+ return pcontext_.getResource(path);
+ }
+
+ public InputStream getInputStream(String url) throws Exception
+ {
+ String path = removeScheme(url);
+ return pcontext_.getResourceAsStream(path);
+ }
+
+ public List<URL> getResources(String url) throws Exception
+ {
+ ArrayList<URL> urlList = new ArrayList<URL>();
+ urlList.add(getResource(url));
+ return urlList;
+ }
+
+ public List<InputStream> getInputStreams(String url) throws Exception
+ {
+ ArrayList<InputStream> inputStreams = new ArrayList<InputStream>();
+ inputStreams.add(getInputStream(url));
+ return inputStreams;
+ }
+
+ public String getRealPath(String url)
+ {
+ String path = removeScheme(url);
+ return pcontext_.getRealPath(path);
+ }
+
+ public boolean isModified(String url, long lastAccess)
+ {
+ File file = new File(getRealPath(url));
+ if (log.isDebugEnabled())
+ log.debug(url + ": " + file.lastModified() + " " + lastAccess);
+ if (file.exists() && file.lastModified() > lastAccess)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public String getWebAccessPath(String url)
+ {
+ return "/" + pcontext_.getPortletContextName() + removeScheme(url);
+ }
+
+ public String getResourceScheme()
+ {
+ return scheme_;
+ }
+
+}
\ No newline at end of file
Added: portal/trunk/component/common/src/main/java/org/exoplatform/resolver/ResourceKey.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/resolver/ResourceKey.java (rev 0)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/resolver/ResourceKey.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+
+package org.exoplatform.resolver;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ResourceKey implements Serializable
+{
+
+ /** . */
+ private final int resolverId;
+
+ /** . */
+ private final String url;
+
+ public ResourceKey(int resolverId, String url)
+ {
+ if (url == null)
+ {
+ throw new NullPointerException("no null URL accepted");
+ }
+ this.resolverId = resolverId;
+ this.url = url;
+ }
+
+ public String getURL()
+ {
+ return url;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return resolverId ^ url.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (o == this)
+ {
+ return true;
+ }
+ if (o instanceof ResourceKey)
+ {
+ ResourceKey that = (ResourceKey)o;
+ return resolverId == that.resolverId && url.equals(that.url);
+ }
+ return false;
+ }
+}
Added: portal/trunk/component/common/src/main/java/org/exoplatform/resolver/ResourceResolver.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/resolver/ResourceResolver.java (rev 0)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/resolver/ResourceResolver.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,97 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.resolver;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.List;
+
+/**
+ * Created by The eXo Platform SAS
+ * Mar 15, 2006
+ */
+abstract public class ResourceResolver
+{
+
+ abstract public URL getResource(String url) throws Exception;
+
+ abstract public InputStream getInputStream(String url) throws Exception;
+
+ abstract public List<URL> getResources(String url) throws Exception;
+
+ abstract public List<InputStream> getInputStreams(String url) throws Exception;
+
+ @SuppressWarnings("unused")
+ public String getWebAccessPath(String url)
+ {
+ throw new RuntimeException("This method is not supported");
+ }
+
+ abstract public String getResourceScheme();
+
+ @SuppressWarnings("unused")
+ public String getRealPath(String url)
+ {
+ throw new RuntimeException("unsupported method");
+ }
+
+ public ResourceKey createResourceKey(String url)
+ {
+ return new ResourceKey(hashCode(), url);
+ }
+
+ public String createResourceId(String url)
+ {
+ return hashCode() + ":" + url;
+ }
+
+ public boolean isResolvable(String url)
+ {
+ return url.startsWith(getResourceScheme());
+ }
+
+ public byte[] getResourceContentAsBytes(String url) throws Exception
+ {
+ InputStream is = getInputStream(url);
+ BufferedInputStream buffer = new BufferedInputStream(is);
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ byte[] data = new byte[buffer.available()];
+ int available = -1;
+ while ((available = buffer.read(data)) > -1)
+ {
+ output.write(data, 0, available);
+ }
+ return output.toByteArray();
+ }
+
+ abstract public boolean isModified(String url, long lastAccess);
+
+ protected String removeScheme(String url)
+ {
+ String scheme = getResourceScheme();
+ if (url.startsWith(scheme))
+ {
+ return url.substring(scheme.length());
+ }
+ return url;
+ }
+}
\ No newline at end of file
Added: portal/trunk/component/common/src/main/java/org/exoplatform/resolver/ServletResourceResolver.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/resolver/ServletResourceResolver.java (rev 0)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/resolver/ServletResourceResolver.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,108 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.resolver;
+
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.ServletContext;
+
+/**
+ * Created by The eXo Platform SAS
+ * Mar 15, 2006
+ */
+public class ServletResourceResolver extends ResourceResolver
+{
+
+ protected static Log log = ExoLogger.getLogger("portal:ServletResourceResolver");
+
+ private ServletContext scontext_;
+
+ private String scheme_;
+
+ public ServletResourceResolver(ServletContext context, String scheme)
+ {
+ scontext_ = context;
+ scheme_ = scheme;
+ }
+
+ public URL getResource(String url) throws Exception
+ {
+ String path = removeScheme(url);
+ return scontext_.getResource(path);
+ }
+
+ public InputStream getInputStream(String url) throws Exception
+ {
+ String path = removeScheme(url);
+ return scontext_.getResourceAsStream(path);
+ }
+
+ public List<URL> getResources(String url) throws Exception
+ {
+ ArrayList<URL> urlList = new ArrayList<URL>();
+ urlList.add(getResource(url));
+ return urlList;
+ }
+
+ public List<InputStream> getInputStreams(String url) throws Exception
+ {
+ ArrayList<InputStream> inputStreams = new ArrayList<InputStream>();
+ inputStreams.add(getInputStream(url));
+ return inputStreams;
+ }
+
+ public String getRealPath(String url)
+ {
+ String path = removeScheme(url);
+ return scontext_.getRealPath(path);
+ }
+
+ public boolean isModified(String url, long lastAccess)
+ {
+ File file = new File(getRealPath(url));
+ if (log.isDebugEnabled())
+ log.debug(url + ": " + file.lastModified() + " " + lastAccess);
+ if (file.exists() && file.lastModified() > lastAccess)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public String getWebAccessPath(String url)
+ {
+ if (log.isDebugEnabled())
+ log.debug("GET WEB ACCESS " + url);
+ return "/" + scontext_.getServletContextName() + removeScheme(url);
+ }
+
+ public String getResourceScheme()
+ {
+ return scheme_;
+ }
+
+}
\ No newline at end of file
Modified: portal/trunk/component/portal/pom.xml
===================================================================
--- portal/trunk/component/portal/pom.xml 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/component/portal/pom.xml 2010-07-23 21:22:58 UTC (rev 3699)
@@ -50,11 +50,6 @@
<dependency>
<groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.web</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.exoplatform.portal</groupId>
<artifactId>exo.portal.component.pc</artifactId>
</dependency>
@@ -84,6 +79,11 @@
</dependency>
<dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/JavascriptManager.java (from rev 3698, portal/trunk/component/web/src/main/java/org/exoplatform/web/application/JavascriptManager.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/JavascriptManager.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/JavascriptManager.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,166 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.application;
+
+import org.exoplatform.commons.utils.PropertyManager;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.web.application.javascript.JavascriptConfigService;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+
+/**
+ * Created by The eXo Platform SAS
+ * Mar 27, 2007
+ */
+public class JavascriptManager
+{
+
+ /** . */
+ private ArrayList<String> data = new ArrayList<String>(100);
+
+ /** . */
+ private ArrayList<String> customizedOnloadJavascript = null;
+
+ /** . */
+ private JavascriptConfigService jsSrevice_;
+
+ public JavascriptManager()
+ {
+ jsSrevice_ =
+ (JavascriptConfigService)ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(
+ JavascriptConfigService.class);
+ }
+
+ public void addJavascript(CharSequence s)
+ {
+ if (s != null)
+ {
+ data.add(s instanceof String ? (String)s : s.toString());
+ data.add(" \n");
+ }
+ }
+
+ public void importJavascript(CharSequence s)
+ {
+ if (s != null)
+ {
+ if (!jsSrevice_.isModuleLoaded(s) || PropertyManager.isDevelopping())
+ {
+ data.add("eXo.require('");
+ data.add(s instanceof String ? (String)s : s.toString());
+ data.add("'); \n");
+ }
+ }
+ }
+
+ public void importJavascript(String s, String location)
+ {
+ if (s != null && location != null)
+ {
+ if (!jsSrevice_.isModuleLoaded(s) || PropertyManager.isDevelopping())
+ {
+ data.add("eXo.require('");
+ data.add(s);
+ data.add("', '");
+ data.add(location);
+ if (!location.endsWith("/"))
+ {
+ data.add("/");
+ }
+ data.add("'); \n");
+ }
+ }
+ }
+
+ public void addOnLoadJavascript(CharSequence s)
+ {
+ if (s != null)
+ {
+ String id = Integer.toString(Math.abs(s.hashCode()));
+ data.add("eXo.core.Browser.addOnLoadCallback('mid");
+ data.add(id);
+ data.add("',");
+ data.add(s instanceof String ? (String)s : s.toString());
+ data.add("); \n");
+ }
+ }
+
+ public void addOnResizeJavascript(CharSequence s)
+ {
+ if (s != null)
+ {
+ String id = Integer.toString(Math.abs(s.hashCode()));
+ data.add("eXo.core.Browser.addOnResizeCallback('mid");
+ data.add(id);
+ data.add("',");
+ data.add(s instanceof String ? (String)s : s.toString());
+ data.add("); \n");
+ }
+ }
+
+ public void addOnScrollJavascript(CharSequence s)
+ {
+ if (s != null)
+ {
+ String id = Integer.toString(Math.abs(s.hashCode()));
+ data.add("eXo.core.Browser.addOnScrollCallback('mid");
+ data.add(id);
+ data.add("',");
+ data.add(s instanceof String ? (String)s : s.toString());
+ data.add("); \n");
+ }
+ }
+
+ public void writeJavascript(Writer writer) throws IOException
+ {
+ for (int i = 0;i < data.size();i++)
+ {
+ String s = data.get(i);
+ writer.write(s);
+ }
+ }
+
+ public void addCustomizedOnLoadScript(CharSequence s)
+ {
+ if (s != null)
+ {
+ if (customizedOnloadJavascript == null)
+ {
+ customizedOnloadJavascript = new ArrayList<String>(30);
+ }
+ customizedOnloadJavascript.add(s instanceof String ? (String)s : s.toString());
+ customizedOnloadJavascript.add("\n");
+ }
+ }
+
+ public void writeCustomizedOnLoadScript(Writer writer) throws IOException
+ {
+ if (customizedOnloadJavascript != null)
+ {
+ for (int i = 0;i < customizedOnloadJavascript.size();i++)
+ {
+ String s = customizedOnloadJavascript.get(i);
+ writer.write(s);
+ }
+ }
+ }
+}
Modified: portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/ApplicationResourceResolver.java
===================================================================
--- portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/ApplicationResourceResolver.java 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/ApplicationResourceResolver.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -1,124 +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.
- */
-
-package org.exoplatform.resolver;
-
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * This class is an aggregation of ResourceResolver object and extends itself the ResourceResover class.
- *
- * Hence every call to this ResourceResolver will in fact be delegated to one of the resolver it aggregates.
- *
- * Created by The eXo Platform SAS
- * Oct 24, 2006
- */
-public class ApplicationResourceResolver extends ResourceResolver
-{
-
- protected static Log log = ExoLogger.getLogger("portal:ApplicationResourceResolver");
-
- private Map<String, ResourceResolver> resolvers_ = new HashMap<String, ResourceResolver>();
-
- /**
- * There are by default 2 resolvers already aggregated:
- * 1) FileResourceResolver
- * 2) ClasspathResourceResolver
- */
- public ApplicationResourceResolver()
- {
- addResourceResolver(new FileResourceResolver());
- addResourceResolver(new ClasspathResourceResolver());
- }
-
- public ResourceResolver getResourceResolverByScheme(String scheme)
- {
- return resolvers_.get(scheme);
- }
-
- public ResourceResolver getResourceResolver(String url)
- {
- String scheme = "app:";
- int index = url.indexOf(":");
- if (index > 0)
- scheme = url.substring(0, index + 1);
- if (log.isDebugEnabled())
- log.debug("Try to extract resource resolver for the url: " + url);
- return resolvers_.get(scheme);
- }
-
- public void addResourceResolver(ResourceResolver resolver)
- {
- if (log.isDebugEnabled())
- log.debug("Add a resource resolver for the scheme: " + resolver.getResourceScheme());
- resolvers_.put(resolver.getResourceScheme(), resolver);
- }
-
- public URL getResource(String url) throws Exception
- {
- return getResourceResolver(url).getResource(url);
- }
-
- public InputStream getInputStream(String url) throws Exception
- {
- return getResourceResolver(url).getInputStream(url);
- }
-
- public List<URL> getResources(String url) throws Exception
- {
- return getResourceResolver(url).getResources(url);
- }
-
- public List<InputStream> getInputStreams(String url) throws Exception
- {
- return getResourceResolver(url).getInputStreams(url);
- }
-
- public boolean isModified(String url, long lastAccess)
- {
- return getResourceResolver(url).isModified(url, lastAccess);
- }
-
- public boolean isResolvable(String url)
- {
- return getResourceResolver(url) != null;
- }
-
- public String getResourceIdPrefix()
- {
- return Integer.toString(hashCode());
- }
-
- public String createResourceId(String url)
- {
- return hashCode() + ":" + url;
- }
-
- public String getResourceScheme()
- {
- return "app:";
- }
-}
Modified: portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/ClasspathResourceResolver.java
===================================================================
--- portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/ClasspathResourceResolver.java 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/ClasspathResourceResolver.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -1,80 +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.
- */
-
-package org.exoplatform.resolver;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-
-/**
- * Created by The eXo Platform SARL
- * Author : Tuan Nguyen
- * tuan08(a)users.sourceforge.net
- * Mar 15, 2006
- */
-public class ClasspathResourceResolver extends ResourceResolver
-{
-
- public URL getResource(String url) throws Exception
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- return cl.getResource(removeScheme(url));
- }
-
- public InputStream getInputStream(String url) throws Exception
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- return cl.getResourceAsStream(removeScheme(url));
- }
-
- public List<URL> getResources(String url) throws Exception
- {
- ArrayList<URL> urlList = new ArrayList<URL>();
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- Enumeration<URL> e = cl.getResources(removeScheme(url));
- while (e.hasMoreElements())
- urlList.add(e.nextElement());
- return urlList;
- }
-
- public List<InputStream> getInputStreams(String url) throws Exception
- {
- ArrayList<InputStream> inputStreams = new ArrayList<InputStream>();
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- Enumeration<URL> e = cl.getResources(removeScheme(url));
- while (e.hasMoreElements())
- inputStreams.add(e.nextElement().openStream());
- return inputStreams;
- }
-
- @SuppressWarnings("unused")
- public boolean isModified(String url, long lastAccess)
- {
- return false;
- }
-
- public String getResourceScheme()
- {
- return "classpath:";
- }
-
-}
\ No newline at end of file
Modified: portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/FileResourceResolver.java
===================================================================
--- portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/FileResourceResolver.java 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/FileResourceResolver.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -1,94 +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.
- */
-
-package org.exoplatform.resolver;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Created by The eXo Platform SARL
- * Author : Tuan Nguyen
- * tuan08(a)users.sourceforge.net
- * Mar 15, 2006
- */
-public class FileResourceResolver extends ResourceResolver
-{
-
- static String FILE_PREFIX = "file:";
-
- public URL getResource(String url) throws Exception
- {
- String path = removeScheme(url);
- File file = new File(path);
- if (file.exists() && file.isFile())
- return file.toURL();
- return null;
- }
-
- public InputStream getInputStream(String url) throws Exception
- {
- String path = removeScheme(url);
- File file = new File(path);
- if (file.exists() && file.isFile())
- {
- FileInputStream is = new FileInputStream(file);
- return is;
- }
- return null;
- }
-
- public List<URL> getResources(String url) throws Exception
- {
- ArrayList<URL> urlList = new ArrayList<URL>();
- urlList.add(getResource(url));
- return urlList;
- }
-
- public List<InputStream> getInputStreams(String url) throws Exception
- {
- ArrayList<InputStream> inputStreams = new ArrayList<InputStream>();
- inputStreams.add(getInputStream(url));
- return inputStreams;
- }
-
- public String getRealPath(String url)
- {
- String path = removeScheme(url);
- return path;
- }
-
- public boolean isModified(String url, long lastAccess)
- {
- File file = new File(getRealPath(url));
- if (file.exists() && file.lastModified() > lastAccess)
- return true;
- return false;
- }
-
- public String getResourceScheme()
- {
- return "file:";
- }
-
-}
\ No newline at end of file
Modified: portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/MockResourceResolver.java
===================================================================
--- portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/MockResourceResolver.java 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/MockResourceResolver.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -1,73 +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.
- */
-
-package org.exoplatform.resolver;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-
-public class MockResourceResolver extends ResourceResolver
-{
-
- private Map<String, URL> resources_;
-
- public MockResourceResolver(Map<String, URL> mapResources)
- {
- resources_ = mapResources;
- }
-
- public URL getResource(String url) throws Exception
- {
- return resources_.get(url);
- }
-
- public InputStream getInputStream(String url) throws Exception
- {
- URL result = resources_.get(url);
- if (result != null)
- return result.openStream();
- return null;
- }
-
- @SuppressWarnings("unused")
- public List<URL> getResources(String url) throws Exception
- {
- return null;
- }
-
- @SuppressWarnings("unused")
- public List<InputStream> getInputStreams(String url) throws Exception
- {
- return null;
- }
-
- @SuppressWarnings("unused")
- public boolean isModified(String url, long lastAccess)
- {
- return false;
- }
-
- public String getResourceScheme()
- {
- return null;
- }
-
-}
Modified: portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/PortletResourceResolver.java
===================================================================
--- portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/PortletResourceResolver.java 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/PortletResourceResolver.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -1,106 +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.
- */
-
-package org.exoplatform.resolver;
-
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-
-import java.io.File;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.portlet.PortletContext;
-
-/**
- * Created by The eXo Platform SAS
- * Mar 15, 2006
- */
-public class PortletResourceResolver extends ResourceResolver
-{
-
- protected static Log log = ExoLogger.getLogger(PortletResourceResolver.class);
-
- private PortletContext pcontext_;
-
- private String scheme_;
-
- public PortletResourceResolver(PortletContext context, String scheme)
- {
- pcontext_ = context;
- scheme_ = scheme;
- }
-
- public URL getResource(String url) throws Exception
- {
- String path = removeScheme(url);
- return pcontext_.getResource(path);
- }
-
- public InputStream getInputStream(String url) throws Exception
- {
- String path = removeScheme(url);
- return pcontext_.getResourceAsStream(path);
- }
-
- public List<URL> getResources(String url) throws Exception
- {
- ArrayList<URL> urlList = new ArrayList<URL>();
- urlList.add(getResource(url));
- return urlList;
- }
-
- public List<InputStream> getInputStreams(String url) throws Exception
- {
- ArrayList<InputStream> inputStreams = new ArrayList<InputStream>();
- inputStreams.add(getInputStream(url));
- return inputStreams;
- }
-
- public String getRealPath(String url)
- {
- String path = removeScheme(url);
- return pcontext_.getRealPath(path);
- }
-
- public boolean isModified(String url, long lastAccess)
- {
- File file = new File(getRealPath(url));
- if (log.isDebugEnabled())
- log.debug(url + ": " + file.lastModified() + " " + lastAccess);
- if (file.exists() && file.lastModified() > lastAccess)
- {
- return true;
- }
- return false;
- }
-
- public String getWebAccessPath(String url)
- {
- return "/" + pcontext_.getPortletContextName() + removeScheme(url);
- }
-
- public String getResourceScheme()
- {
- return scheme_;
- }
-
-}
\ No newline at end of file
Modified: portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/ResourceKey.java
===================================================================
--- portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/ResourceKey.java 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/ResourceKey.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -1,72 +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.
- */
-
-package org.exoplatform.resolver;
-
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class ResourceKey implements Serializable
-{
-
- /** . */
- private final int resolverId;
-
- /** . */
- private final String url;
-
- public ResourceKey(int resolverId, String url)
- {
- if (url == null)
- {
- throw new NullPointerException("no null URL accepted");
- }
- this.resolverId = resolverId;
- this.url = url;
- }
-
- public String getURL()
- {
- return url;
- }
-
- @Override
- public int hashCode()
- {
- return resolverId ^ url.hashCode();
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (o == this)
- {
- return true;
- }
- if (o instanceof ResourceKey)
- {
- ResourceKey that = (ResourceKey)o;
- return resolverId == that.resolverId && url.equals(that.url);
- }
- return false;
- }
-}
Modified: portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/ResourceResolver.java
===================================================================
--- portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/ResourceResolver.java 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/ResourceResolver.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -1,97 +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.
- */
-
-package org.exoplatform.resolver;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.List;
-
-/**
- * Created by The eXo Platform SAS
- * Mar 15, 2006
- */
-abstract public class ResourceResolver
-{
-
- abstract public URL getResource(String url) throws Exception;
-
- abstract public InputStream getInputStream(String url) throws Exception;
-
- abstract public List<URL> getResources(String url) throws Exception;
-
- abstract public List<InputStream> getInputStreams(String url) throws Exception;
-
- @SuppressWarnings("unused")
- public String getWebAccessPath(String url)
- {
- throw new RuntimeException("This method is not supported");
- }
-
- abstract public String getResourceScheme();
-
- @SuppressWarnings("unused")
- public String getRealPath(String url)
- {
- throw new RuntimeException("unsupported method");
- }
-
- public ResourceKey createResourceKey(String url)
- {
- return new ResourceKey(hashCode(), url);
- }
-
- public String createResourceId(String url)
- {
- return hashCode() + ":" + url;
- }
-
- public boolean isResolvable(String url)
- {
- return url.startsWith(getResourceScheme());
- }
-
- public byte[] getResourceContentAsBytes(String url) throws Exception
- {
- InputStream is = getInputStream(url);
- BufferedInputStream buffer = new BufferedInputStream(is);
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- byte[] data = new byte[buffer.available()];
- int available = -1;
- while ((available = buffer.read(data)) > -1)
- {
- output.write(data, 0, available);
- }
- return output.toByteArray();
- }
-
- abstract public boolean isModified(String url, long lastAccess);
-
- protected String removeScheme(String url)
- {
- String scheme = getResourceScheme();
- if (url.startsWith(scheme))
- {
- return url.substring(scheme.length());
- }
- return url;
- }
-}
\ No newline at end of file
Modified: portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/ServletResourceResolver.java
===================================================================
--- portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/ServletResourceResolver.java 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/component/scripting/src/main/java/org/exoplatform/resolver/ServletResourceResolver.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -1,108 +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.
- */
-
-package org.exoplatform.resolver;
-
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-
-import java.io.File;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.servlet.ServletContext;
-
-/**
- * Created by The eXo Platform SAS
- * Mar 15, 2006
- */
-public class ServletResourceResolver extends ResourceResolver
-{
-
- protected static Log log = ExoLogger.getLogger("portal:ServletResourceResolver");
-
- private ServletContext scontext_;
-
- private String scheme_;
-
- public ServletResourceResolver(ServletContext context, String scheme)
- {
- scontext_ = context;
- scheme_ = scheme;
- }
-
- public URL getResource(String url) throws Exception
- {
- String path = removeScheme(url);
- return scontext_.getResource(path);
- }
-
- public InputStream getInputStream(String url) throws Exception
- {
- String path = removeScheme(url);
- return scontext_.getResourceAsStream(path);
- }
-
- public List<URL> getResources(String url) throws Exception
- {
- ArrayList<URL> urlList = new ArrayList<URL>();
- urlList.add(getResource(url));
- return urlList;
- }
-
- public List<InputStream> getInputStreams(String url) throws Exception
- {
- ArrayList<InputStream> inputStreams = new ArrayList<InputStream>();
- inputStreams.add(getInputStream(url));
- return inputStreams;
- }
-
- public String getRealPath(String url)
- {
- String path = removeScheme(url);
- return scontext_.getRealPath(path);
- }
-
- public boolean isModified(String url, long lastAccess)
- {
- File file = new File(getRealPath(url));
- if (log.isDebugEnabled())
- log.debug(url + ": " + file.lastModified() + " " + lastAccess);
- if (file.exists() && file.lastModified() > lastAccess)
- {
- return true;
- }
- return false;
- }
-
- public String getWebAccessPath(String url)
- {
- if (log.isDebugEnabled())
- log.debug("GET WEB ACCESS " + url);
- return "/" + scontext_.getServletContextName() + removeScheme(url);
- }
-
- public String getResourceScheme()
- {
- return scheme_;
- }
-
-}
\ No newline at end of file
Added: portal/trunk/component/web/api/pom.xml
===================================================================
--- portal/trunk/component/web/api/pom.xml (rev 0)
+++ portal/trunk/component/web/api/pom.xml 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,51 @@
+<!--
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web</artifactId>
+ <version>3.2.0-Beta01-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>exo.portal.component.web.api</artifactId>
+ <packaging>jar</packaging>
+ <name>GateIn Portal Component Web API</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.container</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web.controller</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.test.core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Added: portal/trunk/component/web/api/src/main/java/org/exoplatform/web/GenericHttpListener.java
===================================================================
--- portal/trunk/component/web/api/src/main/java/org/exoplatform/web/GenericHttpListener.java (rev 0)
+++ portal/trunk/component/web/api/src/main/java/org/exoplatform/web/GenericHttpListener.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,225 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.container.RootContainer;
+import org.exoplatform.container.RootContainer.PortalContainerPostInitTask;
+import org.exoplatform.container.util.EnvSpecific;
+import org.exoplatform.container.web.AbstractHttpSessionListener;
+import org.exoplatform.services.listener.ListenerService;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.util.EventObject;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.http.HttpSessionEvent;
+
+/**
+ * This class is used to broadcast any "HttpEvent" to allow the rest of the platform to be notified
+ * without changing the web.xml file.
+ *
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 25 sept. 2009
+ */
+public class GenericHttpListener extends AbstractHttpSessionListener implements ServletContextListener
+{
+
+ /**
+ * The name of the "session created" event
+ */
+ public static final String SESSION_CREATED = "org.exoplatform.web.GenericHttpListener.sessionCreated";
+
+ /**
+ * The name of the "session destroyed" event
+ */
+ public static final String SESSION_DESTROYED = "org.exoplatform.web.GenericHttpListener.sessionDestroyed";
+
+ /**
+ * The name of the "context initialized" event
+ */
+ public static final String CONTEXT_INITIALIZED = "org.exoplatform.web.GenericHttpListener.contextInitialized";
+
+ /**
+ * The name of the "context destroyed" event
+ */
+ public static final String CONTEXT_DESTROYED = "org.exoplatform.web.GenericHttpListener.contextDestroyed";
+
+ /**
+ * Logger.
+ */
+ private static Log log = ExoLogger.getLogger("portal:GenericHttpListener");
+
+ /**
+ * This method is called when a HTTP session of a Portal instance is created.
+ *
+ * In this method, we:
+ * 1) first get the portal instance name for which the session is created.
+ * 2) Put the portal instance in the Portal ThreadLocal
+ * 3) Broadcast the SESSION_CREATED event
+ * 4) Flush the {@link ThreadLocal} for the PortalContainer
+ */
+ @Override
+ protected void onSessionCreated(ExoContainer container, HttpSessionEvent event)
+ {
+ try
+ {
+ broadcast((PortalContainer)container, SESSION_CREATED, event);
+ }
+ catch (Exception ex)
+ {
+ log.error("Error on sessionCreated", ex);
+ }
+ }
+
+ /**
+ * This method is called when a HTTP session of a Portal instance is destroyed.
+ *
+ * In this method, we:
+ * 1) first get the portal instance name for which the session is created.
+ * 2) Put the portal instance in the Portal ThreadLocal
+ * 3) Broadcast the SESSION_DESTROYED event
+ * 4) Flush the {@link ThreadLocal} for the PortalContainer
+ */
+ @Override
+ protected void onSessionDestroyed(ExoContainer container, HttpSessionEvent event)
+ {
+ try
+ {
+ broadcast((PortalContainer)container, SESSION_DESTROYED, event);
+ }
+ catch (Exception ex)
+ {
+ log.error("Error on sessionDestroyed", ex);
+ }
+ }
+
+ /**
+ * This method is called when the {@link ServletContext} of the Portal is destroyed.
+ *
+ * In this method, we:
+ * 1) first get the portal instance name for which the session is created.
+ * 2) Put the portal instance in the Portal ThreadLocal
+ * 3) Broadcast the CONTEXT_DESTROYED event
+ * 4) Flush the {@link ThreadLocal} for the PortalContainer
+ */
+ public void contextDestroyed(ServletContextEvent event)
+ {
+ boolean hasBeenSet = false;
+ final ExoContainer oldContainer = ExoContainerContext.getCurrentContainer();
+ try
+ {
+ PortalContainer portalContainer = PortalContainer.getInstanceIfPresent();
+ if (portalContainer == null)
+ {
+ portalContainer = PortalContainer.getCurrentInstance(event.getServletContext());
+ PortalContainer.setInstance(portalContainer);
+ hasBeenSet = true;
+ }
+ broadcast(portalContainer, CONTEXT_DESTROYED, event);
+ }
+ catch (Exception ex)
+ {
+ log.error("Error on contextDestroyed", ex);
+ }
+ finally
+ {
+ if (hasBeenSet)
+ {
+ PortalContainer.setInstance(null);
+ ExoContainerContext.setCurrentContainer(oldContainer);
+ }
+ }
+ }
+
+ /**
+ * This method is called when the {@link ServletContext} of the Portal is initialized.
+ *
+ * In this method, we:
+ * 1) first get the portal instance name for which the session is created.
+ * 2) Put the portal instance in the Portal ThreadLocal
+ * 3) Broadcast the CONTEXT_INITIALIZED event
+ * 4) Flush the {@link ThreadLocal} for the PortalContainer
+ */
+ public void contextInitialized(final ServletContextEvent event)
+ {
+ final PortalContainerPostInitTask task = new PortalContainerPostInitTask()
+ {
+ public void execute(ServletContext scontext, PortalContainer portalContainer)
+ {
+ try
+ {
+ broadcast(portalContainer, CONTEXT_INITIALIZED, event);
+ }
+ catch (Exception ex)
+ {
+ log.error("Error on contextInitialized", ex);
+ }
+ }
+ };
+ ServletContext ctx = event.getServletContext();
+ try
+ {
+ EnvSpecific.initThreadEnv(ctx);
+ RootContainer.getInstance().addInitTask(event.getServletContext(), task);
+ }
+ finally
+ {
+ EnvSpecific.cleanupThreadEnv(ctx);
+ }
+
+ }
+
+ /**
+ * @see org.exoplatform.container.web.AbstractHttpSessionListener#requirePortalEnvironment()
+ */
+ @Override
+ protected boolean requirePortalEnvironment()
+ {
+ return true;
+ }
+
+ /**
+ * Allow the rest of the application to be notified when an HttpEvent happens
+ * @param portalContainer the related portal container
+ * @param eventName the name of the event to broadcast
+ * @param event the notification event
+ */
+ private <T extends EventObject> void broadcast(PortalContainer portalContainer, String eventName, T event)
+ {
+ try
+ {
+ ListenerService listenerService =
+ (ListenerService)portalContainer.getComponentInstanceOfType(ListenerService.class);
+ listenerService.broadcast(eventName, portalContainer, event);
+ }
+ catch (Exception e)
+ {
+ log.warn("Cannot broadcast the event '" + eventName + "'", e);
+ }
+ }
+}
Added: portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/ExtensibleFilter.java
===================================================================
--- portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/ExtensibleFilter.java (rev 0)
+++ portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/ExtensibleFilter.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,115 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.filter;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * This class allows the rest of the platform to define new filters thanks to the external
+ * plugins.
+ *
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 25 sept. 2009
+ */
+public class ExtensibleFilter implements Filter
+{
+
+ /**
+ * List of all the sub filters
+ */
+ private volatile List<FilterDefinition> filters = Collections.unmodifiableList(new ArrayList<FilterDefinition>());
+
+ /**
+ * Adds new {@link FilterDefinition}
+ */
+ public void addFilterDefinitions(FilterDefinitionPlugin plugin)
+ {
+ addFilterDefinitions(plugin.getFilterDefinitions());
+ }
+
+ /**
+ * Adds new {@link FilterDefinition}
+ */
+ void addFilterDefinitions(List<FilterDefinition> pluginFilters)
+ {
+ if (pluginFilters == null || pluginFilters.isEmpty())
+ {
+ // No filter to add
+ return;
+ }
+ synchronized (this)
+ {
+ List<FilterDefinition> result = new ArrayList<FilterDefinition>(filters);
+ result.addAll(pluginFilters);
+ this.filters = Collections.unmodifiableList(result);
+ }
+ }
+
+ /**
+ * @see Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
+ */
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
+ ServletException
+ {
+ ExtensibleFilterChain efChain = new ExtensibleFilterChain(chain, filters);
+ efChain.doFilter(request, response);
+ }
+
+ private static class ExtensibleFilterChain implements FilterChain
+ {
+
+ private final FilterChain parentChain;
+
+ private final Iterator<FilterDefinition> filters;
+
+ private ExtensibleFilterChain(FilterChain parentChain, List<FilterDefinition> filters)
+ {
+ this.parentChain = parentChain;
+ this.filters = filters.iterator();
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException
+ {
+ String path = ((HttpServletRequest)request).getRequestURI();
+ while (filters.hasNext())
+ {
+ FilterDefinition filterDef = filters.next();
+ if (filterDef.getMapping().match(path))
+ {
+ filterDef.getFilter().doFilter(request, response, this);
+ return;
+ }
+ }
+ parentChain.doFilter(request, response);
+ }
+ }
+}
Added: portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/Filter.java
===================================================================
--- portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/Filter.java (rev 0)
+++ portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/Filter.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,46 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.filter;
+
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+/**
+ * This interface defines a Filter that cans be added to the {@link ExtensibleFilter}
+ *
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 25 sept. 2009
+ */
+public interface Filter
+{
+ /**
+ * The <code>doFilter</code> method of the Filter is called by the {@link ExtensibleFilter}
+ * each time a request/response pair is passed through the chain due to a client request
+ * for a resource at the end of the chain.
+ */
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
+ ServletException;
+}
Added: portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/FilterDefinition.java
===================================================================
--- portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/FilterDefinition.java (rev 0)
+++ portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/FilterDefinition.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,126 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.filter;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * This class defined all the variables needed to define a {@link Filter}
+ *
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 25 sept. 2009
+ */
+public class FilterDefinition
+{
+
+ /**
+ * The filter.
+ */
+ private Filter filter;
+
+ /**
+ * The filter mapping.
+ */
+ private volatile FilterMapping mapping;
+
+ /**
+ * The list of patterns that will defined the {@link FilterMapping}
+ */
+ private List<String> patterns;
+
+ public FilterDefinition()
+ {
+ }
+
+ public FilterDefinition(Filter filter, List<String> patterns)
+ {
+ this.filter = filter;
+ this.patterns = patterns;
+ }
+
+ public Filter getFilter()
+ {
+ return filter;
+ }
+
+ public FilterMapping getMapping()
+ {
+ if (mapping == null)
+ {
+ synchronized (this)
+ {
+ if (mapping == null)
+ {
+ this.mapping = new PatternMapping(patterns);
+ this.patterns = null;
+ }
+ }
+ }
+ return mapping;
+ }
+
+ /**
+ * This class is used to defined a mapping based on a list of regular expression
+ */
+ private static class PatternMapping implements FilterMapping
+ {
+
+ /**
+ * the list of regular expressions
+ */
+ private final List<Pattern> patterns;
+
+ private PatternMapping(List<String> strPatterns)
+ {
+ if (strPatterns == null || strPatterns.isEmpty())
+ {
+ throw new IllegalArgumentException("The list of patterns cannot be empty");
+ }
+ this.patterns = new ArrayList<Pattern>(strPatterns.size());
+ for (String sPattern : strPatterns)
+ {
+ patterns.add(Pattern.compile(sPattern));
+ }
+ }
+
+ /**
+ * @return <code>true</code> if at least one pattern matches
+ */
+ public boolean match(String path)
+ {
+ for (int i = 0, length = patterns.size(); i < length; i++)
+ {
+ Pattern pattern = patterns.get(i);
+ Matcher matcher = pattern.matcher(path);
+ if (matcher.matches())
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ }
+}
Added: portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/FilterDefinitionPlugin.java
===================================================================
--- portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/FilterDefinitionPlugin.java (rev 0)
+++ portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/FilterDefinitionPlugin.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,52 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.filter;
+
+import org.exoplatform.container.component.BaseComponentPlugin;
+import org.exoplatform.container.xml.InitParams;
+
+import java.util.List;
+
+/**
+ * This class is used to add new {@link FilterDefinition}
+ *
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 25 sept. 2009
+ */
+public class FilterDefinitionPlugin extends BaseComponentPlugin
+{
+
+ private final InitParams params;
+
+ public FilterDefinitionPlugin(InitParams params)
+ {
+ this.params = params;
+ }
+
+ /**
+ * @return the list of enclosed {@link FilterDefinition}
+ */
+ public List<FilterDefinition> getFilterDefinitions()
+ {
+ return params.getObjectParamValues(FilterDefinition.class);
+ }
+}
Added: portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/FilterMapping.java
===================================================================
--- portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/FilterMapping.java (rev 0)
+++ portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/FilterMapping.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,37 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.filter;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 25 sept. 2009
+ */
+public interface FilterMapping
+{
+
+ /**
+ * Indicates if the current path matches with the current mapping
+ * @param path the path to check
+ * @return <code>true</code> if it matches, <code>false</code> otherwise.
+ */
+ public boolean match(String path);
+}
Added: portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/GenericFilter.java
===================================================================
--- portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/GenericFilter.java (rev 0)
+++ portal/trunk/component/web/api/src/main/java/org/exoplatform/web/filter/GenericFilter.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,69 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.filter;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.web.AbstractFilter;
+
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+/**
+ * This filter allows the rest of the platform to add their own filters without changing the web.xml
+ * file. It is based on {@link ExtensibleFilter} which is a component that supports plugin.
+ *
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 25 sept. 2009
+ */
+public class GenericFilter extends AbstractFilter
+{
+
+ /**
+ * @see javax.servlet.Filter#destroy()
+ */
+ public void destroy()
+ {
+ }
+
+ /**
+ * This filter calls <code>doFilter</code> of the {@link ExtensibleFilter} of
+ * the current eXo container if it cans be found otherwise it releases filter
+ */
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
+ ServletException
+ {
+ ExoContainer container = getContainer();
+ ExtensibleFilter filter = (ExtensibleFilter)container.getComponentInstanceOfType(ExtensibleFilter.class);
+ if (filter == null)
+ {
+ chain.doFilter(request, response);
+ }
+ else
+ {
+ filter.doFilter(request, response, chain);
+ }
+ }
+}
Copied: portal/trunk/component/web/api/src/main/java/org/exoplatform/web/resource (from rev 3698, portal/trunk/component/web/src/main/java/org/exoplatform/web/resource)
Added: portal/trunk/component/web/api/src/test/java/conf/portal/test-configuration.xml
===================================================================
--- portal/trunk/component/web/api/src/test/java/conf/portal/test-configuration.xml (rev 0)
+++ portal/trunk/component/web/api/src/test/java/conf/portal/test-configuration.xml 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,38 @@
+<?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.download.DownloadService</key>
+ <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>3</value>
+ </value-param>
+ </init-params>
+ </component>
+</configuration>
Added: portal/trunk/component/web/api/src/test/java/org/exoplatform/web/command/TestCommandHandler.java
===================================================================
--- portal/trunk/component/web/api/src/test/java/org/exoplatform/web/command/TestCommandHandler.java (rev 0)
+++ portal/trunk/component/web/api/src/test/java/org/exoplatform/web/command/TestCommandHandler.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,98 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.command;
+
+import org.exoplatform.component.test.AbstractGateInTest;
+import org.exoplatform.web.WebAppController;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Created by The eXo Platform SARL
+ * Author : Nhu Dinh Thuan
+ * nhudinhthuan(a)exoplatform.com
+ * Mar 26, 2007
+ */
+public class TestCommandHandler extends AbstractGateInTest
+{
+
+ public TestCommandHandler(String name)
+ {
+ super(name);
+ }
+
+ public void testCommandHandler() throws Exception
+ {
+ CommandHandler handler = new CommandHandler();
+ Map<String, Object> props = new HashMap<String, Object>();
+ props.put("intProp", "10");
+ props.put("stringProp", "welcome to eXo");
+ props.put("doubleValues", new String[]{"10.0", "-6.7", "7.0"});
+ props.put("booleanValue", "true");
+ Command command = handler.createCommand("org.exoplatform.web.command.TestCommandHandler$CommandTest2", props);
+ command.execute(null, null, null);
+ }
+
+ static public class CommandTest2 extends CommandTest
+ {
+
+ private boolean booleanValue = false;
+
+ public void execute(WebAppController controller, HttpServletRequest req, HttpServletResponse res)
+ throws Exception
+ {
+ super.execute(controller, req, res);
+ System.out.println(" \n\n\n === >" + booleanValue + "\n\n");
+ }
+ }
+
+ static public class CommandTest extends Command
+ {
+
+ private double[] doubleValues;
+
+ private Integer intProp;
+
+ private String stringProp;
+
+ public void execute(WebAppController controller, HttpServletRequest req, HttpServletResponse res)
+ throws Exception
+ {
+ System.out.println("\n\n");
+ System.out.println("int prop : " + intProp);
+ System.out.println("String prop : " + stringProp);
+ for (double ele : doubleValues)
+ {
+ System.out.println("===== > " + ele);
+ }
+ System.out.println("\n\n");
+ }
+
+ public void setStringProp(String value)
+ {
+ System.out.println("\n\n invoke setter " + value + "\n\n");
+ stringProp = value;
+ }
+ }
+}
Added: portal/trunk/component/web/api/src/test/java/org/exoplatform/web/filter/TestExtensibleFilter.java
===================================================================
--- portal/trunk/component/web/api/src/test/java/org/exoplatform/web/filter/TestExtensibleFilter.java (rev 0)
+++ portal/trunk/component/web/api/src/test/java/org/exoplatform/web/filter/TestExtensibleFilter.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,606 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.filter;
+
+import org.exoplatform.component.test.AbstractGateInTest;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.FilterChain;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 25 sept. 2009
+ */
+public class TestExtensibleFilter extends AbstractGateInTest
+{
+
+ public void testDoFilter() throws IOException, ServletException
+ {
+ ExtensibleFilter exFilter = new ExtensibleFilter();
+ MockFilterOKTF mockFilterOKTF = new MockFilterOKTF();
+ MockFilterOKWTF mockFilterOKWTF = new MockFilterOKWTF();
+ MockFilterChain chain = new MockFilterChain();
+ exFilter.addFilterDefinitions(Arrays.asList(getFilterDefinition(mockFilterOKTF),
+ getFilterDefinition(mockFilterOKWTF)));
+ exFilter.doFilter(new MockServletRequest(), null, chain);
+ assertTrue(mockFilterOKTF.start);
+ assertTrue(mockFilterOKTF.end);
+ assertTrue(mockFilterOKWTF.start);
+ assertTrue(mockFilterOKWTF.end);
+ assertTrue(chain.called);
+ exFilter = new ExtensibleFilter();
+ mockFilterOKTF = new MockFilterOKTF();
+ mockFilterOKWTF = new MockFilterOKWTF();
+ chain = new MockFilterChain();
+ exFilter.addFilterDefinitions(Arrays.asList(getFilterDefinition(mockFilterOKTF),
+ getFilterDefinition(mockFilterOKWTF), getFilterDefinition(new MockFilterKO())));
+ exFilter.doFilter(new MockServletRequest(), null, chain);
+ assertTrue(mockFilterOKTF.start);
+ assertTrue(mockFilterOKTF.end);
+ assertTrue(mockFilterOKWTF.start);
+ assertTrue(mockFilterOKWTF.end);
+ assertFalse(chain.called);
+ exFilter = new ExtensibleFilter();
+ mockFilterOKTF = new MockFilterOKTF();
+ mockFilterOKWTF = new MockFilterOKWTF();
+ chain = new MockFilterChain();
+ exFilter.addFilterDefinitions(Arrays.asList(getFilterDefinition(mockFilterOKTF),
+ getFilterDefinition(mockFilterOKWTF), getFilterDefinition(new MockFilterKOIO())));
+ try
+ {
+ exFilter.doFilter(new MockServletRequest(), null, chain);
+ fail("IOException is expected");
+ }
+ catch (IOException e)
+ {
+ }
+ assertTrue(mockFilterOKTF.start);
+ assertTrue(mockFilterOKTF.end);
+ assertTrue(mockFilterOKWTF.start);
+ assertFalse(mockFilterOKWTF.end);
+ assertFalse(chain.called);
+ exFilter = new ExtensibleFilter();
+ mockFilterOKTF = new MockFilterOKTF();
+ mockFilterOKWTF = new MockFilterOKWTF();
+ chain = new MockFilterChain();
+ exFilter.addFilterDefinitions(Arrays.asList(getFilterDefinition(mockFilterOKTF),
+ getFilterDefinition(mockFilterOKWTF), getFilterDefinition(new MockFilterKOSE())));
+ try
+ {
+ exFilter.doFilter(new MockServletRequest(), null, chain);
+ fail("ServletException is expected");
+ }
+ catch (ServletException e)
+ {
+ }
+ assertTrue(mockFilterOKTF.start);
+ assertTrue(mockFilterOKTF.end);
+ assertTrue(mockFilterOKWTF.start);
+ assertFalse(mockFilterOKWTF.end);
+ assertFalse(chain.called);
+ exFilter = new ExtensibleFilter();
+ mockFilterOKTF = new MockFilterOKTF();
+ mockFilterOKWTF = new MockFilterOKWTF();
+ chain = new MockFilterChain();
+ exFilter.addFilterDefinitions(Arrays.asList(getFilterDefinition(mockFilterOKTF),
+ getFilterDefinition(mockFilterOKWTF), getFilterDefinition(new MockFilterKORE())));
+ try
+ {
+ exFilter.doFilter(new MockServletRequest(), null, chain);
+ fail("RuntimeException is expected");
+ }
+ catch (RuntimeException e)
+ {
+ }
+ assertTrue(mockFilterOKTF.start);
+ assertTrue(mockFilterOKTF.end);
+ assertTrue(mockFilterOKWTF.start);
+ assertFalse(mockFilterOKWTF.end);
+ assertFalse(chain.called);
+ exFilter = new ExtensibleFilter();
+ mockFilterOKTF = new MockFilterOKTF();
+ mockFilterOKWTF = new MockFilterOKWTF();
+ chain = new MockFilterChain();
+ exFilter.addFilterDefinitions(Arrays.asList(getFilterDefinition(mockFilterOKTF),
+ getFilterDefinition(mockFilterOKWTF), getFilterDefinition(new MockFilterKOER())));
+ try
+ {
+ exFilter.doFilter(new MockServletRequest(), null, chain);
+ fail("Error is expected");
+ }
+ catch (Error e)
+ {
+ }
+ assertTrue(mockFilterOKTF.start);
+ assertTrue(mockFilterOKTF.end);
+ assertTrue(mockFilterOKWTF.start);
+ assertFalse(mockFilterOKWTF.end);
+ assertFalse(chain.called);
+ exFilter = new ExtensibleFilter();
+ mockFilterOKTF = new MockFilterOKTF();
+ mockFilterOKWTF = new MockFilterOKWTF();
+ MockFilterOKTF mockFilterOKTF2 = new MockFilterOKTF();
+ chain = new MockFilterChain();
+ exFilter.addFilterDefinitions(Arrays.asList(getFilterDefinition(mockFilterOKTF),
+ getFilterDefinition(mockFilterOKWTF), getFilterDefinition(new MockFilterKOIO()),
+ getFilterDefinition(mockFilterOKTF2)));
+ try
+ {
+ exFilter.doFilter(new MockServletRequest(), null, chain);
+ fail("IOException is expected");
+ }
+ catch (IOException e)
+ {
+ }
+ assertTrue(mockFilterOKTF.start);
+ assertTrue(mockFilterOKTF.end);
+ assertTrue(mockFilterOKWTF.start);
+ assertFalse(mockFilterOKWTF.end);
+ assertFalse(chain.called);
+ assertFalse(mockFilterOKTF2.start);
+ assertFalse(mockFilterOKTF2.end);
+ }
+
+ private FilterDefinition getFilterDefinition(Filter filter)
+ {
+ return new FilterDefinition(filter, Collections.singletonList(".*"));
+ }
+
+ private static class MockFilterChain implements FilterChain
+ {
+ private boolean called;
+
+ public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException
+ {
+ called = true;
+ }
+ }
+
+ private static class MockFilterOKTF implements Filter
+ {
+
+ private boolean start;
+
+ private boolean end;
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
+ ServletException
+ {
+ try
+ {
+ start = true;
+ chain.doFilter(request, response);
+ }
+ finally
+ {
+ end = true;
+ }
+ }
+ }
+
+ private static class MockFilterOKWTF implements Filter
+ {
+
+ private boolean start;
+
+ private boolean end;
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
+ ServletException
+ {
+ start = true;
+ chain.doFilter(request, response);
+ end = true;
+ }
+ }
+
+ private static class MockFilterKO implements Filter
+ {
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
+ ServletException
+ {
+ }
+ }
+
+ private static class MockFilterKOIO implements Filter
+ {
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
+ ServletException
+ {
+ throw new IOException();
+ }
+ }
+
+ private static class MockFilterKOSE implements Filter
+ {
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
+ ServletException
+ {
+ throw new ServletException();
+ }
+ }
+
+ private static class MockFilterKORE implements Filter
+ {
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
+ ServletException
+ {
+ throw new RuntimeException();
+ }
+ }
+
+ private static class MockFilterKOER implements Filter
+ {
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
+ ServletException
+ {
+ throw new Error();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private static class MockServletRequest implements HttpServletRequest
+ {
+
+ public String getAuthType()
+ {
+
+ return null;
+ }
+
+ public String getContextPath()
+ {
+
+ return null;
+ }
+
+ public Cookie[] getCookies()
+ {
+
+ return null;
+ }
+
+ public long getDateHeader(String name)
+ {
+
+ return 0;
+ }
+
+ public String getHeader(String name)
+ {
+
+ return null;
+ }
+
+ public Enumeration getHeaderNames()
+ {
+
+ return null;
+ }
+
+ public Enumeration getHeaders(String name)
+ {
+
+ return null;
+ }
+
+ public int getIntHeader(String name)
+ {
+
+ return 0;
+ }
+
+ public String getMethod()
+ {
+
+ return null;
+ }
+
+ public String getPathInfo()
+ {
+ return null;
+ }
+
+ public String getPathTranslated()
+ {
+
+ return null;
+ }
+
+ public String getQueryString()
+ {
+
+ return null;
+ }
+
+ public String getRemoteUser()
+ {
+
+ return null;
+ }
+
+ public String getRequestURI()
+ {
+
+ return "/";
+ }
+
+ public StringBuffer getRequestURL()
+ {
+
+ return null;
+ }
+
+ public String getRequestedSessionId()
+ {
+
+ return null;
+ }
+
+ public String getServletPath()
+ {
+
+ return null;
+ }
+
+ public HttpSession getSession()
+ {
+
+ return null;
+ }
+
+ public HttpSession getSession(boolean create)
+ {
+
+ return null;
+ }
+
+ public Principal getUserPrincipal()
+ {
+
+ return null;
+ }
+
+ public boolean isRequestedSessionIdFromCookie()
+ {
+
+ return false;
+ }
+
+ public boolean isRequestedSessionIdFromURL()
+ {
+
+ return false;
+ }
+
+ public boolean isRequestedSessionIdFromUrl()
+ {
+
+ return false;
+ }
+
+ public boolean isRequestedSessionIdValid()
+ {
+
+ return false;
+ }
+
+ public boolean isUserInRole(String role)
+ {
+
+ return false;
+ }
+
+ public Object getAttribute(String name)
+ {
+
+ return null;
+ }
+
+ public Enumeration getAttributeNames()
+ {
+
+ return null;
+ }
+
+ public String getCharacterEncoding()
+ {
+
+ return null;
+ }
+
+ public int getContentLength()
+ {
+
+ return 0;
+ }
+
+ public String getContentType()
+ {
+
+ return null;
+ }
+
+ public ServletInputStream getInputStream() throws IOException
+ {
+
+ return null;
+ }
+
+ public String getLocalAddr()
+ {
+
+ return null;
+ }
+
+ public String getLocalName()
+ {
+
+ return null;
+ }
+
+ public int getLocalPort()
+ {
+
+ return 0;
+ }
+
+ public Locale getLocale()
+ {
+
+ return null;
+ }
+
+ public Enumeration getLocales()
+ {
+
+ return null;
+ }
+
+ public String getParameter(String name)
+ {
+
+ return null;
+ }
+
+ public Map getParameterMap()
+ {
+
+ return null;
+ }
+
+ public Enumeration getParameterNames()
+ {
+
+ return null;
+ }
+
+ public String[] getParameterValues(String name)
+ {
+
+ return null;
+ }
+
+ public String getProtocol()
+ {
+
+ return null;
+ }
+
+ public BufferedReader getReader() throws IOException
+ {
+
+ return null;
+ }
+
+ public String getRealPath(String path)
+ {
+
+ return null;
+ }
+
+ public String getRemoteAddr()
+ {
+
+ return null;
+ }
+
+ public String getRemoteHost()
+ {
+
+ return null;
+ }
+
+ public int getRemotePort()
+ {
+
+ return 0;
+ }
+
+ public RequestDispatcher getRequestDispatcher(String path)
+ {
+
+ return null;
+ }
+
+ public String getScheme()
+ {
+
+ return null;
+ }
+
+ public String getServerName()
+ {
+
+ return null;
+ }
+
+ public int getServerPort()
+ {
+
+ return 0;
+ }
+
+ public boolean isSecure()
+ {
+
+ return false;
+ }
+
+ public void removeAttribute(String name)
+ {
+
+ }
+
+ public void setAttribute(String name, Object o)
+ {
+
+ }
+
+ public void setCharacterEncoding(String env) throws UnsupportedEncodingException
+ {
+
+ }
+
+ }
+}
Added: portal/trunk/component/web/api/src/test/java/org/exoplatform/web/filter/TestFilterDefinition.java
===================================================================
--- portal/trunk/component/web/api/src/test/java/org/exoplatform/web/filter/TestFilterDefinition.java (rev 0)
+++ portal/trunk/component/web/api/src/test/java/org/exoplatform/web/filter/TestFilterDefinition.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,64 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.filter;
+
+import org.exoplatform.component.test.AbstractGateInTest;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 25 sept. 2009
+ */
+public class TestFilterDefinition extends AbstractGateInTest
+{
+
+ public void testMatch()
+ {
+ FilterDefinition def = new FilterDefinition(null, null);
+ try
+ {
+ def.getMapping();
+ fail("An IllegalArgumentException is expected");
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ def = new FilterDefinition(null, new ArrayList<String>());
+ try
+ {
+ def.getMapping();
+ fail("An IllegalArgumentException is expected");
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ def = new FilterDefinition(null, Arrays.asList(".*\\.gif"));
+ assertTrue(def.getMapping().match("/foo/foo.gif"));
+ assertFalse(def.getMapping().match("/foo/foo.giff"));
+ def = new FilterDefinition(null, Arrays.asList(".*\\.gif", ".*\\.giff"));
+ assertTrue(def.getMapping().match("/foo/foo.gif"));
+ assertTrue(def.getMapping().match("/foo/foo.giff"));
+ assertFalse(def.getMapping().match("/foo/foo.giffo"));
+ }
+}
Added: portal/trunk/component/web/api/src/test/resources/TestJSonFormat.html
===================================================================
--- portal/trunk/component/web/api/src/test/resources/TestJSonFormat.html (rev 0)
+++ portal/trunk/component/web/api/src/test/resources/TestJSonFormat.html 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,63 @@
+<!--
+
+ 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>
+ <head>
+ <script type="text/javascript">
+ function testJSonFormat() {
+ text = "{ " +
+ " 'name': 'Thuy', " +
+ " 'scores': [34, 78, 56, 43, 90], " +
+ " 'index': 24, " +
+ " 'isPass': true, " +
+ " 'schools': [ " +
+ " 'school1', " +
+ " 'school2' " +
+ " ], " +
+ " 'accounts': [ " +
+ " { " +
+ " 'username': 'ammi', " +
+ " 'password': '1234' " +
+ " }, " +
+ " { "+
+ " 'username': 'sara', " +
+ " 'password': '34543mf' " +
+ " }, " +
+ " { " +
+ " 'username': 'bim', " +
+ " 'password': 'dsfd4' " +
+ " } " +
+ " ] " +
+ "} ";
+ var json;
+ try{
+ eval("json="+text);
+ alert(json.name +" : "+json.scores[2]);
+ }catch(err){
+ alert(err);
+ }
+ }
+ </script>
+ </head>
+ <body onload="testJSonFormat();">
+ </body>
+</html>
+
Added: portal/trunk/component/web/controller/pom.xml
===================================================================
--- portal/trunk/component/web/controller/pom.xml (rev 0)
+++ portal/trunk/component/web/controller/pom.xml 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,47 @@
+<!--
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web</artifactId>
+ <version>3.2.0-Beta01-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>exo.portal.component.web.controller</artifactId>
+ <packaging>jar</packaging>
+ <name>GateIn Portal Component Web Controller</name>
+
+ <properties>
+ <maven.test.skip>true</maven.test.skip>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.container</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.resources</artifactId>
+ </dependency>
+ </dependencies>
+</project>
Added: portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/WebAppController.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/WebAppController.java (rev 0)
+++ portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/WebAppController.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,151 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.component.ComponentRequestLifecycle;
+import org.exoplatform.container.component.RequestLifeCycle;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.web.application.Application;
+import org.exoplatform.web.command.CommandHandler;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+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
+ *
+ */
+public class WebAppController
+{
+
+ protected static Log log = ExoLogger.getLogger("portal:WebAppController");
+
+ private HashMap<String, Object> attributes_;
+
+ private HashMap<String, Application> applications_;
+
+ private HashMap<String, WebRequestHandler> handlers_;
+
+ /**
+ * 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
+ */
+ public WebAppController() throws Exception
+ {
+ applications_ = new HashMap<String, Application>();
+ attributes_ = new HashMap<String, Object>();
+ handlers_ = new HashMap<String, WebRequestHandler>();
+ register(new CommandHandler());
+ }
+
+ @SuppressWarnings("unused")
+ public Object getAttribute(String name, Object value)
+ {
+ return attributes_.get(name);
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends Application> T getApplication(String appId)
+ {
+ return (T)applications_.get(appId);
+ }
+
+ public List<Application> getApplicationByType(String type)
+ {
+ List<Application> applications = new ArrayList<Application>();
+ for (Application app : applications_.values())
+ {
+ if (app.getApplicationType().equals(type))
+ applications.add(app);
+ }
+ return applications;
+ }
+
+ public void removeApplication(String appId)
+ {
+ applications_.remove(appId);
+ }
+
+ public void addApplication(Application app)
+ {
+ applications_.put(app.getApplicationId(), app);
+ }
+
+ public void register(WebRequestHandler handler) throws Exception
+ {
+ for (String path : handler.getPath())
+ handlers_.put(path, handler);
+ }
+
+ public void unregister(String[] paths)
+ {
+ for (String path : paths)
+ handlers_.remove(path);
+ }
+
+ /**
+ * 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
+ */
+ public void service(HttpServletRequest req, HttpServletResponse res) throws Exception
+ {
+ WebRequestHandler handler = handlers_.get(req.getServletPath());
+ if (log.isDebugEnabled())
+ {
+ 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
+ {
+ handler.execute(this, req, res);
+ }
+ finally
+ {
+ RequestLifeCycle.end();
+ }
+ }
+ }
+}
\ No newline at end of file
Added: portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/WebRequestHandler.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/WebRequestHandler.java (rev 0)
+++ portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/WebRequestHandler.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,53 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * 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 overideen and the buisness logic should be handled here
+ */
+abstract public class WebRequestHandler
+{
+
+ public void onInit(WebAppController controller) throws Exception
+ {
+
+ }
+
+ abstract public String[] getPath();
+
+ abstract public void execute(WebAppController app, HttpServletRequest req, HttpServletResponse res) throws Exception;
+
+ public void onDestroy(WebAppController controler) throws Exception
+ {
+
+ }
+
+}
\ No newline at end of file
Added: portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/Application.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/Application.java (rev 0)
+++ portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/Application.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,115 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.application;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.component.BaseComponentPlugin;
+import org.exoplatform.resolver.ApplicationResourceResolver;
+
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * Created by The eXo Platform SAS
+ * May 7, 2006
+ */
+abstract public class Application extends BaseComponentPlugin
+{
+
+ final static public String JSR168_APPLICATION_TYPE = "jsr168Application";
+
+ final static public String EXO_PORTLET_TYPE = "portlet";
+
+ final static public String EXO_PORTAL_TYPE = "eXoPortal";
+
+ final static public String EXO_GADGET_TYPE = "eXoGadget";
+
+ public final static String WSRP_TYPE = "wsrp";
+
+ private List<ApplicationLifecycle> lifecycleListeners_;
+
+ private ApplicationResourceResolver resourceResolver_;
+
+ private Hashtable<String, Object> attributes_ = new Hashtable<String, Object>();
+
+ abstract public String getApplicationId();
+
+ abstract public String getApplicationType();
+
+ abstract public String getApplicationGroup();
+
+ abstract public String getApplicationName();
+
+ final public ApplicationResourceResolver getResourceResolver()
+ {
+ return resourceResolver_;
+ }
+
+ final public void setResourceResolver(ApplicationResourceResolver resolver)
+ {
+ resourceResolver_ = resolver;
+ }
+
+ final public Object getAttribute(String name)
+ {
+ return attributes_.get(name);
+ }
+
+ final public void setAttribute(String name, Object value)
+ {
+ attributes_.put(name, value);
+ }
+
+ abstract public ResourceBundle getResourceBundle(Locale locale) throws Exception;
+
+ abstract public ResourceBundle getOwnerResourceBundle(String username, Locale locale) throws Exception;
+
+ public ExoContainer getApplicationServiceContainer()
+ {
+ return ExoContainerContext.getCurrentContainer();
+ }
+
+ final public List<ApplicationLifecycle> getApplicationLifecycle()
+ {
+ return lifecycleListeners_;
+ }
+
+ final public void setApplicationLifecycle(List<ApplicationLifecycle> list)
+ {
+ lifecycleListeners_ = list;
+ }
+
+ public void onInit() throws Exception
+ {
+ for (ApplicationLifecycle lifecycle : lifecycleListeners_)
+ {
+ lifecycle.onInit(this);
+ }
+ }
+
+ public void onDestroy() throws Exception
+ {
+ for (ApplicationLifecycle lifecycle : lifecycleListeners_)
+ lifecycle.onDestroy(this);
+ }
+}
\ No newline at end of file
Added: portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationLifecycle.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationLifecycle.java (rev 0)
+++ portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationLifecycle.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,41 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.application;
+
+/**
+ * Created by The eXo Platform SARL
+ * Author : Tuan Nguyen
+ * tuan08(a)users.sourceforge.net
+ * May 9, 2006
+ */
+public interface ApplicationLifecycle<E extends RequestContext>
+{
+
+ public void onInit(Application app) throws Exception;
+
+ public void onStartRequest(Application app, E context) throws Exception;
+
+ public void onFailRequest(Application app, E context, RequestFailure failureType) throws Exception;
+
+ public void onEndRequest(Application app, E context) throws Exception;
+
+ public void onDestroy(Application app) throws Exception;
+
+}
Added: portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationMessage.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationMessage.java (rev 0)
+++ portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationMessage.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,72 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.application;
+
+import java.io.Serializable;
+
+/**
+ * Created by The eXo Platform SARL
+ * Author : Dang Van Minh
+ * minhdv81(a)yahoo.com
+ * Jun 7, 2006
+ */
+public class ApplicationMessage implements Serializable
+{
+ final public static int ERROR = 0, WARNING = 1, INFO = 2;
+
+ private int type_ = INFO;
+
+ private String messageKey_;
+
+ private Object[] messageArgs_;
+
+ public ApplicationMessage(String key, Object[] args)
+ {
+ messageKey_ = key;
+ messageArgs_ = args;
+ }
+
+ public ApplicationMessage(String key, Object[] args, int type)
+ {
+ this(key, args);
+ type_ = type;
+ }
+
+ public String getMessageKey()
+ {
+ return messageKey_;
+ }
+
+ public Object[] getMessageAruments()
+ {
+ return messageArgs_;
+ }
+
+ public int getType()
+ {
+ return type_;
+ }
+
+ public void setType(int type)
+ {
+ this.type_ = type;
+ }
+
+}
Added: portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationSession.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationSession.java (rev 0)
+++ portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationSession.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,36 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.application;
+
+/**
+ * todo (julien) : remove that class that seem useless
+ */
+abstract public class ApplicationSession
+{
+ abstract public Object getAttribute(String name) throws Exception;
+
+ abstract public void setAttribute(String name, Object value, boolean replicated) throws Exception;
+
+ abstract public Object getUserAttribute(String name) throws Exception;
+
+ abstract public void setUserAttribute(String name, Object value, boolean replicated) throws Exception;
+
+ abstract public String getId();
+}
\ No newline at end of file
Added: portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/Parameter.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/Parameter.java (rev 0)
+++ portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/Parameter.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,60 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.application;
+
+/**
+ * Author : Nhu Dinh Thuan
+ * nhudinhthuan(a)exoplatform.com
+ * Oct 26, 2006
+ */
+public class Parameter
+{
+
+ private String name;
+
+ private String value;
+
+ public Parameter(String name, String value)
+ {
+ this.name = name;
+ this.value = value;
+ }
+
+ 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;
+ }
+
+}
Added: portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/RequestContext.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/RequestContext.java (rev 0)
+++ portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/RequestContext.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,171 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.application;
+
+import org.exoplatform.services.resources.Orientation;
+
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+/**
+ * Created by The eXo Platform SAS
+ * May 7, 2006
+ *
+ * This abstract class is a wrapper on top of the request information such as the Locale in use,
+ * the application (for instance PortalApplication, PortletApplication...), an access to the JavascriptManager
+ * as well as a reference to the URLBuilder in use.
+ *
+ * It also contains a ThreadLocal object for an easy access.
+ *
+ * Context can be nested and hence a getParentAppRequestContext() is also available
+ *
+ */
+abstract public class RequestContext
+{
+
+ final static public String ACTION = "op";
+
+ private static ThreadLocal<RequestContext> tlocal_ = new ThreadLocal<RequestContext>();
+
+ private Application app_;
+
+ protected RequestContext parentAppRequestContext_;
+
+ private Map<String, Object> attributes;
+
+ public RequestContext(Application app)
+ {
+ app_ = app;
+ }
+
+ public Application getApplication()
+ {
+ return app_;
+ }
+
+ public Locale getLocale()
+ {
+ return parentAppRequestContext_.getLocale();
+ }
+
+ /**
+ * Returns the orientation for the current request.
+ *
+ * @return the orientation
+ */
+ public abstract Orientation getOrientation();
+
+ public ResourceBundle getApplicationResourceBundle()
+ {
+ return null;
+ }
+
+ abstract public String getRequestParameter(String name);
+
+ abstract public String[] getRequestParameterValues(String name);
+
+ public JavascriptManager getJavascriptManager()
+ {
+ return getParentAppRequestContext().getJavascriptManager();
+ }
+
+ abstract public URLBuilder<?> getURLBuilder();
+
+ public String getRemoteUser()
+ {
+ return parentAppRequestContext_.getRemoteUser();
+ }
+
+ public boolean isUserInRole(String roleUser)
+ {
+ return parentAppRequestContext_.isUserInRole(roleUser);
+ }
+
+ abstract public boolean useAjax();
+
+ public boolean getFullRender()
+ {
+ return true;
+ }
+
+ public ApplicationSession getApplicationSession()
+ {
+ throw new RuntimeException("This method is not supported");
+ }
+
+ public Writer getWriter() throws Exception
+ {
+ return parentAppRequestContext_.getWriter();
+ }
+
+ public void setWriter (Writer writer)
+ {
+ parentAppRequestContext_.setWriter(writer);
+ }
+
+ final public Object getAttribute(String name)
+ {
+ if (attributes == null)
+ return null;
+ return attributes.get(name);
+ }
+
+ final public void setAttribute(String name, Object value)
+ {
+ if (attributes == null)
+ attributes = new HashMap<String, Object>();
+ attributes.put(name, value);
+ }
+
+ final public Object getAttribute(Class type)
+ {
+ return getAttribute(type.getName());
+ }
+
+ final public void setAttribute(Class type, Object value)
+ {
+ setAttribute(type.getName(), value);
+ }
+
+ public RequestContext getParentAppRequestContext()
+ {
+ return parentAppRequestContext_;
+ }
+
+ public void setParentAppRequestContext(RequestContext context)
+ {
+ parentAppRequestContext_ = context;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <T extends RequestContext> T getCurrentInstance()
+ {
+ return (T)tlocal_.get();
+ }
+
+ public static void setCurrentInstance(RequestContext ctx)
+ {
+ tlocal_.set(ctx);
+ }
+
+}
\ No newline at end of file
Added: portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/RequestFailure.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/RequestFailure.java (rev 0)
+++ portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/RequestFailure.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,29 @@
+/*
+ * 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.application;
+
+/**
+ * @author <a href="mailto:hoang281283@gmail.com">Minh Hoang TO</a>
+ * @version $Id$
+ *
+ */
+public enum RequestFailure {
+
+ IO_FAILURE, CONCURRENCY_FAILURE
+}
Added: portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/URLBuilder.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/URLBuilder.java (rev 0)
+++ portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/URLBuilder.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,129 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.application;
+
+import java.net.URLEncoder;
+
+/**
+ * Created by The eXo Platform SAS
+ * Mar 29, 2007
+ */
+abstract public class URLBuilder<T>
+{
+
+ protected String baseURL_;
+
+ public URLBuilder(String baseURL)
+ {
+ baseURL_ = baseURL;
+ }
+
+ public String getBaseURL()
+ {
+ return baseURL_;
+ }
+
+ public void setBaseURL(String url)
+ {
+ baseURL_ = url;
+ }
+
+ public String createURL(String action)
+ {
+ return createURL(action, (Parameter[])null);
+ }
+
+ abstract public String createURL(String action, Parameter[] params);
+
+ public String createURL(String action, String objectId)
+ {
+ return createURL(action, objectId, (Parameter[])null);
+ }
+
+ abstract public String createURL(String action, String objectId, Parameter[] params);
+
+ public String createURL(T targetComponent, String action, String targetBeanId)
+ {
+ return createURL(targetComponent, action, null, targetBeanId, (Parameter[])null);
+ }
+
+ public String createAjaxURL(T targetComponent, String action, String targetBeanId)
+ {
+ return createAjaxURL(targetComponent, action, null, targetBeanId, (Parameter[])null);
+ }
+
+ public String createAjaxURL(T targetComponent, String action, String confirm, String targetBeanId)
+ {
+ return createAjaxURL(targetComponent, action, confirm, targetBeanId, (Parameter[])null);
+ }
+
+ public String createAjaxURL(T targetComponent, String action, String confirm, String targetBeanId, Parameter[] params)
+ {
+ 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();
+ }
+
+ public String createURL(T targetComponent, String action, String confirm, String targetBeanId, Parameter[] params)
+ {
+ 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();
+ }
+
+ abstract protected void createURL(StringBuilder builder, T targetComponent, String action, String targetBeanId,
+ Parameter[] params);
+}
Added: portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/command/Command.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/command/Command.java (rev 0)
+++ portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/command/Command.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,43 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.command;
+
+import org.exoplatform.web.WebAppController;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Created by The eXo Platform SARL
+ * Author : Tuan Nguyen
+ * tuan.nguyen(a)exoplatform.com
+ * May 22, 2007
+ */
+abstract public class Command
+{
+
+ public String[] getRequiredMemberships()
+ {
+ return null;
+ }
+
+ abstract public void execute(WebAppController controller, HttpServletRequest req, HttpServletResponse res)
+ throws Exception;
+}
\ No newline at end of file
Added: portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/command/CommandHandler.java
===================================================================
--- portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/command/CommandHandler.java (rev 0)
+++ portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/command/CommandHandler.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,195 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.command;
+
+import org.exoplatform.web.WebAppController;
+import org.exoplatform.web.WebRequestHandler;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.rmi.activation.UnknownObjectException;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Created by The eXo Platform SAS
+ * Mar 21, 2007
+ */
+public class CommandHandler extends WebRequestHandler
+{
+
+ public String[] getPath()
+ {
+ return new String[]{"/command"};
+ }
+
+ public void execute(WebAppController controller, HttpServletRequest req, HttpServletResponse res) throws Exception
+ {
+ Map props = req.getParameterMap();
+ String type = req.getParameter("type");
+ if (type == null || type.trim().length() < 1)
+ throw new NullPointerException("Unknown type command handler");
+ Command command = createCommand(type, props);
+ if (command == null)
+ throw new UnknownObjectException("Unknown command handler with type is " + type);
+ command.execute(controller, req, res);
+ }
+
+ /**
+ * This method should use the java reflection to create the command object according to the command
+ * type, then populate the command properties
+ *
+ * @param type The command class type
+ * @param props list of the properties that should be set in the command object
+ * @return The command object instance
+ * @throws Exception
+ */
+ @SuppressWarnings("unchecked")
+ public Command createCommand(String type, Map props) throws Exception
+ {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ Class<?> clazz = classLoader.loadClass(type);
+ Object object = clazz.newInstance();
+ Iterator<Object> iter = props.keySet().iterator();
+ while (iter.hasNext())
+ {
+ Object key = iter.next();
+ Field field = getField(clazz, key.toString());
+ if (field == null)
+ continue;
+ setValue(object, field, props.get(key));
+ }
+ return (Command)object;
+ }
+
+ private final void setValue(Object bean, Field field, Object value) throws Exception
+ {
+ Class type = field.getType();
+ if (type.isArray() && !value.getClass().isArray())
+ {
+ value = toValues(type, new Object[]{value});
+ }
+ else if (type.isArray() && value.getClass().isArray())
+ {
+ value = toValues(type, value);
+ }
+ else
+ {
+ if (!type.isArray() && value.getClass().isArray())
+ value = Array.get(value, 0);
+ value = toValue(type, value);
+ }
+ Class clazz = bean.getClass();
+ Method method = getMethod("set", field, clazz);
+ if (method != null)
+ {
+ method.invoke(bean, new Object[]{value});
+ return;
+ }
+ field.setAccessible(true);
+ field.set(bean, value);
+ }
+
+ private final Method getMethod(String prefix, Field field, Class clazz) throws Exception
+ {
+ StringBuilder name = new StringBuilder(field.getName());
+ name.setCharAt(0, Character.toUpperCase(name.charAt(0)));
+ name.insert(0, prefix);
+ return getMethodByName(name.toString(), field, clazz);
+ }
+
+ private final Method getMethodByName(String name, Field field, Class clazz)
+ {
+ try
+ {
+ Method method = clazz.getDeclaredMethod(name.toString(), new Class[]{field.getType()});
+ if (method != null)
+ return method;
+ if (clazz == Object.class)
+ return null;
+ method = getMethodByName(name, field, clazz.getSuperclass());
+ if (method != null)
+ return method;
+ }
+ catch (Exception e)
+ {
+ }
+ return null;
+ }
+
+ private Field getField(Class clazz, String name)
+ {
+ Field field = null;
+ try
+ {
+ field = clazz.getDeclaredField(name);
+ }
+ catch (Exception e)
+ {
+ }
+ if (field != null)
+ return field;
+ if (clazz == Object.class)
+ return null;
+ return getField(clazz.getSuperclass(), name);
+ }
+
+ private Object toValues(Class<?> clazz, Object objects)
+ {
+ Class componentType = clazz.getComponentType();
+ Object newValues = Array.newInstance(componentType, Array.getLength(objects));
+ for (int i = 0; i < Array.getLength(objects); i++)
+ {
+ Array.set(newValues, i, toValue(componentType, Array.get(objects, i)));
+ }
+ return clazz.cast(newValues);
+ }
+
+ private Object toValue(Class<?> clazz, Object object)
+ {
+ if (clazz == int.class)
+ return new Integer(object.toString()).intValue();
+ if (clazz == short.class)
+ return new Short(object.toString()).shortValue();
+ if (clazz == float.class)
+ return new Float(object.toString()).floatValue();
+ if (clazz == double.class)
+ return new Double(object.toString()).doubleValue();
+ if (clazz == boolean.class)
+ return new Boolean(object.toString()).booleanValue();
+ if (clazz == char.class)
+ return object.toString().trim().charAt(0);
+ try
+ {
+ Constructor<?> constructor = clazz.getConstructor(new Class[]{String.class});
+ return constructor.newInstance(new Object[]{object.toString()});
+ }
+ catch (Exception e)
+ {
+ }
+ return object.toString();
+ }
+
+}
\ No newline at end of file
Modified: portal/trunk/component/web/pom.xml
===================================================================
--- portal/trunk/component/web/pom.xml 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/component/web/pom.xml 2010-07-23 21:22:58 UTC (rev 3699)
@@ -28,70 +28,13 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>exo.portal.component.web</artifactId>
- <packaging>jar</packaging>
+ <packaging>pom</packaging>
<name>GateIn Portal Component Web</name>
- <properties>
- <maven.test.skip>true</maven.test.skip>
- </properties>
-
- <dependencies>
-
- <dependency>
- <groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.container</artifactId>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.core</groupId>
- <artifactId>exo.core.component.organization.api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.jcr</groupId>
- <artifactId>exo.jcr.component.ext</artifactId>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.resources</artifactId>
- </dependency>
- <dependency>
- <groupId>org.gatein.wci</groupId>
- <artifactId>wci-wci</artifactId>
- </dependency>
- <dependency>
- <groupId>org.chromattic</groupId>
- <artifactId>chromattic.apt</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.scripting</artifactId>
- </dependency>
- <dependency>
- <groupId>org.gatein.shindig</groupId>
- <artifactId>shindig-gadgets</artifactId>
- </dependency>
- <dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <type>jar</type>
- </dependency>
- <dependency>
- <groupId>org.gatein.captcha</groupId>
- <artifactId>simplecaptcha</artifactId>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.test.core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.jbossas</groupId>
- <artifactId>jboss-as-tomcat</artifactId>
- <scope>provided</scope>
- </dependency>
- </dependencies>
+ <modules>
+ <module>controller</module>
+ <module>security</module>
+ <module>server</module>
+ <module>api</module>
+ </modules>
</project>
Added: portal/trunk/component/web/security/pom.xml
===================================================================
--- portal/trunk/component/web/security/pom.xml (rev 0)
+++ portal/trunk/component/web/security/pom.xml 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,80 @@
+<!--
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web</artifactId>
+ <version>3.2.0-Beta01-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>exo.portal.component.web.security</artifactId>
+ <packaging>jar</packaging>
+ <name>GateIn Portal Component Web Security</name>
+
+ <properties>
+ <maven.test.skip>true</maven.test.skip>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.container</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.core</groupId>
+ <artifactId>exo.core.component.organization.api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.common</artifactId>
+ </dependency>
+<!--
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web.controller</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.wci</groupId>
+ <artifactId>wci-wci</artifactId>
+ </dependency>
+-->
+ <dependency>
+ <groupId>org.chromattic</groupId>
+ <artifactId>chromattic.apt</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.captcha</groupId>
+ <artifactId>simplecaptcha</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.test.core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-tomcat</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
Added: portal/trunk/component/web/security/src/main/java/conf/autologin-nodetypes.xml
===================================================================
--- portal/trunk/component/web/security/src/main/java/conf/autologin-nodetypes.xml (rev 0)
+++ portal/trunk/component/web/security/src/main/java/conf/autologin-nodetypes.xml 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,56 @@
+<!--
+
+ 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.
+
+-->
+<nodeTypes xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0">
+
+ <nodeType name="tkn:tokencontainer" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+ <supertypes>
+ <supertype>nt:base</supertype>
+ <supertype>mix:referenceable</supertype>
+ </supertypes>
+ <childNodeDefinitions>
+ <childNodeDefinition name="*" defaultPrimaryType="tkn:tokenentry" autoCreated="false" mandatory="false"
+ onParentVersion="COPY" protected="false" sameNameSiblings="false">
+ <requiredPrimaryTypes>
+ <requiredPrimaryType>tkn:tokenentry</requiredPrimaryType>
+ </requiredPrimaryTypes>
+ </childNodeDefinition>
+ </childNodeDefinitions>
+ </nodeType>
+
+ <nodeType name="tkn:tokenentry" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+ <supertypes>
+ <supertype>nt:base</supertype>
+ <supertype>mix:referenceable</supertype>
+ </supertypes>
+ <propertyDefinitions>
+ <propertyDefinition name="username" requiredType="String" autoCreated="false" mandatory="true" onParentVersion="COPY" protected="false" multiple="false">
+ <valueConstraints/>
+ </propertyDefinition>
+ <propertyDefinition name="password" requiredType="String" autoCreated="false" mandatory="true" onParentVersion="COPY" protected="false" multiple="false">
+ <valueConstraints/>
+ </propertyDefinition>
+ <propertyDefinition name="expiration" requiredType="Date" autoCreated="true" mandatory="true" onParentVersion="COPY" protected="false" multiple="false">
+ <valueConstraints/>
+ </propertyDefinition>
+ </propertyDefinitions>
+ </nodeType>
+
+</nodeTypes>
Added: portal/trunk/component/web/security/src/main/java/conf/portal/configuration.xml
===================================================================
--- portal/trunk/component/web/security/src/main/java/conf/portal/configuration.xml (rev 0)
+++ portal/trunk/component/web/security/src/main/java/conf/portal/configuration.xml 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,62 @@
+<?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>
+
+ <component>
+ <type>org.exoplatform.web.WebAppController</type>
+ </component>
+
+ <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>
Added: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/CacheUserProfileFilter.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/CacheUserProfileFilter.java (rev 0)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/CacheUserProfileFilter.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,100 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web;
+
+import org.exoplatform.container.component.ComponentRequestLifecycle;
+import org.exoplatform.container.component.RequestLifeCycle;
+import org.exoplatform.container.web.AbstractFilter;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.organization.OrganizationService;
+import org.exoplatform.services.organization.User;
+import org.exoplatform.services.security.ConversationState;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+public class CacheUserProfileFilter extends AbstractFilter
+{
+
+ /**
+ * "subject".
+ */
+ public static final String USER_PROFILE = "UserProfile";
+
+ /**
+ * Logger.
+ */
+ private static Log log = ExoLogger.getLogger("core.security.SetCurrentIdentityFilter");
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException
+ {
+ ConversationState state = ConversationState.getCurrent();
+ try
+ {
+ if (state != null)
+ {
+ if (log.isDebugEnabled())
+ log.debug("Conversation State found, save user profile to Conversation State.");
+
+ if (state.getAttribute(USER_PROFILE) == null)
+ {
+ OrganizationService orgService =
+ (OrganizationService)getContainer().getComponentInstanceOfType(OrganizationService.class);
+
+ begin(orgService);
+ User user = orgService.getUserHandler().findUserByName(state.getIdentity().getUserId());
+ end(orgService);
+ state.setAttribute(USER_PROFILE, user);
+
+ }
+
+ }
+ chain.doFilter(request, response);
+ }
+ catch (Exception e)
+ {
+ log.warn("An error occured while cache user profile", e);
+ }
+
+ }
+
+ public void destroy()
+ {
+ }
+
+ public void begin(OrganizationService orgService) throws Exception
+ {
+ if (orgService instanceof ComponentRequestLifecycle)
+ {
+ RequestLifeCycle.begin((ComponentRequestLifecycle)orgService);
+ }
+ }
+
+ public void end(OrganizationService orgService) throws Exception
+ {
+ if (orgService instanceof ComponentRequestLifecycle)
+ {
+ RequestLifeCycle.end();
+ }
+ }
+}
Added: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/ClusteredSSOFilter.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/ClusteredSSOFilter.java (rev 0)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/ClusteredSSOFilter.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,80 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2010, Red Hat Middleware, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.exoplatform.container.ExoContainer;
+import org.exoplatform.container.web.AbstractFilter;
+import org.exoplatform.web.security.Credentials;
+import org.exoplatform.web.security.PortalLoginModule;
+
+import org.jboss.web.tomcat.security.login.WebAuthentication;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+
+/*
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ */
+public class ClusteredSSOFilter extends AbstractFilter
+{
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
+ {
+ if (ExoContainer.getProfiles().contains("cluster"))
+ {
+ HttpServletRequest httpRequest = (HttpServletRequest)request;
+
+ Credentials credentials = (Credentials)httpRequest.getSession().getAttribute(PortalLoginModule.AUTHENTICATED_CREDENTIALS);
+
+ // Make programatic login if authenticated credentials are present in session - they were set in another cluster node
+ if (credentials != null && httpRequest.getRemoteUser() == null)
+ {
+ WebAuthentication pwl = new WebAuthentication();
+ pwl.login(credentials.getUsername(), credentials.getPassword());
+
+ }
+
+ chain.doFilter(request, response);
+
+ // TODO:
+ // This is a workaround... without this code this attr will vanish from session after first request - don't ask...
+ if (credentials != null && httpRequest.getSession(false) != null)
+ {
+ httpRequest.getSession(false).setAttribute(PortalLoginModule.AUTHENTICATED_CREDENTIALS, credentials);
+ }
+ }
+ else
+ {
+ chain.doFilter(request, response);
+ }
+ }
+
+ public void destroy()
+ {
+ }
+}
Added: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/ErrorLoginServlet.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/ErrorLoginServlet.java (rev 0)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/ErrorLoginServlet.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,126 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.login;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.container.web.AbstractHttpServlet;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.web.security.security.AbstractTokenService;
+import org.exoplatform.web.security.security.CookieTokenService;
+
+import java.io.IOException;
+import java.util.Enumeration;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Manages an error on login
+ *
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 4 oct. 2009
+ */
+public class ErrorLoginServlet extends AbstractHttpServlet
+{
+
+ /**
+ * Serial version ID
+ */
+ private static final long serialVersionUID = -1565579389217147072L;
+
+ /**
+ * Logger.
+ */
+ private static final Log LOG = ExoLogger.getLogger(ErrorLoginServlet.class.getName());
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ PortalContainer pContainer = PortalContainer.getInstance();
+ ServletContext context = pContainer.getPortalContext();
+ // Unregister the token cookie
+ unregisterTokenCookie(req);
+ // Clear the token cookie
+ clearTokenCookie(req, resp);
+ // This allows the customer to define another login page without changing the portal
+ context.getRequestDispatcher("/login/jsp/login.jsp").include(req, resp);
+ }
+
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ doGet(req, resp);
+ }
+
+ private void clearTokenCookie(HttpServletRequest req, HttpServletResponse resp)
+ {
+ Cookie cookie = new Cookie(InitiateLoginServlet.COOKIE_NAME, "");
+ cookie.setPath(req.getContextPath());
+ cookie.setMaxAge(0);
+ resp.addCookie(cookie);
+ }
+
+ private void unregisterTokenCookie(HttpServletRequest req)
+ {
+ String tokenId = getTokenCookie(req);
+ if (tokenId != null)
+ {
+ try
+ {
+ AbstractTokenService tokenService = AbstractTokenService.getInstance(CookieTokenService.class);
+ tokenService.deleteToken(tokenId);
+ }
+ catch (Exception e)
+ {
+ LOG.warn("Cannot delete the token '" + tokenId + "'", e);
+ }
+ }
+ }
+
+ private String getTokenCookie(HttpServletRequest req)
+ {
+ Cookie[] cookies = req.getCookies();
+ if (cookies != null)
+ {
+ for (Cookie cookie : cookies)
+ {
+ if (InitiateLoginServlet.COOKIE_NAME.equals(cookie.getName()))
+ {
+ return cookie.getValue();
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see org.exoplatform.container.web.AbstractHttpServlet#requirePortalEnvironment()
+ */
+ @Override
+ protected boolean requirePortalEnvironment()
+ {
+ return true;
+ }
+}
Added: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java (rev 0)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,183 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.login;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.container.web.AbstractHttpServlet;
+import org.exoplatform.web.security.Credentials;
+import org.exoplatform.web.security.security.AbstractTokenService;
+import org.exoplatform.web.security.security.CookieTokenService;
+import org.exoplatform.web.security.security.TransientTokenService;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+
+import java.io.IOException;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+/**
+ * Initiate the login dance.
+ *
+ * @author <a href="mailto:trong.tran@exoplatform.com">Tran The Trong</a>
+ * @version $Revision$
+ */
+public class InitiateLoginServlet extends AbstractHttpServlet
+{
+
+ /** . */
+ private static final Logger log = LoggerFactory.getLogger(InitiateLoginServlet.class);
+
+ /** . */
+ public static final String COOKIE_NAME = "rememberme";
+
+ /** . */
+ public static final String CREDENTIALS = "credentials";
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ resp.setContentType("text/html; charset=UTF-8");
+ HttpSession session = req.getSession();
+
+ // Looking for credentials stored in the session
+ Credentials credentials = (Credentials)session.getAttribute(InitiateLoginServlet.CREDENTIALS);
+
+ //
+ if (credentials == null)
+ {
+ PortalContainer pContainer = PortalContainer.getInstance();
+ ServletContext context = pContainer.getPortalContext();
+
+ //
+ String token = getRememberMeTokenCookie(req);
+ if (token != null)
+ {
+ AbstractTokenService tokenService = AbstractTokenService.getInstance(CookieTokenService.class);
+ credentials = tokenService.validateToken(token, false);
+ if (credentials == null)
+ {
+ log.debug("Login initiated with no credentials in session but found token an invalid " + token + " " +
+ "that will be cleared in next response");
+
+ // We clear the cookie in the next response as it was not valid
+ Cookie cookie = new Cookie(InitiateLoginServlet.COOKIE_NAME, "");
+ cookie.setPath(req.getContextPath());
+ cookie.setMaxAge(0);
+ resp.addCookie(cookie);
+
+ // This allows the customer to define another login page without
+ // changing the portal
+ showLoginForm(req, resp);
+ }
+ else
+ {
+ // Send authentication request
+ log.debug("Login initiated with no credentials in session but found token " + token + " with existing credentials, " +
+ "performing authentication");
+ sendAuth(resp, credentials.getUsername(), token);
+ }
+ }
+ else
+ {
+ // This allows the customer to define another login page without
+ // changing the portal
+ log.debug("Login initiated with no credentials in session and no token cookie, redirecting to login page");
+ showLoginForm(req, resp);
+ }
+ }
+ else
+ {
+ // We create a temporary token just for the login time
+ TransientTokenService tokenService = AbstractTokenService.getInstance(TransientTokenService.class);
+ String token = tokenService.createToken(credentials);
+ req.getSession().removeAttribute(InitiateLoginServlet.CREDENTIALS);
+
+ // Send authentication request
+ log.debug("Login initiated with credentials in session, performing authentication");
+ sendAuth(resp, credentials.getUsername(), token);
+ }
+ }
+
+ private void showLoginForm(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ String initialURI = (String)req.getAttribute("javax.servlet.forward.request_uri");
+ if (initialURI == null)
+ {
+ throw new IllegalStateException("request attribute javax.servlet.forward.request_uri should not be null here");
+ }
+ try
+ {
+ req.setAttribute("org.gatein.portal.login.initial_uri", initialURI);
+ getServletContext().getRequestDispatcher("/login/jsp/login.jsp").include(req, resp);
+ }
+ finally
+ {
+ req.removeAttribute("org.gatein.portal.login.initial_uri");
+ }
+ }
+
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ doGet(req, resp);
+ }
+
+ private void sendAuth(HttpServletResponse resp, String jUsername, String jPassword) throws IOException
+ {
+ String url = "j_security_check?j_username=" + jUsername + "&j_password=" + jPassword;
+ url = resp.encodeRedirectURL(url);
+ resp.sendRedirect(url);
+ }
+
+ /**
+ * Extract the remember me token from the request or returns null.
+ *
+ * @param req the incoming request
+ * @return the token
+ */
+ public static String getRememberMeTokenCookie(HttpServletRequest req)
+ {
+ Cookie[] cookies = req.getCookies();
+ if (cookies != null)
+ {
+ for (Cookie cookie : cookies)
+ {
+ if (InitiateLoginServlet.COOKIE_NAME.equals(cookie.getName()))
+ {
+ return cookie.getValue();
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see org.exoplatform.container.web.AbstractHttpServlet#requirePortalEnvironment()
+ */
+ @Override
+ protected boolean requirePortalEnvironment()
+ {
+ return true;
+ }
+}
Added: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/PortalLoginController.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/PortalLoginController.java (rev 0)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/PortalLoginController.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,118 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.login;
+
+import org.exoplatform.container.web.AbstractHttpServlet;
+import org.exoplatform.web.security.Credentials;
+import org.exoplatform.web.security.security.AbstractTokenService;
+import org.exoplatform.web.security.security.CookieTokenService;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:trong.tran@exoplatform.com">Tran The Trong</a>
+ * @version $Revision$
+ */
+public class PortalLoginController extends AbstractHttpServlet
+{
+
+ /** . */
+ private static final Logger log = LoggerFactory.getLogger(PortalLoginController.class);
+
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ String username = req.getParameter("username");
+ String password = req.getParameter("password");
+
+ //
+ if (username == null)
+ {
+ log.error("Tried to access the portal login controller without username provided");
+ resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "No username provided");
+ return;
+ }
+ if (password == null)
+ {
+ log.error("Tried to access the portal login controller without password provided");
+ resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "No password provided");
+ return;
+ }
+
+ //
+ log.debug("Found username and password and set credentials in http session");
+ Credentials credentials = new Credentials(username, password);
+ req.getSession().setAttribute(InitiateLoginServlet.CREDENTIALS, credentials);
+
+ // Obtain initial URI
+ String uri = req.getParameter("initialURI");
+
+ // otherwise compute one
+ if (uri == null || uri.length() == 0)
+ {
+ uri = req.getContextPath() + "/private/classic";
+ log.debug("No initial URI found, will use default " + uri + " instead ");
+ }
+ else
+ {
+ 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() / 1000);
+ resp.addCookie(cookie);
+ }
+ }
+
+ //
+ resp.sendRedirect(uri);
+ }
+
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ doGet(req, resp);
+ }
+
+ @Override
+ protected boolean requirePortalEnvironment()
+ {
+ return true;
+ }
+}
Added: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/RememberMeFilter.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/RememberMeFilter.java (rev 0)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/RememberMeFilter.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,98 @@
+/*
+ * 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.
+ */
+
+package org.exoplatform.web.login;
+
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+import org.gatein.common.text.FastURLEncoder;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Enumeration;
+
+/**
+ * The remember me filter performs a send redirect on a portal private servlet mapping when the current request
+ * is a GET request, the user is not authenticated and there is a remember me token cookie in the request.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class RememberMeFilter implements Filter
+{
+ /** . */
+ private static final FastURLEncoder CONVERTER = FastURLEncoder.getUTF8Instance();
+
+ /** . */
+ private static final Logger log = LoggerFactory.getLogger(RememberMeFilter.class);
+
+ public void init(FilterConfig filterConfig) throws ServletException
+ {
+ }
+
+ public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException
+ {
+ doFilter((HttpServletRequest)req, (HttpServletResponse)resp, chain);
+ }
+
+ private void doFilter(HttpServletRequest req, HttpServletResponse resp, FilterChain chain) throws IOException, ServletException
+ {
+ if (req.getRemoteUser() == null && "GET".equals(req.getMethod()))
+ {
+ String token = InitiateLoginServlet.getRememberMeTokenCookie(req);
+ if (token != null)
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append(req.getContextPath());
+ builder.append("/private");
+ String pathInfo = req.getPathInfo();
+ if (pathInfo != null)
+ {
+ builder.append(pathInfo);
+ }
+ char sep = '?';
+ for (Enumeration<String> e = req.getParameterNames();e.hasMoreElements();)
+ {
+ String parameterName = e.nextElement();
+ for (String parameteValue : req.getParameterValues(parameterName))
+ {
+ builder.append(sep);
+ sep = '&';
+ builder.append(CONVERTER.encode(parameterName));
+ builder.append('=');
+ builder.append(CONVERTER.encode(parameteValue));
+ }
+ }
+ String s = builder.toString();
+ log.debug("Redirecting unauthenticated request with token " + token + " to URL " + s);
+ resp.sendRedirect(s);
+ return;
+ }
+ }
+
+ //
+ chain.doFilter(req, resp);
+ }
+
+ public void destroy()
+ {
+ }
+}
Added: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/CaptchaServlet.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/CaptchaServlet.java (rev 0)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/CaptchaServlet.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,88 @@
+/******************************************************************************
+ * JBoss by Red Hat *
+ * Copyright 2010, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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.security;
+
+import static nl.captcha.Captcha.NAME;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import nl.captcha.Captcha;
+import nl.captcha.servlet.CaptchaServletUtil;
+
+/**
+ * @author <a href="mailto:theute@redhat.com">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class CaptchaServlet extends HttpServlet
+{
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String PARAM_HEIGHT = "height";
+
+ private static final String PARAM_WIDTH = "width";
+
+ protected int _width = 200;
+
+ protected int _height = 50;
+
+ @Override
+ public void init() throws ServletException
+ {
+ if (getInitParameter(PARAM_HEIGHT) != null)
+ {
+ _height = Integer.valueOf(getInitParameter(PARAM_HEIGHT));
+ }
+
+ if (getInitParameter(PARAM_WIDTH) != null)
+ {
+ _width = Integer.valueOf(getInitParameter(PARAM_WIDTH));
+ }
+ }
+
+ @Override
+ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ HttpSession session = req.getSession();
+ Captcha captcha;
+ if (session.getAttribute(NAME) == null)
+ {
+ captcha = new Captcha.Builder(_width, _height).addText().gimp().addNoise().addBackground().build();
+
+ session.setAttribute(NAME, captcha);
+ CaptchaServletUtil.writeImage(resp, captcha.getImage());
+
+ return;
+ }
+
+ captcha = (Captcha) session.getAttribute(NAME);
+ CaptchaServletUtil.writeImage(resp, captcha.getImage());
+ }
+
+}
Added: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/Credentials.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/Credentials.java (rev 0)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/Credentials.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,81 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.security;
+
+import java.io.Serializable;
+
+/**
+ * An immutable object that contains a username and a password.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class Credentials implements Serializable
+{
+
+
+
+ /** . */
+ private final String username;
+
+ /** . */
+ private final String password;
+
+ /**
+ * Construct a new instance.
+ *
+ * @param username the username value
+ * @param password the password value
+ * @throws NullPointerException if any argument is null
+ */
+ public Credentials(String username, String password) throws NullPointerException
+ {
+ if (username == null)
+ {
+ throw new NullPointerException("Username is null");
+ }
+ if (password == null)
+ {
+ throw new NullPointerException("Password is null");
+ }
+ this.username = username;
+ this.password = password;
+ }
+
+ /**
+ * Returns the username.
+ *
+ * @return the username
+ */
+ public String getUsername()
+ {
+ return username;
+ }
+
+ /**
+ * Returns the password.
+ *
+ * @return the password
+ */
+ public String getPassword()
+ {
+ return password;
+ }
+}
Added: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/GateInToken.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/GateInToken.java (rev 0)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/GateInToken.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,64 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.security;
+
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : Tan Pham Dinh
+ * tan.pham(a)exoplatform.com
+ * May 6, 2009
+ */
+public class GateInToken implements Token
+{
+
+ public static String EXPIRE_MILI = "expirationMilis";
+
+ public static String USERNAME = "userName";
+
+ public static String PASSWORD = "password";
+
+ /** . */
+ private final long expirationTimeMillis;
+
+ /** . */
+ private final Credentials payload;
+
+ public GateInToken(long expirationTimeMillis, Credentials payload)
+ {
+ this.expirationTimeMillis = expirationTimeMillis;
+ this.payload = payload;
+ }
+
+ public long getExpirationTimeMillis()
+ {
+ return expirationTimeMillis;
+ }
+
+ public Credentials getPayload()
+ {
+ return payload;
+ }
+
+ public boolean isExpired()
+ {
+ return System.currentTimeMillis() > expirationTimeMillis;
+ }
+}
Added: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginModule.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginModule.java (rev 0)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginModule.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,206 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.security;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.security.jaas.AbstractLoginModule;
+import org.exoplatform.web.login.InitiateLoginServlet;
+import org.exoplatform.web.security.security.CookieTokenService;
+import org.exoplatform.web.security.security.TransientTokenService;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.login.LoginException;
+import javax.servlet.http.HttpServletRequest;
+import java.lang.reflect.Method;
+
+/**
+ * A login module implementation that relies on the token store to check the
+ * password validity. If the token store provides a valid {@link Credentials}
+ * value then password stacking is used and the two entries are added in the
+ * shared state map. The first entry is keyed by
+ * <code>javax.security.auth.login.name</code> and contains the
+ * {@link Credentials#getUsername()} value, the second entry is keyed by
+ * <code>javax.security.auth.login.password</code> and contains the
+ * {@link Credentials#getPassword()} ()} value.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PortalLoginModule extends AbstractLoginModule
+{
+
+ /** Logger. */
+ private static final Log log = ExoLogger.getLogger(PortalLoginModule.class);
+
+ /** JACC get context method. */
+ private static final Method getContextMethod;
+
+ static
+ {
+ Method getContext = null;
+ if (isClusteredSSO())
+ {
+ log.debug("About to configure clustered SSO");
+ try
+ {
+ Class<?> policyContextClass = Thread.currentThread().getContextClassLoader().loadClass("javax.security.jacc.PolicyContext");
+ getContext = policyContextClass.getDeclaredMethod("getContext", String.class);
+ }
+ catch (ClassNotFoundException ignore)
+ {
+ log.debug("JACC not found ignoring it", ignore);
+ }
+ catch (Exception e)
+ {
+ log.error("Could not obtain JACC get context method", e);
+ }
+ }
+
+ //
+ getContextMethod = getContext;
+ }
+
+ public static final String AUTHENTICATED_CREDENTIALS = "authenticatedCredentials";
+
+ /**
+ * @see javax.security.auth.spi.LoginModule#login()
+ */
+ @SuppressWarnings("unchecked")
+ public boolean login() throws LoginException
+ {
+
+ Callback[] callbacks = new Callback[2];
+ callbacks[0] = new NameCallback("Username");
+ callbacks[1] = new PasswordCallback("Password", false);
+
+ try
+ {
+ callbackHandler.handle(callbacks);
+ String password = new String(((PasswordCallback)callbacks[1]).getPassword());
+
+ ExoContainer container = getContainer();
+ Object o =
+ ((TransientTokenService)container.getComponentInstanceOfType(TransientTokenService.class)).validateToken(
+ password, true);
+ if (o == null)
+ o =
+ ((CookieTokenService)container.getComponentInstanceOfType(CookieTokenService.class)).validateToken(
+ password, false);
+ //
+
+ // For clustered config check credentials stored and propagated in session. This won't work in tomcat because
+ // of lack of JACC PolicyContext so the code must be a bit defensive
+ if (o == null && getContextMethod != null && password.startsWith(InitiateLoginServlet.COOKIE_NAME))
+ {
+ HttpServletRequest request;
+ try
+ {
+ request = (HttpServletRequest)getContextMethod.invoke(null, "javax.servlet.http.HttpServletRequest");
+ o = request.getSession().getAttribute(AUTHENTICATED_CREDENTIALS);
+ }
+ catch(Throwable e)
+ {
+ log.error(this,e);
+ log.error("LoginModule error. Turn off session credentials checking with proper configuration option of " +
+ "LoginModule set to false");
+ }
+
+ }
+
+ if (o instanceof Credentials)
+ {
+ Credentials wc = (Credentials)o;
+
+ // Set shared state
+ sharedState.put("javax.security.auth.login.name", wc.getUsername());
+ sharedState.put("javax.security.auth.login.password", wc.getPassword());
+ }
+ return true;
+ }
+ catch (Exception e)
+ {
+ LoginException le = new LoginException();
+ le.initCause(e);
+ throw le;
+ }
+ }
+
+ /**
+ * @see javax.security.auth.spi.LoginModule#commit()
+ */
+ public boolean commit() throws LoginException
+ {
+
+ if (getContextMethod != null &&
+ sharedState.containsKey("javax.security.auth.login.name") &&
+ sharedState.containsKey("javax.security.auth.login.password"))
+ {
+ String uid = (String)sharedState.get("javax.security.auth.login.name");
+ String pass = (String)sharedState.get("javax.security.auth.login.password");
+
+ Credentials wc = new Credentials(uid, pass);
+
+ HttpServletRequest request = null;
+ try
+ {
+ request = (HttpServletRequest)getContextMethod.invoke(null, "javax.servlet.http.HttpServletRequest");
+ request.getSession().setAttribute(AUTHENTICATED_CREDENTIALS, wc);
+ }
+ catch(Exception e)
+ {
+ log.error(this,e);
+ log.error("LoginModule error. Turn off session credentials checking with proper configuration option of " +
+ "LoginModule set to false");
+ }
+ }
+ return true;
+ }
+
+ /**
+ * @see javax.security.auth.spi.LoginModule#abort()
+ */
+ public boolean abort() throws LoginException
+ {
+ return true;
+ }
+
+ /**
+ * @see javax.security.auth.spi.LoginModule#logout()
+ */
+ public boolean logout() throws LoginException
+ {
+ return true;
+ }
+
+ @Override
+ protected Log getLogger()
+ {
+ return log;
+ }
+
+ protected static boolean isClusteredSSO()
+ {
+ return ExoContainer.getProfiles().contains("cluster");
+ }
+}
Added: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/Token.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/Token.java (rev 0)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/Token.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -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.security;
+
+/**
+ * A token.
+ */
+public interface Token
+{
+ boolean isExpired();
+
+ long getExpirationTimeMillis();
+
+ Credentials getPayload();
+
+}
Added: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/TokenStore.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/TokenStore.java (rev 0)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/TokenStore.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,53 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.security;
+
+/**
+ * The token store is a place where temporary tokens are held.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public interface TokenStore
+{
+ /**
+ * Create a token and returns it. The store state is modified as it retains the token until
+ * it is removed either explicitely or because the token validity is expired.
+ *
+ * @param credentials the credentials
+ * @return the token key
+ * @throws IllegalArgumentException if the validity is not greater than zero
+ * @throws NullPointerException if the payload is null
+ */
+ String createToken(Credentials credentials) throws IllegalArgumentException, NullPointerException;
+
+ /**
+ * Validates a token. If the token is valid it returns the attached credentials. The store state may be modified
+ * by the removal of the token. The token is removed either if the remove argument is set to true of if the
+ * token is not anymore valid.
+ *
+ * @param tokenKey the token key
+ * @param remove true if the token must be removed regardless its validity
+ * @return the attached credentials or null
+ * @throws NullPointerException if the token key argument is null
+ */
+ Credentials validateToken(String tokenKey, boolean remove) throws NullPointerException;
+
+}
Added: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/AbstractTokenService.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/AbstractTokenService.java (rev 0)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/AbstractTokenService.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,223 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.security.security;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.management.annotations.*;
+import org.exoplatform.management.jmx.annotations.NameTemplate;
+import org.exoplatform.management.jmx.annotations.Property;
+import org.exoplatform.web.login.InitiateLoginServlet;
+import org.exoplatform.web.security.Credentials;
+import org.exoplatform.web.security.Token;
+import org.exoplatform.web.security.TokenStore;
+import org.picocontainer.Startable;
+
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Created by The eXo Platform SAS Author : liem.nguyen ncliam(a)gmail.com Jun 5,
+ * 2009
+ *
+ * todo julien :
+ * - make delay configuration from init param and @Managed setter
+ * - start/stop expiration daemon
+ * - manually invoke the daemon via @Managed
+ *
+ * @param <T> the token type
+ * @param <K> the token key type
+ */
+@Managed
+@ManagedDescription("Token Store Service")
+@NameTemplate({
+ @Property(key = "service", value = "TokenStore"),
+ @Property(key = "name", value = "{Name}")})
+public abstract class AbstractTokenService<T extends Token, K> implements Startable, TokenStore
+{
+
+ protected static final String SERVICE_CONFIG = "service.configuration";
+
+ protected static final int DELAY_TIME = 600;
+
+ protected final Random random = new Random();
+
+ protected String name;
+
+ protected long validityMillis;
+
+ @SuppressWarnings("unchecked")
+ public AbstractTokenService(InitParams initParams)
+ {
+ List<String> params = initParams.getValuesParam(SERVICE_CONFIG).getValues();
+ this.name = params.get(0);
+ long configValue = new Long(params.get(1));
+ this.validityMillis = TimeoutEnum.valueOf(params.get(2)).toMilisecond(configValue);
+ }
+
+ public void start()
+ {
+ // start a thread, garbage expired cookie token every [DELAY_TIME]
+ final AbstractTokenService service = this;
+ ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
+ executor.scheduleWithFixedDelay(new Runnable()
+ {
+ public void run()
+ {
+ service.cleanExpiredTokens();
+ }
+ }, 0, DELAY_TIME, TimeUnit.SECONDS);
+
+ }
+
+ public void stop()
+ {
+ // do nothing
+ }
+
+ public static <T extends AbstractTokenService> T getInstance(Class<T> classType)
+ {
+ PortalContainer container = PortalContainer.getInstance();
+ return classType.cast(container.getComponentInstanceOfType(classType));
+ }
+
+ public Credentials validateToken(String stringKey, boolean remove)
+ {
+ if (stringKey == null)
+ {
+ throw new NullPointerException();
+ }
+
+ //
+ K tokenKey = decodeKey(stringKey);
+
+ T token;
+ try
+ {
+ if (remove)
+ {
+ token = this.deleteToken(tokenKey);
+ }
+ else
+ {
+ token = this.getToken(tokenKey);
+ }
+
+ if (token != null)
+ {
+ boolean valid = token.getExpirationTimeMillis() > System.currentTimeMillis();
+ if (valid)
+ {
+ return token.getPayload();
+ }
+ else if (!remove)
+ {
+ this.deleteToken(tokenKey);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ }
+
+ return null;
+ }
+
+ @Managed
+ @ManagedDescription("Clean all tokens are expired")
+ @Impact(ImpactType.IDEMPOTENT_WRITE)
+ public void cleanExpiredTokens()
+ {
+ K[] ids = getAllTokens();
+ for (K id : ids)
+ {
+ T token = getToken(id);
+ if (token.isExpired())
+ {
+ deleteToken(id);
+ }
+ }
+ }
+
+ @Managed
+ @ManagedDescription("Get time for token expiration in seconds")
+ public long getValidityTime()
+ {
+ return validityMillis / 1000;
+ }
+
+ @Managed
+ @ManagedDescription("The expiration daemon period time in seconds")
+ public long getPeriodTime()
+ {
+ return DELAY_TIME;
+ }
+
+ @Managed
+ @ManagedDescription("The token service name")
+ public String getName()
+ {
+ return name;
+ }
+
+ public abstract T getToken(K id);
+
+ public abstract T deleteToken(K id);
+
+ public abstract K[] getAllTokens();
+
+ /**
+ * Decode a key from its string representation.
+ *
+ * @param stringKey the key a s a string
+ * @return the typed key
+ */
+ protected abstract K decodeKey(String stringKey);
+
+ // We don't make it a property as retrieving the value can be an expensive operation
+ @Managed
+ @ManagedDescription("The number of tokens")
+ @Impact(ImpactType.READ)
+ public abstract long size() throws Exception;
+
+ private enum TimeoutEnum {
+ SECOND(1000), MINUTE(1000 * 60), HOUR(1000 * 60 * 60), DAY(1000 * 60 * 60 * 24);
+
+ private long multiply;
+
+ private TimeoutEnum(long multiply)
+ {
+ this.multiply = multiply;
+ }
+
+ public long toMilisecond(long configValue)
+ {
+ return configValue * multiply;
+ }
+ }
+
+ protected String nextTokenId()
+ {
+ return InitiateLoginServlet.COOKIE_NAME + random.nextInt();
+ }
+}
Added: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/CookieTokenService.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/CookieTokenService.java (rev 0)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/CookieTokenService.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,177 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.security.security;
+
+import org.chromattic.api.ChromatticSession;
+import org.exoplatform.commons.chromattic.ChromatticLifeCycle;
+import org.exoplatform.commons.chromattic.ChromatticManager;
+import org.exoplatform.commons.chromattic.ContextualTask;
+import org.exoplatform.commons.chromattic.SessionContext;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.web.security.Credentials;
+import org.exoplatform.web.security.GateInToken;
+
+import java.util.Collection;
+import java.util.Date;
+
+/**
+ * Created by The eXo Platform SAS Author : liem.nguyen ncliam(a)gmail.com Jun 5,
+ * 2009
+ */
+public class CookieTokenService extends AbstractTokenService<GateInToken, String>
+{
+
+ /** . */
+ public static final String LIFECYCLE_NAME="lifecycle-name";
+
+ /** . */
+ private ChromatticLifeCycle chromatticLifeCycle;
+
+ /** . */
+ private String lifecycleName="autologin";
+
+ public CookieTokenService(InitParams initParams, ChromatticManager chromatticManager)
+ {
+ super(initParams);
+
+ if (initParams.getValuesParam(SERVICE_CONFIG).getValues().size() > 3)
+ {
+ lifecycleName = (String)initParams.getValuesParam(SERVICE_CONFIG).getValues().get(3);
+ }
+ this.chromatticLifeCycle = chromatticManager.getLifeCycle(lifecycleName);
+ }
+
+ public String createToken(final Credentials credentials)
+ {
+ if (validityMillis < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (credentials == null)
+ {
+ throw new NullPointerException();
+ }
+ return new TokenTask<String>() {
+ @Override
+ protected String execute()
+ {
+ String tokenId = nextTokenId();
+ long expirationTimeMillis = System.currentTimeMillis() + validityMillis;
+ GateInToken token = new GateInToken(expirationTimeMillis, credentials);
+ TokenContainer container = getTokenContainer();
+ container.saveToken(tokenId, token.getPayload(), new Date(token.getExpirationTimeMillis()));
+ return tokenId;
+ }
+ }.executeWith(chromatticLifeCycle);
+ }
+
+ @Override
+ public GateInToken getToken(final String id)
+ {
+ return new TokenTask<GateInToken>() {
+ @Override
+ protected GateInToken execute()
+ {
+ return getTokenContainer().getToken((String)id);
+ }
+ }.executeWith(chromatticLifeCycle);
+ }
+
+ @Override
+ public GateInToken deleteToken(final String id)
+ {
+ return new TokenTask<GateInToken>() {
+ @Override
+ protected GateInToken execute()
+ {
+ return getTokenContainer().removeToken((String)id);
+ }
+ }.executeWith(chromatticLifeCycle);
+ }
+
+ @Override
+ public String[] getAllTokens()
+ {
+ return new TokenTask<String[]>() {
+ @Override
+ protected String[] execute()
+ {
+ TokenContainer container = getTokenContainer();
+ Collection<TokenEntry> tokens = container.getAllTokens();
+ String[] ids = new String[tokens.size()];
+ int count = 0;
+ for (TokenEntry token : tokens)
+ {
+ ids[count++] = token.getId();
+ }
+ return ids;
+ }
+ }.executeWith(chromatticLifeCycle);
+ }
+
+ @Override
+ public long size() throws Exception
+ {
+ return new TokenTask<Long>() {
+ @Override
+ protected Long execute()
+ {
+ TokenContainer container = getTokenContainer();
+ Collection<TokenEntry> tokens = container.getAllTokens();
+ return (long)tokens.size();
+ }
+ }.executeWith(chromatticLifeCycle);
+ }
+
+ @Override
+ protected String decodeKey(String stringKey)
+ {
+ return stringKey;
+ }
+
+ /**
+ * Wraps token store logic conveniently.
+ *
+ * @param <V> the return type
+ */
+ private abstract class TokenTask<V> extends ContextualTask<V>
+ {
+
+ protected final TokenContainer getTokenContainer() {
+ SessionContext ctx = chromatticLifeCycle.getContext();
+ ChromatticSession session = ctx.getSession();
+ TokenContainer container = session.findByPath(TokenContainer.class, lifecycleName);
+ if (container == null)
+ {
+ container = session.insert(TokenContainer.class, lifecycleName);
+ }
+ return container;
+ }
+
+ @Override
+ protected V execute(SessionContext context)
+ {
+ return execute();
+ }
+
+ protected abstract V execute();
+
+ }
+}
Added: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/RemindPasswordTokenService.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/RemindPasswordTokenService.java (rev 0)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/RemindPasswordTokenService.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2010, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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.security.security;
+
+import org.exoplatform.commons.chromattic.ChromatticManager;
+import org.exoplatform.container.xml.InitParams;
+
+/**
+ * @author <a href="mailto:theute@redhat.com">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class RemindPasswordTokenService extends CookieTokenService {
+
+ public RemindPasswordTokenService(InitParams initParams,
+ ChromatticManager chromatticManager)
+ {
+ super(initParams, chromatticManager);
+ }
+
+ @Override
+ protected String nextTokenId()
+ {
+ return "" + random.nextInt();
+ }
+}
Added: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/TokenContainer.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/TokenContainer.java (rev 0)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/TokenContainer.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,88 @@
+/*
+ * 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.
+ */
+package org.exoplatform.web.security.security;
+
+import org.chromattic.api.annotations.Create;
+import org.chromattic.api.annotations.PrimaryType;
+import org.chromattic.api.annotations.OneToMany;
+import org.exoplatform.web.security.Credentials;
+import org.exoplatform.web.security.GateInToken;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+@PrimaryType(name = "tkn:tokencontainer")
+public abstract class TokenContainer
+{
+
+ @Create
+ protected abstract TokenEntry createToken();
+
+ @OneToMany
+ protected abstract Map<String, TokenEntry> getTokens();
+
+ public Collection<TokenEntry> getAllTokens()
+ {
+ return getTokens().values();
+ }
+
+ public GateInToken getToken(String tokenId)
+ {
+ Map<String, TokenEntry> tokens = getTokens();
+ TokenEntry entry = tokens.get(tokenId);
+ return entry != null ? entry.getToken() : null;
+ }
+
+ public GateInToken removeToken(String tokenId)
+ {
+ Map<String, TokenEntry> tokens = getTokens();
+ TokenEntry entry = tokens.get(tokenId);
+ if (entry != null)
+ {
+ GateInToken token = entry.getToken();
+ entry.remove();
+ return token;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public GateInToken saveToken(String tokenId, Credentials credentials, Date expirationTime)
+ {
+ Map<String, TokenEntry> tokens = getTokens();
+ TokenEntry entry = tokens.get(tokenId);
+ if (entry == null)
+ {
+ entry = createToken();
+ tokens.put(tokenId, entry);
+ entry.setUserName(credentials.getUsername());
+ entry.setPassword(credentials.getPassword());
+ }
+ entry.setExpirationTime(expirationTime);
+ return entry.getToken();
+ }
+
+}
Added: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/TokenEntry.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/TokenEntry.java (rev 0)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/TokenEntry.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+package org.exoplatform.web.security.security;
+
+import org.chromattic.api.annotations.Destroy;
+import org.chromattic.api.annotations.Name;
+import org.chromattic.api.annotations.PrimaryType;
+import org.chromattic.api.annotations.Property;
+import org.exoplatform.web.security.Credentials;
+import org.exoplatform.web.security.GateInToken;
+
+import java.util.Date;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+@PrimaryType(name = "tkn:tokenentry")
+public abstract class TokenEntry
+{
+
+ @Name
+ public abstract String getId();
+
+ @Property(name = "username")
+ public abstract String getUserName();
+
+ public abstract void setUserName(String userName);
+
+ @Property(name = "password")
+ public abstract String getPassword();
+
+ public abstract void setPassword(String password);
+
+ @Property(name = "expiration")
+ public abstract Date getExpirationTime();
+
+ public abstract void setExpirationTime(Date expirationTime);
+
+ @Destroy
+ public abstract void remove();
+
+ public GateInToken getToken()
+ {
+ return new GateInToken(
+ getExpirationTime().getTime(),
+ new Credentials(getUserName(), getPassword()));
+ }
+
+}
Added: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/TransientTokenService.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/TransientTokenService.java (rev 0)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/TransientTokenService.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,89 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.security.security;
+
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.web.security.Credentials;
+import org.exoplatform.web.security.GateInToken;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Created by The eXo Platform SAS Author : liem.nguyen ncliam(a)gmail.com Jun 5,
+ * 2009
+ */
+public class TransientTokenService extends AbstractTokenService<GateInToken, String>
+{
+
+ protected final ConcurrentHashMap<String, GateInToken> tokens = new ConcurrentHashMap<String, GateInToken>();
+
+ public TransientTokenService(InitParams initParams)
+ {
+ super(initParams);
+ }
+
+ public String createToken(Credentials credentials)
+ {
+ if (validityMillis < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (credentials == null)
+ {
+ throw new NullPointerException();
+ }
+ String tokenId = nextTokenId();
+ long expirationTimeMillis = System.currentTimeMillis() + validityMillis;
+ tokens.put(tokenId, new GateInToken(expirationTimeMillis, credentials));
+ return tokenId;
+ }
+
+ @Override
+ public GateInToken getToken(String id)
+ {
+ return tokens.get(id);
+ }
+
+ @Override
+ protected String decodeKey(String stringKey)
+ {
+ return stringKey;
+ }
+
+ @Override
+ public GateInToken deleteToken(String id)
+ {
+ GateInToken token = tokens.get(id);
+ tokens.remove(id);
+ return token;
+ }
+
+ @Override
+ public String[] getAllTokens()
+ {
+ return tokens.keySet().toArray(new String[]{});
+ }
+
+ @Override
+ public long size() throws Exception
+ {
+ return tokens.size();
+ }
+}
Added: portal/trunk/component/web/server/pom.xml
===================================================================
--- portal/trunk/component/web/server/pom.xml (rev 0)
+++ portal/trunk/component/web/server/pom.xml 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,54 @@
+<!--
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web</artifactId>
+ <version>3.2.0-Beta01-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>exo.portal.component.web.server</artifactId>
+ <packaging>jar</packaging>
+ <name>GateIn Portal Component Web Server</name>
+
+ <properties>
+ <maven.test.skip>true</maven.test.skip>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.container</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web.controller</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.captcha</groupId>
+ <artifactId>simplecaptcha</artifactId>
+ </dependency>
+ </dependencies>
+</project>
Copied: portal/trunk/component/web/server/src/main/java/org/exoplatform/download (from rev 3698, portal/trunk/component/web/src/main/java/org/exoplatform/download)
Copied: portal/trunk/component/web/server/src/main/java/org/exoplatform/services (from rev 3698, portal/trunk/component/web/src/main/java/org/exoplatform/services)
Copied: portal/trunk/component/web/server/src/main/java/org/exoplatform/upload (from rev 3698, portal/trunk/component/web/src/main/java/org/exoplatform/upload)
Added: portal/trunk/component/web/server/src/main/java/org/exoplatform/web/handler/DownloadHandler.java
===================================================================
--- portal/trunk/component/web/server/src/main/java/org/exoplatform/web/handler/DownloadHandler.java (rev 0)
+++ portal/trunk/component/web/server/src/main/java/org/exoplatform/web/handler/DownloadHandler.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,109 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.handler;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.download.DownloadResource;
+import org.exoplatform.download.DownloadService;
+import org.exoplatform.web.WebAppController;
+import org.exoplatform.web.command.Command;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URLEncoder;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Created by The eXo Platform SARL
+ * Author : LeBienThuy
+ * thuy.le(a)exoplatform.com
+ * Dec 9, 2006
+ */
+public class DownloadHandler extends Command
+{
+
+ private String resourceId;
+
+ @SuppressWarnings("unused")
+ public void execute(WebAppController controller, HttpServletRequest req, HttpServletResponse res) throws Exception
+ {
+ res.setHeader("Cache-Control", "private max-age=600, s-maxage=120");
+ ExoContainer container = ExoContainerContext.getCurrentContainer();
+ DownloadService dservice = (DownloadService)container.getComponentInstanceOfType(DownloadService.class);
+ DownloadResource dresource = dservice.getDownloadResource(resourceId);
+ if (dresource == null)
+ {
+ res.setContentType("text/plain");
+ res.getWriter().write("NO DOWNDLOAD RESOURCE CONTENT OR YOU DO NOT HAVE THE RIGHT TO ACCESS THE CONTENT");
+ return;
+ }
+ String userAgent = req.getHeader("User-Agent");
+ if (dresource.getDownloadName() != null)
+ {
+ if (userAgent != null && userAgent.contains("MSIE"))
+ {
+ res.setHeader("Content-Disposition", "attachment;filename=\""
+ + URLEncoder.encode(dresource.getDownloadName(), "UTF-8") + "\"");
+ }
+ else
+ {
+ res.setHeader("Content-Disposition", "attachment; filename*=utf-8''"
+ + URLEncoder.encode(dresource.getDownloadName(), "UTF-8") + "");
+ }
+ }
+ res.setContentType(dresource.getResourceMimeType());
+ InputStream is = dresource.getInputStream();
+ try
+ {
+ optimalRead(is, res.getOutputStream());
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ finally
+ {
+ is.close();
+ }
+ }
+
+ public String getResourceId()
+ {
+ return resourceId;
+ }
+
+ private static void optimalRead(InputStream is, OutputStream os) throws Exception
+ {
+ int bufferLength = 1024; //TODO: Better to compute bufferLength in term of -Xms, -Xmx properties
+ int readLength = 0;
+ while (readLength > -1)
+ {
+ byte[] chunk = new byte[bufferLength];
+ readLength = is.read(chunk);
+ if (readLength > 0)
+ {
+ os.write(chunk, 0, readLength);
+ }
+ }
+ }
+}
\ No newline at end of file
Added: portal/trunk/component/web/server/src/main/java/org/exoplatform/web/handler/UploadHandler.java
===================================================================
--- portal/trunk/component/web/server/src/main/java/org/exoplatform/web/handler/UploadHandler.java (rev 0)
+++ portal/trunk/component/web/server/src/main/java/org/exoplatform/web/handler/UploadHandler.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -0,0 +1,138 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.handler;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.upload.UploadResource;
+import org.exoplatform.upload.UploadService;
+import org.exoplatform.web.WebAppController;
+import org.exoplatform.web.command.Command;
+
+import java.io.Writer;
+import java.net.URLEncoder;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Created by The eXo Platform SARL
+ * Author : Nhu Dinh Thuan
+ * nhudinhthuan(a)exoplatform.com
+ * Dec 9, 2006
+ */
+public class UploadHandler extends Command
+{
+
+ static enum UploadServiceAction {
+ PROGRESS, UPLOAD, DELETE, ABORT
+ }
+
+ private String action;
+
+ private String[] uploadId;
+
+ public void setAction(String action)
+ {
+ this.action = action;
+ }
+
+ public void setUploadId(String[] uploadId)
+ {
+ this.uploadId = uploadId;
+ }
+
+ @SuppressWarnings("unused")
+ public void execute(WebAppController controller, HttpServletRequest req, HttpServletResponse res) throws Exception
+ {
+ res.setHeader("Cache-Control", "no-cache");
+
+ ExoContainer container = ExoContainerContext.getCurrentContainer();
+ UploadService service = (UploadService)container.getComponentInstanceOfType(UploadService.class);
+ if (action == null || action.length() < 1)
+ return;
+
+ UploadServiceAction uploadActionService = UploadServiceAction.valueOf(action.toUpperCase());
+ if (uploadActionService == UploadServiceAction.PROGRESS)
+ {
+ Writer writer = res.getWriter();
+ if (uploadId == null)
+ return;
+ StringBuilder value = new StringBuilder();
+ value.append("{\n upload : {");
+ for (int i = 0; i < uploadId.length; i++)
+ {
+ UploadResource upResource = service.getUploadResource(uploadId[i]);
+ if (upResource == null)
+ continue;
+ if (upResource.getStatus() == UploadResource.FAILED_STATUS)
+ {
+ int limitMB = service.getUploadLimitsMB().get(uploadId[i]).intValue();
+ value.append("\n \"").append(uploadId[i]).append("\": {");
+ value.append("\n \"status\":").append('\"').append("failed").append("\",");
+ value.append("\n \"size\":").append('\"').append(limitMB).append("\"");
+ value.append("\n }");
+ continue;
+ }
+ double percent = 100;
+ if (upResource.getStatus() == UploadResource.UPLOADING_STATUS)
+ {
+ percent = (upResource.getUploadedSize() * 100) / upResource.getEstimatedSize();
+ }
+ value.append("\n \"").append(uploadId[i]).append("\": {");
+ value.append("\n \"percent\":").append('\"').append((int)percent).append("\",");
+ value.append("\n \"fileName\":").append('\"').append(encodeName(upResource.getFileName()))
+ .append("\"");
+ value.append("\n }");
+ if (i < uploadId.length - 1)
+ value.append(',');
+ }
+ value.append("\n }\n}");
+ writer.append(value);
+ }
+ else if (uploadActionService == UploadServiceAction.UPLOAD)
+ {
+ service.createUploadResource(req);
+ }
+ else if (uploadActionService == UploadServiceAction.DELETE)
+ {
+ service.removeUpload(uploadId[0]);
+ }
+ else if (uploadActionService == UploadServiceAction.ABORT)
+ {
+ //TODO: dang.tung - we don't need 2 statements because it'll show error when we reload browser
+ //UploadResource upResource = service.getUploadResource(uploadId[0]);
+ //if(upResource != null) upResource.setStatus(UploadResource.UPLOADED_STATUS) ;
+ service.removeUpload(uploadId[0]);
+ }
+ }
+
+ public String encodeName(String name) throws Exception
+ {
+ String[] arr = name.split(" ");
+ String str = "";
+ for (int i = 0; i < arr.length; i++)
+ {
+ str += " " + URLEncoder.encode(arr[i], "UTF-8");
+ }
+ return str;
+ }
+
+}
\ No newline at end of file
Modified: portal/trunk/examples/extension/ear/pom.xml
===================================================================
--- portal/trunk/examples/extension/ear/pom.xml 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/examples/extension/ear/pom.xml 2010-07-23 21:22:58 UTC (rev 3699)
@@ -46,7 +46,7 @@
</dependency>
<dependency>
<groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.web</artifactId>
+ <artifactId>exo.portal.component.web.api</artifactId>
<version>3.2.0-Beta01-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
Modified: portal/trunk/examples/extension/jar/pom.xml
===================================================================
--- portal/trunk/examples/extension/jar/pom.xml 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/examples/extension/jar/pom.xml 2010-07-23 21:22:58 UTC (rev 3699)
@@ -36,7 +36,7 @@
<dependencies>
<dependency>
<groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.web</artifactId>
+ <artifactId>exo.portal.component.web.api</artifactId>
</dependency>
</dependencies>
</project>
Modified: portal/trunk/examples/portal/ear/pom.xml
===================================================================
--- portal/trunk/examples/portal/ear/pom.xml 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/examples/portal/ear/pom.xml 2010-07-23 21:22:58 UTC (rev 3699)
@@ -46,7 +46,7 @@
</dependency>
<dependency>
<groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.web</artifactId>
+ <artifactId>exo.portal.component.web.api</artifactId>
<version>3.2.0-Beta01-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
Modified: portal/trunk/examples/portal/jar/pom.xml
===================================================================
--- portal/trunk/examples/portal/jar/pom.xml 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/examples/portal/jar/pom.xml 2010-07-23 21:22:58 UTC (rev 3699)
@@ -36,7 +36,7 @@
<dependencies>
<dependency>
<groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.web</artifactId>
+ <artifactId>exo.portal.component.web.api</artifactId>
</dependency>
</dependencies>
</project>
Modified: portal/trunk/gadgets/core/pom.xml
===================================================================
--- portal/trunk/gadgets/core/pom.xml 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/gadgets/core/pom.xml 2010-07-23 21:22:58 UTC (rev 3699)
@@ -62,20 +62,33 @@
</resources>
</build>
<dependencies>
- <dependency>
+ <dependency>
<groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.web</artifactId>
- <scope>provided</scope>
- </dependency>
+ <artifactId>exo.portal.component.common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web.controller</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web.security</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.container</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.shindig</groupId>
+ <artifactId>shindig-gadgets</artifactId>
+ </dependency>
<dependency>
<groupId>org.gatein.shindig</groupId>
<artifactId>shindig-common</artifactId>
- <type>jar</type>
</dependency>
<dependency>
<groupId>org.gatein.shindig</groupId>
<artifactId>shindig-features</artifactId>
- <type>jar</type>
</dependency>
<dependency>
<groupId>org.chromattic</groupId>
Modified: portal/trunk/gadgets/eXoGadgets/pom.xml
===================================================================
--- portal/trunk/gadgets/eXoGadgets/pom.xml 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/gadgets/eXoGadgets/pom.xml 2010-07-23 21:22:58 UTC (rev 3699)
@@ -38,7 +38,7 @@
<dependencies>
<dependency>
<groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.web</artifactId>
+ <artifactId>exo.portal.component.web.security</artifactId>
<scope>provided</scope>
</dependency>
Modified: portal/trunk/packaging/jboss-as/ear/pom.xml
===================================================================
--- portal/trunk/packaging/jboss-as/ear/pom.xml 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/packaging/jboss-as/ear/pom.xml 2010-07-23 21:22:58 UTC (rev 3699)
@@ -88,10 +88,22 @@
</dependency>
<dependency>
<groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.web</artifactId>
+ <artifactId>exo.portal.component.web.security</artifactId>
</dependency>
<dependency>
<groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web.controller</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web.server</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web.api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
<artifactId>exo.portal.component.portal</artifactId>
</dependency>
<dependency>
Modified: portal/trunk/packaging/module/src/main/javascript/portal.packaging.module.js
===================================================================
--- portal/trunk/packaging/module/src/main/javascript/portal.packaging.module.js 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/packaging/module/src/main/javascript/portal.packaging.module.js 2010-07-23 21:22:58 UTC (rev 3699)
@@ -97,10 +97,24 @@
module.component.management =
new Project("org.exoplatform.portal", "exo.portal.component.management", "jar", module.version);
- module.component.web =
- new Project("org.exoplatform.portal", "exo.portal.component.web", "jar", module.version).
+ module.component.web = {}
+ module.component.web.controller =
+ new Project("org.exoplatform.portal", "exo.portal.component.web.controller", "jar", module.version).
+ addDependency(module.component.common);
+
+ module.component.web.security =
+ new Project("org.exoplatform.portal", "exo.portal.component.web.security", "jar", module.version).
+ addDependency(module.component.web.controller).
addDependency(module.component.scripting);
+ module.component.web.server =
+ new Project("org.exoplatform.portal", "exo.portal.component.web.server", "jar", module.version).
+ addDependency(module.component.web.controller).
+ addDependency(module.component.scripting);
+
+ module.component.web.api =
+ new Project("org.exoplatform.portal", "exo.portal.component.web.api", "jar", module.version);
+
module.component.portal =
new Project("org.exoplatform.portal", "exo.portal.component.portal", "jar", module.version).
addDependency(new Project("org.gatein.mop", "mop-api", "jar", mopVersion)).
@@ -118,7 +132,7 @@
addDependency(new Project("org.reflext", "reflext.spi", "jar", reflectVersion)).
addDependency(new Project("org.reflext", "reflext.jlr", "jar", reflectVersion)).
addDependency(new Project("org.reflext", "reflext.api", "jar", reflectVersion)).
- addDependency(module.component.web);
+ addDependency(module.component.web.security);
module.component.identity =
new Project("org.exoplatform.portal", "exo.portal.component.identity", "jar", module.version).
@@ -138,7 +152,10 @@
module.webui = {};
module.webui.framework =
new Project("org.exoplatform.portal", "exo.portal.webui.framework", "jar", module.version).
- addDependency(module.component.web);
+ addDependency(module.component.web.server).
+ addDependency(module.component.web.security).
+ addDependency(module.component.web.api).
+ addDependency(module.component.web.controller);
module.webui.portlet =
new Project("org.exoplatform.portal", "exo.portal.webui.portlet", "jar", module.version).
Modified: portal/trunk/pom.xml
===================================================================
--- portal/trunk/pom.xml 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/pom.xml 2010-07-23 21:22:58 UTC (rev 3699)
@@ -371,6 +371,26 @@
</dependency>
<dependency>
<groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web.controller</artifactId>
+ <version>3.2.0-Beta01-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web.security</artifactId>
+ <version>3.2.0-Beta01-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web.server</artifactId>
+ <version>3.2.0-Beta01-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web.api</artifactId>
+ <version>3.2.0-Beta01-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
<artifactId>exo.portal.component.portal</artifactId>
<version>3.2.0-Beta01-SNAPSHOT</version>
</dependency>
Modified: portal/trunk/webui/core/pom.xml
===================================================================
--- portal/trunk/webui/core/pom.xml 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/webui/core/pom.xml 2010-07-23 21:22:58 UTC (rev 3699)
@@ -45,6 +45,14 @@
<artifactId>exo.portal.component.portal</artifactId>
</dependency>
<dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web.server</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web.api</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.gatein.common</groupId>
<artifactId>common-common</artifactId>
</dependency>
Modified: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/wysiwyg/FCKEditor.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/wysiwyg/FCKEditor.java 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/wysiwyg/FCKEditor.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -19,8 +19,6 @@
package org.exoplatform.webui.form.wysiwyg;
-import com.sun.syndication.io.impl.PropertiesLoader;
-
import org.exoplatform.web.resource.config.xml.FCKConfigListener;
import java.util.regex.Matcher;
Modified: portal/trunk/webui/framework/pom.xml
===================================================================
--- portal/trunk/webui/framework/pom.xml 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/webui/framework/pom.xml 2010-07-23 21:22:58 UTC (rev 3699)
@@ -34,8 +34,16 @@
<dependencies>
<dependency>
<groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.web</artifactId>
+ <artifactId>exo.portal.component.web.controller</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.resources</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.scripting</artifactId>
+ </dependency>
</dependencies>
<build>
Modified: portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponent.java
===================================================================
--- portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponent.java 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponent.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -35,7 +35,6 @@
import org.exoplatform.webui.event.EventListener;
import org.exoplatform.webui.event.MonitorEvent;
-import java.util.ArrayList;
import java.util.List;
/** Created by The eXo Platform SAS May 7, 2006 */
Modified: portal/trunk/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplication.java
===================================================================
--- portal/trunk/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplication.java 2010-07-23 11:14:58 UTC (rev 3698)
+++ portal/trunk/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplication.java 2010-07-23 21:22:58 UTC (rev 3699)
@@ -37,7 +37,6 @@
import org.exoplatform.webui.event.Event.Phase;
import java.io.IOException;
-import java.io.Writer;
import java.util.Locale;
import java.util.ResourceBundle;
14 years, 5 months
gatein SVN: r3698 - portal/trunk/testsuite/testdefinitions.
by do-not-reply@jboss.org
Author: hangnguyen
Date: 2010-07-23 07:14:58 -0400 (Fri, 23 Jul 2010)
New Revision: 3698
Modified:
portal/trunk/testsuite/testdefinitions/GateIn_v3.1.0_BasicPortlets_TestDefinition.ods
portal/trunk/testsuite/testdefinitions/GateIn_v3.1.0_MainFunctions_TestDefinition.ods
Log:
Update test case for GateIn_v3.1.0GA
Modified: portal/trunk/testsuite/testdefinitions/GateIn_v3.1.0_BasicPortlets_TestDefinition.ods
===================================================================
(Binary files differ)
Modified: portal/trunk/testsuite/testdefinitions/GateIn_v3.1.0_MainFunctions_TestDefinition.ods
===================================================================
(Binary files differ)
14 years, 5 months
gatein SVN: r3697 - portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium.
by do-not-reply@jboss.org
Author: hangnguyen
Date: 2010-07-23 06:54:48 -0400 (Fri, 23 Jul 2010)
New Revision: 3697
Added:
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_03_07_005_CheckEditMembershipOfUserWhichRemvoedFromGroup.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_002_AddNewBlankNameCategory.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_003_AddNewCategoryWIthNameStartsWithNumber.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_004_AddNewCateogryWithNameStartsWithDashChars.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_005_AddNewCategoryWithNameContainsAlphaDigitUnderscoreAndDashInTheMiddle.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_006_AddNewCategoryWithSpecialCharsInName.html
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_008_AddCategoryWithNameTheSameWithExistingButDifferentByUpperLowerCase.html
Log:
TESTVN-1006: Create new GateIn Selenium
Added: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_03_07_005_CheckEditMembershipOfUserWhichRemvoedFromGroup.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_03_07_005_CheckEditMembershipOfUserWhichRemvoedFromGroup.html (rev 0)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_03_07_005_CheckEditMembershipOfUserWhichRemvoedFromGroup.html 2010-07-23 10:54:48 UTC (rev 3697)
@@ -0,0 +1,187 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>Test_PRL_03_07_005_CheckEditMembershipOfUserWhichRemvoedFromGroup</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">Test_PRL_03_07_005_CheckEditMembershipOfUserWhichRemvoedFromGroup</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/portal/public/classic/</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Check edit membership of user which removed from group--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>windowMaximize</td>
+ <td></td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Sign in</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>username</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>username</td>
+ <td>root</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>password</td>
+ <td>gtn</td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>//div[@id='UIPortalLoginFormAction']/div/div/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Go to Users and group management --</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>link=Users and groups management</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Choose Group Management --</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIOrganizationPortlet']/div[2]/div[1]/div/div/div/div/div/div/a[2]/div[1]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIOrganizationPortlet']/div[2]/div[1]/div/div/div/div/div/div/a[2]/div[1]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Add user into group --</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Customers</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Customers</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>username</td>
+ <td>root</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>username</td>
+ <td>root</td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>membership</td>
+ <td></td>
+</tr>
+<tr>
+ <td>select</td>
+ <td>membership</td>
+ <td>label=manager</td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//form[@id='UIGroupMembershipForm']/div[2]/div/div/table/tbody/tr/td/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//form[@id='UIGroupMembershipForm']/div[2]/div/div/table/tbody/tr/td/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//img[@alt='Edit']</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//img[@alt='Edit']</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//img[@alt='DeleteUser']</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//img[@alt='DeleteUser']</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertConfirmation</td>
+ <td>Are you sure you want to delete user root from group customers?</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Save</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Save</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForTextPresent</td>
+ <td>Can't save, membership removed!. </td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyTextPresent</td>
+ <td>Can't save, membership removed!. </td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[2]/div[2]/div/div[2]/div/div/div/div/div/div[3]/div/table/tbody/tr/td/div/div/div/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[2]/div[2]/div/div[2]/div/div/div/div/div/div[3]/div/table/tbody/tr/td/div/div/div/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>link=Sign out</td>
+ <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
Added: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_002_AddNewBlankNameCategory.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_002_AddNewBlankNameCategory.html (rev 0)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_002_AddNewBlankNameCategory.html 2010-07-23 10:54:48 UTC (rev 3697)
@@ -0,0 +1,187 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>Test_PRL_05_01_002_AddNewBlankNameCategory</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">Test_PRL_05_01_002_AddNewBlankNameCategory</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/portal/public/classic/</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Add new blank name category--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>windowMaximize</td>
+ <td></td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Sign in</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>username</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>username</td>
+ <td>root</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>password</td>
+ <td>gtn</td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>//div[@id='UIPortalLoginFormAction']/div/div/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Go to Application Registry--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>link=Application Registry</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Click Add application icon--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[1]/div[1]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[1]/div[1]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>displayName</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>displayName</td>
+ <td>Test_PRL_05_01_002</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>description</td>
+ <td>Test_PRL_05_01_002</td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Choose Permission Setting tab--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[2]/div/div/div/div/div/div/div/div/div/div[2]/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[2]/div/div/div/div/div/div/div/div/div/div[2]/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Add Permission</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Add Permission</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='ListPermissionSelector']/div/div[2]/div/div[2]/div/div/div[3]/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='ListPermissionSelector']/div/div[2]/div/div[2]/div/div/div[3]/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=exact:*</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=exact:*</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Save</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Save</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForTextPresent</td>
+ <td>The field "Category name: " is required. </td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyTextPresent</td>
+ <td>The field "Category name: " is required. </td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[2]/div[2]/div/div[2]/div/div/div/div/div/div[3]/div/table/tbody/tr/td/div/div/div/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[2]/div[2]/div/div[2]/div/div/div/div/div/div[3]/div/table/tbody/tr/td/div/div/div/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Cancel</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Cancel</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>link=Sign out</td>
+ <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
Added: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_003_AddNewCategoryWIthNameStartsWithNumber.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_003_AddNewCategoryWIthNameStartsWithNumber.html (rev 0)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_003_AddNewCategoryWIthNameStartsWithNumber.html 2010-07-23 10:54:48 UTC (rev 3697)
@@ -0,0 +1,192 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>Test_PRL_05_01_004_AddNewCategoryWIthNameStartsWithNumber</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">Test_PRL_05_01_004_AddNewCategoryWIthNameStartsWithNumber</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/portal/public/classic/</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Add new category with name starts with number--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>windowMaximize</td>
+ <td></td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Sign in</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>username</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>username</td>
+ <td>root</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>password</td>
+ <td>gtn</td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>//div[@id='UIPortalLoginFormAction']/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Go to Application Registry--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>link=Application Registry</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Click Add Category icon--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[1]/div[1]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[1]/div[1]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>name</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>name</td>
+ <td>05_01_003</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>displayName</td>
+ <td>Test_PRL_05_01_003</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>description</td>
+ <td>Test_PRL_05_01_003</td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Choose Permission Setting tab--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[2]/div/div/div/div/div/div/div/div/div/div[2]/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[2]/div/div/div/div/div/div/div/div/div/div[2]/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIListPermissionSelector']/div[4]/table/tbody/tr/td/div/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIListPermissionSelector']/div[4]/table/tbody/tr/td/div/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Customers</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Customers</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=manager</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=manager</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Save</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Save</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForTextPresent</td>
+ <td>The "Category name: " field must start with a character and must not contain special characters." </td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyTextPresent</td>
+ <td>The "Category name: " field must start with a character and must not contain special characters." </td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[2]/div[2]/div/div[2]/div/div/div/div/div/div[3]/div/table/tbody/tr/td/div/div/div/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[2]/div[2]/div/div[2]/div/div/div/div/div/div[3]/div/table/tbody/tr/td/div/div/div/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//form[@id='UICategoryForm']/div[3]/div[2]/table/tbody/tr/td/div[2]/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//form[@id='UICategoryForm']/div[3]/div[2]/table/tbody/tr/td/div[2]/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>link=Sign out</td>
+ <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
Added: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_004_AddNewCateogryWithNameStartsWithDashChars.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_004_AddNewCateogryWithNameStartsWithDashChars.html (rev 0)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_004_AddNewCateogryWithNameStartsWithDashChars.html 2010-07-23 10:54:48 UTC (rev 3697)
@@ -0,0 +1,197 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>Test_PRL_05_01_004_AddNewCateogryWithNameStartsWithDashChars</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">Test_PRL_05_01_004_AddNewCateogryWithNameStartsWithDashChars</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/portal/public/classic/</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Add new category with name starts with dash characters--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>windowMaximize</td>
+ <td></td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Sign in</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>username</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>username</td>
+ <td>root</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>password</td>
+ <td>gtn</td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>//div[@id='UIPortalLoginFormAction']/div/div/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Go to Application Registry--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>link=Application Registry</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Click Add Category icon--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[1]/div[1]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[1]/div[1]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>name</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>name</td>
+ <td>------</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>displayName</td>
+ <td>Test_PRL_0</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>displayName</td>
+ <td>Test_PRL_05_01_004</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>description</td>
+ <td>Test_PRL_05_01_004</td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Choose Permission Setting tab--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[2]/div/div/div/div/div/div/div/div/div/div[2]/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[2]/div/div/div/div/div/div/div/div/div/div[2]/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Add Permission</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Add Permission</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='ListPermissionSelector']/div/div[2]/div/div[2]/div/div/div[3]/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='ListPermissionSelector']/div/div[2]/div/div[2]/div/div/div[3]/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=manager</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=manager</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Save</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Save</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForTextPresent</td>
+ <td>The "Category name: " field must start with a character and must not contain special characters." </td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyTextPresent</td>
+ <td>The "Category name: " field must start with a character and must not contain special characters." </td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[2]/div[2]/div/div[2]/div/div/div/div/div/div[3]/div/table/tbody/tr/td/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[2]/div[2]/div/div[2]/div/div/div/div/div/div[3]/div/table/tbody/tr/td/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Cancel</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Cancel</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>link=Sign out</td>
+ <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
Added: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_005_AddNewCategoryWithNameContainsAlphaDigitUnderscoreAndDashInTheMiddle.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_005_AddNewCategoryWithNameContainsAlphaDigitUnderscoreAndDashInTheMiddle.html (rev 0)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_005_AddNewCategoryWithNameContainsAlphaDigitUnderscoreAndDashInTheMiddle.html 2010-07-23 10:54:48 UTC (rev 3697)
@@ -0,0 +1,247 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>Test_PRL_05_01_005_AddNewCategoryWithNameContainsAlphaDigitUnderscoreAndDashInTheMiddle</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">Test_PRL_05_01_005_AddNewCategoryWithNameContainsAlphaDigitUnderscoreAndDashInTheMiddle</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/portal/public/classic/</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Add new category with name contains alpha, digit, underscore and dash in the middle--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>windowMaximize</td>
+ <td></td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Sign in</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>username</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>username</td>
+ <td>root</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>password</td>
+ <td>gtn</td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>//div[@id='UIPortalLoginFormAction']/div/div/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Go to Application Registry--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>link=Application Registry</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Click Add category icon--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[1]/div[1]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[1]/div[1]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>name</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>name</td>
+ <td>Test_PRL_05_01_005</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>displayName</td>
+ <td>Test_PRL_05_01_005</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>description</td>
+ <td>Test_PRL_05_01_005</td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Choose Permission Setting tab --</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[2]/div/div/div/div/div/div/div/div/div/div[2]/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[2]/div/div/div/div/div/div/div/div/div/div[2]/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Add Permission</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Add Permission</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='ListPermissionSelector']/div/div[2]/div/div[2]/div/div/div[3]/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='ListPermissionSelector']/div/div[2]/div/div[2]/div/div/div[3]/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=manager</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=manager</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Save</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Save</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Add application into category--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[1]/div/div/div[2]/div/div[4]/div[1]/div/div/div/a[3]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[1]/div/div/div[2]/div/div[4]/div[1]/div/div/div/a[3]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>type</td>
+ <td>label=Gadget</td>
+</tr>
+<tr>
+ <td>select</td>
+ <td>type</td>
+ <td>label=Gadget</td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//option[@value='gadget']</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//option[@value='gadget']</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//input[@name='application' and @value='1']</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//input[@name='application' and @value='1']</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Add</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Add</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForTextPresent</td>
+ <td>Calendar</td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyTextPresent</td>
+ <td>Calendar</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Delete category --</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[1]/div/div/div[2]/div/div[4]/div[1]/div/div/div/a[2]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[1]/div/div/div[2]/div/div[4]/div[1]/div/div/div/a[2]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertConfirmation</td>
+ <td>Are you sure to delete this category and all applications on it?</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>link=Sign out</td>
+ <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
Added: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_006_AddNewCategoryWithSpecialCharsInName.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_006_AddNewCategoryWithSpecialCharsInName.html (rev 0)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_006_AddNewCategoryWithSpecialCharsInName.html 2010-07-23 10:54:48 UTC (rev 3697)
@@ -0,0 +1,192 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>Test_PRL_05_01_006_AddNewCategoryWithSpecialCharsInName</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">Test_PRL_05_01_006_AddNewCategoryWithSpecialCharsInName</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/portal/public/classic/</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Add new category with special characters in name--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>windowMaximize</td>
+ <td></td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Sign in</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>username</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>username</td>
+ <td>root</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>password</td>
+ <td>gtn</td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>//div[@id='UIPortalLoginFormAction']/div/div/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Go to Application Registry --</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>link=Application Registry</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Click Add Category icon--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[1]/div[1]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[1]/div[1]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>name</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>name</td>
+ <td>@$@%@^</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>displayName</td>
+ <td>Test_PRL_05_01_006</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>description</td>
+ <td>Test_PRL_05_01_006</td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Choose Permission Setting --</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[2]/div/div/div/div/div/div/div/div/div/div[2]/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[2]/div/div/div/div/div/div/div/div/div/div[2]/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIListPermissionSelector']/div[4]/table/tbody/tr/td/div/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIListPermissionSelector']/div[4]/table/tbody/tr/td/div/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Partners</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Partners</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=exact:*</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=exact:*</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Save</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Save</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForTextPresent</td>
+ <td>Only alpha, digit, dash and underscore characters allowed for the field "Category name: ". </td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyTextPresent</td>
+ <td>Only alpha, digit, dash and underscore characters allowed for the field "Category name: ". </td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[2]/div[2]/div/div[2]/div/div/div/div/div/div[3]/div/table/tbody/tr/td/div/div/div/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[2]/div[2]/div/div[2]/div/div/div/div/div/div[3]/div/table/tbody/tr/td/div/div/div/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Cancel</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Cancel</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>link=Sign out</td>
+ <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
Added: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_008_AddCategoryWithNameTheSameWithExistingButDifferentByUpperLowerCase.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_008_AddCategoryWithNameTheSameWithExistingButDifferentByUpperLowerCase.html (rev 0)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/Test_PRL_05_01_008_AddCategoryWithNameTheSameWithExistingButDifferentByUpperLowerCase.html 2010-07-23 10:54:48 UTC (rev 3697)
@@ -0,0 +1,447 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>Test_PRL_05_01_008_AddCategoryWithNameTheSameWithExistingButDifferentByUpperLowerCase</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">Test_PRL_05_01_008_AddCategoryWithNameTheSameWithExistingButDifferentByUpperLowerCase</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/portal/public/classic/</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Add new category with category name the same with existing but different by lower/upper case--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>windowMaximize</td>
+ <td></td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Sign in</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>username</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>username</td>
+ <td>root</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>password</td>
+ <td>gtn</td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>//div[@id='UIPortalLoginFormAction']/div/div/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Go to Application Registry--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>link=Application Registry</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Click Add Category icon--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[1]/div[1]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[1]/div[1]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Add name with lower case --</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>name</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>name</td>
+ <td>test_prl_05_01_008</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>displayName</td>
+ <td>test_prl_05_01_008</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>description</td>
+ <td>test_prl_05_01_008</td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Choose Permission Setting --</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[2]/div/div/div/div/div/div/div/div/div/div[2]/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[2]/div/div/div/div/div/div/div/div/div/div[2]/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Add Permission</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Add Permission</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Customers</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Customers</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=exact:*</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=exact:*</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Save</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Save</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForTextPresent</td>
+ <td>test_prl_05_01_008</td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyTextPresent</td>
+ <td>test_prl_05_01_008</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Add application into category--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[1]/div/div/div[2]/div/div[4]/div[1]/div/div/div/a[3]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[1]/div/div/div[2]/div/div[4]/div[1]/div/div/div/a[3]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//input[@name='application' and @value='2']</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//input[@name='application' and @value='2']</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Add</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Add</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForTextPresent</td>
+ <td>Application Registry</td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyTextPresent</td>
+ <td>Application Registry</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Add category with name is upper case--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[1]/div[1]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[1]/div[1]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>name</td>
+ <td>Test_PRL_05_01_008</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>name</td>
+ <td>Test_PRL_05_01_008</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>displayName</td>
+ <td>Test_PRL_05_01_008</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>description</td>
+ <td>Test_PRL_05_01_008</td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Choose Permision Setting --</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[2]/div/div/div/div/div/div/div/div/div/div[2]/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[2]/div/div/div/div/div/div/div/div/div/div[2]/div/div/div/div</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Add Permission</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Add Permission</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='ListPermissionSelector']/div/div[2]/div/div[2]/div/div/div[3]/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='ListPermissionSelector']/div/div[2]/div/div[2]/div/div/div[3]/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=manager</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=manager</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Save</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Save</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForTextPresent</td>
+ <td>Test_PRL_05_01_008</td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyTextPresent</td>
+ <td>Test_PRL_05_01_008</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Choose Permission Setting --</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[1]/div/div/div[2]/div/div[5]/div[1]/div/div/div/a[3]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[1]/div/div/div[2]/div/div[5]/div[1]/div/div/div/a[3]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>type</td>
+ <td></td>
+</tr>
+<tr>
+ <td>select</td>
+ <td>type</td>
+ <td>label=Gadget</td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//option[@value='gadget']</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//option[@value='gadget']</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//input[@name='application' and @value='4']</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//input[@name='application' and @value='4']</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Add</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Add</td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyTextPresent</td>
+ <td>Todo</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForTextPresent</td>
+ <td>Todo</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Delete category is lower case--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=test_prl_05_01_008</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=test_prl_05_01_008</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[1]/div/div/div[2]/div/div[4]/div[1]/div/div/div/a[2]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[@id='UIApplicationOrganizer']/div[2]/div[1]/div/div/div[2]/div/div[4]/div[1]/div/div/div/a[2]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertConfirmation</td>
+ <td>Are you sure to delete this category and all applications on it?</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Delete category is upper case--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Test_PRL_05_01_008</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Test_PRL_05_01_008</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[4]/div[1]/div/div/div/a[2]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>//div[4]/div[1]/div/div/div/a[2]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertConfirmation</td>
+ <td>Are you sure to delete this category and all applications on it?</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>link=Sign out</td>
+ <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
14 years, 5 months
gatein SVN: r3696 - portal/trunk/web/portal/src/main/webapp/groovy/webui/core.
by do-not-reply@jboss.org
Author: ndkhoiits
Date: 2010-07-23 05:52:53 -0400 (Fri, 23 Jul 2010)
New Revision: 3696
Modified:
portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIGrid.gtmpl
Log:
GTNPORTAL-1373 Define dateFormat property in UIGrid
Modified: portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIGrid.gtmpl
===================================================================
--- portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIGrid.gtmpl 2010-07-23 09:39:18 UTC (rev 3695)
+++ portal/trunk/web/portal/src/main/webapp/groovy/webui/core/UIGrid.gtmpl 2010-07-23 09:52:53 UTC (rev 3696)
@@ -72,7 +72,7 @@
def fieldClass = fieldValue.getClass();
if(fieldClass == Integer.class) cssClass = "number";
else if(java.util.Date.class.isAssignableFrom(fieldClass)) {
- if(dateFormat == null) dateFormat = new SimpleDateFormat("HH:mm:ss yyyy-MM-dd");
+ def dateFormat = new SimpleDateFormat("HH:mm:ss yyyy-MM-dd");
cssClass = "Datetime";
fieldValue = dateFormat.format(fieldValue);
}
14 years, 5 months
gatein SVN: r3695 - in portal/trunk: portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component and 1 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-07-23 05:39:18 -0400 (Fri, 23 Jul 2010)
New Revision: 3695
Removed:
portal/trunk/component/web/src/main/java/org/exoplatform/web/application/gadget/
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetManagement.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/GadgetUtil.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ModelAdapter.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
Log:
remove useless GadgetApplication
Modified: portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetManagement.java
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetManagement.java 2010-07-23 09:17:09 UTC (rev 3694)
+++ portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIGadgetManagement.java 2010-07-23 09:39:18 UTC (rev 3695)
@@ -29,7 +29,6 @@
import org.exoplatform.applicationregistry.webui.Util;
import org.exoplatform.web.WebAppController;
import org.exoplatform.web.application.ApplicationMessage;
-import org.exoplatform.web.application.gadget.GadgetApplication;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.commons.serialization.api.annotations.Serialized;
import org.exoplatform.webui.config.annotation.ComponentConfig;
@@ -57,6 +56,8 @@
public class UIGadgetManagement extends UIContainer
{
+ public static final String EXO_GADGET_GROUP = "eXoGadgets";
+
private List<Gadget> gadgets_;
private Gadget selectedGadget_;
@@ -175,7 +176,7 @@
}
service.removeGadget(name);
WebAppController webController = uiManagement.getApplicationComponent(WebAppController.class);
- webController.removeApplication(GadgetApplication.EXO_GADGET_GROUP + "/" + name);
+ webController.removeApplication(EXO_GADGET_GROUP + "/" + name);
Gadget gadget = uiManagement.getGadget(name);
if (gadget.isLocal())
{
Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/GadgetUtil.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/GadgetUtil.java 2010-07-23 09:17:09 UTC (rev 3694)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/GadgetUtil.java 2010-07-23 09:39:18 UTC (rev 3695)
@@ -28,7 +28,6 @@
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.gadget.core.SecurityTokenGenerator;
import org.exoplatform.portal.webui.util.Util;
-import org.exoplatform.web.application.gadget.GadgetApplication;
import org.json.JSONException;
import org.json.JSONObject;
@@ -46,11 +45,6 @@
*/
public class GadgetUtil
{
- static public GadgetApplication toGadgetApplication(Gadget model)
- {
- return new GadgetApplication(model.getName(), model.getUrl(), model.isLocal());
- }
-
static public Gadget toGadget(String name, String path, boolean isLocal) throws Exception
{
Gadget gadget = new Gadget();
Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ModelAdapter.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ModelAdapter.java 2010-07-23 09:17:09 UTC (rev 3694)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ModelAdapter.java 2010-07-23 09:39:18 UTC (rev 3695)
@@ -34,7 +34,6 @@
import org.exoplatform.portal.pom.spi.portlet.Preference;
import org.exoplatform.portal.pom.spi.wsrp.WSRP;
import org.exoplatform.portal.pom.spi.wsrp.WSRPPortletStateType;
-import org.exoplatform.web.application.gadget.GadgetApplication;
import org.gatein.pc.api.PortletContext;
import org.gatein.pc.api.PortletInvoker;
import org.gatein.pc.api.StatefulPortletContext;
@@ -171,8 +170,7 @@
GadgetRegistryService gadgetService =
(GadgetRegistryService)container.getComponentInstanceOfType(GadgetRegistryService.class);
org.exoplatform.application.gadget.Gadget model = gadgetService.getGadget(applicationId);
- GadgetApplication application = new GadgetApplication(model.getName(), model.getUrl(), model.isLocal());
- String url = GadgetUtil.reproduceUrl(application.getUrl(), application.isLocal());
+ String url = GadgetUtil.reproduceUrl(model.getUrl(), model.isLocal());
ExoPortletState prefs = new ExoPortletState(WRAPPER_ID);
prefs.getState().put("url", Arrays.asList(url));
return StatefulPortletContext.create("local._dumbvalue", ExoPortletStateType.getInstance(), prefs);
Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2010-07-23 09:17:09 UTC (rev 3694)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2010-07-23 09:39:18 UTC (rev 3695)
@@ -28,9 +28,7 @@
import org.exoplatform.portal.config.model.Properties;
import org.exoplatform.portal.pom.data.ModelDataStorage;
import org.exoplatform.portal.webui.util.Util;
-import org.exoplatform.web.WebAppController;
import org.exoplatform.web.application.ApplicationMessage;
-import org.exoplatform.web.application.gadget.GadgetApplication;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.EventConfig;
@@ -260,29 +258,17 @@
* @return Gadget Application
* @throws Exception
*/
- private GadgetApplication getApplication()
+ private Gadget getApplication()
{
- WebAppController webController = getApplicationComponent(WebAppController.class);
- GadgetApplication application = webController.getApplication("eXoGadgets/" + gadgetId);
- if (application == null)
+ try
{
GadgetRegistryService gadgetService = getApplicationComponent(GadgetRegistryService.class);
- Gadget model;
- try
- {
- model = gadgetService.getGadget(gadgetId);
- }
- catch (Exception ex)
- {
- return null;
- }
- if (model != null)
- {
- application = GadgetUtil.toGadgetApplication(model);
- webController.addApplication(application);
- }
+ return gadgetService.getGadget(gadgetId);
}
- return application;
+ catch (Exception ex)
+ {
+ return null;
+ }
}
/**
@@ -295,8 +281,8 @@
{
if (url_ == null)
{
- GadgetApplication application = getApplication();
- url_ = GadgetUtil.reproduceUrl(application.getUrl(), application.isLocal());
+ Gadget gadget = getApplication();
+ url_ = GadgetUtil.reproduceUrl(gadget.getUrl(), gadget.isLocal());
}
return url_;
}
14 years, 5 months
gatein SVN: r3694 - in portal/trunk/component: resources/src/main/java/org/exoplatform/web and 4 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-07-23 05:17:09 -0400 (Fri, 23 Jul 2010)
New Revision: 3694
Added:
portal/trunk/component/resources/src/main/java/org/exoplatform/web/
portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/
portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/
portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JSMin.java
portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/Javascript.java
portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigParser.java
portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java
portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptDeployer.java
portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptKey.java
portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptRemoval.java
portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptTask.java
Removed:
portal/trunk/component/web/src/main/java/org/exoplatform/web/application/javascript/
portal/trunk/component/web/src/main/java/org/exoplatform/web/resource/config/xml/GateinResource.java
Log:
moving javascript service to component.module
Added: portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JSMin.java
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JSMin.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JSMin.java 2010-07-23 09:17:09 UTC (rev 3694)
@@ -0,0 +1,342 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.application.javascript;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PushbackInputStream;
+
+public class JSMin
+{
+ private static final int EOF = -1;
+
+ private PushbackInputStream in;
+
+ private OutputStream out;
+
+ private int theA;
+
+ private int theB;
+
+ public JSMin(InputStream in, OutputStream out)
+ {
+ this.in = new PushbackInputStream(in);
+ this.out = out;
+ }
+
+ /**
+ * isAlphanum -- return true if the character is a letter, digit, underscore,
+ * dollar sign, or non-ASCII character.
+ */
+ static boolean isAlphanum(int c)
+ {
+ return ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || c == '_' || c == '$'
+ || c == '\\' || c > 126);
+ }
+
+ /**
+ * get -- return the next character from stdin. Watch out for lookahead. If
+ * the character is a control character, translate it to a space or linefeed.
+ */
+ int get() throws IOException
+ {
+ int c = in.read();
+
+ if (c >= ' ' || c == '\n' || c == EOF)
+ {
+ return c;
+ }
+
+ if (c == '\r')
+ {
+ return '\n';
+ }
+
+ return ' ';
+ }
+
+ /**
+ * Get the next character without getting it.
+ */
+ int peek() throws IOException
+ {
+ int lookaheadChar = in.read();
+ in.unread(lookaheadChar);
+ return lookaheadChar;
+ }
+
+ /**
+ * next -- get the next character, excluding comments. peek() is used to see
+ * if a '/' is followed by a '/' or '*'.
+ */
+ int next() throws IOException, UnterminatedCommentException
+ {
+ int c = get();
+ if (c == '/')
+ {
+ switch (peek())
+ {
+ case '/' :
+ for (;;)
+ {
+ c = get();
+ if (c <= '\n')
+ {
+ return c;
+ }
+ }
+
+ case '*' :
+ get();
+ for (;;)
+ {
+ switch (get())
+ {
+ case '*' :
+ if (peek() == '/')
+ {
+ get();
+ return ' ';
+ }
+ break;
+ case EOF :
+ throw new UnterminatedCommentException();
+ }
+ }
+
+ default :
+ return c;
+ }
+
+ }
+ return c;
+ }
+
+ /**
+ * action -- do something! What you do is determined by the argument: 1 Output
+ * A. Copy B to A. Get the next B. 2 Copy B to A. Get the next B. (Delete A).
+ * 3 Get the next B. (Delete B). action treats a string as a single character.
+ * Wow! action recognizes a regular expression if it is preceded by ( or , or =.
+ */
+
+ void action(int d) throws IOException, UnterminatedRegExpLiteralException, UnterminatedCommentException,
+ UnterminatedStringLiteralException
+ {
+ switch (d)
+ {
+ case 1 :
+ out.write(theA);
+ case 2 :
+ theA = theB;
+
+ if (theA == '\'' || theA == '"')
+ {
+ for (;;)
+ {
+ out.write(theA);
+ theA = get();
+ if (theA == theB)
+ {
+ break;
+ }
+ if (theA <= '\n')
+ {
+ throw new UnterminatedStringLiteralException();
+ }
+ if (theA == '\\')
+ {
+ out.write(theA);
+ theA = get();
+ }
+ }
+ }
+
+ case 3 :
+ theB = next();
+ if (theB == '/'
+ && (theA == '(' || theA == ',' || theA == '=' || theA == ':' || theA == '[' || theA == '!'
+ || theA == '&' || theA == '|' || theA == '?' || theA == '{' || theA == '}' || theA == ';' || theA == '\n'))
+ {
+ out.write(theA);
+ out.write(theB);
+ for (;;)
+ {
+ theA = get();
+ if (theA == '/')
+ {
+ break;
+ }
+ else if (theA == '\\')
+ {
+ out.write(theA);
+ theA = get();
+ }
+ else if (theA <= '\n')
+ {
+ throw new UnterminatedRegExpLiteralException();
+ }
+ out.write(theA);
+ }
+ theB = next();
+ }
+ }
+ }
+
+ /**
+ * jsmin -- Copy the input to the output, deleting the characters which are
+ * insignificant to JavaScript. Comments will be removed. Tabs will be
+ * replaced with spaces. Carriage returns will be replaced with linefeeds.
+ * Most spaces and linefeeds will be removed.
+ */
+ public void jsmin() throws IOException, UnterminatedRegExpLiteralException, UnterminatedCommentException,
+ UnterminatedStringLiteralException
+ {
+ theA = '\n';
+ action(3);
+ while (theA != EOF)
+ {
+ switch (theA)
+ {
+ case ' ' :
+ if (isAlphanum(theB))
+ {
+ action(1);
+ }
+ else
+ {
+ action(2);
+ }
+ break;
+ case '\n' :
+ switch (theB)
+ {
+ case '{' :
+ case '[' :
+ case '(' :
+ case '+' :
+ case '-' :
+ action(1);
+ break;
+ case ' ' :
+ action(3);
+ break;
+ default :
+ if (isAlphanum(theB))
+ {
+ action(1);
+ }
+ else
+ {
+ action(2);
+ }
+ }
+ break;
+ default :
+ switch (theB)
+ {
+ case ' ' :
+ if (isAlphanum(theA))
+ {
+ action(1);
+ break;
+ }
+ action(3);
+ break;
+ case '\n' :
+ switch (theA)
+ {
+ case '}' :
+ case ']' :
+ case ')' :
+ case '+' :
+ case '-' :
+ case '"' :
+ case '\'' :
+ action(1);
+ break;
+ default :
+ if (isAlphanum(theA))
+ {
+ action(1);
+ }
+ else
+ {
+ action(3);
+ }
+ }
+ break;
+ default :
+ action(1);
+ break;
+ }
+ }
+ }
+ out.flush();
+ }
+
+ class UnterminatedCommentException extends Exception
+ {
+ }
+
+ class UnterminatedStringLiteralException extends Exception
+ {
+ }
+
+ class UnterminatedRegExpLiteralException extends Exception
+ {
+ }
+
+ public static void main(String arg[])
+ {
+ try
+ {
+ JSMin jsmin = new JSMin(new FileInputStream(arg[0]), System.out);
+ jsmin.jsmin();
+ }
+ catch (FileNotFoundException e)
+ {
+ e.printStackTrace();
+ }
+ catch (ArrayIndexOutOfBoundsException e)
+ {
+ e.printStackTrace();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ catch (UnterminatedRegExpLiteralException e)
+ {
+ e.printStackTrace();
+ }
+ catch (UnterminatedCommentException e)
+ {
+ e.printStackTrace();
+ }
+ catch (UnterminatedStringLiteralException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+}
Added: portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/Javascript.java
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/Javascript.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/Javascript.java 2010-07-23 09:17:09 UTC (rev 3694)
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+
+package org.exoplatform.web.application.javascript;
+
+import javax.servlet.ServletContext;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class Javascript
+{
+
+ /** . */
+ private final JavascriptKey key;
+
+ /** . */
+ private final ServletContext context;
+
+ /** . */
+ private final int priority;
+
+ public Javascript(JavascriptKey key, ServletContext context, Integer priority)
+ {
+ this.key = key;
+ this.context = context;
+ this.priority = priority != null ? priority : -1;
+ }
+
+ public String getPath() {
+ return key.getContextPath() + key.getScriptPath();
+ }
+
+ public JavascriptKey getKey()
+ {
+ return key;
+ }
+
+ public ServletContext getContext()
+ {
+ return context;
+ }
+
+ public int getPriority()
+ {
+ return priority;
+ }
+
+ public BufferedReader getReader()
+ {
+ return new BufferedReader(new InputStreamReader(context.getResourceAsStream(key.getScriptPath())));
+ }
+}
Added: portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigParser.java
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigParser.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigParser.java 2010-07-23 09:17:09 UTC (rev 3694)
@@ -0,0 +1,144 @@
+/*
+ * 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.
+ */
+package org.exoplatform.web.application.javascript;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.ServletContext;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+/**
+ * @author <a href="mailto:hoang281283@gmail.com">Minh Hoang TO</a>
+ * @version $Id$
+ *
+ */
+public class JavascriptConfigParser
+{
+
+ final public static String JAVA_SCRIPT_TAG = "javascript";
+
+ final public static String JAVA_SCRIPT_PARAM = "param";
+
+ final public static String JAVA_SCRIPT_MODULE = "js-module";
+
+ final public static String JAVA_SCRIPT_PATH = "js-path";
+
+ final public static String JAVA_SCRIPT_PRIORITY = "js-priority";
+
+ /** . */
+ private ServletContext context;
+
+ private JavascriptConfigParser(ServletContext context)
+ {
+ this.context = context;
+ }
+
+ public static void processConfigResource(InputStream is, JavascriptConfigService service, ServletContext scontext)
+ {
+ JavascriptConfigParser parser = new JavascriptConfigParser(scontext);
+ List<JavascriptTask> tasks = parser.fetchTasks(is);
+ if (tasks != null)
+ {
+ for (JavascriptTask task : tasks)
+ {
+ task.execute(service, scontext);
+ }
+ }
+ }
+
+ private List<JavascriptTask> fetchTasks(InputStream is)
+ {
+ try
+ {
+ DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document document = docBuilder.parse(is);
+ return fetchTasksFromXMLConfig(document);
+ }
+ catch (Exception ex)
+ {
+ return null;
+ }
+ }
+
+ private List<JavascriptTask> fetchTasksFromXMLConfig(Document document)
+ {
+ List<JavascriptTask> tasks = new ArrayList<JavascriptTask>();
+ Element element = document.getDocumentElement();
+ NodeList nodes = element.getElementsByTagName(JAVA_SCRIPT_TAG);
+ int length = nodes.getLength();
+ for (int i = 0; i < length; i++)
+ {
+ JavascriptTask task = xmlToTask((Element)nodes.item(i));
+ if (task != null)
+ {
+ tasks.add(task);
+ }
+ }
+ return tasks;
+ }
+
+ private JavascriptTask xmlToTask(Element element)
+ {
+ if (!JAVA_SCRIPT_TAG.equals(element.getTagName()))
+ {
+ return null;
+ }
+ try
+ {
+ JavascriptTask task = new JavascriptTask();
+ NodeList nodes = element.getElementsByTagName(JAVA_SCRIPT_PARAM);
+ int length = nodes.getLength();
+ for (int i = 0; i < length; i++)
+ {
+ Element param_ele = (Element)nodes.item(i);
+ String js_module =
+ param_ele.getElementsByTagName(JAVA_SCRIPT_MODULE).item(0).getFirstChild().getNodeValue();
+ String js_path =
+ param_ele.getElementsByTagName(JAVA_SCRIPT_PATH).item(0).getFirstChild().getNodeValue();
+ Integer js_priority = null;
+ try
+ {
+ js_priority =
+ Integer.valueOf(param_ele.getElementsByTagName(JAVA_SCRIPT_PRIORITY).item(0)
+ .getFirstChild().getNodeValue());
+ }
+ catch (Exception e)
+ {
+ //Js_priority still is null;
+ }
+ JavascriptKey key = new JavascriptKey(js_module, js_path, context.getContextPath());
+ Javascript js = new Javascript(key, context, js_priority);
+ task.addScript(js);
+ }
+ return task;
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ return null;
+ }
+ }
+}
Added: portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java 2010-07-23 09:17:09 UTC (rev 3694)
@@ -0,0 +1,356 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.application.javascript;
+
+import org.exoplatform.commons.utils.Safe;
+import org.exoplatform.container.ExoContainerContext;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+import org.gatein.wci.impl.DefaultServletContainerFactory;
+import org.picocontainer.Startable;
+
+import java.io.*;
+import java.util.*;
+
+import javax.servlet.ServletContext;
+
+public class JavascriptConfigService implements Startable
+{
+
+ /** Our logger. */
+ private final Logger log = LoggerFactory.getLogger(JavascriptConfigService.class);
+
+ private Collection<String> availableScripts_;
+
+ private Collection<String> availableScriptsPaths_;
+
+ private List<Javascript> availableScriptsKey_;
+
+ private String mergedJavascript = "";
+
+ private HashMap<String, String> extendedJavascripts;
+
+ private byte[] jsBytes = null;
+
+ /** . */
+ private JavascriptDeployer deployer;
+
+ private JavascriptRemoval removal;
+
+ /** Used to clear merged Javascript on undeploying an webapp */
+ private Map<String, List<String>> object_view_of_merged_JS;
+
+ public JavascriptConfigService(ExoContainerContext context)
+ {
+ availableScripts_ = new ArrayList<String>();
+ availableScriptsPaths_ = new ArrayList<String>();
+ availableScriptsKey_ = new ArrayList<Javascript>();
+ extendedJavascripts = new HashMap<String, String>();
+ deployer = new JavascriptDeployer(context.getPortalContainerName(), this);
+ removal = new JavascriptRemoval(context.getPortalContainerName(), this);
+ object_view_of_merged_JS = new HashMap<String, List<String>>();
+ }
+
+ /**
+ * Return a collection list This method should return the availables scripts in the service
+ * @return
+ */
+ public Collection<String> getAvailableScripts()
+ {
+ return availableScripts_;
+ }
+
+ /**
+ * Get a available script paths
+ * @return a collection list. This method should return the available script paths
+ */
+ public Collection<String> getAvailableScriptsPaths()
+ {
+ return availableScriptsPaths_;
+ }
+
+ /**
+ * Add extended JavaScript into available JavaScript
+ * @param module
+ * module name
+ * @param scriptPath
+ * URI path of JavaScript
+ * @param scontext
+ * the webapp's {@link javax.servlet.ServletContext}
+ * @param scriptData
+ * Content of JavaScript that will be added into available JavaScript
+ */
+ public synchronized void addExtendedJavascript(String module, String scriptPath, ServletContext scontext, String scriptData)
+ {
+ String servletContextName = scontext.getServletContextName();
+ String path = "/" + servletContextName + scriptPath;
+ availableScripts_.add(module);
+ availableScriptsPaths_.add(path);
+ extendedJavascripts.put(path, scriptData);
+ }
+
+ /**
+ * Clear available JavaScript and add new JavaScripts
+ * @param jsKeys
+ * new list of JavaScript will replace current available JavaScript
+ */
+ @SuppressWarnings("unchecked")
+ public synchronized void addJavascripts(List<Javascript> jsKeys)
+ {
+ availableScriptsKey_.addAll(jsKeys);
+
+
+ Collections.sort(availableScriptsKey_, new Comparator<Javascript>()
+ {
+ public int compare(Javascript o1, Javascript o2)
+ {
+ if (o1.getPriority() == o2.getPriority())
+ return o1.getKey().getModule().compareTo(o2.getKey().getModule());
+ else if (o1.getPriority() < 0)
+ return 1;
+ else if (o2.getPriority() < 0)
+ return -1;
+ else
+ return o1.getPriority() - o2.getPriority();
+ }
+ });
+
+ mergedJavascript = "";
+ availableScripts_.clear();
+ availableScriptsPaths_.clear();
+ object_view_of_merged_JS.clear();
+
+ //
+ for (Javascript script : availableScriptsKey_) {
+ addJavascript(script);
+ }
+ }
+
+ /**
+ * Add an JavaScript into available JavaScripts
+ * @param javascript
+ * JavaScript will be added into available JavaScript
+ */
+ private void addJavascript(Javascript javascript)
+ {
+ availableScripts_.add(javascript.getKey().getModule());
+ availableScriptsPaths_.add(javascript.getPath());
+
+ List<String> mergedJS_list = object_view_of_merged_JS.get(javascript.getKey().getContextPath());
+ if (mergedJS_list == null)
+ {
+ mergedJS_list = new ArrayList<String>();
+ object_view_of_merged_JS.put(javascript.getKey().getContextPath(), mergedJS_list);
+ }
+
+ StringBuffer sB = new StringBuffer();
+ String line = "";
+ try
+ {
+ BufferedReader reader = javascript.getReader();
+ try
+ {
+ while ((line = reader.readLine()) != null)
+ {
+ line = line + "\n";
+ sB.append(line);
+ mergedJS_list.add(line);
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ finally
+ {
+ Safe.close(reader);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ sB.append("\n");
+ mergedJS_list.add("\n");
+
+ mergedJavascript = mergedJavascript.concat(sB.toString());
+ }
+
+ /**
+ * Remove JavaScripts from availabe JavaScipts by ServletContext
+ * @param scontext
+ * the webapp's {@link javax.servlet.ServletContext}
+ *
+ */
+ public synchronized void remove(ServletContext context)
+ {
+ // We clone to avoid concurrent modification exception
+ for (Javascript script : new ArrayList<Javascript>(availableScriptsKey_))
+ {
+ if (script.getContext().getContextPath().equals(context.getContextPath())) {
+ removeJavascript(script);
+ }
+ }
+ }
+
+ /**
+ * Remove JavaScript from available JavaScripts
+ * @param script
+ * JavaScript will be removed
+ */
+ public synchronized void removeJavascript(Javascript script)
+ {
+ availableScripts_.remove(script.getKey().getModule());
+ availableScriptsPaths_.remove(script.getPath());
+ object_view_of_merged_JS.remove(script.getKey().getContextPath());
+
+ // Enlist entries to be removed
+ for (Iterator<Javascript> i = availableScriptsKey_.iterator();i.hasNext();)
+ {
+ Javascript _script = i.next();
+ if (script.getKey().equals(_script.getKey()))
+ {
+ i.remove();
+ }
+ }
+ }
+
+ /**
+ * Refresh the mergedJavascript
+ */
+ public void refreshMergedJavascript()
+ {
+ mergedJavascript = "";
+ StringBuffer buffer = new StringBuffer();
+ for (String webApp : object_view_of_merged_JS.keySet())
+ {
+ for (String jsPath : object_view_of_merged_JS.get(webApp))
+ {
+ buffer.append(jsPath);
+ }
+ }
+ mergedJavascript = buffer.toString();
+ }
+
+ /**
+ * Write the merged javascript in a provided output stream.
+ *
+ * @param out the output stream
+ * @throws IOException any io exception
+ */
+ public void writeMergedJavascript(OutputStream out) throws IOException
+ {
+ if (jsBytes == null)
+ {
+ // Generate javascript in a buffer
+ StringBuffer allJavascript = new StringBuffer();
+ allJavascript.append(mergedJavascript);
+ for (String script : extendedJavascripts.values())
+ {
+ allJavascript.append(script);
+ }
+ String s = allJavascript.toString();
+
+ // Get bytes
+ byte[] bytes;
+ try
+ {
+ bytes = s.getBytes("UTF-8");
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new AssertionError("No access to UTF-8, e");
+ }
+
+ // Minify
+ try
+ {
+ ByteArrayInputStream input = new ByteArrayInputStream(bytes);
+ ByteArrayOutputStream jsStream = new ByteArrayOutputStream();
+ JSMin jsMin = new JSMin(input, jsStream);
+ jsMin.jsmin();
+ jsBytes = jsStream.toByteArray();
+ }
+ catch (Exception e)
+ {
+ log.error("Error when generating minified javascript, will use normal javascript instead", e);
+ jsBytes = bytes;
+ }
+ }
+
+ //
+ out.write(jsBytes);
+ }
+
+ /**
+ * Check the existence of module in Available Scripts
+ * @param module
+ * @return true if Available Scripts contain module, else return false
+ */
+ public boolean isModuleLoaded(CharSequence module)
+ {
+ return getAvailableScripts().contains(module);
+ }
+
+ /**
+ * Remove JavaScript from available JavaScripts and extended JavaScripts
+ * @param module
+ * module will be removed
+ * @param scriptPath
+ * URI of script that will be removed
+ * @param scontext
+ * the webapp's {@link javax.servlet.ServletContext}
+ *
+ */
+ public void removeExtendedJavascript(String module, String scriptPath, ServletContext scontext)
+ {
+ String servletContextName = scontext.getServletContextName();
+ availableScripts_.remove(module);
+ String path = "/" + servletContextName + scriptPath;
+ availableScriptsPaths_.remove(path);
+ extendedJavascripts.remove(path);
+ jsBytes = null;
+ }
+
+ /**
+ * Start service.
+ * Registry org.exoplatform.web.application.javascript.JavascriptDeployer,
+ * org.exoplatform.web.application.javascript.JavascriptRemoval into ServletContainer
+ * @see org.picocontainer.Startable#start()
+ */
+ public void start()
+ {
+ DefaultServletContainerFactory.getInstance().getServletContainer().addWebAppListener(deployer);
+ DefaultServletContainerFactory.getInstance().getServletContainer().addWebAppListener(removal);
+ }
+
+ /**
+ * Stop service.
+ * Remove org.exoplatform.web.application.javascript.JavascriptDeployer,
+ * org.exoplatform.web.application.javascript.JavascriptRemoval from ServletContainer
+ * @see org.picocontainer.Startable#stop()
+ */
+ public void stop()
+ {
+ DefaultServletContainerFactory.getInstance().getServletContainer().removeWebAppListener(deployer);
+ DefaultServletContainerFactory.getInstance().getServletContainer().removeWebAppListener(removal);
+ }
+
+}
\ No newline at end of file
Added: portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptDeployer.java
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptDeployer.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptDeployer.java 2010-07-23 09:17:09 UTC (rev 3694)
@@ -0,0 +1,146 @@
+/**
+ * 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.
+ */
+
+package org.exoplatform.web.application.javascript;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.container.RootContainer.PortalContainerPostInitTask;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.gatein.wci.WebAppEvent;
+import org.gatein.wci.WebAppLifeCycleEvent;
+import org.gatein.wci.WebAppListener;
+import org.gatein.wci.impl.DefaultServletContainerFactory;
+import org.picocontainer.Startable;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.servlet.ServletContext;
+
+/**
+ * Created by The eXo Platform SAS
+ * Jan 19, 2007
+ */
+
+public class JavascriptDeployer implements WebAppListener, Startable
+{
+
+ private static final String GATEIN_CONFIG_RESOURCE = "/WEB-INF/gatein-resources.xml";
+
+ /**
+ * Logger
+ */
+ private static final Log LOG = ExoLogger.getLogger(JavascriptDeployer.class);
+
+ /** . */
+ private final JavascriptConfigService javascriptService;
+
+ /**
+ * The name of the portal container
+ */
+ private final String portalContainerName;
+
+ public JavascriptDeployer(String portalContainerName, JavascriptConfigService javascriptService)
+ {
+ this.javascriptService = javascriptService;
+ this.portalContainerName = portalContainerName;
+ }
+
+ public void start()
+ {
+ DefaultServletContainerFactory.getInstance().getServletContainer().addWebAppListener(this);
+ }
+
+ public void stop()
+ {
+ DefaultServletContainerFactory.getInstance().getServletContainer().removeWebAppListener(this);
+ }
+
+ public void onEvent(WebAppEvent event)
+ {
+ if (event instanceof WebAppLifeCycleEvent)
+ {
+ WebAppLifeCycleEvent waEvent = (WebAppLifeCycleEvent)event;
+ if (waEvent.getType() == WebAppLifeCycleEvent.ADDED)
+ {
+ ServletContext scontext = null;
+ try
+ {
+ scontext = event.getWebApp().getServletContext();
+
+ InputStream is = scontext.getResourceAsStream(GATEIN_CONFIG_RESOURCE);
+ if (is == null)
+ return;
+ try
+ {
+ is.close();
+ }
+ catch (Exception ex)
+ {
+ // ignore me
+ }
+ final PortalContainerPostInitTask task = new PortalContainerPostInitTask()
+ {
+
+ public void execute(ServletContext scontext, PortalContainer portalContainer)
+ {
+ register(scontext, portalContainer);
+ }
+ };
+ PortalContainer.addInitTask(scontext, task, portalContainerName);
+ }
+ catch (Exception ex)
+ {
+ LOG.error("An error occurs while registering 'Javascript in gatein-resources.xml' from the context '"
+ + (scontext == null ? "unknown" : scontext.getServletContextName()) + "'", ex);
+ }
+ }
+ }
+ }
+
+ private void register(ServletContext scontext, PortalContainer container)
+ {
+ InputStream is = null;
+ try
+ {
+ is = scontext.getResourceAsStream(GATEIN_CONFIG_RESOURCE);
+ JavascriptConfigParser.processConfigResource(is, javascriptService, scontext);
+ }
+ catch (Exception ex)
+ {
+ LOG.error("An error occurs while processing 'Javascript in gatein-resources.xml' from the context '"
+ + scontext.getServletContextName() + "'", ex);
+ }
+ finally
+ {
+ if (is != null)
+ {
+ try
+ {
+ is.close();
+ }
+ catch (IOException e)
+ {
+ // ignore me
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptKey.java
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptKey.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptKey.java 2010-07-23 09:17:09 UTC (rev 3694)
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+package org.exoplatform.web.application.javascript;
+
+/**
+ * @author <a href="mailto:hoang281283@gmail.com">Minh Hoang TO</a>
+ * @version $Id$
+ *
+ */
+public class JavascriptKey
+{
+
+ /** . */
+ private final String module;
+
+ /** . */
+ private final String scriptPath;
+
+ /** . */
+ private final String contextPath;
+
+ public JavascriptKey(String module, String scriptPath, String contextPath) throws IllegalArgumentException
+ {
+ if (module == null || scriptPath == null || contextPath == null)
+ {
+ throw new IllegalArgumentException("Module and scriptPath are mandatory for JavascriptKey");
+ }
+ this.module = module;
+ this.scriptPath = scriptPath;
+ this.contextPath = contextPath;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof JavascriptKey)
+ {
+ JavascriptKey that = (JavascriptKey)obj;
+ return module.equals(that.module) && scriptPath.equals(that.scriptPath) && contextPath.equals(that.contextPath);
+ }
+ return false;
+ }
+
+ public String getModule()
+ {
+ return module;
+ }
+
+ public String getScriptPath()
+ {
+ return scriptPath;
+ }
+
+ public String getContextPath()
+ {
+ return contextPath;
+ }
+}
Added: portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptRemoval.java
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptRemoval.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptRemoval.java 2010-07-23 09:17:09 UTC (rev 3694)
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+package org.exoplatform.web.application.javascript;
+
+import org.gatein.wci.WebAppEvent;
+import org.gatein.wci.WebAppLifeCycleEvent;
+import org.gatein.wci.WebAppListener;
+import org.gatein.wci.impl.DefaultServletContainerFactory;
+import org.picocontainer.Startable;
+
+import javax.servlet.ServletContext;
+
+/**
+ * @author <a href="mailto:hoang281283@gmail.com">Minh Hoang TO</a>
+ * @version $Id$
+ *
+ */
+public class JavascriptRemoval implements WebAppListener, Startable
+{
+
+ private String portalContainerName;
+
+ private JavascriptConfigService javascriptService;
+
+ public JavascriptRemoval(String _portalContainerName, JavascriptConfigService _javascriptService)
+ {
+ this.portalContainerName = _portalContainerName;
+ this.javascriptService = _javascriptService;
+ }
+
+ /**
+ * @see org.gatein.wci.WebAppListener#onEvent(org.gatein.wci.WebAppEvent)
+ */
+ public void onEvent(WebAppEvent arg0)
+ {
+ if (arg0 instanceof WebAppLifeCycleEvent)
+ {
+ WebAppLifeCycleEvent wevent = (WebAppLifeCycleEvent)arg0;
+ if (wevent.getType() == WebAppLifeCycleEvent.REMOVED)
+ {
+ removeJavascript(wevent.getWebApp().getServletContext());
+ refreshJavascript();
+ }
+ }
+ }
+
+ /**
+ * Removes javascript deployed in this web app.
+ *
+ * @param scontext the servlet context
+ */
+ private void removeJavascript(ServletContext scontext)
+ {
+ String webApp = scontext.getContextPath();
+ javascriptService.remove(scontext);
+ }
+
+ private void refreshJavascript()
+ {
+ javascriptService.refreshMergedJavascript();
+ }
+
+ public void start()
+ {
+ DefaultServletContainerFactory.getInstance().getServletContainer().addWebAppListener(this);
+ }
+
+ public void stop()
+ {
+ DefaultServletContainerFactory.getInstance().getServletContainer().removeWebAppListener(this);
+ }
+
+}
Added: portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptTask.java
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptTask.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptTask.java 2010-07-23 09:17:09 UTC (rev 3694)
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+package org.exoplatform.web.application.javascript;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.ServletContext;
+
+/**
+ * @author <a href="mailto:hoang281283@gmail.com">Minh Hoang TO</a>
+ * @version $Id$
+ *
+ */
+public class JavascriptTask
+{
+
+ private List<Javascript> scripts;
+
+ public JavascriptTask()
+ {
+ scripts = new ArrayList<Javascript>();
+ }
+
+ public void execute(JavascriptConfigService service, ServletContext scontext)
+ {
+ service.addJavascripts(scripts);
+ }
+
+ public void addScript(Javascript script)
+ {
+ scripts.add(script);
+ }
+}
Deleted: portal/trunk/component/web/src/main/java/org/exoplatform/web/resource/config/xml/GateinResource.java
===================================================================
--- portal/trunk/component/web/src/main/java/org/exoplatform/web/resource/config/xml/GateinResource.java 2010-07-23 08:40:15 UTC (rev 3693)
+++ portal/trunk/component/web/src/main/java/org/exoplatform/web/resource/config/xml/GateinResource.java 2010-07-23 09:17:09 UTC (rev 3694)
@@ -1,46 +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.
- */
-
-package org.exoplatform.web.resource.config.xml;
-
-import org.w3c.dom.Element;
-
-/**
- *
- * Created by eXoPlatform SAS
- *
- * Author: Minh Hoang TO - hoang281283(a)gmail.com
- *
- * Sep 17, 2009
- */
-public interface GateinResource
-{
-
- final public static String JAVA_SCRIPT_TAG = "javascript";
-
- final public static String JAVA_SCRIPT_PARAM = "param";
-
- final public static String JAVA_SCRIPT_MODULE = "js-module";
-
- final public static String JAVA_SCRIPT_PATH = "js-path";
-
- final public static String JAVA_SCRIPT_PRIORITY = "js-priority";
-
- public void binding(Element elemt);
-}
14 years, 5 months