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>