gatein SVN: r619 - portal/trunk/packaging/pkg.
by do-not-reply@jboss.org
Author: dbaeli
Date: 2009-11-16 23:43:50 -0500 (Mon, 16 Nov 2009)
New Revision: 619
Modified:
portal/trunk/packaging/pkg/pom.xml
Log:
GTNPORTAL-256: Replace the exopackage structure with maven tooling
* rollback usage of embedded exopackage until mvn install in packaging/ performs correctely the goals included in exopackage
Modified: portal/trunk/packaging/pkg/pom.xml
===================================================================
--- portal/trunk/packaging/pkg/pom.xml 2009-11-17 04:42:52 UTC (rev 618)
+++ portal/trunk/packaging/pkg/pom.xml 2009-11-17 04:43:50 UTC (rev 619)
@@ -34,10 +34,10 @@
<dependencies>
<dependency>
- <groupId>org.exoplatform.portal</groupId>
+ <groupId>org.exoplatform.tool</groupId>
<artifactId>exopackage</artifactId>
<type>zip</type>
- <version>3.0.0-CR01-SNAPSHOT</version>
+ <version>1.1.0-Beta05</version>
</dependency>
<dependency>
@@ -104,7 +104,7 @@
<overWriteSnapshots>true</overWriteSnapshots>
<artifactItems>
<artifactItem>
- <groupId>org.exoplatform.portal</groupId>
+ <groupId>org.exoplatform.tool</groupId>
<artifactId>exopackage</artifactId>
<type>zip</type>
<outputDirectory>target/exopackage</outputDirectory>
15 years, 1 month
gatein SVN: r618 - portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form.
by do-not-reply@jboss.org
Author: truong.le
Date: 2009-11-16 23:42:52 -0500 (Mon, 16 Nov 2009)
New Revision: 618
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/UIFormInputSet.java
Log:
GTNPORTAL-127: display not well when creating or editing category
Modified: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/UIFormInputSet.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/UIFormInputSet.java 2009-11-17 04:32:44 UTC (rev 617)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/UIFormInputSet.java 2009-11-17 04:42:52 UTC (rev 618)
@@ -182,7 +182,12 @@
}
w.write("<tr>");
w.write("<td class=\"FieldLabel\">");
- w.write(label);
+
+ // if missing resource, don't print out the label.
+ if(!label.equals(inputEntry.getName()))
+ {
+ w.write(label);
+ }
w.write("</td>");
w.write("<td class=\"FieldComponent\">");
renderUIComponent(inputEntry);
15 years, 1 month
gatein SVN: r617 - in portal/trunk: webui/portal/src/main/java/org/exoplatform/portal/webui/navigation and 1 other directory.
by do-not-reply@jboss.org
Author: liem_nguyen
Date: 2009-11-16 23:32:44 -0500 (Mon, 16 Nov 2009)
New Revision: 617
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationNodeSelector.java
Log:
GTNPORTAL-98 Problem in add/edit node form in the first time (Popup Window width)
Modified: portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java 2009-11-17 04:31:48 UTC (rev 616)
+++ portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java 2009-11-17 04:32:44 UTC (rev 617)
@@ -356,7 +356,7 @@
selector.removeChild(UIRightClickPopupMenu.class);
uiNavigationPopup.setUIComponent(pageManager);
uiNavigationPopup.setWindowSize(400, 400);
- event.getRequestContext().addUIComponentToUpdateByAjax(uiNavigationPopup);
+ event.getRequestContext().addUIComponentToUpdateByAjax(uiNavigationPopup.getParent());
}
}
Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationNodeSelector.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationNodeSelector.java 2009-11-17 04:31:48 UTC (rev 616)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationNodeSelector.java 2009-11-17 04:32:44 UTC (rev 617)
@@ -537,7 +537,7 @@
uiNodeForm.setValues(selectedNode);
uiNodeForm.setSelectedParent(obj);
uiManagementPopup.setWindowSize(800, 500);
- ctx.addUIComponentToUpdateByAjax(uiManagementPopup);
+ event.getRequestContext().addUIComponentToUpdateByAjax(uiManagementPopup.getParent());
}
}
15 years, 1 month
gatein SVN: r616 - portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component.
by do-not-reply@jboss.org
Author: truong.le
Date: 2009-11-16 23:31:48 -0500 (Mon, 16 Nov 2009)
New Revision: 616
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategoryForm.java
Log:
GTNPORTAL-252: ClassCastException in Application registry when creating new category
fix bug in save procedure
Modified: portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategoryForm.java
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategoryForm.java 2009-11-17 03:31:19 UTC (rev 615)
+++ portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategoryForm.java 2009-11-17 04:31:48 UTC (rev 616)
@@ -142,7 +142,7 @@
{
category.setDisplayName(displayName);
}
- category.setDescription(uiSetting.getUIStringInput(FIELD_DESCRIPTION).getValue());
+ category.setDescription(uiSetting.getUIFormTextAreaInput(FIELD_DESCRIPTION).getValue());
UIListPermissionSelector uiListPermissionSelector = uiPermission.getChild(UIListPermissionSelector.class);
ArrayList<String> pers = new ArrayList<String>();
15 years, 1 month
gatein SVN: r615 - in portal/trunk/packaging/exopackage: src/main/javascript/eXo/server and 1 other directory.
by do-not-reply@jboss.org
Author: dbaeli
Date: 2009-11-16 22:31:19 -0500 (Mon, 16 Nov 2009)
New Revision: 615
Modified:
portal/trunk/packaging/exopackage/
portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Jboss.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/JbossEar.js
Log:
GTNPORTAL-73: it is not possible to package additional org.hibernate
* No more removal of hibernate libraries (as a distinct version of hibernate may be used in GateIn)
Property changes on: portal/trunk/packaging/exopackage
___________________________________________________________________
Name: svn:ignore
+ target
Modified: portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Jboss.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Jboss.js 2009-11-17 03:21:42 UTC (rev 614)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Jboss.js 2009-11-17 03:31:19 UTC (rev 615)
@@ -86,7 +86,6 @@
// Remove hibernate libs for JBoss AS5
if (this.exoJBoss5) {
print("====================== JBOSS5 AS 5 ====================== ");
- product.removeDependencyByGroupId("org.hibernate");
product.removeDependency(new Project("org.jboss", "jbossxb", "jar", "2.0.0.GA"));
product.removeDependency(new Project("org.jboss.logging", "jboss-logging-spi", "jar", "2.0.5.GA"));
product.removeDependency(new Project("org.jboss", "jboss-common-core", "jar", "2.2.9.GA"));
Modified: portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/JbossEar.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/JbossEar.js 2009-11-17 03:21:42 UTC (rev 614)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/JbossEar.js 2009-11-17 03:31:19 UTC (rev 615)
@@ -93,7 +93,6 @@
// Remove hibernate libs for JBoss AS5
if (this.exoJBoss5) {
print("====================== JBOSS5 AS 5 ====================== ");
- product.removeDependencyByGroupId("org.hibernate");
product.removeDependency(new Project("org.jboss", "jbossxb", "jar", "2.0.0.GA"));
product.removeDependency(new Project("org.jboss.logging", "jboss-logging-spi", "jar", "2.0.5.GA"));
product.removeDependency(new Project("org.jboss", "jboss-common-core", "jar", "2.2.9.GA"));
15 years, 1 month
gatein SVN: r614 - in portal/trunk/packaging/exopackage/src/main: lib and 1 other directory.
by do-not-reply@jboss.org
Author: dbaeli
Date: 2009-11-16 22:21:42 -0500 (Mon, 16 Nov 2009)
New Revision: 614
Added:
portal/trunk/packaging/exopackage/src/main/lib/
portal/trunk/packaging/exopackage/src/main/lib/js.jar
Log:
GTNPORTAL-256: Replace the exopackage structure with maven tooling
* Step 1: include exopackage in GateIn to avoid external dependencies
* Same code as exopackage 1.1.0-Beta05 (was in http://svn.exoplatform.org/projects/utils/exopackage/tags/1.1.0-Beta05 )
Added: portal/trunk/packaging/exopackage/src/main/lib/js.jar
===================================================================
(Binary files differ)
Property changes on: portal/trunk/packaging/exopackage/src/main/lib/js.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
15 years, 1 month
gatein SVN: r613 - in portal/trunk/packaging: exopackage and 1 other directory.
by do-not-reply@jboss.org
Author: dbaeli
Date: 2009-11-16 22:20:51 -0500 (Mon, 16 Nov 2009)
New Revision: 613
Modified:
portal/trunk/packaging/exopackage/pom.xml
portal/trunk/packaging/pom.xml
Log:
GTNPORTAL-256: Replace the exopackage structure with maven tooling
* Step 1: include exopackage in GateIn to avoid external dependencies
* Same code as exopackage 1.1.0-Beta05 (was in http://svn.exoplatform.org/projects/utils/exopackage/tags/1.1.0-Beta05 )
Modified: portal/trunk/packaging/exopackage/pom.xml
===================================================================
--- portal/trunk/packaging/exopackage/pom.xml 2009-11-17 02:28:12 UTC (rev 612)
+++ portal/trunk/packaging/exopackage/pom.xml 2009-11-17 03:20:51 UTC (rev 613)
@@ -24,26 +24,27 @@
<artifactId>exo.portal.packaging</artifactId>
<version>3.0.0-CR01-SNAPSHOT</version>
</parent>
- <modelVersion>4.0.0</modelVersion>
+
+ <modelVersion>4.0.0</modelVersion>
<artifactId>exopackage</artifactId>
- <name>GateIn eXo Package</name>
+ <name>GateIn eXo Package</name>
<packaging>pom</packaging>
<build>
<plugins>
- <!-- exobuild packaging -->
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <goals><goal>assembly</goal></goals>
- </execution>
- </executions>
- <configuration>
- <descriptors><descriptor>src/assemble/exopackage-zip.xml</descriptor></descriptors>
- </configuration>
- </plugin>
+ <!-- exobuild packaging -->
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals><goal>assembly</goal></goals>
+ </execution>
+ </executions>
+ <configuration>
+ <descriptors><descriptor>src/assemble/exopackage-zip.xml</descriptor></descriptors>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
@@ -66,6 +67,6 @@
</execution>
</executions>
</plugin>
- </plugins>
- </build>
+ </plugins>
+ </build>
</project>
Modified: portal/trunk/packaging/pom.xml
===================================================================
--- portal/trunk/packaging/pom.xml 2009-11-17 02:28:12 UTC (rev 612)
+++ portal/trunk/packaging/pom.xml 2009-11-17 03:20:51 UTC (rev 613)
@@ -32,7 +32,7 @@
<name>GateIn Portal Packaging</name>
<modules>
- <!--module>exopackage</module-->
+ <module>exopackage</module>
<module>module</module>
<module>product</module>
<module>pkg</module>
15 years, 1 month
gatein SVN: r612 - in portal/trunk/packaging: exopackage and 10 other directories.
by do-not-reply@jboss.org
Author: dbaeli
Date: 2009-11-16 21:28:12 -0500 (Mon, 16 Nov 2009)
New Revision: 612
Added:
portal/trunk/packaging/exopackage/
portal/trunk/packaging/exopackage/README.txt
portal/trunk/packaging/exopackage/pom.xml
portal/trunk/packaging/exopackage/src/
portal/trunk/packaging/exopackage/src/assemble/
portal/trunk/packaging/exopackage/src/assemble/exopackage-zip.xml
portal/trunk/packaging/exopackage/src/main/
portal/trunk/packaging/exopackage/src/main/javascript/
portal/trunk/packaging/exopackage/src/main/javascript/eXo/
portal/trunk/packaging/exopackage/src/main/javascript/eXo/System.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/command/
portal/trunk/packaging/exopackage/src/main/javascript/eXo/command/exobuild.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/command/exoproject.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/command/exosvn.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/command/maven.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/command/svn.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/core/
portal/trunk/packaging/exopackage/src/main/javascript/eXo/core/IOUtil.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/core/TaskDescriptor.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/core/Util.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/eXo.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/projects/
portal/trunk/packaging/exopackage/src/main/javascript/eXo/projects/Module.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/projects/Product.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/projects/Project.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/projects/Workflow.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/projects/WorkflowBackup.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/
portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Database.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Ear.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Jboss.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/JbossEar.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Jonas.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/ServerUtil.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Tomcat.js
portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/WorkflowConfig.js
Modified:
portal/trunk/packaging/pkg/pom.xml
portal/trunk/packaging/pom.xml
Log:
GTNPORTAL-256: Replace the exopackage structure with maven tooling
* Step 1: include exopackage in GateIn to avoid external dependencies
* Same code as exopackage 1.1.0-Beta05 (was in http://svn.exoplatform.org/projects/utils/exopackage/tags/1.1.0-Beta05 )
Added: portal/trunk/packaging/exopackage/README.txt
===================================================================
--- portal/trunk/packaging/exopackage/README.txt (rev 0)
+++ portal/trunk/packaging/exopackage/README.txt 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,22 @@
+* exopackage : scripting to build GateIn ear and to assemble the gatein distribution.
+
+Status:
+As explain in the GateIn main README file, this tooling is aimed to be replaced.
+So this artifact is here for a short time to let the team work on replacing this way to package the
+Please see http://jira.jboss.org/jira/browse/GTNPORTAL-256 for the main Jira about it.
+
+Description:
+* .js files represent the scripts executed to package GateIn and its extensions.
+* exobuild is the packager :
+** creates the ear or not according to the target AS
+** setup the DB configuration
+** copy the binary to the target AS
+
+Goal:
+* Replace this scripting by a maven plugin and some maven projects (ear for jboss packaging for example)
+
+Tasks:
+* Describe the features (jboss, tomcat packaging, ...)
+* Clean-up non needed code (svn update, dependency download, ...)
+* Study what maven built-in functions can be used
+* Write a dedicate maven plugin if needed
\ No newline at end of file
Added: portal/trunk/packaging/exopackage/pom.xml
===================================================================
--- portal/trunk/packaging/exopackage/pom.xml (rev 0)
+++ portal/trunk/packaging/exopackage/pom.xml 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,71 @@
+<!--
+
+ 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.packaging</artifactId>
+ <version>3.0.0-CR01-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>exopackage</artifactId>
+ <name>GateIn eXo Package</name>
+ <packaging>pom</packaging>
+
+ <build>
+ <plugins>
+ <!-- exobuild packaging -->
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals><goal>assembly</goal></goals>
+ </execution>
+ </executions>
+ <configuration>
+ <descriptors><descriptor>src/assemble/exopackage-zip.xml</descriptor></descriptors>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.3</version>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>target/${project.artifactId}-${project.version}.zip</file>
+ <type>zip</type>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: portal/trunk/packaging/exopackage/src/assemble/exopackage-zip.xml
===================================================================
--- portal/trunk/packaging/exopackage/src/assemble/exopackage-zip.xml (rev 0)
+++ portal/trunk/packaging/exopackage/src/assemble/exopackage-zip.xml 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,25 @@
+<assembly>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <fileSets>
+ <fileSet>
+ <directory>src/main</directory>
+ <outputDirectory></outputDirectory>
+ <includes><include>**</include></includes>
+ <excludes>
+ <exclude>**/*.sh</exclude>
+ <exclude>conf/**</exclude>
+ </excludes>
+ <useDefaultExcludes>true</useDefaultExcludes>
+ </fileSet>
+ <fileSet>
+ <directory>src/main</directory>
+ <outputDirectory></outputDirectory>
+ <includes><include>**/*.sh</include></includes>
+ <useDefaultExcludes>true</useDefaultExcludes>
+ <fileMode>0755</fileMode>
+ </fileSet>
+ </fileSets>
+</assembly>
\ No newline at end of file
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/System.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/System.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/System.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,94 @@
+eXo.System = {
+ verbose :false,
+
+ addSystemClasspath : function(url) {
+ var sysClassLoader = java.lang.ClassLoader.getSystemClassLoader();
+ var argTypes = [ java.net.URL.getClass() ];
+ method = java.net.URLClassLoader.getClass().getDeclaredMethod("addURL", argTypes);
+ method.setAccessible(true);
+ for (i = 0; i < url.length; i++) {
+ var args = new Array();
+ args[0] = url[i];
+ method.invoke(sysClassLoader, args);
+ }
+ },
+
+ info : function(tag, message) {
+ if (message == null) {
+ message = tag;
+ tag = "INFO";
+ }
+ java.lang.System.out.print("[" + tag + "]");
+ for ( var i = tag.length + 2; i < 10; i++)
+ java.lang.System.out.print(" ");
+
+ java.lang.System.out.println(message);
+// var tmp = message.split("\n");
+// java.lang.System.out.println(tmp[0]);
+// for ( var j = 1; j < tmp.length; j++) {
+// java.lang.System.out.println(" " + tmp[j]);
+// }
+ },
+
+ error : function(message) {
+ this.info("ERROR", message);
+ },
+
+ vinfo : function(tag, message) {
+ if (this.verbose)
+ this.info(tag, message);
+ },
+
+ print : function(message) {
+ java.lang.System.out.print(message);
+ },
+
+ vprint : function(message) {
+ if (this.verbose)
+ java.lang.System.out.print(message);
+ },
+
+ printIndentation : function() {
+ print(" ");
+ },
+
+ vprintIndentation : function() {
+ if (this.verbose)
+ print(" ");
+ },
+
+ run : function(args, printResult, printError) {
+ var proc = java.lang.Runtime.getRuntime().exec(args);
+ var din = new java.io.DataInputStream(proc.getInputStream());
+ var b = new java.lang.StringBuilder();
+ var line = null;
+ while ((line = din.readLine()) != null) {
+ b.append(line).append('\n');
+ if (printResult)
+ print(line);
+ }
+
+ if (printError) {
+ var errStream = new java.io.DataInputStream(proc.getErrorStream());
+ while ((line = errStream.readLine()) != null)
+ print(line);
+ }
+
+ return b.toString();
+ },
+
+ readInput : function(message) {
+ java.lang.System.out.print(message + ": ");
+ var b = new java.lang.StringBuilder();
+ var systemin = java.lang.System['in'];
+ while (true) {
+ var val = systemin.read();
+ if (val == 13)
+ continue;
+ if (val == 10)
+ break;
+ b.appendCodePoint(val);
+ }
+ return b.toString();
+ }
+}
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/command/exobuild.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/command/exobuild.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/command/exobuild.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,391 @@
+eXo.require("eXo.server.Tomcat");
+eXo.require("eXo.server.Jboss");
+eXo.require("eXo.server.JbossEar");
+eXo.require("eXo.server.Ear");
+eXo.require("eXo.server.Jonas");
+eXo.require("eXo.server.Database");
+eXo.require("eXo.server.WorkflowConfig");
+eXo.require("eXo.core.TaskDescriptor");
+eXo.require("eXo.command.maven");
+eXo.require("eXo.command.svn");
+eXo.require("eXo.core.IOUtil");
+eXo.require("eXo.projects.Workflow");
+eXo.require("eXo.projects.WorkflowBackup");
+eXo.require("eXo.projects.Product");
+
+// initialize possible database setups
+var databaseMap = new java.util.HashMap();
+databaseMap.put("hsqldb", eXo.server.Database.HsqlDB("hsqldb"));
+databaseMap.put("mysql", eXo.server.Database.MysqlDB("mysql"));
+databaseMap.put("oracle", eXo.server.Database.OracleDB("oracle"));
+databaseMap.put("postgresql", eXo.server.Database.PostgresDB("postgresql"));
+databaseMap.put("db2", eXo.server.Database.DB2ExpressDB("db2"));
+databaseMap.put("db2v8", eXo.server.Database.DB2V8DB("db2v8"));
+databaseMap.put("derby", eXo.server.Database.DerbyDB("derby"));
+databaseMap.put("sqlserver", eXo.server.Database.SqlServerDB("sqlserver"));
+
+// initialize possible server setups
+var serverMap = new java.util.HashMap();
+serverMap.put("tomcat", new Tomcat(eXo.env.workingDir + "/tomcat"));
+serverMap.put("jboss", new Jboss(eXo.env.workingDir + "/jboss"));
+serverMap.put("jbossear", new JbossEar(eXo.env.workingDir + "/jboss"));
+serverMap.put("jonas", new Jonas(eXo.env.workingDir + "/jonas"));
+serverMap.put("ear", new Ear(eXo.env.workingDir + "/ear"));
+
+// TODO autodetect !!
+var modules = [ "all", "pc", "jcr", "ws", "tools", "ecm", "cs", "ks", "portal", "liveroom", "dms", "workflow" ];
+// TODO autodetect !!
+var products = [ "cs", "ks", "ecm", "portal", "ultimate", "wcm", "webos", "liveroom", "dms", "workflow" ];
+
+function exobuildInstructions() {
+ print("\n" + "Use of the exobuild command: \n\n" + " exobuild --product=name\n" + " [--version=version]\n"
+ + " [--update]\n" + " [--build]\n" + " [--exclude=modules]\n"
+ + " [--deploy[=server]]\n" + " [--release[=server]]\n"
+ + " [--workflow[=jbpm|bonita]]\n" + " [--enable-workflow[=bonita|jbpm]]\n"
+ + " [--clean-mvn-repo]\n" + " [--database[=dialect]]\n" + " [--dbsetup=option]\n"
+ + "\n\n" + "Options: \n" + " * --product=name Name of the product you want to build.\n"
+ + " The possible names are "
+ + products
+ + ", ...\n"
+ + " Default is portal.\n"
+ + " * --version=number Allows to specify which version of the product\n"
+ + " to build such as trunk, tags/2.0, branches/2.0,.... \n"
+ + " Default is trunk.\n"
+ + " * --update Run a svn update before it builds.\n"
+ + " * --build Compile and install the sub projects of the product,\n"
+ + " * --exclude Exclude the given modules (comma separated) from compilation and fetch jars from repository\n"
+ + " You can specify any module name in "
+ + modules
+ + ".\n"
+ + " Use this to avoid full build or when a module breaks the build\n"
+ + " * --deploy=server Deploy to a given application server. Possible values are: 'all', "
+ + serverMap.keySet()
+ + ".\n"
+ + " Default is tomcat.\n"
+ + " * --release=server Release for the target application server. Produce a zip named after the current SVN revision.\n"
+ + " Possible values are: 'all', "
+ + serverMap.keySet()
+ + ".\n"
+ + " Default is tomcat\n"
+ + " * --clean-mvn-repo Clean your local repository of eXo artifacts before building.\n"
+ + " * --database=dialect Specify target database dialect. The possible values are "
+ + databaseMap.keySet()
+ + ".\n"
+ + " This will configure the appropriate JCR dialects and deploy the JDBC driver.\n"
+ + " Used with --dbsetup=file option, exobuild tries to get database settings in a file named\n"
+ + " database-configuration.{dialect}.xml\n"
+ + " Default is hsqldb.\n"
+ + " * --dbsetup=option Use this option with --database option to specify the database setup behaviour.\n"
+ + " dbsetup=file will use the database and jcr files you provided.\n"
+ + " dbsetup=ask allow you to enter the connection url , username and password of the database server.\n"
+ + " dbsetup=defaults is the default option if dbsetup is not specified and will override settings by those defined in Database.js\n"
+ + " * --workflow=engine (For the old verions of ECM from 2.0 to 2.2.x) Specify the workflow engine to bundle with the product. The possible values are bonita or jbpm.\n"
+ + " This option is only used for products that use workflow. Default engine is jbpm\n"
+ + " * --enable-workflow=engine + .\n"
+ + " (Since DMS 2.3) Specify the workflow engine to bundle with the product. The possible values are bonita or jbpm.\n"
+ + " This option is only used for products that use workflow. Default engine is bonita\n"
+ + " * --help To print this help. Also you can use option: '-help' or 'help' or '?' \n");
+}
+
+function errExobuild(cause, value) {
+ eXo.System.info("ERR", cause + ": " + value);
+ exobuildInstructions();
+ java.lang.System.exit(1);
+}
+
+// name is "=NAME_SERVER" or "=all" or "" as default for tomcat
+// cycle is "deploy" or "release"
+function storeServers(name, cycle) {
+ if (name == "") {
+ eXo.System.info("INFO", " add server = " + "tomcat");
+ deployServers.add(serverMap.get("tomcat"));
+ } else if (name.match("=")) {
+ var serverName = name.substring("=".length);
+ if (serverName == "all") {
+ eXo.System.info("INFO", " add servers = " + serverMap.keySet());
+ deployServers = serverMap.values();
+ } else {
+ if (serverMap.get(serverName) == null)
+ errExobuild("UNKNOWN server in " + cycle + " for deploy", serverName);
+ eXo.System.info("INFO", " add server = " + serverName);
+ deployServers.add(serverMap.get(serverName));
+ }
+ } else
+ errExobuild("UNKNOWN server in " + cycle, serverName);
+}
+
+function ReleaseTask(server, product, version) {
+ var descriptor = new TaskDescriptor("Release Task", server.serverHome);
+ descriptor.execute = function() {
+ var versionInfo = "unknown";
+ if (!noInternet && "trunk" == version) {
+ var commands = [ "svn", "info", eXo.env.eXoProjectsDir + "/" + product.codeRepo ];
+ eXo.System.info("RELEASE", "Getting product revision from SVN.");
+ var result = eXo.System.run(commands);
+ var line = result.split("\n");
+ for ( var i = 0; i < line.length; i++) {
+ if (line[i].match("vision")) {
+ eXo.System.info("RELEASE", line[i]);
+ versionInfo = "r" + line[i].substring(line[i].lastIndexOf(":") + 1, line[i].length()).trim();
+ }
+ }
+ } else {
+ versionInfo = version;
+ }
+ var zipName = "exo-" + product.name + "-" + versionInfo + "-" + server.name;
+ eXo.System.info("RELEASE", "Building zip: " + zipName + ".zip" + " in " + eXo.env.workingDir);
+ eXo.core.IOUtil.zip(server.serverHome, eXo.env.workingDir, zipName);
+ }
+ return descriptor;
+}
+
+function EarTask(server, product, version) {
+ var descriptor = new TaskDescriptor("Ear Task", server.serverHome);
+ descriptor.execute = function() {
+ var versionInfo = "unknown";
+ if (!noInternet && "trunk" == version) {
+ var commands = [ "svn", "info", eXo.env.eXoProjectsDir + "/" + product.codeRepo ];
+ eXo.System.info("EAR", "Getting product revision from SVN.");
+ var result = eXo.System.run(commands);
+ var line = result.split("\n");
+ for ( var i = 0; i < line.length; i++) {
+ if (line[i].match("vision")) {
+ eXo.System.info("EAR", line[i]);
+ versionInfo = "r" + line[i].substring(line[i].lastIndexOf(":") + 1, line[i].length()).trim();
+ }
+ }
+ } else {
+ versionInfo = version;
+ }
+ var earName = product.name + "-" + versionInfo;
+ var dest = eXo.env.workingDir + "/" + earName + ".ear"; // =
+ // server.earFile;
+ eXo.System.info("EAR", "Building ear: " + dest);
+ eXo.core.IOUtil.ear(server.serverHome, dest);
+ eXo.core.IOUtil.remove(server.serverHome);
+ }
+ return descriptor;
+}
+
+var build_ = false;
+var update_ = false;
+var ask = false;
+var exclude_ = null;
+var release_ = false;
+var cleanMVNRepo_ = false;
+var dbsetup = "defaults";
+var maven = new eXo.command.maven();
+var exosvn = null;
+var server = null;
+var deployServers = new java.util.HashSet();
+var productName = "portal";
+var product = null;
+var dialect = "hsqldb";
+var database = databaseMap.get(dialect);
+var version = "trunk";
+var workflow = new Workflow("bonita", version);
+var workflowBackup = new WorkflowBackup("jbpm", version);
+var useWorkflowPlg = false;
+var enableWorkflow = false;
+var tasks = new java.util.ArrayList();
+var noInternet = false;
+
+var args = arguments;
+
+if (args.length == 0)
+ errExobuild("NO ARGUMENT PASSED", "");
+
+for ( var i = 0; i < args.length; i++) {
+ var arg = args[i];
+ if ("--update" == arg) {
+ update_ = true;
+ } else if (arg.match("--version")) {
+ if (arg.match("--version="))
+ version = arg.substring("--version=".length);
+ } else if ("--build" == arg) {
+ build_ = true;
+ } else if (arg.match("--dbsetup")) {
+ if (arg.match("--dbsetup="))
+ dbsetup = arg.substring("--dbsetup=".length);
+ } else if ("--clean-mvn-repo" == arg) {
+ cleanMVNRepo_ = true;
+ } else if (arg.match("--release")) {
+ storeServers(arg.substring("--release".length), "release");
+ release_ = true;
+ } else if (arg.match("--exclude=")) {
+ exclude_ = arg.substring("--exclude=".length);
+ } else if (arg.match("--deploy")) {
+ storeServers(arg.substring("--deploy".length), "deploy");
+ } else if (arg.match("--database")) {
+ if (arg.match("--database=")) {
+ dialect = arg.substring("--database=".length);
+ var database = databaseMap.get(dialect);
+ if (database == null)
+ errExobuild("UNKNOWN dialect", dialect);
+ }
+ } else if (arg.match("--product")) {
+ if (arg.match("--product=")) {
+ productName = arg.substring("--product=".length);
+ }
+ } else if (arg.match("--workflow")) {
+ eXo.System
+ .info(
+ "INFO",
+ "This parameter was deprecated since ECM 2.3. If you are using DMS 2.3 please use --enable-workflow to replace the old one");
+ var workflowName = arg.substring("--workflow=".length);
+ if (workflowName != "") {
+ workflow.name = workflowName;
+ workflowBackup.name = workflowName;
+ java.lang.System.setProperty("workflow", workflowName);
+ }
+ useWorkflowPlg = true;
+ } else if (arg.match("--enable-workflow")) {
+ var workflowName = arg.substring("--enable-workflow=".length);
+ if ((workflowName == "bonita") || (workflowName == "jbpm")) {
+ workflow.name = workflowName;
+ java.lang.System.setProperty("workflow", workflowName);
+ } else {
+ eXo.System.info("ERR", "'--enable-workflow' only accepts 'bonita' or 'jbpm'");
+ java.lang.System.exit(1);
+ }
+ useWorkflowPlg = true;
+ enableWorkflow = true;
+ } else if (arg == "--nointernet") {
+ noInternet = true;
+ } else if (arg == "--help" || arg == "-help" || arg == "help" || arg == "?") {
+ exobuildInstructions();
+ java.lang.System.exit(1);
+ } else {
+ errExobuild("UNKNOWN ARGUMENT", arg);
+ }
+}
+
+if (productName == null || productName == "") {
+ errExobuild("NULL product", "");
+} else {
+ product = Product.GetProduct(productName, version);
+ if (productName == "workflow") {
+ enableWorkflow = true;
+ }
+
+}
+
+if (deployServers != null && !deployServers.isEmpty() && dbsetup == "ask") {
+ tasks.add(database.GetConfigTask());
+}
+
+if (update_) {
+ // exosvn = new eXo.command.exosvn();
+ exosvn = new eXo.command.svn();
+ if ("all" != exclude_) {
+ for ( var i = 0; i < product.dependencyModule.length; i++) {
+ var module = product.dependencyModule[i];
+ if (exclude_ == null || exclude_.indexOf(module.name) < 0) {
+ var moduleDir = eXo.env.eXoProjectsDir + "/" + module.relativeSRCRepo;
+ var directory = new java.io.File(moduleDir);
+ if (directory.exists())
+ tasks.add(exosvn.UpdateTask(moduleDir));
+ }
+ }
+ }
+ tasks.add(exosvn.UpdateTask(eXo.env.eXoProjectsDir + "/" + product.codeRepo));
+}
+
+if (build_) {
+ var mvnArgs;
+ // When you use --enable-workflow parameter, with DMS product,
+ // we need use Maven profiles function to build
+ // DMS with both component DMS-core and DMS-ext(including content
+ // validation)
+ if (enableWorkflow && (product.name == "eXoDMS")) {
+ mvnArgs = [ "clean", "install", "-P", "ext" ];
+ } else {
+ mvnArgs = [ "clean", "install" ];
+ }
+ for ( var i = 0; i < product.dependencyModule.length; i++) {
+ var module = product.dependencyModule[i];
+ if (cleanMVNRepo_) {
+ eXo.core.IOUtil.remove(eXo.env.dependenciesDir + "/repository/" + module.relativeMavenRepo);
+ }
+ if ("all" != exclude_) {
+ if (exclude_ == null || exclude_.indexOf(module.name) < 0) {
+ var moduleDir = eXo.env.eXoProjectsDir + "/" + module.relativeSRCRepo;
+ var directory = new java.io.File(moduleDir);
+ if (directory.exists())
+ tasks.add(maven.MavenTask(moduleDir, mvnArgs));
+ }
+ }
+ }
+ var moduleDir = eXo.env.eXoProjectsDir + "/" + product.codeRepo;
+ tasks.add(maven.MavenTask(moduleDir, mvnArgs));
+}
+
+if (deployServers != null && !deployServers.isEmpty()) {
+ if (product.useWorkflow || useWorkflowPlg || enableWorkflow) {
+ if (enableWorkflow) {
+ workflow.version = product.workflowVersion;
+ workflow.configWorkflow(product);
+ } else {
+ workflowBackup.version = product.workflowVersion;
+ workflowBackup.configWorkflow(product);
+ }
+ }
+
+ var serv = deployServers.iterator();
+ while (serv.hasNext()) {
+ server = serv.next();
+ server.pluginVersion = product.serverPluginVersion;
+ tasks.add(product.DeployTask(product, server, eXo.env.m2Repos));
+ if (database != null) {
+ tasks.add(database.DeployTask(product, server, eXo.env.m2Repos));
+ tasks.add(database.ConfigureTask(product, server, dbsetup));
+ }
+ if (product.name == "eXoWorkflow") {
+ var patchWorkflow = eXo.server.WorkflowConfig;
+ tasks.add(patchWorkflow.patchWarWorkflow(server, product));
+ }
+ if (product.name == "eXoDMS") {
+ if (product.useWorkflow || useWorkflowPlg || enableWorkflow) {
+ if (enableWorkflow) {
+ var patchWorkflow = eXo.server.WorkflowConfig;
+ tasks.add(patchWorkflow.patchWarWorkflow(server, product));
+ }
+ }
+ }
+ if (server.name == "ear") {
+ tasks.add(EarTask(server, product, version));
+ }
+
+ if (release_)
+ tasks.add(ReleaseTask(server, product, version));
+ }
+}
+/**
+ * Liveroom Deploys and configures Openfire Deploys a Red5 server automatically
+ * after deploying Liveroom
+ */
+if ((product.hasDependencyModule("liveroom") || productName == "liveroom") && deployServers != null) {
+ var liveroomModule = (product.module.name == "liveroom") ? product.module : product.getDependencyModule("liveroom");
+ liveroomModule.configure(tasks, deployServers, serverMap);
+}
+
+/**
+ * Deploy openfire for CS Chat application Deploys and configures Openfire
+ * Deploys a Red5 server automatically after deploying Liveroom
+ */
+if ((product.hasDependencyModule("cs") || productName == "cs") && deployServers != null) {
+ var csModule = (product.module.name == "cs") ? product.module : product.getDependencyModule("cs");
+ if (csModule.eXoApplication && csModule.eXoApplication.chat) {
+ csModule.configure(tasks, deployServers, serverMap);
+ }
+}
+
+for ( var i = 0; i < tasks.size(); i++) {
+ task = tasks.get(i);
+ var start = java.lang.System.currentTimeMillis();
+ task.banner();
+ task.execute();
+ task.executionTime = java.lang.System.currentTimeMillis() - start;
+ task.report();
+}
+java.lang.System.exit(0);
\ No newline at end of file
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/command/exoproject.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/command/exoproject.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/command/exoproject.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,107 @@
+eXo.require("eXo.server") ;
+eXo.require("eXo.server.Tomcat") ;
+eXo.require("eXo.command.maven") ;
+
+function exoproject() {
+ server = new Tomcat(eXo.env.workingDir + "/tomcat") ;
+};
+
+exoproject.prototype.ModuleDeploy = function() {
+ var maven = new eXo.command.maven() ;
+ var mvnArgs = ["clean","install"] ;
+ maven.MavenTask(eXo.env.currentDir, mvnArgs).execute() ;
+
+ src = new java.io.File("target") ;
+ var child = src.listFiles();
+ for(i = 0; i < child.length; i++) {
+ var file = child[i] ;
+ if(file.getName().endsWith(".jar")) {
+ eXo.System.info("COPY", file.getName() + " to " + server.deployLibDir) ;
+ eXo.core.IOUtil.cp(file.getAbsolutePath(), server.deployLibDir + "/" + file.getName()) ;
+ } else if(file.getName().endsWith(".war")) {
+ eXo.System.info("COPY", file.getName() + " to " + server.deployWebappDir) ;
+ eXo.core.IOUtil.cp(file.getAbsolutePath(), server.deployWebappDir + "/" + file.getName()) ;
+ }
+ }
+}
+
+exoproject.prototype.QuickWarDeploy = function() {
+ var maven = new eXo.command.maven() ;
+ var mvnArgs = ["compile", "jar:jar"] ;
+ maven.MavenTask(eXo.env.currentDir, mvnArgs).execute() ;
+
+ var dest = new java.io.File("src/main/webapp/WEB-INF/lib") ;
+ if(!dest.exists()) dest.mkdir() ;
+ src = new java.io.File("target") ;
+ var child = src.listFiles();
+ for(var i = 0; i < child.length; i++) {
+ var file = child[i] ;
+ if(file.getName().endsWith(".jar")) {
+ eXo.System.info("COPY", file.getName() + " to " + server.deployLibDir) ;
+ eXo.core.IOUtil.cp(file.getAbsolutePath(), "src/main/webapp/WEB-INF/lib/" + file.getName()) ;
+ } else if(file.getName().endsWith(".war")) {
+ var jarDir = new java.io.File(file.getAbsolutePath().substring(0, file.getAbsolutePath().length() - 4) + "/WEB-INF/lib") ;
+ if(jarDir.exists()) {
+ var jarChild = jarDir.listFiles();
+ for(var j = 0; j < jarChild.length; j++) {
+ var jarFile = jarChild[j] ;
+ eXo.System.info("COPY", jarFile.getName() + " to " + server.deployLibDir) ;
+ eXo.core.IOUtil.cp(jarFile.getAbsolutePath(), "src/main/webapp/WEB-INF/lib/" + jarFile.getName()) ;
+ }
+ }
+ }
+ }
+}
+
+exoproject.prototype.ContextDeploy = function() {
+ var folder = new java.io.File("src/main/resources/tomcat") ;
+ var child = folder.listFiles();
+ var destination = server.serverHome + "/conf/Catalina/localhost" ;
+ for(var i = 0; i < child.length; i++) {
+ var file = child[i] ;
+ if(file.getName().endsWith(".xml")) {
+ eXo.System.info("COPY", file.getName() + " to " + destination) ;
+ eXo.core.IOUtil.cp(file.getAbsolutePath(), destination + "/" + file.getName()) ;
+ }
+ }
+}
+
+function printInstructions() {
+ print(
+ "\n\n" +
+ "Usage of exoproject command: \n\n" +
+ " exoproject --deploy=[context,module,quickwar] [--server=tomcat,jboss,jonas,ear,jbossear] \n\n" +
+ "Options: \n" +
+ " * --deploy is mandatory. Enables to deploy either a context, a module (jar) or a war.\n" +
+ " * --server is optional. Enables to specify the target application server.\n"
+ );
+ }
+
+var args = arguments;
+
+if(args.length == 0) {
+ printInstructions() ;
+ java.lang.System.exit(1);
+}
+
+exoproject = new exoproject() ;
+for(var i = 0; i < args.length; i++) {
+ var arg = args[i] ;
+ if("--server=jonas".equals(arg)) {
+ exoproject.server = Jonas(eXo.env.workingDir + "/jonas") ;
+ } else if("--server=jboss".equals(arg)) {
+ exoproject.server = Jboss(eXo.env.workingDir + "/jboss") ;
+ } else if("--server=jbossear".equals(arg)) {
+ exoproject.server = JbossEar(eXo.env.workingDir + "/jboss") ;
+ } else if("--server=ear".equals(arg)) {
+ exoproject.server = Ear(eXo.env.workingDir + "/ear") ;
+ } else if("--server=tomcat".equals(arg)) {
+ exoproject.server = Tomcat(eXo.env.workingDir + "/tomcat") ;
+ } else if("--deploy=context".equals(arg)) {
+ exoproject.ContextDeploy() ;
+ } else if("--deploy=module".equals(arg)) {
+ exoproject.ModuleDeploy() ;
+ } else if("--deploy=quickwar".equals(arg)) {
+ exoproject.QuickWarDeploy() ;
+ }
+}
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/command/exosvn.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/command/exosvn.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/command/exosvn.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,152 @@
+eXo.require("eXo.core.TaskDescriptor") ;
+eXo.require("eXo.core.Util") ;
+
+function exosvn() {
+
+};
+
+function exosvnInstructions() {
+ print(
+ "\n" +
+ "Use of the exosvn command: \n\n" +
+ " exosvn \n" +
+ " [add]\n" +
+ " [rm]\n" +
+ "\n\n" +
+ "Options: \n" +
+ " * add looks for new files in the project and adds them in svn\n" +
+ " * rm looks for file to remove from svn\n"
+ );
+}
+
+exosvn.prototype.Param = function(args) {
+ var param = {} ;
+ for(var i = 0; i < args.length; i++ ) {
+ if(args[i].match("--include=")) {
+ param.include = args[i].substring("--include=".length()) ;
+ } else if(args[i].match("--exclude=")) {
+ param.exclude = args.substring("--exclude=".length()) ;
+ } else {
+ param.workingDir = args[i] ;
+ }
+ }
+ return param ;
+}
+
+exosvn.prototype.MatchFile = function (param) {
+ var matcher = {} ;
+ matcher.proc = java.lang.Runtime.getRuntime().exec("svn st " + param.workingDir) ;
+ matcher.files = new java.util.ArrayList() ;
+ var din = new java.io.DataInputStream(matcher.proc.getInputStream() );
+
+ while( (line=din.readLine()) != null ) {
+ if(line.matches(param.include) && !line.matches(param.exclude)) {
+ matcher.files.add(line) ;
+ print(line);
+ }
+ }
+ // waits for the process to end before returns
+ while (matcher.proc.waitFor() != 0) {}
+ return matcher ;
+}
+
+exosvn.prototype.AddTask = function(args) {
+ var descriptor = new TaskDescriptor("svn add", "") ;
+
+ descriptor.execute = function() {
+ param = exosvn.Param(args) ;
+ if(param.workingDir == null) param.workingDir = descriptor.workingDir ;
+ // includes all lines beginning with '?' and followed by any characters
+ if(param.include == null) param.include = "^\\?.*" ;
+ // excludes the 'target' directory and files created by eclipse (.classpath; .settings; .project; .wtpmodules)
+ if(param.exclude == null) param.exclude = ".*\.classpath$|.*\.settings$|.*\.project$|.*\.wtpmodules$|.*target$";
+ java.lang.System.setProperty("user.dir", param.workingDir) ;
+
+ matches = exosvn.MatchFile(param) ;
+ proc = matches.proc ;
+ var exitValue = proc.exitValue();
+ if(exitValue == 0 && matches.files.size() > 0) {
+ var input = eXo.System.readInput("Do you want to add the above files[yes] ?") ;
+ if("yes".equals(input)) {
+ var b = new java.lang.StringBuilder() ;
+ b.append("svn add ");
+ for(i = 0; i < matches.files.size();i++) {
+ b.append(matches.files.get(i).substring(6));
+ }
+ proc = java.lang.Runtime.getRuntime().exec(b.toString()) ;
+ }
+ } else {
+ print("Cannot perform the svn command, svn exit with the code " + exitValue);
+ }
+ errStream = new java.io.DataInputStream( proc.getInputStream() );
+ while( (line = errStream.readLine()) != null ) print(line) ;
+ }
+ return descriptor ;
+}
+
+//exosvn.prototype.UpdateTask = function(module) {
+//
+// var task = new TaskDescriptor("svn update", module) ;
+// task.description = "Run svn update again module " + module ;
+//
+// task.execute = function() {
+// java.lang.Runtime.getRuntime().exec("svn update " + module) ;
+// var args = ['svn', 'update', module] ;
+// print("Module: " + module) ;
+// var result = eXo.System.run(args, true, true) ;
+// }
+// return task;
+//}
+
+exosvn.prototype.RemoveTask = function(args) {
+ var descriptor = new TaskDescriptor("svn remove", "") ;
+
+ descriptor.execute = function() {
+ param = exosvn.Param(args) ;
+ if(param.workingDir == null) param.workingDir = descriptor.workingDir ;
+ if(param.include == null) param.include = "^\\!.*" ;
+ java.lang.System.setProperty("user.dir", param.workingDir) ;
+
+ matches = exosvn.MatchFile(param) ;
+ proc = matches.proc ;
+ var exitValue = proc.exitValue();
+ if(exitValue == 0 && matches.files.size() > 0) {
+ var input = eXo.System.readInput("Do you want to remove the above files[yes] ?") ;
+ if("yes".equals(input)) {
+ var b = new java.lang.StringBuilder() ;
+ b.append("svn rm ");
+ for(i = 0; i < matches.files.size();i++) {
+ b.append(matches.files.get(i).substring(6));
+ }
+ proc = java.lang.Runtime.getRuntime().exec(b.toString()) ;
+ }
+ } else {
+ print("Cannot perform the svn command, svn exit with the code " + exitValue);
+ }
+ errStream = new java.io.DataInputStream( proc.getInputStream() );
+ while( (line = errStream.readLine()) != null ) print(line) ;
+ }
+
+ return descriptor ;
+}
+
+eXo.command.exosvn = exosvn.prototype.constructor ;
+
+
+var args = arguments;
+
+if(args.length == 0) {
+ exosvnInstructions() ;
+ java.lang.System.exit(1);
+} else {
+ exosvn = new exosvn();
+
+ var svncommand = args[0] ;
+ args = eXo.core.Util.shift(args) ;
+
+ if ("add".equals(svncommand)) {
+ exosvn.AddTask(args).execute() ;
+ } else if ("rm".equals(svncommand)) {
+ exosvn.RemoveTask(args).execute() ;
+ }
+}
\ No newline at end of file
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/command/maven.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/command/maven.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/command/maven.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,38 @@
+eXo.require("eXo.core.TaskDescriptor");
+
+function maven() {
+
+}
+maven.prototype.MavenTask = function(projectDir, args) {
+ var descriptor = new TaskDescriptor("Maven Task", projectDir) ;
+ descriptor.description = "Run mvn " + args + " against module " + projectDir ;
+ descriptor.projectDir = projectDir;
+ descriptor.mavenArgs = args;
+
+ descriptor.execute = function() {
+ var m2Home= eXo.env.m2Home ;
+ java.lang.System.setProperty("maven.home", m2Home) ;
+ java.lang.System.setProperty("classworlds.conf", m2Home + "/bin/m2.conf") ;
+
+ java.lang.System.setProperty("user.dir", this.workingDir) ;
+ print("path: " + m2Home) ;
+ var mvnClasspath = [
+ new java.net.URL("file:" + m2Home + "/core/boot/classworlds-1.1.jar"),
+ new java.net.URL("file:" + m2Home + "/boot/classworlds-1.1.jar")
+ ] ;
+
+ var contextLoader= java.lang.Thread.currentThread().getContextClassLoader();
+ var mvnLoader = new java.net.URLClassLoader(mvnClasspath, contextLoader);
+ java.lang.Thread.currentThread().setContextClassLoader(mvnLoader);
+ var type = mvnLoader.loadClass("org.codehaus.classworlds.Launcher") ;
+ var exitCode = type.newInstance().mainWithExitCode(this.mavenArgs);
+ java.lang.System.gc() ;
+ if(exitCode != 0) {
+ throw new java.lang.Exception("BUILD MODULE :" + this.workingDir + " FAILED");
+ }
+ java.lang.Thread.currentThread().setContextClassLoader(contextLoader);
+ }
+ return descriptor ;
+}
+
+eXo.command.maven = maven.prototype.constructor ;
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/command/svn.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/command/svn.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/command/svn.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,23 @@
+eXo.require("eXo.core.TaskDescriptor") ;
+eXo.require("eXo.core.Util") ;
+
+function svn() {
+
+};
+
+
+svn.prototype.UpdateTask = function(module) {
+
+ var task = new TaskDescriptor("svn update", module) ;
+ task.description = "Run svn update on module " + module ;
+
+ task.execute = function() {
+ var args = ['svn', 'update', module] ;
+ print("Module: " + module) ;
+ // Runs the command
+ var result = eXo.System.run(args, true, true) ;
+ }
+ return task;
+}
+
+eXo.command.svn = svn.prototype.constructor ;
\ No newline at end of file
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/core/IOUtil.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/core/IOUtil.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/core/IOUtil.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,338 @@
+function IOUtil() {
+}
+
+IOUtil.prototype.shift = function(args) {
+ if(args.length == 0) return args ;
+ var newargs = new Array() ;
+ for(var i = 0; i < args.length - 1; i++) newargs[i] = args[i + 1] ;
+ return newargs ;
+}
+
+
+IOUtil.prototype.emptyFolder = function(folder) {
+ if(typeof(folder) == 'string') {
+ this.emptyFolder(new java.io.File(folder)) ;
+ } else {
+ if(folder.exists() && folder.isDirectory()) {
+ var child = folder.listFiles();
+ for(var i = 0; i < child.length; i++) {
+ var file = child[i]
+ if(file.isDirectory()) this.emptyFolder(file) ;
+ var method = file.getClass().getMethod('delete', null);
+ var result = method.invoke(file, null);
+ if(result) {
+ eXo.System.vinfo("[DELETE] " + file.getAbsolutePath());
+ } else {
+ print("[ERROR] Cannot delete " + file.getAbsolutePath());
+ }
+ }
+ }
+ }
+}
+
+IOUtil.prototype.remove = function(path) {
+ var file = path ;
+ if(typeof(path) == 'string') file = new java.io.File(path) ;
+
+ if(file.exists()) {
+ this.emptyFolder(file) ;
+ var method = file.getClass().getMethod('delete', null);
+ var result = method.invoke(file, null);
+ if(result) {
+ eXo.System.vinfo("[DELETE] " + file.getAbsolutePath());
+ } else {
+ print("[ERROR] Cannot delete " + file.getAbsolutePath());
+ }
+ } else {
+ print("[ERROR] Cannot find " + path);
+ }
+}
+
+IOUtil.prototype.createByteArray = function(size) { // creates an array of 2^size bytes
+ var buff = new java.io.ByteArrayOutputStream(size) ;
+ buff.write(1) ;
+ for(var i = 0; i < size; i++) {
+ var innerBuff = buff.toByteArray() ;
+ buff.write(innerBuff, 0, innerBuff.length) ;
+ }
+ var bytes = buff.toByteArray() ;
+ return bytes ;
+}
+
+IOUtil.prototype.cp = function(src, dest) {
+ var srcFolder = new java.io.File(src) ;
+ if(!srcFolder.exists()) {
+ throw(src + " does not exist") ;
+ } else if(srcFolder.isFile()) {
+ var destFolder = new java.io.File(dest);
+ if (destFolder.isFile()) {
+ dest = destFolder.getParent();
+ }
+ if (destFolder.exists()) {
+ dest = dest + "/" + srcFolder.getName();
+ }
+ var input = new java.io.FileInputStream(srcFolder) ;
+ var output = new java.io.FileOutputStream(dest) ;
+ var buff = this.createByteArray(12) ;
+ var len = 0 ;
+ while ((len = input.read(buff)) > 0) {
+ output.write(buff, 0, len);
+ }
+ input.close();
+ output.close();
+ this.chmod(srcFolder,dest)
+ eXo.System.vinfo("COPY", "Copy file " + src) ;
+ } else {
+ var destFolder = new java.io.File(dest) ;
+ if(!destFolder.exists()) {
+ destFolder.mkdirs() ;
+ eXo.System.vinfo("MKDIR", "Create a directory " + dest) ;
+ }
+ var child = srcFolder.listFiles();
+ for(var i = 0; i < child.length; i++) {
+ var file = child[i] ;
+ if(file.isFile()) {
+ this.cp(file.getAbsolutePath(),
+ destFolder.getAbsolutePath() + "/" + file.getName());
+ } else {
+ this.cp(file.getAbsolutePath(),
+ destFolder.getAbsolutePath() + "/" + file.getName());
+ }
+ }
+ }
+}
+
+IOUtil.prototype.createFile = function(path, content) {
+ var tmp = new java.lang.String(content) ;
+ var bytes = tmp.getBytes() ;
+ var out = new java.io.FileOutputStream(path);
+ out.write(bytes, 0, bytes.length);
+ out.close();
+ eXo.System.vinfo("NEW", "Create file " + path) ;
+}
+
+IOUtil.prototype.createFolder = function(path) {
+ var folder = new java.io.File(path);
+ if(!folder.exists()) {
+ folder.mkdirs();
+ eXo.System.vinfo("MKDIR", "Create a directory " + path) ;
+ } else {
+ eXo.System.vinfo("INFO", "Directory is exists" ) ;
+ }
+}
+
+IOUtil.prototype.patchWar = function(warFile, properties, templateEntry, destEntry, mentries) {
+ print("[PATCH WAR]" + warFile.getName());
+ if (this.getJarEntryContent(warFile, templateEntry) != null) {
+ var configTmpl = this.getJarEntryAsText(warFile, templateEntry);
+ eXo.System.info("CONF", "Filtering war entry " + templateEntry + " > " + destEntry);
+ var config = eXo.core.Util.modifyText(configTmpl, properties) ;
+ mentries.put(destEntry, config.getBytes()) ;
+ } else {
+ eXo.System.info("CONF", "Failed to filer war entry " + templateEntry);
+ java.lang.System.exit(1);
+ }
+ return mentries;
+}
+
+IOUtil.prototype.getJarEntryContent = function(fileName, entryName) {
+ var file = new java.io.File(fileName);
+ if (!file.exists()) {
+ eXo.System.info("IO", "" + fileName + " file not found" ) ;
+ return null;
+ }
+ eXo.System.info("IO", "Opening " + file);
+ var jar = new java.util.jar.JarFile(file) ;
+ var entries = jar.entries() ;
+ while(entries.hasMoreElements()) {
+ var entry = entries.nextElement() ;
+ if(entry.getName() == entryName) {
+ var entryStream = jar.getInputStream(entry);
+ var buffer = this.createByteArray(12) ;
+ var bytesRead;
+ var out = new java.io.ByteArrayOutputStream();
+ while ((bytesRead = entryStream.read(buffer)) != -1) {
+ out.write(buffer, 0, bytesRead);
+ }
+ entryStream.close();
+ jar.close() ;
+ return out.toByteArray() ;
+ }
+ }
+ jar.close() ;
+ return null;
+}
+
+IOUtil.prototype.getJarEntryAsText = function(fileName, entryName) {
+ return new java.lang.String(this.getJarEntryContent(fileName, entryName));
+}
+
+IOUtil.prototype.modifyJarEntry = function(moduleFile, configEntry, properties) {
+ var file = new java.io.File(moduleFile) ;
+ if(!file.exists()) return ;
+ var content = this.getJarEntryAsText(moduleFile, configEntry) ;
+ var i = properties.entrySet().iterator();
+ while(i.hasNext()) {
+ var entry = i.next() ;
+ content = content.replace(entry.getKey(), entry.getValue()) ;
+ }
+
+ mentries = new java.util.HashMap() ;
+ mentries.put(configEntry, content.getBytes("UTF-8")) ;
+ eXo.core.IOUtil.modifyJar(moduleFile, mentries, null);
+}
+
+/**
+ * This method allow you to modify the content of one/multiple entries and the manifiest of
+ * a jar file.
+ *
+ * fileName: The absolute path to the jar file that you want to modify
+ * entries: A java.util.Map object. The key should be the entry name that you want to
+ * modify, and the value should be a java byte array (byte[])
+ */
+IOUtil.prototype.modifyJar = function(fileName, mentries, mattrs) {
+ print("[MODIFY JAR]" + fileName);
+ var file = new java.io.File(fileName);
+ var jar = new java.util.jar.JarFile(fileName) ;
+ var mf = jar.getManifest() ;
+ if(mattrs != null) {
+ var i = mattrs.entrySet().iterator();
+ while(i.hasNext()) {
+ var entry = i.next();
+ mf.getMainAttributes().putValue(entry.getKey(), entry.getValue()) ;
+ }
+ }
+ var tmpFile = new java.io.File(fileName + ".tmp") ;
+ var jos = new java.util.jar.JarOutputStream(new java.io.FileOutputStream(tmpFile), mf) ;
+ var entries = jar.entries() ;
+ var buffer = this.createByteArray(12) ;
+ var bytesRead;
+ while(entries.hasMoreElements()) {
+ var entry = entries.nextElement() ;
+ var entryName = entry.getName() ;
+ if(entryName.match("MANIFEST.MF")) {
+ } else if(mentries != null && mentries.containsKey(entryName)) {
+ entry = new java.util.jar.JarEntry(entryName) ;
+ jos.putNextEntry(entry) ;
+ var content = mentries.get(entryName) ;
+ jos.write(content, 0, content.length) ;
+ mentries.remove(entryName) ;
+ } else {
+ var entryStream = jar.getInputStream(entry);
+ jos.putNextEntry(entry) ;
+ while ((bytesRead = entryStream.read(buffer)) != -1) jos.write(buffer, 0, bytesRead);
+ }
+ }
+ jar.close() ;
+ jos.close() ;
+ this.remove(file) ;
+ tmpFile.renameTo(file) ;
+}
+
+IOUtil.prototype.addToArchive = function(zosStream, entryPath, file) {
+ eXo.System.info("ADDTOARCHIVE", entryPath + file.getName()) ;
+ if (entryPath != null && entryPath != "")
+ entryPath += "/";
+
+ if(file.isDirectory()) {
+ var children = file.listFiles() ;
+ for(var i = 0; i < children.length; i++) {
+ this.addToArchive(zosStream, entryPath + file.getName(), children[i]) ;
+ }
+ } else {
+ zosStream.putNextEntry(new java.util.zip.ZipEntry(entryPath + file.getName()));
+ if (this.log)
+ eXo.System.info("DEPLOY", entryPath + file.getName()) ;
+ var fis = new java.io.FileInputStream(file);
+ var buf = this.createByteArray(12) ;
+ var len = -1;
+ while((len = fis.read(buf)) > 0) {
+ zosStream.write(buf, 0, len);
+ }
+ fis.close();
+ }
+}
+
+IOUtil.prototype.zip = function(src, dest, zipName) {
+ var srcFile = new java.io.File(src) ;
+ if(!srcFile.exists()) {
+ eXo.System.vinfo("INFO", "File Not Exist " + srcFile.getAbsolutePath()) ;
+ java.lang.System.exit(1) ;
+ }
+ var destDir = new java.io.File(dest);
+ if(!destDir.exists()) destDir.mkdirs() ;
+ var destFile = new java.io.File(dest + "/" + zipName + ".zip");
+ this.remove(destFile) ;
+ var zos = new java.util.zip.ZipOutputStream(new java.io.FileOutputStream(destFile));
+ if(srcFile.isDirectory()) {
+ var children = srcFile.listFiles() ;
+ for(var i = 0; i < children.length; i++) {
+ this.addToArchive(zos, zipName, children[i]) ;
+ }
+ } else {
+ this.addToArchive(zos, zipName, srcFile) ;
+ }
+ zos.close() ;
+}
+
+IOUtil.prototype.ear = function(src, dest) {
+ this.log = true;
+ var srcFile = new java.io.File(src) ;
+ if(!srcFile.exists()) {
+ eXo.System.vinfo("INFO", "File Not Exist " + srcFile.getAbsolutePath()) ;
+ java.lang.System.exit(1) ;
+ }
+ var destDir = new java.io.File(dest.substring(0, dest.lastIndexOf("/")));
+ if(!destDir.exists()) destDir.mkdirs() ;
+ var destFile = new java.io.File(dest);
+ this.remove(destFile) ;
+ var zos = new java.util.zip.ZipOutputStream(new java.io.FileOutputStream(destFile));
+ if(srcFile.isDirectory()) {
+ var children = srcFile.listFiles() ;
+ for(var i = 0; i < children.length; i++) {
+ this.addToArchive(zos, "", children[i]) ;
+ }
+ } else {
+ this.addToArchive(zos, "", srcFile) ;
+ }
+ zos.close() ;
+ this.log = false;
+}
+
+IOUtil.prototype.chmod = function(srcFolder, dest) {
+ if (!java.lang.System.getProperty("os.name").startsWith("Windows")) {
+ try{
+ java.lang.Runtime.getRuntime().exec("chmod --reference=" + srcFolder + " " + dest );
+ } catch(error) {
+ }
+ }
+}
+
+IOUtil.prototype.chmodExecutable = function(dest) {
+ if (!java.lang.System.getProperty("os.name").startsWith("Windows")) {
+ try{
+ print("chmod +x on " + dest);
+ java.lang.Runtime.getRuntime().exec("chmod +x " + dest );
+ } catch(error) {
+ }
+ }
+}
+
+IOUtil.prototype.chmodExecutableInDir = function(dirName, extension) {
+ //Executable .sh
+ var binDir = new java.io.File(dirName);
+ if (binDir.isDirectory()){
+ var files = binDir.listFiles();
+ for (i = 0; i < files.length; i++) {
+ var fileChild = files[i];
+ if (fileChild.getName().endsWith(extension)){
+ eXo.core.IOUtil.chmodExecutable(fileChild);
+ }
+ }
+ }
+ }
+
+eXo.core.IOUtil = new IOUtil() ;
+
+//var test = eXo.core.IOUtil.getJarEntryContent("target/exo.tool.build-2.0.jar", "linux/exobuild.sh");
+//print (new java.lang.String(test));
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/core/TaskDescriptor.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/core/TaskDescriptor.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/core/TaskDescriptor.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,47 @@
+TaskDescriptor = function (taskName, wd) {
+ this.name = taskName ;
+ this.description = "" ;
+ this.workingDir = wd ;
+ this.message = "" ;
+ this.executionTime = 0 ;
+
+ this.banner = function () {
+ print("--------------------------- RUNNING TASK ------------------------------------") ;
+ print("TASK : " + this.name) ;
+ print("DESCRIPTION : " + this.description) ;
+ print("WORKING DIR : " + this.workingDir) ;
+ print("-----------------------------------------------------------------------------") ;
+ }
+
+ this.execute = function () {
+ print("You Need to override this method") ;
+ }
+
+ this.report = function() {
+ print("-----------------------------------------------------------------------------") ;
+ print("TASK : " + this.name) ;
+ print("DESCRIPTION : " + this.description) ;
+ print("WORKING DIR : " + this.workingDir) ;
+ print("MESSAGE : " + this.message)
+ print("EXECUTION TIME : " + (this.executionTime/1000) + "s") ;
+ print("-----------------------------------------------------------------------------\n") ;
+ }
+}
+
+/*
+var task1 = new TaskDescriptor("task1", "target");
+var task2= new TaskDescriptor("task2", "target");
+
+task2.execute = function() {
+ print("execute task 2") ;
+}
+
+var tasks = [task1, task2] ;
+print("\n");
+
+for(var i = 0; i < tasks.length; i++) {
+ tasks[i].banner();
+ tasks[i].execute();
+ tasks[i].report();
+}
+*/
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/core/Util.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/core/Util.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/core/Util.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,21 @@
+function Util() {
+
+}
+
+Util.prototype.shift = function(args) {
+ if(args.length == 0) return args ;
+ var newargs = new Array() ;
+ for(var i = 0; i < args.length - 1; i++) newargs[i] = args[i + 1] ;
+ return newargs ;
+}
+
+Util.prototype.modifyText = function(content, properties) {
+ var i = properties.entrySet().iterator();
+ while(i.hasNext()) {
+ var entry = i.next() ;
+ content = content.replace(entry.getKey(), entry.getValue()) ;
+ }
+ return content
+}
+
+eXo.core.Util = new Util() ;
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/eXo.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/eXo.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/eXo.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,112 @@
+function Env() {
+
+ print("******************************************");
+ print("* eXo Package version embeeded in GateIn *");
+ print("******************************************");
+
+ this.eXoPackageHome = java.lang.System.getProperty("exo.package.home");
+ print("* eXoPackageHome : " + this.eXoPackageHome);
+
+ this.baseDir = java.lang.System.getProperty("exo.base.dir");
+ print("* BaseDir : " + this.baseDir);
+
+ this.workingDir = java.lang.System.getProperty("exo.working.dir");
+ if (this.workingDir == null || this.workingDir.equals("")) {
+ this.workingDir = this.baseDir + "/exo-working";
+ }
+ print("* workingDir : " + this.workingDir);
+
+ this.eXoConfDir = java.lang.System.getProperty("exo.conf.dir");
+ print("* eXoConfDir : " + this.eXoConfDir);
+
+ this.dependenciesDir = java.lang.System.getProperty("exo.dep.dir");
+ if (this.dependenciesDir == null || this.dependenciesDir.equals(""))
+ this.dependenciesDir = this.baseDir + "/exo-dependencies";
+ print("* dependenciesDir : " + this.dependenciesDir);
+
+ this.eXoProjectsDir = java.lang.System.getProperty("exo.src.dir");
+ if (this.eXoProjectsDir == null || this.eXoProjectsDir.equals(""))
+ this.eXoProjectsDir = this.baseDir + "/eXoProjects";
+ print("* eXoProjectsDir : " + this.eXoProjectsDir);
+
+ this.javaHome = java.lang.System.getProperty("java.home");
+ print("* javaHome : " + this.javaHome);
+ this.currentDir = java.lang.System.getProperty("exo.current.dir");
+ print("* currentDir : " + this.currentDir);
+
+ if (this.currentDir.startsWith("/cygdrive/")) {
+ this.currentDir = this.currentDir.substring("/cygdrive/".length);
+ this.currentDir = this.currentDir.replaceFirst("/", ":/");
+ }
+ print("* currentDir : " + this.currentDir);
+
+ this.m2Home = java.lang.System.getProperty("exo.m2.home");
+ if (this.m2Home == null || this.m2Home.equals(""))
+ this.m2Home = this.baseDir + "/maven2";
+ print("* m2Home : " + this.m2Home);
+
+ print("* m2Repos : " + java.lang.System.getProperty("exo.m2.repos"));
+ var m2Repos = java.lang.System.getProperty("exo.m2.repos").split(",");
+ this.m2Repos = new Array();
+ var j = 0;
+ for ( var i = 0; i < m2Repos.length; i++)
+ if (m2Repos[i].trim() != "")
+ this.m2Repos[j++] = m2Repos[i].trim();
+
+ this.cleanServer = java.lang.System.getProperty("clean.server");
+ print("* cleanServer : " + this.cleanServer);
+ print("********************************");
+
+}
+
+var eXo = {
+ core : {},
+ projects : {},
+ server : {},
+ command : {},
+
+ env :new Env(),
+
+ require : function(module, jsLocation) {
+ try {
+ if (eval(module + ' != null'))
+ return;
+ } catch (err) {
+ print("[ERROR] err : " + module);
+ java.lang.System.exit(1);
+ }
+ if (jsLocation == null) {
+ jsLocation = eXo.env.eXoPackageHome + '/javascript/';
+ }
+ var path = jsLocation + module.replace(/\./g, '/') + '.js';
+ try {
+ load(path);
+ } catch (err) {
+ print("[ERROR] Cannot load the javascript module " + module + " from " + jsLocation);
+ print(err);
+ }
+ },
+
+ load : function(relativePath, jsLocation) {
+ if (jsLocation == null) {
+ jsLocation = eXo.env.eXoPackageHome + '/javascript/';
+ }
+ var path = jsLocation + '/' + relativePath;
+ print("Loading path : " + path);
+ try {
+ load(path);
+ } catch (err) {
+ print("Cannot load the javascript module " + relativePath + " from " + jsLocation);
+ print(err);
+ }
+ }
+};
+
+eXo.require("eXo.System");
+eXo.require("eXo.core.Util");
+
+if (arguments.length > 0) {
+ var command = arguments[0];
+ arguments = eXo.core.Util.shift(arguments);
+ eXo.require("eXo.command." + command);
+}
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/projects/Module.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/projects/Module.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/projects/Module.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,43 @@
+eXo.require("eXo.projects.Project");
+
+function Module() {
+ this.version = null;
+ this.relativeMavenRepo = null;
+ this.relativeSRCRepo = null;
+ this.name = null;
+}
+
+Module.GetModule = function(path, params) {
+ // Try to load the module descriptor corresponding to the specified name and
+ // version
+// var srcPath = "/modules/" + path + "/";
+// var srcConf = eXo.env.eXoConfDir + srcPath;
+// var srcLoc = eXo.env.currentDir + srcPath;
+//
+// // eXo.System.info("Opening " + src);
+// print("Loading module: " + srcPath);
+// if (new java.io.File(srcLoc+"module.js").exists()) {
+// // Local
+// eXo.load("module.js", srcLoc);
+// } else {
+// // Sinon configuration
+// eXo.load("module.js", srcConf);
+// }
+ var srcName = path + ".packaging.module.js";
+ var srcConf = eXo.env.eXoConfDir;
+
+ // eXo.System.info("Opening " + src);
+ print("Loading: " + srcName + " ( in " + srcConf + ")");
+ eXo.load(srcName, srcConf);
+
+
+ try {
+ // The function getModule() is defined in the loaded module descriptor
+ return getModule(params);
+ } catch (error) {
+ print("ERROR while loading module descriptor (name=\"" + name
+ + "\", version=\"" + version + "\"). Perhaps it is missing.");
+ java.lang.System.exit(1);
+ }
+ return null;
+}
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/projects/Product.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/projects/Product.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/projects/Product.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,197 @@
+eXo.require("eXo.core.TaskDescriptor");
+
+function Product() {
+ this.name = null;
+ this.portalwar = null;
+ this.codeRepo = null;
+ this.dependenciesHolder = new java.util.HashMap();
+ this.serverPatches = new java.util.HashMap();
+
+ this.module = null;
+ this.useWorkflow = false;
+ this.useContentValidation = false;
+ this.dependencyModule = null;
+ this.serverPluginVersion = "trunk";
+}
+
+Product.prototype.getVersion = function() {
+
+};
+
+Product.GetProduct = function(name, version) {
+ // Try to load the product descriptor corresponding to the specified name
+ // and version
+
+ var srcName = name + ".packaging.product.js";
+ var srcConf = eXo.env.eXoConfDir;
+
+ // eXo.System.info("Opening " + src);
+ print("Loading: " + srcConf + "/" + srcName);
+ eXo.load(srcName, srcConf);
+
+// try {
+ // The function getProduct() is defined in the loaded product decriptor
+ var product = getProduct(version);
+
+ // Set the version on the product
+ product.version = version;
+
+ //
+ return product;
+// } catch (error) {
+// eXo.System.error("ERROR while loading product descriptor (name=\"" + name + "\").");
+// eXo.System.error(error);
+// throw error;
+// }
+}
+
+Product.prototype.addServerPatch = function(serverName, project) {
+ eXo.System.info("DEBUG", "Product.addServerPatch serverName = " + serverName);
+ var holders = this.serverPatches.get(serverName);
+ if (holders == null) {
+ holders = new java.util.ArrayList(3);
+ this.serverPatches.put(serverName, holders);
+ }
+ holders.add(project);
+}
+
+Product.prototype.getServerPatches = function(serverName) {
+ return this.serverPatches.get(serverName);
+}
+
+Product.prototype.addDependencies = function(project) {
+ try {
+ this.dependenciesHolder.put(project.relativePath, project);
+ if (project.hasDependency()) {
+ var list = project.dependencies;
+ for ( var i = 0; i < list.size(); i++) {
+ this.addDependencies(list.get(i));
+ }
+ }
+ } catch (error) {
+ print("Error while adding dependencies for project " + project);
+ throw error;
+ }
+}
+
+Product.prototype.getDependencies = function() {
+ return this.dependenciesHolder.values();
+}
+
+Product.prototype.getDependency = function(project) {
+ return this.dependenciesHolder.get(project.relativePath);
+}
+
+Product.prototype.getDependencyById = function(depId) {
+ var arrDep = this.getDependencies().toArray();
+ for ( var i = 0; i < arrDep.length; i++) {
+ var project = arrDep[i];
+ if (project.artifactId == depId) {
+ return project;
+ }
+ }
+ return null;
+}
+
+Product.prototype.hasDependency = function(project) {
+ return this.dependenciesHolder.containsKey(project.relativePath);
+}
+
+Product.prototype.removeDependency = function(project) {
+ eXo.System.info("DELETE", "Remove dependency " + project.artifactId);
+ this.dependenciesHolder.remove(project.relativePath);
+}
+
+Product.prototype.removeDependencyById = function(projectId) {
+ var project = this.getDependencyById(projectId);
+ if (project !== null) {
+ this.removeDependency(project);
+ } else {
+ eXo.System.info("ERROR", "Dependency " + projectId + " doesn't exist !");
+ }
+}
+
+Product.prototype.removeDependencyByGroupId = function(groupId) {
+ var dependencies = new java.util.ArrayList();
+ var arrDep = this.getDependencies().toArray();
+ for ( var i = 0; i < arrDep.length; i++) {
+ var project = arrDep[i];
+ if (project.groupId == groupId) {
+ this.removeDependency(project);
+ }
+ }
+};
+
+Product.prototype.hasDependencyModule = function(depName) {
+ var hasDep = false;
+ if (this.dependencyModule !== null) {
+ for ( var i = 0; i < this.dependencyModule.length && !hasDep; i++)
+ hasDep = (this.dependencyModule[i].name == depName);
+ }
+ return hasDep;
+};
+
+Product.prototype.getDependencyModule = function(depName) {
+ var mod = null;
+ if (this.hasDependencyModule(depName)) {
+ for ( var i = 0; i < this.dependencyModule.length && mod === null; i++) {
+ if (this.dependencyModule[i].name == depName)
+ mod = this.dependencyModule[i];
+ }
+ }
+ return mod;
+};
+
+/**
+ *
+ */
+Product.prototype.preDeploy = function() {
+ // TODO : to overwrite in your product definition
+ // like : product.cleanDependencies = function() { .. }
+};
+
+Product.prototype.DeployTask = function(product, server, repos) {
+ patches = product.getServerPatches(server.name);
+ eXo.System.info("INFO", "Add DeployTask for product '" + product.name
+ + "' version '" + product.codeRepo + "' on server '" + server.name
+ + "' with patches '" + patches + "'.");
+ if (patches == null) {
+ var msg = "The server " + server.name + " may not support this product: "
+ + product.name + ". Please try to use another server";
+ eXo.System.print("INFO", msg);
+ return;
+ }
+ var descriptor = new TaskDescriptor("Deploy Product", server.serverHome);
+ descriptor.execute = function() {
+ eXo.System.info("DELETE", "Delete " + server.serverHome);
+ eXo.core.IOUtil.remove(server.serverHome);
+ if (server.name != "ear") {
+ eXo.System.info("COPY", "Copy a clean server " + server.cleanServer);
+ eXo.core.IOUtil.cp(eXo.env.dependenciesDir + "/" + server.cleanServer,
+ server.serverHome);
+ }
+ server.preDeploy(product);
+ product.preDeploy();
+ for ( var i = 0; i < patches.size(); i++) {
+ project = patches.get(i);
+ var message = "Patch the server " + server.name + " with project "
+ + project.artifactId + " " + project.version;
+ eXo.System.info("INFO", message);
+ new java.io.File(server.patchDir).mkdirs();
+ project.extractTo(repos, server.patchDir, "META-INF/maven.*");
+ }
+
+ eXo.System.info("INFO", "Deploying dependencies");
+ var i = product.getDependencies().iterator();
+ counter = 0;
+ while (i.hasNext()) {
+ dep = i.next();
+ dep.deployTo(repos, server);
+ server.onDeploy(dep);
+ counter++;
+ }
+ eXo.System.info("INFO", "Deployed total " + counter + " files");
+ server.postDeploy(product);
+ }
+ return descriptor;
+}
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/projects/Project.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/projects/Project.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/projects/Project.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,174 @@
+eXo.require("eXo.core.IOUtil") ;
+
+function Project(gid, id, ptype, version) {
+
+ // Uncomment for debugging
+ // print("Project.js: new Project(gid: " + gid + " id: " + id + " ptype: "+ ptype + " version: "+ version + " )");
+
+ this.groupId = gid ;
+ this.artifactId = id ;
+ this.version = version ;
+ this.type = ptype ;
+ this.deloyName = null ;
+
+ this.extension = ptype ;
+ if(ptype == "exo-portlet" || ptype == "exo-portal") this.extension = "war" ;
+ if(ptype == "exo-ear-jar") this.extension = "jar";
+ if(ptype == "exopc-war") this.extension = "exopc-war";
+ if(ptype == "exo-ear-rar") this.extension = "rar";
+ this.relativePath = gid.replace(/\./g, '/') + "/" + id + "/" + version + "/" +
+ id + "-" + version + "." + this.extension ;
+ this.artifact = gid + ":" + id + ":" + version + ":" + this.extension;
+ this.tomcatDependency = true ;
+ this.jbossDependency = true ;
+ this.jbossearDependency = true ;
+ this.earDependency = true ;
+ this.jonasDependency = true ;
+
+ this.dependencies = null ;
+}
+
+Project.prototype.setServerDependency = function (name, b) {
+ if("tomcat" == name) this.tomcatDependency = b ;
+ else if("jboss" == name) this.jbossDependency = b ;
+ else if("jbossear" == name) this.jbossearDependency = b ;
+ else if("ear" == name) this.earDependency = b ;
+ else if("jonas" == name) this.jonasDependency = b ;
+}
+
+Project.prototype.addDependency = function(project) {
+ if(this.dependencies == null) this.dependencies = new java.util.ArrayList() ;
+ this.dependencies.add(project) ;
+ return this ;
+}
+
+Project.prototype.hasDependency = function() {return this.dependencies != null ;}
+
+Project.prototype.extractTo = function(repository, dir, ignore) {
+ for( var i = 0; i < repository.length; i++) {
+ try {
+ var surl = repository[i] + "/" + this.relativePath;
+ var url = new java.net.URL(surl);
+ eXo.System.info("PATCH", "Fetching patch at " + repository[i] + "/" + this.relativePath);
+ var is = new java.util.jar.JarInputStream(url.openStream()) ;
+ var entry = is.getNextEntry() ;
+ while(entry != null) {
+ if(!entry.isDirectory()) {
+ var name = entry.getName() ;
+ if(ignore == null || !name.matches(ignore)) {
+ var file = new java.io.File(dir + "/" + name);
+ var parentFolder = new java.io.File(file.getParent()) ;
+ if(!parentFolder.exists()) parentFolder.mkdirs() ;
+ var out = new java.io.FileOutputStream(file) ;
+ var buf = new eXo.core.IOUtil.createByteArray(14) ;
+ var read = is.read(buf);
+ while(read != -1) {
+ out.write(buf, 0, read) ;
+ read = is.read(buf);
+ }
+ out.close();
+ if (file.getCanonicalPath().endsWith(".sh"))
+ IOUtil.prototype.chmodExecutable(file);
+ eXo.System.info("PATCH", dir + "/" + entry.getName()) ;
+ }
+ }
+ entry = is.getNextEntry() ;
+ }
+ is.close() ;
+ return ;
+ } catch(err) {
+ eXo.System.info(err.message);
+ if(i < (repository.length - 1)) eXo.System.info("Trying to download from the repo : " + repository[i+1]);
+ }
+
+ }
+ throw("Error while extracting the project : " + this.relativePath) ;
+}
+
+Project.prototype.deployTo = function(repository, server) {
+ for(var i = 0; i < repository.length; i++) {
+ try {
+ var surl = repository[i] + "/" + this.relativePath;
+ var url = new java.net.URL(surl);
+ //eXo.System.info("[DEPS] " + this.artifact);
+
+ var warName = null, fileName = null ;
+ if(this.deployName != null) {
+ warName = this.deployName;
+ } else {
+ warName = this.artifactId ;
+ var temp = warName.substring(warName.length - 7);
+ if(temp.match(".webapp")) {
+ warName = warName.substring(0, warName.lastIndexOf(".")) ;
+ }
+ warName = warName.substring(warName.lastIndexOf(".") + 1) ;
+ }
+
+ if(this.extension == "war") {
+ fileName = server.deployWebappDir + "/" + warName + ".war" ;
+ } else if(this.type == "exo-ear-jar") {
+ fileName = server.deployWebappDir + "/" + this.artifactId + ".jar" ;
+ } else if(this.type == "exo-ear-rar") {
+ fileName = server.deployWebappDir + "/" + this.artifactId + ".rar" ;
+ } else if(this.type == "ear") {
+ if (server.deployEarDir == null){
+ print("NO EAR DEPLOY DIR, by passing " + this.deployName);
+ return ;
+ }
+ fileName = server.deployEarDir + "/" + this.artifactId + ".ear" ;
+ } else if(this.type == "exopc-war") {
+ fileName = server.deployWebappDir + "/" + warName + ".war" ;
+ } else {
+ fileName = server.deployLibDir + "/" + this.artifactId + "-" +this.version + "." + this.type ;
+ }
+
+ var file = new java.io.File(fileName);
+ var parentFolder = new java.io.File(file.getParent()) ;
+ if(!parentFolder.exists()) parentFolder.mkdirs() ;
+ var out = new java.io.FileOutputStream(file) ;
+
+ //Check locally, download from maven if needed
+ var is = null ;
+ try {
+ is = url.openStream();
+ } catch (err1) {
+ eXo.System.info("Artifact " + this.artifact + " not found locally, searching in maven repos");
+ var mvnArgs = ["dependency:get", "-Dartifact=" + this.artifact, "-Dmaven.artifact.threads=1"] ;
+ maven.MavenTask(eXo.env.currentDir, mvnArgs).execute() ;
+ }
+
+ //Fetch the binary on the server
+ var is = url.openStream() ;
+ eXo.System.vprintIndentation() ;
+ eXo.System.vprint("[") ;
+ var buf = new eXo.core.IOUtil.createByteArray(14) ;
+ var read = 0, totalRead = 0, chunkOf100k = 0, chunkCount = 0 ;
+ while(read != -1) {
+ read = is.read(buf);
+ if(read > 0) {
+ out.write(buf, 0, read) ;
+ chunkOf100k += read ;
+ totalRead += read ;
+ if(chunkOf100k > 100000) {
+ chunkOf100k = chunkOf100k - 100000 ;
+ chunkCount++ ;
+ eXo.System.vprint(".");
+ }
+ }
+ }
+ for(i = chunkCount; i < 60; i++) eXo.System.vprint(" ") ;
+ eXo.System.vprint("] " + totalRead/1024 + "kb\n");
+ out.close();
+ is.close() ;
+ eXo.System.info("DEPLOY", fileName);
+ return ;
+ } catch(err) {
+ eXo.System.info(err.message);
+ if(i < (repository.length - 1)) {
+ eXo.System.info("Trying to download from the repo : " + repository[i+1]);
+ }
+ }
+ }
+ throw("Error while deploying the project : " + this.relativePath) ;
+}
+eXo.projects.Project = Project.prototype.constructor ;
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/projects/Workflow.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/projects/Workflow.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/projects/Workflow.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,73 @@
+eXo.require("eXo.core.IOUtil") ;
+eXo.require("eXo.core.TaskDescriptor") ;
+eXo.require("eXo.projects.Project");
+
+function Workflow(workflowName, workflowVersion) {
+ this.name = workflowName;
+ this.version = workflowVersion;
+}
+
+Workflow.prototype.configWorkflow = function(product) {
+
+print("Workflow.js: Configuring workflow version: " + this.version + " name: "+this.name);
+
+ product.addDependencies(this.getPortlet());
+ if(this.name == "jbpm") {
+ print("Workflow.js: adding dependencies for jbpm");
+ product.addDependencies(new Project("org.exoplatform.ecm.workflow", "exo.ecm.workflow.component.workflow.impl.jbpm.facade", "jar", this.version));
+ product.addDependencies(new Project("org.exoplatform.ecm.workflow", "exo.ecm.workflow.component.workflow.impl.jbpm.engine", "jar", "3.0"));
+ product.addDependencies(new Project("org.exoplatform.ecm.workflow.bp", "exo.ecm.workflow.bp.jbpm.payraise", "jar", this.version));
+ product.addDependencies(new Project("org.exoplatform.ecm.workflow.bp", "exo.ecm.workflow.bp.jbpm.holiday", "jar", this.version));
+ if (product.useContentvalidation) {
+ product.addDependencies(new Project("org.exoplatform.ecm.dms.ext.contentvalidation", "exo.ecm.dms.ext.contentvalidation.component.jbpmconfig", "jar", product.contentvalidationVersion));
+ product.addDependencies(new Project("org.exoplatform.ecm.dms.ext.contentvalidation.bp", "exo.ecm.dms.ext.contentvalidation.bp.jbpm.content.publishing", "jar", product.contentvalidationVersion));
+ product.addDependencies(new Project("org.exoplatform.ecm.dms.ext.contentvalidation", "exo.ecm.dms.ext.contentvalidation.component.plugin", "jar", product.contentvalidationVersion));
+ product.addDependencies(new Project("org.exoplatform.ecm.dms.ext.contentvalidation", "exo.ecm.dms.ext.contentvalidation.component.workflowPublication", "jar", product.contentvalidationVersion));
+ product.addDependencies(new Project("org.exoplatform.ecm.dms.ext.contentvalidation", "exo.ecm.dms.ext.contentvalidation.component.webui", "jar", product.contentvalidationVersion));
+ }
+ } else if(this.name == "bonita") {
+ print("Workflow.js: adding dependencies for bonita");
+
+ product.addDependencies(new Project("org.exoplatform.ecm.workflow", "exo.ecm.workflow.component.workflow.impl.bonita", "jar", this.version));
+ product.addDependencies(new Project("org.exoplatform.ecm.workflow.bp", "exo.ecm.workflow.bp.bonita.holiday", "jar", this.version));
+ product.addDependencies(new Project("org.exoplatform.ecm.workflow.bp", "exo.ecm.workflow.bp.bonita.payraise", "jar", this.version));
+ if (product.useContentvalidation) {
+ product.addDependencies(new Project("org.exoplatform.ecm.dms.ext.contentvalidation", "exo.ecm.dms.ext.contentvalidation.component.plugin", "jar", product.contentvalidationVersion));
+ product.addDependencies(new Project("org.exoplatform.ecm.dms.ext.contentvalidation", "exo.ecm.dms.ext.contentvalidation.component.workflowPublication", "jar", product.contentvalidationVersion));
+ product.addDependencies(new Project("org.exoplatform.ecm.dms.ext.contentvalidation", "exo.ecm.dms.ext.contentvalidation.component.bonitaconfig", "jar", product.contentvalidationVersion));
+ product.addDependencies(new Project("org.exoplatform.ecm.dms.ext.contentvalidation.bp", "exo.ecm.dms.ext.contentvalidation.bp.bonita.content-publishing", "jar", product.contentvalidationVersion));
+ product.addDependencies(new Project("org.exoplatform.ecm.dms.ext.contentvalidation", "exo.ecm.dms.ext.contentvalidation.component.webui", "jar", product.contentvalidationVersion));
+ }
+
+ product.addDependencies(new Project("org.ow2.bonita", "bonita-api", "jar", "4.0"));
+ product.addDependencies(new Project("org.ow2.bonita", "bonita-core", "jar", "4.0"));
+ product.addDependencies(new Project("org.ow2.novabpm", "novaBpmIdentity", "jar", "1.0"));
+ product.addDependencies(new Project("org.ow2.novabpm", "novaBpmUtil", "jar", "1.0"));
+ product.addDependencies(new Project("org.jbpm", "pvm", "jar", "r2175"));
+
+ //Remove duplicate ehcache from Portal
+ product.removeDependency(new Project("net.sf.ehcache", "ehcache", "jar", "1.4.1"));
+
+ //Add external dependencies
+ product.addDependencies(new Project("bsh", "bsh", "jar", "2.0b1"));
+ product.addDependencies(new Project("net.sf.ehcache", "ehcache", "jar", "1.5.0"));
+ product.addDependencies(new Project("backport-util-concurrent", "backport-util-concurrent", "jar", "3.1"));
+ product.addDependencies(new Project("org.ow2.util.asm", "asm", "jar", "3.1"));
+ product.addServerPatch("jbossear",new Project("org.exoplatform.ecm.workflow", "exo.ecm.workflow.server.jboss.patch-ear", "jar", this.version));
+ product.addServerPatch("jboss",new Project("org.exoplatform.ecm.workflow", "exo.ecm.workflow.server.jboss.patch", "jar", this.version));
+ product.addServerPatch("tomcat",new Project("org.exoplatform.ecm.workflow", "exo.ecm.workflow.server.tomcat.patch", "jar", this.version));
+ }
+}
+
+Workflow.prototype.getPortlet = function() {
+ return new Project("org.exoplatform.ecm.workflow", "exo.ecm.workflow.portlet.workflow", "exo-portlet", this.version).
+ addDependency(new Project("org.exoplatform.ecm.workflow", "exo.ecm.workflow.component.workflow.api", "jar", this.version)).
+ addDependency(new Project("org.exoplatform.ecm.workflow", "exo.ecm.workflow.webui.workflow", "jar", this.version)).
+ addDependency(new Project("rome", "rome", "jar", "0.9")).
+ addDependency(new Project("com.totsp.feedpod", "itunes-com-podcast", "jar", "0.2")).
+ addDependency(new Project("jdom", "jdom", "jar", "1.0")).
+ addDependency(new Project("org.apache.ws.commons", "ws-commons-util", "jar", "1.0.1")).
+ addDependency(new Project("com.sun.xml.stream", "sjsxp", "jar", "1.0"));
+}
+
+eXo.projects.Workflow = Workflow.prototype.constructor ;
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/projects/WorkflowBackup.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/projects/WorkflowBackup.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/projects/WorkflowBackup.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,34 @@
+eXo.require("eXo.core.IOUtil") ;
+eXo.require("eXo.core.TaskDescriptor") ;
+eXo.require("eXo.projects.Project");
+
+function WorkflowBackup(workflowName, workflowVersion) {
+ this.name = workflowName ;
+ this.version = workflowVersion;
+}
+
+WorkflowBackup.prototype.configWorkflow = function(product) {
+ if(this.name == "jbpm") {
+
+ print("WorkflowBackup.js: adding dependencies for jbpm");
+
+ product.addDependencies(new Project("org.exoplatform.ecm", "exo.ecm.component.workflow.impl.jbpm.facade", "jar", this.version)) ;
+ product.addDependencies(new Project("org.exoplatform.ecm", "exo.ecm.component.workflow.impl.jbpm.engine", "jar", "3.0")) ;
+ //For POC using 2.0, please use this
+ //product.addDependencies(new Project("org.exoplatform.ecm", "exo.ecm.component.workflow.impl.jbpm.facade", "jar", "2.0")) ;
+ // workflow version management has been fixed. Use "product.workflowVersion" variable in your JS product descriptor to set
+ // workflow version to use (avoid problem with trunk product using branche for workflow for example)
+ } else if(this.name = "bonita") {
+ print("WorkflowBackup.js: adding dependencies for bonita");
+ product.addDependencies(new Project("org.exoplatform.ecm", "exo.ecm.component.workflow.impl.bonita", "jar", this.version)) ;
+ product.addDependencies(new Project("org.objectweb.bonita", "bonita-client", "jar", "3.0"));
+ product.addDependencies(new Project("org.objectweb.bonita", "bonita", "exo-ear-jar", "3.0"));
+ product.addDependencies(new Project("org.objectweb.bonita", "config", "exo-ear-rar", "3.0"));
+ product.addDependencies(new Project("org.objectweb.bonita", "bonita_ws", "war", "3.0"));
+ product.addDependencies(new Project("org.objectweb.bonita", "jabber", "exo-ear-rar", "3.0"));
+ product.addDependencies(new Project("org.objectweb.bonita", "loadclass", "exo-ear-rar", "3.0"));
+ product.addServerPatch("jonas",new Project("org.exoplatform.ecm", "exo.ecm.server.jonas.patch", "jar", this.version));
+ }
+}
+
+eXo.projects.Workflow = Workflow.prototype.constructor ;
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Database.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Database.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Database.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,232 @@
+eXo.require("eXo.core.TaskDescriptor") ;
+eXo.require("eXo.projects.Project") ;
+
+function DBInstance() {
+ this.name = null ;
+ this.drivers = [] ;
+ this.conectionURL = null ;
+ this.driverClass = null ;
+ this.username = null ;
+ this.password = null;
+ this.dialect = null ;
+}
+
+DBInstance.prototype.DeployTask = function(product, server, repos) {
+ var task = new TaskDescriptor("Deploy Database Driver", null) ;
+ task.description = "Deploy the database driver for database " + this.name;
+// task.product = product ;
+// task.server = server ;
+ task.repos = repos ;
+ task.dbinstance = this ;
+
+ task.execute = function() {
+ var driver = this.dbinstance.drivers ;
+ for(var i = 0; i < driver.length ; i++) {
+ var project = driver[i] ;
+ project.deployTo(repos, server) ;
+ server.onDeploy(project) ;
+ }
+ }
+ return task ;
+}
+
+DBInstance.prototype.GetConfigTask = function() {
+ var descriptor = new TaskDescriptor("Configure Database", null) ;
+ descriptor.description = "Configure the database environment for " + this.name;
+ descriptor.dbinstance = this ;
+
+ descriptor.execute = function() {
+ var input = null ;
+ input = eXo.System.readInput("Enter the connection url[" + this.dbinstance.conectionURL + "]") ;
+ if(input != null && input.length() > 0) this.dbinstance.conectionURL = input ;
+ input = eXo.System.readInput("Enter the username[" + this.dbinstance.username + "]") ;
+ if(input != null && input.length() > 0) this.dbinstance.username = input ;
+ input = eXo.System.readInput("Enter the password[" + this.dbinstance.password + "]") ;
+ if(input != null && input.length() > 0) this.dbinstance.password = input ;
+ }
+ return descriptor;
+}
+
+
+DBInstance.prototype.ConfigureTask = function(product, server, dbsetup) {
+ var descriptor = new TaskDescriptor("Configure Database", null) ;
+ descriptor.description = "Configure the database environment for " + this.name;
+ descriptor.dbinstance = this ;
+
+ descriptor.execute =function () {
+
+ if (!product.portalwar) {
+ eXo.System.info("Server have not include portal to deploy database.");
+ return 1;
+ }
+ var IOUtil = eXo.core.IOUtil ;
+ var jarFile = server.deployWebappDir + "/" + product.portalwar ;
+ var mentries = new java.util.HashMap() ;
+
+ if (dbsetup=="file") {
+ var dbconfigSource = "WEB-INF/conf/database/database-configuration."+this.dbinstance.name+".xml";
+ var dbconfigDest = "WEB-INF/conf/database/database-configuration.xml";
+ if (IOUtil.getJarEntryContent(jarFile, dbconfigSource) != null) {
+ var configTmpl = IOUtil.getJarEntryAsText(jarFile, dbconfigSource);
+ mentries.put(dbconfigDest, configTmpl.getBytes()) ;
+ eXo.System.info("CONF", "Replaced " + dbconfigDest + " by " + dbconfigSource);
+ } else {
+ eXo.System.info("CONF", dbconfigSource + " entry not found, using " + dbconfigDest );
+ }
+ } else {
+ var properties = new java.util.HashMap() ;
+ properties.put("${dialect}", this.dbinstance.dialect) ;
+ properties.put("${driverClass}", this.dbinstance.driverClass) ;
+ properties.put("${connectionUrl}", this.dbinstance.conectionURL) ;
+ properties.put("${username}", this.dbinstance.username) ;
+ properties.put("${password}", this.dbinstance.password) ;
+
+ var propmsg = "Database settings: " + properties.entrySet();
+ eXo.System.info("CONF", propmsg);
+
+ var templateEntry = "WEB-INF/conf/database/database-configuration.tmpl.xml";
+ var dbconfigEntry = "WEB-INF/conf/database/database-configuration.xml";
+ mentries = IOUtil.patchWar(jarFile, properties, templateEntry, dbconfigEntry, mentries)
+
+ }
+
+ var properties = new java.util.HashMap() ;
+ properties.put("${dialect}", this.dbinstance.name);
+ eXo.System.info("CONF", "JCR settings: " + properties.entrySet());
+
+ mentries = IOUtil.patchWar(jarFile, properties, "WEB-INF/conf/jcr/repository-configuration.tmpl.xml",
+ "WEB-INF/conf/jcr/repository-configuration.xml", mentries)
+
+ mentries = IOUtil.patchWar(jarFile, properties, "WEB-INF/conf/jcr/jcr-configuration.tmpl.xml",
+ "WEB-INF/conf/jcr/jcr-configuration.xml", mentries)
+
+
+ var portalwar = server.deployWebappDir + "/" + product.portalwar;
+ eXo.System.info("CONF", "Patching database config in " + portalwar + ": \n\t" + mentries.keySet());
+ IOUtil.modifyJar(portalwar, mentries, null) ;
+ }
+ return descriptor;
+}
+
+//==========================================================================================
+
+function Database() {
+
+}
+
+Database.prototype.HsqlDB = function(name) {
+ var instance = new DBInstance() ;
+ instance.name = name ;
+ instance.drivers = [ new Project("hsqldb", "hsqldb", "jar", "1.8.0.7") ] ;
+
+ instance.driverClass = "org.hsqldb.jdbcDriver";
+ instance.dialect = "org.hibernate.dialect.HSQLDialect" ;
+ instance.conectionURL = "jdbc:hsqldb:file:../temp/data/exodb";
+ instance.username = "sa" ;
+ instance.password = "";
+ return instance ;
+}
+
+Database.prototype.MysqlDB = function(name) {
+ var instance = new DBInstance() ;
+ instance.name = name ;
+ instance.drivers = [ new Project("mysql", "mysql-connector-java", "jar", "5.0.5")] ;
+
+ instance.driverClass = "com.mysql.jdbc.Driver";
+ instance.dialect = "org.hibernate.dialect.MySQLDialect" ;
+ instance.conectionURL = "jdbc:mysql://localhost/webos";
+ instance.username = "exoadmin" ;
+ instance.password = "exo12321";
+
+ return instance ;
+}
+
+Database.prototype.PostgresDB = function(name) {
+ var instance = new DBInstance() ;
+ instance.name = name ;
+ instance.drivers = [ new Project("org.postgresql", "postgresql-jdbc3", "jar", "8.2-505")] ;
+
+ instance.driverClass = "org.postgresql.Driver";
+ instance.dialect = "org.hibernate.dialect.PostgreSQLDialect" ;
+ instance.conectionURL = "jdbc:postgresql://192.168.1.15:5432/exodb";
+ instance.username = "exo" ;
+ instance.password = "exo";
+
+ return instance ;
+}
+
+Database.prototype.OracleDB = function(name) {
+ var instance = new DBInstance() ;
+ instance.name = name ;
+ instance.drivers = [ new Project("oracle", "ojdbc", "jar", "1.4")] ;
+
+ instance.driverClass = "oracle.jdbc.OracleDriver";
+ instance.dialect = "org.hibernate.dialect.Oracle9Dialect" ;
+ instance.conectionURL = "jdbc:oracle:thin:@//192.168.1.15:1521/xe";
+ instance.username = "exo" ;
+ instance.password = "exo";
+
+ return instance ;
+}
+
+Database.prototype.DB2ExpressDB = function(name) {
+ var instance = new DBInstance() ;
+ instance.name = name ;
+ instance.drivers = [ new Project("com.ibm.db2", "db2jcc", "jar", "9.1"),
+ new Project("com.ibm.db2", "db2jcc_license_cu", "jar", "9.1")] ;
+
+ instance.driverClass = "com.ibm.db2.jcc.DB2Driver";
+ instance.dialect = "org.hibernate.dialect.DB2Dialect" ;
+ instance.conectionURL = "jdbc:db2://192.168.1.15:50000/exodb";
+ instance.username = "exoinst" ;
+ instance.password = "exo";
+
+ return instance ;
+}
+
+Database.prototype.DB2V8DB = function(name) {
+ var instance = new DBInstance() ;
+ instance.name = name ;
+ instance.drivers = [ new Project("com.ibm.db2", "db2jcc", "jar", "8.0"),
+ new Project("com.ibm.db2", "db2jcc_license_cu", "jar", "8.0")] ;
+
+ instance.driverClass = "com.ibm.db2.jcc.DB2Driver";
+ instance.dialect = "org.hibernate.dialect.DB2Dialect" ;
+ instance.conectionURL = "jdbc:db2://10.21.10.11:50520/EXO";
+ instance.username = "bdpdo11" ;
+ instance.password = "edvgpn8ll40k";
+
+ return instance ;
+}
+
+Database.prototype.DerbyDB = function(name) {
+ var instance = new DBInstance() ;
+ instance.name = name ;
+ instance.drivers = [ new Project("org.apache", "derby", "jar", "10.2")] ;
+
+ instance.driverClass = "org.apache.derby.jdbc.ClientDriver";
+ instance.dialect = "org.hibernate.dialect.DerbyDialect" ;
+ instance.conectionURL = "jdbc:derby://192.168.1.15:1527/exodb;create=true";
+ instance.username = "exo" ;
+ instance.password = "exo";
+
+ return instance ;
+}
+
+Database.prototype.SqlServerDB = function(name) {
+ var instance = new DBInstance() ;
+ instance.name = name ;
+ instance.drivers = [ new Project("com.microsoft", "sqljdbc", "jar", "1.1.1501")] ;
+
+ instance.driverClass = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
+ instance.dialect = "org.hibernate.dialect.SQLServerDialect" ;
+ instance.conectionURL = "jdbc:sqlserver://192.168.1.19:1433;databaseName=exodb";
+ instance.username = "exo" ;
+ instance.password = "exo";
+
+ return instance ;
+}
+
+//==========================================================================================
+
+eXo.server.Database = new Database() ;
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Ear.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Ear.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Ear.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,66 @@
+eXo.require("eXo.core.TaskDescriptor");
+eXo.require("eXo.core.IOUtil");
+eXo.require("eXo.server.ServerUtil");
+eXo.require("eXo.projects.Project");
+
+function Ear(earHome) {
+ this.runningInstance_ = null;
+ this.name = "ear";
+ this.serverHome = earHome;
+ // using "[product.name]-[version].ear" in the EarTask of exobuild now;
+ this.earFile = eXo.env.workingDir + "/gatein.ear";
+ // TODO use WEBSPHERE_HOME
+ this.cleanServer = java.lang.System.getProperty("clean.server");
+ if (this.cleanServer == null || this.cleanServer.equals("") || !this.cleanServer.startsWith("ear"))
+ this.cleanServer = "ear";
+ this.deployLibDir = this.serverHome;
+ this.deployWebappDir = this.serverHome;
+ this.deployEarDir = this.serverHome;
+ this.patchDir = this.serverHome;
+}
+
+Ear.prototype.RunTask = function() {
+ var descriptor = new TaskDescriptor("Run Ear", this.serverHome + "/bin");
+ descriptor.server = this;
+ descriptor.execute = function() {
+
+ }
+ return descriptor;
+};
+
+Ear.prototype.StopTask = function() {
+ var descriptor = new TaskDescriptor("Stop Ear", this.serverHome + "/bin");
+ descriptor.server = this;
+ descriptor.execute = function() {
+
+ }
+ return descriptor;
+};
+
+Ear.prototype.CleanTask = function() {
+ var descriptor = new TaskDescriptor("Clean Ear", this.serverHome + "/bin");
+ descriptor.server = this;
+ descriptor.execute = function() {
+ eXo.core.IOUtil.emptyFolder(this.server.serverHome + "/temp");
+ }
+ return descriptor;
+}
+
+Ear.prototype.preDeploy = function(product) {
+ product.addDependencies(new Project("commons-pool", "commons-pool", "jar", "1.2"));
+ product.addDependencies(new Project("commons-dbcp", "commons-dbcp", "jar", "1.2.1"));
+ product.addDependencies(new Project("org.exoplatform.portal", "exo.portal.server.websphere.plugin", "jar",
+ this.pluginVersion));
+}
+
+Ear.prototype.onDeploy = function(project) {
+}
+
+Ear.prototype.postDeploy = function(product) {
+ ServerUtil = eXo.server.ServerUtil;
+ ServerUtil.createWebsphereEarApplicationXml(this.deployWebappDir, product);
+ ServerUtil.addClasspathForWar(this.deployLibDir);
+ ServerUtil.patchWebspherePortalWebXml(this.deployWebappDir, product);
+}
+
+eXo.server.Ear = Ear.prototype.constructor;
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Jboss.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Jboss.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Jboss.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,118 @@
+eXo.require("eXo.core.TaskDescriptor");
+eXo.require("eXo.core.IOUtil");
+eXo.require("eXo.server.ServerUtil");
+eXo.require("eXo.projects.Project");
+
+function Jboss(jbossHome) {
+ this.exoJBoss5 = false;
+ this.runningInstance_ = null;
+ this.name = "jboss";
+ this.serverHome = jbossHome;
+ this.cleanServer = eXo.env.cleanServer;
+ this.deployLibDir = this.serverHome + "/server/default/deploy/gatein.sar";
+ this.deployWebappDir = this.serverHome + "/server/default/deploy/gatein.sar";
+ this.deployEarDir = this.serverHome + "/server/default/deploy/";
+ this.patchDir = this.serverHome;// + "/server/default"; //because we have to
+ // patch bin/ directory
+}
+
+Jboss.prototype.RunTask = function() {
+ var descriptor = new TaskDescriptor("Run Jboss", this.serverHome + "/bin");
+ descriptor.server = this;
+ descriptor.execute = function() {
+ var javaHome = eXo.env.javaHome;
+ java.lang.System.setProperty("user.dir", descriptor.workingDir);
+ java.lang.System.setProperty("program.name", "run.sh");
+ java.lang.System.setProperty("java.io.tmpdir", this.server.serverHome + "/temp");
+ var sysClasspath = [ new java.net.URL("file:" + this.server.javaHome + "/lib/tools.jar"),
+ new java.net.URL("file:" + this.server.serverHome + "/bin/run.jar") ];
+ eXo.System.addSystemClasspath(sysClasspath);
+
+ var contextLoader = java.lang.Thread.currentThread().getContextClassLoader();
+ var jbossLoader = new java.net.URLClassLoader(new URL[0], contextLoader);
+ java.lang.Thread.currentThread().setContextClassLoader(jbossLoader);
+ var args = new java.lang.String[0];
+ jboss = new org.jboss.Main();
+ jboss.boot(args);
+ runningInstance_ = jboss;
+ java.lang.Thread.currentThread().setContextClassLoader(contextLoader);
+ }
+ return descriptor;
+};
+
+Jboss.prototype.StopTask = function() {
+ var descriptor = new TaskDescriptor("Stop Jboss", this.serverHome + "/bin");
+ descriptor.server = this;
+ descriptor.execute = function() {
+ var sysClasspath = [ new java.net.URL("file:" + this.server.serverHome + "/bin/shutdown.jar"),
+ new java.net.URL("file:" + this.server.serverHome + "/client/jbossall-client.jar") ];
+ var contextLoader = java.lang.Thread.currentThread().getContextClassLoader();
+ var jbossLoader = new java.net.URLClassLoader(sysClasspath, contextLoader);
+ java.lang.Thread.currentThread().setContextClassLoader(jbossLoader);
+ var args = [ "-S" ];
+ org.jboss.Shutdown.main(args);
+ runningInstance_ = null;
+ java.lang.Thread.currentThread().setContextClassLoader(contextLoader);
+ }
+ return descriptor;
+};
+
+Jboss.prototype.CleanTask = function() {
+ var descriptor = new TaskDescriptor("Clean Jboss", this.serverHome + "/bin");
+ descriptor.server = this;
+ descriptor.execute = function() {
+ eXo.core.IOUtil.emptyFolder(this.server.serverHome + "/temp");
+ }
+ return descriptor;
+}
+
+Jboss.prototype.preDeploy = function(product) {
+ product.addDependencies(new Project("commons-pool", "commons-pool", "jar", "1.2"));
+ product.addDependencies(new Project("commons-dbcp", "commons-dbcp", "jar", "1.2.1"));
+ product.addDependencies(new Project("org.exoplatform.portal", "exo.portal.server.jboss.plugin", "jar",
+ product.serverPluginVersion));
+
+ // Above 2.5 we don't bundle JOTM anymore
+ var version = product.version;
+ // DANGEROUS HACK, HACK, HACK !!!!!
+ // 2.5.2.0 will contain jotm
+ if (version.indexOf("2.0") != 0 //
+ && version.indexOf("2.1") != 0 //
+ && version.indexOf("2.2") != 0) {
+ product.removeDependency(new Project("jotm", "jotm_jrmp_stubs", "jar", "2.0.10"));
+ product.removeDependency(new Project("jotm", "jotm", "jar", "2.0.10"));
+ }
+
+ // Remove hibernate libs for JBoss AS5
+ if (this.exoJBoss5) {
+ print("====================== JBOSS5 AS 5 ====================== ");
+ product.removeDependencyByGroupId("org.hibernate");
+ product.removeDependency(new Project("org.jboss", "jbossxb", "jar", "2.0.0.GA"));
+ product.removeDependency(new Project("org.jboss.logging", "jboss-logging-spi", "jar", "2.0.5.GA"));
+ product.removeDependency(new Project("org.jboss", "jboss-common-core", "jar", "2.2.9.GA"));
+ }
+};
+
+Jboss.prototype.onDeploy = function(project) {
+};
+
+Jboss.prototype.postDeploy = function(product) {
+ ServerUtil = eXo.server.ServerUtil;
+ ServerUtil.createEarApplicationXmlForJboss(this.deployWebappDir, product);
+ ServerUtil.addClasspathForWar(this.deployLibDir);
+
+ // Use jboss PrefixSorter deployer
+ var eXoResourcesFile = new java.io.File(this.deployWebappDir + "/eXoResources.war");
+ var neweXoResourcesFile = new java.io.File(this.deployWebappDir + "/01eXoResources.war");
+ eXoResourcesFile.renameTo(neweXoResourcesFile);
+
+ var portalFile = new java.io.File(this.deployWebappDir + "/" + product.portalwar);
+ var newPortalFile = new java.io.File(this.deployWebappDir + "/02portal.war");
+ portalFile.renameTo(newPortalFile);
+ product.portalwar = "02portal.war";
+
+ eXo.core.IOUtil.chmodExecutableInDir(this.serverHome + "/bin/", ".sh");
+
+}
+
+eXo.server.Jboss = Jboss.prototype.constructor;
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/JbossEar.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/JbossEar.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/JbossEar.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,138 @@
+eXo.require("eXo.core.TaskDescriptor");
+eXo.require("eXo.core.IOUtil");
+eXo.require("eXo.server.ServerUtil");
+eXo.require("eXo.projects.Project");
+
+function JbossEar(jbossHome) {
+ this.exoJBoss5 = true;
+ this.runningInstance_ = null;
+ this.name = "jbossear";
+ this.serverHome = jbossHome;
+ this.cleanServer = java.lang.System.getProperty("clean.server");
+ if (this.cleanServer == null || this.cleanServer.equals("") || !this.cleanServer.startsWith("jboss"))
+ this.cleanServer = "jboss-5.1.0.GA";
+ this.deployLibDir = this.serverHome + "/server/default/deploy/gatein.ear";
+ this.deployWebappDir = this.serverHome + "/server/default/deploy/gatein.ear";
+ this.deployEarDir = this.serverHome + "/server/default/deploy/";
+ this.patchDir = this.serverHome;// + "/server/default"; //because we have to
+ // patch bin/ directory
+}
+
+JbossEar.prototype.RunTask = function() {
+ var descriptor = new TaskDescriptor("Run JbossEar", this.serverHome + "/bin");
+ descriptor.server = this;
+ descriptor.execute = function() {
+ var javaHome = eXo.env.javaHome;
+ java.lang.System.setProperty("user.dir", descriptor.workingDir);
+ java.lang.System.setProperty("program.name", "run.sh");
+ java.lang.System.setProperty("java.io.tmpdir", this.server.serverHome + "/temp");
+ var sysClasspath = [ new java.net.URL("file:" + this.server.javaHome + "/lib/tools.jar"),
+ new java.net.URL("file:" + this.server.serverHome + "/bin/run.jar") ];
+ eXo.System.addSystemClasspath(sysClasspath);
+
+ var contextLoader = java.lang.Thread.currentThread().getContextClassLoader();
+ var jbossLoader = new java.net.URLClassLoader(new URL[0], contextLoader);
+ java.lang.Thread.currentThread().setContextClassLoader(jbossLoader);
+ var args = new java.lang.String[0];
+ jboss = new org.jboss.Main();
+ jboss.boot(args);
+ runningInstance_ = jboss;
+ java.lang.Thread.currentThread().setContextClassLoader(contextLoader);
+ }
+ return descriptor;
+};
+
+JbossEar.prototype.StopTask = function() {
+ var descriptor = new TaskDescriptor("Stop JbossEar", this.serverHome + "/bin");
+ descriptor.server = this;
+ descriptor.execute = function() {
+ var sysClasspath = [ new java.net.URL("file:" + this.server.serverHome + "/bin/shutdown.jar"),
+ new java.net.URL("file:" + this.server.serverHome + "/client/jbossall-client.jar") ];
+ var contextLoader = java.lang.Thread.currentThread().getContextClassLoader();
+ var jbossLoader = new java.net.URLClassLoader(sysClasspath, contextLoader);
+ java.lang.Thread.currentThread().setContextClassLoader(jbossLoader);
+ var args = [ "-S" ];
+ org.jboss.Shutdown.main(args);
+ runningInstance_ = null;
+ java.lang.Thread.currentThread().setContextClassLoader(contextLoader);
+ }
+ return descriptor;
+};
+
+JbossEar.prototype.CleanTask = function() {
+ var descriptor = new TaskDescriptor("Clean JbossEar", this.serverHome + "/bin");
+ descriptor.server = this;
+ descriptor.execute = function() {
+ eXo.core.IOUtil.emptyFolder(this.server.serverHome + "/temp");
+ }
+ return descriptor;
+}
+
+JbossEar.prototype.preDeploy = function(product) {
+ product.addDependencies(new Project("commons-pool", "commons-pool", "jar", "1.2"));
+ product.addDependencies(new Project("commons-dbcp", "commons-dbcp", "jar", "1.2.1"));
+ product.addDependencies(new Project("org.exoplatform.portal", "exo.portal.server.jboss.plugin", "jar",
+ product.serverPluginVersion));
+ // product.removeDependency(new Project("quartz", "quartz", "jar",
+ // "1.5.0-RC2"));
+
+ var version = product.version;
+ if (version.indexOf("2.0") != 0 && version.indexOf("2.1") != 0 && version.indexOf("2.2") != 0
+ && version.indexOf("2.5") != 0) {
+ product.addDependencies(new Project("org.slf4j", "slf4j-api", "jar", "1.5.6"));
+ product.addDependencies(new Project("org.slf4j", "slf4j-log4j12", "jar", "1.5.6"));
+ }
+
+ // Above 2.5 we don't bundle JOTM anymore
+ var version = product.version;
+ if (version.indexOf("2.0") != 0 && version.indexOf("2.1") != 0 && version.indexOf("2.2") != 0) {
+ product.removeDependency(new Project("jotm", "jotm_jrmp_stubs", "jar", "2.0.10"));
+ product.removeDependency(new Project("jotm", "jotm", "jar", "2.0.10"));
+ }
+
+ // Remove hibernate libs for JBoss AS5
+ if (this.exoJBoss5) {
+ print("====================== JBOSS5 AS 5 ====================== ");
+ product.removeDependencyByGroupId("org.hibernate");
+ product.removeDependency(new Project("org.jboss", "jbossxb", "jar", "2.0.0.GA"));
+ product.removeDependency(new Project("org.jboss.logging", "jboss-logging-spi", "jar", "2.0.5.GA"));
+ product.removeDependency(new Project("org.jboss", "jboss-common-core", "jar", "2.2.9.GA"));
+ }
+}
+
+JbossEar.prototype.onDeploy = function(project) {
+}
+
+JbossEar.prototype.postDeploy = function(product) {
+ ServerUtil = eXo.server.ServerUtil;
+ ServerUtil.createEarApplicationXmlForJboss(this.deployWebappDir, product);
+ ServerUtil.addClasspathForWar(this.deployLibDir);
+
+ // Use jboss PrefixSorter deployer
+ var eXoResourcesFile = new java.io.File(this.deployWebappDir + "/eXoResources.war");
+ var neweXoResourcesFile = new java.io.File(this.deployWebappDir + "/01eXoResources.war");
+ eXoResourcesFile.renameTo(neweXoResourcesFile);
+
+ var portalFile = new java.io.File(this.deployWebappDir + "/" + product.portalwar);
+ var newPortalFile = new java.io.File(this.deployWebappDir + "/02portal.war");
+ portalFile.renameTo(newPortalFile);
+ product.portalwar = "02portal.war";
+
+ //Move all jars in /lib
+ var earDir = new java.io.File(this.deployWebappDir);
+ var libDir = new java.io.File(this.deployWebappDir, "lib");
+ libDir.mkdir();
+ var files = earDir.listFiles();
+ for ( var i = 0; i < files.length; i++) {
+ var file = files[i];
+ var filepath = file.getAbsolutePath();
+ if (filepath.endsWith(".jar")){
+ eXo.core.IOUtil.cp(filepath, libDir.getAbsolutePath());
+ eXo.core.IOUtil.remove(file);
+ }
+ }
+
+ eXo.core.IOUtil.chmodExecutableInDir(this.serverHome + "/bin/", ".sh");
+}
+
+eXo.server.JbossEar = JbossEar.prototype.constructor;
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Jonas.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Jonas.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Jonas.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,93 @@
+eXo.require("eXo.core.IOUtil") ;
+eXo.require("eXo.core.TaskDescriptor") ;
+eXo.require("eXo.projects.Project");
+
+function Jonas(jonasHome) {
+ this.runningInstance_ = null ;
+ this.name = "jonas" ;
+ this.serverHome = jonasHome ;
+ this.cleanServer = java.lang.System.getProperty("clean.server") ;
+ if(this.cleanServer == null || this.cleanServer.equals("") || !this.cleanServer.startsWith("JONAS")) this.cleanServer = "JONAS_4_8_6" ;
+ this.deployLibDir = this.serverHome + "/lib/apps" ;
+ this.deployWebappDir = this.serverHome + "/apps/autoload/gatein.ear";
+ this.deployEarDir = this.serverHome + "/apps/autoload/";
+ this.patchDir = this.serverHome ;
+}
+
+Jonas.prototype.RunTask = function() {
+ descriptor = new TaskDescriptor("Run Jonas", this.serverHome + "/bin") ;
+ descriptor.execute = function() {
+ eXo.System.info("RunTask() has not been implemented.") ;
+ }
+ return descriptor ;
+};
+
+Jonas.prototype.StopTask = function() {
+ descriptor = new TaskDescriptor("Stop Jonas", this.serverHome + "/bin") ;
+ descriptor.execute = function() {
+ eXo.System.info("StopTask() has not been implemented.") ;
+ }
+ return descriptor ;
+};
+
+Jonas.prototype.CleanTask = function() {
+ descriptor = new TaskDescriptor("Clean Jonas", this.serverHome + "/bin") ;
+ descriptor.server = this;
+ descriptor.execute = function() {
+ eXo.core.IOUtil.emptyFolder(this.server.serverHome + "/logs");
+ eXo.core.IOUtil.emptyFolder(this.server.serverHome + "/temp");
+ eXo.core.IOUtil.emptyFolder(this.server.serverHome + "/work");
+ }
+ return descriptor ;
+}
+
+Jonas.prototype.preDeploy = function(product) {
+ eXo.core.IOUtil.createFolder(this.deployWebappDir + "/META-INF");
+ product.addDependencies(new Project("commons-dbcp", "commons-dbcp", "jar", "1.2.1")) ;
+ product.addDependencies(new Project("commons-pool", "commons-pool", "jar", "1.2")) ;
+ product.addDependencies(new Project("org.exoplatform.portal", "exo.portal.server.jonas.plugin", "jar", product.serverPluginVersion)) ; //this.pluginVersion
+}
+
+Jonas.prototype.onDeploy = function(project) {
+
+//if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
+// process = serverHome + "\\bin\\nt\\post-patch.bat";
+// }
+// else {
+// process = serverHome + "/bin/unix/post-patch.sh";
+// try {
+// Runtime.getRuntime().exec("chmod +x " + process);
+// } catch(Exception e) {
+// System.err.println("[ERROR] " + e.toString());
+// }
+// }
+// try {
+// Runtime.getRuntime().exec(process);
+// } catch(Exception e) {
+// System.err.println("[ERROR] " + e.toString());
+// }
+// }
+
+}
+
+Jonas.prototype.postDeploy = function(product) {
+ ServerUtil = eXo.server.ServerUtil ;
+ ServerUtil.createEarApplicationXml(this.deployWebappDir, product) ;
+ ServerUtil.addClasspathForWar(this.deployLibDir) ;
+ var workflow = java.lang.System.getProperty("workflow");
+ if(product.useWorkflow && workflow == "bonita") {
+ var IOUtil = eXo.core.IOUtil ;
+ var properties = new java.util.HashMap() ;
+ properties.put("${workflow}", "bonita") ;
+ var jarFile = server.deployWebappDir + "/" + product.portalwar ;
+ var mentries = new java.util.HashMap() ;
+ var configTmpl =
+ IOUtil.getJarEntryAsText(jarFile, "WEB-INF/conf/configuration.tmpl.xml");
+ var config = eXo.core.Util.modifyText(configTmpl, properties) ;
+ mentries.put("WEB-INF/conf/configuration.xml", config.getBytes()) ;
+ IOUtil.modifyJar(server.deployWebappDir + "/" + product.portalwar, mentries, null) ;
+ }
+ eXo.core.IOUtil.chmodExecutableInDir(this.serverHome + "/bin/", ".sh");
+}
+
+eXo.server.Jonas = Jonas.prototype.constructor ;
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/ServerUtil.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/ServerUtil.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/ServerUtil.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,218 @@
+eXo.require("eXo.core.IOUtil");
+
+function ServerUtil() { }
+
+ServerUtil.prototype.createEarApplicationXmlForJboss = function(deployEarDir, product) {
+ var earDir = new java.io.File(deployEarDir) ;
+ var b = new java.lang.StringBuilder();
+ b.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+ b.append("<!DOCTYPE application PUBLIC \"-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN\" \"http://java.sun.com/dtd/application_1_3.dtd\">");
+ b.append("\n<application>\n");
+ b.append(" <display-name>exoplatform</display-name>\n");
+ var eXoResources = "eXoResources.war";
+ b.append(" <module>\n");
+ b.append(" <web>\n");
+ b.append(" <web-uri>01").append(eXoResources).append("</web-uri>\n");
+ b.append(" <context-root>").append(eXoResources.substring(0, eXoResources.indexOf('.'))).append("</context-root>\n");
+ b.append(" </web>\n");
+ b.append(" </module>\n");
+ b.append(" <module>\n");
+ b.append(" <web>\n");
+ b.append(" <web-uri>02").append(product.portalwar).append("</web-uri>\n");
+ b.append(" <context-root>").append(product.portalwar.substring(0, product.portalwar.indexOf('.'))).append("</context-root>\n");
+ b.append(" </web>\n");
+ b.append(" </module>\n");
+ var file = earDir.list();
+ for (var i = 0; i < file.length; i++) {
+ if(file[i].endsWith("war") && file[i] != product.portalwar && file[i] != eXoResources) {
+ var idx = file[i].indexOf('.');
+ var context = file[i].substring(0, idx);
+ b.append(" <module>\n");
+ b.append(" <web>\n");
+ b.append(" <web-uri>").append(file[i]).append("</web-uri>\n");
+ b.append(" <context-root>").append(context).append("</context-root>\n");
+ b.append(" </web>\n");
+ b.append(" </module>\n");
+//Jars moved in lib/
+// } else if(file[i].endsWith("jar")) {
+// b.append(" <module>\n").
+// append(" <ejb>").append(file[i]).append("</ejb>\n").
+// append(" </module>\n");
+ } else if(file[i].endsWith("rar")) {
+ b.append(" <module>\n");
+ b.append(" <connector>").append(file[i]).append("</connector>\n");
+ b.append(" </module>\n");
+ }
+ }
+ b.append("</application>\n");
+ eXo.core.IOUtil.createFolder(deployEarDir + "/META-INF");
+ var out =
+ new java.io.FileOutputStream(deployEarDir + "/META-INF/application.xml");
+ out.write(b.toString().getBytes(), 0, b.length());
+ out.close();
+}
+
+
+ServerUtil.prototype.createEarApplicationXml = function(deployEarDir, product) {
+ var earDir = new java.io.File(deployEarDir) ;
+ var b = new java.lang.StringBuilder();
+ b.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+ b.append("<!DOCTYPE application PUBLIC \"-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN\" \"http://java.sun.com/dtd/application_1_3.dtd\">");
+ b.append("\n<application>\n");
+ b.append(" <display-name>exoplatform</display-name>\n");
+ var eXoResources = "eXoResources.war";
+ b.append(" <module>\n");
+ b.append(" <web>\n");
+ b.append(" <web-uri>").append(eXoResources).append("</web-uri>\n");
+ b.append(" <context-root>").append(eXoResources.substring(0, eXoResources.indexOf('.'))).append("</context-root>\n");
+ b.append(" </web>\n");
+ b.append(" </module>\n");
+ b.append(" <module>\n");
+ b.append(" <web>\n");
+ b.append(" <web-uri>").append(product.portalwar).append("</web-uri>\n");
+ b.append(" <context-root>").append(product.portalwar.substring(0, product.portalwar.indexOf('.'))).append("</context-root>\n");
+ b.append(" </web>\n");
+ b.append(" </module>\n");
+ var file = earDir.list();
+ for (var i = 0; i < file.length; i++) {
+ if(file[i].endsWith("war") && file[i] != product.portalwar && file[i] != eXoResources) {
+ var idx = file[i].indexOf('.');
+ var context = file[i].substring(0, idx);
+ b.append(" <module>\n");
+ b.append(" <web>\n");
+ b.append(" <web-uri>").append(file[i]).append("</web-uri>\n");
+ b.append(" <context-root>").append(context).append("</context-root>\n");
+ b.append(" </web>\n");
+ b.append(" </module>\n");
+ } else if(file[i].endsWith("jar")) {
+ b.append(" <module>\n").
+ append(" <ejb>").append(file[i]).append("</ejb>\n").
+ append(" </module>\n");
+ } else if(file[i].endsWith("rar")) {
+ b.append(" <module>\n");
+ b.append(" <connector>").append(file[i]).append("</connector>\n");
+ b.append(" </module>\n");
+ }
+ }
+ b.append("</application>\n");
+ eXo.core.IOUtil.createFolder(deployEarDir + "/META-INF");
+ var out =
+ new java.io.FileOutputStream(deployEarDir + "/META-INF/application.xml");
+ out.write(b.toString().getBytes(), 0, b.length());
+ out.close();
+}
+
+ServerUtil.prototype.createWebsphereEarApplicationXml = function(deployEarDir, product) {
+ var earDir = new java.io.File(deployEarDir) ;
+ var b = new java.lang.StringBuilder();
+ b.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+ b.append("<!DOCTYPE application PUBLIC \"-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN\" \"http://java.sun.com/dtd/application_1_3.dtd\">");
+ b.append("\n<application>\n");
+ b.append(" <display-name>exoplatform</display-name>\n");
+ var eXoResources = "eXoResources.war";
+ b.append(" <module>\n");
+ b.append(" <web>\n");
+ b.append(" <web-uri>").append(eXoResources).append("</web-uri>\n");
+ b.append(" <context-root>").append(eXoResources.substring(0, eXoResources.indexOf('.'))).append("</context-root>\n");
+ b.append(" </web>\n");
+ b.append(" </module>\n");
+ b.append(" <module>\n");
+ b.append(" <web>\n");
+ b.append(" <web-uri>").append(product.portalwar).append("</web-uri>\n");
+ b.append(" <context-root>").append(product.portalwar.substring(0, product.portalwar.indexOf('.'))).append("</context-root>\n");
+ b.append(" </web>\n");
+ b.append(" </module>\n");
+ var file = earDir.list();
+ for (var i = 0; i < file.length; i++) {
+ if(file[i].endsWith("war") && file[i] != product.portalwar && file[i] != eXoResources) {
+ var idx = file[i].indexOf('.');
+ var context = file[i].substring(0, idx);
+ b.append(" <module>\n");
+ b.append(" <web>\n");
+ b.append(" <web-uri>").append(file[i]).append("</web-uri>\n");
+ b.append(" <context-root>").append(context).append("</context-root>\n");
+ b.append(" </web>\n");
+ b.append(" </module>\n");
+ }
+ }
+ b.append("</application>\n");
+ eXo.core.IOUtil.createFolder(deployEarDir + "/META-INF");
+ var out = new java.io.FileOutputStream(deployEarDir + "/META-INF/application.xml");
+ out.write(b.toString().getBytes(), 0, b.length());
+ out.close();
+}
+
+
+ServerUtil.prototype.patchWebspherePortalWebXml = function(deployEarDir, product) {
+ var warFile = deployEarDir + "/" + product.portalwar;
+ var file = new java.io.File(warFile);
+ if (!file.exists()) {
+ eXo.System.info("IO", warFile + " file not found" ) ;
+ return null;
+ }
+ var jar = new java.util.jar.JarFile(file) ;
+ var webXmlEntry = "WEB-INF/web.xml";
+ eXo.System.info("INFO", "---------------------------------------------------------------");
+ eXo.System.info("INFO", "To be patched web.xml within " + product.portalwar + " file " + warFile + "/" + webXmlEntry);
+ var webXML = eXo.core.IOUtil.getJarEntryAsText(warFile, webXmlEntry);
+
+ var b = new java.lang.StringBuilder();
+ b.append("<!-- Websphere Listener -->\n");
+ b.append(" <listener>\n");
+ b.append(" <listener-class>org.exoplatform.services.organization.ext.websphere.WebsphereSessionListener</listener-class>\n");
+ b.append(" </listener>\n");
+ b.append("\n");
+ b.append(" <listener>");
+ webXML = webXML.replaceFirst("<listener>", b.toString());
+
+ b = new java.lang.StringBuilder();
+ b.append("<!-- Websphere filter -->\n");
+ b.append(" <filter>\n");
+ b.append(" <filter-name>WebsphereFilter</filter-name>\n");
+ b.append(" <filter-class>org.exoplatform.services.organization.ext.websphere.WebsphereFilter</filter-class>\n");
+ b.append(" </filter>\n");
+ b.append("\n");
+ b.append(" <filter>");
+ webXML = webXML.replaceFirst("<filter>", b.toString());
+
+ b = new java.lang.StringBuilder();
+ b.append("<!-- Websphere filter-mapping -->\n");
+ b.append(" <filter-mapping>\n");
+ b.append(" <filter-name>WebsphereFilter</filter-name>\n");
+ b.append(" <url-pattern>/public/*</url-pattern>\n");
+ b.append(" </filter-mapping>\n");
+ b.append("\n");
+ b.append(" <filter-mapping>");
+ webXML = webXML.replaceFirst("<filter-mapping>", b.toString());
+
+
+ var replaceMap = new java.util.HashMap() ;
+
+ replaceMap.put(webXmlEntry, webXML.getBytes()) ;
+ eXo.core.IOUtil.modifyJar(warFile, replaceMap, null) ;
+}
+
+ServerUtil.prototype.addClasspathForWar = function(earPath) {
+ var earDir = new java.io.File(earPath) ;
+ var files = earDir.listFiles() ;
+ var b = new java.lang.StringBuilder() ;
+ for(var i = 0; i< files.length; i++) {
+ var file = files[i] ;
+ if (file.getName().endsWith(".jar")) {
+ b.append(file.getName()).append(' ');
+ }
+ }
+ var classpath = b.toString() ;
+ for(var i = 0; i< files.length; i++) {
+ var file = files[i] ;
+ if (file.getName().endsWith(".war")) {
+ manifestAttributes = new java.util.HashMap() ;
+ manifestAttributes.put("Class-Path", classpath) ;
+ if (file.isFile()) {
+ eXo.core.IOUtil.modifyJar(file.getAbsolutePath(), null, manifestAttributes);
+ }
+ }
+ }
+}
+
+eXo.server.ServerUtil = new ServerUtil();
\ No newline at end of file
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Tomcat.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Tomcat.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/Tomcat.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,130 @@
+eXo.require("eXo.core.TaskDescriptor");
+eXo.require("eXo.projects.Project");
+
+function Tomcat(tomcatHome) {
+ this.runningInstance_ = null;
+ this.name = "tomcat";
+ this.serverHome = tomcatHome;
+ this.cleanServer = eXo.env.cleanServer;
+ this.deployLibDir = this.serverHome + "/lib";
+ this.deployWebappDir = this.serverHome + "/webapps";
+ this.patchDir = this.serverHome;
+ this.pluginVersion = "trunk";
+}
+
+Tomcat.prototype.RunTask = function() {
+ var descriptor = new TaskDescriptor("Run Tomcat", this.serverHome + "/bin");
+ descriptor.execute = function() {
+ java.lang.System.setProperty("user.dir", descriptor.workingDir);
+ java.lang.System.setProperty("catalina.base", eXo.server.Tomcat.serverHome);
+ java.lang.System.setProperty("catalina.home", eXo.server.Tomcat.serverHome);
+ java.lang.System.setProperty("java.io.tmpdir", eXo.server.Tomcat.serverHome + "/temp");
+ java.lang.System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
+ java.lang.System.setProperty("java.security.auth.login.config", eXo.server.Tomcat.serverHome + "/conf/jaas.conf");
+ var sysClasspath = [ new java.net.URL("file:" + eXo.env.javaHome + "/lib/tools.jar"),
+ new java.net.URL("file:" + this.serverHome + "/bin/commons-logging-api.jar") ];
+ eXo.System.addSystemClasspath(sysClasspath);
+ var tomcatClasspath = [ new java.net.URL("file:" + eXo.server.Tomcat.serverHome + "/bin/bootstrap.jar") ];
+ var contextLoader = java.lang.Thread.currentThread().getContextClassLoader();
+ var tomcatLoader = new java.net.URLClassLoader(tomcatClasspath, contextLoader);
+ java.lang.Thread.currentThread().setContextClassLoader(tomcatLoader);
+
+ var bootstrap = tomcatLoader.loadClass("org.apache.catalina.startup.Bootstrap");
+ instance = bootstrap.newInstance();
+ java.lang.System.gc();
+ instance.init();
+ instance.start();
+
+ java.lang.Thread.currentThread().setContextClassLoader(contextLoader);
+ eXo.server.Tomcat.runningInstance_ = instance;
+ }
+ return descriptor;
+}
+
+Tomcat.prototype.StopTask = function() {
+ var descriptor = new TaskDescriptor("Stop Tomcat", this.serverHome + "/bin");
+ descriptor.execute = function() {
+ if (eXo.server.Tomcat.runningInstance_ != null) {
+ eXo.server.Tomcat.runningInstance_.stop();
+ eXo.server.Tomcat.runningInstance_ = null;
+ }
+ }
+ return descriptor;
+}
+
+Tomcat.prototype.CleanTask = function() {
+ var descriptor = new TaskDescriptor("Clean Tomcat", this.serverHome + "/bin");
+ descriptor.execute = function() {
+ eXo.core.IOUtil.emptyFolder(serverHome + "/logs");
+ eXo.core.IOUtil.emptyFolder(serverHome + "/temp");
+ }
+ return descriptor;
+}
+
+Tomcat.prototype.preDeploy = function(product) {
+
+ var version = product.version;
+ if (version.indexOf("2.0") != 0 && version.indexOf("2.1") != 0 && version.indexOf("2.2") != 0
+ && version.indexOf("2.5") != 0) {
+ product.addDependencies(new Project("org.slf4j", "slf4j-api", "jar", "1.5.6"));
+ product.addDependencies(new Project("org.slf4j", "slf4j-jdk14", "jar", "1.5.6"));
+ }
+ product.addDependencies(new Project("commons-logging", "commons-logging", "jar", "1.0.4"));
+ product.addDependencies(new Project("commons-pool", "commons-pool", "jar", "1.2"));
+ product.addDependencies(new Project("commons-dbcp", "commons-dbcp", "jar", "1.2.1"));
+ product.addDependencies(new Project("org.exoplatform.portal", "exo.portal.server.tomcat.plugin", "jar", product.serverPluginVersion));
+ product.addDependencies(new Project("org.exoplatform.tool", "exo.tool.webunit", "jar", "1.0.0"));
+
+ //GTNPORTAL-32 No WSRP on tomcat yet
+ product.removeDependency(new Project("org.exoplatform.portal", "exo.portal.component.wsrp", "jar", product.serverPluginVersion ));
+ product.removeDependencyByGroupId("org.gatein.wsrp");
+
+}
+
+Tomcat.prototype.onDeploy = function(project) {
+ // if("exo-portal" == project.type) {
+ // var context =
+ // project.artifactId.substring(project.artifactId.lastIndexOf(".") + 1) ;
+ // var dirname = this.serverHome + "/conf/Catalina/localhost/";
+ // var destDir = new java.io.File(dirname);
+ // if(!destDir.exists()) destDir.mkdirs() ;
+ // var filename = dirname + context + ".xml";
+ // eXo.System.info("TOMCAT", "Generating tomcat context" + filename);
+ // var config =
+ // "<Context path='/" + context+ "' docBase='" + context + "' debug='0'
+ // reloadable='true' crossContext='true'> \n" +
+ // //className can be org.apache.catalina.logger.FileLogger
+ // " <Logger className='org.apache.catalina.logger.SystemOutLogger' \n" +
+ // " prefix='localhost_" + context + "_log.' suffix='.txt'
+ // timestamp='true'/> \n" +
+ // " <Manager className='org.apache.catalina.session.PersistentManager'
+ // saveOnRestart='false'/> \n" +
+ // " <Realm className='org.apache.catalina.realm.JAASRealm' \n" +
+ // " appName='exo-domain' \n" +
+ // " userClassNames='org.exoplatform.services.security.jaas.UserPrincipal'
+ // \n" +
+ // " roleClassNames='org.exoplatform.services.security.jaas.RolePrincipal'
+ // \n" +
+ // " debug='0' cache='false'/> \n" +
+ // " <Valve className='org.apache.catalina.authenticator.FormAuthenticator'
+ // characterEncoding='UTF-8'/>" +
+ // "</Context> \n";
+ // eXo.core.IOUtil.createFile(filename, config) ;
+ // }
+}
+
+Tomcat.prototype.postDeploy = function(product) {
+ var configFileInWar = "WEB-INF/conf/configuration.xml";
+ var portalwar = new java.io.File(this.deployWebappDir + "/" + product.portalwar);
+ eXo.System.info("CONF", "Patching " + configFileInWar + " in " + portalwar + " : remove wsrp configuration");
+ var mentries = new java.util.HashMap() ;
+ var configTmpl = eXo.core.IOUtil.getJarEntryAsText(portalwar, configFileInWar);
+ configTmpl = configTmpl.replaceAll("<import>war:/conf/common/wsrp-configuration.xml</import>", "");
+ mentries.put(configFileInWar, configTmpl.getBytes()) ;
+ eXo.core.IOUtil.modifyJar(portalwar, mentries, null);
+ //
+
+ eXo.core.IOUtil.chmodExecutableInDir(this.serverHome + "/bin/", ".sh");
+}
+
+eXo.server.Tomcat = Tomcat.prototype.constructor;
Added: portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/WorkflowConfig.js
===================================================================
--- portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/WorkflowConfig.js (rev 0)
+++ portal/trunk/packaging/exopackage/src/main/javascript/eXo/server/WorkflowConfig.js 2009-11-17 02:28:12 UTC (rev 612)
@@ -0,0 +1,56 @@
+eXo.require("eXo.core.TaskDescriptor");
+eXo.require("eXo.projects.Project");
+eXo.require("eXo.core.IOUtil");
+
+function WorkflowConfig() {
+
+}
+
+WorkflowConfig.prototype.patchWarWorkflow = function(server,product) {
+ var descriptor = new TaskDescriptor("Configure workflow", null) ;
+ var workflowName = java.lang.System.getProperty("workflow");
+ if (workflowName == null || workflowName == "") workflowName = "bonita";
+ descriptor.description = "Configure to use workflow with " + workflowName;
+ descriptor.execute =function () {
+ var jarFile = server.deployWebappDir + "/" + product.portalwar;
+ var IOUtil = eXo.core.IOUtil;
+ var mentries = new java.util.HashMap();
+ var properties = new java.util.HashMap();
+ properties.put("${workflow}", workflowName);
+ if (product.name == "eXoWorkflow") {
+ eXo.System.info("CONF", "JCR settings: " + properties.entrySet());
+ mentries = IOUtil.patchWar(jarFile, properties, "WEB-INF/conf/configuration.tmpl.xml",
+ "WEB-INF/conf/configuration.xml", mentries);
+ var portalwar = server.deployWebappDir + "/" + product.portalwar;
+ eXo.System.info("CONF", "Patching workflow config in " + portalwar + ": \n\t" + mentries.keySet());
+ IOUtil.modifyJar(portalwar, mentries, null);
+ }
+ if (product.name == "eXoDMS") {
+ var jarFile = server.deployWebappDir + "/" + product.portalwar;
+ var IOUtil = eXo.core.IOUtil;
+ var mentries = new java.util.HashMap();
+ var properties = new java.util.HashMap();
+ eXo.System.info("CONF", "Enable Workflow settings");
+ mentries = IOUtil.patchWar(jarFile, properties, "WEB-INF/conf/portal/group/organization/management/executive-board/navigation.workflow.xml",
+ "WEB-INF/conf/portal/group/organization/management/executive-board/navigation.xml", mentries);
+ var portalwar = server.deployWebappDir + "/" + product.portalwar;
+ eXo.System.info("CONF", "Patching workflow config in " + portalwar + ": \n\t" + mentries.keySet());
+ IOUtil.modifyJar(portalwar, mentries, null);
+
+ mentries = IOUtil.patchWar(jarFile, properties, "WEB-INF/conf/portal/group/platform/administrators/navigation.workflow.xml",
+ "WEB-INF/conf/portal/group/platform/administrators/navigation.xml", mentries);
+ var portalwar = server.deployWebappDir + "/" + product.portalwar;
+ eXo.System.info("CONF", "Patching workflow config in " + portalwar + ": \n\t" + mentries.keySet());
+ IOUtil.modifyJar(portalwar, mentries, null);
+
+ mentries = IOUtil.patchWar(jarFile, properties, "WEB-INF/conf/portal/group/platform/users/navigation.workflow.xml",
+ "WEB-INF/conf/portal/group/platform/users/navigation.xml", mentries);
+ var portalwar = server.deployWebappDir + "/" + product.portalwar;
+ eXo.System.info("CONF", "Patching workflow config in " + portalwar + ": \n\t" + mentries.keySet());
+ IOUtil.modifyJar(portalwar, mentries, null);
+ }
+ }
+ return descriptor;
+}
+
+eXo.server.WorkflowConfig = new WorkflowConfig();
Modified: portal/trunk/packaging/pkg/pom.xml
===================================================================
--- portal/trunk/packaging/pkg/pom.xml 2009-11-16 12:53:30 UTC (rev 611)
+++ portal/trunk/packaging/pkg/pom.xml 2009-11-17 02:28:12 UTC (rev 612)
@@ -34,10 +34,10 @@
<dependencies>
<dependency>
- <groupId>org.exoplatform.tool</groupId>
+ <groupId>org.exoplatform.portal</groupId>
<artifactId>exopackage</artifactId>
<type>zip</type>
- <version>1.1.0-Beta05</version>
+ <version>3.0.0-CR01-SNAPSHOT</version>
</dependency>
<dependency>
@@ -104,7 +104,7 @@
<overWriteSnapshots>true</overWriteSnapshots>
<artifactItems>
<artifactItem>
- <groupId>org.exoplatform.tool</groupId>
+ <groupId>org.exoplatform.portal</groupId>
<artifactId>exopackage</artifactId>
<type>zip</type>
<outputDirectory>target/exopackage</outputDirectory>
Modified: portal/trunk/packaging/pom.xml
===================================================================
--- portal/trunk/packaging/pom.xml 2009-11-16 12:53:30 UTC (rev 611)
+++ portal/trunk/packaging/pom.xml 2009-11-17 02:28:12 UTC (rev 612)
@@ -32,6 +32,7 @@
<name>GateIn Portal Packaging</name>
<modules>
+ <!--module>exopackage</module-->
<module>module</module>
<module>product</module>
<module>pkg</module>
15 years, 1 month
gatein SVN: r611 - in portal/trunk: component/common/src/main/java/org/exoplatform/services/resources and 20 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2009-11-16 07:53:30 -0500 (Mon, 16 Nov 2009)
New Revision: 611
Added:
portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/
portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/ConfigurationData.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/ConfigurationService.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/ConfigurationServiceImpl.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ExoResourceBundle.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/IdentityResourceBundle.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/InputStreamURLConnection.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/InputStreamURLStreamHandler.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/LocaleConfig.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/LocaleConfigService.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/Orientation.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/PropertiesClassLoader.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/Query.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ResourceBundleData.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ResourceBundleDescription.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ResourceBundleLoader.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ResourceBundleService.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/XMLResourceBundleParser.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/impl/
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/impl/BaseResourceBundlePlugin.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/impl/BaseResourceBundleService.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigImpl.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigServiceImpl.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/impl/SimpleResourceBundleService.java
portal/trunk/component/resources/src/test/java/locale/test/myRB1-2.xml
portal/trunk/component/resources/src/test/java/locale/test/myRB1.xml
portal/trunk/component/resources/src/test/java/locale/test/myRB1_en-2.xml
portal/trunk/component/resources/src/test/java/locale/test/myRB1_en.xml
portal/trunk/component/resources/src/test/java/locale/test/myRB1_fr-2.xml
portal/trunk/component/resources/src/test/java/locale/test/myRB1_fr.xml
portal/trunk/component/resources/src/test/java/locale/test/myRB2-2.properties
portal/trunk/component/resources/src/test/java/locale/test/myRB2.properties
portal/trunk/component/resources/src/test/java/locale/test/myRB2_en-2.properties
portal/trunk/component/resources/src/test/java/locale/test/myRB2_en.properties
portal/trunk/component/resources/src/test/java/locale/test/myRB2_fr-2.properties
portal/trunk/component/resources/src/test/java/locale/test/myRB2_fr.properties
portal/trunk/component/resources/src/test/java/org/exoplatform/services/resources/TestExoResourceBundle.java
portal/trunk/component/resources/src/test/java/org/exoplatform/services/resources/TestLocaleConfigService.java
portal/trunk/component/resources/src/test/java/resources/
portal/trunk/component/resources/src/test/java/resources/locales-config.xml
Removed:
portal/trunk/component/common/src/main/java/org/exoplatform/services/config/
portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ExoResourceBundle.java
portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/IdentityResourceBundle.java
portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/InputStreamURLConnection.java
portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/InputStreamURLStreamHandler.java
portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/LocaleConfig.java
portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/LocaleConfigService.java
portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/Orientation.java
portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/PropertiesClassLoader.java
portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/Query.java
portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ResourceBundleData.java
portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ResourceBundleDescription.java
portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ResourceBundleLoader.java
portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ResourceBundleService.java
portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/XMLResourceBundleParser.java
portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/BaseResourceBundlePlugin.java
portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/BaseResourceBundleService.java
portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigImpl.java
portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigServiceImpl.java
portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/hibernate/ResourceBundleServiceImpl.java
portal/trunk/component/common/src/test/java/org/exoplatform/services/resources/TestExoResourceBundle.java
portal/trunk/component/common/src/test/java/org/exoplatform/services/resources/TestLocaleConfigService.java
portal/trunk/component/common/src/test/java/org/exoplatform/services/resources/impl/TesBaseResourceBundleService.java
portal/trunk/component/common/src/test/resources/locale/test/
portal/trunk/component/common/src/test/resources/resources/
portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/ConfigurationData.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/ConfigurationService.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/ConfigurationServiceImpl.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/jcr/
portal/trunk/component/resources/src/test/java/resources/locales-config.xml
Modified:
portal/trunk/component/pc/src/main/java/org/exoplatform/portal/pc/ExoKernelIntegration.java
portal/trunk/component/resources/pom.xml
portal/trunk/component/resources/src/main/java/conf/portal/configuration.xml
portal/trunk/component/resources/src/test/java/conf/portal/test-configuration.xml
portal/trunk/component/web/pom.xml
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/common/common-configuration.xml
Log:
GTNPORTAL-253 : Remove resource bundle persistence
Deleted: portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ExoResourceBundle.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ExoResourceBundle.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ExoResourceBundle.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,161 +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.services.resources;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.ListResourceBundle;
-import java.util.Map;
-import java.util.ResourceBundle;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * May 7, 2004
- *
- * @author: Tuan Nguyen
- * @email: tuan08(a)users.sourceforge.net
- * @version: $Id: ExoResourceBundle.java 9439 2006-10-12 03:28:53Z thuannd $
- **/
-@SuppressWarnings("serial")
-public class ExoResourceBundle extends ListResourceBundle implements Serializable
-{
-
- private static Pattern LINE_SEPARATOR = Pattern.compile("[\\r]?\\n");
-
- private static Pattern UNICODE_CHARACTER = Pattern.compile("\\\\u[\\p{XDigit}]{4}+");
-
- private Object[][] contents;
-
- public ExoResourceBundle(String data)
- {
- String[] tokens = LINE_SEPARATOR.split(data);
- List<String[]> properties = new ArrayList<String[]>();
- for (String token : tokens)
- {
- int idx = token.indexOf('=');
- if (idx < 0 || idx >= token.length() - 1)
- {
- continue;
- }
- String key = token.substring(0, idx);
- if (key.trim().startsWith("#"))
- {
- continue;
- }
- String value = convert(token.substring(idx + 1, token.length()));
- properties.add(new String[]{key, value});
- }
- String[][] aProperties = new String[properties.size()][2];
- contents = (String[][])properties.toArray(aProperties);
- }
-
- public ExoResourceBundle(String data, ResourceBundle parent)
- {
- this(data);
- setParent(parent);
- }
-
- public Object[][] getContents()
- {
- return contents;
- }
-
- public void putAll(Map<? super Object, ? super Object> map)
- {
- Enumeration<String> keys = getKeys();
- while (keys.hasMoreElements())
- {
- String key = keys.nextElement();
- if (key != null)
- {
- map.put(key, getString(key));
- }
- }
- }
-
- static String convert(String content)
- {
- Matcher matcher = UNICODE_CHARACTER.matcher(content);
- StringBuilder buffer = new StringBuilder(content.length());
- int start = 0;
- while (matcher.find(start))
- {
- buffer.append(content.substring(start, matcher.start()));
- buffer.append(unicode2Char(matcher.group()));
- start = matcher.end();
- }
- if (start >= 0 && start < content.length())
- {
- buffer.append(content.substring(start));
- }
- return buffer.toString();
- }
-
- static char unicode2Char(String unicodeChar)
- {
- int value = 0;
- char aChar;
- for (int i = 0; i < 4; i++)
- {
- aChar = unicodeChar.charAt(i + 2);
- switch (aChar)
- {
- case '0' :
- case '1' :
- case '2' :
- case '3' :
- case '4' :
- case '5' :
- case '6' :
- case '7' :
- case '8' :
- case '9' : {
- value = (value << 4) + aChar - '0';
- break;
- }
- case 'a' :
- case 'b' :
- case 'c' :
- case 'd' :
- case 'e' :
- case 'f' : {
- value = (value << 4) + 10 + aChar - 'a';
- break;
- }
- case 'A' :
- case 'B' :
- case 'C' :
- case 'D' :
- case 'E' :
- case 'F' : {
- value = (value << 4) + 10 + aChar - 'A';
- break;
- }
- default : {
- throw new IllegalArgumentException("Malformed \\uxxxx encoding.");
- }
- }
- }
- return (char)value;
- }
-}
Deleted: portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/IdentityResourceBundle.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/IdentityResourceBundle.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/IdentityResourceBundle.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,58 +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.services.resources;
-
-import java.util.Enumeration;
-import java.util.Locale;
-import java.util.ResourceBundle;
-import java.util.Vector;
-
-/**
- * A resource bundle that returns the queried key. It returns an empty enumeration when the keys are queried.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class IdentityResourceBundle extends ResourceBundle
-{
-
- public static final String MAGIC_LANGUAGE = "ma".intern();
-
- public static final Locale MAGIC_LOCALE = new Locale(MAGIC_LANGUAGE);
-
- private static final Vector<String> EMPTY_KEYS = new Vector<String>();
-
- private static final IdentityResourceBundle instance = new IdentityResourceBundle();
-
- public static ResourceBundle getInstance()
- {
- return instance;
- }
-
- protected Object handleGetObject(String key)
- {
- return key;
- }
-
- public Enumeration<String> getKeys()
- {
- return EMPTY_KEYS.elements();
- }
-}
Deleted: portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/InputStreamURLConnection.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/InputStreamURLConnection.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/InputStreamURLConnection.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,68 +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.services.resources;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLConnection;
-
-/**
- * An URLConnection extension that use a local {@link java.io.InputStream} object.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class InputStreamURLConnection extends URLConnection
-{
-
- private final InputStream in;
-
- /**
- * Creates a new connection.
- *
- * @param url the original URL
- * @param in the input stream
- * @throws IllegalArgumentException if the stream is null
- */
- public InputStreamURLConnection(URL url, InputStream in) throws IllegalArgumentException
- {
- super(url);
-
- //
- if (in == null)
- {
- throw new IllegalArgumentException("No null input stream accepted");
- }
-
- //
- this.in = in;
- }
-
- public void connect() throws IOException
- {
- // no op
- }
-
- public InputStream getInputStream() throws IOException
- {
- return in;
- }
-}
Deleted: portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/InputStreamURLStreamHandler.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/InputStreamURLStreamHandler.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/InputStreamURLStreamHandler.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,62 +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.services.resources;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLStreamHandler;
-
-/**
- * An URLStreamHandler extension that use a local {@link java.io.InputStream} object. This object will always use
- * the stream provided and nothing else. So the life time of an instance is very limited.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class InputStreamURLStreamHandler extends URLStreamHandler
-{
-
- private final InputStream in;
-
- /**
- * Creates a new handler.
- *
- * @param in the input stream
- * @throws IllegalArgumentException if the stream is null
- */
- public InputStreamURLStreamHandler(InputStream in) throws IllegalArgumentException
- {
- if (in == null)
- {
- throw new IllegalArgumentException("No null input stream accepted");
- }
-
- //
- this.in = in;
- }
-
- protected URLConnection openConnection(URL u) throws IOException
- {
- return new InputStreamURLConnection(u, in);
- }
-
-}
Deleted: portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/LocaleConfig.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/LocaleConfig.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/LocaleConfig.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,84 +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.services.resources;
-
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * May 3, 2004
- *
- * @author: Tuan Nguyen
- * @email: tuan08(a)users.sourceforge.net
- * @version: $Id: LocaleConfig.java 5799 2006-05-28 17:55:42Z geaz $
- **/
-public interface LocaleConfig
-{
-
- public String getDescription();
-
- public void setDescription(String desc);
-
- public String getOutputEncoding();
-
- public void setOutputEncoding(String enc);
-
- public String getInputEncoding();
-
- public void setInputEncoding(String enc);
-
- public Locale getLocale();
-
- public void setLocale(Locale locale);
-
- public void setLocale(String localeName);
-
- public String getLanguage();
-
- public String getLocaleName();
-
- public ResourceBundle getResourceBundle(String name);
-
- public ResourceBundle getMergeResourceBundle(String[] names);
-
- public ResourceBundle getNavigationResourceBundle(String ownerType, String ownerId);
-
- public void setInput(HttpServletRequest req) throws java.io.UnsupportedEncodingException;
-
- public void setOutput(HttpServletResponse res);
-
- /**
- * Returns the orientation of the locale config.
- *
- * @return the orientation
- */
- public Orientation getOrientation();
-
- /**
- * Updates the orientation of the locale config.
- *
- * @param orientation the new orientation
- */
- public void setOrientation(Orientation orientation);
-
-}
Deleted: portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/LocaleConfigService.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/LocaleConfigService.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/LocaleConfigService.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,47 +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.services.resources;
-
-import java.util.Collection;
-
-/**
- * @author Benjamin Mestrallet benjamin.mestrallet(a)exoplatform.com This Service
- * is used to manage the locales that the applications can handle
- */
-public interface LocaleConfigService
-{
-
- /**
- * @return Return the default LocaleConfig
- */
- public LocaleConfig getDefaultLocaleConfig();
-
- /**
- * @param lang a locale language
- * @return The LocalConfig
- */
- public LocaleConfig getLocaleConfig(String lang);
-
- /**
- * @return All the LocalConfig that manage by the service
- */
- public Collection<LocaleConfig> getLocalConfigs();
-
-}
Deleted: portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/Orientation.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/Orientation.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/Orientation.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,85 +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.services.resources;
-
-/**
- * An orientation.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public enum Orientation {
-
- LT(0), // Western Europe
-
- RT(1), // Middle East (Arabic, Hebrew)
-
- TL(2), // Japanese, Chinese, Korean
-
- TR(3); // Mongolian
-
- private final int ordinal;
-
- Orientation(int ordinal)
- {
- this.ordinal = ordinal;
- }
-
- /**
- * Indicates whether the Locale correspond to an LT orientation.
- *
- * @return true if the orientation is LT
- */
- public boolean isLT()
- {
- return ordinal == 0;
- }
-
- /**
- * Indicates whether the Locale correspond to an RT orientation.
- *
- * @return true if the orientation is RT
- */
- public boolean isRT()
- {
- return ordinal == 1;
- }
-
- /**
- * Indicates whether the Locale correspond to an TL orientation.
- *
- * @return true if the orientation is TL
- */
- public boolean isTL()
- {
- return ordinal == 2;
- }
-
- /**
- * Indicates whether the Locale correspond to an TR orientation.
- *
- * @return true if the orientation is TR
- */
- public boolean isTR()
- {
- return ordinal == 3;
- }
-
-}
Deleted: portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/PropertiesClassLoader.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/PropertiesClassLoader.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/PropertiesClassLoader.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,200 +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.services.resources;
-
-import org.exoplatform.commons.utils.IOUtil;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.Map;
-import java.util.Properties;
-import java.util.TreeMap;
-
-/**
- * A {@link ClassLoader} extension that will retrieve resources from the parent
- * classloader. For each resource having a ".properties" suffix it the
- * classloader will try first to locate a corresponding resource using the same
- * base name but with an ".xml" suffix. If such a resource is found, it will be
- * loaded using {@link XMLResourceBundleParser}
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class PropertiesClassLoader extends ClassLoader
-{
-
- /**
- * Logger.
- */
- private static final Log LOG = ExoLogger.getLogger(PropertiesClassLoader.class);
-
- /**
- * Indicates whether the resource must be encoded into UTF-8
- */
- private boolean unicode;
-
- public PropertiesClassLoader(ClassLoader parent)
- {
- this(parent, false);
- }
-
- public PropertiesClassLoader(ClassLoader parent, boolean unicode)
- {
- super(parent);
- this.unicode = unicode;
- }
-
- public PropertiesClassLoader()
- {
- }
-
- @Override
- public URL getResource(String name)
- {
- if (name.endsWith(".properties"))
- {
- URL url = null;
- ClassLoader parent = getParent();
- while (parent != null)
- {
- url = getResource(parent, name, unicode);
- if (url != null)
- {
- return url;
- }
- parent = parent.getParent();
- }
- if (url == null)
- {
- url = getResource(this, name, unicode);
- }
- return url;
- }
- return super.getResource(name);
- }
-
- private static URL getResource(ClassLoader cl, String name, boolean unicode)
- {
- String xmlName = name.substring(0, name.length() - ".properties".length()) + ".xml";
- URL url = getResource(cl, xmlName, unicode, true);
- if (url == null)
- {
- url = getResource(cl, name, unicode, false);
- }
- return url;
- }
-
- private static URL getResource(ClassLoader cl, String name, boolean unicode, boolean xml)
- {
- Enumeration<URL> urls = null;
- try
- {
- urls = cl.getResources(name);
- }
- catch (Exception e)
- {
- LOG.error("An error occured while seeking all the resources with the name " + name, e);
- return null;
- }
- if (urls != null && urls.hasMoreElements())
- {
- // At least one such resource has been found
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- URL url = null;
- Map<Object, Object> props = unicode ? new TreeMap<Object, Object>() : new Properties();
- while (urls.hasMoreElements())
- {
- url = urls.nextElement();
- InputStream in = null;
- try
- {
- // Load content
- in = url.openStream();
- if (xml)
- {
- props.putAll(XMLResourceBundleParser.asProperties(in));
- }
- else
- {
- byte[] buf = IOUtil.getStreamContentAsBytes(in);
- ExoResourceBundle bundle = new ExoResourceBundle(new String(buf, "UTF-8"));
- bundle.putAll(props);
- }
- }
- catch (Exception e)
- {
- LOG.error("An error occured while loading the content of " + url, e);
- return null;
- }
- finally
- {
- if (in != null)
- {
- try
- {
- in.close();
- }
- catch (IOException e)
- {
- // Do nothing
- }
- }
- }
- }
- try
- {
- // Now serialize as binary
- if (unicode)
- {
- // Encoded into UTF-8
- for (Map.Entry<Object, Object> entry : props.entrySet())
- {
- out.write(((String)entry.getKey()).getBytes("UTF-8"));
- out.write('=');
- out.write(((String)entry.getValue()).getBytes("UTF-8"));
- out.write('\n');
- }
- }
- else
- {
- // Properties format : encoded into ISO-8859-1 with unicode characters
- ((Properties)props).store(out, null);
- }
- out.close();
- InputStream in = new ByteArrayInputStream(out.toByteArray());
-
- //
- return new URL(url, "", new InputStreamURLStreamHandler(in));
- }
- catch (Exception e)
- {
- LOG.error("An error occured while creating the content of " + url, e);
- return null;
- }
- }
- return null;
- }
-}
Deleted: portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/Query.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/Query.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/Query.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,71 +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.services.resources;
-
-/**
- * Created by The eXo Platform SAS . Author : Tuan Nguyen
- * tuan08(a)users.sourceforge.net Date: Jun 14, 2003 Time: 1:12:22 PM
- */
-public class Query
-{
-
- private String name_;
-
- private String languages_;
-
- private int maxSize_;
-
- public Query(String name, String language)
- {
- name_ = name;
- languages_ = language;
- maxSize_ = 100;
- }
-
- public String getName()
- {
- return name_;
- }
-
- public void setName(String s)
- {
- name_ = s;
- }
-
- public String getLanguage()
- {
- return languages_;
- }
-
- public void setLanguage(String s)
- {
- languages_ = s;
- }
-
- public int getMaxSize()
- {
- return maxSize_;
- }
-
- public void setMaxSize(int s)
- {
- maxSize_ = s;
- }
-}
Deleted: portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ResourceBundleData.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ResourceBundleData.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ResourceBundleData.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,53 +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.services.resources;
-
-import java.io.Serializable;
-
-/**
- * Created by The eXo Platform SAS . Author : Tuan Nguyen
- * tuan08(a)users.sourceforge.net Date: May 14, 2004 Time: 1:12:22 PM
- */
-@SuppressWarnings("serial")
-public class ResourceBundleData extends ResourceBundleDescription implements Serializable
-{
-
- private String data_;
-
- public ResourceBundleData()
- {
- setResourceType("-");
- setLanguage(DEFAULT_LANGUAGE);
- }
-
- /**
- * @hibernate.property length="65535"
- * type="org.exoplatform.services.database.impl.TextClobType"
- **/
- public String getData()
- {
- return data_;
- }
-
- public void setData(String data)
- {
- data_ = data;
- }
-}
Deleted: portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ResourceBundleDescription.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ResourceBundleDescription.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ResourceBundleDescription.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,138 +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.services.resources;
-
-import java.io.Serializable;
-
-/**
- * Created by The eXo Platform SAS . Author : Tuan Nguyen
- * tuan08(a)users.sourceforge.net Date: May 14, 2004 Time: 1:12:22 PM
- */
-@SuppressWarnings("serial")
-public class ResourceBundleDescription implements Serializable
-{
-
- protected String id_;
-
- protected String name_;
-
- protected String language_;
-
- protected String country_;
-
- protected String variant_;
-
- protected String resourceType_;
-
- public ResourceBundleDescription()
- {
- }
-
- /**
- * @hibernate.id generator-class="assigned"
- **/
- public String getId()
- {
- if (id_ == null)
- {
- StringBuffer b = new StringBuffer();
- b.append(name_);
- if (language_ != null)
- b.append('_').append(language_);
- // if(country_ != null) b.append('_').append(country_);
- // if(variant_ != null) b.append('_').append(variant_);
- id_ = b.toString();
- }
- return id_;
- }
-
- public void setId(String id)
- {
- id_ = id;
- }
-
- /**
- * @hibernate.property
- **/
- public String getName()
- {
- return name_;
- }
-
- public void setName(String name)
- {
- name_ = name;
- }
-
- /**
- * @hibernate.property
- **/
- public String getLanguage()
- {
- return language_;
- }
-
- public void setLanguage(String s)
- {
- language_ = s;
- }
-
- /**
- * @hibernate.property
- **/
- public String getCountry()
- {
- return country_;
- }
-
- public void setCountry(String s)
- {
- country_ = s;
- }
-
- /**
- * @hibernate.property
- **/
- public String getVariant()
- {
- return variant_;
- }
-
- public void setVariant(String s)
- {
- variant_ = s;
- }
-
- /**
- * @hibernate.property
- **/
- public String getResourceType()
- {
- return resourceType_;
- }
-
- public void setResourceType(String s)
- {
- resourceType_ = s;
- }
-
- final static public String DEFAULT_LANGUAGE = "en";
-
-}
Deleted: portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ResourceBundleLoader.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ResourceBundleLoader.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ResourceBundleLoader.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,43 +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.services.resources;
-
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-/**
- * A facade for obtaining resource bundles.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class ResourceBundleLoader
-{
-
- public static ResourceBundle load(String baseName, Locale locale, ClassLoader classLoader)
- {
- if (IdentityResourceBundle.MAGIC_LANGUAGE.equals(locale.getLanguage()))
- {
- return IdentityResourceBundle.getInstance();
- }
- PropertiesClassLoader pcl = new PropertiesClassLoader(classLoader);
- return ResourceBundle.getBundle(baseName, locale, pcl);
- }
-}
Deleted: portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ResourceBundleService.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ResourceBundleService.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ResourceBundleService.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,128 +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.services.resources;
-
-import org.exoplatform.commons.utils.PageList;
-
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-/**
- * May 7, 2004
- *
- * @author: Tuan Nguyen
- * @email: tuan08(a)users.sourceforge.net
- * @version: $Id: ResourceBundleService.java 5799 2006-05-28 17:55:42Z geaz $
- * This class is used to manage the Resoucebunlde. It should work like
- * the java.util.ResourceBundle class except that the properties file
- * can be in the database or a a directory. The class
- * java.util.ResourceBundle require that the properties file has to be
- * in the classpath.
- **/
-public interface ResourceBundleService
-{
- /**
- * This method should search for a template in the database that the service
- * manage or the resource in the classpath of the current thread class loader
- *
- * @param name The name of the resource bunlde
- * @param locale the locale
- * @return A ResourceBunlde or null if no ResourceBundle is found
- */
- public ResourceBundle getResourceBundle(String name, Locale locale);
-
- /**
- * This method should search for a template in the database that the service
- * manage or the resource in the classpath of the specified class loader
- *
- * @param name the name of the resource
- * @param locale the locale
- * @param cl The classloader
- * @return
- */
- public ResourceBundle getResourceBundle(String name, Locale locale, ClassLoader cl);
-
- /**
- * This method will call the method public ResourceBundle
- * getResourceBundle(String[] name, Locale locale, ClassLoader cl) and using
- * the the classloader of the current thread
- */
- public ResourceBundle getResourceBundle(String[] name, Locale locale);
-
- /**
- * This method will look for all the resources with the given names and merge
- * into one resource bundle, the properties in the later resource bundle name
- * will have the higher priority than the previous one.
- */
- public ResourceBundle getResourceBundle(String[] name, Locale locale, ClassLoader cl);
-
- /**
- * This method should look for a resource bundle in the database that match
- * the given id. The ResourceBundleData store the data as text instead of a
- * properties map.
- *
- * @param id The id of the resource bundle data
- * @return A ResourceBundleData instance or no record is found.
- * @throws Exception
- */
- public ResourceBundleData getResourceBundleData(String id) throws Exception;
-
- /**
- * This method remove the data record in the databas and return the data
- * instance after it has been removed
- *
- * @param id The id of the data record
- * @return A ResourceBundleData instance
- * @throws Exception
- */
- public ResourceBundleData removeResourceBundleData(String id) throws Exception;
-
- /**
- * This method shoudl create or update a ResourceBundleData instance
- *
- * @param data the ResourceBundleData instance to update or create
- * @throws Exception
- */
- public void saveResourceBundle(ResourceBundleData data) throws Exception;
-
- /**
- * This method search and return a page description iterator
- *
- * @param q The search criteria
- * @return A PageDescription Iterator
- * @throws Exception
- */
- public PageList findResourceDescriptions(Query q) throws Exception;
-
- /**
- * This method is acted as a factory of
- *
- * @return
- */
- public ResourceBundleData createResourceBundleDataInstance();
-
- /**
- * The developer can store the common properties in certain resource bundles
- * so later he can merge a resource bundle with the shared resource bunldes
- *
- * @return the name of the shared resource bundle
- */
- public String[] getSharedResourceBundleNames();
-}
Deleted: portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/XMLResourceBundleParser.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/XMLResourceBundleParser.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/XMLResourceBundleParser.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,205 +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.services.resources;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-/**
- * A parser for XML resource bundle having the following rules:
- *
- * <ul>
- * <li>The root document element is named "bundle"</li>
- * <li>Any non root element can have any name</li>
- * <li>Any non root element content must not have mixed content (i.e text and children elements)</li>
- * <li>Any element having textual content is considered as a bundle entry with they key formed by the
- * dot concatenation of its parent element name except the root element and the value is the text content</li>
- * </ul>
- *
- * For instance the following document:
- *
- * <bundle>
- * <foo>
- * <A>1<A>
- * <B>2<B>
- * </foo>
- * <C>3<C>
- * </bundle>
- *
- * will give the bundle with entries:
- *
- * <ul>
- * <li>foo.A=1</li>
- * <li>foo.B=2</li>
- * <li>C=3</li>
- * </ul>
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class XMLResourceBundleParser
-{
-
- /**
- * @see #asMap(org.xml.sax.InputSource)
- */
- public static Properties asProperties(InputStream in) throws IOException, SAXException,
- ParserConfigurationException, IllegalArgumentException
- {
- if (in == null)
- {
- throw new IllegalArgumentException("No null input stream allowed");
- }
- return asProperties(new InputSource(in));
- }
-
- /**
- * @see #asMap(org.xml.sax.InputSource)
- */
- public static Properties asProperties(Reader in) throws IOException, SAXException, ParserConfigurationException,
- IllegalArgumentException
- {
- if (in == null)
- {
- throw new IllegalArgumentException("No null reader allowed");
- }
- return asProperties(new InputSource(in));
- }
-
- /**
- * @see #asMap(org.xml.sax.InputSource)
- */
- public static Properties asProperties(InputSource in) throws IOException, SAXException,
- ParserConfigurationException, IllegalArgumentException
- {
- if (in == null)
- {
- throw new IllegalArgumentException("No null input source allowed");
- }
- Map<String, String> bundle = asMap(in);
- Properties props = new Properties();
- props.putAll(bundle);
- return props;
- }
-
- /**
- * @see #asMap(org.xml.sax.InputSource)
- */
- public static Map<String, String> asMap(InputStream in) throws IOException, SAXException,
- ParserConfigurationException, IllegalArgumentException
- {
- if (in == null)
- {
- throw new IllegalArgumentException("No null input stream allowed");
- }
- return asMap(new InputSource(in));
- }
-
- /**
- * @see #asMap(org.xml.sax.InputSource)
- */
- public static Map<String, String> asMap(Reader in) throws IOException, SAXException, ParserConfigurationException,
- IllegalArgumentException
- {
- if (in == null)
- {
- throw new IllegalArgumentException("No null reader allowed");
- }
- return asMap(new InputSource(in));
- }
-
- /**
- * Load an xml resource bundle as a {@link Map<String,String>} object.
- *
- * @param in the input source
- * @return the properties object
- * @throws IOException any IOException
- * @throws SAXException any SAXException
- * @throws ParserConfigurationException any ParserConfigurationException
- * @throws IllegalArgumentException if the argument is null
- */
- public static Map<String, String> asMap(InputSource in) throws IOException, SAXException,
- ParserConfigurationException, IllegalArgumentException
- {
- if (in == null)
- {
- throw new IllegalArgumentException("No null input source allowed");
- }
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document document = builder.parse(in);
- Element bundleElt = document.getDocumentElement();
- HashMap<String, String> bundle = new HashMap<String, String>();
- collect(new LinkedList<String>(), bundleElt, bundle);
- return bundle;
- }
-
- private static void collect(LinkedList<String> path, Element currentElt, Map<String, String> bundle)
- {
- NodeList children = currentElt.getChildNodes();
- boolean text = true;
- for (int i = children.getLength() - 1; i >= 0; i--)
- {
- Node child = children.item(i);
- if (child.getNodeType() == Node.ELEMENT_NODE)
- {
- text = false;
- Element childElt = (Element)child;
- String name = childElt.getTagName();
- path.addLast(name);
- collect(path, childElt, bundle);
- path.removeLast();
- }
- }
- if (text && path.size() > 0)
- {
- String value = currentElt.getTextContent();
- StringBuffer sb = new StringBuffer();
- for (Iterator<String> i = path.iterator(); i.hasNext();)
- {
- String name = i.next();
- sb.append(name);
- if (i.hasNext())
- {
- sb.append('.');
- }
- }
- String key = sb.toString();
- bundle.put(key, value);
- }
- }
-}
Deleted: portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/BaseResourceBundlePlugin.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/BaseResourceBundlePlugin.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/BaseResourceBundlePlugin.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,75 +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.services.resources.impl;
-
-import org.exoplatform.container.component.BaseComponentPlugin;
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.container.xml.ValuesParam;
-
-import java.util.List;
-
-/**
- * This class is used to define new resource bundles
- *
- * Created by The eXo Platform SAS
- * Author : Nicolas Filotto
- * nicolas.filotto(a)exoplatform.com
- * 24 sept. 2009
- */
-public class BaseResourceBundlePlugin extends BaseComponentPlugin
-{
-
- private final InitParams params;
-
- public BaseResourceBundlePlugin(InitParams params)
- {
- this.params = params;
- }
-
- /**
- * @return the list of enclosed "classpath" resource bundles
- */
- @SuppressWarnings("unchecked")
- public List<String> getClasspathResources()
- {
- ValuesParam vParam = params.getValuesParam("classpath.resources");
- return vParam == null ? null : vParam.getValues();
- }
-
- /**
- * @return the list of enclosed "portal" resource bundles
- */
- @SuppressWarnings("unchecked")
- public List<String> getPortalResources()
- {
- ValuesParam vParam = params.getValuesParam("portal.resource.names");
- return vParam == null ? null : vParam.getValues();
- }
-
- /**
- * @return the list of enclosed "init" resource bundles
- */
- @SuppressWarnings("unchecked")
- public List<String> getInitResources()
- {
- ValuesParam vParam = params.getValuesParam("init.resources");
- return vParam == null ? null : vParam.getValues();
- }
-}
Deleted: portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/BaseResourceBundleService.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/BaseResourceBundleService.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/BaseResourceBundleService.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,341 +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.services.resources.impl;
-
-import org.exoplatform.commons.utils.IOUtil;
-import org.exoplatform.commons.utils.MapResourceBundle;
-import org.exoplatform.commons.utils.PageList;
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.services.log.Log;
-import org.exoplatform.services.resources.IdentityResourceBundle;
-import org.exoplatform.services.resources.LocaleConfig;
-import org.exoplatform.services.resources.LocaleConfigService;
-import org.exoplatform.services.resources.PropertiesClassLoader;
-import org.exoplatform.services.resources.Query;
-import org.exoplatform.services.resources.ResourceBundleData;
-import org.exoplatform.services.resources.ResourceBundleLoader;
-import org.exoplatform.services.resources.ResourceBundleService;
-import org.picocontainer.Startable;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-/**
- * Created by The eXo Platform SAS Mar 9, 2007
- */
-abstract public class BaseResourceBundleService implements ResourceBundleService, Startable
-{
-
- protected Log log_;
-
- protected volatile List<String> classpathResources_;
-
- protected volatile String[] portalResourceBundleNames_;
-
- protected LocaleConfigService localeService_;
-
- protected ExoCache<String, ResourceBundle> cache_;
-
- private volatile List<String> initResources_;
-
- @SuppressWarnings("unchecked")
- protected void initParams(InitParams params)
- {
- classpathResources_ = params.getValuesParam("classpath.resources").getValues();
-
- // resources name can use for portlets
- List prnames = params.getValuesParam("portal.resource.names").getValues();
- portalResourceBundleNames_ = new String[prnames.size()];
- for (int i = 0; i < prnames.size(); i++)
- {
- portalResourceBundleNames_[i] = (String)prnames.get(i);
- }
-
- initResources_ = params.getValuesParam("init.resources").getValues();
- }
-
- /**
- * Add new resources bundles
- */
- public synchronized void addResourceBundle(BaseResourceBundlePlugin plugin)
- {
- List<String> classpathResources = plugin.getClasspathResources();
- if (classpathResources != null && !classpathResources.isEmpty())
- {
- List<String> result = new ArrayList<String>(classpathResources);
- if (classpathResources_ != null)
- {
- result.addAll(classpathResources_);
- }
- this.classpathResources_ = Collections.unmodifiableList(result);
- }
- List<String> portalResources = plugin.getPortalResources();
- if (portalResources != null && !portalResources.isEmpty())
- {
- List<String> result = new ArrayList<String>(portalResources);
- if (portalResourceBundleNames_ != null)
- {
- result.addAll(Arrays.asList(portalResourceBundleNames_));
- }
- this.portalResourceBundleNames_ = (String[])result.toArray(new String[result.size()]);
- }
- List<String> initResources = plugin.getInitResources();
- if (initResources != null && !initResources.isEmpty())
- {
- List<String> result = new ArrayList<String>(initResources);
- if (initResources_ != null)
- {
- result.addAll(initResources_);
- }
- this.initResources_ = Collections.unmodifiableList(result);
- }
- }
-
- /**
- * Loads all the "init" resource bundles
- * @see org.picocontainer.Startable#start()
- */
- public void start()
- {
- PageList pl = null;
- try
- {
- pl = findResourceDescriptions(new Query(null, null));
- }
- catch (Exception e)
- {
- throw new RuntimeException("Cannot check if a resource already exists", e);
- }
- if (pl.getAvailable() > 0)
- return;
-
- // init resources
- List<String> initResources = initResources_;
- for (String resource : initResources)
- {
- initResources(resource, Thread.currentThread().getContextClassLoader());
- }
- }
-
- /**
- * @see org.picocontainer.Startable#stop()
- */
- public void stop()
- {
- }
-
- public ResourceBundle getResourceBundle(String[] name, Locale locale)
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- return getResourceBundle(name, locale, cl);
- }
-
- public ResourceBundle getResourceBundle(String name, Locale locale)
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- return getResourceBundle(name, locale, cl);
- }
-
- public String[] getSharedResourceBundleNames()
- {
- return portalResourceBundleNames_;
- }
-
- public ResourceBundleData createResourceBundleDataInstance()
- {
- return new ResourceBundleData();
- }
-
- protected boolean isClasspathResource(String name)
- {
- if (classpathResources_ == null)
- return false;
- for (int i = 0; i < classpathResources_.size(); i++)
- {
- String pack = classpathResources_.get(i);
- if (name.startsWith(pack))
- return true;
- }
- return false;
- }
-
- protected void initResources(String baseName, ClassLoader cl)
- {
- String name = baseName.replace('.', '/');
- try
- {
- Collection<LocaleConfig> localeConfigs = localeService_.getLocalConfigs();
- String defaultLang = localeService_.getDefaultLocaleConfig().getLanguage();
- for (Iterator<LocaleConfig> iter = localeConfigs.iterator(); iter.hasNext();)
- {
- LocaleConfig localeConfig = iter.next();
- String language = localeConfig.getLanguage();
- String content = getResourceBundleContent(name, language, defaultLang, cl);
- if (content != null)
- {
- // save the content
- ResourceBundleData data = new ResourceBundleData();
- data.setId(baseName + "_" + language);
- data.setName(baseName);
- data.setLanguage(language);
- data.setData(content);
- saveResourceBundle(data);
- }
- }
- }
- catch (Exception ex)
- {
- log_.error("Error while reading the resource bundle : " + baseName, ex);
- }
- }
-
- protected String getResourceBundleContent(String name, String language, String defaultLang, ClassLoader cl)
- throws Exception
- {
- String fileName = null;
- try
- {
- cl = new PropertiesClassLoader(cl, true);
- fileName = name + "_" + language + ".properties";
- URL url = cl.getResource(fileName);
- if (url == null && defaultLang.equals(language))
- {
- url = cl.getResource(name + ".properties");
- }
- if (url != null)
- {
- InputStream is = url.openStream();
- try
- {
- byte[] buf = IOUtil.getStreamContentAsBytes(is);
- return new String(buf, "UTF-8");
- }
- finally
- {
- try
- {
- is.close();
- }
- catch (IOException e)
- {
- // Do nothing
- }
- }
- }
- }
- catch (Exception e)
- {
- throw new Exception("Error while reading the file: " + fileName, e);
- }
- return null;
- }
-
- public ResourceBundle getResourceBundle(String name, Locale locale, ClassLoader cl)
- {
- if (IdentityResourceBundle.MAGIC_LANGUAGE.equals(locale.getLanguage()))
- {
- return IdentityResourceBundle.getInstance();
- }
- if (isClasspathResource(name))
- return ResourceBundleLoader.load(name, locale, cl);
- String id = name + "_" + locale.getLanguage();
- try
- {
- ResourceBundle rb = cache_.get(id);
- if (rb != null)
- return rb;
- }
- catch (Exception ex)
- {
- }
-
- try
- {
- ResourceBundle res = null;
- String rootId = name + "_" + localeService_.getDefaultLocaleConfig().getLanguage();
- ResourceBundle parent = getResourceBundleFromDb(rootId, null, locale);
- if (parent != null)
- {
- res = getResourceBundleFromDb(id, parent, locale);
- if (res == null)
- res = parent;
- cache_.put(id, res);
- return res;
- }
- }
- catch (Exception ex)
- {
- log_.error("Error: " + id, ex);
- }
- return null;
- }
-
- public ResourceBundle getResourceBundle(String[] name, Locale locale, ClassLoader cl)
- {
- if (IdentityResourceBundle.MAGIC_LANGUAGE.equals(locale.getLanguage()))
- {
- return IdentityResourceBundle.getInstance();
- }
- StringBuilder idBuf = new StringBuilder("merge:");
- for (String n : name)
- idBuf.append(n).append("_");
- idBuf.append(locale);
- String id = idBuf.toString();
- try
- {
- ResourceBundle res = cache_.get(id);
- if (res != null)
- return res;
- MapResourceBundle outputBundled = new MapResourceBundle(locale);
- for (int i = 0; i < name.length; i++)
- {
- ResourceBundle temp = getResourceBundle(name[i], locale, cl);
- if (temp != null)
- {
- outputBundled.merge(temp);
- continue;
- }
- log_.warn("Cannot load and merge the bundle: " + name[i]);
- }
- outputBundled.resolveDependencies();
- cache_.put(id, outputBundled);
- return outputBundled;
- }
- catch (Exception ex)
- {
- log_.error("Cannot load and merge the bundle: " + id, ex);
- }
- return null;
- }
-
- abstract protected ResourceBundle getResourceBundleFromDb(String id, ResourceBundle parent, Locale locale)
- throws Exception;
-
-}
Deleted: portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigImpl.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigImpl.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigImpl.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,183 +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.services.resources.impl;
-
-import org.exoplatform.container.ExoContainerContext;
-import org.exoplatform.services.resources.LocaleConfig;
-import org.exoplatform.services.resources.Orientation;
-import org.exoplatform.services.resources.ResourceBundleService;
-
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * @author Benjamin Mestrallet benjamin.mestrallet(a)exoplatform.com
- */
-public class LocaleConfigImpl implements LocaleConfig
-{
-
- static private Map<String, Locale> predefinedLocaleMap_ = null;
-
- static
- {
- predefinedLocaleMap_ = new HashMap<String, Locale>(10);
- predefinedLocaleMap_.put("us", Locale.US);
- predefinedLocaleMap_.put("en", Locale.ENGLISH);
- predefinedLocaleMap_.put("fr", Locale.FRANCE);
- predefinedLocaleMap_.put("zh", Locale.SIMPLIFIED_CHINESE);
- }
-
- private Locale locale_;
-
- private String outputEncoding_;
-
- private String inputEncoding_;
-
- private String description_;
-
- private String localeName_;
-
- private Orientation orientation;
-
- public LocaleConfigImpl()
- {
- }
-
- public final String getDescription()
- {
- return description_;
- }
-
- public final void setDescription(String desc)
- {
- description_ = desc;
- }
-
- public final String getOutputEncoding()
- {
- return outputEncoding_;
- }
-
- public final void setOutputEncoding(String enc)
- {
- outputEncoding_ = enc;
- }
-
- public final String getInputEncoding()
- {
- return inputEncoding_;
- }
-
- public final void setInputEncoding(String enc)
- {
- inputEncoding_ = enc;
- }
-
- public final Locale getLocale()
- {
- return locale_;
- }
-
- public final void setLocale(Locale locale)
- {
- locale_ = locale;
- if (localeName_ == null)
- localeName_ = locale.getLanguage();
- }
-
- public final void setLocale(String localeName)
- {
- localeName_ = localeName;
- locale_ = predefinedLocaleMap_.get(localeName);
- if (locale_ == null)
- locale_ = new Locale(localeName);
- }
-
- public final String getLanguage()
- {
- return locale_.getLanguage();
- }
-
- public final String getLocaleName()
- {
- return localeName_;
- }
-
- public final void setLocaleName(String localeName)
- {
- localeName_ = localeName;
- }
-
- public ResourceBundle getResourceBundle(String name)
- {
- ResourceBundleService service =
- (ResourceBundleService)ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(
- ResourceBundleService.class);
- ResourceBundle res = service.getResourceBundle(name, locale_);
- return res;
- }
-
- public ResourceBundle getMergeResourceBundle(String[] names)
- {
- ResourceBundleService service =
- (ResourceBundleService)ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(
- ResourceBundleService.class);
- ResourceBundle res = service.getResourceBundle(names, locale_);
- return res;
- }
-
- public ResourceBundle getNavigationResourceBundle(String ownerType, String ownerId)
- {
- return getResourceBundle("locale.navigation." + ownerType + "." + ownerId.replaceAll("/", "."));
- }
-
- public void setInput(HttpServletRequest req) throws java.io.UnsupportedEncodingException
- {
- req.setCharacterEncoding(inputEncoding_);
- }
-
- public void setOutput(HttpServletResponse res)
- {
- res.setContentType("text/html; charset=" + outputEncoding_);
- res.setLocale(locale_);
- }
-
- public Orientation getOrientation()
- {
- return orientation;
- }
-
- public void setOrientation(Orientation orientation)
- {
- this.orientation = orientation;
- }
-
- @Override
- public String toString()
- {
- return "LocaleConfig[" + "localeName=" + localeName_ + ",locale=" + locale_ + ",description=" + description_
- + ",inputEncoding=" + inputEncoding_ + ",outputEncoding=" + outputEncoding_ + "]";
- }
-}
Deleted: portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigServiceImpl.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigServiceImpl.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigServiceImpl.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,181 +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.services.resources.impl;
-
-import org.exoplatform.commons.utils.PropertyManager;
-import org.exoplatform.container.configuration.ConfigurationManager;
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.exoplatform.services.resources.IdentityResourceBundle;
-import org.exoplatform.services.resources.LocaleConfig;
-import org.exoplatform.services.resources.LocaleConfigService;
-import org.exoplatform.services.resources.Orientation;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-/**
- * @author Benjamin Mestrallet benjamin.mestrallet(a)exoplatform.com This Service
- * is used to manage the locales that the applications can handle
- */
-public class LocaleConfigServiceImpl implements LocaleConfigService
-{
-
- private static Log log = ExoLogger.getLogger(LocaleConfigServiceImpl.class);
-
- private LocaleConfig defaultConfig_;
-
- private Map<String, LocaleConfig> configs_;
-
- private static final Map<String, Orientation> orientations = new HashMap<String, Orientation>();
-
- static
- {
- orientations.put("lt", Orientation.LT);
- orientations.put("rt", Orientation.RT);
- orientations.put("tl", Orientation.TL);
- orientations.put("tr", Orientation.TR);
- }
-
- public LocaleConfigServiceImpl(InitParams params, ConfigurationManager cmanager) throws Exception
- {
- configs_ = new HashMap<String, LocaleConfig>(10);
- String confResource = params.getValueParam("locale.config.file").getValue();
- InputStream is = cmanager.getInputStream(confResource);
- parseConfiguration(is);
- }
-
- /**
- * @return Return the default LocaleConfig
- */
- public LocaleConfig getDefaultLocaleConfig()
- {
- return defaultConfig_;
- }
-
- /**
- * @param lang a locale language
- * @return The LocalConfig
- */
- public LocaleConfig getLocaleConfig(String lang)
- {
- LocaleConfig config = configs_.get(lang);
- if (config != null)
- return config;
- return defaultConfig_;
- }
-
- /**
- * @return All the LocalConfig that manage by the service
- */
- public Collection<LocaleConfig> getLocalConfigs()
- {
- return configs_.values();
- }
-
- private void parseConfiguration(InputStream is) throws Exception
- {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setIgnoringComments(true);
- factory.setCoalescing(true);
- factory.setNamespaceAware(false);
- factory.setValidating(false);
- DocumentBuilder parser = factory.newDocumentBuilder();
- Document document = parser.parse(is);
- NodeList nodes = document.getElementsByTagName("locale-config");
- for (int i = 0; i < nodes.getLength(); i++)
- {
- Node node = nodes.item(i);
- NodeList children = node.getChildNodes();
- LocaleConfig config = new LocaleConfigImpl();
- for (int j = 0; j < children.getLength(); j++)
- {
- Node element = children.item(j);
- if ("locale".equals(element.getNodeName()))
- {
- config.setLocale(element.getFirstChild().getNodeValue());
- }
- else if ("output-encoding".equals(element.getNodeName()))
- {
- config.setOutputEncoding(element.getFirstChild().getNodeValue());
- }
- else if ("input-encoding".equals(element.getNodeName()))
- {
- config.setInputEncoding(element.getFirstChild().getNodeValue());
- }
- else if ("description".equals(element.getNodeName()))
- {
- config.setDescription(element.getFirstChild().getNodeValue());
- }
- else if ("orientation".equals(element.getNodeName()))
- {
- String s = element.getFirstChild().getNodeValue();
- Orientation orientation = orientations.get(s);
- if (orientation == null)
- {
- log.error("Wrong orientation value " + s);
- }
- else
- {
- config.setOrientation(orientation);
- }
- }
- }
-
- //
- if (config.getOrientation() == null)
- {
- log.debug("No orientation found on the locale config, use the LT default");
- config.setOrientation(Orientation.LT);
- }
-
- //
- log.debug("Added locale config " + config + " to the set of locale configs");
-
- //
- configs_.put(config.getLanguage(), config);
- if (i == 0)
- defaultConfig_ = config;
- }
-
- //
- if (PropertyManager.isDevelopping())
- {
- LocaleConfig magicConfig = new LocaleConfigImpl();
- magicConfig.setLocale(IdentityResourceBundle.MAGIC_LOCALE);
- magicConfig.setDescription("Magic locale");
- magicConfig.setInputEncoding("UTF-8");
- magicConfig.setOutputEncoding("UTF-8");
- magicConfig.setDescription("Default configuration for the debugging locale");
- magicConfig.setOrientation(Orientation.LT);
- configs_.put(magicConfig.getLanguage(), magicConfig);
- log.debug("Added magic locale for debugging bundle usage at runtime");
- }
- }
-}
Deleted: portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/hibernate/ResourceBundleServiceImpl.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/hibernate/ResourceBundleServiceImpl.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/hibernate/ResourceBundleServiceImpl.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,176 +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.services.resources.impl.hibernate;
-
-import org.exoplatform.commons.utils.MapResourceBundle;
-import org.exoplatform.commons.utils.PageList;
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.services.cache.CacheService;
-import org.exoplatform.services.database.DBObjectPageList;
-import org.exoplatform.services.database.HibernateService;
-import org.exoplatform.services.database.ObjectQuery;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.resources.ExoResourceBundle;
-import org.exoplatform.services.resources.LocaleConfigService;
-import org.exoplatform.services.resources.Query;
-import org.exoplatform.services.resources.ResourceBundleData;
-import org.exoplatform.services.resources.ResourceBundleDescription;
-import org.exoplatform.services.resources.impl.BaseResourceBundleService;
-import org.hibernate.Session;
-
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * Created by The eXo Platform SAS. Author : Roman Pedchenko
- * roman.pedchenko(a)exoplatform.com.ua Apr 10, 2007
- */
-public class ResourceBundleServiceImpl extends BaseResourceBundleService
-{
-
- /**
- * Hibernate service.
- */
- private final HibernateService hService;
-
- /**
- * @param service hibernate service
- * @param localeService locale service
- * @param cService cache service
- * @param params init parameters
- * @throws Exception exception
- */
- public ResourceBundleServiceImpl(final HibernateService service, final LocaleConfigService localeService,
- final CacheService cService, final InitParams params) throws Exception
- {
-
- log_ = ExoLogger.getLogger("org.exoplatform.services.portletcontainer");
- cache_ = cService.getCacheInstance(getClass().getName());
- localeService_ = localeService;
- hService = service;
-
- initParams(params);
- }
-
- /**
- * Overridden method.
- *
- * @param name name
- * @return data
- * @throws Exception exception
- * @see org.exoplatform.services.resources.ResourceBundleService#getResourceBundleData(java.lang.String)
- */
- public final ResourceBundleData getResourceBundleData(final String name) throws Exception
- {
- return (ResourceBundleData)hService.findOne(ResourceBundleData.class, name);
- }
-
- /**
- * Overridden method.
- *
- * @param id id
- * @return data
- * @throws Exception exception
- * @see org.exoplatform.services.resources.ResourceBundleService#removeResourceBundleData(java.lang.String)
- */
- public final ResourceBundleData removeResourceBundleData(final String id) throws Exception
- {
- ResourceBundleData data = (ResourceBundleData)hService.remove(ResourceBundleData.class, id);
- cache_.remove(data.getId());
- return data;
- }
-
- /**
- * Overridden method.
- *
- * @param q query
- * @return page list
- * @throws Exception exception
- * @see org.exoplatform.services.resources.ResourceBundleService#findResourceDescriptions(org.exoplatform.services.resources.Query)
- */
- public final PageList findResourceDescriptions(final Query q) throws Exception
- {
- String name = q.getName();
- if ((name == null) || (name.length() == 0))
- name = "%";
- ObjectQuery oq = new ObjectQuery(ResourceBundleDescription.class);
- oq.addLIKE("name", name);
- oq.addLIKE("language", q.getLanguage());
- oq.setDescOrderBy("name");
- return new DBObjectPageList(hService, oq);
- }
-
- /**
- * Overridden method.
- *
- * @param data data
- * @throws Exception exception
- * @see org.exoplatform.services.resources.ResourceBundleService#saveResourceBundle(org.exoplatform.services.resources.ResourceBundleData)
- */
- public final void saveResourceBundle(final ResourceBundleData data) throws Exception
- {
- hService.save(data);
- cache_.remove(data.getId());
- }
-
- /**
- * Overridden method.
- *
- * @param id id
- * @param parent parent
- * @param locale locale
- * @returnresource bundle
- * @throws Exception exception
- * @see org.exoplatform.services.resources.impl.BaseResourceBundleService#getResourceBundleFromDb(java.lang.String,
- * java.util.ResourceBundle, java.util.Locale)
- */
- protected final ResourceBundle getResourceBundleFromDb(final String id, final ResourceBundle parent,
- final Locale locale) throws Exception
- {
-
- Session session = hService.openSession();
- ResourceBundleData data = (ResourceBundleData)session.get(ResourceBundleData.class, id);
- if (data != null)
- {
- ResourceBundle res = new ExoResourceBundle(data.getData(), parent);
- MapResourceBundle mres = new MapResourceBundle(res, locale);
- return mres;
- }
- // return null;
-
- ResourceBundle rB;
- try
- {
- rB = ResourceBundle.getBundle(id, locale, Thread.currentThread().getContextClassLoader());
- }
- catch (MissingResourceException e)
- {
- rB = null;
- }
- if (rB != null)
- {
- return new MapResourceBundle(rB, locale);
-
- }
- else
- return null;
- }
-}
Deleted: portal/trunk/component/common/src/test/java/org/exoplatform/services/resources/TestExoResourceBundle.java
===================================================================
--- portal/trunk/component/common/src/test/java/org/exoplatform/services/resources/TestExoResourceBundle.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/test/java/org/exoplatform/services/resources/TestExoResourceBundle.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,84 +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.services.resources;
-
-import junit.framework.TestCase;
-
-public class TestExoResourceBundle extends TestCase
-{
-
- public void testConstructor()
- {
- ExoResourceBundle bundle;
- bundle = new ExoResourceBundle("key1=value");
- assertEquals(1, bundle.getContents().length);
- assertEquals("value", bundle.getString("key1"));
- bundle = new ExoResourceBundle("key1=value\nkey2=value");
- assertEquals(2, bundle.getContents().length);
- assertEquals("value", bundle.getString("key1"));
- assertEquals("value", bundle.getString("key2"));
- bundle = new ExoResourceBundle("key1=value\r\nkey2=value");
- assertEquals(2, bundle.getContents().length);
- assertEquals("value", bundle.getString("key1"));
- assertEquals("value", bundle.getString("key2"));
- bundle = new ExoResourceBundle("#comment\r\nkey2=value");
- assertEquals(1, bundle.getContents().length);
- assertEquals("value", bundle.getString("key2"));
- bundle = new ExoResourceBundle(" #comment\r\nkey2=value");
- assertEquals(1, bundle.getContents().length);
- assertEquals("value", bundle.getString("key2"));
- bundle = new ExoResourceBundle(" bad entry\r\nkey2=value");
- assertEquals(1, bundle.getContents().length);
- assertEquals("value", bundle.getString("key2"));
- bundle = new ExoResourceBundle("#key1 =value\r\nkey2=value");
- assertEquals(1, bundle.getContents().length);
- assertEquals("value", bundle.getString("key2"));
- bundle = new ExoResourceBundle(" key1 =value\r\n key2 =value");
- assertEquals(2, bundle.getContents().length);
- assertEquals("value", bundle.getString(" key1 "));
- assertEquals("value", bundle.getString(" key2 "));
- }
-
- public void testUnicode2Char()
- {
- for (int i = 0; i < (1 << 16); i++)
- {
- String value = Integer.toHexString(i);
- while (value.length() < 4)
- {
- value = "0" + value;
- }
- assertEquals((char)i, ExoResourceBundle.unicode2Char("\\u" + value));
- }
- }
-
- public void testConvert()
- {
- assertEquals("Normal Value", ExoResourceBundle.convert("Normal Value"));
- assertEquals("\u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", ExoResourceBundle
- .convert("\\u00E9\\u00E7\\u00E0\\u00F9\\u0194\\u0BF5"));
- assertEquals("before \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", ExoResourceBundle
- .convert("before \\u00E9\\u00E7\\u00E0\\u00F9\\u0194\\u0BF5"));
- assertEquals("\u00E9\u00E7\u00E0\u00F9\u0194\u0BF5 after", ExoResourceBundle
- .convert("\\u00E9\\u00E7\\u00E0\\u00F9\\u0194\\u0BF5 after"));
- assertEquals("before \u00E9\u00E7\u00E0 between \u00F9\u0194\u0BF5 after", ExoResourceBundle
- .convert("before \\u00E9\\u00E7\\u00E0 between \\u00F9\\u0194\\u0BF5 after"));
- }
-}
Deleted: portal/trunk/component/common/src/test/java/org/exoplatform/services/resources/TestLocaleConfigService.java
===================================================================
--- portal/trunk/component/common/src/test/java/org/exoplatform/services/resources/TestLocaleConfigService.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/test/java/org/exoplatform/services/resources/TestLocaleConfigService.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,134 +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.services.resources;
-
-import junit.framework.TestCase;
-
-import org.exoplatform.commons.utils.PropertyManager;
-import org.exoplatform.container.configuration.ConfigurationManagerImpl;
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.container.xml.ValueParam;
-import org.exoplatform.services.resources.impl.LocaleConfigImpl;
-import org.exoplatform.services.resources.impl.LocaleConfigServiceImpl;
-
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class TestLocaleConfigService extends TestCase
-{
-
- public TestLocaleConfigService()
- {
- }
-
- public TestLocaleConfigService(String s)
- {
- super(s);
- }
-
- public void testFoo() throws Exception
- {
- PropertyManager.setProperty(PropertyManager.DEVELOPING, "false");
- LocaleConfigService service = createService();
- Map<String, LocaleConfig> map = createMap(service);
- assertEquals(4, map.size());
- assertCommonConfigs(service);
- }
-
- public void testBar() throws Exception
- {
- PropertyManager.setProperty(PropertyManager.DEVELOPING, "true");
- LocaleConfigService service = createService();
- Map<String, LocaleConfig> map = createMap(service);
- assertEquals(5, map.size());
- assertCommonConfigs(service);
- LocaleConfig ma = service.getLocaleConfig("ma");
- assertLocaleConfig(ma, "ma", "Default configuration for the debugging locale", "UTF-8", "UTF-8", Orientation.LT,
- IdentityResourceBundle.MAGIC_LOCALE);
- }
-
- public void testLocaleConfig() throws Exception
- {
- LocaleConfig ma = new LocaleConfigImpl();
- ma.setLocale("ma");
- assertEquals("ma", ma.getLocaleName());
-
- LocaleConfig ma1 = new LocaleConfigImpl();
- ma1.setLocale(new Locale("ma"));
- assertEquals("ma", ma1.getLocaleName());
- }
-
- private Map<String, LocaleConfig> createMap(LocaleConfigService service)
- {
- Map<String, LocaleConfig> map = new HashMap<String, LocaleConfig>();
- for (LocaleConfig config : service.getLocalConfigs())
- {
- map.put(config.getLanguage(), config);
- }
- return map;
- }
-
- private LocaleConfigService createService() throws Exception
- {
- ConfigurationManagerImpl cm = new ConfigurationManagerImpl();
- InitParams params = new InitParams();
- ValueParam param = new ValueParam();
- param.setName("locale.config.file");
- param.setValue("classpath:/resources/locales-config.xml");
- params.addParameter(param);
-
- //
- LocaleConfigService service = new LocaleConfigServiceImpl(params, cm);
- return service;
- }
-
- private void assertCommonConfigs(LocaleConfigService service)
- {
- LocaleConfig en = service.getLocaleConfig("en");
- LocaleConfig fr = service.getLocaleConfig("fr");
- LocaleConfig ar = service.getLocaleConfig("ar");
- LocaleConfig vi = service.getLocaleConfig("vi");
- assertLocaleConfig(en, "en", "Default configuration for english locale", "UTF-8", "UTF-8", Orientation.LT,
- Locale.ENGLISH);
- assertLocaleConfig(fr, "fr", "Default configuration for the french locale", "UTF-8", "UTF-8", Orientation.LT,
- Locale.FRANCE);
- assertLocaleConfig(ar, "ar", "Default configuration for the arabic locale", "UTF-8", "UTF-8", Orientation.RT,
- new Locale("ar"));
- assertLocaleConfig(vi, "vi", "Default configuration for the vietnam locale", "UTF-8", "UTF-8", Orientation.LT,
- new Locale("vi"));
- }
-
- private void assertLocaleConfig(LocaleConfig config, String language, String description, String inputEncoding,
- String outputEncoding, Orientation orientation, Locale locale)
- {
- assertNotNull(config);
- assertEquals(language, config.getLanguage());
- assertEquals(description, config.getDescription());
- assertEquals(inputEncoding, config.getInputEncoding());
- assertEquals(outputEncoding, config.getOutputEncoding());
- assertEquals(orientation, config.getOrientation());
- assertEquals(locale, config.getLocale());
- }
-}
Deleted: portal/trunk/component/common/src/test/java/org/exoplatform/services/resources/impl/TesBaseResourceBundleService.java
===================================================================
--- portal/trunk/component/common/src/test/java/org/exoplatform/services/resources/impl/TesBaseResourceBundleService.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/common/src/test/java/org/exoplatform/services/resources/impl/TesBaseResourceBundleService.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,483 +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.services.resources.impl;
-
-import junit.framework.TestCase;
-
-import org.exoplatform.commons.utils.MapResourceBundle;
-import org.exoplatform.commons.utils.PageList;
-import org.exoplatform.container.configuration.ConfigurationManagerImpl;
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.container.xml.ValueParam;
-import org.exoplatform.services.cache.CacheListener;
-import org.exoplatform.services.cache.CachedObjectSelector;
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.services.resources.ExoResourceBundle;
-import org.exoplatform.services.resources.LocaleConfigService;
-import org.exoplatform.services.resources.Query;
-import org.exoplatform.services.resources.ResourceBundleData;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-public class TesBaseResourceBundleService extends TestCase
-{
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- // Any language
- Locale.setDefault(new Locale("xxx", "xxx"));
- }
-
- public void testResourceBundleContent() throws Exception
- {
- BaseResourceBundleService service = new MyResourceBundleService(false);
- String content;
- // Simple resource bundle
- content =
- service.getResourceBundleContent("locale/test/myRB1", "en", "en", Thread.currentThread()
- .getContextClassLoader());
- assertTrue(content.contains("my.key1=My New Value In English"));
- assertTrue(content.contains("my.key3=My New Value In English"));
- content =
- service.getResourceBundleContent("locale/test/myRB1", "fr", "en", Thread.currentThread()
- .getContextClassLoader());
- assertTrue(content
- .contains("my.key1=My Value In French with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5"));
- assertTrue(content
- .contains("my.key2=My Value In French with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5"));
- content =
- service.getResourceBundleContent("locale/test/myRB2", "en", "en", Thread.currentThread()
- .getContextClassLoader());
- assertTrue(content.contains("my.key1=My New Value In English"));
- assertTrue(content.contains("my.key3=My New Value In English"));
- content =
- service.getResourceBundleContent("locale/test/myRB2", "fr", "en", Thread.currentThread()
- .getContextClassLoader());
- assertTrue(content
- .contains("my.key1=My Value In French with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5"));
- assertTrue(content
- .contains("my.key2=My Value In French with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5"));
- // Multiple resources bundles
- content = service.getResourceBundleContent("locale/test/myRB1", "en", "en", new MyClassLoader());
- assertTrue(content.contains("my.key1=My New Value In English"));
- assertTrue(content.contains("my.key2=My New Value In English v2"));
- assertTrue(content.contains("my.key3=My New Value In English v2"));
- content = service.getResourceBundleContent("locale/test/myRB1", "fr", "en", new MyClassLoader());
- assertTrue(content
- .contains("my.key1=My Value In French v2 with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5"));
- assertTrue(content
- .contains("my.key2=My Value In French with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5"));
- assertTrue(content
- .contains("my.key3=My Value In French v2 with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5"));
- content = service.getResourceBundleContent("locale/test/myRB2", "en", "en", new MyClassLoader());
- assertTrue(content.contains("my.key1=My New Value In English"));
- assertTrue(content.contains("my.key2=My New Value In English v2"));
- assertTrue(content.contains("my.key3=My New Value In English v2"));
- content = service.getResourceBundleContent("locale/test/myRB2", "fr", "en", new MyClassLoader());
- assertTrue(content
- .contains("my.key1=My Value In French v2 with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5"));
- assertTrue(content
- .contains("my.key2=My Value In French with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5"));
- assertTrue(content
- .contains("my.key3=My Value In French v2 with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5"));
- }
-
- public void testGetResourceBundle() throws Exception
- {
- BaseResourceBundleService service = new MyResourceBundleService(true);
- ResourceBundle rb;
- rb =
- service.getResourceBundle("locale.test.myRB1", Locale.ENGLISH, Thread.currentThread().getContextClassLoader());
- assertEquals("My New Value In English", rb.getString("my.key1"));
- assertEquals("My Default Value In English", rb.getString("my.key2"));
- assertEquals("My New Value In English", rb.getString("my.key3"));
- rb =
- service.getResourceBundle("locale.test.myRB1", Locale.FRENCH, Thread.currentThread().getContextClassLoader());
- assertEquals("My Value In French with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", rb
- .getString("my.key1"));
- assertEquals("My Value In French with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", rb
- .getString("my.key2"));
- assertEquals("My Default Value In English", rb.getString("my.key3"));
- rb = service.getResourceBundle("locale.test.myRB1", Locale.JAPAN, Thread.currentThread().getContextClassLoader());
- assertEquals("My Default Value In English", rb.getString("my.key1"));
- assertEquals("My Default Value In English", rb.getString("my.key2"));
- assertEquals("My Default Value In English", rb.getString("my.key3"));
- rb =
- service.getResourceBundle("locale.test.myRB2", Locale.ENGLISH, Thread.currentThread().getContextClassLoader());
- assertEquals("My New Value In English", rb.getString("my.key1"));
- assertEquals("My Default Value In English", rb.getString("my.key2"));
- assertEquals("My New Value In English", rb.getString("my.key3"));
- rb =
- service.getResourceBundle("locale.test.myRB2", Locale.FRENCH, Thread.currentThread().getContextClassLoader());
- assertEquals("My Value In French with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", rb
- .getString("my.key1"));
- assertEquals("My Value In French with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", rb
- .getString("my.key2"));
- assertEquals("My Default Value In English", rb.getString("my.key3"));
- rb = service.getResourceBundle("locale.test.myRB2", Locale.JAPAN, Thread.currentThread().getContextClassLoader());
- assertEquals("My Default Value In English", rb.getString("my.key1"));
- assertEquals("My Default Value In English", rb.getString("my.key2"));
- assertEquals("My Default Value In English", rb.getString("my.key3"));
- service = new MyResourceBundleService(false);
- rb =
- service.getResourceBundle("locale.test.myRB1", Locale.ENGLISH, Thread.currentThread().getContextClassLoader());
- assertEquals("My New Value In English", rb.getString("my.key1"));
- assertEquals("My New Value In English", rb.getString("my.key3"));
- rb =
- service.getResourceBundle("locale.test.myRB1", Locale.FRENCH, Thread.currentThread().getContextClassLoader());
- assertEquals("My Value In French with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", rb
- .getString("my.key1"));
- assertEquals("My Value In French with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", rb
- .getString("my.key2"));
- assertEquals("My New Value In English", rb.getString("my.key3"));
- rb = service.getResourceBundle("locale.test.myRB1", Locale.JAPAN, Thread.currentThread().getContextClassLoader());
- assertEquals("My New Value In English", rb.getString("my.key1"));
- assertEquals("My New Value In English", rb.getString("my.key3"));
- rb =
- service.getResourceBundle("locale.test.myRB2", Locale.ENGLISH, Thread.currentThread().getContextClassLoader());
- assertEquals("My New Value In English", rb.getString("my.key1"));
- assertEquals("My New Value In English", rb.getString("my.key3"));
- rb =
- service.getResourceBundle("locale.test.myRB2", Locale.FRENCH, Thread.currentThread().getContextClassLoader());
- assertEquals("My Value In French with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", rb
- .getString("my.key1"));
- assertEquals("My Value In French with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", rb
- .getString("my.key2"));
- assertEquals("My New Value In English", rb.getString("my.key3"));
- rb = service.getResourceBundle("locale.test.myRB2", Locale.JAPAN, Thread.currentThread().getContextClassLoader());
- assertEquals("My New Value In English", rb.getString("my.key1"));
- assertEquals("My New Value In English", rb.getString("my.key3"));
- // Multiple resources bundles
- service = new MyResourceBundleService(new MyClassLoader(), true);
- rb = service.getResourceBundle("locale.test.myRB1", Locale.ENGLISH, new MyClassLoader());
- assertEquals("My New Value In English", rb.getString("my.key1"));
- assertEquals("My New Value In English v2", rb.getString("my.key2"));
- assertEquals("My New Value In English v2", rb.getString("my.key3"));
- rb = service.getResourceBundle("locale.test.myRB1", Locale.FRENCH, new MyClassLoader());
- assertEquals("My Value In French v2 with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", rb
- .getString("my.key1"));
- assertEquals("My Value In French with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", rb
- .getString("my.key2"));
- assertEquals("My Value In French v2 with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", rb
- .getString("my.key3"));
- rb = service.getResourceBundle("locale.test.myRB1", Locale.JAPAN, new MyClassLoader());
- assertEquals("My Default Value In English v2", rb.getString("my.key1"));
- assertEquals("My Default Value In English", rb.getString("my.key2"));
- assertEquals("My Default Value In English", rb.getString("my.key3"));
- rb = service.getResourceBundle("locale.test.myRB2", Locale.ENGLISH, new MyClassLoader());
- assertEquals("My New Value In English", rb.getString("my.key1"));
- assertEquals("My New Value In English v2", rb.getString("my.key2"));
- assertEquals("My New Value In English v2", rb.getString("my.key3"));
- rb = service.getResourceBundle("locale.test.myRB2", Locale.FRENCH, new MyClassLoader());
- assertEquals("My Value In French v2 with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", rb
- .getString("my.key1"));
- assertEquals("My Value In French with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", rb
- .getString("my.key2"));
- assertEquals("My Value In French v2 with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", rb
- .getString("my.key3"));
- rb = service.getResourceBundle("locale.test.myRB2", Locale.JAPAN, new MyClassLoader());
- assertEquals("My Default Value In English v2", rb.getString("my.key1"));
- assertEquals("My Default Value In English", rb.getString("my.key2"));
- assertEquals("My Default Value In English", rb.getString("my.key3"));
- service = new MyResourceBundleService(new MyClassLoader(), false);
- rb = service.getResourceBundle("locale.test.myRB1", Locale.ENGLISH, new MyClassLoader());
- assertEquals("My New Value In English", rb.getString("my.key1"));
- assertEquals("My New Value In English v2", rb.getString("my.key2"));
- assertEquals("My New Value In English v2", rb.getString("my.key3"));
- rb = service.getResourceBundle("locale.test.myRB1", Locale.FRENCH, new MyClassLoader());
- assertEquals("My Value In French v2 with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", rb
- .getString("my.key1"));
- assertEquals("My Value In French with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", rb
- .getString("my.key2"));
- assertEquals("My Value In French v2 with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", rb
- .getString("my.key3"));
- rb = service.getResourceBundle("locale.test.myRB1", Locale.JAPAN, new MyClassLoader());
- assertEquals("My New Value In English", rb.getString("my.key1"));
- assertEquals("My New Value In English v2", rb.getString("my.key2"));
- assertEquals("My New Value In English v2", rb.getString("my.key3"));
- rb = service.getResourceBundle("locale.test.myRB2", Locale.ENGLISH, new MyClassLoader());
- assertEquals("My New Value In English", rb.getString("my.key1"));
- assertEquals("My New Value In English v2", rb.getString("my.key2"));
- assertEquals("My New Value In English v2", rb.getString("my.key3"));
- rb = service.getResourceBundle("locale.test.myRB2", Locale.FRENCH, new MyClassLoader());
- assertEquals("My Value In French v2 with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", rb
- .getString("my.key1"));
- assertEquals("My Value In French with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", rb
- .getString("my.key2"));
- assertEquals("My Value In French v2 with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", rb
- .getString("my.key3"));
- rb = service.getResourceBundle("locale.test.myRB2", Locale.JAPAN, new MyClassLoader());
- assertEquals("My New Value In English", rb.getString("my.key1"));
- assertEquals("My New Value In English v2", rb.getString("my.key2"));
- assertEquals("My New Value In English v2", rb.getString("my.key3"));
- }
-
- public void testInitResources() throws Exception
- {
- MyResourceBundleService service = new MyResourceBundleService(true);
- service.initResources("locale.test.myRB1", Thread.currentThread().getContextClassLoader());
- assertEquals(2, service.getRbs().size());
- service.getRbs().clear();
- service.initResources("locale.test.myRB2", Thread.currentThread().getContextClassLoader());
- assertEquals(2, service.getRbs().size());
- }
-
- private static class MyResourceBundleService extends BaseResourceBundleService
- {
-
- private ClassLoader classLoader;
-
- private boolean isClasspathResource;
-
- private List<ResourceBundleData> rbs = new ArrayList<ResourceBundleData>();
-
- public MyResourceBundleService(boolean isClasspathResource) throws Exception
- {
- this(Thread.currentThread().getContextClassLoader(), isClasspathResource);
- }
-
- public MyResourceBundleService(ClassLoader classLoader, boolean isClasspathResource) throws Exception
- {
- this.classLoader = classLoader;
- this.isClasspathResource = isClasspathResource;
- this.localeService_ = createService();
- this.cache_ = new ExoCache()
- {
-
- public void addCacheListener(CacheListener arg0)
- {
- }
-
- public void clearCache()
- {
- }
-
- public Object get(Serializable arg0)
- {
- return null;
- }
-
- public int getCacheHit()
- {
- return 0;
- }
-
- public int getCacheMiss()
- {
- return 0;
- }
-
- public int getCacheSize()
- {
- return 0;
- }
-
- public List getCachedObjects()
- {
- return null;
- }
-
- public String getLabel()
- {
- return null;
- }
-
- public long getLiveTime()
- {
- return 0;
- }
-
- public int getMaxSize()
- {
- return 0;
- }
-
- public String getName()
- {
- return null;
- }
-
- public boolean isDistributed()
- {
- return false;
- }
-
- public boolean isLogEnabled()
- {
- return false;
- }
-
- public boolean isReplicated()
- {
- return false;
- }
-
- public void put(Serializable arg0, Object arg1)
- {
- }
-
- public void putMap(Map arg0)
- {
- }
-
- public Object remove(Serializable arg0)
- {
- return null;
- }
-
- public List removeCachedObjects()
- {
- return null;
- }
-
- public void select(CachedObjectSelector arg0) throws Exception
- {
- }
-
- public void setDistributed(boolean arg0)
- {
- }
-
- public void setLabel(String arg0)
- {
- }
-
- public void setLiveTime(long arg0)
- {
- }
-
- public void setLogEnabled(boolean arg0)
- {
- }
-
- public void setMaxSize(int arg0)
- {
- }
-
- public void setName(String arg0)
- {
- }
-
- public void setReplicated(boolean arg0)
- {
- }
-
- };
- }
-
- private LocaleConfigService createService() throws Exception
- {
- ConfigurationManagerImpl cm = new ConfigurationManagerImpl();
- InitParams params = new InitParams();
- ValueParam param = new ValueParam();
- param.setName("locale.config.file");
- param.setValue("classpath:/resources/locales-config.xml");
- params.addParameter(param);
-
- //
- LocaleConfigService service = new LocaleConfigServiceImpl(params, cm);
- return service;
- }
-
- @Override
- protected boolean isClasspathResource(String name)
- {
- return isClasspathResource;
- }
-
- @Override
- protected ResourceBundle getResourceBundleFromDb(String id, ResourceBundle parent, Locale locale)
- throws Exception
- {
- String language = locale.getLanguage();
- int index = id.indexOf('_');
- if (index >= 0)
- {
- language = id.substring(index + 1);
- id = id.substring(0, index);
- }
- String content = getResourceBundleContent(id.replace('.', '/'), language, "en", classLoader);
- if (content == null)
- {
- return null;
- }
- ResourceBundle result = new ExoResourceBundle(content, parent);
- return new MapResourceBundle(result, locale);
- }
-
- public PageList findResourceDescriptions(Query q) throws Exception
- {
- return null;
- }
-
- public ResourceBundleData getResourceBundleData(String id) throws Exception
- {
- return null;
- }
-
- public ResourceBundleData removeResourceBundleData(String id) throws Exception
- {
- return null;
- }
-
- public void saveResourceBundle(ResourceBundleData data) throws Exception
- {
- rbs.add(data);
- }
-
- public List<ResourceBundleData> getRbs()
- {
- return rbs;
- }
- }
-
- private static class MyClassLoader extends ClassLoader
- {
-
- public MyClassLoader()
- {
- super(Thread.currentThread().getContextClassLoader());
- }
-
- @Override
- public Enumeration<URL> getResources(String name) throws IOException
- {
- List<URL> result = new ArrayList<URL>();
- URL url = super.getResource(name);
- if (url != null)
- {
- result.add(url);
- result.add(super.getResource(name.replace(".", "-2.")));
- }
- return Collections.enumeration(result);
- }
- }
-}
Modified: portal/trunk/component/pc/src/main/java/org/exoplatform/portal/pc/ExoKernelIntegration.java
===================================================================
--- portal/trunk/component/pc/src/main/java/org/exoplatform/portal/pc/ExoKernelIntegration.java 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/pc/src/main/java/org/exoplatform/portal/pc/ExoKernelIntegration.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -21,7 +21,6 @@
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
-import org.exoplatform.services.resources.ResourceBundleService;
import org.gatein.pc.api.PortletInvoker;
import org.gatein.pc.federation.FederatingPortletInvoker;
import org.gatein.pc.federation.impl.FederatingPortletInvokerService;
@@ -61,7 +60,7 @@
* We enforce the dependency with the ResourceBundleService since it must be stared before the
* <code>portletApplicationRegistry</code>
*/
- public ExoKernelIntegration(ExoContainerContext context, ResourceBundleService resourceBundleService)
+ public ExoKernelIntegration(ExoContainerContext context)
{
this.container = context.getContainer();
}
Modified: portal/trunk/component/resources/pom.xml
===================================================================
--- portal/trunk/component/resources/pom.xml 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/resources/pom.xml 2009-11-16 12:53:30 UTC (rev 611)
@@ -32,10 +32,6 @@
<name>GateIn Portal Component Resources</name>
<description>resources data service...</description>
- <properties>
- <maven.test.skip>true</maven.test.skip>
- </properties>
-
<dependencies>
<dependency>
<groupId>org.exoplatform.kernel</groupId>
@@ -90,5 +86,12 @@
<artifactId>exo.portal.component.common</artifactId>
<version>3.0.0-CR01-SNAPSHOT</version>
</dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Modified: portal/trunk/component/resources/src/main/java/conf/portal/configuration.xml
===================================================================
--- portal/trunk/component/resources/src/main/java/conf/portal/configuration.xml 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/resources/src/main/java/conf/portal/configuration.xml 2009-11-16 12:53:30 UTC (rev 611)
@@ -30,7 +30,7 @@
<component>
<key>org.exoplatform.services.resources.ResourceBundleService</key>
- <type>org.exoplatform.services.resources.jcr.ResourceBundleServiceImpl</type>
+ <type>org.exoplatform.services.resources.impl.SimpleResourceBundleService</type>
<init-params>
<values-param>
<name>classpath.resources</name>
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/config (from rev 597, portal/trunk/component/common/src/main/java/org/exoplatform/services/config)
Deleted: portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/ConfigurationData.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/config/ConfigurationData.java 2009-11-13 22:36:33 UTC (rev 597)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/ConfigurationData.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,63 +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.services.config;
-
-/**
- * @author Tuan Nguyen (tuan08(a)users.sourceforge.net)
- * @since Dec 5, 2004
- * @version $Id: ConfigurationDataImpl.java 5799 2006-05-28 17:55:42Z geaz $
- * @hibernate.class table="EXO_SERVICE_CONFIG"
- * @hibernate.cache usage="read-write"
- */
-public class ConfigurationData
-{
-
- private String serviceType;
-
- private String data;
-
- /**
- * @hibernate.id generator-class="assigned" unsaved-value="null"
- ***/
- public String getServiceType()
- {
- return serviceType;
- }
-
- public void setServiceType(String s)
- {
- serviceType = s;
- }
-
- /**
- * @hibernate.property length="65535"
- * type="org.exoplatform.services.database.impl.TextClobType"
- **/
- public String getData()
- {
- return data;
- }
-
- public String setData(String s)
- {
- return data = s;
- }
-
-}
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/ConfigurationData.java (from rev 610, portal/trunk/component/common/src/main/java/org/exoplatform/services/config/ConfigurationData.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/ConfigurationData.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/ConfigurationData.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -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.
+ */
+
+package org.exoplatform.services.config;
+
+/**
+ * @author Tuan Nguyen (tuan08(a)users.sourceforge.net)
+ * @since Dec 5, 2004
+ * @version $Id: ConfigurationDataImpl.java 5799 2006-05-28 17:55:42Z geaz $
+ * @hibernate.class table="EXO_SERVICE_CONFIG"
+ * @hibernate.cache usage="read-write"
+ */
+public class ConfigurationData
+{
+
+ private String serviceType;
+
+ private String data;
+
+ /**
+ * @hibernate.id generator-class="assigned" unsaved-value="null"
+ ***/
+ public String getServiceType()
+ {
+ return serviceType;
+ }
+
+ public void setServiceType(String s)
+ {
+ serviceType = s;
+ }
+
+ /**
+ * @hibernate.property length="65535"
+ * type="org.exoplatform.services.database.impl.TextClobType"
+ **/
+ public String getData()
+ {
+ return data;
+ }
+
+ public String setData(String s)
+ {
+ return data = s;
+ }
+
+}
Deleted: portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/ConfigurationService.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/config/ConfigurationService.java 2009-11-13 22:36:33 UTC (rev 597)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/ConfigurationService.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,34 +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.services.config;
-
-/**
- * @author Tuan Nguyen (tuan08(a)users.sourceforge.net)
- * @since Dec 5, 2004
- * @version $Id: ConfigurationService.java 5799 2006-05-28 17:55:42Z geaz $
- */
-public interface ConfigurationService
-{
- public Object getServiceConfiguration(Class serviceType) throws Exception;
-
- public void saveServiceConfiguration(Class serviceType, Object config) throws Exception;
-
- public void removeServiceConfiguration(Class serviceType) throws Exception;
-}
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/ConfigurationService.java (from rev 610, portal/trunk/component/common/src/main/java/org/exoplatform/services/config/ConfigurationService.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/ConfigurationService.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/ConfigurationService.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,34 @@
+/**
+ * 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.services.config;
+
+/**
+ * @author Tuan Nguyen (tuan08(a)users.sourceforge.net)
+ * @since Dec 5, 2004
+ * @version $Id: ConfigurationService.java 5799 2006-05-28 17:55:42Z geaz $
+ */
+public interface ConfigurationService
+{
+ public Object getServiceConfiguration(Class serviceType) throws Exception;
+
+ public void saveServiceConfiguration(Class serviceType, Object config) throws Exception;
+
+ public void removeServiceConfiguration(Class serviceType) throws Exception;
+}
Deleted: portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/ConfigurationServiceImpl.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/services/config/ConfigurationServiceImpl.java 2009-11-13 22:36:33 UTC (rev 597)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/ConfigurationServiceImpl.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,96 +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.services.config;
-
-import com.thoughtworks.xstream.XStream;
-import com.thoughtworks.xstream.io.xml.XppDriver;
-
-import org.exoplatform.services.database.HibernateService;
-
-/**
- * @author Tuan Nguyen (tuan08(a)users.sourceforge.net)
- * @since Dec 5, 2004
- * @version $Id: ConfigurationServiceImpl.java 5799 2006-05-28 17:55:42Z geaz $
- */
-public class ConfigurationServiceImpl implements ConfigurationService
-{
-
- private HibernateService hservice_;
-
- private XStream xstream_;
-
- public ConfigurationServiceImpl(HibernateService service)
- {
- hservice_ = service;
- xstream_ = new XStream(new XppDriver());
- }
-
- public Object getServiceConfiguration(Class serviceType) throws Exception
- {
- ConfigurationData impl = (ConfigurationData)hservice_.findOne(ConfigurationData.class, serviceType.getName());
- Object obj = null;
- if (impl == null)
- {
- obj = loadDefaultConfig(serviceType);
- saveServiceConfiguration(serviceType, obj);
- }
- else
- {
- obj = xstream_.fromXML(impl.getData());
- }
- return obj;
- }
-
- public void saveServiceConfiguration(Class serviceType, Object config) throws Exception
- {
- ConfigurationData configData =
- (ConfigurationData)hservice_.findOne(ConfigurationData.class, serviceType.getName());
- String xml = xstream_.toXML(config);
- if (configData == null)
- {
- configData = new ConfigurationData();
- configData.setServiceType(serviceType.getName());
- configData.setData(xml);
- hservice_.create(configData);
- }
- else
- {
- configData.setData(xml);
- hservice_.update(configData);
- }
- }
-
- public void removeServiceConfiguration(Class serviceType) throws Exception
- {
- hservice_.remove(serviceType, serviceType.getName());
- }
-
- @SuppressWarnings("unused")
- private Object loadDefaultConfig(Class serviceType) throws Exception
- {
- // ServiceConfiguration sconf =
- // manager_.getServiceConfiguration(serviceType) ;
- // Iterator i = sconf.values().iterator() ;
- // ObjectParam param = (ObjectParam) i.next() ;
- // return param.getObject() ;
- return null;
- }
-
-}
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/ConfigurationServiceImpl.java (from rev 610, portal/trunk/component/common/src/main/java/org/exoplatform/services/config/ConfigurationServiceImpl.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/ConfigurationServiceImpl.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/config/ConfigurationServiceImpl.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,96 @@
+/**
+ * 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.services.config;
+
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.io.xml.XppDriver;
+
+import org.exoplatform.services.database.HibernateService;
+
+/**
+ * @author Tuan Nguyen (tuan08(a)users.sourceforge.net)
+ * @since Dec 5, 2004
+ * @version $Id: ConfigurationServiceImpl.java 5799 2006-05-28 17:55:42Z geaz $
+ */
+public class ConfigurationServiceImpl implements ConfigurationService
+{
+
+ private HibernateService hservice_;
+
+ private XStream xstream_;
+
+ public ConfigurationServiceImpl(HibernateService service)
+ {
+ hservice_ = service;
+ xstream_ = new XStream(new XppDriver());
+ }
+
+ public Object getServiceConfiguration(Class serviceType) throws Exception
+ {
+ ConfigurationData impl = (ConfigurationData)hservice_.findOne(ConfigurationData.class, serviceType.getName());
+ Object obj = null;
+ if (impl == null)
+ {
+ obj = loadDefaultConfig(serviceType);
+ saveServiceConfiguration(serviceType, obj);
+ }
+ else
+ {
+ obj = xstream_.fromXML(impl.getData());
+ }
+ return obj;
+ }
+
+ public void saveServiceConfiguration(Class serviceType, Object config) throws Exception
+ {
+ ConfigurationData configData =
+ (ConfigurationData)hservice_.findOne(ConfigurationData.class, serviceType.getName());
+ String xml = xstream_.toXML(config);
+ if (configData == null)
+ {
+ configData = new ConfigurationData();
+ configData.setServiceType(serviceType.getName());
+ configData.setData(xml);
+ hservice_.create(configData);
+ }
+ else
+ {
+ configData.setData(xml);
+ hservice_.update(configData);
+ }
+ }
+
+ public void removeServiceConfiguration(Class serviceType) throws Exception
+ {
+ hservice_.remove(serviceType, serviceType.getName());
+ }
+
+ @SuppressWarnings("unused")
+ private Object loadDefaultConfig(Class serviceType) throws Exception
+ {
+ // ServiceConfiguration sconf =
+ // manager_.getServiceConfiguration(serviceType) ;
+ // Iterator i = sconf.values().iterator() ;
+ // ObjectParam param = (ObjectParam) i.next() ;
+ // return param.getObject() ;
+ return null;
+ }
+
+}
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ExoResourceBundle.java (from rev 597, portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ExoResourceBundle.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ExoResourceBundle.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ExoResourceBundle.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,161 @@
+/**
+ * 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.services.resources;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.ListResourceBundle;
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * May 7, 2004
+ *
+ * @author: Tuan Nguyen
+ * @email: tuan08(a)users.sourceforge.net
+ * @version: $Id: ExoResourceBundle.java 9439 2006-10-12 03:28:53Z thuannd $
+ **/
+@SuppressWarnings("serial")
+public class ExoResourceBundle extends ListResourceBundle implements Serializable
+{
+
+ private static Pattern LINE_SEPARATOR = Pattern.compile("[\\r]?\\n");
+
+ private static Pattern UNICODE_CHARACTER = Pattern.compile("\\\\u[\\p{XDigit}]{4}+");
+
+ private Object[][] contents;
+
+ public ExoResourceBundle(String data)
+ {
+ String[] tokens = LINE_SEPARATOR.split(data);
+ List<String[]> properties = new ArrayList<String[]>();
+ for (String token : tokens)
+ {
+ int idx = token.indexOf('=');
+ if (idx < 0 || idx >= token.length() - 1)
+ {
+ continue;
+ }
+ String key = token.substring(0, idx);
+ if (key.trim().startsWith("#"))
+ {
+ continue;
+ }
+ String value = convert(token.substring(idx + 1, token.length()));
+ properties.add(new String[]{key, value});
+ }
+ String[][] aProperties = new String[properties.size()][2];
+ contents = (String[][])properties.toArray(aProperties);
+ }
+
+ public ExoResourceBundle(String data, ResourceBundle parent)
+ {
+ this(data);
+ setParent(parent);
+ }
+
+ public Object[][] getContents()
+ {
+ return contents;
+ }
+
+ public void putAll(Map<? super Object, ? super Object> map)
+ {
+ Enumeration<String> keys = getKeys();
+ while (keys.hasMoreElements())
+ {
+ String key = keys.nextElement();
+ if (key != null)
+ {
+ map.put(key, getString(key));
+ }
+ }
+ }
+
+ static String convert(String content)
+ {
+ Matcher matcher = UNICODE_CHARACTER.matcher(content);
+ StringBuilder buffer = new StringBuilder(content.length());
+ int start = 0;
+ while (matcher.find(start))
+ {
+ buffer.append(content.substring(start, matcher.start()));
+ buffer.append(unicode2Char(matcher.group()));
+ start = matcher.end();
+ }
+ if (start >= 0 && start < content.length())
+ {
+ buffer.append(content.substring(start));
+ }
+ return buffer.toString();
+ }
+
+ static char unicode2Char(String unicodeChar)
+ {
+ int value = 0;
+ char aChar;
+ for (int i = 0; i < 4; i++)
+ {
+ aChar = unicodeChar.charAt(i + 2);
+ switch (aChar)
+ {
+ case '0' :
+ case '1' :
+ case '2' :
+ case '3' :
+ case '4' :
+ case '5' :
+ case '6' :
+ case '7' :
+ case '8' :
+ case '9' : {
+ value = (value << 4) + aChar - '0';
+ break;
+ }
+ case 'a' :
+ case 'b' :
+ case 'c' :
+ case 'd' :
+ case 'e' :
+ case 'f' : {
+ value = (value << 4) + 10 + aChar - 'a';
+ break;
+ }
+ case 'A' :
+ case 'B' :
+ case 'C' :
+ case 'D' :
+ case 'E' :
+ case 'F' : {
+ value = (value << 4) + 10 + aChar - 'A';
+ break;
+ }
+ default : {
+ throw new IllegalArgumentException("Malformed \\uxxxx encoding.");
+ }
+ }
+ }
+ return (char)value;
+ }
+}
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/IdentityResourceBundle.java (from rev 597, portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/IdentityResourceBundle.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/IdentityResourceBundle.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/IdentityResourceBundle.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,58 @@
+/**
+ * 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.services.resources;
+
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.Vector;
+
+/**
+ * A resource bundle that returns the queried key. It returns an empty enumeration when the keys are queried.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class IdentityResourceBundle extends ResourceBundle
+{
+
+ public static final String MAGIC_LANGUAGE = "ma".intern();
+
+ public static final Locale MAGIC_LOCALE = new Locale(MAGIC_LANGUAGE);
+
+ private static final Vector<String> EMPTY_KEYS = new Vector<String>();
+
+ private static final IdentityResourceBundle instance = new IdentityResourceBundle();
+
+ public static ResourceBundle getInstance()
+ {
+ return instance;
+ }
+
+ protected Object handleGetObject(String key)
+ {
+ return key;
+ }
+
+ public Enumeration<String> getKeys()
+ {
+ return EMPTY_KEYS.elements();
+ }
+}
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/InputStreamURLConnection.java (from rev 597, portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/InputStreamURLConnection.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/InputStreamURLConnection.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/InputStreamURLConnection.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,68 @@
+/**
+ * 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.services.resources;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+
+/**
+ * An URLConnection extension that use a local {@link java.io.InputStream} object.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class InputStreamURLConnection extends URLConnection
+{
+
+ private final InputStream in;
+
+ /**
+ * Creates a new connection.
+ *
+ * @param url the original URL
+ * @param in the input stream
+ * @throws IllegalArgumentException if the stream is null
+ */
+ public InputStreamURLConnection(URL url, InputStream in) throws IllegalArgumentException
+ {
+ super(url);
+
+ //
+ if (in == null)
+ {
+ throw new IllegalArgumentException("No null input stream accepted");
+ }
+
+ //
+ this.in = in;
+ }
+
+ public void connect() throws IOException
+ {
+ // no op
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ return in;
+ }
+}
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/InputStreamURLStreamHandler.java (from rev 597, portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/InputStreamURLStreamHandler.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/InputStreamURLStreamHandler.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/InputStreamURLStreamHandler.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,62 @@
+/**
+ * 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.services.resources;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+/**
+ * An URLStreamHandler extension that use a local {@link java.io.InputStream} object. This object will always use
+ * the stream provided and nothing else. So the life time of an instance is very limited.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class InputStreamURLStreamHandler extends URLStreamHandler
+{
+
+ private final InputStream in;
+
+ /**
+ * Creates a new handler.
+ *
+ * @param in the input stream
+ * @throws IllegalArgumentException if the stream is null
+ */
+ public InputStreamURLStreamHandler(InputStream in) throws IllegalArgumentException
+ {
+ if (in == null)
+ {
+ throw new IllegalArgumentException("No null input stream accepted");
+ }
+
+ //
+ this.in = in;
+ }
+
+ protected URLConnection openConnection(URL u) throws IOException
+ {
+ return new InputStreamURLConnection(u, in);
+ }
+
+}
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/LocaleConfig.java (from rev 597, portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/LocaleConfig.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/LocaleConfig.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/LocaleConfig.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,84 @@
+/**
+ * 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.services.resources;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * May 3, 2004
+ *
+ * @author: Tuan Nguyen
+ * @email: tuan08(a)users.sourceforge.net
+ * @version: $Id: LocaleConfig.java 5799 2006-05-28 17:55:42Z geaz $
+ **/
+public interface LocaleConfig
+{
+
+ public String getDescription();
+
+ public void setDescription(String desc);
+
+ public String getOutputEncoding();
+
+ public void setOutputEncoding(String enc);
+
+ public String getInputEncoding();
+
+ public void setInputEncoding(String enc);
+
+ public Locale getLocale();
+
+ public void setLocale(Locale locale);
+
+ public void setLocale(String localeName);
+
+ public String getLanguage();
+
+ public String getLocaleName();
+
+ public ResourceBundle getResourceBundle(String name);
+
+ public ResourceBundle getMergeResourceBundle(String[] names);
+
+ public ResourceBundle getNavigationResourceBundle(String ownerType, String ownerId);
+
+ public void setInput(HttpServletRequest req) throws java.io.UnsupportedEncodingException;
+
+ public void setOutput(HttpServletResponse res);
+
+ /**
+ * Returns the orientation of the locale config.
+ *
+ * @return the orientation
+ */
+ public Orientation getOrientation();
+
+ /**
+ * Updates the orientation of the locale config.
+ *
+ * @param orientation the new orientation
+ */
+ public void setOrientation(Orientation orientation);
+
+}
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/LocaleConfigService.java (from rev 597, portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/LocaleConfigService.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/LocaleConfigService.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/LocaleConfigService.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -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.
+ */
+
+package org.exoplatform.services.resources;
+
+import java.util.Collection;
+
+/**
+ * @author Benjamin Mestrallet benjamin.mestrallet(a)exoplatform.com This Service
+ * is used to manage the locales that the applications can handle
+ */
+public interface LocaleConfigService
+{
+
+ /**
+ * @return Return the default LocaleConfig
+ */
+ public LocaleConfig getDefaultLocaleConfig();
+
+ /**
+ * @param lang a locale language
+ * @return The LocalConfig
+ */
+ public LocaleConfig getLocaleConfig(String lang);
+
+ /**
+ * @return All the LocalConfig that manage by the service
+ */
+ public Collection<LocaleConfig> getLocalConfigs();
+
+}
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/Orientation.java (from rev 597, portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/Orientation.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/Orientation.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/Orientation.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,85 @@
+/**
+ * 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.services.resources;
+
+/**
+ * An orientation.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public enum Orientation {
+
+ LT(0), // Western Europe
+
+ RT(1), // Middle East (Arabic, Hebrew)
+
+ TL(2), // Japanese, Chinese, Korean
+
+ TR(3); // Mongolian
+
+ private final int ordinal;
+
+ Orientation(int ordinal)
+ {
+ this.ordinal = ordinal;
+ }
+
+ /**
+ * Indicates whether the Locale correspond to an LT orientation.
+ *
+ * @return true if the orientation is LT
+ */
+ public boolean isLT()
+ {
+ return ordinal == 0;
+ }
+
+ /**
+ * Indicates whether the Locale correspond to an RT orientation.
+ *
+ * @return true if the orientation is RT
+ */
+ public boolean isRT()
+ {
+ return ordinal == 1;
+ }
+
+ /**
+ * Indicates whether the Locale correspond to an TL orientation.
+ *
+ * @return true if the orientation is TL
+ */
+ public boolean isTL()
+ {
+ return ordinal == 2;
+ }
+
+ /**
+ * Indicates whether the Locale correspond to an TR orientation.
+ *
+ * @return true if the orientation is TR
+ */
+ public boolean isTR()
+ {
+ return ordinal == 3;
+ }
+
+}
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/PropertiesClassLoader.java (from rev 597, portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/PropertiesClassLoader.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/PropertiesClassLoader.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/PropertiesClassLoader.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,200 @@
+/**
+ * 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.services.resources;
+
+import org.exoplatform.commons.utils.IOUtil;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Map;
+import java.util.Properties;
+import java.util.TreeMap;
+
+/**
+ * A {@link ClassLoader} extension that will retrieve resources from the parent
+ * classloader. For each resource having a ".properties" suffix it the
+ * classloader will try first to locate a corresponding resource using the same
+ * base name but with an ".xml" suffix. If such a resource is found, it will be
+ * loaded using {@link XMLResourceBundleParser}
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PropertiesClassLoader extends ClassLoader
+{
+
+ /**
+ * Logger.
+ */
+ private static final Log LOG = ExoLogger.getLogger(PropertiesClassLoader.class);
+
+ /**
+ * Indicates whether the resource must be encoded into UTF-8
+ */
+ private boolean unicode;
+
+ public PropertiesClassLoader(ClassLoader parent)
+ {
+ this(parent, false);
+ }
+
+ public PropertiesClassLoader(ClassLoader parent, boolean unicode)
+ {
+ super(parent);
+ this.unicode = unicode;
+ }
+
+ public PropertiesClassLoader()
+ {
+ }
+
+ @Override
+ public URL getResource(String name)
+ {
+ if (name.endsWith(".properties"))
+ {
+ URL url = null;
+ ClassLoader parent = getParent();
+ while (parent != null)
+ {
+ url = getResource(parent, name, unicode);
+ if (url != null)
+ {
+ return url;
+ }
+ parent = parent.getParent();
+ }
+ if (url == null)
+ {
+ url = getResource(this, name, unicode);
+ }
+ return url;
+ }
+ return super.getResource(name);
+ }
+
+ private static URL getResource(ClassLoader cl, String name, boolean unicode)
+ {
+ String xmlName = name.substring(0, name.length() - ".properties".length()) + ".xml";
+ URL url = getResource(cl, xmlName, unicode, true);
+ if (url == null)
+ {
+ url = getResource(cl, name, unicode, false);
+ }
+ return url;
+ }
+
+ private static URL getResource(ClassLoader cl, String name, boolean unicode, boolean xml)
+ {
+ Enumeration<URL> urls = null;
+ try
+ {
+ urls = cl.getResources(name);
+ }
+ catch (Exception e)
+ {
+ LOG.error("An error occured while seeking all the resources with the name " + name, e);
+ return null;
+ }
+ if (urls != null && urls.hasMoreElements())
+ {
+ // At least one such resource has been found
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ URL url = null;
+ Map<Object, Object> props = unicode ? new TreeMap<Object, Object>() : new Properties();
+ while (urls.hasMoreElements())
+ {
+ url = urls.nextElement();
+ InputStream in = null;
+ try
+ {
+ // Load content
+ in = url.openStream();
+ if (xml)
+ {
+ props.putAll(XMLResourceBundleParser.asProperties(in));
+ }
+ else
+ {
+ byte[] buf = IOUtil.getStreamContentAsBytes(in);
+ ExoResourceBundle bundle = new ExoResourceBundle(new String(buf, "UTF-8"));
+ bundle.putAll(props);
+ }
+ }
+ catch (Exception e)
+ {
+ LOG.error("An error occured while loading the content of " + url, e);
+ return null;
+ }
+ finally
+ {
+ if (in != null)
+ {
+ try
+ {
+ in.close();
+ }
+ catch (IOException e)
+ {
+ // Do nothing
+ }
+ }
+ }
+ }
+ try
+ {
+ // Now serialize as binary
+ if (unicode)
+ {
+ // Encoded into UTF-8
+ for (Map.Entry<Object, Object> entry : props.entrySet())
+ {
+ out.write(((String)entry.getKey()).getBytes("UTF-8"));
+ out.write('=');
+ out.write(((String)entry.getValue()).getBytes("UTF-8"));
+ out.write('\n');
+ }
+ }
+ else
+ {
+ // Properties format : encoded into ISO-8859-1 with unicode characters
+ ((Properties)props).store(out, null);
+ }
+ out.close();
+ InputStream in = new ByteArrayInputStream(out.toByteArray());
+
+ //
+ return new URL(url, "", new InputStreamURLStreamHandler(in));
+ }
+ catch (Exception e)
+ {
+ LOG.error("An error occured while creating the content of " + url, e);
+ return null;
+ }
+ }
+ return null;
+ }
+}
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/Query.java (from rev 597, portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/Query.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/Query.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/Query.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,71 @@
+/**
+ * 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.services.resources;
+
+/**
+ * Created by The eXo Platform SAS . Author : Tuan Nguyen
+ * tuan08(a)users.sourceforge.net Date: Jun 14, 2003 Time: 1:12:22 PM
+ */
+public class Query
+{
+
+ private String name_;
+
+ private String languages_;
+
+ private int maxSize_;
+
+ public Query(String name, String language)
+ {
+ name_ = name;
+ languages_ = language;
+ maxSize_ = 100;
+ }
+
+ public String getName()
+ {
+ return name_;
+ }
+
+ public void setName(String s)
+ {
+ name_ = s;
+ }
+
+ public String getLanguage()
+ {
+ return languages_;
+ }
+
+ public void setLanguage(String s)
+ {
+ languages_ = s;
+ }
+
+ public int getMaxSize()
+ {
+ return maxSize_;
+ }
+
+ public void setMaxSize(int s)
+ {
+ maxSize_ = s;
+ }
+}
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ResourceBundleData.java (from rev 597, portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ResourceBundleData.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ResourceBundleData.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ResourceBundleData.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -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.services.resources;
+
+import java.io.Serializable;
+
+/**
+ * Created by The eXo Platform SAS . Author : Tuan Nguyen
+ * tuan08(a)users.sourceforge.net Date: May 14, 2004 Time: 1:12:22 PM
+ */
+@SuppressWarnings("serial")
+public class ResourceBundleData extends ResourceBundleDescription implements Serializable
+{
+
+ private String data_;
+
+ public ResourceBundleData()
+ {
+ setResourceType("-");
+ setLanguage(DEFAULT_LANGUAGE);
+ }
+
+ /**
+ * @hibernate.property length="65535"
+ * type="org.exoplatform.services.database.impl.TextClobType"
+ **/
+ public String getData()
+ {
+ return data_;
+ }
+
+ public void setData(String data)
+ {
+ data_ = data;
+ }
+}
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ResourceBundleDescription.java (from rev 597, portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ResourceBundleDescription.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ResourceBundleDescription.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ResourceBundleDescription.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -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.services.resources;
+
+import java.io.Serializable;
+
+/**
+ * Created by The eXo Platform SAS . Author : Tuan Nguyen
+ * tuan08(a)users.sourceforge.net Date: May 14, 2004 Time: 1:12:22 PM
+ */
+@SuppressWarnings("serial")
+public class ResourceBundleDescription implements Serializable
+{
+
+ protected String id_;
+
+ protected String name_;
+
+ protected String language_;
+
+ protected String country_;
+
+ protected String variant_;
+
+ protected String resourceType_;
+
+ public ResourceBundleDescription()
+ {
+ }
+
+ /**
+ * @hibernate.id generator-class="assigned"
+ **/
+ public String getId()
+ {
+ if (id_ == null)
+ {
+ StringBuffer b = new StringBuffer();
+ b.append(name_);
+ if (language_ != null)
+ b.append('_').append(language_);
+ // if(country_ != null) b.append('_').append(country_);
+ // if(variant_ != null) b.append('_').append(variant_);
+ id_ = b.toString();
+ }
+ return id_;
+ }
+
+ public void setId(String id)
+ {
+ id_ = id;
+ }
+
+ /**
+ * @hibernate.property
+ **/
+ public String getName()
+ {
+ return name_;
+ }
+
+ public void setName(String name)
+ {
+ name_ = name;
+ }
+
+ /**
+ * @hibernate.property
+ **/
+ public String getLanguage()
+ {
+ return language_;
+ }
+
+ public void setLanguage(String s)
+ {
+ language_ = s;
+ }
+
+ /**
+ * @hibernate.property
+ **/
+ public String getCountry()
+ {
+ return country_;
+ }
+
+ public void setCountry(String s)
+ {
+ country_ = s;
+ }
+
+ /**
+ * @hibernate.property
+ **/
+ public String getVariant()
+ {
+ return variant_;
+ }
+
+ public void setVariant(String s)
+ {
+ variant_ = s;
+ }
+
+ /**
+ * @hibernate.property
+ **/
+ public String getResourceType()
+ {
+ return resourceType_;
+ }
+
+ public void setResourceType(String s)
+ {
+ resourceType_ = s;
+ }
+
+ final static public String DEFAULT_LANGUAGE = "en";
+
+}
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ResourceBundleLoader.java (from rev 597, portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ResourceBundleLoader.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ResourceBundleLoader.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ResourceBundleLoader.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -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.services.resources;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * A facade for obtaining resource bundles.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ResourceBundleLoader
+{
+
+ public static ResourceBundle load(String baseName, Locale locale, ClassLoader classLoader)
+ {
+ if (IdentityResourceBundle.MAGIC_LANGUAGE.equals(locale.getLanguage()))
+ {
+ return IdentityResourceBundle.getInstance();
+ }
+ PropertiesClassLoader pcl = new PropertiesClassLoader(classLoader);
+ return ResourceBundle.getBundle(baseName, locale, pcl);
+ }
+}
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ResourceBundleService.java (from rev 597, portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/ResourceBundleService.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ResourceBundleService.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ResourceBundleService.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,128 @@
+/**
+ * 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.services.resources;
+
+import org.exoplatform.commons.utils.PageList;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * May 7, 2004
+ *
+ * @author: Tuan Nguyen
+ * @email: tuan08(a)users.sourceforge.net
+ * @version: $Id: ResourceBundleService.java 5799 2006-05-28 17:55:42Z geaz $
+ * This class is used to manage the Resoucebunlde. It should work like
+ * the java.util.ResourceBundle class except that the properties file
+ * can be in the database or a a directory. The class
+ * java.util.ResourceBundle require that the properties file has to be
+ * in the classpath.
+ **/
+public interface ResourceBundleService
+{
+ /**
+ * This method should search for a template in the database that the service
+ * manage or the resource in the classpath of the current thread class loader
+ *
+ * @param name The name of the resource bunlde
+ * @param locale the locale
+ * @return A ResourceBunlde or null if no ResourceBundle is found
+ */
+ public ResourceBundle getResourceBundle(String name, Locale locale);
+
+ /**
+ * This method should search for a template in the database that the service
+ * manage or the resource in the classpath of the specified class loader
+ *
+ * @param name the name of the resource
+ * @param locale the locale
+ * @param cl The classloader
+ * @return
+ */
+ public ResourceBundle getResourceBundle(String name, Locale locale, ClassLoader cl);
+
+ /**
+ * This method will call the method public ResourceBundle
+ * getResourceBundle(String[] name, Locale locale, ClassLoader cl) and using
+ * the the classloader of the current thread
+ */
+ public ResourceBundle getResourceBundle(String[] name, Locale locale);
+
+ /**
+ * This method will look for all the resources with the given names and merge
+ * into one resource bundle, the properties in the later resource bundle name
+ * will have the higher priority than the previous one.
+ */
+ public ResourceBundle getResourceBundle(String[] name, Locale locale, ClassLoader cl);
+
+ /**
+ * This method should look for a resource bundle in the database that match
+ * the given id. The ResourceBundleData store the data as text instead of a
+ * properties map.
+ *
+ * @param id The id of the resource bundle data
+ * @return A ResourceBundleData instance or no record is found.
+ * @throws Exception
+ */
+ public ResourceBundleData getResourceBundleData(String id) throws Exception;
+
+ /**
+ * This method remove the data record in the databas and return the data
+ * instance after it has been removed
+ *
+ * @param id The id of the data record
+ * @return A ResourceBundleData instance
+ * @throws Exception
+ */
+ public ResourceBundleData removeResourceBundleData(String id) throws Exception;
+
+ /**
+ * This method shoudl create or update a ResourceBundleData instance
+ *
+ * @param data the ResourceBundleData instance to update or create
+ * @throws Exception
+ */
+ public void saveResourceBundle(ResourceBundleData data) throws Exception;
+
+ /**
+ * This method search and return a page description iterator
+ *
+ * @param q The search criteria
+ * @return A PageDescription Iterator
+ * @throws Exception
+ */
+ public PageList<ResourceBundleData> findResourceDescriptions(Query q) throws Exception;
+
+ /**
+ * This method is acted as a factory of
+ *
+ * @return
+ */
+ public ResourceBundleData createResourceBundleDataInstance();
+
+ /**
+ * The developer can store the common properties in certain resource bundles
+ * so later he can merge a resource bundle with the shared resource bunldes
+ *
+ * @return the name of the shared resource bundle
+ */
+ public String[] getSharedResourceBundleNames();
+}
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/XMLResourceBundleParser.java (from rev 597, portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/XMLResourceBundleParser.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/XMLResourceBundleParser.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/XMLResourceBundleParser.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,205 @@
+/**
+ * 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.services.resources;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+/**
+ * A parser for XML resource bundle having the following rules:
+ *
+ * <ul>
+ * <li>The root document element is named "bundle"</li>
+ * <li>Any non root element can have any name</li>
+ * <li>Any non root element content must not have mixed content (i.e text and children elements)</li>
+ * <li>Any element having textual content is considered as a bundle entry with they key formed by the
+ * dot concatenation of its parent element name except the root element and the value is the text content</li>
+ * </ul>
+ *
+ * For instance the following document:
+ *
+ * <bundle>
+ * <foo>
+ * <A>1<A>
+ * <B>2<B>
+ * </foo>
+ * <C>3<C>
+ * </bundle>
+ *
+ * will give the bundle with entries:
+ *
+ * <ul>
+ * <li>foo.A=1</li>
+ * <li>foo.B=2</li>
+ * <li>C=3</li>
+ * </ul>
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class XMLResourceBundleParser
+{
+
+ /**
+ * @see #asMap(org.xml.sax.InputSource)
+ */
+ public static Properties asProperties(InputStream in) throws IOException, SAXException,
+ ParserConfigurationException, IllegalArgumentException
+ {
+ if (in == null)
+ {
+ throw new IllegalArgumentException("No null input stream allowed");
+ }
+ return asProperties(new InputSource(in));
+ }
+
+ /**
+ * @see #asMap(org.xml.sax.InputSource)
+ */
+ public static Properties asProperties(Reader in) throws IOException, SAXException, ParserConfigurationException,
+ IllegalArgumentException
+ {
+ if (in == null)
+ {
+ throw new IllegalArgumentException("No null reader allowed");
+ }
+ return asProperties(new InputSource(in));
+ }
+
+ /**
+ * @see #asMap(org.xml.sax.InputSource)
+ */
+ public static Properties asProperties(InputSource in) throws IOException, SAXException,
+ ParserConfigurationException, IllegalArgumentException
+ {
+ if (in == null)
+ {
+ throw new IllegalArgumentException("No null input source allowed");
+ }
+ Map<String, String> bundle = asMap(in);
+ Properties props = new Properties();
+ props.putAll(bundle);
+ return props;
+ }
+
+ /**
+ * @see #asMap(org.xml.sax.InputSource)
+ */
+ public static Map<String, String> asMap(InputStream in) throws IOException, SAXException,
+ ParserConfigurationException, IllegalArgumentException
+ {
+ if (in == null)
+ {
+ throw new IllegalArgumentException("No null input stream allowed");
+ }
+ return asMap(new InputSource(in));
+ }
+
+ /**
+ * @see #asMap(org.xml.sax.InputSource)
+ */
+ public static Map<String, String> asMap(Reader in) throws IOException, SAXException, ParserConfigurationException,
+ IllegalArgumentException
+ {
+ if (in == null)
+ {
+ throw new IllegalArgumentException("No null reader allowed");
+ }
+ return asMap(new InputSource(in));
+ }
+
+ /**
+ * Load an xml resource bundle as a {@link Map<String,String>} object.
+ *
+ * @param in the input source
+ * @return the properties object
+ * @throws IOException any IOException
+ * @throws SAXException any SAXException
+ * @throws ParserConfigurationException any ParserConfigurationException
+ * @throws IllegalArgumentException if the argument is null
+ */
+ public static Map<String, String> asMap(InputSource in) throws IOException, SAXException,
+ ParserConfigurationException, IllegalArgumentException
+ {
+ if (in == null)
+ {
+ throw new IllegalArgumentException("No null input source allowed");
+ }
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document document = builder.parse(in);
+ Element bundleElt = document.getDocumentElement();
+ HashMap<String, String> bundle = new HashMap<String, String>();
+ collect(new LinkedList<String>(), bundleElt, bundle);
+ return bundle;
+ }
+
+ private static void collect(LinkedList<String> path, Element currentElt, Map<String, String> bundle)
+ {
+ NodeList children = currentElt.getChildNodes();
+ boolean text = true;
+ for (int i = children.getLength() - 1; i >= 0; i--)
+ {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE)
+ {
+ text = false;
+ Element childElt = (Element)child;
+ String name = childElt.getTagName();
+ path.addLast(name);
+ collect(path, childElt, bundle);
+ path.removeLast();
+ }
+ }
+ if (text && path.size() > 0)
+ {
+ String value = currentElt.getTextContent();
+ StringBuffer sb = new StringBuffer();
+ for (Iterator<String> i = path.iterator(); i.hasNext();)
+ {
+ String name = i.next();
+ sb.append(name);
+ if (i.hasNext())
+ {
+ sb.append('.');
+ }
+ }
+ String key = sb.toString();
+ bundle.put(key, value);
+ }
+ }
+}
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/impl/BaseResourceBundlePlugin.java (from rev 597, portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/BaseResourceBundlePlugin.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/impl/BaseResourceBundlePlugin.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/impl/BaseResourceBundlePlugin.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,75 @@
+/**
+ * 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.services.resources.impl;
+
+import org.exoplatform.container.component.BaseComponentPlugin;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.ValuesParam;
+
+import java.util.List;
+
+/**
+ * This class is used to define new resource bundles
+ *
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 24 sept. 2009
+ */
+public class BaseResourceBundlePlugin extends BaseComponentPlugin
+{
+
+ private final InitParams params;
+
+ public BaseResourceBundlePlugin(InitParams params)
+ {
+ this.params = params;
+ }
+
+ /**
+ * @return the list of enclosed "classpath" resource bundles
+ */
+ @SuppressWarnings("unchecked")
+ public List<String> getClasspathResources()
+ {
+ ValuesParam vParam = params.getValuesParam("classpath.resources");
+ return vParam == null ? null : vParam.getValues();
+ }
+
+ /**
+ * @return the list of enclosed "portal" resource bundles
+ */
+ @SuppressWarnings("unchecked")
+ public List<String> getPortalResources()
+ {
+ ValuesParam vParam = params.getValuesParam("portal.resource.names");
+ return vParam == null ? null : vParam.getValues();
+ }
+
+ /**
+ * @return the list of enclosed "init" resource bundles
+ */
+ @SuppressWarnings("unchecked")
+ public List<String> getInitResources()
+ {
+ ValuesParam vParam = params.getValuesParam("init.resources");
+ return vParam == null ? null : vParam.getValues();
+ }
+}
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/impl/BaseResourceBundleService.java (from rev 597, portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/BaseResourceBundleService.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/impl/BaseResourceBundleService.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/impl/BaseResourceBundleService.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,353 @@
+/**
+ * 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.services.resources.impl;
+
+import org.exoplatform.commons.utils.IOUtil;
+import org.exoplatform.commons.utils.MapResourceBundle;
+import org.exoplatform.commons.utils.PageList;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.resources.IdentityResourceBundle;
+import org.exoplatform.services.resources.LocaleConfig;
+import org.exoplatform.services.resources.LocaleConfigService;
+import org.exoplatform.services.resources.PropertiesClassLoader;
+import org.exoplatform.services.resources.Query;
+import org.exoplatform.services.resources.ResourceBundleData;
+import org.exoplatform.services.resources.ResourceBundleLoader;
+import org.exoplatform.services.resources.ResourceBundleService;
+import org.picocontainer.Startable;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+/**
+ * Created by The eXo Platform SAS Mar 9, 2007
+ */
+abstract public class BaseResourceBundleService implements ResourceBundleService, Startable
+{
+
+ protected Log log_;
+
+ protected volatile List<String> classpathResources_;
+
+ protected volatile String[] portalResourceBundleNames_;
+
+ protected LocaleConfigService localeService_;
+
+ protected ExoCache<String, ResourceBundle> cache_;
+
+ private volatile List<String> initResources_;
+
+ @SuppressWarnings("unchecked")
+ protected void initParams(InitParams params)
+ {
+ classpathResources_ = params.getValuesParam("classpath.resources").getValues();
+
+ // resources name can use for portlets
+ List prnames = params.getValuesParam("portal.resource.names").getValues();
+ portalResourceBundleNames_ = new String[prnames.size()];
+ for (int i = 0; i < prnames.size(); i++)
+ {
+ portalResourceBundleNames_[i] = (String)prnames.get(i);
+ }
+
+ initResources_ = params.getValuesParam("init.resources").getValues();
+ }
+
+ /**
+ * Add new resources bundles
+ */
+ public synchronized void addResourceBundle(BaseResourceBundlePlugin plugin)
+ {
+ List<String> classpathResources = plugin.getClasspathResources();
+ if (classpathResources != null && !classpathResources.isEmpty())
+ {
+ List<String> result = new ArrayList<String>(classpathResources);
+ if (classpathResources_ != null)
+ {
+ result.addAll(classpathResources_);
+ }
+ this.classpathResources_ = Collections.unmodifiableList(result);
+ }
+ List<String> portalResources = plugin.getPortalResources();
+ if (portalResources != null && !portalResources.isEmpty())
+ {
+ List<String> result = new ArrayList<String>(portalResources);
+ if (portalResourceBundleNames_ != null)
+ {
+ result.addAll(Arrays.asList(portalResourceBundleNames_));
+ }
+ this.portalResourceBundleNames_ = (String[])result.toArray(new String[result.size()]);
+ }
+ List<String> initResources = plugin.getInitResources();
+ if (initResources != null && !initResources.isEmpty())
+ {
+ List<String> result = new ArrayList<String>(initResources);
+ if (initResources_ != null)
+ {
+ result.addAll(initResources_);
+ }
+ this.initResources_ = Collections.unmodifiableList(result);
+ }
+ }
+
+ /**
+ * Loads all the "init" resource bundles
+ * @see org.picocontainer.Startable#start()
+ */
+ public void start()
+ {
+ PageList pl = null;
+ try
+ {
+ pl = findResourceDescriptions(new Query(null, null));
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Cannot check if a resource already exists", e);
+ }
+ if (pl.getAvailable() > 0)
+ return;
+
+ // init resources
+ List<String> initResources = initResources_;
+ for (String resource : initResources)
+ {
+ initResources(resource, Thread.currentThread().getContextClassLoader());
+ }
+ }
+
+ /**
+ * @see org.picocontainer.Startable#stop()
+ */
+ public void stop()
+ {
+ }
+
+ public ResourceBundle getResourceBundle(String[] name, Locale locale)
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ return getResourceBundle(name, locale, cl);
+ }
+
+ public ResourceBundle getResourceBundle(String name, Locale locale)
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ return getResourceBundle(name, locale, cl);
+ }
+
+ public String[] getSharedResourceBundleNames()
+ {
+ return portalResourceBundleNames_;
+ }
+
+ public ResourceBundleData createResourceBundleDataInstance()
+ {
+ return new ResourceBundleData();
+ }
+
+ protected boolean isClasspathResource(String name)
+ {
+ if (classpathResources_ == null)
+ return false;
+ for (int i = 0; i < classpathResources_.size(); i++)
+ {
+ String pack = classpathResources_.get(i);
+ if (name.startsWith(pack))
+ return true;
+ }
+ return false;
+ }
+
+ protected void initResources(String baseName, ClassLoader cl)
+ {
+ String name = baseName.replace('.', '/');
+ try
+ {
+ Collection<LocaleConfig> localeConfigs = localeService_.getLocalConfigs();
+ String defaultLang = localeService_.getDefaultLocaleConfig().getLanguage();
+ for (Iterator<LocaleConfig> iter = localeConfigs.iterator(); iter.hasNext();)
+ {
+ LocaleConfig localeConfig = iter.next();
+ String language = localeConfig.getLanguage();
+ String content = getResourceBundleContent(name, language, defaultLang, cl);
+ if (content != null)
+ {
+ // save the content
+ ResourceBundleData data = new ResourceBundleData();
+ data.setId(baseName + "_" + language);
+ data.setName(baseName);
+ data.setLanguage(language);
+ data.setData(content);
+ saveResourceBundle(data);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ log_.error("Error while reading the resource bundle : " + baseName, ex);
+ }
+ }
+
+ protected String getResourceBundleContent(String name, String language, String defaultLang, ClassLoader cl)
+ throws Exception
+ {
+ String fileName = null;
+ try
+ {
+ cl = new PropertiesClassLoader(cl, true);
+ fileName = name + "_" + language + ".properties";
+ URL url = cl.getResource(fileName);
+ if (url == null && defaultLang.equals(language))
+ {
+ url = cl.getResource(name + ".properties");
+ }
+ if (url != null)
+ {
+ InputStream is = url.openStream();
+ try
+ {
+ byte[] buf = IOUtil.getStreamContentAsBytes(is);
+ return new String(buf, "UTF-8");
+ }
+ finally
+ {
+ try
+ {
+ is.close();
+ }
+ catch (IOException e)
+ {
+ // Do nothing
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ throw new Exception("Error while reading the file: " + fileName, e);
+ }
+ return null;
+ }
+
+ /**
+ * Invalidate an entry in the cache at this level. Normally this is called by the subclass.
+ *
+ * @param name the bundle name
+ */
+ protected final void invalidate(String name)
+ {
+ cache_.remove(name);
+ }
+
+ public ResourceBundle getResourceBundle(String name, Locale locale, ClassLoader cl)
+ {
+ if (IdentityResourceBundle.MAGIC_LANGUAGE.equals(locale.getLanguage()))
+ {
+ return IdentityResourceBundle.getInstance();
+ }
+ if (isClasspathResource(name))
+ return ResourceBundleLoader.load(name, locale, cl);
+ String id = name + "_" + locale.getLanguage();
+ try
+ {
+ ResourceBundle rb = cache_.get(id);
+ if (rb != null)
+ return rb;
+ }
+ catch (Exception ex)
+ {
+ }
+
+ try
+ {
+ ResourceBundle res = null;
+ String rootId = name + "_" + localeService_.getDefaultLocaleConfig().getLanguage();
+ ResourceBundle parent = getResourceBundleFromDb(rootId, null, locale);
+ if (parent != null)
+ {
+ res = getResourceBundleFromDb(id, parent, locale);
+ if (res == null)
+ res = parent;
+ cache_.put(id, res);
+ return res;
+ }
+ }
+ catch (Exception ex)
+ {
+ log_.error("Error: " + id, ex);
+ }
+ return null;
+ }
+
+ public ResourceBundle getResourceBundle(String[] name, Locale locale, ClassLoader cl)
+ {
+ if (IdentityResourceBundle.MAGIC_LANGUAGE.equals(locale.getLanguage()))
+ {
+ return IdentityResourceBundle.getInstance();
+ }
+ StringBuilder idBuf = new StringBuilder("merge:");
+ for (String n : name)
+ idBuf.append(n).append("_");
+ idBuf.append(locale);
+ String id = idBuf.toString();
+ try
+ {
+ ResourceBundle res = cache_.get(id);
+ if (res != null)
+ return res;
+ MapResourceBundle outputBundled = new MapResourceBundle(locale);
+ for (int i = 0; i < name.length; i++)
+ {
+ ResourceBundle temp = getResourceBundle(name[i], locale, cl);
+ if (temp != null)
+ {
+ outputBundled.merge(temp);
+ continue;
+ }
+ log_.warn("Cannot load and merge the bundle: " + name[i]);
+ }
+ outputBundled.resolveDependencies();
+ cache_.put(id, outputBundled);
+ return outputBundled;
+ }
+ catch (Exception ex)
+ {
+ log_.error("Cannot load and merge the bundle: " + id, ex);
+ }
+ return null;
+ }
+
+ abstract protected ResourceBundle getResourceBundleFromDb(String id, ResourceBundle parent, Locale locale)
+ throws Exception;
+
+}
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigImpl.java (from rev 597, portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigImpl.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigImpl.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigImpl.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -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.services.resources.impl;
+
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.services.resources.LocaleConfig;
+import org.exoplatform.services.resources.Orientation;
+import org.exoplatform.services.resources.ResourceBundleService;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author Benjamin Mestrallet benjamin.mestrallet(a)exoplatform.com
+ */
+public class LocaleConfigImpl implements LocaleConfig
+{
+
+ static private Map<String, Locale> predefinedLocaleMap_ = null;
+
+ static
+ {
+ predefinedLocaleMap_ = new HashMap<String, Locale>(10);
+ predefinedLocaleMap_.put("us", Locale.US);
+ predefinedLocaleMap_.put("en", Locale.ENGLISH);
+ predefinedLocaleMap_.put("fr", Locale.FRANCE);
+ predefinedLocaleMap_.put("zh", Locale.SIMPLIFIED_CHINESE);
+ }
+
+ private Locale locale_;
+
+ private String outputEncoding_;
+
+ private String inputEncoding_;
+
+ private String description_;
+
+ private String localeName_;
+
+ private Orientation orientation;
+
+ public LocaleConfigImpl()
+ {
+ }
+
+ public final String getDescription()
+ {
+ return description_;
+ }
+
+ public final void setDescription(String desc)
+ {
+ description_ = desc;
+ }
+
+ public final String getOutputEncoding()
+ {
+ return outputEncoding_;
+ }
+
+ public final void setOutputEncoding(String enc)
+ {
+ outputEncoding_ = enc;
+ }
+
+ public final String getInputEncoding()
+ {
+ return inputEncoding_;
+ }
+
+ public final void setInputEncoding(String enc)
+ {
+ inputEncoding_ = enc;
+ }
+
+ public final Locale getLocale()
+ {
+ return locale_;
+ }
+
+ public final void setLocale(Locale locale)
+ {
+ locale_ = locale;
+ if (localeName_ == null)
+ localeName_ = locale.getLanguage();
+ }
+
+ public final void setLocale(String localeName)
+ {
+ localeName_ = localeName;
+ locale_ = predefinedLocaleMap_.get(localeName);
+ if (locale_ == null)
+ locale_ = new Locale(localeName);
+ }
+
+ public final String getLanguage()
+ {
+ return locale_.getLanguage();
+ }
+
+ public final String getLocaleName()
+ {
+ return localeName_;
+ }
+
+ public final void setLocaleName(String localeName)
+ {
+ localeName_ = localeName;
+ }
+
+ public ResourceBundle getResourceBundle(String name)
+ {
+ ResourceBundleService service =
+ (ResourceBundleService)ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(
+ ResourceBundleService.class);
+ ResourceBundle res = service.getResourceBundle(name, locale_);
+ return res;
+ }
+
+ public ResourceBundle getMergeResourceBundle(String[] names)
+ {
+ ResourceBundleService service =
+ (ResourceBundleService)ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(
+ ResourceBundleService.class);
+ ResourceBundle res = service.getResourceBundle(names, locale_);
+ return res;
+ }
+
+ public ResourceBundle getNavigationResourceBundle(String ownerType, String ownerId)
+ {
+ return getResourceBundle("locale.navigation." + ownerType + "." + ownerId.replaceAll("/", "."));
+ }
+
+ public void setInput(HttpServletRequest req) throws java.io.UnsupportedEncodingException
+ {
+ req.setCharacterEncoding(inputEncoding_);
+ }
+
+ public void setOutput(HttpServletResponse res)
+ {
+ res.setContentType("text/html; charset=" + outputEncoding_);
+ res.setLocale(locale_);
+ }
+
+ public Orientation getOrientation()
+ {
+ return orientation;
+ }
+
+ public void setOrientation(Orientation orientation)
+ {
+ this.orientation = orientation;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "LocaleConfig[" + "localeName=" + localeName_ + ",locale=" + locale_ + ",description=" + description_
+ + ",inputEncoding=" + inputEncoding_ + ",outputEncoding=" + outputEncoding_ + "]";
+ }
+}
Copied: portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigServiceImpl.java (from rev 597, portal/trunk/component/common/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigServiceImpl.java)
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigServiceImpl.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/impl/LocaleConfigServiceImpl.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,181 @@
+/**
+ * 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.services.resources.impl;
+
+import org.exoplatform.commons.utils.PropertyManager;
+import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.resources.IdentityResourceBundle;
+import org.exoplatform.services.resources.LocaleConfig;
+import org.exoplatform.services.resources.LocaleConfigService;
+import org.exoplatform.services.resources.Orientation;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+/**
+ * @author Benjamin Mestrallet benjamin.mestrallet(a)exoplatform.com This Service
+ * is used to manage the locales that the applications can handle
+ */
+public class LocaleConfigServiceImpl implements LocaleConfigService
+{
+
+ private static Log log = ExoLogger.getLogger(LocaleConfigServiceImpl.class);
+
+ private LocaleConfig defaultConfig_;
+
+ private Map<String, LocaleConfig> configs_;
+
+ private static final Map<String, Orientation> orientations = new HashMap<String, Orientation>();
+
+ static
+ {
+ orientations.put("lt", Orientation.LT);
+ orientations.put("rt", Orientation.RT);
+ orientations.put("tl", Orientation.TL);
+ orientations.put("tr", Orientation.TR);
+ }
+
+ public LocaleConfigServiceImpl(InitParams params, ConfigurationManager cmanager) throws Exception
+ {
+ configs_ = new HashMap<String, LocaleConfig>(10);
+ String confResource = params.getValueParam("locale.config.file").getValue();
+ InputStream is = cmanager.getInputStream(confResource);
+ parseConfiguration(is);
+ }
+
+ /**
+ * @return Return the default LocaleConfig
+ */
+ public LocaleConfig getDefaultLocaleConfig()
+ {
+ return defaultConfig_;
+ }
+
+ /**
+ * @param lang a locale language
+ * @return The LocalConfig
+ */
+ public LocaleConfig getLocaleConfig(String lang)
+ {
+ LocaleConfig config = configs_.get(lang);
+ if (config != null)
+ return config;
+ return defaultConfig_;
+ }
+
+ /**
+ * @return All the LocalConfig that manage by the service
+ */
+ public Collection<LocaleConfig> getLocalConfigs()
+ {
+ return configs_.values();
+ }
+
+ private void parseConfiguration(InputStream is) throws Exception
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setIgnoringComments(true);
+ factory.setCoalescing(true);
+ factory.setNamespaceAware(false);
+ factory.setValidating(false);
+ DocumentBuilder parser = factory.newDocumentBuilder();
+ Document document = parser.parse(is);
+ NodeList nodes = document.getElementsByTagName("locale-config");
+ for (int i = 0; i < nodes.getLength(); i++)
+ {
+ Node node = nodes.item(i);
+ NodeList children = node.getChildNodes();
+ LocaleConfig config = new LocaleConfigImpl();
+ for (int j = 0; j < children.getLength(); j++)
+ {
+ Node element = children.item(j);
+ if ("locale".equals(element.getNodeName()))
+ {
+ config.setLocale(element.getFirstChild().getNodeValue());
+ }
+ else if ("output-encoding".equals(element.getNodeName()))
+ {
+ config.setOutputEncoding(element.getFirstChild().getNodeValue());
+ }
+ else if ("input-encoding".equals(element.getNodeName()))
+ {
+ config.setInputEncoding(element.getFirstChild().getNodeValue());
+ }
+ else if ("description".equals(element.getNodeName()))
+ {
+ config.setDescription(element.getFirstChild().getNodeValue());
+ }
+ else if ("orientation".equals(element.getNodeName()))
+ {
+ String s = element.getFirstChild().getNodeValue();
+ Orientation orientation = orientations.get(s);
+ if (orientation == null)
+ {
+ log.error("Wrong orientation value " + s);
+ }
+ else
+ {
+ config.setOrientation(orientation);
+ }
+ }
+ }
+
+ //
+ if (config.getOrientation() == null)
+ {
+ log.debug("No orientation found on the locale config, use the LT default");
+ config.setOrientation(Orientation.LT);
+ }
+
+ //
+ log.debug("Added locale config " + config + " to the set of locale configs");
+
+ //
+ configs_.put(config.getLanguage(), config);
+ if (i == 0)
+ defaultConfig_ = config;
+ }
+
+ //
+ if (PropertyManager.isDevelopping())
+ {
+ LocaleConfig magicConfig = new LocaleConfigImpl();
+ magicConfig.setLocale(IdentityResourceBundle.MAGIC_LOCALE);
+ magicConfig.setDescription("Magic locale");
+ magicConfig.setInputEncoding("UTF-8");
+ magicConfig.setOutputEncoding("UTF-8");
+ magicConfig.setDescription("Default configuration for the debugging locale");
+ magicConfig.setOrientation(Orientation.LT);
+ configs_.put(magicConfig.getLanguage(), magicConfig);
+ log.debug("Added magic locale for debugging bundle usage at runtime");
+ }
+ }
+}
Added: portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/impl/SimpleResourceBundleService.java
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/impl/SimpleResourceBundleService.java (rev 0)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/impl/SimpleResourceBundleService.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -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.services.resources.impl;
+
+import org.exoplatform.commons.utils.LazyPageList;
+import org.exoplatform.commons.utils.ListAccess;
+import org.exoplatform.commons.utils.MapResourceBundle;
+import org.exoplatform.commons.utils.PageList;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.resources.ExoResourceBundle;
+import org.exoplatform.services.resources.LocaleConfigService;
+import org.exoplatform.services.resources.Query;
+import org.exoplatform.services.resources.ResourceBundleData;
+import org.exoplatform.services.resources.impl.BaseResourceBundleService;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * Created by The eXo Platform SARL
+ * Author : Tung Pham
+ * thanhtungty(a)gmail.com
+ * Dec 1, 2007
+ */
+public class SimpleResourceBundleService extends BaseResourceBundleService
+{
+
+ private final ConcurrentMap<String, ResourceBundleData> bundles = new ConcurrentHashMap<String, ResourceBundleData>();
+
+ public SimpleResourceBundleService(InitParams params, CacheService cService, LocaleConfigService localeService) throws Exception
+ {
+ log_ = ExoLogger.getLogger("org.exoplatform.services.resources");
+ localeService_ = localeService;
+ cache_ = cService.getCacheInstance(ResourceBundleData.class.getName());
+ initParams(params);
+ }
+
+ public ResourceBundleData getResourceBundleData(String id) throws Exception
+ {
+ return bundles.get(id);
+ }
+
+ public ResourceBundleData removeResourceBundleData(String id) throws Exception
+ {
+ if (id == null)
+ {
+ return null;
+ }
+ ResourceBundleData data = bundles.remove(id);
+ invalidate(id);
+ return data;
+ }
+
+ public void saveResourceBundle(ResourceBundleData resourceData) throws Exception
+ {
+ String id = resourceData.getId();
+ bundles.put(id, resourceData);
+ invalidate(id);
+ }
+
+ public PageList<ResourceBundleData> findResourceDescriptions(Query q) throws Exception
+ {
+ final ArrayList<ResourceBundleData> list = new ArrayList<ResourceBundleData>();
+ for (ResourceBundleData data : bundles.values())
+ {
+ boolean matches = true;
+ if (q.getName() != null)
+ {
+ matches &= q.getName().equals(data.getName());
+ }
+ if (q.getLanguage() != null)
+ {
+ matches &= q.getLanguage().equals(data.getLanguage());
+ }
+ if (matches)
+ {
+ list.add(data);
+ }
+ }
+ Collections.sort(list, new Comparator<ResourceBundleData>()
+ {
+ public int compare(ResourceBundleData o1, ResourceBundleData o2)
+ {
+ String l1 = o1.getLanguage();
+ String l2 = o2.getLanguage();
+ if (l1 == null)
+ {
+ return l2 == null ? 0 : 1;
+ }
+ else
+ {
+ return l1 == null ? -1 : l1.compareTo(l2);
+ }
+ }
+ });
+ return new LazyPageList<ResourceBundleData>(new ListAccess<ResourceBundleData>()
+ {
+ public ResourceBundleData[] load(int index, int length) throws Exception, IllegalArgumentException
+ {
+ List<ResourceBundleData> sub = list.subList(index, index + length);
+ return sub.toArray(new ResourceBundleData[sub.size()]);
+ }
+
+ public int getSize() throws Exception
+ {
+ return list.size();
+ }
+ }, 20);
+ }
+
+ @Override
+ protected ResourceBundle getResourceBundleFromDb(String id, ResourceBundle parent, Locale locale) throws Exception
+ {
+ ResourceBundleData data = getResourceBundleData(id);
+ if (data == null)
+ {
+ return null;
+ }
+ return new MapResourceBundle(new ExoResourceBundle(data.getData(), parent), locale);
+ }
+}
\ No newline at end of file
Modified: portal/trunk/component/resources/src/test/java/conf/portal/test-configuration.xml
===================================================================
--- portal/trunk/component/resources/src/test/java/conf/portal/test-configuration.xml 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/resources/src/test/java/conf/portal/test-configuration.xml 2009-11-16 12:53:30 UTC (rev 611)
@@ -70,5 +70,31 @@
<type>org.exoplatform.services.resources.ResourceBundleManager</type>
</component>
+ <component>
+ <key>org.exoplatform.services.resources.ResourceBundleService</key>
+ <type>org.exoplatform.services.resources.impl.SimpleResourceBundleService</type>
+ <init-params>
+ <values-param>
+ <name>classpath.resources</name>
+ <description>The resources that start with the following package name should be load from file system</description>
+ <value>locale.portlet</value>
+ </values-param>
+
+ <values-param>
+ <name>init.resources</name>
+ <description>Store the following resources into the db for the first launch </description>
+ <value>locale.test.resources.test</value>
+ </values-param>
+
+ <values-param>
+ <name>portal.resource.names</name>
+ <description>The properties files of the portal , those file will be merged
+ into one ResoruceBundle properties </description>
+ <value>local.portal.portal</value>
+ <value>local.portal.custom</value>
+ </values-param>
+ </init-params>
+ </component>
+
<import>jar:/conf/portal/testjcr/test-jcr-configuration.xml</import>
</configuration>
Copied: portal/trunk/component/resources/src/test/java/locale/test/myRB1-2.xml (from rev 597, portal/trunk/component/common/src/test/resources/locale/test/myRB1-2.xml)
===================================================================
--- portal/trunk/component/resources/src/test/java/locale/test/myRB1-2.xml (rev 0)
+++ portal/trunk/component/resources/src/test/java/locale/test/myRB1-2.xml 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,28 @@
+<?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.
+
+-->
+
+<bundle>
+ <my>
+ <!-- Key 1 -->
+ <key1>My Default Value In English v2</key1>
+ </my>
+</bundle>
\ No newline at end of file
Copied: portal/trunk/component/resources/src/test/java/locale/test/myRB1.xml (from rev 597, portal/trunk/component/common/src/test/resources/locale/test/myRB1.xml)
===================================================================
--- portal/trunk/component/resources/src/test/java/locale/test/myRB1.xml (rev 0)
+++ portal/trunk/component/resources/src/test/java/locale/test/myRB1.xml 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,32 @@
+<?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.
+
+-->
+
+<bundle>
+ <my>
+ <!-- Key 1 -->
+ <key1>My Default Value In English</key1>
+ <!-- Key 2 -->
+ <key2>My Default Value In English</key2>
+ <!-- Key 3 -->
+ <key3>My Default Value In English</key3>
+ </my>
+</bundle>
\ No newline at end of file
Copied: portal/trunk/component/resources/src/test/java/locale/test/myRB1_en-2.xml (from rev 597, portal/trunk/component/common/src/test/resources/locale/test/myRB1_en-2.xml)
===================================================================
--- portal/trunk/component/resources/src/test/java/locale/test/myRB1_en-2.xml (rev 0)
+++ portal/trunk/component/resources/src/test/java/locale/test/myRB1_en-2.xml 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,30 @@
+<?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.
+
+-->
+
+<bundle>
+ <my>
+ <!-- Key 2 -->
+ <key2>My New Value In English v2</key2>
+ <!-- Key 3 -->
+ <key3>My New Value In English v2</key3>
+ </my>
+</bundle>
\ No newline at end of file
Copied: portal/trunk/component/resources/src/test/java/locale/test/myRB1_en.xml (from rev 597, portal/trunk/component/common/src/test/resources/locale/test/myRB1_en.xml)
===================================================================
--- portal/trunk/component/resources/src/test/java/locale/test/myRB1_en.xml (rev 0)
+++ portal/trunk/component/resources/src/test/java/locale/test/myRB1_en.xml 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,30 @@
+<?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.
+
+-->
+
+<bundle>
+ <my>
+ <!-- Key 1 -->
+ <key1>My New Value In English</key1>
+ <!-- Key 3 -->
+ <key3>My New Value In English</key3>
+ </my>
+</bundle>
\ No newline at end of file
Copied: portal/trunk/component/resources/src/test/java/locale/test/myRB1_fr-2.xml (from rev 597, portal/trunk/component/common/src/test/resources/locale/test/myRB1_fr-2.xml)
===================================================================
--- portal/trunk/component/resources/src/test/java/locale/test/myRB1_fr-2.xml (rev 0)
+++ portal/trunk/component/resources/src/test/java/locale/test/myRB1_fr-2.xml 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,30 @@
+<!--
+
+ 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.
+
+-->
+
+<?xml version="1.0" encoding="UTF-8"?>
+<bundle>
+ <my>
+ <!-- Key 1 -->
+ <key1>My Value In French v2 with special characters such as éçàùƔ௵</key1>
+ <!-- Key 3 -->
+ <key3>My Value In French v2 with special characters such as éçàùƔ௵</key3>
+ </my>
+</bundle>
\ No newline at end of file
Copied: portal/trunk/component/resources/src/test/java/locale/test/myRB1_fr.xml (from rev 597, portal/trunk/component/common/src/test/resources/locale/test/myRB1_fr.xml)
===================================================================
--- portal/trunk/component/resources/src/test/java/locale/test/myRB1_fr.xml (rev 0)
+++ portal/trunk/component/resources/src/test/java/locale/test/myRB1_fr.xml 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,30 @@
+<!--
+
+ 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.
+
+-->
+
+<?xml version="1.0" encoding="UTF-8"?>
+<bundle>
+ <my>
+ <!-- Key 1 -->
+ <key1>My Value In French with special characters such as éçàùƔ௵</key1>
+ <!-- Key 2 -->
+ <key2>My Value In French with special characters such as éçàùƔ௵</key2>
+ </my>
+</bundle>
\ No newline at end of file
Copied: portal/trunk/component/resources/src/test/java/locale/test/myRB2-2.properties (from rev 597, portal/trunk/component/common/src/test/resources/locale/test/myRB2-2.properties)
===================================================================
--- portal/trunk/component/resources/src/test/java/locale/test/myRB2-2.properties (rev 0)
+++ portal/trunk/component/resources/src/test/java/locale/test/myRB2-2.properties 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,21 @@
+#
+# 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.
+#
+
+# key1
+my.key1=My Default Value In English v2
Copied: portal/trunk/component/resources/src/test/java/locale/test/myRB2.properties (from rev 597, portal/trunk/component/common/src/test/resources/locale/test/myRB2.properties)
===================================================================
--- portal/trunk/component/resources/src/test/java/locale/test/myRB2.properties (rev 0)
+++ portal/trunk/component/resources/src/test/java/locale/test/myRB2.properties 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,25 @@
+#
+# 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.
+#
+
+# key1
+my.key1=My Default Value In English
+# key2
+my.key2=My Default Value In English
+# key3
+my.key3=My Default Value In English
\ No newline at end of file
Copied: portal/trunk/component/resources/src/test/java/locale/test/myRB2_en-2.properties (from rev 597, portal/trunk/component/common/src/test/resources/locale/test/myRB2_en-2.properties)
===================================================================
--- portal/trunk/component/resources/src/test/java/locale/test/myRB2_en-2.properties (rev 0)
+++ portal/trunk/component/resources/src/test/java/locale/test/myRB2_en-2.properties 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,23 @@
+#
+# 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.
+#
+
+# key2
+my.key2=My New Value In English v2
+# key3
+my.key3=My New Value In English v2
Copied: portal/trunk/component/resources/src/test/java/locale/test/myRB2_en.properties (from rev 597, portal/trunk/component/common/src/test/resources/locale/test/myRB2_en.properties)
===================================================================
--- portal/trunk/component/resources/src/test/java/locale/test/myRB2_en.properties (rev 0)
+++ portal/trunk/component/resources/src/test/java/locale/test/myRB2_en.properties 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,23 @@
+#
+# 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.
+#
+
+# key1
+my.key1=My New Value In English
+# key3
+my.key3=My New Value In English
Copied: portal/trunk/component/resources/src/test/java/locale/test/myRB2_fr-2.properties (from rev 597, portal/trunk/component/common/src/test/resources/locale/test/myRB2_fr-2.properties)
===================================================================
--- portal/trunk/component/resources/src/test/java/locale/test/myRB2_fr-2.properties (rev 0)
+++ portal/trunk/component/resources/src/test/java/locale/test/myRB2_fr-2.properties 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,23 @@
+#
+# 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.
+#
+
+# key1
+my.key1=My Value In French v2 with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5
+# key3
+my.key3=My Value In French v2 with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5
Copied: portal/trunk/component/resources/src/test/java/locale/test/myRB2_fr.properties (from rev 597, portal/trunk/component/common/src/test/resources/locale/test/myRB2_fr.properties)
===================================================================
--- portal/trunk/component/resources/src/test/java/locale/test/myRB2_fr.properties (rev 0)
+++ portal/trunk/component/resources/src/test/java/locale/test/myRB2_fr.properties 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,23 @@
+#
+# 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.
+#
+
+# key1
+my.key1=My Value In French with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5
+# key2
+my.key2=My Value In French with special characters such as \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5
Copied: portal/trunk/component/resources/src/test/java/org/exoplatform/services/resources/TestExoResourceBundle.java (from rev 597, portal/trunk/component/common/src/test/java/org/exoplatform/services/resources/TestExoResourceBundle.java)
===================================================================
--- portal/trunk/component/resources/src/test/java/org/exoplatform/services/resources/TestExoResourceBundle.java (rev 0)
+++ portal/trunk/component/resources/src/test/java/org/exoplatform/services/resources/TestExoResourceBundle.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,84 @@
+/**
+ * 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.services.resources;
+
+import junit.framework.TestCase;
+
+public class TestExoResourceBundle extends TestCase
+{
+
+ public void testConstructor()
+ {
+ ExoResourceBundle bundle;
+ bundle = new ExoResourceBundle("key1=value");
+ assertEquals(1, bundle.getContents().length);
+ assertEquals("value", bundle.getString("key1"));
+ bundle = new ExoResourceBundle("key1=value\nkey2=value");
+ assertEquals(2, bundle.getContents().length);
+ assertEquals("value", bundle.getString("key1"));
+ assertEquals("value", bundle.getString("key2"));
+ bundle = new ExoResourceBundle("key1=value\r\nkey2=value");
+ assertEquals(2, bundle.getContents().length);
+ assertEquals("value", bundle.getString("key1"));
+ assertEquals("value", bundle.getString("key2"));
+ bundle = new ExoResourceBundle("#comment\r\nkey2=value");
+ assertEquals(1, bundle.getContents().length);
+ assertEquals("value", bundle.getString("key2"));
+ bundle = new ExoResourceBundle(" #comment\r\nkey2=value");
+ assertEquals(1, bundle.getContents().length);
+ assertEquals("value", bundle.getString("key2"));
+ bundle = new ExoResourceBundle(" bad entry\r\nkey2=value");
+ assertEquals(1, bundle.getContents().length);
+ assertEquals("value", bundle.getString("key2"));
+ bundle = new ExoResourceBundle("#key1 =value\r\nkey2=value");
+ assertEquals(1, bundle.getContents().length);
+ assertEquals("value", bundle.getString("key2"));
+ bundle = new ExoResourceBundle(" key1 =value\r\n key2 =value");
+ assertEquals(2, bundle.getContents().length);
+ assertEquals("value", bundle.getString(" key1 "));
+ assertEquals("value", bundle.getString(" key2 "));
+ }
+
+ public void testUnicode2Char()
+ {
+ for (int i = 0; i < (1 << 16); i++)
+ {
+ String value = Integer.toHexString(i);
+ while (value.length() < 4)
+ {
+ value = "0" + value;
+ }
+ assertEquals((char)i, ExoResourceBundle.unicode2Char("\\u" + value));
+ }
+ }
+
+ public void testConvert()
+ {
+ assertEquals("Normal Value", ExoResourceBundle.convert("Normal Value"));
+ assertEquals("\u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", ExoResourceBundle
+ .convert("\\u00E9\\u00E7\\u00E0\\u00F9\\u0194\\u0BF5"));
+ assertEquals("before \u00E9\u00E7\u00E0\u00F9\u0194\u0BF5", ExoResourceBundle
+ .convert("before \\u00E9\\u00E7\\u00E0\\u00F9\\u0194\\u0BF5"));
+ assertEquals("\u00E9\u00E7\u00E0\u00F9\u0194\u0BF5 after", ExoResourceBundle
+ .convert("\\u00E9\\u00E7\\u00E0\\u00F9\\u0194\\u0BF5 after"));
+ assertEquals("before \u00E9\u00E7\u00E0 between \u00F9\u0194\u0BF5 after", ExoResourceBundle
+ .convert("before \\u00E9\\u00E7\\u00E0 between \\u00F9\\u0194\\u0BF5 after"));
+ }
+}
Copied: portal/trunk/component/resources/src/test/java/org/exoplatform/services/resources/TestLocaleConfigService.java (from rev 597, portal/trunk/component/common/src/test/java/org/exoplatform/services/resources/TestLocaleConfigService.java)
===================================================================
--- portal/trunk/component/resources/src/test/java/org/exoplatform/services/resources/TestLocaleConfigService.java (rev 0)
+++ portal/trunk/component/resources/src/test/java/org/exoplatform/services/resources/TestLocaleConfigService.java 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,134 @@
+/**
+ * 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.services.resources;
+
+import junit.framework.TestCase;
+
+import org.exoplatform.commons.utils.PropertyManager;
+import org.exoplatform.container.configuration.ConfigurationManagerImpl;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.ValueParam;
+import org.exoplatform.services.resources.impl.LocaleConfigImpl;
+import org.exoplatform.services.resources.impl.LocaleConfigServiceImpl;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class TestLocaleConfigService extends TestCase
+{
+
+ public TestLocaleConfigService()
+ {
+ }
+
+ public TestLocaleConfigService(String s)
+ {
+ super(s);
+ }
+
+ public void testFoo() throws Exception
+ {
+ PropertyManager.setProperty(PropertyManager.DEVELOPING, "false");
+ LocaleConfigService service = createService();
+ Map<String, LocaleConfig> map = createMap(service);
+ assertEquals(4, map.size());
+ assertCommonConfigs(service);
+ }
+
+ public void testBar() throws Exception
+ {
+ PropertyManager.setProperty(PropertyManager.DEVELOPING, "true");
+ LocaleConfigService service = createService();
+ Map<String, LocaleConfig> map = createMap(service);
+ assertEquals(5, map.size());
+ assertCommonConfigs(service);
+ LocaleConfig ma = service.getLocaleConfig("ma");
+ assertLocaleConfig(ma, "ma", "Default configuration for the debugging locale", "UTF-8", "UTF-8", Orientation.LT,
+ IdentityResourceBundle.MAGIC_LOCALE);
+ }
+
+ public void testLocaleConfig() throws Exception
+ {
+ LocaleConfig ma = new LocaleConfigImpl();
+ ma.setLocale("ma");
+ assertEquals("ma", ma.getLocaleName());
+
+ LocaleConfig ma1 = new LocaleConfigImpl();
+ ma1.setLocale(new Locale("ma"));
+ assertEquals("ma", ma1.getLocaleName());
+ }
+
+ private Map<String, LocaleConfig> createMap(LocaleConfigService service)
+ {
+ Map<String, LocaleConfig> map = new HashMap<String, LocaleConfig>();
+ for (LocaleConfig config : service.getLocalConfigs())
+ {
+ map.put(config.getLanguage(), config);
+ }
+ return map;
+ }
+
+ private LocaleConfigService createService() throws Exception
+ {
+ ConfigurationManagerImpl cm = new ConfigurationManagerImpl();
+ InitParams params = new InitParams();
+ ValueParam param = new ValueParam();
+ param.setName("locale.config.file");
+ param.setValue("classpath:/resources/locales-config.xml");
+ params.addParameter(param);
+
+ //
+ LocaleConfigService service = new LocaleConfigServiceImpl(params, cm);
+ return service;
+ }
+
+ private void assertCommonConfigs(LocaleConfigService service)
+ {
+ LocaleConfig en = service.getLocaleConfig("en");
+ LocaleConfig fr = service.getLocaleConfig("fr");
+ LocaleConfig ar = service.getLocaleConfig("ar");
+ LocaleConfig vi = service.getLocaleConfig("vi");
+ assertLocaleConfig(en, "en", "Default configuration for english locale", "UTF-8", "UTF-8", Orientation.LT,
+ Locale.ENGLISH);
+ assertLocaleConfig(fr, "fr", "Default configuration for the french locale", "UTF-8", "UTF-8", Orientation.LT,
+ Locale.FRANCE);
+ assertLocaleConfig(ar, "ar", "Default configuration for the arabic locale", "UTF-8", "UTF-8", Orientation.RT,
+ new Locale("ar"));
+ assertLocaleConfig(vi, "vi", "Default configuration for the vietnam locale", "UTF-8", "UTF-8", Orientation.LT,
+ new Locale("vi"));
+ }
+
+ private void assertLocaleConfig(LocaleConfig config, String language, String description, String inputEncoding,
+ String outputEncoding, Orientation orientation, Locale locale)
+ {
+ assertNotNull(config);
+ assertEquals(language, config.getLanguage());
+ assertEquals(description, config.getDescription());
+ assertEquals(inputEncoding, config.getInputEncoding());
+ assertEquals(outputEncoding, config.getOutputEncoding());
+ assertEquals(orientation, config.getOrientation());
+ assertEquals(locale, config.getLocale());
+ }
+}
Copied: portal/trunk/component/resources/src/test/java/resources (from rev 597, portal/trunk/component/common/src/test/resources/resources)
Deleted: portal/trunk/component/resources/src/test/java/resources/locales-config.xml
===================================================================
--- portal/trunk/component/common/src/test/resources/resources/locales-config.xml 2009-11-13 22:36:33 UTC (rev 597)
+++ portal/trunk/component/resources/src/test/java/resources/locales-config.xml 2009-11-16 12:53:30 UTC (rev 611)
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-
-<locales-config>
-
- <locale-config>
- <locale>en</locale>
- <output-encoding>UTF-8</output-encoding>
- <input-encoding>UTF-8</input-encoding>
- <description>Default configuration for english locale</description>
- </locale-config>
-
- <locale-config>
- <locale>fr</locale>
- <output-encoding>UTF-8</output-encoding>
- <input-encoding>UTF-8</input-encoding>
- <description>Default configuration for the french locale</description>
- </locale-config>
-
- <locale-config>
- <locale>ar</locale>
- <output-encoding>UTF-8</output-encoding>
- <input-encoding>UTF-8</input-encoding>
- <description>Default configuration for the arabic locale</description>
- <orientation>rt</orientation>
- </locale-config>
-
- <locale-config>
- <locale>vi</locale>
- <output-encoding>UTF-8</output-encoding>
- <input-encoding>UTF-8</input-encoding>
- <description>Default configuration for the vietnam locale</description>
- <orientation>lt</orientation>
- </locale-config>
-</locales-config>
Copied: portal/trunk/component/resources/src/test/java/resources/locales-config.xml (from rev 610, portal/trunk/component/common/src/test/resources/resources/locales-config.xml)
===================================================================
--- portal/trunk/component/resources/src/test/java/resources/locales-config.xml (rev 0)
+++ portal/trunk/component/resources/src/test/java/resources/locales-config.xml 2009-11-16 12:53:30 UTC (rev 611)
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+
+<locales-config>
+
+ <locale-config>
+ <locale>en</locale>
+ <output-encoding>UTF-8</output-encoding>
+ <input-encoding>UTF-8</input-encoding>
+ <description>Default configuration for english locale</description>
+ </locale-config>
+
+ <locale-config>
+ <locale>fr</locale>
+ <output-encoding>UTF-8</output-encoding>
+ <input-encoding>UTF-8</input-encoding>
+ <description>Default configuration for the french locale</description>
+ </locale-config>
+
+ <locale-config>
+ <locale>ar</locale>
+ <output-encoding>UTF-8</output-encoding>
+ <input-encoding>UTF-8</input-encoding>
+ <description>Default configuration for the arabic locale</description>
+ <orientation>rt</orientation>
+ </locale-config>
+
+ <locale-config>
+ <locale>vi</locale>
+ <output-encoding>UTF-8</output-encoding>
+ <input-encoding>UTF-8</input-encoding>
+ <description>Default configuration for the vietnam locale</description>
+ <orientation>lt</orientation>
+ </locale-config>
+</locales-config>
Modified: portal/trunk/component/web/pom.xml
===================================================================
--- portal/trunk/component/web/pom.xml 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/component/web/pom.xml 2009-11-16 12:53:30 UTC (rev 611)
@@ -55,6 +55,12 @@
</dependency>
<dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.resources</artifactId>
+ <version>3.0.0-CR01-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
<groupId>org.gatein.wci</groupId>
<artifactId>wci-wci</artifactId>
<version>${org.gatein.wci.version}</version>
Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/common/common-configuration.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/common/common-configuration.xml 2009-11-16 11:44:02 UTC (rev 610)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/common/common-configuration.xml 2009-11-16 12:53:30 UTC (rev 611)
@@ -79,7 +79,7 @@
<component>
<key>org.exoplatform.services.resources.ResourceBundleService</key>
- <type>org.exoplatform.services.resources.jcr.ResourceBundleServiceImpl</type>
+ <type>org.exoplatform.services.resources.impl.SimpleResourceBundleService</type>
<init-params>
<values-param>
<name>classpath.resources</name>
15 years, 1 month
gatein SVN: r610 - portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component.
by do-not-reply@jboss.org
Author: truong.le
Date: 2009-11-16 06:44:02 -0500 (Mon, 16 Nov 2009)
New Revision: 610
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategoryForm.java
Log:
GTNPORTAL-252: ClassCastException in Application registry when creating new category
Modified: portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategoryForm.java
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategoryForm.java 2009-11-16 11:10:22 UTC (rev 609)
+++ portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategoryForm.java 2009-11-16 11:44:02 UTC (rev 610)
@@ -102,7 +102,7 @@
category_ = category;
uiSetting.getUIStringInput(FIELD_NAME).setEditable(false).setValue(category_.getName());
uiSetting.getUIStringInput(FIELD_DISPLAY_NAME).setValue(category_.getDisplayName());
- uiSetting.getUIStringInput(FIELD_DESCRIPTION).setValue(category_.getDescription());
+ uiSetting.getUIFormTextAreaInput(FIELD_DESCRIPTION).setValue(category_.getDescription());
List<String> accessPermissions = category_.getAccessPermissions();
String[] per = new String[accessPermissions.size()];
if (accessPermissions != null && accessPermissions.size() > 0)
15 years, 1 month