[validations] First version of the validations project
authorAntonio Moreno <antonio.moreno@openbravo.com>
Tue, 30 Mar 2010 13:18:54 +0200
changeset 6907 60a98816806d
parent 6906 39596de39bca
child 6908 13dabd88fa58
[validations] First version of the validations project
build.xml
src-core/src/org/openbravo/buildvalidation/Validation.java
src-core/src/org/openbravo/buildvalidation/ValidationHandler.java
src-core/src/org/openbravo/modulescript/ModuleScript.java
src-core/src/org/openbravo/modulescript/ModuleScriptHandler.java
src-db/database/build.xml
src-db/database/lib/dbsourcemanager.jar
src-diagnostics/.classpath
src-diagnostics/.project
src-diagnostics/.settings/.jsdtscope
src-diagnostics/.settings/org.eclipse.jdt.core.prefs
src-diagnostics/.settings/org.eclipse.jst.common.project.facet.core.prefs
src-diagnostics/.settings/org.eclipse.wst.common.component
src-diagnostics/.settings/org.eclipse.wst.common.project.facet.core.xml
src-diagnostics/.settings/org.eclipse.wst.jsdt.ui.superType.container
src-diagnostics/.settings/org.eclipse.wst.jsdt.ui.superType.name
src-diagnostics/WebContent/META-INF/MANIFEST.MF
src-diagnostics/WebContent/WEB-INF/lib/.keep
src-diagnostics/WebContent/WEB-INF/web.xml
src-diagnostics/build-create.xml
src-diagnostics/build.xml
src-diagnostics/build/.keep
src-diagnostics/check-ob-perms.sh
src-diagnostics/config/diagnostics.properties
src-diagnostics/config/log4j.properties
src-diagnostics/src/Test.java
src-diagnostics/src/org/openbravo/check/Check.java
src-diagnostics/src/org/openbravo/task/CheckDB.java
src-diagnostics/src/org/openbravo/task/CheckEnvironmentVariables.java
src-diagnostics/src/org/openbravo/task/CheckJVMVersion.java
src-diagnostics/src/org/openbravo/task/CheckMemory.java
src-diagnostics/src/org/openbravo/task/CheckTomcatAntExecution.java
src-diagnostics/src/org/openbravo/task/CheckTomcatFilePermissions.java
src-diagnostics/src/org/openbravo/task/CheckTomcatMemory.java
src-diagnostics/src/org/openbravo/task/CheckTomcatVersion.java
src-diagnostics/src/org/openbravo/task/CheckX.java
src-diagnostics/src/org/openbravo/task/CompareVersion.java
src-diagnostics/src/org/openbravo/utils/PropertiesManager.java
src-diagnostics/src/org/openbravo/utils/ServerConnection.java
src-diagnostics/src/org/openbravo/utils/Version.java
src-util/buildvalidation/build.xml
src-util/buildvalidation/config/log4j.properties
src-util/buildvalidation/config/log4j.properties~
src-util/buildvalidation/src/org/openbravo/buildvalidation/Cbpvendoracct.java
src-util/buildvalidation/src/org/openbravo/buildvalidation/CbpvendoracctData.xsql
src-util/diagnostic/.classpath
src-util/diagnostic/.project
src-util/diagnostic/.settings/.jsdtscope
src-util/diagnostic/.settings/org.eclipse.jdt.core.prefs
src-util/diagnostic/.settings/org.eclipse.jst.common.project.facet.core.prefs
src-util/diagnostic/.settings/org.eclipse.wst.common.component
src-util/diagnostic/.settings/org.eclipse.wst.common.project.facet.core.xml
src-util/diagnostic/.settings/org.eclipse.wst.jsdt.ui.superType.container
src-util/diagnostic/.settings/org.eclipse.wst.jsdt.ui.superType.name
src-util/diagnostic/WebContent/META-INF/MANIFEST.MF
src-util/diagnostic/WebContent/WEB-INF/web.xml
src-util/diagnostic/build-create.xml
src-util/diagnostic/build.xml
src-util/diagnostic/build/.keep
src-util/diagnostic/check-ob-perms.sh
src-util/diagnostic/config/diagnostics.properties
src-util/diagnostic/config/log4j.properties
src-util/diagnostic/src/Test.java
src-util/diagnostic/src/org/openbravo/check/Check.java
src-util/diagnostic/src/org/openbravo/task/CheckDB.java
src-util/diagnostic/src/org/openbravo/task/CheckEnvironmentVariables.java
src-util/diagnostic/src/org/openbravo/task/CheckJVMVersion.java
src-util/diagnostic/src/org/openbravo/task/CheckMemory.java
src-util/diagnostic/src/org/openbravo/task/CheckTomcatAntExecution.java
src-util/diagnostic/src/org/openbravo/task/CheckTomcatFilePermissions.java
src-util/diagnostic/src/org/openbravo/task/CheckTomcatMemory.java
src-util/diagnostic/src/org/openbravo/task/CheckTomcatVersion.java
src-util/diagnostic/src/org/openbravo/task/CheckX.java
src-util/diagnostic/src/org/openbravo/task/CompareVersion.java
src-util/diagnostic/src/org/openbravo/utils/PropertiesManager.java
src-util/diagnostic/src/org/openbravo/utils/ServerConnection.java
src-util/diagnostic/src/org/openbravo/utils/Version.java
src-util/modulescript/build.xml
src/build.xml
src/org/openbravo/erpCommon/ad_process/ApplyModulesCallServlet.java
--- a/build.xml	Thu Apr 01 18:22:18 2010 +0200
+++ b/build.xml	Tue Mar 30 13:18:54 2010 +0200
@@ -212,6 +212,10 @@
     <fileset dir="${base.modules}">
       <include name="*/lib/**" />
     </fileset>
+    <dirset dir="${base.modules}">
+      <include name="*/build/classes/" />
+    </dirset>
+    <pathelement path="${basedir}/../../src-util/modulescript/build/classes/" />
   </path>
   
   <macrodef name="updatesystemstatus">
@@ -318,6 +322,18 @@
     <ant dir="${base.src}" target="compile" inheritAll="true" inheritRefs="true" />
   </target>
 
+  <target name="validate" depends="init">
+    <ant dir="src-util/buildvalidation" target="validate" inheritAll="true" inheritRefs="true" />
+  </target>
+  
+  <target name="compile.buildvalidation" depends="init, core.lib">
+    <ant dir="src-util/buildvalidation" target="compile" inheritAll="true" inheritRefs="true" />
+  </target>
+  
+  <target name="compile.modulescript" depends="init, core.lib">
+    <ant dir="src-util/modulescript" target="compile" inheritAll="true" inheritRefs="true" />
+  </target>
+
   <target name="compile.complete.deploy" depends="compile.complete.development, compile.complete.war">
     
     <!-- Calculate wad checksum to enable smartbuild-->
@@ -568,14 +584,14 @@
     <antcall target="db.apply.modules.sampledata" />
   </target>
 
-  <target name="update.database" depends="init, core.lib, database.lib">
+  <target name="update.database" depends="init, core.lib, database.lib, validate">
     <ant dir="${base.db}" target="update.database.java" inheritAll="true" inheritRefs="true" />
     <updatesystemstatus v="RB21"/>
     <antcall target="generate.entities.quick" />
     <antcall target="db.apply.modules" />
   </target>
 
-  <target name="update.database.mod" depends="init, core.lib, database.lib">
+  <target name="update.database.mod" depends="init, core.lib, database.lib, validate">
     <ant dir="${base.db}" target="update.database.mod.java" inheritAll="true" inheritRefs="true" />
   </target>
 
@@ -607,8 +623,7 @@
   </target>
 
 
-  <target name="apply.modules">
-    <antcall target="update.database.mod" />
+  <target name="apply.modules" depends="update.database.mod">
     <updatesystemstatus v="RB21"/>
 
     <antcall inheritall="true" inheritrefs="true" target="apply.module" />
@@ -786,8 +801,8 @@
   </target>
 
   <target name="diagnostic">
-    <ant dir="src-diagnostics" antfile="build-create.xml" target="build" />
-    <ant dir="src-diagnostics" target="check.all" />
+    <ant dir="src-util/diagnostic" antfile="build-create.xml" target="build" />
+    <ant dir="src-util/diagnostic" target="check.all" />
   </target>
 
   <target name="setup.check.os">
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-core/src/org/openbravo/buildvalidation/Validation.java	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,31 @@
+package org.openbravo.buildvalidation;
+
+import java.io.File;
+import java.util.ArrayList;
+
+import org.openbravo.database.CPStandAlone;
+import org.openbravo.database.ConnectionProvider;
+
+public abstract class Validation {
+
+  private ConnectionProvider cp = null;
+  private File basedir;
+
+  public abstract ArrayList<String> execute();
+
+  public ConnectionProvider getConnectionProvider() {
+    if (cp == null) {
+      File f = new File("");
+      f = new File(f.getAbsolutePath());
+      File fProp = null;
+      if (new File("../../config/Openbravo.properties").exists())
+        fProp = new File("../../config/Openbravo.properties");
+      else if (new File("../config/Openbravo.properties").exists())
+        fProp = new File("../config/Openbravo.properties");
+      else if (new File("config/Openbravo.properties").exists())
+        fProp = new File("config/Openbravo.properties");
+      cp = new CPStandAlone(fProp.getAbsolutePath());
+    }
+    return cp;
+  }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-core/src/org/openbravo/buildvalidation/ValidationHandler.java	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,101 @@
+package org.openbravo.buildvalidation;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+public class ValidationHandler extends Task {
+
+  private File basedir;
+  private String module;
+  private static Logger log4j = Logger.getLogger(ValidationHandler.class);
+
+  @Override
+  public void execute() {
+    String errorMessage = "";
+    List<String> classes = new ArrayList<String>();
+    File modFolders[];
+    if (module != null && !module.equals("%")) {
+      File moduleFolder = new File(basedir, "modules/" + module);
+      modFolders = new File[1];
+      modFolders[0] = moduleFolder;
+    } else {
+      File coreBuildFolder = new File(basedir, "src-util/buildvalidation/build/classes");
+      readClassFiles(classes, coreBuildFolder);
+      File moduleFolder = new File(basedir, "modules");
+      modFolders = moduleFolder.listFiles();
+    }
+    for (File modFolder : modFolders) {
+      if (modFolder.isDirectory()) {
+        File validationFolder = new File(modFolder, "build/classes");
+        if (validationFolder.exists()) {
+          readClassFiles(classes, validationFolder);
+        }
+      }
+    }
+
+    for (String s : classes) {
+      ArrayList<String> errors = new ArrayList<String>();
+      try {
+        Class<?> myClass = Class.forName(s);
+        if (myClass.getGenericSuperclass().equals(
+            Class.forName("org.openbravo.buildvalidation.Validation"))) {
+          Object instance = myClass.newInstance();
+          errors = callExecute(myClass, instance);
+          for (String error : errors) {
+            errorMessage += error + "\n";
+          }
+        }
+      } catch (Exception e) {
+        throw new BuildException("The validation " + s + " couldn't be properly executed");
+      }
+      if (errors.size() > 0) {
+        throw new BuildException(
+            errorMessage
+                + "\nThe validation failed. The system hasn't been modified. Fix the problems described in the validation messages, and then start the build again.");
+      }
+    }
+  }
+
+  @SuppressWarnings("unchecked")
+  private ArrayList<String> callExecute(Class<?> myClass, Object instance)
+      throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
+    return (ArrayList<String>) myClass.getMethod("execute", new Class[0]).invoke(instance,
+        new Object[0]);
+  }
+
+  private void readClassFiles(List<String> coreClasses, File file) {
+    if (file.isDirectory()) {
+      File[] files = file.listFiles();
+      for (File f : files) {
+        readClassFiles(coreClasses, f);
+      }
+    } else {
+      String fileName = file.getAbsolutePath();
+      fileName = fileName.split("build" + File.separatorChar + "classes" + File.separatorChar)[1];
+      coreClasses.add(fileName.replace(".class", "").replace(File.separatorChar, '.'));
+    }
+  }
+
+  public File getBasedir() {
+    return basedir;
+  }
+
+  public void setBasedir(File basedir) {
+    this.basedir = basedir;
+  }
+
+  public String getModule() {
+    return module;
+  }
+
+  public void setModule(String module) {
+    this.module = module;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-core/src/org/openbravo/modulescript/ModuleScript.java	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,18 @@
+package org.openbravo.modulescript;
+
+import org.openbravo.database.CPStandAlone;
+import org.openbravo.database.ConnectionProvider;
+
+public abstract class ModuleScript {
+
+  private ConnectionProvider cp = null;
+
+  public abstract void execute();
+
+  public ConnectionProvider getConnectionProvider() {
+    if (cp == null) {
+      cp = new CPStandAlone("config/Openbravo.properties");
+    }
+    return cp;
+  }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-core/src/org/openbravo/modulescript/ModuleScriptHandler.java	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,91 @@
+package org.openbravo.modulescript;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+public class ModuleScriptHandler extends Task {
+
+  private static Logger log4j = Logger.getLogger(ModuleScriptHandler.class);
+
+  private File basedir;
+  private String moduleJavaPackage;
+
+  @Override
+  public void execute() {
+    List<String> classes = new ArrayList<String>();
+    if (moduleJavaPackage != null) {
+      // We will only be executing the ModuleScripts of a specific module
+      File moduleDir = new File(basedir, "modules/" + moduleJavaPackage + "/build/classes");
+      readClassFiles(classes, moduleDir);
+    } else {
+      File coreBuildFolder = new File(basedir, "src-util/modulescript/build/classes");
+      readClassFiles(classes, coreBuildFolder);
+      File moduleFolder = new File(basedir, "modules");
+      File modFolders[] = moduleFolder.listFiles();
+      for (File modFolder : modFolders) {
+        if (modFolder.isDirectory()) {
+          File validationFolder = new File(modFolder, "build/classes");
+          if (validationFolder.exists()) {
+            readClassFiles(classes, validationFolder);
+          }
+        }
+      }
+    }
+    for (String s : classes) {
+      try {
+        Class<?> myClass = Class.forName(s);
+        if (myClass.getGenericSuperclass().equals(
+            Class.forName("org.openbravo.modulescript.ModuleScript"))) {
+          Object instance = myClass.newInstance();
+          callExecute(myClass, instance);
+        }
+      } catch (Exception e) {
+        throw new BuildException("Execution of moduleScript " + s + "failed.");
+      }
+    }
+  }
+
+  @SuppressWarnings("unchecked")
+  private ArrayList<String> callExecute(Class<?> myClass, Object instance)
+      throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
+    return (ArrayList<String>) myClass.getMethod("execute", new Class[0]).invoke(instance,
+        new Object[0]);
+  }
+
+  private void readClassFiles(List<String> coreClasses, File file) {
+    if (file.isDirectory()) {
+      File[] files = file.listFiles();
+      for (File f : files) {
+        readClassFiles(coreClasses, f);
+      }
+    } else {
+      String fileName = file.getAbsolutePath();
+      System.out.println(fileName);
+      fileName = fileName.split("build" + File.separatorChar + "classes" + File.separatorChar)[1];
+      coreClasses.add(fileName.replace(".class", "").replace(File.separatorChar, '.'));
+    }
+  }
+
+  public File getBasedir() {
+    return basedir;
+  }
+
+  public void setBasedir(File basedir) {
+    this.basedir = basedir;
+  }
+
+  public String getModuleJavaPackage() {
+    return moduleJavaPackage;
+  }
+
+  public void setModuleJavaPackage(String moduleJavaPackage) {
+    this.moduleJavaPackage = moduleJavaPackage;
+  }
+
+}
--- a/src-db/database/build.xml	Thu Apr 01 18:22:18 2010 +0200
+++ b/src-db/database/build.xml	Tue Mar 30 13:18:54 2010 +0200
@@ -42,6 +42,10 @@
     <fileset dir="${base.lib}">
       <include name="**/*.jar" />
     </fileset>
+    <dirset dir="${base.modules}">
+      <include name="*/build/classes/" />
+    </dirset>
+    <pathelement path="${basedir}/../../src-util/modulescript/build/classes/" />
   </path>
 
   <taskdef name="createscript" classname="org.openbravo.ddlutils.task.CreateXML2SQL">
Binary file src-db/database/lib/dbsourcemanager.jar has changed
--- a/src-diagnostics/.classpath	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-1.5.0-sun-1.5.0.11"/>
-	<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v5.5"/>
-	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
-	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
-	<classpathentry kind="output" path="build/classes"/>
-</classpath>
--- a/src-diagnostics/.project	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-	<name>OpenbravoDiagnostics</name>
-	<comment></comment>
-	<projects>
-	</projects>
-	<buildSpec>
-		<buildCommand>
-			<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-		<buildCommand>
-			<name>org.eclipse.jdt.core.javabuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-		<buildCommand>
-			<name>org.eclipse.wst.common.project.facet.core.builder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-		<buildCommand>
-			<name>org.eclipse.wst.validation.validationbuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-	</buildSpec>
-	<natures>
-		<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
-		<nature>org.eclipse.jdt.core.javanature</nature>
-		<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
-		<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
-		<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
-	</natures>
-</projectDescription>
--- a/src-diagnostics/.settings/.jsdtscope	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
-	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
-		<attributes>
-			<attribute name="hide" value="true"/>
-		</attributes>
-	</classpathentry>
-	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
-	<classpathentry kind="output" path=""/>
-</classpath>
--- a/src-diagnostics/.settings/org.eclipse.jdt.core.prefs	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-#Mon Nov 17 11:09:39 GMT+01:00 2008
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
--- a/src-diagnostics/.settings/org.eclipse.jst.common.project.facet.core.prefs	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-#Mon Nov 17 11:09:40 GMT+01:00 2008
-classpath.helper/org.eclipse.jdt.launching.JRE_CONTAINER\:\:org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType\:\:java-1.5.0-sun-1.5.0.11/owners=jst.java\:5.0
-classpath.helper/org.eclipse.jst.server.core.container\:\:org.eclipse.jst.server.tomcat.runtimeTarget\:\:Apache\ Tomcat\ v5.5/owners=jst.web\:2.4
-eclipse.preferences.version=1
--- a/src-diagnostics/.settings/org.eclipse.wst.common.component	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project-modules id="moduleCoreId" project-version="1.5.0">
-<wb-module deploy-name="OpenbravoDiagnostics">
-<wb-resource deploy-path="/" source-path="/WebContent"/>
-<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
-<property name="context-root" value="OpenbravoDiagnostics"/>
-<property name="java-output-path"/>
-</wb-module>
-</project-modules>
--- a/src-diagnostics/.settings/org.eclipse.wst.common.project.facet.core.xml	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<faceted-project>
-  <runtime name="Apache Tomcat v5.5"/>
-  <fixed facet="jst.java"/>
-  <fixed facet="jst.web"/>
-  <installed facet="jst.java" version="5.0"/>
-  <installed facet="jst.web" version="2.4"/>
-  <installed facet="wst.jsdt.web" version="1.0"/>
-</faceted-project>
--- a/src-diagnostics/.settings/org.eclipse.wst.jsdt.ui.superType.container	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
--- a/src-diagnostics/.settings/org.eclipse.wst.jsdt.ui.superType.name	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-Window
\ No newline at end of file
--- a/src-diagnostics/WebContent/META-INF/MANIFEST.MF	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Class-Path: 
-
--- a/src-diagnostics/WebContent/WEB-INF/web.xml	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
-	<display-name>
-	OpenbravoDiagnostics</display-name>
-
-	  <servlet>
-      <servlet-name>
-        Check
-      </servlet-name>
-      <servlet-class>
-        org.openbravo.check.Check
-      </servlet-class>
-      
-      
-    </servlet>
-	
-	<servlet-mapping>
-      <servlet-name>
-        Check
-      </servlet-name>
-      <url-pattern>
-        /Check.html
-    </url-pattern>
-  </servlet-mapping>
-  
-
-  
-    
-</web-app>
--- a/src-diagnostics/build-create.xml	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
-*************************************************************************
-* The contents of this file are subject to the Openbravo  Public  License
-* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
-* Version 1.1  with a permitted attribution clause; you may not  use this
-* file except in compliance with the License. You  may  obtain  a copy of
-* the License at http://www.openbravo.com/legal/license.html
-* Software distributed under the License  is  distributed  on  an "AS IS"
-* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-* License for the specific  language  governing  rights  and  limitations
-* under the License.
-* The Original Code is Openbravo ERP.
-* The Initial Developer of the Original Code is Openbravo SLU
-* All portions are Copyright (C) 2008 Openbravo SLU
-* All Rights Reserved.
-* Contributor(s):  ______________________________________.
-************************************************************************
--->
-<project name="openbravo-diagnostics-build" basedir="." default="build">
-
-  <path id="diagnostic.class.path">
-    <fileset dir="WebContent/WEB-INF/lib">
-      <include name="**/*.jar" />
-    </fileset>
-  </path>
-
-  <target name="build" depends="clean">
-    <copy todir="WebContent/WEB-INF/lib">
-      <fileset dir="../lib/runtime">
-        <include name="**/*.jar" />
-      </fileset>
-    </copy>
-    <javac srcdir="src" destdir="build/classes" encoding="UTF-8" debug="true" debuglevel="lines,vars,source" deprecation="on">
-      <classpath refid="diagnostic.class.path" />
-    </javac>
-  </target>
-
-  <target name="clean">
-    <delete failonerror="false">
-      <fileset dir="WebContent/WEB-INF/lib" />
-      <fileset dir="build/classes" />
-    </delete>
-    <mkdir dir="WebContent/WEB-INF/lib" />
-    <mkdir dir="build/classes" />
-    <copy file="../config/Openbravo.properties" todir="config" failonerror="false" />
-    <copy todir="WebContent/WEB-INF">
-      <fileset dir="config" />
-    </copy>
-  </target>
-
-  <target name="war">
-    <delete failonerror="false" file="lib/OpenbravoDiagnostics.war" />
-    <war compress="true" destfile="OpenbravoDiagnostics.war" encoding="UTF-8" webxml="WebContent/WEB-INF/web.xml">
-      <zipfileset dir="WebContent">
-        <exclude name="**/WEB-INF/web.xml" />
-        <exclude name="**/WEB-INF/lib/servlet-api.jar" />
-      </zipfileset>
-      <classes dir="build/classes" />
-    </war>
-  </target>
-</project>
\ No newline at end of file
--- a/src-diagnostics/build.xml	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,227 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
-*************************************************************************
-* The contents of this file are subject to the Openbravo  Public  License
-* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
-* Version 1.1  with a permitted attribution clause; you may not  use this
-* file except in compliance with the License. You  may  obtain  a copy of
-* the License at http://www.openbravo.com/legal/license.html
-* Software distributed under the License  is  distributed  on  an "AS IS"
-* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-* License for the specific  language  governing  rights  and  limitations
-* under the License.
-* The Original Code is Openbravo ERP.
-* The Initial Developer of the Original Code is Openbravo SLU
-* All portions are Copyright (C) 2008 Openbravo SLU
-* All Rights Reserved.
-* Contributor(s):  ______________________________________.
-************************************************************************
--->
-<project name="openbravo-diagnostics" basedir="." default="check.all">
-
-  <property file="config/diagnostics.properties" />
-  <property file="config/Openbravo.properties" />
-  <property environment="env" />
-
-  <condition property="context.running">
-    <http url="${tomcat.manager.url}/../OpenbravoDiagnostics/Check.html" />
-  </condition>
-
-  <condition property="isCheckPerms">
-    <and>
-      <os family="unix" />
-      <equals arg1="${chekPerms}" arg2="true" />
-    </and>
-  </condition>
-
-
-
-  <path id="diagnostic.class.path">
-    <pathelement path="build/classes" />
-    <pathelement path="config"/>
-    <fileset dir="WebContent/WEB-INF/lib">
-      <include name="**/*.jar" />
-    </fileset>
-  </path>
-
-
-  <taskdef name="compareVersion" classname="org.openbravo.task.CompareVersion">
-    <classpath refid="diagnostic.class.path" />
-  </taskdef>
-
-  <target name="check.all">
-    <antcall target="check.permissions" />
-    <antcall target="check.properties.configuration" />
-    <antcall target="check.environment.variables" />
-    <antcall target="check.db" />
-    <antcall target="check.ant" />
-    <antcall target="check.tomcat" />
-    <antcall target="undeploy.context" />
-  </target>
-
-  <target name="check.properties.configuration">
-    <antcall target="check.properties" />
-    <antcall target="check.log4j" />
-  </target>
-
-  <target name="check.environment.variables">
-    <taskdef name="checkEnv" classname="org.openbravo.task.CheckEnvironmentVariables">
-      <classpath refid="diagnostic.class.path" />
-    </taskdef>
-    <checkEnv />
-  </target>
-
-  <target name="check.properties">
-    <echo message="Checking for Openbravo.properties file..." />
-    <available file="../config/Openbravo.properties" property="isProperties" />
-    <fail unless="isProperties" message="Openbravo.properties file not available. Tip: move config/Openbravo.properties.template file to config/Openbravo.properties and configure it" />
-    <echo message="Openbravo.properties file OK" />
-
-    <echo message="Checking for source.path in Openbravo.properties file..." />
-    <condition property="isSourcePath">
-      <and>
-        <isset property="source.path" />
-        <available file="${source.path}" type="dir" />
-      </and>
-    </condition>
-    <fail unless="isSourcePath" message="source.path property is not properly set in Openbravo.properties file" />
-    <echo message="source.path OK" />
-  </target>
-
-  <target name="check.log4j">
-    <echo message="Checking for log4j.lcf file..." />
-    <available file="../config/log4j.lcf" property="isLog4j" />
-    <fail unless="isLog4j" message="log4j.lcf file not available. Tip: move config/log4j.lcf.template file to config/log4j.lcf and configure it" />
-    <echo message="log4j.lcf file OK" />
-  </target>
-
-  <target name="check.permissions" if="isCheckPerms">
-    <echo message="Checking file permissions for current user, (this will take a while)..." />
-    <exec executable="./check-ob-perms.sh" failonerror="true">
-      <arg value=".." />
-    </exec>
-    <echo message="Permissions OK" />
-  </target>
-
-  <target name="check.ant">
-    <antcall target="check.ant.version" />
-    <antcall target="check.ant.jvm.size" />
-    <antcall target="check.ant.jvm.version" />
-  </target>
-
-  <target name="check.tomcat">
-    <antcall target="deploy.context" />
-
-    <antcall target="check.tomcat.version" />
-    <antcall target="check.tomcat.jvm.size" />
-    <antcall target="check.tomcat.jvm.version" />
-    <antcall target="check.tomcat.ant" />
-    <antcall target="check.tomcat.permissions" />
-  </target>
-
-  <target name="check.db">
-    <taskdef name="checkDB" classname="org.openbravo.task.CheckDB">
-      <classpath refid="diagnostic.class.path" />
-    </taskdef>
-    <checkDB />
-  </target>
-
-  <target name="check.ant.version">
-    <echo message="Checking ant version..." />
-    <echo message="Minimun ${ant.min.version}, current ${ant.version}" />
-    <condition property="antversion">
-      <antversion atleast="${ant.min.version}" />
-    </condition>
-    <fail unless="antversion" message="Minimum ant version: ${ant.min.version}, current version ${ant.version}. Tip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#Apache_Ant" />
-    <echo message="Version OK" />
-  </target>
-
-  <target name="check.ant.jvm.version">
-    <echo message="Checking ant's JVM version..." />
-    <compareVersion v1="${ant.java.version}" v2="${jvm-version}" />
-  </target>
-
-  <target name="check.ant.jvm.size">
-    <taskdef name="checkAntMem" classname="org.openbravo.task.CheckMemory">
-      <classpath refid="diagnostic.class.path" />
-    </taskdef>
-    <checkAntMem />
-  </target>
-
-
-
-  <target name="check.tomcat.version">
-    <taskdef name="checkTomcatVersion" classname="org.openbravo.task.CheckTomcatVersion">
-      <classpath refid="diagnostic.class.path" />
-    </taskdef>
-    <checkTomcatVersion />
-  </target>
-
-  <target name="check.tomcat.jvm.size">
-    <taskdef name="checkMem" classname="org.openbravo.task.CheckTomcatMemory">
-      <classpath refid="diagnostic.class.path" />
-    </taskdef>
-    <checkMem />
-  </target>
-
-  <target name="check.tomcat.jvm.version">
-    <taskdef name="checkJVMversion" classname="org.openbravo.task.CheckJVMVersion">
-      <classpath refid="diagnostic.class.path" />
-    </taskdef>
-    <checkJVMversion />
-  </target>
-
-  <target name="check.tomcat.ant">
-    <taskdef name="checkTomcatAnt" classname="org.openbravo.task.CheckTomcatAntExecution">
-      <classpath refid="diagnostic.class.path" />
-    </taskdef>
-    <checkTomcatAnt />
-  </target>
-
-  <target name="check.tomcat.x">
-    <taskdef name="CheckX" classname="org.openbravo.task.CheckX">
-      <classpath refid="diagnostic.class.path" />
-    </taskdef>
-    <CheckX />
-  </target>
-
-
-  <target name="deploy.context" unless="context.running">
-    <ant antfile="build-create.xml" target="war" />
-    <taskdef name="deploy.war" classname="org.apache.catalina.ant.DeployTask">
-      <classpath refid="diagnostic.class.path" />
-    </taskdef>
-    <taskdef name="start" classname="org.apache.catalina.ant.StartTask">
-      <classpath refid="diagnostic.class.path" />
-    </taskdef>
-
-    <deploy.war url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/OpenbravoDiagnostics" war="file:src-diagnostics${file.separator}OpenbravoDiagnostics.war" />
-
-    <start url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/OpenbravoDiagnostics" />
-
-
-  </target>
-
-  <target name="check.tomcat.permissions" if="isCheckPerms">
-    <taskdef name="checkTomcatPermissions" classname="org.openbravo.task.CheckTomcatFilePermissions">
-      <classpath refid="diagnostic.class.path" />
-    </taskdef>
-    <checkTomcatPermissions />
-  </target>
-
-  <target name="undeploy.context">
-    <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask">
-      <classpath refid="diagnostic.class.path" />
-    </taskdef>
-    <undeploy url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/OpenbravoDiagnostics" failonerror="false" />
-  </target>
-
-  <target name="test1" description="simple ant task to be called from tomcat">
-    <echo message="testing..." />
-  </target>
-
-  <target name="test2" description="simple compilation task">
-    <delete file="build/classes/Test.class" failonerror="false" />
-    <javac srcdir="src" destdir="build/classes" includes="**/Test*" encoding="UTF-8" debug="true" debuglevel="lines,vars,source" deprecation="on" />
-  </target>
-</project>
--- a/src-diagnostics/check-ob-perms.sh	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-#!/bin/sh
-
-# *************************************************************************
-# * The contents of this file are subject to the Openbravo  Public  License
-# * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
-# * Version 1.1  with a permitted attribution clause; you may not  use this
-# * file except in compliance with the License. You  may  obtain  a copy of
-# * the License at http://www.openbravo.com/legal/license.html 
-# * Software distributed under the License  is  distributed  on  an "AS IS"
-# * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-# * License for the specific  language  governing  rights  and  limitations
-# * under the License. 
-# * The Original Code is Openbravo ERP. 
-# * The Initial Developer of the Original Code is Openbravo SLU 
-# * All portions are Copyright (C) 2008 Openbravo SLU 
-# * All Rights Reserved. 
-# * Contributor(s):  ______________________________________.
-# ************************************************************************
-
-
-# Check a user's permissions in a directory
-
-if [ $# -lt 1 ]; then
-  echo "Usage: check-ob-perms.sh directory [username]"
-  exit 1
-elif [ ! -d "$1" ]; then
-  echo "Error: specified directory does not exist: $2"
-  exit 1
-fi
-
-if [ $# -lt 2 ]; then
-  USER=${whoami}
-else
-  USER=$2
-fi
-
-USERID=$(id -u $USER)
-USERGROUPS="$(id -G $USER)"
-DIRFILES=$(find "$1" -printf "%U-%G+%m_%p\n")
-
-# If find fails, there is no read permission or the file does not exist
-if [ $? -eq 1 ]; then
-  echo "Error: user $USER does not have read permissions in some files or directories"
-  exit 1
-fi
-
-IFS='
-'
-
-for FILEDATA in $DIRFILES; do
-  # get part until first -
-  OWNER=${FILEDATA%%-*}
-  # get part until first +, but after -
-  mytemp=${FILEDATA%%+*}
-  GROUP=${mytemp#*-}
-  # get part until first -, but after +
-  mytemp=${FILEDATA%%_*}
-  PERM=${mytemp#*+}
-  # get part after first _
-  FILE=${FILEDATA#*_}
-
-  if [ $USERID -ne $OWNER ]; then
-    
-    # Check if user belongs to the file's group
-    echo $USERGROUPS | grep -q $GROUP
-    [ $? -eq 0 ] && BELONGS=1 || BELONGS=0
-
-    # Significant bit
-    if [ $BELONGS -eq 1 ]; then
-      SBIT=$(echo $PERM | sed 's/.\(.\)./\1/')
-    else
-      SBIT=$(echo $PERM | sed 's/..\(.\)/\1/')
-    fi
-
-    if [ $SBIT -ne 6 ] && [ $SBIT -ne 7 ]; then
-      echo "Error: user $USER does not have read or write permissions in file or directory:"
-      echo "$FILE"
-      exit 1
-    fi
-
-  fi
-
-done
--- a/src-diagnostics/config/diagnostics.properties	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-
-# *************************************************************************
-# * The contents of this file are subject to the Openbravo  Public  License
-# * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
-# * Version 1.1  with a permitted attribution clause; you may not  use this
-# * file except in compliance with the License. You  may  obtain  a copy of
-# * the License at http://www.openbravo.com/legal/license.html 
-# * Software distributed under the License  is  distributed  on  an "AS IS"
-# * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-# * License for the specific  language  governing  rights  and  limitations
-# * under the License. 
-# * The Original Code is Openbravo ERP. 
-# * The Initial Developer of the Original Code is Openbravo SLU 
-# * All portions are Copyright (C) 2008 Openbravo SLU 
-# * All Rights Reserved. 
-# * Contributor(s):  ______________________________________.
-# ************************************************************************
-
-ant.min.version=1.7.0
-max.memory=512
-jvm-version=1.6
-
-db.ora.version=10
-db.ora.opencursors=3000
-db.ora.processes=150
-
-db.pg.version=8.3.3
-db.pg.windows.version=8.3.5
-
-tomcat.version=5.5
--- a/src-diagnostics/config/log4j.properties	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-# *************************************************************************
-# * The contents of this file are subject to the Openbravo  Public  License
-# * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
-# * Version 1.1  with a permitted attribution clause; you may not  use this
-# * file except in compliance with the License. You  may  obtain  a copy of
-# * the License at http://www.openbravo.com/legal/license.html 
-# * Software distributed under the License  is  distributed  on  an "AS IS"
-# * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-# * License for the specific  language  governing  rights  and  limitations
-# * under the License. 
-# * The Original Code is Openbravo ERP. 
-# * The Initial Developer of the Original Code is Openbravo SLU 
-# * All portions are Copyright (C) 2010 Openbravo SLU 
-# * All Rights Reserved. 
-# * Contributor(s):  ______________________________________.
-# ************************************************************************
-
-log4j.rootCategory=INFO, C
-log4j.category.org.openbravo=INFO
-log4j.appender.C=org.apache.log4j.ConsoleAppender
-log4j.appender.C.layout=org.apache.log4j.PatternLayout
-
--- a/src-diagnostics/src/Test.java	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License. 
- * The Original Code is Openbravo ERP. 
- * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2010 Openbravo SLU 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-
-public class Test {
-
-  /**
-   * Dummy class to test that compilation can be done from Tomcat applications
-   */
-  public static void main(String[] args) {
-
-  }
-
-}
--- a/src-diagnostics/src/org/openbravo/check/Check.java	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License. 
- * The Original Code is Openbravo ERP. 
- * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008 Openbravo SLU 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-
-package org.openbravo.check;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.ProjectHelper;
-
-public class Check extends HttpServlet {
-  private static final long serialVersionUID = 1L;
-
-  @Override
-  protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
-      IOException {
-    final String command = req.getParameter("Command") == null ? "" : req.getParameter("Command");
-
-    final PrintWriter out = resp.getWriter();
-
-    if (command.equals("memory")) {
-      final Runtime runtime = Runtime.getRuntime();
-      final long maxMemory = runtime.maxMemory() / (1024 * 1024); // Memory
-      // in MB
-
-      out.println(maxMemory);
-    } else if (command.equals("jvm-version")) {
-      out.println(System.getProperty("java.runtime.version"));
-    } else if (command.equals("server")) {
-      out.println(req.getSession().getServletContext().getServerInfo());
-    } else if (command.equals("ant")) {
-      final String result = checkAnt(req.getParameter("file"), req.getParameter("task"));
-      out.println(result);
-    } else {
-      out.println("Non-recognized command: " + command);
-    }
-    out.close();
-  }
-
-  private String checkAnt(String file, String task) {
-    final Project project = new Project();
-    System.out.println("task: " + task);
-    try {
-      project.init();
-      ProjectHelper.getProjectHelper().parse(project, new File(file));
-      project.executeTarget(task);
-    } catch (final Exception e) {
-      return e.getMessage();
-    }
-    return "OK";
-  }
-
-  @Override
-  protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
-      IOException {
-    doPost(req, resp);
-  }
-}
--- a/src-diagnostics/src/org/openbravo/task/CheckDB.java	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,239 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License. 
- * The Original Code is Openbravo ERP. 
- * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008 Openbravo SLU 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-package org.openbravo.task;
-
-import java.io.FileInputStream;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.util.Properties;
-
-import org.apache.log4j.Logger;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.openbravo.utils.PropertiesManager;
-import org.openbravo.utils.Version;
-
-
-public class CheckDB extends Task {
-  static Logger log4j = Logger.getLogger(CheckDB.class);
-
-  @Override
-  public void execute() throws BuildException {
-
-    log4j.info("Checking database...");
-    final Properties properties = new Properties();
-    try {
-      properties.load(new FileInputStream("config/Openbravo.properties"));
-    } catch (final Exception e) {
-      throw new BuildException(e);
-    }
-
-    final String rdbms = properties.getProperty("bbdd.rdbms");
-    final String dbDriver = properties.getProperty("bbdd.driver");
-    String dbServer = properties.getProperty("bbdd.url");
-
-    final String user = properties.getProperty("bbdd.user");
-    final String userPassword = properties.getProperty("bbdd.password");
-
-    final String systemUser = properties.getProperty("bbdd.systemUser");
-    final String systemUserPassword = properties.getProperty("bbdd.systemPassword");
-
-    if (rdbms.equalsIgnoreCase("POSTGRE"))
-      dbServer += "/" + properties.getProperty("bbdd.sid");
-
-    try {
-      Class.forName(dbDriver);
-    } catch (final Exception e) {
-      throw new BuildException(e.getMessage());
-    }
-
-    log4j.info("Trying to connect to db server as standard user.");
-    try {
-      final Connection connUser = DriverManager.getConnection(dbServer, user, userPassword);
-      connUser.close();
-    } catch (final Exception e) {
-      log4j.warn("Couldn't connect to standard user (" + user
-          + ") tip, database might require to be created. Error:" + e.getMessage());
-    }
-    log4j.info("Connection OK");
-
-    log4j.info("Trying to connect to db server as system user.");
-    Connection connSystem = null;
-    try {
-      connSystem = DriverManager.getConnection(dbServer, systemUser, systemUserPassword);
-    } catch (final Exception e) {
-      throw new BuildException(e.getMessage());
-    }
-    log4j.info("Connection OK");
-
-    PreparedStatement st;
-    ResultSet result;
-
-    if (rdbms.equalsIgnoreCase("ORACLE")) {
-      // Check version
-      String versionString = "";
-      log4j.info("Checking Oracle version...");
-      try {
-        st = connSystem.prepareStatement("select * from v$version where banner like '%Oracle%'");
-        result = st.executeQuery();
-        while (result.next()) {
-          versionString = result.getString(1);
-        }
-        result.close();
-        st.close();
-      } catch (final Exception e) {
-        throw new BuildException(e.getMessage());
-      }
-      final String version = Version.getVersion(versionString);
-      final String minVersion = new PropertiesManager().getProperty("db.ora.version");
-      String msg = "Minimum required version: " + minVersion + ", current version " + version;
-      if (Version.compareVersion(version, minVersion) < 0)
-        throw new BuildException(msg
-            + "\nTip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#Oracle");
-      else {
-        log4j.info(msg);
-        log4j.info("Oracle version OK");
-      }
-
-      // check open_cursors
-      log4j.info("Checking Oracle open cursors...");
-      long openCursors = 0;
-      try {
-        st = connSystem
-            .prepareStatement("SELECT value FROM v$parameter WHERE name ='open_cursors'");
-        result = st.executeQuery();
-        while (result.next()) {
-          openCursors = new Long(result.getString(1));
-        }
-        result.close();
-        st.close();
-      } catch (final Exception e) {
-        throw new BuildException(e.getMessage());
-      }
-      final long minOpenCursors = new Long(new PropertiesManager()
-          .getProperty("db.ora.opencursors"));
-      msg = "Minimum open cursors required: " + minOpenCursors + ", current open cursors "
-          + openCursors;
-      if (openCursors < minOpenCursors)
-        throw new BuildException(msg
-            + "\nTip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#Oracle");
-      else {
-        log4j.info(msg);
-        log4j.info("Open cursors OK");
-      }
-
-      // check processes
-      log4j.info("Checking Oracle open cursors...");
-      long processes = 0;
-      try {
-        st = connSystem.prepareStatement("SELECT value FROM v$parameter WHERE name ='processes'");
-        result = st.executeQuery();
-        while (result.next()) {
-          processes = new Long(result.getString(1));
-        }
-        result.close();
-        st.close();
-      } catch (final Exception e) {
-        throw new BuildException(e.getMessage());
-      }
-      final long minProcesses = new Long(new PropertiesManager().getProperty("db.ora.processes"));
-      msg = "Minimum open processes required: " + minProcesses + ", current processes " + processes;
-      if (processes < minProcesses)
-        throw new BuildException(msg
-            + "\nTip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#Oracle");
-      else {
-        log4j.info(msg);
-        log4j.info("Open cursors OK");
-      }
-
-      try {
-        st = connSystem
-            .prepareStatement("select value from nls_database_parameters where parameter='NLS_NCHAR_CHARACTERSET'");
-        result = st.executeQuery();
-        result.next();
-        String nchar_charset = result.getString(1);
-        if (nchar_charset.equals("AL16UTF16"))
-          log4j.info("NCHAR charset encoding OK.");
-        else {
-          throw new BuildException("NCHAR charset encoding incorrect. Current encoding: "
-              + nchar_charset + ". Required encoding: AL16UTF16");
-        }
-        result.close();
-        st.close();
-      } catch (final Exception e) {
-        throw new BuildException(e.getMessage());
-      }
-    } else { // PostgreSQL
-      // Check version
-      log4j.info("Checking PostgreSQL version...");
-      String version = "";
-      try {
-        st = connSystem
-            .prepareStatement("SELECT setting FROM pg_settings WHERE name = 'server_version'");
-
-        result = st.executeQuery();
-
-        while (result.next()) {
-          version = result.getString(1);
-        }
-        result.close();
-        st.close();
-      } catch (final Exception e) {
-        throw new BuildException(e.getMessage());
-      }
-
-      String minVersion = new PropertiesManager().getProperty("db.pg.version");
-      if (System.getProperty("os.name").equalsIgnoreCase("Windows"))
-        minVersion = new PropertiesManager().getProperty("db.pg.windows.version");
-      else
-        minVersion = new PropertiesManager().getProperty("db.pg.version");
-
-      final String msg = "Minimum required version: " + minVersion + ", current version " + version;
-      if (Version.compareVersion(version, minVersion) < 0)
-        throw new BuildException(msg
-            + "\nTip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#PostgreSQL");
-      else {
-        log4j.info(msg);
-        log4j.info("PostgreSQL version OK");
-      }
-
-      // Check contrib
-      log4j.info("Checking PostgreSQL contrib package installed...");
-      try {
-        st = connSystem.prepareStatement("SELECT uuid_generate_v4()");
-        result = st.executeQuery();
-        result.close();
-        st.close();
-      } catch (final Exception e) {
-        throw new BuildException("PostgreSQL contrib package seems not to be installed"
-            + "\nTip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#PostgreSQL");
-      }
-      log4j.info("Contrib package OK");
-
-    }
-    try {
-      connSystem.close();
-    } catch (final Exception e) {
-      throw new BuildException(e.getMessage());
-    }
-  }
-
-}
--- a/src-diagnostics/src/org/openbravo/task/CheckEnvironmentVariables.java	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License. 
- * The Original Code is Openbravo ERP. 
- * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008 Openbravo SLU 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-
-package org.openbravo.task;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-
-import org.apache.log4j.Logger;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-
-/**
- * Checks whether the required environment variables are set.
- * 
- * @author awolski
- * 
- */
-public class CheckEnvironmentVariables extends Task {
-
-  static Logger log4j = Logger.getLogger(CheckEnvironmentVariables.class);
-
-  /**
-   * A mapping of the required variables and the message to display if not found.
-   */
-  static Map<String, String> varsToCheck;
-
-  static {
-    varsToCheck = new HashMap<String, String>();
-    varsToCheck.put("CATALINA_HOME", "CATALINA_HOME environment variable is required. "
-        + "Tip: Set a CATALINA_HOME environment variable to the"
-        + " directory where Tomcat is installed.");
-  }
-
-  /**
-   * Verifies that all of the required environment variables are set.
-   */
-  @Override
-  public void execute() throws BuildException {
-    log4j.info("Checking for required environment variables...");
-    String msg = "";
-
-    final Set<Entry<String, String>> vars = varsToCheck.entrySet();
-
-    for (final Entry<String, String> var : vars) {
-      final String name = var.getKey();
-      final String tip = var.getValue();
-
-      final String value = System.getenv(name);
-      if (value == null) {
-        msg += tip + "\n";
-      } else {
-        log4j.info(name + " found: " + value);
-      }
-    }
-    if (!"".equals(msg)) {
-      throw new BuildException(msg);
-    } else {
-      log4j.info("Environment variables OK");
-    }
-  }
-}
--- a/src-diagnostics/src/org/openbravo/task/CheckJVMVersion.java	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License. 
- * The Original Code is Openbravo ERP. 
- * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008 Openbravo SLU 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-
-package org.openbravo.task;
-
-import org.apache.log4j.Logger;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.openbravo.utils.PropertiesManager;
-import org.openbravo.utils.ServerConnection;
-import org.openbravo.utils.Version;
-
-public class CheckJVMVersion extends Task {
-  static Logger log4j = Logger.getLogger(CheckJVMVersion.class);
-
-  @Override
-  public void execute() throws BuildException {
-    log4j.info("Checking Tomcat's JVM version...");
-
-    final String jvmVersion = new ServerConnection().getCheck("jvm-version");
-    final String minJvmVersion = new PropertiesManager().getProperty("jvm-version");
-
-    final String msg = "Current Tomcat's JVM version: " + jvmVersion
-        + " minimum required version: " + minJvmVersion;
-
-    if (Version.compareVersion(jvmVersion, minJvmVersion) < 0)
-      throw new BuildException(msg
-          + "\nTip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#Apache_Tomcat");
-    else {
-      log4j.info(msg);
-      log4j.info("Tomcat's JVM version OK");
-    }
-  }
-
-  public static void main(String[] args) {
-    final CheckJVMVersion c = new CheckJVMVersion();
-    c.execute();
-  }
-
-}
--- a/src-diagnostics/src/org/openbravo/task/CheckMemory.java	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License. 
- * The Original Code is Openbravo ERP. 
- * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008 Openbravo SLU 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-
-package org.openbravo.task;
-
-import org.apache.log4j.Logger;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.openbravo.utils.PropertiesManager;
-
-public class CheckMemory extends Task {
-  static Logger log4j = Logger.getLogger(CheckMemory.class);
-
-  @Override
-  public void execute() throws BuildException {
-    log4j.info("Checking ant's memory...");
-    final Runtime runtime = Runtime.getRuntime();
-    final long maxCurrentMemory = runtime.maxMemory() / (1024 * 1024); // Memory
-    // in
-    // MB
-
-    final long maxMemory = new Long(new PropertiesManager().getProperty("max.memory"));
-    final String msg = "Current max ant's memory:" + maxCurrentMemory + "M, minimum required:"
-        + maxMemory + "M";
-    // check max memory +- 5%, because it is not accurate
-    if (maxMemory > maxCurrentMemory * 1.05)
-      throw new BuildException(msg
-          + "\nTip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#Apache_Ant");
-    else {
-      log4j.info(msg);
-      log4j.info("Ant's memory OK ");
-    }
-  }
-
-}
--- a/src-diagnostics/src/org/openbravo/task/CheckTomcatAntExecution.java	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License. 
- * The Original Code is Openbravo ERP. 
- * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008 Openbravo SLU 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-
-package org.openbravo.task;
-
-import java.io.File;
-
-import org.apache.log4j.Logger;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.openbravo.utils.ServerConnection;
-
-public class CheckTomcatAntExecution extends Task {
-  static Logger log4j = Logger.getLogger(CheckTomcatAntExecution.class);
-
-  @Override
-  public void execute() throws BuildException {
-    final File f = new File("src-diagnostics/build.xml");
-    final String fileName = f.getAbsolutePath().replace("\\", "/");
-    System.out.println(fileName);
-    log4j.info("Checking tomcat executing ant tasks...");
-    String result = new ServerConnection().getCheck("ant", "&file=" + fileName + "&task=test1");
-    if (result.equals("OK"))
-      log4j.info("Possible to execute simple tasks. OK");
-    else
-      throw new BuildException("Tomcat cannot execute simple ant tasks: " + result);
-
-    result = new ServerConnection().getCheck("ant", "&file=" + fileName + "&task=test2");
-    if (result.equals("OK"))
-      log4j.info("Possible to execute ant javac task. OK");
-    else
-      throw new BuildException("Tomcat cannot execute ant javac task: " + result
-          + "Tip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#Apache_Tomcat");
-  }
-
-}
--- a/src-diagnostics/src/org/openbravo/task/CheckTomcatFilePermissions.java	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License. 
- * The Original Code is Openbravo ERP. 
- * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008 Openbravo SLU 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-
-package org.openbravo.task;
-
-import java.io.File;
-
-import org.apache.log4j.Logger;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.openbravo.utils.ServerConnection;
-
-public class CheckTomcatFilePermissions extends Task {
-  static Logger log4j = Logger.getLogger(CheckTomcatFilePermissions.class);
-
-  @Override
-  public void execute() throws BuildException {
-    final File f = new File("src-diagnostics/build.xml");
-    final String fileName = f.getAbsolutePath();
-    log4j.info("Checking tomcat's user file permissions...");
-    final String result = new ServerConnection().getCheck("ant", "&file=" + fileName
-        + "&task=check.permissions");
-    if (result.equals("OK"))
-      log4j.info("Tomcat's user permissions. OK");
-    else
-      throw new BuildException("Tomcat's user do not have read/write permissions in all files");
-  }
-}
--- a/src-diagnostics/src/org/openbravo/task/CheckTomcatMemory.java	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License. 
- * The Original Code is Openbravo ERP. 
- * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008 Openbravo SLU 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-
-package org.openbravo.task;
-
-import org.apache.log4j.Logger;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.openbravo.utils.PropertiesManager;
-import org.openbravo.utils.ServerConnection;
-
-public class CheckTomcatMemory extends Task {
-  static Logger log4j = Logger.getLogger(CheckTomcatMemory.class);
-
-  @Override
-  public void execute() throws BuildException {
-    log4j.info("Checking tomcat's memory...");
-    final long maxCurrentMemory = new Long(new ServerConnection().getCheck("memory"));
-    final long MaxMemory = new Long(new PropertiesManager().getProperty("max.memory"));
-    final String msg = "Current max memory in server:" + maxCurrentMemory + "M, minimum required:"
-        + MaxMemory + "M";
-
-    // check max memory +- 5%, because it is not accurate
-    if (MaxMemory > maxCurrentMemory * 1.05)
-      throw new BuildException(msg
-          + "Tip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#Apache_Tomcat");
-    else {
-      log4j.info(msg);
-      log4j.info("Tomcat's memory OK ");
-    }
-
-  }
-}
--- a/src-diagnostics/src/org/openbravo/task/CheckTomcatVersion.java	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License. 
- * The Original Code is Openbravo ERP. 
- * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008 Openbravo SLU 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-
-package org.openbravo.task;
-
-import org.apache.log4j.Logger;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.openbravo.utils.PropertiesManager;
-import org.openbravo.utils.ServerConnection;
-import org.openbravo.utils.Version;
-
-public class CheckTomcatVersion extends Task {
-
-  static Logger log4j = Logger.getLogger(CheckTomcatVersion.class);
-
-  @Override
-  public void execute() throws BuildException {
-    log4j.info("Checking tomcat version...");
-    final String versionString = new ServerConnection().getCheck("server");
-    if (!versionString.contains("Tomcat"))
-      throw new BuildException("Server seems not to be Tomcat");
-    final String version = Version.getVersion(versionString);
-    final String minVersion = new PropertiesManager().getProperty("tomcat.version");
-    final String msg = "Minimum Tomcat version: " + minVersion + ", current version: " + version;
-    if (Version.compareVersion(version, minVersion) < 0)
-      throw new BuildException(msg
-          + "Tip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#Apache_Tomcat");
-    else {
-      log4j.info(msg);
-      log4j.info("Tomcat version OK");
-    }
-  }
-}
--- a/src-diagnostics/src/org/openbravo/task/CheckX.java	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License. 
- * The Original Code is Openbravo ERP. 
- * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008 Openbravo SLU 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-
-package org.openbravo.task;
-
-import java.io.File;
-
-import org.apache.log4j.Logger;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.openbravo.utils.ServerConnection;
-
-public class CheckX extends Task {
-  static Logger log4j = Logger.getLogger(CheckX.class);
-
-  @Override
-  public void execute() throws BuildException {
-    final File f = new File("src-diagnostics/build.xml");
-    final String fileName = f.getAbsolutePath();
-    log4j.info("Checking tomcat's user has X...");
-    final String result = new ServerConnection().getCheck("ant", "&file=" + fileName
-        + "&task=compile.web");
-    if (result.equals("OK"))
-      log4j.info("Tomcat's user X. OK");
-    else {
-      if (result.contains("X11"))
-        throw new BuildException("Tomcat's user do not have X. Tip try executing xhost+");
-      else
-        throw new BuildException(result);
-    }
-  }
-}
--- a/src-diagnostics/src/org/openbravo/task/CompareVersion.java	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License. 
- * The Original Code is Openbravo ERP. 
- * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008 Openbravo SLU 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-package org.openbravo.task;
-
-import org.apache.log4j.Logger;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.openbravo.utils.Version;
-
-public class CompareVersion extends Task {
-  private String v1;
-  private String v2;
-  static Logger log4j = Logger.getLogger(CompareVersion.class);
-
-  @Override
-  public void execute() throws BuildException {
-    final String msg = "Minimum version " + v2 + " current version " + v1;
-    if (Version.compareVersion(v1, v2) < 0)
-      throw new BuildException(msg);
-    log4j.info(msg);
-  }
-
-  public void setV1(String v1) {
-    this.v1 = v1;
-  }
-
-  public void setV2(String v2) {
-    this.v2 = v2;
-  }
-
-}
--- a/src-diagnostics/src/org/openbravo/utils/PropertiesManager.java	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License. 
- * The Original Code is Openbravo ERP. 
- * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008 Openbravo SLU 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-
-package org.openbravo.utils;
-
-import java.io.FileInputStream;
-import java.util.Properties;
-
-public class PropertiesManager {
-
-  Properties obProperties;
-
-  public PropertiesManager(String propertiesFile) {
-    try {
-      obProperties = new Properties();
-      obProperties.load(new FileInputStream(propertiesFile));
-    } catch (final Exception e) {
-      // do nothing
-    }
-  }
-
-  public PropertiesManager() {
-    this("src-diagnostics/config/diagnostics.properties");
-  }
-
-  public String getProperty(String name) {
-    return obProperties.getProperty(name);
-  }
-}
--- a/src-diagnostics/src/org/openbravo/utils/ServerConnection.java	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License. 
- * The Original Code is Openbravo ERP. 
- * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008 Openbravo SLU 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-
-package org.openbravo.utils;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-public class ServerConnection {
-
-  private URL getUrl(String action, String additionalParameters) throws MalformedURLException {
-    String serverUrl=new PropertiesManager("config/Openbravo.properties").getProperty(
-    "tomcat.manager.url");
-    serverUrl = serverUrl.substring(0,serverUrl.lastIndexOf('/'));
-    return new URL(serverUrl+ "/OpenbravoDiagnostics/Check.html?Command=" + action + additionalParameters);
-  }
-
-  public String getCheck(String action, String additionalParameters) {
-    BufferedReader br = null;
-    BufferedWriter bw = null;
-    try {
-      final HttpURLConnection conn = (HttpURLConnection) getUrl(action, additionalParameters)
-          .openConnection();
-
-      conn.setDoOutput(true);
-
-      bw = new BufferedWriter(new OutputStreamWriter(conn.getOutputStream()));
-      bw.flush();
-      bw.close();
-
-      String s = null;
-      final StringBuilder sb = new StringBuilder();
-      br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
-      while ((s = br.readLine()) != null) {
-        sb.append(s);
-      }
-      br.close();
-      return sb.toString();
-    } catch (final IOException e) {
-      // log4j.error(e.getMessage(), e);
-      // throw e;
-    }
-    return "";
-  }
-
-  public String getCheck(String action) {
-    return getCheck(action, "");
-  }
-}
--- a/src-diagnostics/src/org/openbravo/utils/Version.java	Thu Apr 01 18:22:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License. 
- * The Original Code is Openbravo ERP. 
- * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008 Openbravo SLU 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-
-package org.openbravo.utils;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class Version {
-  public static int compareVersion(String v1, String v2) {
-    if (v1.equals(v2))
-      return 0;
-    final String[] version1 = v1.split("\\.");
-    final String[] version2 = v2.split("\\.");
-    final int minorVers = version1.length > version2.length ? version2.length : version1.length;
-    for (int i = 0; i < minorVers; i++) {
-      if (version1[i].equals(version2[i]))
-        continue;
-      try {
-        return new Integer(version1[i]).compareTo(new Integer(version2[i]));
-      } catch (NumberFormatException e) {
-        //Not possible to compare
-        return -1;
-      }
-    }
-    return 0;
-  }
-
-  public static String getVersion(String str) {
-    String version = "";
-    if (str == null)
-      return "";
-    final Pattern pattern = Pattern.compile("((\\d+\\.)+)\\d+");
-    final Matcher matcher = pattern.matcher(str);
-    if (matcher.find()) {
-      version = matcher.group();
-    }
-    return version;
-  }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/buildvalidation/build.xml	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License 
+ * Version 1.1 (the "License"), being the Mozilla Public License 
+ * version 1.1  with a permitted attribution clause ; you may not use 
+ * this file except in compliance with the License. 
+ * You may obtain a copy of the License at  
+ * http://www.openbravo.com/legal/license.txt 
+ * Software distributed under the License is distributed on an 
+ * "AS IS" basis, WITHOUT WARRANTY OF  ANY KIND, either express or 
+ * implied. See the License for the specific language governing rights 
+ * and  limitations under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SL 
+ * All portions are Copyright (C) 2005-2009 Openbravo SL 
+ * All Rights Reserved. 
+ * Contributor(s): Openbravo S.L.
+ ************************************************************************
+-->
+<!--
+List of targets:
+
+init: creates the needed folders.
+clean: removes all the created files and folders.
+sqlc: generates java files from xsql's files.
+compileSqlc: compile the java files generated from xsql's files.
+compile: compile the java files of the project.
+build.jar: generates the jar file in the lib folder.
+build: compile the project, including the xsql's files and generates the jar and doc.
+doc: generates the api for the project.
+-->
+<project name="openbravo-pre-install" default="compile" basedir=".">
+  <property name="build.pre" value="${basedir}/build/classes" />
+  <property name="build.pre.sqlc" value="${basedir}/build/javasqlc" />
+  <property name="build.pre.src" value="${basedir}/src/" />
+  <property name="main.dir" value="${basedir}/../.." />
+
+  <path id="pre.class.path">
+    <pathelement path="../src-core/build/classes" />
+    <pathelement path="build/classes" />
+    <dirset dir="${base.modules}">
+      <include name="*/build/classes/" />
+    </dirset>
+    <pathelement path="config"/>
+    <fileset dir="${base.lib}">
+      <include name="**/*.jar" />
+    </fileset>
+  </path>
+
+  <condition property="module.not.provided">
+    <equals arg1="${module}" arg2="%" />
+  </condition>
+  <condition property="checkCore">
+    <equals arg1="${module}" arg2="org.openbravo" />
+  </condition>
+  <target name="init">
+    <mkdir dir="${build.pre}" />
+    <mkdir dir="${build.pre.sqlc}" />
+    <mkdir dir="${build.pre.sqlc}/src" />
+    <mkdir dir="${main.dir}/modules/${module}/build/" />
+    <mkdir dir="${main.dir}/modules/${module}/build/javasqlc" />
+    <mkdir dir="${main.dir}/modules/${module}/build/classes" />
+  </target>
+
+  <target name="clean">
+    <delete dir="${build.pre}" failonerror="false" includeemptydirs="true" />
+    <delete dir="${build.pre.sqlc}" failonerror="false" includeemptydirs="true" />
+  </target>
+
+  <target name="sqlc" depends="init">
+    <java classname="org.openbravo.data.Sqlc" jvm="${env.JAVA_HOME}/bin/java" fork="yes" maxmemory="${build.maxmemory}">
+      <arg line="'${base.config}'/Openbravo.properties .xsql ./src/org '${build.pre.sqlc}'" />
+      <classpath refid="pre.class.path" />
+    </java>
+  	
+  	<java classname="org.openbravo.data.Sqlc" jvm="${env.JAVA_HOME}/bin/java" fork="yes" maxmemory="${build.maxmemory}">
+      <arg line="'${base.config}'/Openbravo.properties .xsql '${base.modules}' '${build.pre.sqlc}'/src */src-util/buildvalidation" />
+  	  <classpath refid="pre.class.path" />
+  	</java>
+  </target>
+
+  <target name="compileSqlc" depends="sqlc">
+    <javac srcdir="${build.pre.sqlc}/src" includes="**/*.java" destdir="${build.pre}" encoding="UTF-8" debug="true" debuglevel="lines,vars,source">
+      <classpath refid="pre.class.path" />
+    </javac>
+  </target>
+
+
+  <target name="javacCore" if="checkCore">
+    <javac srcdir="${main.dir}" includes="src-util/buildvalidation/src/**/*.java" destdir="${build.pre}" deprecation="on" encoding="UTF-8" debug="true" debuglevel="lines,vars,source">
+      <classpath refid="pre.class.path" />
+    </javac>
+  </target>
+  <target name="javacModule" unless="checkCore">
+    <javac srcdir="${main.dir}" includes="modules/${module}/src-util/buildvalidation/**/*.java" destdir="${main.dir}/modules/${module}/build/classes" deprecation="on" encoding="UTF-8" debug="true" debuglevel="lines,vars,source">
+      <classpath refid="pre.class.path" />
+    </javac>
+  </target>
+  
+  <target name="compile" depends="checkmodule,compileSqlc,javacCore,javacModule">
+    <copy todir="${build.pre}" encoding="UTF-8">
+      <fileset dir="${build.pre.src}" includes="**/*xml" />
+      <fileset dir="${build.pre.src}" includes="**/*html" />
+    </copy>
+    <copy todir="${build.pre}" encoding="UTF-8">
+      <fileset dir="${base.modules}">
+          <include name="*/src-buildvalidation/**/*" />
+          <exclude name="*/src-buildvalidation/**/*.java" />
+          <exclude name="*/src-buildvalidation/**/*.xsql" />
+      </fileset>
+      <mapper type="regexp" from="(.*\${file.separator}src-buildvalidation/)(.*)" to="\2" />
+    </copy>
+  </target>
+
+  <target name="build.jar">
+    <jar destfile="${build.pre.lib}/openbravo-pre.jar">
+      <fileset dir="${build.pre}" />
+      <manifest>
+        <attribute name="Built-By" value="Openbravo S.L." />
+        <!--section name="common/class1.class">
+        <attribute name="Sealed" value="false"/>
+      </section-->
+      </manifest>
+    </jar>
+  </target>
+
+  <target name="build" depends="compile, build.jar">
+  </target>
+
+  
+  <target name="validate" >
+    <taskdef name="ValidationHandler" classname="org.openbravo.buildvalidation.ValidationHandler" onerror="failall">
+      <classpath refid="pre.class.path" />
+    </taskdef>
+    <ValidationHandler basedir="${base.src}/../" module="${module}" />
+  </target>
+  
+  <target name="checkmodule"  if="module.not.provided">
+    <fail>You need to specify a module</fail>
+  </target>
+  
+</project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/buildvalidation/config/log4j.properties	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,24 @@
+# *************************************************************************
+# * The contents of this file are subject to the Openbravo  Public  License
+# * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+# * Version 1.1  with a permitted attribution clause; you may not  use this
+# * file except in compliance with the License. You  may  obtain  a copy of
+# * the License at http://www.openbravo.com/legal/license.html 
+# * Software distributed under the License  is  distributed  on  an "AS IS"
+# * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+# * License for the specific  language  governing  rights  and  limitations
+# * under the License. 
+# * The Original Code is Openbravo ERP. 
+# * The Initial Developer of the Original Code is Openbravo SL 
+# * All portions are Copyright (C) 2010 Openbravo SL 
+# * All Rights Reserved. 
+# * Contributor(s):  ______________________________________.
+# ************************************************************************
+
+log4j.rootCategory=INFO, C, O2
+log4j.category.org.openbravo=INFO
+log4j.appender.C=org.apache.log4j.ConsoleAppender
+log4j.appender.C.layout=org.apache.log4j.PatternLayout
+
+# Additional Appender used for Improved Upgrade Process
+log4j.appender.O2=org.openbravo.utils.OBRebuildAppender
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/buildvalidation/config/log4j.properties~	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,24 @@
+# *************************************************************************
+# * The contents of this file are subject to the Openbravo  Public  License
+# * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+# * Version 1.1  with a permitted attribution clause; you may not  use this
+# * file except in compliance with the License. You  may  obtain  a copy of
+# * the License at http://www.openbravo.com/legal/license.html 
+# * Software distributed under the License  is  distributed  on  an "AS IS"
+# * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+# * License for the specific  language  governing  rights  and  limitations
+# * under the License. 
+# * The Original Code is Openbravo ERP. 
+# * The Initial Developer of the Original Code is Openbravo SL 
+# * All portions are Copyright (C) 2010 Openbravo SL 
+# * All Rights Reserved. 
+# * Contributor(s):  ______________________________________.
+# ************************************************************************
+
+log4j.rootCategory=INFO, C, O2S
+log4j.category.org.openbravo=INFO
+log4j.appender.C=org.apache.log4j.ConsoleAppender
+log4j.appender.C.layout=org.apache.log4j.PatternLayout
+
+# Additional Appender used for Improved Upgrade Process
+log4j.appender.O2=org.openbravo.utils.OBRebuildAppender
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/buildvalidation/src/org/openbravo/buildvalidation/Cbpvendoracct.java	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,24 @@
+package org.openbravo.buildvalidation;
+
+import java.util.ArrayList;
+
+import org.openbravo.database.ConnectionProvider;
+
+public class Cbpvendoracct extends Validation {
+
+  public ArrayList<String> execute() {
+    ConnectionProvider cp = getConnectionProvider();
+    ArrayList<String> errors = new ArrayList<String>();
+    try {
+      int a=Integer.parseInt(CbpvendoracctData.countNoDistinct(cp));
+      int b=Integer.parseInt(CbpvendoracctData.countDistinct(cp));
+      if(a!=b){
+          errors.add("Error message for Amedios validation (TBD)");
+      }
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+    return errors;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/buildvalidation/src/org/openbravo/buildvalidation/CbpvendoracctData.xsql	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2008-2009 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+-->
+
+
+<SqlClass name="CbpvendoracctData" package="org.openbravo.buildvalidation">
+  <SqlMethod name="countNoDistinct" type="preparedStatement" return="string">
+      <SqlMethodComment></SqlMethodComment>
+      <Sql><![CDATA[
+         SELECT count(*) from (select c_acctschema_id, c_bpartner_id, status from c_bp_vendor_acct) a
+          ]]>
+      </Sql>
+  </SqlMethod>
+  <SqlMethod name="countDistinct" type="preparedStatement" return="string">
+      <SqlMethodComment></SqlMethodComment>
+      <Sql><![CDATA[
+         SELECT count(*) from (select distinct c_acctschema_id, c_bpartner_id, status from c_bp_vendor_acct) a
+          ]]>
+      </Sql>
+  </SqlMethod>
+</SqlClass>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/.classpath	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-1.5.0-sun-1.5.0.11"/>
+	<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v5.5"/>
+	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
+	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
+	<classpathentry kind="output" path="build/classes"/>
+</classpath>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/.project	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>OpenbravoDiagnostics</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.wst.common.project.facet.core.builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.wst.validation.validationbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+		<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+		<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+	</natures>
+</projectDescription>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/.settings/.jsdtscope	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
+		<attributes>
+			<attribute name="hide" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+	<classpathentry kind="output" path=""/>
+</classpath>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/.settings/org.eclipse.jdt.core.prefs	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,7 @@
+#Mon Nov 17 11:09:39 GMT+01:00 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/.settings/org.eclipse.jst.common.project.facet.core.prefs	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,4 @@
+#Mon Nov 17 11:09:40 GMT+01:00 2008
+classpath.helper/org.eclipse.jdt.launching.JRE_CONTAINER\:\:org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType\:\:java-1.5.0-sun-1.5.0.11/owners=jst.java\:5.0
+classpath.helper/org.eclipse.jst.server.core.container\:\:org.eclipse.jst.server.tomcat.runtimeTarget\:\:Apache\ Tomcat\ v5.5/owners=jst.web\:2.4
+eclipse.preferences.version=1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/.settings/org.eclipse.wst.common.component	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+<wb-module deploy-name="OpenbravoDiagnostics">
+<wb-resource deploy-path="/" source-path="/WebContent"/>
+<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
+<property name="context-root" value="OpenbravoDiagnostics"/>
+<property name="java-output-path"/>
+</wb-module>
+</project-modules>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/.settings/org.eclipse.wst.common.project.facet.core.xml	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+  <runtime name="Apache Tomcat v5.5"/>
+  <fixed facet="jst.java"/>
+  <fixed facet="jst.web"/>
+  <installed facet="jst.java" version="5.0"/>
+  <installed facet="jst.web" version="2.4"/>
+  <installed facet="wst.jsdt.web" version="1.0"/>
+</faceted-project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/.settings/org.eclipse.wst.jsdt.ui.superType.container	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/.settings/org.eclipse.wst.jsdt.ui.superType.name	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,1 @@
+Window
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/WebContent/META-INF/MANIFEST.MF	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path: 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/WebContent/WEB-INF/web.xml	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+	<display-name>
+	OpenbravoDiagnostics</display-name>
+
+	  <servlet>
+      <servlet-name>
+        Check
+      </servlet-name>
+      <servlet-class>
+        org.openbravo.check.Check
+      </servlet-class>
+      
+      
+    </servlet>
+	
+	<servlet-mapping>
+      <servlet-name>
+        Check
+      </servlet-name>
+      <url-pattern>
+        /Check.html
+    </url-pattern>
+  </servlet-mapping>
+  
+
+  
+    
+</web-app>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/build-create.xml	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+*************************************************************************
+* The contents of this file are subject to the Openbravo  Public  License
+* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+* Version 1.1  with a permitted attribution clause; you may not  use this
+* file except in compliance with the License. You  may  obtain  a copy of
+* the License at http://www.openbravo.com/legal/license.html
+* Software distributed under the License  is  distributed  on  an "AS IS"
+* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+* License for the specific  language  governing  rights  and  limitations
+* under the License.
+* The Original Code is Openbravo ERP.
+* The Initial Developer of the Original Code is Openbravo SLU
+* All portions are Copyright (C) 2008 Openbravo SLU
+* All Rights Reserved.
+* Contributor(s):  ______________________________________.
+************************************************************************
+-->
+<project name="openbravo-diagnostics-build" basedir="." default="build">
+
+  <path id="diagnostic.class.path">
+    <fileset dir="WebContent/WEB-INF/lib">
+      <include name="**/*.jar" />
+    </fileset>
+  </path>
+
+  <target name="build" depends="clean">
+    <copy todir="WebContent/WEB-INF/lib">
+      <fileset dir="../../lib/runtime">
+        <include name="**/*.jar" />
+      </fileset>
+    </copy>
+    <javac srcdir="src" destdir="build/classes" encoding="UTF-8" debug="true" debuglevel="lines,vars,source" deprecation="on">
+      <classpath refid="diagnostic.class.path" />
+    </javac>
+  </target>
+
+  <target name="clean">
+    <delete failonerror="false">
+      <fileset dir="WebContent/WEB-INF/lib" />
+      <fileset dir="build/classes" />
+    </delete>
+    <mkdir dir="WebContent/WEB-INF/lib" />
+    <mkdir dir="build/classes" />
+    <copy file="../../config/Openbravo.properties" todir="config" failonerror="false" />
+    <copy todir="WebContent/WEB-INF">
+      <fileset dir="config" />
+    </copy>
+  </target>
+
+  <target name="war">
+    <delete failonerror="false" file="lib/OpenbravoDiagnostics.war" />
+    <war compress="true" destfile="OpenbravoDiagnostics.war" encoding="UTF-8" webxml="WebContent/WEB-INF/web.xml">
+      <zipfileset dir="WebContent">
+        <exclude name="**/WEB-INF/web.xml" />
+        <exclude name="**/WEB-INF/lib/servlet-api.jar" />
+      </zipfileset>
+      <classes dir="build/classes" />
+    </war>
+  </target>
+</project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/build.xml	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,227 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+*************************************************************************
+* The contents of this file are subject to the Openbravo  Public  License
+* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+* Version 1.1  with a permitted attribution clause; you may not  use this
+* file except in compliance with the License. You  may  obtain  a copy of
+* the License at http://www.openbravo.com/legal/license.html
+* Software distributed under the License  is  distributed  on  an "AS IS"
+* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+* License for the specific  language  governing  rights  and  limitations
+* under the License.
+* The Original Code is Openbravo ERP.
+* The Initial Developer of the Original Code is Openbravo SLU
+* All portions are Copyright (C) 2008 Openbravo SLU
+* All Rights Reserved.
+* Contributor(s):  ______________________________________.
+************************************************************************
+-->
+<project name="openbravo-diagnostics" basedir="." default="check.all">
+
+  <property file="config/diagnostics.properties" />
+  <property file="config/Openbravo.properties" />
+  <property environment="env" />
+
+  <condition property="context.running">
+    <http url="${tomcat.manager.url}/../OpenbravoDiagnostics/Check.html" />
+  </condition>
+
+  <condition property="isCheckPerms">
+    <and>
+      <os family="unix" />
+      <equals arg1="${chekPerms}" arg2="true" />
+    </and>
+  </condition>
+
+
+
+  <path id="diagnostic.class.path">
+    <pathelement path="build/classes" />
+    <pathelement path="config"/>
+    <fileset dir="WebContent/WEB-INF/lib">
+      <include name="**/*.jar" />
+    </fileset>
+  </path>
+
+
+  <taskdef name="compareVersion" classname="org.openbravo.task.CompareVersion">
+    <classpath refid="diagnostic.class.path" />
+  </taskdef>
+
+  <target name="check.all">
+    <antcall target="check.permissions" />
+    <antcall target="check.properties.configuration" />
+    <antcall target="check.environment.variables" />
+    <antcall target="check.db" />
+    <antcall target="check.ant" />
+    <antcall target="check.tomcat" />
+    <antcall target="undeploy.context" />
+  </target>
+
+  <target name="check.properties.configuration">
+    <antcall target="check.properties" />
+    <antcall target="check.log4j" />
+  </target>
+
+  <target name="check.environment.variables">
+    <taskdef name="checkEnv" classname="org.openbravo.task.CheckEnvironmentVariables">
+      <classpath refid="diagnostic.class.path" />
+    </taskdef>
+    <checkEnv />
+  </target>
+
+  <target name="check.properties">
+    <echo message="Checking for Openbravo.properties file..." />
+    <available file="../../config/Openbravo.properties" property="isProperties" />
+    <fail unless="isProperties" message="Openbravo.properties file not available. Tip: move config/Openbravo.properties.template file to config/Openbravo.properties and configure it" />
+    <echo message="Openbravo.properties file OK" />
+
+    <echo message="Checking for source.path in Openbravo.properties file..." />
+    <condition property="isSourcePath">
+      <and>
+        <isset property="source.path" />
+        <available file="${source.path}" type="dir" />
+      </and>
+    </condition>
+    <fail unless="isSourcePath" message="source.path property is not properly set in Openbravo.properties file" />
+    <echo message="source.path OK" />
+  </target>
+
+  <target name="check.log4j">
+    <echo message="Checking for log4j.lcf file..." />
+    <available file="../../config/log4j.lcf" property="isLog4j" />
+    <fail unless="isLog4j" message="log4j.lcf file not available. Tip: move config/log4j.lcf.template file to config/log4j.lcf and configure it" />
+    <echo message="log4j.lcf file OK" />
+  </target>
+
+  <target name="check.permissions" if="isCheckPerms">
+    <echo message="Checking file permissions for current user, (this will take a while)..." />
+    <exec executable="./check-ob-perms.sh" failonerror="true">
+      <arg value=".." />
+    </exec>
+    <echo message="Permissions OK" />
+  </target>
+
+  <target name="check.ant">
+    <antcall target="check.ant.version" />
+    <antcall target="check.ant.jvm.size" />
+    <antcall target="check.ant.jvm.version" />
+  </target>
+
+  <target name="check.tomcat">
+    <antcall target="deploy.context" />
+
+    <antcall target="check.tomcat.version" />
+    <antcall target="check.tomcat.jvm.size" />
+    <antcall target="check.tomcat.jvm.version" />
+    <antcall target="check.tomcat.ant" />
+    <antcall target="check.tomcat.permissions" />
+  </target>
+
+  <target name="check.db">
+    <taskdef name="checkDB" classname="org.openbravo.task.CheckDB">
+      <classpath refid="diagnostic.class.path" />
+    </taskdef>
+    <checkDB />
+  </target>
+
+  <target name="check.ant.version">
+    <echo message="Checking ant version..." />
+    <echo message="Minimun ${ant.min.version}, current ${ant.version}" />
+    <condition property="antversion">
+      <antversion atleast="${ant.min.version}" />
+    </condition>
+    <fail unless="antversion" message="Minimum ant version: ${ant.min.version}, current version ${ant.version}. Tip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#Apache_Ant" />
+    <echo message="Version OK" />
+  </target>
+
+  <target name="check.ant.jvm.version">
+    <echo message="Checking ant's JVM version..." />
+    <compareVersion v1="${ant.java.version}" v2="${jvm-version}" />
+  </target>
+
+  <target name="check.ant.jvm.size">
+    <taskdef name="checkAntMem" classname="org.openbravo.task.CheckMemory">
+      <classpath refid="diagnostic.class.path" />
+    </taskdef>
+    <checkAntMem />
+  </target>
+
+
+
+  <target name="check.tomcat.version">
+    <taskdef name="checkTomcatVersion" classname="org.openbravo.task.CheckTomcatVersion">
+      <classpath refid="diagnostic.class.path" />
+    </taskdef>
+    <checkTomcatVersion />
+  </target>
+
+  <target name="check.tomcat.jvm.size">
+    <taskdef name="checkMem" classname="org.openbravo.task.CheckTomcatMemory">
+      <classpath refid="diagnostic.class.path" />
+    </taskdef>
+    <checkMem />
+  </target>
+
+  <target name="check.tomcat.jvm.version">
+    <taskdef name="checkJVMversion" classname="org.openbravo.task.CheckJVMVersion">
+      <classpath refid="diagnostic.class.path" />
+    </taskdef>
+    <checkJVMversion />
+  </target>
+
+  <target name="check.tomcat.ant">
+    <taskdef name="checkTomcatAnt" classname="org.openbravo.task.CheckTomcatAntExecution">
+      <classpath refid="diagnostic.class.path" />
+    </taskdef>
+    <checkTomcatAnt />
+  </target>
+
+  <target name="check.tomcat.x">
+    <taskdef name="CheckX" classname="org.openbravo.task.CheckX">
+      <classpath refid="diagnostic.class.path" />
+    </taskdef>
+    <CheckX />
+  </target>
+
+
+  <target name="deploy.context" unless="context.running">
+    <ant antfile="build-create.xml" target="war" />
+    <taskdef name="deploy.war" classname="org.apache.catalina.ant.DeployTask">
+      <classpath refid="diagnostic.class.path" />
+    </taskdef>
+    <taskdef name="start" classname="org.apache.catalina.ant.StartTask">
+      <classpath refid="diagnostic.class.path" />
+    </taskdef>
+
+    <deploy.war url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/OpenbravoDiagnostics" war="file:src-util${file.separator}diagnostic${file.separator}OpenbravoDiagnostics.war" />
+
+    <start url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/OpenbravoDiagnostics" />
+
+
+  </target>
+
+  <target name="check.tomcat.permissions" if="isCheckPerms">
+    <taskdef name="checkTomcatPermissions" classname="org.openbravo.task.CheckTomcatFilePermissions">
+      <classpath refid="diagnostic.class.path" />
+    </taskdef>
+    <checkTomcatPermissions />
+  </target>
+
+  <target name="undeploy.context">
+    <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask">
+      <classpath refid="diagnostic.class.path" />
+    </taskdef>
+    <undeploy url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/OpenbravoDiagnostics" failonerror="false" />
+  </target>
+
+  <target name="test1" description="simple ant task to be called from tomcat">
+    <echo message="testing..." />
+  </target>
+
+  <target name="test2" description="simple compilation task">
+    <delete file="build/classes/Test.class" failonerror="false" />
+    <javac srcdir="src" destdir="build/classes" includes="**/Test*" encoding="UTF-8" debug="true" debuglevel="lines,vars,source" deprecation="on" />
+  </target>
+</project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/check-ob-perms.sh	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,83 @@
+#!/bin/sh
+
+# *************************************************************************
+# * The contents of this file are subject to the Openbravo  Public  License
+# * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+# * Version 1.1  with a permitted attribution clause; you may not  use this
+# * file except in compliance with the License. You  may  obtain  a copy of
+# * the License at http://www.openbravo.com/legal/license.html 
+# * Software distributed under the License  is  distributed  on  an "AS IS"
+# * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+# * License for the specific  language  governing  rights  and  limitations
+# * under the License. 
+# * The Original Code is Openbravo ERP. 
+# * The Initial Developer of the Original Code is Openbravo SLU 
+# * All portions are Copyright (C) 2008 Openbravo SLU 
+# * All Rights Reserved. 
+# * Contributor(s):  ______________________________________.
+# ************************************************************************
+
+
+# Check a user's permissions in a directory
+
+if [ $# -lt 1 ]; then
+  echo "Usage: check-ob-perms.sh directory [username]"
+  exit 1
+elif [ ! -d "$1" ]; then
+  echo "Error: specified directory does not exist: $2"
+  exit 1
+fi
+
+if [ $# -lt 2 ]; then
+  USER=${whoami}
+else
+  USER=$2
+fi
+
+USERID=$(id -u $USER)
+USERGROUPS="$(id -G $USER)"
+DIRFILES=$(find "$1" -printf "%U-%G+%m_%p\n")
+
+# If find fails, there is no read permission or the file does not exist
+if [ $? -eq 1 ]; then
+  echo "Error: user $USER does not have read permissions in some files or directories"
+  exit 1
+fi
+
+IFS='
+'
+
+for FILEDATA in $DIRFILES; do
+  # get part until first -
+  OWNER=${FILEDATA%%-*}
+  # get part until first +, but after -
+  mytemp=${FILEDATA%%+*}
+  GROUP=${mytemp#*-}
+  # get part until first -, but after +
+  mytemp=${FILEDATA%%_*}
+  PERM=${mytemp#*+}
+  # get part after first _
+  FILE=${FILEDATA#*_}
+
+  if [ $USERID -ne $OWNER ]; then
+    
+    # Check if user belongs to the file's group
+    echo $USERGROUPS | grep -q $GROUP
+    [ $? -eq 0 ] && BELONGS=1 || BELONGS=0
+
+    # Significant bit
+    if [ $BELONGS -eq 1 ]; then
+      SBIT=$(echo $PERM | sed 's/.\(.\)./\1/')
+    else
+      SBIT=$(echo $PERM | sed 's/..\(.\)/\1/')
+    fi
+
+    if [ $SBIT -ne 6 ] && [ $SBIT -ne 7 ]; then
+      echo "Error: user $USER does not have read or write permissions in file or directory:"
+      echo "$FILE"
+      exit 1
+    fi
+
+  fi
+
+done
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/config/diagnostics.properties	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,30 @@
+
+# *************************************************************************
+# * The contents of this file are subject to the Openbravo  Public  License
+# * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+# * Version 1.1  with a permitted attribution clause; you may not  use this
+# * file except in compliance with the License. You  may  obtain  a copy of
+# * the License at http://www.openbravo.com/legal/license.html 
+# * Software distributed under the License  is  distributed  on  an "AS IS"
+# * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+# * License for the specific  language  governing  rights  and  limitations
+# * under the License. 
+# * The Original Code is Openbravo ERP. 
+# * The Initial Developer of the Original Code is Openbravo SLU 
+# * All portions are Copyright (C) 2008 Openbravo SLU 
+# * All Rights Reserved. 
+# * Contributor(s):  ______________________________________.
+# ************************************************************************
+
+ant.min.version=1.7.0
+max.memory=512
+jvm-version=1.6
+
+db.ora.version=10
+db.ora.opencursors=3000
+db.ora.processes=150
+
+db.pg.version=8.3.3
+db.pg.windows.version=8.3.5
+
+tomcat.version=5.5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/config/log4j.properties	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,22 @@
+# *************************************************************************
+# * The contents of this file are subject to the Openbravo  Public  License
+# * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+# * Version 1.1  with a permitted attribution clause; you may not  use this
+# * file except in compliance with the License. You  may  obtain  a copy of
+# * the License at http://www.openbravo.com/legal/license.html 
+# * Software distributed under the License  is  distributed  on  an "AS IS"
+# * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+# * License for the specific  language  governing  rights  and  limitations
+# * under the License. 
+# * The Original Code is Openbravo ERP. 
+# * The Initial Developer of the Original Code is Openbravo SLU 
+# * All portions are Copyright (C) 2010 Openbravo SLU 
+# * All Rights Reserved. 
+# * Contributor(s):  ______________________________________.
+# ************************************************************************
+
+log4j.rootCategory=INFO, C
+log4j.category.org.openbravo=INFO
+log4j.appender.C=org.apache.log4j.ConsoleAppender
+log4j.appender.C.layout=org.apache.log4j.PatternLayout
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/src/Test.java	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,29 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2010 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+public class Test {
+
+  /**
+   * Dummy class to test that compilation can be done from Tomcat applications
+   */
+  public static void main(String[] args) {
+
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/src/org/openbravo/check/Check.java	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,81 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2008 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.check;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectHelper;
+
+public class Check extends HttpServlet {
+  private static final long serialVersionUID = 1L;
+
+  @Override
+  protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
+      IOException {
+    final String command = req.getParameter("Command") == null ? "" : req.getParameter("Command");
+
+    final PrintWriter out = resp.getWriter();
+
+    if (command.equals("memory")) {
+      final Runtime runtime = Runtime.getRuntime();
+      final long maxMemory = runtime.maxMemory() / (1024 * 1024); // Memory
+      // in MB
+
+      out.println(maxMemory);
+    } else if (command.equals("jvm-version")) {
+      out.println(System.getProperty("java.runtime.version"));
+    } else if (command.equals("server")) {
+      out.println(req.getSession().getServletContext().getServerInfo());
+    } else if (command.equals("ant")) {
+      final String result = checkAnt(req.getParameter("file"), req.getParameter("task"));
+      out.println(result);
+    } else {
+      out.println("Non-recognized command: " + command);
+    }
+    out.close();
+  }
+
+  private String checkAnt(String file, String task) {
+    final Project project = new Project();
+    System.out.println("task: " + task);
+    try {
+      project.init();
+      ProjectHelper.getProjectHelper().parse(project, new File(file));
+      project.executeTarget(task);
+    } catch (final Exception e) {
+      return e.getMessage();
+    }
+    return "OK";
+  }
+
+  @Override
+  protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
+      IOException {
+    doPost(req, resp);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/src/org/openbravo/task/CheckDB.java	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,239 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2008 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.task;
+
+import java.io.FileInputStream;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.Properties;
+
+import org.apache.log4j.Logger;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.openbravo.utils.PropertiesManager;
+import org.openbravo.utils.Version;
+
+
+public class CheckDB extends Task {
+  static Logger log4j = Logger.getLogger(CheckDB.class);
+
+  @Override
+  public void execute() throws BuildException {
+
+    log4j.info("Checking database...");
+    final Properties properties = new Properties();
+    try {
+      properties.load(new FileInputStream("config/Openbravo.properties"));
+    } catch (final Exception e) {
+      throw new BuildException(e);
+    }
+
+    final String rdbms = properties.getProperty("bbdd.rdbms");
+    final String dbDriver = properties.getProperty("bbdd.driver");
+    String dbServer = properties.getProperty("bbdd.url");
+
+    final String user = properties.getProperty("bbdd.user");
+    final String userPassword = properties.getProperty("bbdd.password");
+
+    final String systemUser = properties.getProperty("bbdd.systemUser");
+    final String systemUserPassword = properties.getProperty("bbdd.systemPassword");
+
+    if (rdbms.equalsIgnoreCase("POSTGRE"))
+      dbServer += "/" + properties.getProperty("bbdd.sid");
+
+    try {
+      Class.forName(dbDriver);
+    } catch (final Exception e) {
+      throw new BuildException(e.getMessage());
+    }
+
+    log4j.info("Trying to connect to db server as standard user.");
+    try {
+      final Connection connUser = DriverManager.getConnection(dbServer, user, userPassword);
+      connUser.close();
+    } catch (final Exception e) {
+      log4j.warn("Couldn't connect to standard user (" + user
+          + ") tip, database might require to be created. Error:" + e.getMessage());
+    }
+    log4j.info("Connection OK");
+
+    log4j.info("Trying to connect to db server as system user.");
+    Connection connSystem = null;
+    try {
+      connSystem = DriverManager.getConnection(dbServer, systemUser, systemUserPassword);
+    } catch (final Exception e) {
+      throw new BuildException(e.getMessage());
+    }
+    log4j.info("Connection OK");
+
+    PreparedStatement st;
+    ResultSet result;
+
+    if (rdbms.equalsIgnoreCase("ORACLE")) {
+      // Check version
+      String versionString = "";
+      log4j.info("Checking Oracle version...");
+      try {
+        st = connSystem.prepareStatement("select * from v$version where banner like '%Oracle%'");
+        result = st.executeQuery();
+        while (result.next()) {
+          versionString = result.getString(1);
+        }
+        result.close();
+        st.close();
+      } catch (final Exception e) {
+        throw new BuildException(e.getMessage());
+      }
+      final String version = Version.getVersion(versionString);
+      final String minVersion = new PropertiesManager().getProperty("db.ora.version");
+      String msg = "Minimum required version: " + minVersion + ", current version " + version;
+      if (Version.compareVersion(version, minVersion) < 0)
+        throw new BuildException(msg
+            + "\nTip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#Oracle");
+      else {
+        log4j.info(msg);
+        log4j.info("Oracle version OK");
+      }
+
+      // check open_cursors
+      log4j.info("Checking Oracle open cursors...");
+      long openCursors = 0;
+      try {
+        st = connSystem
+            .prepareStatement("SELECT value FROM v$parameter WHERE name ='open_cursors'");
+        result = st.executeQuery();
+        while (result.next()) {
+          openCursors = new Long(result.getString(1));
+        }
+        result.close();
+        st.close();
+      } catch (final Exception e) {
+        throw new BuildException(e.getMessage());
+      }
+      final long minOpenCursors = new Long(new PropertiesManager()
+          .getProperty("db.ora.opencursors"));
+      msg = "Minimum open cursors required: " + minOpenCursors + ", current open cursors "
+          + openCursors;
+      if (openCursors < minOpenCursors)
+        throw new BuildException(msg
+            + "\nTip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#Oracle");
+      else {
+        log4j.info(msg);
+        log4j.info("Open cursors OK");
+      }
+
+      // check processes
+      log4j.info("Checking Oracle open cursors...");
+      long processes = 0;
+      try {
+        st = connSystem.prepareStatement("SELECT value FROM v$parameter WHERE name ='processes'");
+        result = st.executeQuery();
+        while (result.next()) {
+          processes = new Long(result.getString(1));
+        }
+        result.close();
+        st.close();
+      } catch (final Exception e) {
+        throw new BuildException(e.getMessage());
+      }
+      final long minProcesses = new Long(new PropertiesManager().getProperty("db.ora.processes"));
+      msg = "Minimum open processes required: " + minProcesses + ", current processes " + processes;
+      if (processes < minProcesses)
+        throw new BuildException(msg
+            + "\nTip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#Oracle");
+      else {
+        log4j.info(msg);
+        log4j.info("Open cursors OK");
+      }
+
+      try {
+        st = connSystem
+            .prepareStatement("select value from nls_database_parameters where parameter='NLS_NCHAR_CHARACTERSET'");
+        result = st.executeQuery();
+        result.next();
+        String nchar_charset = result.getString(1);
+        if (nchar_charset.equals("AL16UTF16"))
+          log4j.info("NCHAR charset encoding OK.");
+        else {
+          throw new BuildException("NCHAR charset encoding incorrect. Current encoding: "
+              + nchar_charset + ". Required encoding: AL16UTF16");
+        }
+        result.close();
+        st.close();
+      } catch (final Exception e) {
+        throw new BuildException(e.getMessage());
+      }
+    } else { // PostgreSQL
+      // Check version
+      log4j.info("Checking PostgreSQL version...");
+      String version = "";
+      try {
+        st = connSystem
+            .prepareStatement("SELECT setting FROM pg_settings WHERE name = 'server_version'");
+
+        result = st.executeQuery();
+
+        while (result.next()) {
+          version = result.getString(1);
+        }
+        result.close();
+        st.close();
+      } catch (final Exception e) {
+        throw new BuildException(e.getMessage());
+      }
+
+      String minVersion = new PropertiesManager().getProperty("db.pg.version");
+      if (System.getProperty("os.name").equalsIgnoreCase("Windows"))
+        minVersion = new PropertiesManager().getProperty("db.pg.windows.version");
+      else
+        minVersion = new PropertiesManager().getProperty("db.pg.version");
+
+      final String msg = "Minimum required version: " + minVersion + ", current version " + version;
+      if (Version.compareVersion(version, minVersion) < 0)
+        throw new BuildException(msg
+            + "\nTip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#PostgreSQL");
+      else {
+        log4j.info(msg);
+        log4j.info("PostgreSQL version OK");
+      }
+
+      // Check contrib
+      log4j.info("Checking PostgreSQL contrib package installed...");
+      try {
+        st = connSystem.prepareStatement("SELECT uuid_generate_v4()");
+        result = st.executeQuery();
+        result.close();
+        st.close();
+      } catch (final Exception e) {
+        throw new BuildException("PostgreSQL contrib package seems not to be installed"
+            + "\nTip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#PostgreSQL");
+      }
+      log4j.info("Contrib package OK");
+
+    }
+    try {
+      connSystem.close();
+    } catch (final Exception e) {
+      throw new BuildException(e.getMessage());
+    }
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/src/org/openbravo/task/CheckEnvironmentVariables.java	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,80 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2008 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.task;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.apache.log4j.Logger;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+/**
+ * Checks whether the required environment variables are set.
+ * 
+ * @author awolski
+ * 
+ */
+public class CheckEnvironmentVariables extends Task {
+
+  static Logger log4j = Logger.getLogger(CheckEnvironmentVariables.class);
+
+  /**
+   * A mapping of the required variables and the message to display if not found.
+   */
+  static Map<String, String> varsToCheck;
+
+  static {
+    varsToCheck = new HashMap<String, String>();
+    varsToCheck.put("CATALINA_HOME", "CATALINA_HOME environment variable is required. "
+        + "Tip: Set a CATALINA_HOME environment variable to the"
+        + " directory where Tomcat is installed.");
+  }
+
+  /**
+   * Verifies that all of the required environment variables are set.
+   */
+  @Override
+  public void execute() throws BuildException {
+    log4j.info("Checking for required environment variables...");
+    String msg = "";
+
+    final Set<Entry<String, String>> vars = varsToCheck.entrySet();
+
+    for (final Entry<String, String> var : vars) {
+      final String name = var.getKey();
+      final String tip = var.getValue();
+
+      final String value = System.getenv(name);
+      if (value == null) {
+        msg += tip + "\n";
+      } else {
+        log4j.info(name + " found: " + value);
+      }
+    }
+    if (!"".equals(msg)) {
+      throw new BuildException(msg);
+    } else {
+      log4j.info("Environment variables OK");
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/src/org/openbravo/task/CheckJVMVersion.java	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,56 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2008 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.task;
+
+import org.apache.log4j.Logger;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.openbravo.utils.PropertiesManager;
+import org.openbravo.utils.ServerConnection;
+import org.openbravo.utils.Version;
+
+public class CheckJVMVersion extends Task {
+  static Logger log4j = Logger.getLogger(CheckJVMVersion.class);
+
+  @Override
+  public void execute() throws BuildException {
+    log4j.info("Checking Tomcat's JVM version...");
+
+    final String jvmVersion = new ServerConnection().getCheck("jvm-version");
+    final String minJvmVersion = new PropertiesManager().getProperty("jvm-version");
+
+    final String msg = "Current Tomcat's JVM version: " + jvmVersion
+        + " minimum required version: " + minJvmVersion;
+
+    if (Version.compareVersion(jvmVersion, minJvmVersion) < 0)
+      throw new BuildException(msg
+          + "\nTip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#Apache_Tomcat");
+    else {
+      log4j.info(msg);
+      log4j.info("Tomcat's JVM version OK");
+    }
+  }
+
+  public static void main(String[] args) {
+    final CheckJVMVersion c = new CheckJVMVersion();
+    c.execute();
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/src/org/openbravo/task/CheckMemory.java	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,51 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2008 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.task;
+
+import org.apache.log4j.Logger;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.openbravo.utils.PropertiesManager;
+
+public class CheckMemory extends Task {
+  static Logger log4j = Logger.getLogger(CheckMemory.class);
+
+  @Override
+  public void execute() throws BuildException {
+    log4j.info("Checking ant's memory...");
+    final Runtime runtime = Runtime.getRuntime();
+    final long maxCurrentMemory = runtime.maxMemory() / (1024 * 1024); // Memory
+    // in
+    // MB
+
+    final long maxMemory = new Long(new PropertiesManager().getProperty("max.memory"));
+    final String msg = "Current max ant's memory:" + maxCurrentMemory + "M, minimum required:"
+        + maxMemory + "M";
+    // check max memory +- 5%, because it is not accurate
+    if (maxMemory > maxCurrentMemory * 1.05)
+      throw new BuildException(msg
+          + "\nTip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#Apache_Ant");
+    else {
+      log4j.info(msg);
+      log4j.info("Ant's memory OK ");
+    }
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/src/org/openbravo/task/CheckTomcatAntExecution.java	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,52 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2008 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.task;
+
+import java.io.File;
+
+import org.apache.log4j.Logger;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.openbravo.utils.ServerConnection;
+
+public class CheckTomcatAntExecution extends Task {
+  static Logger log4j = Logger.getLogger(CheckTomcatAntExecution.class);
+
+  @Override
+  public void execute() throws BuildException {
+    final File f = new File("src-diagnostics/build.xml");
+    final String fileName = f.getAbsolutePath().replace("\\", "/");
+    System.out.println(fileName);
+    log4j.info("Checking tomcat executing ant tasks...");
+    String result = new ServerConnection().getCheck("ant", "&file=" + fileName + "&task=test1");
+    if (result.equals("OK"))
+      log4j.info("Possible to execute simple tasks. OK");
+    else
+      throw new BuildException("Tomcat cannot execute simple ant tasks: " + result);
+
+    result = new ServerConnection().getCheck("ant", "&file=" + fileName + "&task=test2");
+    if (result.equals("OK"))
+      log4j.info("Possible to execute ant javac task. OK");
+    else
+      throw new BuildException("Tomcat cannot execute ant javac task: " + result
+          + "Tip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#Apache_Tomcat");
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/src/org/openbravo/task/CheckTomcatFilePermissions.java	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,44 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2008 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.task;
+
+import java.io.File;
+
+import org.apache.log4j.Logger;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.openbravo.utils.ServerConnection;
+
+public class CheckTomcatFilePermissions extends Task {
+  static Logger log4j = Logger.getLogger(CheckTomcatFilePermissions.class);
+
+  @Override
+  public void execute() throws BuildException {
+    final File f = new File("src-diagnostics/build.xml");
+    final String fileName = f.getAbsolutePath();
+    log4j.info("Checking tomcat's user file permissions...");
+    final String result = new ServerConnection().getCheck("ant", "&file=" + fileName
+        + "&task=check.permissions");
+    if (result.equals("OK"))
+      log4j.info("Tomcat's user permissions. OK");
+    else
+      throw new BuildException("Tomcat's user do not have read/write permissions in all files");
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/src/org/openbravo/task/CheckTomcatMemory.java	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,49 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2008 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.task;
+
+import org.apache.log4j.Logger;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.openbravo.utils.PropertiesManager;
+import org.openbravo.utils.ServerConnection;
+
+public class CheckTomcatMemory extends Task {
+  static Logger log4j = Logger.getLogger(CheckTomcatMemory.class);
+
+  @Override
+  public void execute() throws BuildException {
+    log4j.info("Checking tomcat's memory...");
+    final long maxCurrentMemory = new Long(new ServerConnection().getCheck("memory"));
+    final long MaxMemory = new Long(new PropertiesManager().getProperty("max.memory"));
+    final String msg = "Current max memory in server:" + maxCurrentMemory + "M, minimum required:"
+        + MaxMemory + "M";
+
+    // check max memory +- 5%, because it is not accurate
+    if (MaxMemory > maxCurrentMemory * 1.05)
+      throw new BuildException(msg
+          + "Tip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#Apache_Tomcat");
+    else {
+      log4j.info(msg);
+      log4j.info("Tomcat's memory OK ");
+    }
+
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/src/org/openbravo/task/CheckTomcatVersion.java	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,50 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2008 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.task;
+
+import org.apache.log4j.Logger;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.openbravo.utils.PropertiesManager;
+import org.openbravo.utils.ServerConnection;
+import org.openbravo.utils.Version;
+
+public class CheckTomcatVersion extends Task {
+
+  static Logger log4j = Logger.getLogger(CheckTomcatVersion.class);
+
+  @Override
+  public void execute() throws BuildException {
+    log4j.info("Checking tomcat version...");
+    final String versionString = new ServerConnection().getCheck("server");
+    if (!versionString.contains("Tomcat"))
+      throw new BuildException("Server seems not to be Tomcat");
+    final String version = Version.getVersion(versionString);
+    final String minVersion = new PropertiesManager().getProperty("tomcat.version");
+    final String msg = "Minimum Tomcat version: " + minVersion + ", current version: " + version;
+    if (Version.compareVersion(version, minVersion) < 0)
+      throw new BuildException(msg
+          + "Tip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#Apache_Tomcat");
+    else {
+      log4j.info(msg);
+      log4j.info("Tomcat version OK");
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/src/org/openbravo/task/CheckX.java	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,48 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2008 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.task;
+
+import java.io.File;
+
+import org.apache.log4j.Logger;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.openbravo.utils.ServerConnection;
+
+public class CheckX extends Task {
+  static Logger log4j = Logger.getLogger(CheckX.class);
+
+  @Override
+  public void execute() throws BuildException {
+    final File f = new File("src-diagnostics/build.xml");
+    final String fileName = f.getAbsolutePath();
+    log4j.info("Checking tomcat's user has X...");
+    final String result = new ServerConnection().getCheck("ant", "&file=" + fileName
+        + "&task=compile.web");
+    if (result.equals("OK"))
+      log4j.info("Tomcat's user X. OK");
+    else {
+      if (result.contains("X11"))
+        throw new BuildException("Tomcat's user do not have X. Tip try executing xhost+");
+      else
+        throw new BuildException(result);
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/src/org/openbravo/task/CompareVersion.java	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,47 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2008 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.task;
+
+import org.apache.log4j.Logger;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.openbravo.utils.Version;
+
+public class CompareVersion extends Task {
+  private String v1;
+  private String v2;
+  static Logger log4j = Logger.getLogger(CompareVersion.class);
+
+  @Override
+  public void execute() throws BuildException {
+    final String msg = "Minimum version " + v2 + " current version " + v1;
+    if (Version.compareVersion(v1, v2) < 0)
+      throw new BuildException(msg);
+    log4j.info(msg);
+  }
+
+  public void setV1(String v1) {
+    this.v1 = v1;
+  }
+
+  public void setV2(String v2) {
+    this.v2 = v2;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/src/org/openbravo/utils/PropertiesManager.java	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,45 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2008 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.utils;
+
+import java.io.FileInputStream;
+import java.util.Properties;
+
+public class PropertiesManager {
+
+  Properties obProperties;
+
+  public PropertiesManager(String propertiesFile) {
+    try {
+      obProperties = new Properties();
+      obProperties.load(new FileInputStream(propertiesFile));
+    } catch (final Exception e) {
+      // do nothing
+    }
+  }
+
+  public PropertiesManager() {
+    this("src-util/diagnostic/config/diagnostics.properties");
+  }
+
+  public String getProperty(String name) {
+    return obProperties.getProperty(name);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/src/org/openbravo/utils/ServerConnection.java	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,71 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2008 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.utils;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+public class ServerConnection {
+
+  private URL getUrl(String action, String additionalParameters) throws MalformedURLException {
+    String serverUrl=new PropertiesManager("config/Openbravo.properties").getProperty(
+    "tomcat.manager.url");
+    serverUrl = serverUrl.substring(0,serverUrl.lastIndexOf('/'));
+    return new URL(serverUrl+ "/OpenbravoDiagnostics/Check.html?Command=" + action + additionalParameters);
+  }
+
+  public String getCheck(String action, String additionalParameters) {
+    BufferedReader br = null;
+    BufferedWriter bw = null;
+    try {
+      final HttpURLConnection conn = (HttpURLConnection) getUrl(action, additionalParameters)
+          .openConnection();
+
+      conn.setDoOutput(true);
+
+      bw = new BufferedWriter(new OutputStreamWriter(conn.getOutputStream()));
+      bw.flush();
+      bw.close();
+
+      String s = null;
+      final StringBuilder sb = new StringBuilder();
+      br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+      while ((s = br.readLine()) != null) {
+        sb.append(s);
+      }
+      br.close();
+      return sb.toString();
+    } catch (final IOException e) {
+      // log4j.error(e.getMessage(), e);
+      // throw e;
+    }
+    return "";
+  }
+
+  public String getCheck(String action) {
+    return getCheck(action, "");
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/diagnostic/src/org/openbravo/utils/Version.java	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,56 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2008 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.utils;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class Version {
+  public static int compareVersion(String v1, String v2) {
+    if (v1.equals(v2))
+      return 0;
+    final String[] version1 = v1.split("\\.");
+    final String[] version2 = v2.split("\\.");
+    final int minorVers = version1.length > version2.length ? version2.length : version1.length;
+    for (int i = 0; i < minorVers; i++) {
+      if (version1[i].equals(version2[i]))
+        continue;
+      try {
+        return new Integer(version1[i]).compareTo(new Integer(version2[i]));
+      } catch (NumberFormatException e) {
+        //Not possible to compare
+        return -1;
+      }
+    }
+    return 0;
+  }
+
+  public static String getVersion(String str) {
+    String version = "";
+    if (str == null)
+      return "";
+    final Pattern pattern = Pattern.compile("((\\d+\\.)+)\\d+");
+    final Matcher matcher = pattern.matcher(str);
+    if (matcher.find()) {
+      version = matcher.group();
+    }
+    return version;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/modulescript/build.xml	Tue Mar 30 13:18:54 2010 +0200
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License 
+ * Version 1.1 (the "License"), being the Mozilla Public License 
+ * version 1.1  with a permitted attribution clause ; you may not use 
+ * this file except in compliance with the License. 
+ * You may obtain a copy of the License at  
+ * http://www.openbravo.com/legal/license.txt 
+ * Software distributed under the License is distributed on an 
+ * "AS IS" basis, WITHOUT WARRANTY OF  ANY KIND, either express or 
+ * implied. See the License for the specific language governing rights 
+ * and  limitations under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SL 
+ * All portions are Copyright (C) 2005-2009 Openbravo SL 
+ * All Rights Reserved. 
+ * Contributor(s): Openbravo S.L.
+ ************************************************************************
+-->
+<!--
+List of targets:
+
+init: creates the needed folders.
+clean: removes all the created files and folders.
+sqlc: generates java files from xsql's files.
+compileSqlc: compile the java files generated from xsql's files.
+compile: compile the java files of the project.
+build.jar: generates the jar file in the lib folder.
+build: compile the project, including the xsql's files and generates the jar and doc.
+doc: generates the api for the project.
+-->
+<project name="openbravo-pre-install" default="compile" basedir=".">
+  <property name="build.pre" value="${basedir}/build/classes" />
+  <property name="build.pre.sqlc" value="${basedir}/build/javasqlc" />
+  <property name="build.pre.src" value="${basedir}/src/" />
+  <property name="main.dir" value="${basedir}/../.." />
+
+  <path id="pre.class.path">
+    <pathelement path="../src-core/build/classes" />
+    <pathelement path="build/classes" />
+    <dirset dir="${base.modules}">
+      <include name="*/build/classes/" />
+    </dirset>
+    <pathelement path="config"/>
+    <fileset dir="${base.lib}">
+      <include name="**/*.jar" />
+    </fileset>
+  </path>
+
+  <condition property="module.not.provided">
+    <equals arg1="${module}" arg2="%" />
+  </condition>
+  <condition property="checkCore">
+    <equals arg1="${module}" arg2="org.openbravo" />
+  </condition>
+  <target name="init">
+    <mkdir dir="${build.pre}" />
+    <mkdir dir="${build.pre.sqlc}" />
+    <mkdir dir="${build.pre.sqlc}/src" />
+    <mkdir dir="${main.dir}/modules/${module}/build/" />
+    <mkdir dir="${main.dir}/modules/${module}/build/javasqlc" />
+    <mkdir dir="${main.dir}/modules/${module}/build/classes" />
+  </target>
+
+  <target name="clean">
+    <delete dir="${build.pre}" failonerror="false" includeemptydirs="true" />
+    <delete dir="${build.pre.sqlc}" failonerror="false" includeemptydirs="true" />
+  </target>
+
+  <target name="sqlc" depends="init">
+    <java classname="org.openbravo.data.Sqlc" jvm="${env.JAVA_HOME}/bin/java" fork="yes" maxmemory="${build.maxmemory}">
+      <arg line="'${base.config}'/Openbravo.properties .xsql ./src/org '${build.pre.sqlc}'" />
+      <classpath refid="pre.class.path" />
+    </java>
+  	
+  	<java classname="org.openbravo.data.Sqlc" jvm="${env.JAVA_HOME}/bin/java" fork="yes" maxmemory="${build.maxmemory}">
+      <arg line="'${base.config}'/Openbravo.properties .xsql '${base.modules}' '${build.pre.sqlc}'/src */src-util/modulescript" />
+  	  <classpath refid="pre.class.path" />
+  	</java>
+  </target>
+
+  <target name="compileSqlc" depends="sqlc">
+    <javac srcdir="${build.pre.sqlc}/src" includes="**/*.java" destdir="${build.pre}" encoding="UTF-8" debug="true" debuglevel="lines,vars,source">
+      <classpath refid="pre.class.path" />
+    </javac>
+  </target>
+
+
+  <target name="javacCore" if="checkCore">
+    <javac srcdir="${main.dir}" includes="src-util/modulescript/src/**/*.java" destdir="${build.pre}" deprecation="on" encoding="UTF-8" debug="true" debuglevel="lines,vars,source">
+      <classpath refid="pre.class.path" />
+    </javac>
+  </target>
+  <target name="javacModule" unless="checkCore">
+    <javac srcdir="${main.dir}" includes="modules/${module}/src-util/modulescript/**/*.java" destdir="${main.dir}/modules/${module}/build/classes" deprecation="on" encoding="UTF-8" debug="true" debuglevel="lines,vars,source">
+      <classpath refid="pre.class.path" />
+    </javac>
+  </target>
+  
+  <target name="compile" depends="checkmodule,compileSqlc,javacCore,javacModule">
+    <copy todir="${build.pre}" encoding="UTF-8">
+      <fileset dir="${build.pre.src}" includes="**/*xml" />
+      <fileset dir="${build.pre.src}" includes="**/*html" />
+    </copy>
+    <copy todir="${build.pre}" encoding="UTF-8">
+      <fileset dir="${base.modules}">
+          <include name="*/src-modulescript/**/*" />
+          <exclude name="*/src-modulescript/**/*.java" />
+          <exclude name="*/src-modulescript/**/*.xsql" />
+      </fileset>
+      <mapper type="regexp" from="(.*\${file.separator}src-modulescript/)(.*)" to="\2" />
+    </copy>
+  </target>
+
+  <target name="build.jar">
+    <jar destfile="${build.pre.lib}/openbravo-pre.jar">
+      <fileset dir="${build.pre}" />
+      <manifest>
+        <attribute name="Built-By" value="Openbravo S.L." />
+        <!--section name="common/class1.class">
+        <attribute name="Sealed" value="false"/>
+      </section-->
+      </manifest>
+    </jar>
+  </target>
+
+  <target name="build" depends="compile, build.jar">
+  </target>
+
+  
+  <target name="checkmodule"  if="module.not.provided">
+    <fail>You need to specify a module</fail>
+  </target>
+  
+</project>
--- a/src/build.xml	Thu Apr 01 18:22:18 2010 +0200
+++ b/src/build.xml	Tue Mar 30 13:18:54 2010 +0200
@@ -307,7 +307,7 @@
   
   <target name="compileSqlc" depends="sqlc">
     <updatesystemstatus v="RB43"/>
-    <javac  srcdir="${basedir}:${build.sqlc}/src:${build.sqlc}/srcAD:${base.src.test}:${base.modules}" excludes="${base.modules}/src-wad/**" destdir="${build}" encoding="UTF-8" fork="true" memorymaximumsize="${build.maxmemory}" debug="true" debuglevel="lines,vars,source" deprecation="on">
+    <javac  srcdir="${basedir}:${build.sqlc}/src:${build.sqlc}/srcAD:${base.src.test}:${base.modules}" excludes="${base.modules}/*/src-wad/**,${base.modules}/*/src-util/**" destdir="${build}" encoding="UTF-8" fork="true" memorymaximumsize="${build.maxmemory}" debug="true" debuglevel="lines,vars,source" deprecation="on">
       <classpath refid="project.class.path" />
     </javac>
     
--- a/src/org/openbravo/erpCommon/ad_process/ApplyModulesCallServlet.java	Thu Apr 01 18:22:18 2010 +0200
+++ b/src/org/openbravo/erpCommon/ad_process/ApplyModulesCallServlet.java	Tue Mar 30 13:18:54 2010 +0200
@@ -150,7 +150,6 @@
 
   private ApplyModulesResponse fillErrorResponse(VariablesSecureApp vars, String state,
       String defaultState) {
-
     ApplyModulesResponse resp = new ApplyModulesResponse();
     resp.setState(Integer.parseInt(state.replace("RB", "")));
     PreparedStatement ps2 = null;
@@ -158,18 +157,18 @@
     boolean warning = false;
     boolean error = false;
     try {
-      ps2 = getPreparedStatement("SELECT MESSAGE, SYSTEM_STATUS LINE_NUMBER FROM AD_ERROR_LOG WHERE ERROR_LEVEL='ERROR' ORDER BY CREATED DESC");
+      ps2 = getPreparedStatement("SELECT MESSAGE, SYSTEM_STATUS LINE_NUMBER FROM AD_ERROR_LOG WHERE ERROR_LEVEL='ERROR' ORDER BY CREATED ");
       ps2.executeQuery();
       ResultSet rs2 = ps2.getResultSet();
       ArrayList<String> errors = new ArrayList<String>();
-      if (rs2.next()) {
+      while (rs2.next()) {
         error = true; // there is at least an error in this state
         errors.add(rs2.getString(1));
         resp.setState(Integer.parseInt(rs2.getString(2).replace("RB", "")));
       }
       resp.setErrors(errors.toArray(new String[0]));
 
-      ps3 = getPreparedStatement("SELECT MESSAGE FROM AD_ERROR_LOG ORDER BY CREATED DESC");
+      ps3 = getPreparedStatement("SELECT MESSAGE FROM AD_ERROR_LOG ORDER BY CREATED ");
       ps3.executeQuery();
       ResultSet rs3 = ps3.getResultSet();
       if (rs3.next()) {