diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..94afd65cc
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+/wpsg-xml/target/
+/52n-wps-io/target/
+/52n-wps-server/target/
+/52n-wps-webapp/target/
\ No newline at end of file
diff --git a/52n-wps-ags/.gitignore b/52n-wps-ags/.gitignore
new file mode 100644
index 000000000..ea8c4bf7f
--- /dev/null
+++ b/52n-wps-ags/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/52n-wps-ags/.settings/org.eclipse.core.resources.prefs b/52n-wps-ags/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 000000000..24e56b874
--- /dev/null
+++ b/52n-wps-ags/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding//src/main/java=ISO-8859-1
diff --git a/52n-wps-ags/.settings/org.eclipse.jdt.core.prefs b/52n-wps-ags/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..69c31cd49
--- /dev/null
+++ b/52n-wps-ags/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/52n-wps-ags/.settings/org.eclipse.m2e.core.prefs b/52n-wps-ags/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 000000000..f897a7f1c
--- /dev/null
+++ b/52n-wps-ags/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/52n-wps-ags/.settings/org.eclipse.wst.common.component b/52n-wps-ags/.settings/org.eclipse.wst.common.component
new file mode 100644
index 000000000..0d230fe79
--- /dev/null
+++ b/52n-wps-ags/.settings/org.eclipse.wst.common.component
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/52n-wps-ags/.settings/org.eclipse.wst.common.project.facet.core.xml b/52n-wps-ags/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 000000000..c78d9323f
--- /dev/null
+++ b/52n-wps-ags/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/52n-wps-ags/.settings/org.eclipse.wst.validation.prefs b/52n-wps-ags/.settings/org.eclipse.wst.validation.prefs
new file mode 100644
index 000000000..04cad8cb7
--- /dev/null
+++ b/52n-wps-ags/.settings/org.eclipse.wst.validation.prefs
@@ -0,0 +1,2 @@
+disabled=06target
+eclipse.preferences.version=1
diff --git a/52n-wps-ags/pom.xml b/52n-wps-ags/pom.xml
index 4a42cf237..a4158945a 100644
--- a/52n-wps-ags/pom.xml
+++ b/52n-wps-ags/pom.xml
@@ -61,6 +61,16 @@
org.n52.wps
52n-wps-server
${project.version}
+
+
+ servlet-api
+ javax.servlet
+
+
+ servlet-api-2.5
+ org.mortbay.jetty
+
+
diff --git a/52n-wps-client-lib/.gitignore b/52n-wps-client-lib/.gitignore
new file mode 100644
index 000000000..ea8c4bf7f
--- /dev/null
+++ b/52n-wps-client-lib/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/52n-wps-client-lib/.settings/org.eclipse.core.resources.prefs b/52n-wps-client-lib/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 000000000..24e56b874
--- /dev/null
+++ b/52n-wps-client-lib/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding//src/main/java=ISO-8859-1
diff --git a/52n-wps-client-lib/.settings/org.eclipse.jdt.core.prefs b/52n-wps-client-lib/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..60105c1b9
--- /dev/null
+++ b/52n-wps-client-lib/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/52n-wps-client-lib/.settings/org.eclipse.m2e.core.prefs b/52n-wps-client-lib/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 000000000..f897a7f1c
--- /dev/null
+++ b/52n-wps-client-lib/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/52n-wps-client-lib/pom.xml b/52n-wps-client-lib/pom.xml
index 8838b5942..64cc90e50 100644
--- a/52n-wps-client-lib/pom.xml
+++ b/52n-wps-client-lib/pom.xml
@@ -41,7 +41,7 @@
be.spacebel.wps
wpsg-xml
- 1.0.0
+ 2.0.3
diff --git a/52n-wps-commons/.gitignore b/52n-wps-commons/.gitignore
new file mode 100644
index 000000000..ea8c4bf7f
--- /dev/null
+++ b/52n-wps-commons/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/52n-wps-commons/.settings/org.eclipse.core.resources.prefs b/52n-wps-commons/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 000000000..24e56b874
--- /dev/null
+++ b/52n-wps-commons/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding//src/main/java=ISO-8859-1
diff --git a/52n-wps-commons/.settings/org.eclipse.jdt.core.prefs b/52n-wps-commons/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..69c31cd49
--- /dev/null
+++ b/52n-wps-commons/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/52n-wps-commons/.settings/org.eclipse.m2e.core.prefs b/52n-wps-commons/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 000000000..f897a7f1c
--- /dev/null
+++ b/52n-wps-commons/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/52n-wps-commons/.settings/org.eclipse.wst.common.component b/52n-wps-commons/.settings/org.eclipse.wst.common.component
new file mode 100644
index 000000000..ee871acab
--- /dev/null
+++ b/52n-wps-commons/.settings/org.eclipse.wst.common.component
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/52n-wps-commons/.settings/org.eclipse.wst.common.project.facet.core.xml b/52n-wps-commons/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 000000000..c78d9323f
--- /dev/null
+++ b/52n-wps-commons/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/52n-wps-commons/.settings/org.eclipse.wst.validation.prefs b/52n-wps-commons/.settings/org.eclipse.wst.validation.prefs
new file mode 100644
index 000000000..04cad8cb7
--- /dev/null
+++ b/52n-wps-commons/.settings/org.eclipse.wst.validation.prefs
@@ -0,0 +1,2 @@
+disabled=06target
+eclipse.preferences.version=1
diff --git a/52n-wps-grass/.gitignore b/52n-wps-grass/.gitignore
new file mode 100644
index 000000000..ea8c4bf7f
--- /dev/null
+++ b/52n-wps-grass/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/52n-wps-grass/.settings/org.eclipse.core.resources.prefs b/52n-wps-grass/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 000000000..24e56b874
--- /dev/null
+++ b/52n-wps-grass/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding//src/main/java=ISO-8859-1
diff --git a/52n-wps-grass/.settings/org.eclipse.jdt.core.prefs b/52n-wps-grass/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..69c31cd49
--- /dev/null
+++ b/52n-wps-grass/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/52n-wps-grass/.settings/org.eclipse.m2e.core.prefs b/52n-wps-grass/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 000000000..f897a7f1c
--- /dev/null
+++ b/52n-wps-grass/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/52n-wps-grass/.settings/org.eclipse.wst.common.component b/52n-wps-grass/.settings/org.eclipse.wst.common.component
new file mode 100644
index 000000000..49125cf5c
--- /dev/null
+++ b/52n-wps-grass/.settings/org.eclipse.wst.common.component
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/52n-wps-grass/.settings/org.eclipse.wst.common.project.facet.core.xml b/52n-wps-grass/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 000000000..c78d9323f
--- /dev/null
+++ b/52n-wps-grass/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/52n-wps-grass/.settings/org.eclipse.wst.validation.prefs b/52n-wps-grass/.settings/org.eclipse.wst.validation.prefs
new file mode 100644
index 000000000..04cad8cb7
--- /dev/null
+++ b/52n-wps-grass/.settings/org.eclipse.wst.validation.prefs
@@ -0,0 +1,2 @@
+disabled=06target
+eclipse.preferences.version=1
diff --git a/52n-wps-grass/pom.xml b/52n-wps-grass/pom.xml
index bdd6ff1fb..45156e27e 100644
--- a/52n-wps-grass/pom.xml
+++ b/52n-wps-grass/pom.xml
@@ -57,7 +57,7 @@
be.spacebel.wps
wpsg-xml
- 1.0.0
+ 2.0.3
tomcat
@@ -100,45 +100,6 @@
axiom-api
1.2.8
-
- org.apache.rampart
- rampart-policy
- 1.4
-
-
- xmlbeans
- xbean
-
-
- org.apache.ant
- ant-nodeps
-
-
- opensaml
- opensaml
-
-
-
-
- org.apache.rampart
- rampart-core
- 1.4
-
-
- xmlbeans
- xbean
-
-
- opensaml
- opensaml
-
-
- org.apache.ant
- ant-nodeps
-
-
-
-
xerces
xercesImpl
diff --git a/52n-wps-gridgain/pom.xml b/52n-wps-gridgain/pom.xml
deleted file mode 100644
index b0cea9673..000000000
--- a/52n-wps-gridgain/pom.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
- org.n52.wps
- 52n-wps-parent
- 2.0-RC8-SNAPSHOT
-
- 4.0.0
- 52n-wps-gridgain
- 52north 52n-wps-gridgain
- The project 52 north 52n-wps-grid does something with
- JAVA.
-
-
- gridgain-site
- http://www.gridgainsystems.com/maven2
-
-
-
-
-
-
-
-
- ${project.groupId}
- 52n-wps-commons
-
-
- ${project.groupId}
- 52n-wps-io
-
-
- ${project.groupId}
- 52n-wps-server
-
-
- ${project.groupId}
- 52n-wps-unicore
- ${project.version}
-
-
- be.spacebel.wps
- wpsg-xml
- 1.0.0
-
-
-
-
-
- org.gridgain
- gridgain
- 2.1.1
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
- 1.5
- 1.5
-
-
-
-
-
\ No newline at end of file
diff --git a/52n-wps-gridgain/src/main/java/org/n52/wps/gridgain/AbstractGridGainAlgorithm.java b/52n-wps-gridgain/src/main/java/org/n52/wps/gridgain/AbstractGridGainAlgorithm.java
deleted file mode 100644
index 601baaf12..000000000
--- a/52n-wps-gridgain/src/main/java/org/n52/wps/gridgain/AbstractGridGainAlgorithm.java
+++ /dev/null
@@ -1,83 +0,0 @@
-
-package org.n52.wps.gridgain;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-import org.gridgain.grid.Grid;
-import org.gridgain.grid.GridException;
-import org.gridgain.grid.GridFactory;
-import org.gridgain.grid.GridTaskFuture;
-import org.n52.wps.gridgain.client.GridGainTask;
-import org.n52.wps.io.data.IData;
-import org.n52.wps.server.AbstractObservableAlgorithm;
-import org.n52.wps.server.IAlgorithm;
-import org.n52.wps.unicore.UnicoreAlgorithmInput;
-import org.n52.wps.unicore.UnicoreAlgorithmOutput;
-
-public abstract class AbstractGridGainAlgorithm extends AbstractObservableAlgorithm implements IGridGainAlgorithm
-{
- private static Logger LOGGER = Logger.getLogger(AbstractGridGainAlgorithm.class);
-
- protected IAlgorithm embeddedAlgorithm;
-
- public IAlgorithm getEmbeddedAlgorithm()
- {
- return embeddedAlgorithm;
- }
-
- public AbstractGridGainAlgorithm(IAlgorithm pEmbeddedAlgorithm)
- {
- super();
- this.embeddedAlgorithm = pEmbeddedAlgorithm;
- }
-
- public AbstractGridGainAlgorithm(String wellKnownName, IAlgorithm pEmbeddedAlgorithm)
- {
- super(wellKnownName);
- this.embeddedAlgorithm = pEmbeddedAlgorithm;
- }
-
- public List getErrors()
- {
- return embeddedAlgorithm.getErrors();
- }
-
- public Class getInputDataType(String id)
- {
- return embeddedAlgorithm.getInputDataType(id);
- }
-
- public Class getOutputDataType(String id)
- {
- return embeddedAlgorithm.getOutputDataType(id);
- }
-
- public Map run(Map> pInputData)
- {
- UnicoreAlgorithmOutput algorithmOutput;
-
- try
- {
- UnicoreAlgorithmInput algorithmInput = new UnicoreAlgorithmInput(pInputData, embeddedAlgorithm.getDescription().getIdentifier().getStringValue());
-
- GridFactory.start();
- Grid grid = GridFactory.getGrid();
- GridTaskFuture future = grid.execute(GridGainTask.class, algorithmInput);
-
- algorithmOutput = future.get();
- }
- catch (GridException e)
- {
- LOGGER.error(e);
- throw new RuntimeException(e);
- }
- finally
- {
- GridFactory.stop(true);
- }
-
- return algorithmOutput.getData();
- }
-}
diff --git a/52n-wps-gridgain/src/main/java/org/n52/wps/gridgain/GridGainAlgorithmRepository.java b/52n-wps-gridgain/src/main/java/org/n52/wps/gridgain/GridGainAlgorithmRepository.java
deleted file mode 100644
index f12a841ca..000000000
--- a/52n-wps-gridgain/src/main/java/org/n52/wps/gridgain/GridGainAlgorithmRepository.java
+++ /dev/null
@@ -1,272 +0,0 @@
-
-package org.n52.wps.gridgain;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import net.opengis.wps.x100.ProcessDescriptionType;
-
-import org.apache.log4j.Logger;
-import org.n52.wps.PropertyDocument.Property;
-import org.n52.wps.commons.WPSConfig;
-import org.n52.wps.server.IAlgorithm;
-import org.n52.wps.server.repository.IAlgorithmRepository;
-import org.n52.wps.server.request.ExecuteRequest;
-import org.n52.wps.unicore.IUnicoreAlgorithm;
-import org.n52.wps.unicore.UnicoreAlgorithmRepository;
-
-public class GridGainAlgorithmRepository implements IAlgorithmRepository
-{
- private static Logger LOGGER = Logger.getLogger(GridGainAlgorithmRepository.class);
-
-// public static String CFG_REGISTRY = "Registry";
-// public static String CFG_KEYSTORE = "Keystore";
-// public static String CFG_ALIAS = "Alias";
-// public static String CFG_PASSWORD = "Password";
-// public static String CFG_TYPE = "Type";
-//
-// public static String CFG_OVERWRITE = "OverwriteRemoteFile";
-// public static String CFG_COMPRESSION = "CompressInputData";
-
- private static GridGainAlgorithmRepository instance;
-
- private Map processDescriptionMap;
-// private Properties unicoreProperties;
-
- public GridGainAlgorithmRepository()
- {
- processDescriptionMap = new HashMap();
-
- if(WPSConfig.getInstance().isRepositoryActive(this.getClass().getCanonicalName())){
- Property[] propertyArray = WPSConfig.getInstance().getPropertiesForRepositoryClass(this.getClass().getCanonicalName());
- for(Property property : propertyArray){
- if(property.getName().equalsIgnoreCase("Algorithm") && property.getActive()){
- addAlgorithm(property.getStringValue());
- }
- }
- } else {
- LOGGER.debug("Local Algorithm Repository is inactive.");
- }
- }
-
- public GridGainAlgorithmRepository(String wpsConfigPath)
- {
- processDescriptionMap = new HashMap();
-
- Property[] propertyArray = WPSConfig.getInstance(wpsConfigPath).getPropertiesForRepositoryClass(this.getClass().getCanonicalName());
-
-// unicoreProperties = createUnicoreProperties(propertyArray);
-
- for (Property property : propertyArray)
- {
- if (property.getName().equalsIgnoreCase("Algorithm"))
- {
- addAlgorithm(property.getStringValue());
- }
- }
- }
-
-// private Properties createUnicoreProperties(Property[] propertyArray)
-// {
-// Properties result = new Properties();
-//
-// for (Property property : propertyArray)
-// {
-// if (property.getName().equalsIgnoreCase(CFG_REGISTRY))
-// {
-// result.setProperty(CFG_REGISTRY, property.getStringValue());
-// }
-// else if (property.getName().equalsIgnoreCase(CFG_KEYSTORE))
-// {
-// result.setProperty(CFG_KEYSTORE, property.getStringValue());
-// }
-// else if (property.getName().equalsIgnoreCase(CFG_ALIAS))
-// {
-// result.setProperty(CFG_ALIAS, property.getStringValue());
-// }
-// else if (property.getName().equalsIgnoreCase(CFG_PASSWORD))
-// {
-// result.setProperty(CFG_PASSWORD, property.getStringValue());
-// }
-// else if (property.getName().equalsIgnoreCase(CFG_TYPE))
-// {
-// result.setProperty(CFG_TYPE, property.getStringValue());
-// }
-// else if (property.getName().equalsIgnoreCase(CFG_OVERWRITE))
-// {
-// result.setProperty(CFG_OVERWRITE, property.getStringValue());
-// }
-// else if (property.getName().equalsIgnoreCase(CFG_COMPRESSION))
-// {
-// result.setProperty(CFG_COMPRESSION, property.getStringValue());
-// }
-// else
-// {
-// LOGGER.warn("Unsupported configuration paramter '" + property.getName() + "'.");
-// }
-// }
-//
-// return result;
-// }
-
- public static GridGainAlgorithmRepository getInstance()
- {
- if (instance == null)
- {
- instance = new GridGainAlgorithmRepository();
- }
- return instance;
- }
-
- public static GridGainAlgorithmRepository getInstance(String wpsConfigPath)
- {
- if (instance == null)
- {
- instance = new GridGainAlgorithmRepository(wpsConfigPath);
- }
- return instance;
- }
-
-// public Properties getUnicoreProperties()
-// {
-// return unicoreProperties;
-// }
-
- public boolean addAlgorithm(Object processID)
- {
- if (!(processID instanceof String))
- {
- return false;
- }
-
- String algorithmClassName = (String) processID;
-
- try
- {
- IGridGainAlgorithm algorithm = (IGridGainAlgorithm) GridGainAlgorithmRepository.class.getClassLoader().loadClass(algorithmClassName).newInstance();
-
- if (!algorithm.processDescriptionIsValid())
- {
- LOGGER.warn("Algorithm description is not valid: " + algorithmClassName);
- return false;
- }
-
- processDescriptionMap.put(algorithmClassName, algorithm.getDescription());
- LOGGER.info("Algorithm class registered: " + algorithmClassName);
-
- if (algorithm.getWellKnownName().length() != 0)
- {
- processDescriptionMap.put(algorithm.getWellKnownName(), algorithm.getDescription());
- }
- }
- catch (ClassNotFoundException e)
- {
- LOGGER.warn("Could not find algorithm class: " + algorithmClassName, e);
- return false;
- }
- catch (IllegalAccessException e)
- {
- LOGGER.warn("Access error occured while registering algorithm: " + algorithmClassName);
- return false;
- }
- catch (InstantiationException e)
- {
- LOGGER.warn("Could not instantiate algorithm: " + algorithmClassName);
- return false;
- }
- return true;
- }
-
- public boolean containsAlgorithm(String processID)
- {
- return processDescriptionMap.containsKey(processID);
- }
-
- public IAlgorithm getAlgorithm(String processID, ExecuteRequest executeRequest)
- {
- try
- {
- IGridGainAlgorithm algorithm = (IGridGainAlgorithm) GridGainAlgorithmRepository.class.getClassLoader().loadClass(processID).newInstance();
-
- return algorithm;
- }
- catch (ClassNotFoundException e)
- {
- LOGGER.warn("Could not find algorithm class: " + processID, e);
- throw new RuntimeException(e);
- }
- catch (IllegalAccessException e)
- {
- LOGGER.warn("Access error occured while registering algorithm: " + processID);
- throw new RuntimeException(e);
- }
- catch (InstantiationException e)
- {
- LOGGER.warn("Could not instantiate algorithm: " + processID);
- throw new RuntimeException(e);
- }
-
- }
-
- public Collection getAlgorithmNames()
- {
- return processDescriptionMap.keySet();
- }
-
- public Collection getAlgorithms()
- {
-
- List algorithmList = new ArrayList();
- for(String algorithmName : getAlgorithmNames()){
- try
- {
- IGridGainAlgorithm algorithm = (IGridGainAlgorithm) GridGainAlgorithmRepository.class.getClassLoader().loadClass(algorithmName).newInstance();
-
- algorithmList.add(algorithm);
- }
- catch (ClassNotFoundException e)
- {
- LOGGER.warn("Could not find algorithm class: " + algorithmName, e);
- throw new RuntimeException(e);
- }
- catch (IllegalAccessException e)
- {
- LOGGER.warn("Access error occured while registering algorithm: " + algorithmName);
- throw new RuntimeException(e);
- }
- catch (InstantiationException e)
- {
- LOGGER.warn("Could not instantiate algorithm: " + algorithmName);
- throw new RuntimeException(e);
- }
- }
- return algorithmList;
- }
-
- public boolean removeAlgorithm(Object processID)
- {
- if (!(processID instanceof String))
- {
- return false;
- }
- String className = (String) processID;
- if (processDescriptionMap.containsKey(className))
- {
- processDescriptionMap.remove(className);
- return true;
- }
- return false;
- }
-
- public ProcessDescriptionType getProcessDescription(String processID) {
- if(!processDescriptionMap.containsKey(processID)){
- processDescriptionMap.put(processID, getAlgorithm(processID, null).getDescription());
- }
- return processDescriptionMap.get(processID);
- }
-
-
-}
diff --git a/52n-wps-gridgain/src/main/java/org/n52/wps/gridgain/IGridGainAlgorithm.java b/52n-wps-gridgain/src/main/java/org/n52/wps/gridgain/IGridGainAlgorithm.java
deleted file mode 100644
index d65003992..000000000
--- a/52n-wps-gridgain/src/main/java/org/n52/wps/gridgain/IGridGainAlgorithm.java
+++ /dev/null
@@ -1,15 +0,0 @@
-
-package org.n52.wps.gridgain;
-
-import java.util.List;
-import java.util.Map;
-
-import org.n52.wps.io.data.IData;
-import org.n52.wps.server.IAlgorithm;
-
-public interface IGridGainAlgorithm extends IAlgorithm
-{
- List
+
+ be.spacebel.wps
+ wpsg-xml
+ 2.0.3
+
com.vividsolutions
jts
@@ -129,7 +98,7 @@
commons-io
commons-io
- 1.3.1
+ 2.4
javax.media
diff --git a/52n-wps-io/src/main/java/be/vito/ese/wps/io/GenericXMLDataBinding.java b/52n-wps-io/src/main/java/be/vito/ese/wps/io/GenericXMLDataBinding.java
new file mode 100644
index 000000000..2620d82a0
--- /dev/null
+++ b/52n-wps-io/src/main/java/be/vito/ese/wps/io/GenericXMLDataBinding.java
@@ -0,0 +1,26 @@
+package be.vito.ese.wps.io;
+
+import org.n52.wps.io.data.IComplexData;
+import org.w3c.dom.Document;
+
+public class GenericXMLDataBinding implements IComplexData{
+
+ private static final long serialVersionUID = -5326483198974935610L;
+
+ private Document document;
+
+ public GenericXMLDataBinding(Document document){
+ this.document = document;
+ }
+
+ @Override
+ public Document getPayload(){
+ return document;
+ }
+
+ @Override
+ public Class> getSupportedClass(){
+ return Document.class;
+ }
+
+}
\ No newline at end of file
diff --git a/52n-wps-io/src/main/java/be/vito/ese/wps/io/GenericXMLParser.java b/52n-wps-io/src/main/java/be/vito/ese/wps/io/GenericXMLParser.java
new file mode 100644
index 000000000..4bcab2bc2
--- /dev/null
+++ b/52n-wps-io/src/main/java/be/vito/ese/wps/io/GenericXMLParser.java
@@ -0,0 +1,91 @@
+package be.vito.ese.wps.io;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.n52.wps.io.data.IData;
+import org.n52.wps.io.datahandler.xml.AbstractXMLParser;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+public class GenericXMLParser extends AbstractXMLParser{
+
+ @Override
+ public Class>[] getSupportedInternalOutputDataType(){
+ return new Class [] {GenericXMLDataBinding.class};
+ }
+
+ @Override
+ public IData parseXML(InputStream stream){
+
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ // documentBuilderFactory.setNamespaceAware(true);
+
+ try{
+ DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ Document document = documentBuilder.parse(stream);
+ return new GenericXMLDataBinding(document);
+ }
+ catch (SAXException | IOException | ParserConfigurationException ex) {
+ throw new RuntimeException("Error while parsing XML: " + ex.getMessage(), ex);
+ }
+
+ }
+
+ @Override
+ public IData parse(InputStream input, String mimeType){
+ return parseXML(input);
+ }
+
+ @Override
+ public IData parseXML(String xml){
+
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ FileOutputStream tmpFos = null;
+ File tmpFile = null;
+ // documentBuilderFactory.setNamespaceAware(true);
+
+ try{
+
+ tmpFile = File.createTempFile("input", "xml");
+ tmpFos = new FileOutputStream(tmpFile);
+
+ StringReader xmlReader = new StringReader(xml);
+ int i = xmlReader.read();
+ while(i != -1){
+ tmpFos.write(i);
+ i = xmlReader.read();
+ }
+ tmpFos.close();
+
+ DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ Document document = documentBuilder.parse(tmpFile);
+ return new GenericXMLDataBinding(document);
+ }
+ catch (SAXException | IOException | ParserConfigurationException ex) {
+ throw new RuntimeException("Error while parsing XML: " + ex.getMessage(), ex);
+ }
+ finally{
+ if(tmpFile != null){
+ tmpFile.delete();
+ }
+ if(tmpFos != null){
+ try{
+ tmpFos.close();
+ }
+ catch(IOException ex){
+ // ignore
+ }
+ }
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/52n-wps-io/src/main/java/be/vito/ese/wps/io/TimeSeriesDataBinding.java b/52n-wps-io/src/main/java/be/vito/ese/wps/io/TimeSeriesDataBinding.java
new file mode 100644
index 000000000..17f7c9b15
--- /dev/null
+++ b/52n-wps-io/src/main/java/be/vito/ese/wps/io/TimeSeriesDataBinding.java
@@ -0,0 +1,37 @@
+package be.vito.ese.wps.io;
+
+import java.util.Date;
+import java.util.List;
+
+import org.n52.wps.io.data.IComplexData;
+
+public class TimeSeriesDataBinding implements IComplexData{
+
+ private static final long serialVersionUID = 6945469444347550464L;
+
+ private String coverageId;
+ private List averages;
+ private List dates;
+
+ public TimeSeriesDataBinding(String coverageId,
+ List averages,
+ List dates){
+
+ this.coverageId = coverageId;
+ this.averages = averages;
+ this.dates = dates;
+
+ }
+
+ @Override
+ public TimeSeriesDocument getPayload(){
+ return new TimeSeriesDocument(coverageId,
+ averages, dates);
+ }
+
+ @Override
+ public Class getSupportedClass(){
+ return TimeSeriesDocument.class;
+ }
+
+}
\ No newline at end of file
diff --git a/52n-wps-io/src/main/java/be/vito/ese/wps/io/TimeSeriesDocument.java b/52n-wps-io/src/main/java/be/vito/ese/wps/io/TimeSeriesDocument.java
new file mode 100644
index 000000000..840a36b9b
--- /dev/null
+++ b/52n-wps-io/src/main/java/be/vito/ese/wps/io/TimeSeriesDocument.java
@@ -0,0 +1,83 @@
+package be.vito.ese.wps.io;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class TimeSeriesDocument{
+
+ private String coverageId;
+ private List averages;
+ private List dates;
+
+ private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
+
+ public TimeSeriesDocument(String coverageId,
+ List averages,
+ List dates){
+
+ this.coverageId = coverageId;
+ this.averages = averages;
+ this.dates = dates;
+
+ if(averages.size() != dates.size()){
+ throw new IllegalArgumentException("Date and average sizes must be equal");
+ }
+
+ }
+
+ public Node getDomNode(){
+
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+
+ DocumentBuilder documentBuilder = null;
+ Document document = null;
+ Element rootElement = null;
+
+ try{
+
+ documentBuilder = factory.newDocumentBuilder();
+ document = documentBuilder.newDocument();
+
+ rootElement = document.createElementNS("http://vito.be/ese/timeseries", "ts:timeseries");
+
+ rootElement.setAttribute("coverageId", coverageId);
+ document.appendChild(rootElement);
+
+ int i = 0;
+ for(Double average : averages){
+
+ Element entryElement = document.createElementNS("http://vito.be/ese/timeseries", "ts:entry");
+ rootElement.appendChild(entryElement);
+
+ Element averageElement = document.createElementNS("http://vito.be/ese/timeseries", "ts:average");
+ averageElement.appendChild(document.createTextNode(average.toString()));
+ entryElement.appendChild(averageElement);
+
+ Element dateElement = document.createElementNS("http://vito.be/ese/timeseries", "ts:date");
+ dateElement.appendChild(document.createTextNode(DATE_FORMAT.format(dates.get(i))));
+ entryElement.appendChild(dateElement);
+
+ i++;
+
+ }
+
+ }
+ catch(ParserConfigurationException ex){
+ ex.printStackTrace();
+ }
+
+ return rootElement;
+ }
+
+}
diff --git a/52n-wps-io/src/main/java/be/vito/ese/wps/io/TimeSeriesGenerator.java b/52n-wps-io/src/main/java/be/vito/ese/wps/io/TimeSeriesGenerator.java
new file mode 100644
index 000000000..be5bc1825
--- /dev/null
+++ b/52n-wps-io/src/main/java/be/vito/ese/wps/io/TimeSeriesGenerator.java
@@ -0,0 +1,34 @@
+package be.vito.ese.wps.io;
+
+import java.io.OutputStream;
+
+import org.n52.wps.io.data.IData;
+import org.n52.wps.io.datahandler.binary.LargeBufferStream;
+import org.n52.wps.io.datahandler.xml.AbstractXMLGenerator;
+import org.w3c.dom.Node;
+
+public class TimeSeriesGenerator extends AbstractXMLGenerator{
+
+ @Override
+ public OutputStream generate(IData coll){
+
+ LargeBufferStream lbos = new LargeBufferStream();
+ // this.writeToStream(coll, lbos);
+ return lbos;
+
+ }
+
+ @Override
+ public Class>[] getSupportedInternalInputDataType(){
+
+ Class> [] supportedClasses = {TimeSeriesDataBinding.class};
+ return supportedClasses;
+
+ }
+
+ @Override
+ public Node generateXML(IData coll, String schema){
+ return ((TimeSeriesDataBinding)coll).getPayload().getDomNode();
+ }
+
+}
diff --git a/52n-wps-io/src/main/java/org/n52/wps/io/data/SimpleBBoxBinding.java b/52n-wps-io/src/main/java/org/n52/wps/io/data/SimpleBBoxBinding.java
new file mode 100644
index 000000000..5bb7f4942
--- /dev/null
+++ b/52n-wps-io/src/main/java/org/n52/wps/io/data/SimpleBBoxBinding.java
@@ -0,0 +1,39 @@
+package org.n52.wps.io.data;
+
+import net.opengis.ows.x11.BoundingBoxType;
+
+/** Simplified class for demo purpose
+ * */
+public class SimpleBBoxBinding implements IData {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private BoundingBoxType bbox;
+
+ public SimpleBBoxBinding(BoundingBoxType bbox) {
+ this.bbox = bbox;
+ }
+
+ @Override
+ public Object getPayload() {
+ // TODO Auto-generated method stub
+ return this.bbox;
+ }
+
+ @Override
+ public Class getSupportedClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public BoundingBoxType getBbox() {
+ return bbox;
+ }
+
+ public void setBbox(BoundingBoxType bbox) {
+ this.bbox = bbox;
+ }
+
+}
diff --git a/52n-wps-io/src/main/java/org/n52/wps/io/data/binding/complex/DataListDataBinding.java b/52n-wps-io/src/main/java/org/n52/wps/io/data/binding/complex/DataListDataBinding.java
new file mode 100644
index 000000000..a0769c10d
--- /dev/null
+++ b/52n-wps-io/src/main/java/org/n52/wps/io/data/binding/complex/DataListDataBinding.java
@@ -0,0 +1,34 @@
+package org.n52.wps.io.data.binding.complex;
+
+import org.n52.wps.io.data.IComplexData;
+
+import xint.esa.ese.wps.format.dataList.DataListDocument;
+import xint.esa.ese.wps.format.urlList.URLListDocument;
+
+
+
+public class DataListDataBinding implements IComplexData{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ protected transient DataListDocument urlDom;
+
+ public DataListDataBinding(DataListDocument payload) {
+ this.urlDom = payload;
+ }
+
+ public Class getSupportedClass() {
+ return DataListDocument.class;
+ }
+
+ public DataListDocument getPayload() {
+ return urlDom;
+ }
+
+
+
+
+
+}
diff --git a/52n-wps-io/src/main/java/org/n52/wps/io/data/binding/complex/EODataCacheDataBinding.java b/52n-wps-io/src/main/java/org/n52/wps/io/data/binding/complex/EODataCacheDataBinding.java
new file mode 100644
index 000000000..f744cab74
--- /dev/null
+++ b/52n-wps-io/src/main/java/org/n52/wps/io/data/binding/complex/EODataCacheDataBinding.java
@@ -0,0 +1,34 @@
+package org.n52.wps.io.data.binding.complex;
+
+import org.n52.wps.io.data.IComplexData;
+
+import xint.esa.ese.wps.format.eoDataCache.EODataCacheDocument;
+import xint.esa.ese.wps.format.urlList.URLListDocument;
+
+
+
+public class EODataCacheDataBinding implements IComplexData{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ protected transient EODataCacheDocument urlDom;
+
+ public EODataCacheDataBinding(EODataCacheDocument payload) {
+ this.urlDom = payload;
+ }
+
+ public Class getSupportedClass() {
+ return EODataCacheDocument.class;
+ }
+
+ public EODataCacheDocument getPayload() {
+ return urlDom;
+ }
+
+
+
+
+
+}
diff --git a/52n-wps-io/src/main/java/org/n52/wps/io/data/binding/complex/URLListDataBinding.java b/52n-wps-io/src/main/java/org/n52/wps/io/data/binding/complex/URLListDataBinding.java
index b7d295149..ad6caa14f 100644
--- a/52n-wps-io/src/main/java/org/n52/wps/io/data/binding/complex/URLListDataBinding.java
+++ b/52n-wps-io/src/main/java/org/n52/wps/io/data/binding/complex/URLListDataBinding.java
@@ -1,31 +1,33 @@
-package org.n52.wps.io.data.binding.complex;
-
-import org.n52.wps.io.data.IComplexData;
-
-import xint.esa.ssegrid.wps.javaSAGAProfile.URLListDocument;
-
-public class URLListDataBinding implements IComplexData{
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- protected transient URLListDocument urlDom;
-
- public URLListDataBinding(URLListDocument payload) {
- this.urlDom = payload;
- }
-
- public Class getSupportedClass() {
- return URLListDocument.class;
- }
-
- public URLListDocument getPayload() {
- return urlDom;
- }
-
-
-
-
-
-}
+package org.n52.wps.io.data.binding.complex;
+
+import org.n52.wps.io.data.IComplexData;
+
+import xint.esa.ese.wps.format.urlList.URLListDocument;
+
+
+
+public class URLListDataBinding implements IComplexData{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ protected transient URLListDocument urlDom;
+
+ public URLListDataBinding(URLListDocument payload) {
+ this.urlDom = payload;
+ }
+
+ public Class getSupportedClass() {
+ return URLListDocument.class;
+ }
+
+ public URLListDocument getPayload() {
+ return urlDom;
+ }
+
+
+
+
+
+}
diff --git a/52n-wps-io/src/main/java/org/n52/wps/io/datahandler/xml/DataListGenerator.java b/52n-wps-io/src/main/java/org/n52/wps/io/datahandler/xml/DataListGenerator.java
new file mode 100644
index 000000000..3c9a04d03
--- /dev/null
+++ b/52n-wps-io/src/main/java/org/n52/wps/io/datahandler/xml/DataListGenerator.java
@@ -0,0 +1,87 @@
+/***************************************************************
+ This implementation provides a framework to publish processes to the
+web through the OGC Web Processing Service interface. The framework
+is extensible in terms of processes and data handlers. It is compliant
+to the WPS version 0.4.0 (OGC 05-007r4).
+
+ Copyright (C) 2006 by con terra GmbH
+
+ Authors:
+ Theodor Foerster, ITC, Enschede, the Netherlands
+ Carsten Priess, Institute for geoinformatics, University of
+Muenster, Germany
+
+
+ Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
+ 48155 Muenster, Germany, 52n@conterra.de
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program (see gnu-gpl v2.txt); if not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA or visit the web page of the Free
+ Software Foundation, http://www.fsf.org.
+
+ Created on: 13.06.2006
+ ***************************************************************/
+package org.n52.wps.io.datahandler.xml;
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import org.n52.wps.io.IStreamableGenerator;
+import org.n52.wps.io.data.IData;
+import org.n52.wps.io.data.binding.complex.DataListDataBinding;
+import org.n52.wps.io.datahandler.binary.LargeBufferStream;
+import org.w3c.dom.Node;
+
+public class DataListGenerator extends AbstractXMLGenerator implements IStreamableGenerator {
+
+
+ public DataListGenerator()
+ {
+ super();
+ }
+
+ public DataListGenerator(boolean pReadWPSConfig)
+ {
+ super(pReadWPSConfig);
+ }
+
+ @Override
+ public OutputStream generate(IData coll) {
+ // TODO Auto-generated method stub
+ LargeBufferStream baos = new LargeBufferStream();
+ this.writeToStream(coll, baos);
+ return baos;
+ }
+
+ @Override
+ public Class[] getSupportedInternalInputDataType() {
+ Class[] supportedClasses = {DataListDataBinding.class};
+ return supportedClasses;
+
+ }
+
+ @Override
+ public void writeToStream(IData data, OutputStream os) {
+ OutputStreamWriter w = new OutputStreamWriter(os);
+ //write(data, w);
+ //TODO
+ }
+
+ @Override
+ public Node generateXML(IData coll, String schema) {
+ // TODO Auto-generated method stub
+ return ((DataListDataBinding)coll).getPayload().getDomNode();
+
+ }
+
+}
diff --git a/52n-wps-io/src/main/java/org/n52/wps/io/datahandler/xml/DataListParser.java b/52n-wps-io/src/main/java/org/n52/wps/io/datahandler/xml/DataListParser.java
new file mode 100644
index 000000000..d00a9784c
--- /dev/null
+++ b/52n-wps-io/src/main/java/org/n52/wps/io/datahandler/xml/DataListParser.java
@@ -0,0 +1,120 @@
+/***************************************************************
+ This implementation provides a framework to publish processes to the
+web through the OGC Web Processing Service interface. The framework
+is extensible in terms of processes and data handlers. It is compliant
+to the WPS version 0.4.0 (OGC 05-007r4).
+
+ Copyright (C) 2006 by con terra GmbH
+
+ Authors:
+ Bastian Sch�ffer, IfGI
+
+ Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
+ 48155 Muenster, Germany, 52n@conterra.de
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program (see gnu-gpl v2.txt); if not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA or visit the web page of the Free
+ Software Foundation, http://www.fsf.org.
+
+ Created on: 13.06.2006
+ ***************************************************************/
+package org.n52.wps.io.datahandler.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import org.apache.log4j.Logger;
+import org.apache.xmlbeans.XmlException;
+import org.n52.wps.io.IStreamableParser;
+import org.n52.wps.io.data.IData;
+import org.n52.wps.io.data.binding.complex.DataListDataBinding;
+import xint.esa.ese.wps.format.dataList.DataListDocument;
+
+
+/**
+ * This parser handles xml files compliant to gmlpacket.xsd
+ * @author schaeffer
+ *
+ */
+public class DataListParser extends AbstractXMLParser implements IStreamableParser {
+ private static Logger LOGGER = Logger.getLogger(DataListParser.class);
+
+
+ public DataListParser() {
+ super();
+ LOGGER.info("DataListParser");
+
+ }
+
+ public DataListParser(boolean pReadWPSConfig) {
+ super(pReadWPSConfig);
+ LOGGER.info("URLListParser2");
+ }
+
+
+
+
+ @Override
+ public DataListDataBinding parseXML(String urllist) {
+ LOGGER.info("URLListParser");
+ LOGGER.info(urllist);
+ DataListDocument urlDom = null;
+ try {
+ urlDom = DataListDocument.Factory.parse(urllist);
+ } catch (XmlException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return new DataListDataBinding(urlDom);
+ }
+
+ @Override
+ public DataListDataBinding parseXML(InputStream stream) {
+ DataListDocument urlDom = null;
+ try {
+ urlDom = DataListDocument.Factory.parse(stream);
+ } catch (XmlException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return new DataListDataBinding(urlDom);
+ }
+
+ @Override
+ public IData parse(InputStream input, String mimeType) {
+ LOGGER.info("URLListParser6");
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Class[] getSupportedInternalOutputDataType() {
+ Class[] supportedClasses = {DataListDataBinding.class};
+ return supportedClasses;
+ }
+
+ @Override
+ public Object parseXML(URI uri) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+
+
+
+}
diff --git a/52n-wps-io/src/main/java/org/n52/wps/io/datahandler/xml/EODataListGenerator.java b/52n-wps-io/src/main/java/org/n52/wps/io/datahandler/xml/EODataListGenerator.java
new file mode 100644
index 000000000..21cf37b82
--- /dev/null
+++ b/52n-wps-io/src/main/java/org/n52/wps/io/datahandler/xml/EODataListGenerator.java
@@ -0,0 +1,89 @@
+/***************************************************************
+ This implementation provides a framework to publish processes to the
+web through the OGC Web Processing Service interface. The framework
+is extensible in terms of processes and data handlers. It is compliant
+to the WPS version 0.4.0 (OGC 05-007r4).
+
+ Copyright (C) 2006 by con terra GmbH
+
+ Authors:
+ Theodor Foerster, ITC, Enschede, the Netherlands
+ Carsten Priess, Institute for geoinformatics, University of
+Muenster, Germany
+
+
+ Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
+ 48155 Muenster, Germany, 52n@conterra.de
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program (see gnu-gpl v2.txt); if not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA or visit the web page of the Free
+ Software Foundation, http://www.fsf.org.
+
+ Created on: 13.06.2006
+ ***************************************************************/
+package org.n52.wps.io.datahandler.xml;
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+
+import org.n52.wps.io.IStreamableGenerator;
+import org.n52.wps.io.data.IData;
+import org.n52.wps.io.data.binding.complex.EODataCacheDataBinding;
+import org.n52.wps.io.data.binding.complex.URLListDataBinding;
+import org.n52.wps.io.datahandler.binary.LargeBufferStream;
+import org.w3c.dom.Node;
+
+public class EODataListGenerator extends AbstractXMLGenerator implements IStreamableGenerator {
+
+
+ public EODataListGenerator()
+ {
+ super();
+ }
+
+ public EODataListGenerator(boolean pReadWPSConfig)
+ {
+ super(pReadWPSConfig);
+ }
+
+ @Override
+ public OutputStream generate(IData coll) {
+ // TODO Auto-generated method stub
+ LargeBufferStream baos = new LargeBufferStream();
+ this.writeToStream(coll, baos);
+ return baos;
+ }
+
+ @Override
+ public Class[] getSupportedInternalInputDataType() {
+ Class[] supportedClasses = {EODataCacheDataBinding.class};
+ return supportedClasses;
+
+ }
+
+ @Override
+ public void writeToStream(IData data, OutputStream os) {
+ OutputStreamWriter w = new OutputStreamWriter(os);
+ //write(data, w);
+ //TODO
+ }
+
+ @Override
+ public Node generateXML(IData coll, String schema) {
+ // TODO Auto-generated method stub
+ return ((EODataCacheDataBinding)coll).getPayload().getDomNode();
+
+ }
+
+}
diff --git a/52n-wps-io/src/main/java/org/n52/wps/io/datahandler/xml/EODataListParser.java b/52n-wps-io/src/main/java/org/n52/wps/io/datahandler/xml/EODataListParser.java
new file mode 100644
index 000000000..726206a6e
--- /dev/null
+++ b/52n-wps-io/src/main/java/org/n52/wps/io/datahandler/xml/EODataListParser.java
@@ -0,0 +1,166 @@
+/***************************************************************
+ This implementation provides a framework to publish processes to the
+web through the OGC Web Processing Service interface. The framework
+is extensible in terms of processes and data handlers. It is compliant
+to the WPS version 0.4.0 (OGC 05-007r4).
+
+ Copyright (C) 2006 by con terra GmbH
+
+ Authors:
+ Bastian Sch�ffer, IfGI
+
+ Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
+ 48155 Muenster, Germany, 52n@conterra.de
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program (see gnu-gpl v2.txt); if not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA or visit the web page of the Free
+ Software Foundation, http://www.fsf.org.
+
+ Created on: 13.06.2006
+ ***************************************************************/
+package org.n52.wps.io.datahandler.xml;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+
+
+
+
+
+import org.apache.log4j.Logger;
+import org.apache.xmlbeans.XmlException;
+import org.geotools.feature.DefaultFeatureCollections;
+import org.geotools.feature.FeatureCollection;
+import org.geotools.feature.GeometryAttributeImpl;
+import org.geotools.feature.type.GeometryDescriptorImpl;
+import org.geotools.feature.type.GeometryTypeImpl;
+import org.geotools.filter.identity.GmlObjectIdImpl;
+import org.geotools.gml3.ApplicationSchemaConfiguration;
+import org.geotools.gml3.GMLConfiguration;
+import org.geotools.xml.Configuration;
+import org.geotools.xml.Parser;
+import org.n52.wps.commons.context.ExecutionContext;
+import org.n52.wps.commons.context.ExecutionContextFactory;
+import org.n52.wps.io.IStreamableParser;
+import org.n52.wps.io.SchemaRepository;
+import org.n52.wps.io.data.IData;
+import org.n52.wps.io.data.binding.complex.EODataCacheDataBinding;
+import org.n52.wps.io.data.binding.complex.GTVectorDataBinding;
+import org.opengis.feature.GeometryAttribute;
+import org.opengis.feature.simple.SimpleFeature;
+import org.opengis.feature.type.GeometryDescriptor;
+import org.opengis.feature.type.GeometryType;
+import org.opengis.filter.identity.Identifier;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import xint.esa.ese.wps.format.eoDataCache.EODataCacheDocument;
+
+import com.vividsolutions.jts.geom.Geometry;
+
+
+/**
+ * This parser handles xml files compliant to gmlpacket.xsd
+ * @author schaeffer
+ *
+ */
+public class EODataListParser extends AbstractXMLParser implements IStreamableParser {
+ private static Logger LOGGER = Logger.getLogger(EODataListParser.class);
+
+
+ public EODataListParser() {
+ super();
+ LOGGER.info("URLListParser");
+
+ }
+
+ public EODataListParser(boolean pReadWPSConfig) {
+ super(pReadWPSConfig);
+ LOGGER.info("URLListParser2");
+ }
+
+
+
+
+ @Override
+ public EODataCacheDataBinding parseXML(String urllist) {
+ LOGGER.info("URLListParser");
+ LOGGER.info(urllist);
+ EODataCacheDocument urlDom = null;
+ try {
+ urlDom = EODataCacheDocument.Factory.parse(urllist);
+ } catch (XmlException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return new EODataCacheDataBinding(urlDom);
+ }
+
+ @Override
+ public EODataCacheDataBinding parseXML(InputStream stream) {
+ EODataCacheDocument urlDom = null;
+ try {
+ urlDom = EODataCacheDocument.Factory.parse(stream);
+ } catch (XmlException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return new EODataCacheDataBinding(urlDom);
+ }
+
+ @Override
+ public IData parse(InputStream input, String mimeType) {
+ LOGGER.info("URLListParser6");
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Class[] getSupportedInternalOutputDataType() {
+ Class[] supportedClasses = {EODataCacheDataBinding.class};
+ return supportedClasses;
+ }
+
+ @Override
+ public Object parseXML(URI uri) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+
+
+
+}
diff --git a/52n-wps-io/src/main/java/org/n52/wps/io/datahandler/xml/URLListParser.java b/52n-wps-io/src/main/java/org/n52/wps/io/datahandler/xml/URLListParser.java
index e1c6e0f2f..431b6be47 100644
--- a/52n-wps-io/src/main/java/org/n52/wps/io/datahandler/xml/URLListParser.java
+++ b/52n-wps-io/src/main/java/org/n52/wps/io/datahandler/xml/URLListParser.java
@@ -1,163 +1,164 @@
-/***************************************************************
- This implementation provides a framework to publish processes to the
-web through the OGC Web Processing Service interface. The framework
-is extensible in terms of processes and data handlers. It is compliant
-to the WPS version 0.4.0 (OGC 05-007r4).
-
- Copyright (C) 2006 by con terra GmbH
-
- Authors:
- Bastian Sch�ffer, IfGI
-
- Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
- 48155 Muenster, Germany, 52n@conterra.de
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program (see gnu-gpl v2.txt); if not, write to
- the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA or visit the web page of the Free
- Software Foundation, http://www.fsf.org.
-
- Created on: 13.06.2006
- ***************************************************************/
-package org.n52.wps.io.datahandler.xml;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.XMLConstants;
-import javax.xml.namespace.QName;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParserFactory;
-
-
-import org.apache.log4j.Logger;
-import org.apache.xmlbeans.XmlException;
-import org.geotools.feature.DefaultFeatureCollections;
-import org.geotools.feature.FeatureCollection;
-import org.geotools.feature.GeometryAttributeImpl;
-import org.geotools.feature.type.GeometryDescriptorImpl;
-import org.geotools.feature.type.GeometryTypeImpl;
-import org.geotools.filter.identity.GmlObjectIdImpl;
-import org.geotools.gml3.ApplicationSchemaConfiguration;
-import org.geotools.gml3.GMLConfiguration;
-import org.geotools.xml.Configuration;
-import org.geotools.xml.Parser;
-import org.n52.wps.commons.context.ExecutionContext;
-import org.n52.wps.commons.context.ExecutionContextFactory;
-import org.n52.wps.io.IStreamableParser;
-import org.n52.wps.io.SchemaRepository;
-import org.n52.wps.io.data.IData;
-import org.n52.wps.io.data.binding.complex.GTVectorDataBinding;
-import org.n52.wps.io.data.binding.complex.URLListDataBinding;
-import org.opengis.feature.GeometryAttribute;
-import org.opengis.feature.simple.SimpleFeature;
-import org.opengis.feature.type.GeometryDescriptor;
-import org.opengis.feature.type.GeometryType;
-import org.opengis.filter.identity.Identifier;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-import xint.esa.ssegrid.wps.javaSAGAProfile.URLListDocument;
-
-import com.vividsolutions.jts.geom.Geometry;
-
-
-/**
- * This parser handles xml files compliant to gmlpacket.xsd
- * @author schaeffer
- *
- */
-public class URLListParser extends AbstractXMLParser implements IStreamableParser {
- private static Logger LOGGER = Logger.getLogger(URLListParser.class);
-
-
- public URLListParser() {
- super();
- LOGGER.info("URLListParser");
-
- }
-
- public URLListParser(boolean pReadWPSConfig) {
- super(pReadWPSConfig);
- LOGGER.info("URLListParser2");
- }
-
-
-
-
- @Override
- public URLListDataBinding parseXML(String urllist) {
- LOGGER.info("URLListParser");
- LOGGER.info(urllist);
- URLListDocument urlDom = null;
- try {
- urlDom = URLListDocument.Factory.parse(urllist);
- } catch (XmlException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return new URLListDataBinding(urlDom);
- }
-
- @Override
- public URLListDataBinding parseXML(InputStream stream) {
- URLListDocument urlDom = null;
- try {
- urlDom = URLListDocument.Factory.parse(stream);
- } catch (XmlException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return new URLListDataBinding(urlDom);
- }
-
- @Override
- public IData parse(InputStream input, String mimeType) {
- LOGGER.info("URLListParser6");
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Class[] getSupportedInternalOutputDataType() {
- Class[] supportedClasses = {URLListDataBinding.class};
- return supportedClasses;
- }
-
- @Override
- public Object parseXML(URI uri) {
- // TODO Auto-generated method stub
- return null;
- }
-
-
-
-
-
-}
+/***************************************************************
+ This implementation provides a framework to publish processes to the
+web through the OGC Web Processing Service interface. The framework
+is extensible in terms of processes and data handlers. It is compliant
+to the WPS version 0.4.0 (OGC 05-007r4).
+
+ Copyright (C) 2006 by con terra GmbH
+
+ Authors:
+ Bastian Sch�ffer, IfGI
+
+ Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
+ 48155 Muenster, Germany, 52n@conterra.de
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program (see gnu-gpl v2.txt); if not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA or visit the web page of the Free
+ Software Foundation, http://www.fsf.org.
+
+ Created on: 13.06.2006
+ ***************************************************************/
+package org.n52.wps.io.datahandler.xml;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+
+
+
+import org.apache.log4j.Logger;
+import org.apache.xmlbeans.XmlException;
+import org.geotools.feature.DefaultFeatureCollections;
+import org.geotools.feature.FeatureCollection;
+import org.geotools.feature.GeometryAttributeImpl;
+import org.geotools.feature.type.GeometryDescriptorImpl;
+import org.geotools.feature.type.GeometryTypeImpl;
+import org.geotools.filter.identity.GmlObjectIdImpl;
+import org.geotools.gml3.ApplicationSchemaConfiguration;
+import org.geotools.gml3.GMLConfiguration;
+import org.geotools.xml.Configuration;
+import org.geotools.xml.Parser;
+import org.n52.wps.commons.context.ExecutionContext;
+import org.n52.wps.commons.context.ExecutionContextFactory;
+import org.n52.wps.io.IStreamableParser;
+import org.n52.wps.io.SchemaRepository;
+import org.n52.wps.io.data.IData;
+import org.n52.wps.io.data.binding.complex.GTVectorDataBinding;
+import org.n52.wps.io.data.binding.complex.URLListDataBinding;
+import org.opengis.feature.GeometryAttribute;
+import org.opengis.feature.simple.SimpleFeature;
+import org.opengis.feature.type.GeometryDescriptor;
+import org.opengis.feature.type.GeometryType;
+import org.opengis.filter.identity.Identifier;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import xint.esa.ese.wps.format.urlList.URLListDocument;
+
+import com.vividsolutions.jts.geom.Geometry;
+
+
+/**
+ * This parser handles xml files compliant to gmlpacket.xsd
+ * @author schaeffer
+ *
+ */
+public class URLListParser extends AbstractXMLParser implements IStreamableParser {
+ private static Logger LOGGER = Logger.getLogger(URLListParser.class);
+
+
+ public URLListParser() {
+ super();
+ LOGGER.info("URLListParser");
+
+ }
+
+ public URLListParser(boolean pReadWPSConfig) {
+ super(pReadWPSConfig);
+ LOGGER.info("URLListParser2");
+ }
+
+
+
+
+ @Override
+ public URLListDataBinding parseXML(String urllist) {
+ LOGGER.info("URLListParser");
+ LOGGER.info(urllist);
+ URLListDocument urlDom = null;
+ try {
+ urlDom = URLListDocument.Factory.parse(urllist);
+ } catch (XmlException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return new URLListDataBinding(urlDom);
+ }
+
+ @Override
+ public URLListDataBinding parseXML(InputStream stream) {
+ URLListDocument urlDom = null;
+ try {
+ urlDom = URLListDocument.Factory.parse(stream);
+ } catch (XmlException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return new URLListDataBinding(urlDom);
+ }
+
+ @Override
+ public IData parse(InputStream input, String mimeType) {
+ LOGGER.info("URLListParser6");
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Class[] getSupportedInternalOutputDataType() {
+ Class[] supportedClasses = {URLListDataBinding.class};
+ return supportedClasses;
+ }
+
+ @Override
+ public Object parseXML(URI uri) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+
+
+
+}
diff --git a/52n-wps-python/.gitignore b/52n-wps-python/.gitignore
new file mode 100644
index 000000000..ea8c4bf7f
--- /dev/null
+++ b/52n-wps-python/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/52n-wps-python/.settings/org.eclipse.core.resources.prefs b/52n-wps-python/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 000000000..24e56b874
--- /dev/null
+++ b/52n-wps-python/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding//src/main/java=ISO-8859-1
diff --git a/52n-wps-python/.settings/org.eclipse.jdt.core.prefs b/52n-wps-python/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..69c31cd49
--- /dev/null
+++ b/52n-wps-python/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/52n-wps-python/.settings/org.eclipse.m2e.core.prefs b/52n-wps-python/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 000000000..f897a7f1c
--- /dev/null
+++ b/52n-wps-python/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/52n-wps-python/.settings/org.eclipse.wst.common.component b/52n-wps-python/.settings/org.eclipse.wst.common.component
new file mode 100644
index 000000000..9a8834cfa
--- /dev/null
+++ b/52n-wps-python/.settings/org.eclipse.wst.common.component
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/52n-wps-python/.settings/org.eclipse.wst.common.project.facet.core.xml b/52n-wps-python/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 000000000..c78d9323f
--- /dev/null
+++ b/52n-wps-python/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/52n-wps-python/.settings/org.eclipse.wst.validation.prefs b/52n-wps-python/.settings/org.eclipse.wst.validation.prefs
new file mode 100644
index 000000000..04cad8cb7
--- /dev/null
+++ b/52n-wps-python/.settings/org.eclipse.wst.validation.prefs
@@ -0,0 +1,2 @@
+disabled=06target
+eclipse.preferences.version=1
diff --git a/52n-wps-server/.settings/org.eclipse.core.resources.prefs b/52n-wps-server/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 000000000..24e56b874
--- /dev/null
+++ b/52n-wps-server/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding//src/main/java=ISO-8859-1
diff --git a/52n-wps-server/.settings/org.eclipse.jdt.core.prefs b/52n-wps-server/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..69c31cd49
--- /dev/null
+++ b/52n-wps-server/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/52n-wps-server/.settings/org.eclipse.m2e.core.prefs b/52n-wps-server/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 000000000..f897a7f1c
--- /dev/null
+++ b/52n-wps-server/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/52n-wps-server/.settings/org.eclipse.wst.common.component b/52n-wps-server/.settings/org.eclipse.wst.common.component
new file mode 100644
index 000000000..4aa812e64
--- /dev/null
+++ b/52n-wps-server/.settings/org.eclipse.wst.common.component
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/52n-wps-server/.settings/org.eclipse.wst.common.project.facet.core.xml b/52n-wps-server/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 000000000..c78d9323f
--- /dev/null
+++ b/52n-wps-server/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/52n-wps-server/.settings/org.eclipse.wst.validation.prefs b/52n-wps-server/.settings/org.eclipse.wst.validation.prefs
new file mode 100644
index 000000000..04cad8cb7
--- /dev/null
+++ b/52n-wps-server/.settings/org.eclipse.wst.validation.prefs
@@ -0,0 +1,2 @@
+disabled=06target
+eclipse.preferences.version=1
diff --git a/52n-wps-server/pom.xml b/52n-wps-server/pom.xml
index ef3afc0b3..2a7092568 100644
--- a/52n-wps-server/pom.xml
+++ b/52n-wps-server/pom.xml
@@ -42,12 +42,12 @@
be.spacebel.wps
wpsg-xml
- 1.0.0
+ 2.0.3
- tomcat
- servlet-api
- 5.5.15
+ org.apache.tomcat
+ tomcat-servlet-api
+ 7.0.30
provided
@@ -70,6 +70,7 @@
axis2
1.5
+
commons-net
commons-net
@@ -83,38 +84,41 @@
org.apache.ws.commons.axiom
axiom-impl
- 1.2.8
+ 1.2.12
org.apache.ws.commons.axiom
axiom-dom
- 1.2.8
+ 1.2.12
org.apache.ws.commons.axiom
axiom-api
- 1.2.8
-
-
- org.apache.rampart
- rampart-core
- 1.4
-
-
- xmlbeans
- xbean
-
-
- opensaml
- opensaml
-
-
- org.apache.ant
- ant-nodeps
-
-
-
+ 1.2.12
+
+ net.sf.wsag4j.types
+ wsag4j-addressing-types
+ 2.0.0
+
+
+ org.apache.axis2
+ axis2-saaj
+ 1.6.2
+
+
+ org.apache.ws.security
+ wss4j
+ 1.6.1
+
+
+
+ org.apache.ant
+ ant
+ 1.8.2
+
+
+
xerces
xercesImpl
@@ -127,6 +131,38 @@
2.0
compile
-
+
+ org.apache.oozie
+ oozie-client
+ 4.0.0-cdh5.1.0
+
+
+ org.apache.hadoop
+ hadoop-client
+ 2.3.0-cdh5.1.0
+ compile
+
+
+
+ org.apache.hadoop
+ hadoop-auth
+ 2.3.0-cdh5.1.0
+ compile
+
+
+
+
+
+ cloudera-repo-releases
+ https://repository.cloudera.com/artifactory/repo/
+
+
+ cloudera-repo-releases2
+ https://repository.cloudera.com/cloudera/cloudera-repos/
+
+
+
+
+
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/AbstractCancellableAlgorithm.java b/52n-wps-server/src/main/java/org/n52/wps/server/AbstractCancellableAlgorithm.java
new file mode 100644
index 000000000..0c3f90161
--- /dev/null
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/AbstractCancellableAlgorithm.java
@@ -0,0 +1,135 @@
+package org.n52.wps.server;
+
+import net.opengis.wps.x100.InputDescriptionType;
+import net.opengis.wps.x100.OutputDescriptionType;
+
+import org.n52.wps.io.data.binding.complex.DataListDataBinding;
+import org.n52.wps.io.data.binding.complex.EODataCacheDataBinding;
+import org.n52.wps.io.data.binding.complex.GenericFileDataBinding;
+import org.n52.wps.io.data.binding.complex.URLListDataBinding;
+import org.n52.wps.io.data.binding.literal.LiteralBooleanBinding;
+import org.n52.wps.io.data.binding.literal.LiteralDoubleBinding;
+import org.n52.wps.io.data.binding.literal.LiteralIntBinding;
+import org.n52.wps.io.data.binding.literal.LiteralLongBinding;
+import org.n52.wps.io.data.binding.literal.LiteralStringBinding;
+
+public abstract class AbstractCancellableAlgorithm extends AbstractAlgorithm implements ICancelAlgorithm{
+
+
+ private String instanceId;
+
+ public String getInstanceId() {
+ return this.instanceId;
+ }
+
+ public void setInstanceId(String instanceId) {
+ this.instanceId = instanceId;
+ }
+
+ /** In the case of the AbstractCancellableAlgorith, it was chosen to
+ * give a default getInput/Output Data Type implementation in order
+ * to facilitate later implementation .
+ * Off course, this should rather be defined in a specialization class */
+
+ public Class getInputDataType(String id) {
+ InputDescriptionType[] inputs = this.getDescription().getDataInputs()
+ .getInputArray();
+ for (InputDescriptionType input : inputs) {
+ if (input.getIdentifier().getStringValue().equals(id)) {
+ if (input.isSetLiteralData()) {
+ String datatype = input.getLiteralData().getDataType()
+ .getStringValue();
+ if (datatype.contains("tring")) {
+ return LiteralStringBinding.class;
+ }
+ if (datatype.contains("ong")) {
+ return LiteralLongBinding.class;
+ }
+ if (datatype.contains("ollean")) {
+ return LiteralBooleanBinding.class;
+ }
+ if (datatype.contains("loat") || datatype.contains("ouble")) {
+ return LiteralDoubleBinding.class;
+ }
+ if (datatype.contains("nt")) {
+ return LiteralIntBinding.class;
+ }
+ }
+ if (input.isSetComplexData()) {
+ String mimeType = input.getComplexData().getDefault()
+ .getFormat().getMimeType();
+ if (mimeType.contains("xml") || (mimeType.contains("XML"))) {
+ return URLListDataBinding.class;
+ } else {
+ return URLListDataBinding.class;
+ }
+ }
+ }
+ }
+ throw new RuntimeException("Could not determie internal inputDataType");
+ }
+
+ public Class getOutputDataType(String id) {
+ OutputDescriptionType[] outputs = this.getDescription()
+ .getProcessOutputs().getOutputArray();
+
+ for (OutputDescriptionType output : outputs) {
+ if (output.getIdentifier().getStringValue().equals(id)) {
+
+ if (output.isSetLiteralOutput()) {
+ // Missing case when dataType is not present
+ if (output.getLiteralOutput().getDataType() == null) {
+ return LiteralStringBinding.class;
+ }
+ String datatype = output.getLiteralOutput().getDataType()
+ .getStringValue();
+ if (datatype.contains("tring")) {
+ return LiteralStringBinding.class;
+ }
+ if (datatype.contains("ollean")) {
+ return LiteralBooleanBinding.class;
+ }
+ if (datatype.contains("ong")) {
+ return LiteralLongBinding.class;
+ }
+ if (datatype.contains("loat") || datatype.contains("ouble")) {
+ return LiteralDoubleBinding.class;
+ }
+ if (datatype.contains("nt")) {
+ return LiteralIntBinding.class;
+ }
+ }
+ if (output.isSetComplexOutput()) {
+ String mimeType = output.getComplexOutput().getDefault()
+ .getFormat().getMimeType();
+ if (mimeType.contains("xml") || (mimeType.contains("XML"))) {
+ if (output.getComplexOutput().getDefault().getFormat()
+ .getSchema().contains("URLList")) {
+ return URLListDataBinding.class;
+
+ }
+ else if (output.getComplexOutput().getDefault().getFormat()
+ .getSchema().contains("DataList")) {
+ return DataListDataBinding.class;
+
+ }
+ else if (output.getComplexOutput().getDefault().getFormat()
+ .getSchema().contains("EODataCache")) {
+ return EODataCacheDataBinding.class;
+
+ }
+ else {
+ return GenericFileDataBinding.class;
+ }
+
+ } else {
+ return GenericFileDataBinding.class;
+ }
+ }
+ }
+ }
+ throw new RuntimeException("Could not determie internal inputDataType");
+ }
+
+
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/AbstractSelfDescribingAlgorithm.java b/52n-wps-server/src/main/java/org/n52/wps/server/AbstractSelfDescribingAlgorithm.java
index b63af7c55..7060ecf03 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/AbstractSelfDescribingAlgorithm.java
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/AbstractSelfDescribingAlgorithm.java
@@ -1,349 +1,348 @@
-package org.n52.wps.server;
-
-import java.lang.reflect.Constructor;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import net.opengis.ows.x11.DomainMetadataType;
-import net.opengis.wps.x100.ComplexDataCombinationType;
-import net.opengis.wps.x100.ComplexDataCombinationsType;
-import net.opengis.wps.x100.ComplexDataDescriptionType;
-import net.opengis.wps.x100.InputDescriptionType;
-import net.opengis.wps.x100.LiteralInputType;
-import net.opengis.wps.x100.LiteralOutputType;
-import net.opengis.wps.x100.OutputDescriptionType;
-import net.opengis.wps.x100.ProcessDescriptionType;
-import net.opengis.wps.x100.ProcessDescriptionType.DataInputs;
-import net.opengis.wps.x100.ProcessDescriptionType.ProcessOutputs;
-import net.opengis.wps.x100.ProcessDescriptionsDocument;
-import net.opengis.wps.x100.ProcessDescriptionsDocument.ProcessDescriptions;
-import net.opengis.wps.x100.SupportedComplexDataInputType;
-import net.opengis.wps.x100.SupportedComplexDataType;
-
-import org.apache.log4j.Logger;
-import org.n52.wps.io.GeneratorFactory;
-import org.n52.wps.io.IGenerator;
-import org.n52.wps.io.IParser;
-import org.n52.wps.io.ParserFactory;
-import org.n52.wps.io.data.IComplexData;
-import org.n52.wps.io.data.ILiteralData;
-import org.n52.wps.server.observerpattern.IObserver;
-import org.n52.wps.server.observerpattern.ISubject;
-import org.n52.wps.server.profiles.JavaSaga.JavaSagaDeploymentProfile;
-
-
-public abstract class AbstractSelfDescribingAlgorithm extends AbstractAlgorithm implements ISubject{
-
- private static Logger LOGGER = Logger.getLogger(AbstractSelfDescribingAlgorithm.class);
- @Override
- protected ProcessDescriptionType initializeDescription() {
- ProcessDescriptionsDocument document = ProcessDescriptionsDocument.Factory.newInstance();
- ProcessDescriptions processDescriptions = document.addNewProcessDescriptions();
- ProcessDescriptionType processDescription = processDescriptions.addNewProcessDescription();
- processDescription.setStatusSupported(true);
- processDescription.setStoreSupported(true);
- processDescription.setProcessVersion("1.0.0");
-
- //1. Identifer
- processDescription.addNewIdentifier().setStringValue(this.getClass().getName());
- processDescription.addNewTitle().setStringValue(this.getClass().getCanonicalName());
- //2. Inputs
-
-
- List identifiers = this.getInputIdentifiers();
- DataInputs dataInputs = null;
- if(identifiers.size()>0){
- dataInputs = processDescription.addNewDataInputs();
- }
-
- for(String identifier : identifiers){
- InputDescriptionType dataInput = dataInputs.addNewInput();
- dataInput.setMinOccurs(getMinOccurs(identifier));
- dataInput.setMaxOccurs(getMaxOccurs(identifier));
- dataInput.addNewIdentifier().setStringValue(identifier);
- dataInput.addNewTitle().setStringValue(identifier);
-
- Class> inputDataTypeClass = this.getInputDataType(identifier);
- Class>[] interfaces = inputDataTypeClass.getInterfaces();
-
- for(Class> implementedInterface : interfaces){
- if(implementedInterface.equals(ILiteralData.class)){
- LiteralInputType literalData = dataInput.addNewLiteralData();
- String inputClassType = "";
-
- Constructor>[] constructors = inputDataTypeClass.getConstructors();
- for(Constructor> constructor : constructors){
- Class>[] parameters = constructor.getParameterTypes();
- if(parameters.length==1){
- inputClassType = parameters[0].getSimpleName();
- }
- }
-
- if(inputClassType.length()>0){
- DomainMetadataType datatype = literalData.addNewDataType();
- datatype.setReference("xs:"+inputClassType.toLowerCase());
- literalData.addNewAnyValue();
- }
-
- }else if(implementedInterface.equals(IComplexData.class)){
- SupportedComplexDataInputType complexData = dataInput.addNewComplexData();
- ComplexDataCombinationType defaultInputFormat = complexData.addNewDefault();
- ComplexDataCombinationsType supportedtInputFormat = complexData.addNewSupported();
- List parsers = ParserFactory.getInstance().getAllParsers();
- List foundParsers = new ArrayList();
- for(IParser parser : parsers) {
- Class>[] supportedClasses = parser.getSupportedInternalOutputDataType();
- for(Class> clazz : supportedClasses){
- if(clazz.equals(inputDataTypeClass)){
- foundParsers.add(parser);
- }
-
- }
- }
-
- for(int i = 0; i0){
- ComplexDataDescriptionType supportedCreatedFormatAdditional = supportedtInputFormat.addNewFormat();
- supportedCreatedFormatAdditional.setEncoding(supportedEncodings[k]);
- supportedCreatedFormatAdditional.setMimeType(supportedFormat);
- supportedCreatedFormatAdditional.setSchema(supportedSchemas[t]);
- }
- }
-
-// if(supportedFormats.length==1 && supportedEncodings.length==1){
-// String supportedFormat = supportedFormats[j];
-// ComplexDataDescriptionType supportedCreatedFormat = supportedtInputFormat.addNewFormat();
-// supportedCreatedFormat.setMimeType(supportedFormat);
-// supportedCreatedFormat.setEncoding(supportedEncodings[k]);
-// for(int t = 0; t0){
-// ComplexDataDescriptionType supportedCreatedFormatAdditional = supportedtInputFormat.addNewFormat();
-// supportedCreatedFormatAdditional.setEncoding(supportedEncodings[k]);
-// supportedCreatedFormatAdditional.setMimeType(supportedFormat);
-// supportedCreatedFormatAdditional.setSchema(supportedSchemas[t]);
-// }
-// }
-// }
- }
- }
- }
- }
- }
- }
-
- //3. Outputs
- ProcessOutputs dataOutputs = processDescription.addNewProcessOutputs();
- List outputIdentifiers = this.getOutputIdentifiers();
- for(String identifier : outputIdentifiers){
- OutputDescriptionType dataOutput = dataOutputs.addNewOutput();
-
-
- dataOutput.addNewIdentifier().setStringValue(identifier);
- dataOutput.addNewTitle().setStringValue(identifier);
- dataOutput.addNewAbstract().setStringValue(identifier);
-
- Class> outputDataTypeClass = this.getOutputDataType(identifier);
- Class>[] interfaces = outputDataTypeClass.getInterfaces();
-
- for(Class> implementedInterface : interfaces){
-
-
- if(implementedInterface.equals(ILiteralData.class)){
- LiteralOutputType literalData = dataOutput.addNewLiteralOutput();
- String outputClassType = "";
-
- Constructor>[] constructors = outputDataTypeClass.getConstructors();
- for(Constructor> constructor : constructors){
- Class>[] parameters = constructor.getParameterTypes();
- if(parameters.length==1){
- outputClassType = parameters[0].getSimpleName();
- }
- }
-
- if(outputClassType.length()>0){
- literalData.addNewDataType().setReference("xs:"+outputClassType.toLowerCase());
- }
-
-
- }else if(implementedInterface.equals(IComplexData.class)){
-
- SupportedComplexDataType complexData = dataOutput.addNewComplexOutput();
- ComplexDataCombinationType defaultInputFormat = complexData.addNewDefault();
- ComplexDataCombinationsType supportedtOutputFormat = complexData.addNewSupported();
-
- List generators = GeneratorFactory.getInstance().getAllGenerators();
- List foundGenerators = new ArrayList();
- for(IGenerator generator : generators) {
- Class>[] supportedClasses = generator.getSupportedInternalInputDataType();
- for(Class> clazz : supportedClasses){
- if(clazz.equals(outputDataTypeClass)){
- foundGenerators.add(generator);
- }
-
- }
- }
-
- for(int i = 0; i0){
- ComplexDataDescriptionType supportedCreatedFormatAdditional = supportedtOutputFormat.addNewFormat();
- supportedCreatedFormatAdditional.setMimeType(supportedFormat);
- supportedCreatedFormatAdditional.setSchema(supportedSchemas[t]);
- supportedCreatedFormatAdditional.setEncoding(supportedEncodings[k]);
- }
- }
- }
-// if(supportedFormats.length==1 && supportedEncodings.length==1){
-// String supportedFormat = supportedFormats[j];
-// ComplexDataDescriptionType supportedCreatedFormat = supportedtOutputFormat.addNewFormat();
-// supportedCreatedFormat.setMimeType(supportedFormat);
-// supportedCreatedFormat.setEncoding(supportedEncodings[k]);
-// for(int t = 0; t0){
-// ComplexDataDescriptionType supportedCreatedFormatAdditional = supportedtOutputFormat.addNewFormat();
-// supportedCreatedFormatAdditional.setEncoding(supportedEncodings[k]);
-// supportedCreatedFormatAdditional.setMimeType(supportedFormat);
-// supportedCreatedFormatAdditional.setSchema(supportedSchemas[t]);
-// }
-// }
-// }
- }
- }
- }
- }
- }
- }
- LOGGER.info(document.toString());
- return document.getProcessDescriptions().getProcessDescriptionArray(0);
- }
-
- public BigInteger getMinOccurs(String identifier){
- return new BigInteger("1");
- }
- public BigInteger getMaxOccurs(String identifier){
- return new BigInteger("1");
- }
-
- public abstract List getInputIdentifiers();
- public abstract List getOutputIdentifiers();
-
-
-
- private List observers = new ArrayList();
-
- private Object state = null;
-
- public Object getState() {
- return state;
- }
-
- public void update(Object state) {
- if(Thread.currentThread().isInterrupted()){
- return;
- }
- this.state = state;
- notifyObservers();
- }
-
- public void addObserver(IObserver o) {
- observers.add(o);
- }
-
- public void removeObserver(IObserver o) {
- observers.remove(o);
- }
-
- public void notifyObservers() {
- Iterator i = observers.iterator();
- while (i.hasNext()) {
- IObserver o = (IObserver) i.next();
- o.update(this);
- }
- }
-
- @Override
- public List getErrors() {
- List errors = new ArrayList();
- return errors;
- }
-}
+package org.n52.wps.server;
+
+import java.lang.reflect.Constructor;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import net.opengis.ows.x11.DomainMetadataType;
+import net.opengis.wps.x100.ComplexDataCombinationType;
+import net.opengis.wps.x100.ComplexDataCombinationsType;
+import net.opengis.wps.x100.ComplexDataDescriptionType;
+import net.opengis.wps.x100.InputDescriptionType;
+import net.opengis.wps.x100.LiteralInputType;
+import net.opengis.wps.x100.LiteralOutputType;
+import net.opengis.wps.x100.OutputDescriptionType;
+import net.opengis.wps.x100.ProcessDescriptionType;
+import net.opengis.wps.x100.ProcessDescriptionType.DataInputs;
+import net.opengis.wps.x100.ProcessDescriptionType.ProcessOutputs;
+import net.opengis.wps.x100.ProcessDescriptionsDocument;
+import net.opengis.wps.x100.ProcessDescriptionsDocument.ProcessDescriptions;
+import net.opengis.wps.x100.SupportedComplexDataInputType;
+import net.opengis.wps.x100.SupportedComplexDataType;
+
+import org.apache.log4j.Logger;
+import org.n52.wps.io.GeneratorFactory;
+import org.n52.wps.io.IGenerator;
+import org.n52.wps.io.IParser;
+import org.n52.wps.io.ParserFactory;
+import org.n52.wps.io.data.IComplexData;
+import org.n52.wps.io.data.ILiteralData;
+import org.n52.wps.server.observerpattern.IObserver;
+import org.n52.wps.server.observerpattern.ISubject;
+
+
+public abstract class AbstractSelfDescribingAlgorithm extends AbstractAlgorithm implements ISubject{
+
+ private static Logger LOGGER = Logger.getLogger(AbstractSelfDescribingAlgorithm.class);
+ @Override
+ protected ProcessDescriptionType initializeDescription() {
+ ProcessDescriptionsDocument document = ProcessDescriptionsDocument.Factory.newInstance();
+ ProcessDescriptions processDescriptions = document.addNewProcessDescriptions();
+ ProcessDescriptionType processDescription = processDescriptions.addNewProcessDescription();
+ processDescription.setStatusSupported(true);
+ processDescription.setStoreSupported(true);
+ processDescription.setProcessVersion("1.0.0");
+
+ //1. Identifer
+ processDescription.addNewIdentifier().setStringValue(this.getClass().getName());
+ processDescription.addNewTitle().setStringValue(this.getClass().getCanonicalName());
+ //2. Inputs
+
+
+ List identifiers = this.getInputIdentifiers();
+ DataInputs dataInputs = null;
+ if(identifiers.size()>0){
+ dataInputs = processDescription.addNewDataInputs();
+ }
+
+ for(String identifier : identifiers){
+ InputDescriptionType dataInput = dataInputs.addNewInput();
+ dataInput.setMinOccurs(getMinOccurs(identifier));
+ dataInput.setMaxOccurs(getMaxOccurs(identifier));
+ dataInput.addNewIdentifier().setStringValue(identifier);
+ dataInput.addNewTitle().setStringValue(identifier);
+
+ Class> inputDataTypeClass = this.getInputDataType(identifier);
+ Class>[] interfaces = inputDataTypeClass.getInterfaces();
+
+ for(Class> implementedInterface : interfaces){
+ if(implementedInterface.equals(ILiteralData.class)){
+ LiteralInputType literalData = dataInput.addNewLiteralData();
+ String inputClassType = "";
+
+ Constructor>[] constructors = inputDataTypeClass.getConstructors();
+ for(Constructor> constructor : constructors){
+ Class>[] parameters = constructor.getParameterTypes();
+ if(parameters.length==1){
+ inputClassType = parameters[0].getSimpleName();
+ }
+ }
+
+ if(inputClassType.length()>0){
+ DomainMetadataType datatype = literalData.addNewDataType();
+ datatype.setReference("xs:"+inputClassType.toLowerCase());
+ literalData.addNewAnyValue();
+ }
+
+ }else if(implementedInterface.equals(IComplexData.class)){
+ SupportedComplexDataInputType complexData = dataInput.addNewComplexData();
+ ComplexDataCombinationType defaultInputFormat = complexData.addNewDefault();
+ ComplexDataCombinationsType supportedtInputFormat = complexData.addNewSupported();
+ List parsers = ParserFactory.getInstance().getAllParsers();
+ List foundParsers = new ArrayList();
+ for(IParser parser : parsers) {
+ Class>[] supportedClasses = parser.getSupportedInternalOutputDataType();
+ for(Class> clazz : supportedClasses){
+ if(clazz.equals(inputDataTypeClass)){
+ foundParsers.add(parser);
+ }
+
+ }
+ }
+
+ for(int i = 0; i0){
+ ComplexDataDescriptionType supportedCreatedFormatAdditional = supportedtInputFormat.addNewFormat();
+ supportedCreatedFormatAdditional.setEncoding(supportedEncodings[k]);
+ supportedCreatedFormatAdditional.setMimeType(supportedFormat);
+ supportedCreatedFormatAdditional.setSchema(supportedSchemas[t]);
+ }
+ }
+
+// if(supportedFormats.length==1 && supportedEncodings.length==1){
+// String supportedFormat = supportedFormats[j];
+// ComplexDataDescriptionType supportedCreatedFormat = supportedtInputFormat.addNewFormat();
+// supportedCreatedFormat.setMimeType(supportedFormat);
+// supportedCreatedFormat.setEncoding(supportedEncodings[k]);
+// for(int t = 0; t0){
+// ComplexDataDescriptionType supportedCreatedFormatAdditional = supportedtInputFormat.addNewFormat();
+// supportedCreatedFormatAdditional.setEncoding(supportedEncodings[k]);
+// supportedCreatedFormatAdditional.setMimeType(supportedFormat);
+// supportedCreatedFormatAdditional.setSchema(supportedSchemas[t]);
+// }
+// }
+// }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //3. Outputs
+ ProcessOutputs dataOutputs = processDescription.addNewProcessOutputs();
+ List outputIdentifiers = this.getOutputIdentifiers();
+ for(String identifier : outputIdentifiers){
+ OutputDescriptionType dataOutput = dataOutputs.addNewOutput();
+
+
+ dataOutput.addNewIdentifier().setStringValue(identifier);
+ dataOutput.addNewTitle().setStringValue(identifier);
+ dataOutput.addNewAbstract().setStringValue(identifier);
+
+ Class> outputDataTypeClass = this.getOutputDataType(identifier);
+ Class>[] interfaces = outputDataTypeClass.getInterfaces();
+
+ for(Class> implementedInterface : interfaces){
+
+
+ if(implementedInterface.equals(ILiteralData.class)){
+ LiteralOutputType literalData = dataOutput.addNewLiteralOutput();
+ String outputClassType = "";
+
+ Constructor>[] constructors = outputDataTypeClass.getConstructors();
+ for(Constructor> constructor : constructors){
+ Class>[] parameters = constructor.getParameterTypes();
+ if(parameters.length==1){
+ outputClassType = parameters[0].getSimpleName();
+ }
+ }
+
+ if(outputClassType.length()>0){
+ literalData.addNewDataType().setReference("xs:"+outputClassType.toLowerCase());
+ }
+
+
+ }else if(implementedInterface.equals(IComplexData.class)){
+
+ SupportedComplexDataType complexData = dataOutput.addNewComplexOutput();
+ ComplexDataCombinationType defaultInputFormat = complexData.addNewDefault();
+ ComplexDataCombinationsType supportedtOutputFormat = complexData.addNewSupported();
+
+ List generators = GeneratorFactory.getInstance().getAllGenerators();
+ List foundGenerators = new ArrayList();
+ for(IGenerator generator : generators) {
+ Class>[] supportedClasses = generator.getSupportedInternalInputDataType();
+ for(Class> clazz : supportedClasses){
+ if(clazz.equals(outputDataTypeClass)){
+ foundGenerators.add(generator);
+ }
+
+ }
+ }
+
+ for(int i = 0; i0){
+ ComplexDataDescriptionType supportedCreatedFormatAdditional = supportedtOutputFormat.addNewFormat();
+ supportedCreatedFormatAdditional.setMimeType(supportedFormat);
+ supportedCreatedFormatAdditional.setSchema(supportedSchemas[t]);
+ supportedCreatedFormatAdditional.setEncoding(supportedEncodings[k]);
+ }
+ }
+ }
+// if(supportedFormats.length==1 && supportedEncodings.length==1){
+// String supportedFormat = supportedFormats[j];
+// ComplexDataDescriptionType supportedCreatedFormat = supportedtOutputFormat.addNewFormat();
+// supportedCreatedFormat.setMimeType(supportedFormat);
+// supportedCreatedFormat.setEncoding(supportedEncodings[k]);
+// for(int t = 0; t0){
+// ComplexDataDescriptionType supportedCreatedFormatAdditional = supportedtOutputFormat.addNewFormat();
+// supportedCreatedFormatAdditional.setEncoding(supportedEncodings[k]);
+// supportedCreatedFormatAdditional.setMimeType(supportedFormat);
+// supportedCreatedFormatAdditional.setSchema(supportedSchemas[t]);
+// }
+// }
+// }
+ }
+ }
+ }
+ }
+ }
+ }
+ LOGGER.info(document.toString());
+ return document.getProcessDescriptions().getProcessDescriptionArray(0);
+ }
+
+ public BigInteger getMinOccurs(String identifier){
+ return new BigInteger("1");
+ }
+ public BigInteger getMaxOccurs(String identifier){
+ return new BigInteger("1");
+ }
+
+ public abstract List getInputIdentifiers();
+ public abstract List getOutputIdentifiers();
+
+
+
+ private List observers = new ArrayList();
+
+ private Object state = null;
+
+ public Object getState() {
+ return state;
+ }
+
+ public void update(Object state) {
+ if(Thread.currentThread().isInterrupted()){
+ return;
+ }
+ this.state = state;
+ notifyObservers();
+ }
+
+ public void addObserver(IObserver o) {
+ observers.add(o);
+ }
+
+ public void removeObserver(IObserver o) {
+ observers.remove(o);
+ }
+
+ public void notifyObservers() {
+ Iterator i = observers.iterator();
+ while (i.hasNext()) {
+ IObserver o = (IObserver) i.next();
+ o.update(this);
+ }
+ }
+
+ @Override
+ public List getErrors() {
+ List errors = new ArrayList();
+ return errors;
+ }
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/AbstractTransactionalAlgorithm.java b/52n-wps-server/src/main/java/org/n52/wps/server/AbstractTransactionalAlgorithm.java
index 94b353577..8367ceb69 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/AbstractTransactionalAlgorithm.java
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/AbstractTransactionalAlgorithm.java
@@ -3,6 +3,7 @@
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
+import java.util.Map;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
@@ -11,9 +12,11 @@
import org.apache.log4j.Logger;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlOptions;
+import org.n52.wps.io.data.IData;
import org.n52.wps.server.repository.DefaultTransactionalProcessRepository;
import org.n52.wps.server.request.ExecuteRequest;
import org.n52.wps.util.XMLUtils;
+
import net.opengis.wps.x100.AuditTraceType;
import net.opengis.wps.x100.ExecuteResponseDocument;
import net.opengis.wps.x100.ProcessDescriptionDocument;
@@ -23,7 +26,7 @@ public abstract class AbstractTransactionalAlgorithm implements IAlgorithm {
protected String algorithmID;
private static Logger LOGGER = Logger
- .getLogger(DefaultTransactionalProcessRepository.class);
+ .getLogger(AbstractTransactionalAlgorithm.class);
public AbstractTransactionalAlgorithm(String algorithmID) {
this.algorithmID = algorithmID;
@@ -34,7 +37,7 @@ public String getAlgorithmID() {
return algorithmID;
}
- public abstract HashMap run(ExecuteRequest document)
+ public abstract Map run(ExecuteRequest document)
throws ExceptionReport;
/** call the backend to cancel the task */
@@ -150,6 +153,7 @@ public static void storeAuditDocument(String instanceId,
String path = subPath + "WEB-INF/AuditDocuments/" + instanceId + ".xml";
try {
// TODO handling when exception occurs ...
+ LOGGER.debug("auditTraceType save in "+path);
auditTraceType.save(new File(path));
// XMLUtils.writeXmlFile((Document)auditTraceType.getDomNode(),
// path);
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/CapabilitiesConfiguration.java b/52n-wps-server/src/main/java/org/n52/wps/server/CapabilitiesConfiguration.java
index cc10a45d8..47a4767c1 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/CapabilitiesConfiguration.java
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/CapabilitiesConfiguration.java
@@ -139,8 +139,10 @@ private static void initSkeleton() throws XmlException, IOException {
process.setProcessVersion(processVersion);
process.setTitle(title);
}
- DataOfferings datas = capsSkeleton.getCapabilities().addNewDataOfferings();
+ DataOfferings datas = null;
for(String dataName : RepositoryManager.getInstance().getDatas()) {
+ if(datas==null) { datas=capsSkeleton.getCapabilities().addNewDataOfferings();
+ }
DataDescriptionType description = RepositoryManager.getInstance().getDataDescription(dataName);
if(description==null){
continue;
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/ICancelAlgorithm.java b/52n-wps-server/src/main/java/org/n52/wps/server/ICancelAlgorithm.java
new file mode 100644
index 000000000..974311379
--- /dev/null
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/ICancelAlgorithm.java
@@ -0,0 +1,7 @@
+package org.n52.wps.server;
+
+public interface ICancelAlgorithm {
+
+ public void cancel();
+ public String getInstanceId();
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/ITransactionalAlgorithm.java b/52n-wps-server/src/main/java/org/n52/wps/server/ITransactionalAlgorithm.java
new file mode 100644
index 000000000..b6c20ee83
--- /dev/null
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/ITransactionalAlgorithm.java
@@ -0,0 +1,15 @@
+package org.n52.wps.server;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.n52.wps.io.data.IData;
+
+public interface ITransactionalAlgorithm {
+
+ public void cancel();
+ Map run(Map> inputData) throws InterruptedException;
+ public String getAudit();
+
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/algorithm/importgrid/ImportData.java b/52n-wps-server/src/main/java/org/n52/wps/server/algorithm/importgrid/ImportData.java
deleted file mode 100644
index 66a93d338..000000000
--- a/52n-wps-server/src/main/java/org/n52/wps/server/algorithm/importgrid/ImportData.java
+++ /dev/null
@@ -1,421 +0,0 @@
-package org.n52.wps.server.algorithm.importgrid;
-
-import java.io.File;
-import java.security.MessageDigest;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.log4j.Logger;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.ApplicationType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.DataStagingType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDescriptionType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobIdentificationType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.impl.CreationFlagEnumerationImpl;
-import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.FileNameType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.POSIXApplicationDocument;
-import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.POSIXApplicationType;
-import org.n52.wps.PropertyDocument.Property;
-import org.n52.wps.commons.WPSConfig;
-import org.n52.wps.io.data.IData;
-import org.n52.wps.io.data.binding.complex.URLListDataBinding;
-import org.n52.wps.io.data.binding.literal.LiteralStringBinding;
-import org.n52.wps.server.AbstractSelfDescribingAlgorithm;
-import org.n52.wps.server.profiles.JavaSaga.SagaCallbackManager;
-
-import org.ogf.saga.context.Context;
-import org.ogf.saga.context.ContextFactory;
-import org.ogf.saga.error.BadParameterException;
-import org.ogf.saga.error.NoSuccessException;
-import org.ogf.saga.job.Job;
-import org.ogf.saga.monitoring.Metric;
-import org.ogf.saga.monitoring.Monitorable;
-import org.ogf.saga.session.Session;
-import org.ogf.saga.session.SessionFactory;
-import org.ogf.saga.url.URLFactory;
-import xint.esa.ssegrid.wps.javaSAGAProfile.URLListDocument;
-import xint.esa.ssegrid.wps.javaSAGAProfile.URLListDocument.URLList;
-
-import com.terradue.ogf.saga.impl.job.JobDescription;
-import com.terradue.ogf.saga.impl.job.JobFactory;
-import com.terradue.ogf.saga.impl.job.JobImpl;
-import com.terradue.ogf.saga.impl.job.JobServiceImpl;
-import com.terradue.ogf.schema.jsdl.JSDLFactory;
-import com.terradue.ssegrid.sagaext.JobServiceAssistant;
-import com.terradue.ssegrid.sagaext.MyProxyClient;
-import com.terradue.ssegrid.sagaext.ProcessingRegistry;
-
-public class ImportData extends AbstractSelfDescribingAlgorithm {
-
- private static Logger LOGGER = Logger.getLogger(ImportData.class);
-
- private static String GridFilesDir;
- private static String SagaLibDir;
- private static org.ogf.saga.url.URL GridmapGLUE;
- private ProcessingRegistry processingRegistry = null;
- private String WPSPublicationPrefix;
- private String DeployProcessDir;
-
- private String myProxyURL;
- private String myProxyUser;
- private String myProxyPassword;
-
-
- public List getInputIdentifiers() {
- List list = new ArrayList();
- list.add("sourceList");
- list.add("rootDir");
- return list;
- }
-
- public Class getInputDataType(String identifier) {
- if (identifier.equalsIgnoreCase("sourceList")) {
- return URLListDataBinding.class;
- }
- if (identifier.equalsIgnoreCase("rootDir")) {
- return LiteralStringBinding.class;
- }
- return null;
- }
-
- public List getOutputIdentifiers() {
- List list = new ArrayList();
- list.add("importedList");
- return list;
- }
-
- public Class getOutputDataType(String identifier) {
- if (identifier.equalsIgnoreCase("importedList")) {
- return URLListDataBinding.class;
- }
- return null;
- }
-
- public Map run(Map> inputData) {
- // create unique process instance id
-
- HashMap result = new HashMap();
- try {
- String pii = UUID.randomUUID().toString();
- // get JavaSaga Repository properties
- getSagaRepositoryProperties();
- // wps MAP
- // Initialize WPS Map
- String processID = "org.n52.wps.server.algorithm.importgrid.ImportData";
- HashMap WPSmap = new HashMap();
- WPSmap.put("WPS_DEPLOY_PROCESS_DIR", GridFilesDir
- + "deploy/process/");
- WPSmap.put("WPS_DEPLOY_AUXDATA_DIR", GridFilesDir
- + "deploy/auxdata/");
- WPSmap.put("WPS_JOB_INPUTS_DIR", GridFilesDir + "execute/"
- + processID + "/" + pii + "/${GAI_JOB_UID}/inputs");
- WPSmap.put("WPS_JOB_OUTPUTS_DIR", GridFilesDir + "execute/"
- + processID + "/" + pii + "/${GAI_JOB_UID}/outputs");
- WPSmap.put("WPS_JOB_AUDITS_DIR", GridFilesDir + "execute/"
- + processID + "/" + pii + "/${GAI_JOB_UID}/audits");
- WPSmap.put("WPS_JOB_RESULTS_DIR", GridFilesDir + "execute/"
- + processID + "/" + pii + "/${GAI_JOB_UID}/results");
- WPSmap.put("WPS_JOB_RESULTS_URL", WPSPublicationPrefix + processID
- + "/" + pii + "/${GAI_JOB_UID}/results");
- LOGGER.info("pii:" + pii);
- // load registry
- processingRegistry = new ProcessingRegistry(false);
- // Read inputs
- List sourceListData = inputData.get("sourceList");
- if (sourceListData == null || sourceListData.size() != 1) {
- throw new RuntimeException(
- "Error while allocating input parameters");
- }
- List rootDirData = inputData.get("rootDir");
- if (rootDirData == null || rootDirData.size() != 1) {
- throw new RuntimeException(
- "Error while allocating input parameters");
- }
- String rootDir = (String) rootDirData
- .get(0).getPayload();
- if(!rootDir.endsWith(File.separator)) {
- rootDir = rootDir + File.separator;
- }
- URLListDocument sourceListDoc = (URLListDocument) sourceListData
- .get(0).getPayload();
- // Retrieve this algorithm directory path
- String thisPath = this.getClass().getProtectionDomain()
- .getCodeSource().getLocation().toString();
- thisPath = thisPath.replaceFirst("file:", "");
- thisPath = thisPath.substring(0, thisPath.indexOf("WEB-INF"))
- + "WEB-INF";
- String thisDir = thisPath + File.separator + "TempJSDL";
- LOGGER.info("thisDir: " + thisDir);
- (new File(thisDir)).mkdirs();
- String dummyDir = GridFilesDir + "deploy/process/Copy/";
- String dummyPath = dummyDir + "copy.sh";
- (new File(dummyDir)).mkdirs();
- LOGGER.info("dummyPath: " + dummyPath);
- (new File(dummyPath)).createNewFile();
-
- // Construct the JSDL
-
- JobDefinitionDocument jsdlDoc = JobDefinitionDocument.Factory
- .newInstance();
- JobDescriptionType jsdlDec = jsdlDoc.addNewJobDefinition()
- .addNewJobDescription();
- JobIdentificationType jobId = jsdlDec.addNewJobIdentification();
- jobId.setJobName("ImportedData_${GAI_JOB_UID}");
- jobId.setDescription("Transfers a file (or a directory of files) from one Grid to another");
- jobId.addJobProject("SSEGrid");
- ApplicationType jobApp = jsdlDec.addNewApplication();
- POSIXApplicationDocument posix = POSIXApplicationDocument.Factory
- .newInstance();
-
- POSIXApplicationType posixApp = posix.addNewPOSIXApplication();
- FileNameType echo = FileNameType.Factory.newInstance();
- echo.setStringValue("copy.sh");
- posixApp.setExecutable(echo);
- // FileNameType stdin = FileNameType.Factory.newInstance();
- // stdin.setStringValue("stdin");
- // posixApp.setInput(stdin);
- FileNameType stdout = FileNameType.Factory.newInstance();
- stdout.setStringValue("stdout");
- posixApp.setOutput(stdout);
- FileNameType error = FileNameType.Factory.newInstance();
- error.setStringValue("stderr");
- posixApp.setError(error);
- org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.DirectoryNameType working = org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.DirectoryNameType.Factory
- .newInstance();
- working.setStringValue("${GAI_JOB_WORKING_DIR}");
- //posixApp.setWorkingDirectory(working);
- jobApp.set(posix);
- jobApp.setApplicationName("ImportedData");
- DataStagingType dummyStage = jsdlDec.addNewDataStaging();
- dummyStage.setFileName("${GAI_JOB_WORKING_DIR}/copy.sh");
- dummyStage.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- dummyStage.addNewSource().setURI(
- "${WPS_DEPLOY_PROCESS_DIR}Copy/copy.sh");
-
- DataStagingType exitStage = jsdlDec.addNewDataStaging();
- exitStage.setFileName("${GAI_JOB_WORKING_DIR}/exitMessage");
- exitStage.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- exitStage.addNewTarget().setURI(
- "${WPS_JOB_OUTPUTS_DIR}/exitMessage");
-
- DataStagingType outStage = jsdlDec.addNewDataStaging();
- outStage.setFileName("${GAI_JOB_WORKING_DIR}/stdout");
- outStage.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- outStage.addNewTarget().setURI("${WPS_JOB_OUTPUTS_DIR}/stdout");
-
- DataStagingType errStage = jsdlDec.addNewDataStaging();
- errStage.setFileName("${GAI_JOB_WORKING_DIR}/stderr");
- errStage.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- errStage.addNewTarget().setURI("${WPS_JOB_OUTPUTS_DIR}/stderr");
-
- // Modify jsdlDoc
- for (int i = 0; i < sourceListDoc.getURLList().getUrlArray().length; i++) {
- String sourceURL = sourceListDoc.getURLList().getUrlArray(i);
- //String subURL = sourceURL.substring(sourceURL.lastIndexOf(File.separator)+1);
- String subURL = sourceURL.substring(rootDir.length());
- String destinationURL = subURL;
- DataStagingType staging = jsdlDoc.getJobDefinition()
- .getJobDescription().addNewDataStaging();
- staging.setFileName(destinationURL);
- staging.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- staging.setDeleteOnTermination(false);
- staging.addNewSource().setURI(sourceURL);
- //DataStagingType staging2 = jsdlDoc.getJobDefinition()
- //.getJobDescription().addNewDataStaging();
- /**
- staging2.setFileName(subURL);
- staging2.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- staging2.setDeleteOnTermination(true);
- staging2.addNewTarget().setURI(destinationURL);
- */
- }
- LOGGER.info("jsdl: " + jsdlDoc.toString());
- File jsdlModifiedFile = new File(thisDir + File.separator + "jsdl_"
- + pii + ".xml");
- jsdlDoc.save(jsdlModifiedFile);
- LOGGER.info("written modified file: " + jsdlModifiedFile.getPath());
-
- Session session = SessionFactory.createSession(false);
- Context context = ContextFactory.createContext("globus");
- context.setAttribute(Context.USERPROXY, GridFilesDir + "proxy");
- session.addContext(context);
- // Get delegation to that user proxy and set propoerly context
- MyProxyClient.delegateProxyFromMyProxyServer(myProxyURL, 7512,
- myProxyUser, myProxyPassword, 604800, context);
- JobServiceImpl js = JobFactory.createJobService(session/*
- * ,
- * gridmapGLUE
- */);
- JobServiceAssistant jsa = new JobServiceAssistant(js);
- jsa.addSubstitutionVariables(WPSmap);
- JobDescription jd = (JobDescription) JobFactory
- .createJobDescription(JSDLFactory
- .createJSDLDocument(jsdlModifiedFile));
- // jsa.substituteSimpleInputs(jd, (Map)(new
- // HashMap()));
- JobImpl jobs = null;
- jobs = (JobImpl) ((JobServiceImpl) js).createJob(jd);
- // create now the job execute dirs
- String inputsDir = jobs
- .getSubstitutedVariable("WPS_JOB_INPUTS_DIR");
- String outputsDir = jobs
- .getSubstitutedVariable("WPS_JOB_OUTPUTS_DIR");
- String auditsDir = jobs
- .getSubstitutedVariable("WPS_JOB_AUDITS_DIR");
- String resultsDir = jobs
- .getSubstitutedVariable("WPS_JOB_RESULTS_DIR");
-
- (new File(inputsDir)).mkdirs();
- (new File(outputsDir)).mkdirs();
- (new File(auditsDir)).mkdirs();
- (new File(resultsDir)).mkdirs();
- (new File(resultsDir)).setWritable(true, false);
- // Create all destination directories and create output URL list
-
- jobs.addCallback(Job.JOB_STATE, new SagaCallbackManager());
- jobs.addCallback(Job.JOB_STATEDETAIL, new SagaCallbackManager());
- LOGGER.info("run");
- jobs.run();
- LOGGER.info("wait...");
- jobs.waitFor();
- LOGGER.info("done");
- String importedDir = "/EODATA/RESULTS_DIRS/"+jobs.getId();
- LOGGER.info("importeddir:"+importedDir);
- URLListDocument importedDataDoc = URLListDocument.Factory.newInstance();
- URLList urlList = importedDataDoc.addNewURLList();
- urlList.setCount(sourceListDoc.getURLList().getCount());
-
- for (int i = 0; i < sourceListDoc.getURLList().getUrlArray().length; i++) {
- String sourceURL = sourceListDoc.getURLList().getUrlArray(i);
- String subURL = sourceURL.substring(rootDir.length());
- //sourceURL.substring(sourceURL.lastIndexOf(File.separator)+1);
- String destinationURL = resultsDir+File.separator+subURL;
- File destinationFile= new File(destinationURL);
- destinationFile.mkdirs();
- destinationFile.setWritable(true,false);
- urlList.addUrl(importedDir+File.separator+subURL);
- }
- boolean exitFault = false;
- String[][] exitMessages;
- exitMessages = jsa.readExitMessages(jobs);
- for (String[] exitMessage : exitMessages) {
- if (!exitMessage[0].trim().equals("0")) {
- exitFault = true;
- break;
- }
- }
- result.put("importedList", new URLListDataBinding(importedDataDoc));
- } catch (Exception e) {
- e.printStackTrace();
- LOGGER.info("Exception: " + e.getMessage());
- throw new RuntimeException(e);
- }
- return result;
-
- }
-
- private void getSagaRepositoryProperties() throws BadParameterException,
- NoSuccessException {
- Property[] properties = WPSConfig.getInstance()
- .getPropertiesForRepositoryName("JavaSagaRepository");
- Property WPSSaga = WPSConfig.getInstance().getPropertyForKey(
- properties, "GridFilesDir");
- if (WPSSaga == null) {
- throw new RuntimeException(
- "Error. Could not find the required GridFilesDir property in wps_config.xml");
- }
- GridFilesDir = WPSSaga.getStringValue();
- Property sagaLibProp = WPSConfig.getInstance().getPropertyForKey(
- properties, "SagaLibDir");
- if (sagaLibProp == null) {
- throw new RuntimeException(
- "Error. Could not find the required SagaLibDir property in wps_config.xml");
- }
- SagaLibDir = (sagaLibProp.getStringValue());
- Property wpsPublicRoot = WPSConfig.getInstance().getPropertyForKey(
- properties, "WPSPublicationPrefix");
- if (wpsPublicRoot == null) {
- throw new RuntimeException(
- "Error. Could not find WPSPublicationPrefix");
- }
- WPSPublicationPrefix = wpsPublicRoot.getStringValue();
-
- // Set the deployement process directory
- DeployProcessDir = (GridFilesDir + "deploy/process/");
- Property gridmap = WPSConfig.getInstance().getPropertyForKey(
- properties, "GridGlue");
- if (gridmap == null) {
- throw new RuntimeException(
- "Error. Could not find the required GridGlue property in wps_config.xml");
- }
- // Saga.location must be loaded before the following line
- GridmapGLUE = URLFactory.createURL(gridmap.getStringValue());
- // Note system properties must already be set by a previous run
- Property myProxyURLProp = WPSConfig.getInstance().getPropertyForKey(
- properties, "MyProxyURL");
- if (myProxyURLProp == null) {
- throw new RuntimeException(
- "Error. Could not find the required MyProxyUser property in wps_config.xml");
- }
- myProxyURL = myProxyURLProp.getStringValue();
-
- Property myProxyUserProp = WPSConfig.getInstance().getPropertyForKey(
- properties, "MyProxyUser");
- if (myProxyUserProp == null) {
- throw new RuntimeException(
- "Error. Could not find the required MyProxyUser property in wps_config.xml");
- }
- myProxyUser = myProxyUserProp.getStringValue();
-
- Property myProxyPasswordProp = WPSConfig.getInstance()
- .getPropertyForKey(properties, "MyProxyPassword");
- if (myProxyPasswordProp == null) {
- throw new RuntimeException(
- "Error. Could not find the required MyProxyUser property in wps_config.xml");
- }
- myProxyPassword = myProxyPasswordProp.getStringValue();
-
- }
-
- // Callback monitors job.
- public boolean cb(Monitorable m, Metric metric, Context ctxt) {
- try {
- String value = metric.getAttribute(Metric.VALUE);
- String name = metric.getAttribute(Metric.NAME);
- System.out.println("Callback called for metric " + name
- + ", value = " + value);
- } catch (Throwable e) {
- System.err.println("error" + e);
- e.printStackTrace(System.err);
- }
- // Keep the callback.
- return true;
- }
-
- public void setMyProxyURL(String myProxyURL) {
- this.myProxyURL = myProxyURL;
- }
-
- public String getMyProxyURL() {
- return myProxyURL;
- }
-
- public void setMyProxyUser(String myProxyUser) {
- this.myProxyUser = myProxyUser;
- }
-
- public String getMyProxyUser() {
- return myProxyUser;
- }
-
- public void setMyProxyPassword(String myProxyPassword) {
- this.myProxyPassword = myProxyPassword;
- }
-
- public String getMyProxyPassword() {
- return myProxyPassword;
- }
-}
\ No newline at end of file
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/algorithm/importgrid/ImportData2.java b/52n-wps-server/src/main/java/org/n52/wps/server/algorithm/importgrid/ImportData2.java
deleted file mode 100644
index c28390315..000000000
--- a/52n-wps-server/src/main/java/org/n52/wps/server/algorithm/importgrid/ImportData2.java
+++ /dev/null
@@ -1,407 +0,0 @@
-package org.n52.wps.server.algorithm.importgrid;
-
-import java.io.File;
-import java.security.MessageDigest;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.log4j.Logger;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.ApplicationType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.DataStagingType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDescriptionType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobIdentificationType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.impl.CreationFlagEnumerationImpl;
-import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.FileNameType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.POSIXApplicationDocument;
-import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.POSIXApplicationType;
-import org.n52.wps.PropertyDocument.Property;
-import org.n52.wps.commons.WPSConfig;
-import org.n52.wps.io.data.IData;
-import org.n52.wps.io.data.binding.complex.URLListDataBinding;
-import org.n52.wps.io.data.binding.literal.LiteralStringBinding;
-import org.n52.wps.server.AbstractSelfDescribingAlgorithm;
-import org.n52.wps.server.profiles.JavaSaga.SagaCallbackManager;
-
-import org.ogf.saga.context.Context;
-import org.ogf.saga.context.ContextFactory;
-import org.ogf.saga.error.BadParameterException;
-import org.ogf.saga.error.NoSuccessException;
-import org.ogf.saga.job.Job;
-import org.ogf.saga.monitoring.Metric;
-import org.ogf.saga.monitoring.Monitorable;
-import org.ogf.saga.session.Session;
-import org.ogf.saga.session.SessionFactory;
-import org.ogf.saga.url.URLFactory;
-import xint.esa.ssegrid.wps.javaSAGAProfile.URLListDocument;
-import xint.esa.ssegrid.wps.javaSAGAProfile.URLListDocument.URLList;
-
-import com.terradue.ogf.saga.impl.job.JobDescription;
-import com.terradue.ogf.saga.impl.job.JobFactory;
-import com.terradue.ogf.saga.impl.job.JobImpl;
-import com.terradue.ogf.saga.impl.job.JobServiceImpl;
-import com.terradue.ogf.schema.jsdl.JSDLFactory;
-import com.terradue.ssegrid.sagaext.JobServiceAssistant;
-import com.terradue.ssegrid.sagaext.MyProxyClient;
-import com.terradue.ssegrid.sagaext.ProcessingRegistry;
-
-public class ImportData2 extends AbstractSelfDescribingAlgorithm {
-
- private static Logger LOGGER = Logger.getLogger(ImportData2.class);
-
- private static String GridFilesDir;
- private static String SagaLibDir;
- private static org.ogf.saga.url.URL GridmapGLUE;
- private ProcessingRegistry processingRegistry = null;
- private String WPSPublicationPrefix;
- private String DeployProcessDir;
-
- private String myProxyURL;
- private String myProxyUser;
- private String myProxyPassword;
-
-
- public List getInputIdentifiers() {
- List list = new ArrayList();
- list.add("sourceList");
- return list;
- }
-
- public Class getInputDataType(String identifier) {
- if (identifier.equalsIgnoreCase("sourceList")) {
- return URLListDataBinding.class;
- }
- return null;
- }
-
- public List getOutputIdentifiers() {
- List list = new ArrayList();
- list.add("importedList");
- return list;
- }
-
- public Class getOutputDataType(String identifier) {
- if (identifier.equalsIgnoreCase("importedList")) {
- return URLListDataBinding.class;
- }
- return null;
- }
-
- public Map run(Map> inputData) {
- // create unique process instance id
-
- HashMap result = new HashMap();
- try {
- String pii = UUID.randomUUID().toString();
- // get JavaSaga Repository properties
- getSagaRepositoryProperties();
- // wps MAP
- // Initialize WPS Map
- String processID = "org.n52.wps.server.algorithm.importgrid.ImportData2";
- HashMap WPSmap = new HashMap();
- WPSmap.put("WPS_DEPLOY_PROCESS_DIR", GridFilesDir
- + "deploy/process/");
- WPSmap.put("WPS_DEPLOY_AUXDATA_DIR", GridFilesDir
- + "deploy/auxdata/");
- WPSmap.put("WPS_JOB_INPUTS_DIR", GridFilesDir + "execute/"
- + processID + "/" + pii + "/${GAI_JOB_UID}/inputs");
- WPSmap.put("WPS_JOB_OUTPUTS_DIR", GridFilesDir + "execute/"
- + processID + "/" + pii + "/${GAI_JOB_UID}/outputs");
- WPSmap.put("WPS_JOB_AUDITS_DIR", GridFilesDir + "execute/"
- + processID + "/" + pii + "/${GAI_JOB_UID}/audits");
- WPSmap.put("WPS_JOB_RESULTS_DIR", GridFilesDir + "execute/"
- + processID + "/" + pii + "/${GAI_JOB_UID}/results");
- WPSmap.put("WPS_JOB_RESULTS_URL", WPSPublicationPrefix + processID
- + "/" + pii + "/${GAI_JOB_UID}/results");
- LOGGER.info("pii:" + pii);
- // load registry
- processingRegistry = new ProcessingRegistry(false);
- // Read inputs
- List sourceListData = inputData.get("sourceList");
- if (sourceListData == null || sourceListData.size() != 1) {
- throw new RuntimeException(
- "Error while allocating input parameters");
- }
-
- URLListDocument sourceListDoc = (URLListDocument) sourceListData
- .get(0).getPayload();
- // Retrieve this algorithm directory path
- String thisPath = this.getClass().getProtectionDomain()
- .getCodeSource().getLocation().toString();
- thisPath = thisPath.replaceFirst("file:", "");
- thisPath = thisPath.substring(0, thisPath.indexOf("WEB-INF"))
- + "WEB-INF";
- String thisDir = thisPath + File.separator + "TempJSDL";
- LOGGER.info("thisDir: " + thisDir);
- (new File(thisDir)).mkdirs();
- String dummyDir = GridFilesDir + "deploy/process/Copy/";
- String dummyPath = dummyDir + "copy.sh";
- (new File(dummyDir)).mkdirs();
- LOGGER.info("dummyPath: " + dummyPath);
- (new File(dummyPath)).createNewFile();
-
- // Construct the JSDL
-
- JobDefinitionDocument jsdlDoc = JobDefinitionDocument.Factory
- .newInstance();
- JobDescriptionType jsdlDec = jsdlDoc.addNewJobDefinition()
- .addNewJobDescription();
- JobIdentificationType jobId = jsdlDec.addNewJobIdentification();
- jobId.setJobName("ImportedData_${GAI_JOB_UID}");
- jobId.setDescription("Transfers a file (or a directory of files) from one Grid to another");
- jobId.addJobProject("SSEGrid");
- ApplicationType jobApp = jsdlDec.addNewApplication();
- POSIXApplicationDocument posix = POSIXApplicationDocument.Factory
- .newInstance();
-
- POSIXApplicationType posixApp = posix.addNewPOSIXApplication();
- FileNameType echo = FileNameType.Factory.newInstance();
- echo.setStringValue("copy.sh");
- posixApp.setExecutable(echo);
- // FileNameType stdin = FileNameType.Factory.newInstance();
- // stdin.setStringValue("stdin");
- // posixApp.setInput(stdin);
- FileNameType stdout = FileNameType.Factory.newInstance();
- stdout.setStringValue("stdout");
- posixApp.setOutput(stdout);
- FileNameType error = FileNameType.Factory.newInstance();
- error.setStringValue("stderr");
- posixApp.setError(error);
- org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.DirectoryNameType working = org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.DirectoryNameType.Factory
- .newInstance();
- working.setStringValue("${GAI_JOB_WORKING_DIR}");
- //posixApp.setWorkingDirectory(working);
- jobApp.set(posix);
- jobApp.setApplicationName("ImportedData");
- DataStagingType dummyStage = jsdlDec.addNewDataStaging();
- dummyStage.setFileName("${GAI_JOB_WORKING_DIR}/copy.sh");
- dummyStage.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- dummyStage.addNewSource().setURI(
- "${WPS_DEPLOY_PROCESS_DIR}Copy/copy.sh");
-
- DataStagingType exitStage = jsdlDec.addNewDataStaging();
- exitStage.setFileName("${GAI_JOB_WORKING_DIR}/exitMessage");
- exitStage.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- exitStage.addNewTarget().setURI(
- "${WPS_JOB_OUTPUTS_DIR}/exitMessage");
-
- DataStagingType outStage = jsdlDec.addNewDataStaging();
- outStage.setFileName("${GAI_JOB_WORKING_DIR}/stdout");
- outStage.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- outStage.addNewTarget().setURI("${WPS_JOB_OUTPUTS_DIR}/stdout");
-
- DataStagingType errStage = jsdlDec.addNewDataStaging();
- errStage.setFileName("${GAI_JOB_WORKING_DIR}/stderr");
- errStage.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- errStage.addNewTarget().setURI("${WPS_JOB_OUTPUTS_DIR}/stderr");
-
- // Modify jsdlDoc
- for (int i = 0; i < sourceListDoc.getURLList().getUrlArray().length; i++) {
- String sourceURL = sourceListDoc.getURLList().getUrlArray(i);
- String subURL = sourceURL.substring(sourceURL.lastIndexOf(File.separator)+1);
-
- String destinationURL = "${GAI_JOB_RESULTS_DIR}/"+subURL;
- DataStagingType staging = jsdlDoc.getJobDefinition()
- .getJobDescription().addNewDataStaging();
- staging.setFileName(subURL);
- staging.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- staging.setDeleteOnTermination(false);
- staging.addNewSource().setURI(sourceURL);
- //DataStagingType staging2 = jsdlDoc.getJobDefinition()
- //.getJobDescription().addNewDataStaging();
- /**
- staging2.setFileName(subURL);
- staging2.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- staging2.setDeleteOnTermination(true);
- staging2.addNewTarget().setURI(destinationURL);
- */
- }
- LOGGER.info("jsdl: " + jsdlDoc.toString());
- File jsdlModifiedFile = new File(thisDir + File.separator + "jsdl_"
- + pii + ".xml");
- jsdlDoc.save(jsdlModifiedFile);
- LOGGER.info("written modified file: " + jsdlModifiedFile.getPath());
-
- Session session = SessionFactory.createSession(false);
- Context context = ContextFactory.createContext("globus");
- context.setAttribute(Context.USERPROXY, GridFilesDir + "proxy");
- session.addContext(context);
- // Get delegation to that user proxy and set propoerly context
- MyProxyClient.delegateProxyFromMyProxyServer(myProxyURL, 7512,
- myProxyUser, myProxyPassword, 604800, context);
- JobServiceImpl js = JobFactory.createJobService(session/*
- * ,
- * gridmapGLUE
- */);
- JobServiceAssistant jsa = new JobServiceAssistant(js);
- jsa.addSubstitutionVariables(WPSmap);
- JobDescription jd = (JobDescription) JobFactory
- .createJobDescription(JSDLFactory
- .createJSDLDocument(jsdlModifiedFile));
- // jsa.substituteSimpleInputs(jd, (Map)(new
- // HashMap()));
- JobImpl jobs = null;
- jobs = (JobImpl) ((JobServiceImpl) js).createJob(jd);
- // create now the job execute dirs
- String inputsDir = jobs
- .getSubstitutedVariable("WPS_JOB_INPUTS_DIR");
- String outputsDir = jobs
- .getSubstitutedVariable("WPS_JOB_OUTPUTS_DIR");
- String auditsDir = jobs
- .getSubstitutedVariable("WPS_JOB_AUDITS_DIR");
- String resultsDir = jobs
- .getSubstitutedVariable("WPS_JOB_RESULTS_DIR");
-
- (new File(inputsDir)).mkdirs();
- (new File(outputsDir)).mkdirs();
- (new File(auditsDir)).mkdirs();
- (new File(resultsDir)).mkdirs();
- (new File(resultsDir)).setWritable(true, false);
- // Create all destination directories and create output URL list
-
- jobs.addCallback(Job.JOB_STATE, new SagaCallbackManager());
- jobs.addCallback(Job.JOB_STATEDETAIL, new SagaCallbackManager());
- LOGGER.info("run");
- jobs.run();
- LOGGER.info("wait...");
- jobs.waitFor();
- LOGGER.info("done");
- String importedDir = "/EODATA/RESULTS_DIRS/"+jobs.getId();
- LOGGER.info("importeddir:"+importedDir);
- URLListDocument importedDataDoc = URLListDocument.Factory.newInstance();
- URLList urlList = importedDataDoc.addNewURLList();
- urlList.setCount(sourceListDoc.getURLList().getCount());
-
- for (int i = 0; i < sourceListDoc.getURLList().getUrlArray().length; i++) {
- String sourceURL = sourceListDoc.getURLList().getUrlArray(i);
- String subURL = sourceURL.substring(sourceURL.lastIndexOf(File.separator)+1);
- String destinationURL = resultsDir+File.separator+subURL;
- File destinationFile= new File(destinationURL);
- destinationFile.mkdirs();
- destinationFile.setWritable(true,false);
- urlList.addUrl(importedDir+File.separator+subURL);
- }
- boolean exitFault = false;
- String[][] exitMessages;
- exitMessages = jsa.readExitMessages(jobs);
- for (String[] exitMessage : exitMessages) {
- if (!exitMessage[0].trim().equals("0")) {
- exitFault = true;
- break;
- }
- }
- result.put("importedList", new URLListDataBinding(importedDataDoc));
- } catch (Exception e) {
- e.printStackTrace();
- LOGGER.info("Exception: " + e.getMessage());
- throw new RuntimeException(e);
- }
- return result;
-
- }
-
- private void getSagaRepositoryProperties() throws BadParameterException,
- NoSuccessException {
- Property[] properties = WPSConfig.getInstance()
- .getPropertiesForRepositoryName("JavaSagaRepository");
- Property WPSSaga = WPSConfig.getInstance().getPropertyForKey(
- properties, "GridFilesDir");
- if (WPSSaga == null) {
- throw new RuntimeException(
- "Error. Could not find the required GridFilesDir property in wps_config.xml");
- }
- GridFilesDir = WPSSaga.getStringValue();
- Property sagaLibProp = WPSConfig.getInstance().getPropertyForKey(
- properties, "SagaLibDir");
- if (sagaLibProp == null) {
- throw new RuntimeException(
- "Error. Could not find the required SagaLibDir property in wps_config.xml");
- }
- SagaLibDir = (sagaLibProp.getStringValue());
- Property wpsPublicRoot = WPSConfig.getInstance().getPropertyForKey(
- properties, "WPSPublicationPrefix");
- if (wpsPublicRoot == null) {
- throw new RuntimeException(
- "Error. Could not find WPSPublicationPrefix");
- }
- WPSPublicationPrefix = wpsPublicRoot.getStringValue();
-
- // Set the deployement process directory
- DeployProcessDir = (GridFilesDir + "deploy/process/");
- Property gridmap = WPSConfig.getInstance().getPropertyForKey(
- properties, "GridGlue");
- if (gridmap == null) {
- throw new RuntimeException(
- "Error. Could not find the required GridGlue property in wps_config.xml");
- }
- // Saga.location must be loaded before the following line
- GridmapGLUE = URLFactory.createURL(gridmap.getStringValue());
- // Note system properties must already be set by a previous run
- Property myProxyURLProp = WPSConfig.getInstance().getPropertyForKey(
- properties, "MyProxyURL");
- if (myProxyURLProp == null) {
- throw new RuntimeException(
- "Error. Could not find the required MyProxyUser property in wps_config.xml");
- }
- myProxyURL = myProxyURLProp.getStringValue();
-
- Property myProxyUserProp = WPSConfig.getInstance().getPropertyForKey(
- properties, "MyProxyUser");
- if (myProxyUserProp == null) {
- throw new RuntimeException(
- "Error. Could not find the required MyProxyUser property in wps_config.xml");
- }
- myProxyUser = myProxyUserProp.getStringValue();
-
- Property myProxyPasswordProp = WPSConfig.getInstance()
- .getPropertyForKey(properties, "MyProxyPassword");
- if (myProxyPasswordProp == null) {
- throw new RuntimeException(
- "Error. Could not find the required MyProxyUser property in wps_config.xml");
- }
- myProxyPassword = myProxyPasswordProp.getStringValue();
-
- }
-
- // Callback monitors job.
- public boolean cb(Monitorable m, Metric metric, Context ctxt) {
- try {
- String value = metric.getAttribute(Metric.VALUE);
- String name = metric.getAttribute(Metric.NAME);
- System.out.println("Callback called for metric " + name
- + ", value = " + value);
- } catch (Throwable e) {
- System.err.println("error" + e);
- e.printStackTrace(System.err);
- }
- // Keep the callback.
- return true;
- }
-
- public void setMyProxyURL(String myProxyURL) {
- this.myProxyURL = myProxyURL;
- }
-
- public String getMyProxyURL() {
- return myProxyURL;
- }
-
- public void setMyProxyUser(String myProxyUser) {
- this.myProxyUser = myProxyUser;
- }
-
- public String getMyProxyUser() {
- return myProxyUser;
- }
-
- public void setMyProxyPassword(String myProxyPassword) {
- this.myProxyPassword = myProxyPassword;
- }
-
- public String getMyProxyPassword() {
- return myProxyPassword;
- }
-}
\ No newline at end of file
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/algorithm/intergrid/GridDataTransfer.java b/52n-wps-server/src/main/java/org/n52/wps/server/algorithm/intergrid/GridDataTransfer.java
deleted file mode 100644
index d401e5138..000000000
--- a/52n-wps-server/src/main/java/org/n52/wps/server/algorithm/intergrid/GridDataTransfer.java
+++ /dev/null
@@ -1,391 +0,0 @@
-package org.n52.wps.server.algorithm.intergrid;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.UUID;
-
-import org.apache.log4j.Logger;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.ApplicationType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.DataStagingType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDescriptionType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobIdentificationType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.impl.CreationFlagEnumerationImpl;
-import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.FileNameType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.POSIXApplicationDocument;
-import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.POSIXApplicationType;
-import org.n52.wps.PropertyDocument.Property;
-import org.n52.wps.commons.WPSConfig;
-import org.n52.wps.io.data.IData;
-import org.n52.wps.io.data.binding.complex.URLListDataBinding;
-import org.n52.wps.io.data.binding.literal.LiteralStringBinding;
-import org.n52.wps.server.AbstractSelfDescribingAlgorithm;
-import org.n52.wps.server.profiles.JavaSaga.SagaCallbackManager;
-
-import org.ogf.saga.context.Context;
-import org.ogf.saga.context.ContextFactory;
-import org.ogf.saga.error.BadParameterException;
-import org.ogf.saga.error.NoSuccessException;
-import org.ogf.saga.job.Job;
-import org.ogf.saga.monitoring.Metric;
-import org.ogf.saga.monitoring.Monitorable;
-import org.ogf.saga.session.Session;
-import org.ogf.saga.session.SessionFactory;
-import org.ogf.saga.url.URLFactory;
-import xint.esa.ssegrid.wps.javaSAGAProfile.URLListDocument;
-
-import com.terradue.ogf.saga.impl.job.JobDescription;
-import com.terradue.ogf.saga.impl.job.JobFactory;
-import com.terradue.ogf.saga.impl.job.JobImpl;
-import com.terradue.ogf.saga.impl.job.JobServiceImpl;
-import com.terradue.ogf.schema.jsdl.JSDLFactory;
-import com.terradue.ssegrid.sagaext.JobServiceAssistant;
-import com.terradue.ssegrid.sagaext.MyProxyClient;
-import com.terradue.ssegrid.sagaext.ProcessingRegistry;
-
-public class GridDataTransfer extends AbstractSelfDescribingAlgorithm {
-
- private static Logger LOGGER = Logger.getLogger(GridDataTransfer.class);
-
- private static String GridFilesDir;
- private static String SagaLibDir;
- private static org.ogf.saga.url.URL GridmapGLUE;
- private ProcessingRegistry processingRegistry = null;
- private String WPSPublicationPrefix;
- private String DeployProcessDir;
-
- private String myProxyURL;
- private String myProxyUser;
- private String myProxyPassword;
-
-
- public List getInputIdentifiers() {
- List list = new ArrayList();
- list.add("sourceList");
- list.add("destinationList");
- return list;
- }
-
- public Class getInputDataType(String identifier) {
- if (identifier.equalsIgnoreCase("sourceList")
- || identifier.equalsIgnoreCase("destinationList")) {
- return URLListDataBinding.class;
- }
- return null;
- }
-
- public List getOutputIdentifiers() {
- List list = new ArrayList();
- list.add("output");
- return list;
- }
-
- public Class getOutputDataType(String identifier) {
- if (identifier.equalsIgnoreCase("output")) {
- return LiteralStringBinding.class;
- }
- return null;
- }
-
- public Map run(Map> inputData) {
- // create unique process instance id
-
- HashMap result = new HashMap();
- try {
- String pii = UUID.randomUUID().toString();
- // get JavaSaga Repository properties
- getSagaRepositoryProperties();
- // wps MAP
- // Initialize WPS Map
- String processID = "GridDataTransfer";
- HashMap WPSmap = new HashMap();
- WPSmap.put("WPS_DEPLOY_PROCESS_DIR", GridFilesDir
- + "deploy/process/");
- WPSmap.put("WPS_DEPLOY_AUXDATA_DIR", GridFilesDir
- + "deploy/auxdata/");
- WPSmap.put("WPS_JOB_INPUTS_DIR", GridFilesDir + "execute/"
- + processID + "/" + pii + "/${GAI_JOB_UID}/inputs");
- WPSmap.put("WPS_JOB_OUTPUTS_DIR", GridFilesDir + "execute/"
- + processID + "/" + pii + "/${GAI_JOB_UID}/outputs");
- WPSmap.put("WPS_JOB_AUDITS_DIR", GridFilesDir + "execute/"
- + processID + "/" + pii + "/${GAI_JOB_UID}/audits");
- WPSmap.put("WPS_JOB_RESULTS_DIR", GridFilesDir + "execute/"
- + processID + "/" + pii + "/${GAI_JOB_UID}/results");
- WPSmap.put("WPS_JOB_RESULTS_URL", WPSPublicationPrefix + processID
- + "/" + pii + "/${GAI_JOB_UID}/results");
- LOGGER.info("pii:" + pii);
- // load registry
- processingRegistry = new ProcessingRegistry(false);
- // Read inputs
- List sourceListData = inputData.get("sourceList");
- if (sourceListData == null || sourceListData.size() != 1) {
- throw new RuntimeException(
- "Error while allocating input parameters");
- }
- List destinationListData = inputData.get("destinationList");
- if (destinationListData == null || destinationListData.size() != 1) {
- throw new RuntimeException(
- "Error while allocating input parameters");
- }
- URLListDocument sourceListDoc = (URLListDocument) sourceListData
- .get(0).getPayload();
- URLListDocument destinationListDoc = (URLListDocument) destinationListData
- .get(0).getPayload();
- // Retrieve this algorithm directory path
- String thisPath = this.getClass().getProtectionDomain()
- .getCodeSource().getLocation().toString();
- thisPath = thisPath.replaceFirst("file:", "");
- thisPath = thisPath.substring(0, thisPath.indexOf("WEB-INF"))
- + "WEB-INF";
- String thisDir = thisPath + File.separator + "TempJSDL";
- LOGGER.info("thisDir: " + thisDir);
- (new File(thisDir)).mkdirs();
- String dummyDir = GridFilesDir + "deploy/process/Dummy/";
- String dummyPath = dummyDir + "dummy.sh";
- (new File(dummyDir)).mkdirs();
- LOGGER.info("dummyPath: " + dummyPath);
- (new File(dummyPath)).createNewFile();
-
- // Construct the JSDL
-
- JobDefinitionDocument jsdlDoc = JobDefinitionDocument.Factory
- .newInstance();
- JobDescriptionType jsdlDec = jsdlDoc.addNewJobDefinition()
- .addNewJobDescription();
- JobIdentificationType jobId = jsdlDec.addNewJobIdentification();
- jobId.setJobName("GridDataTransfer_${GAI_JOB_UID}");
- jobId.setDescription("Transfers a file (or a directory of files) from one Grid to another");
- jobId.addJobProject("SSEGrid");
- ApplicationType jobApp = jsdlDec.addNewApplication();
- POSIXApplicationDocument posix = POSIXApplicationDocument.Factory
- .newInstance();
-
- POSIXApplicationType posixApp = posix.addNewPOSIXApplication();
- FileNameType echo = FileNameType.Factory.newInstance();
- echo.setStringValue("dummy.sh");
- posixApp.setExecutable(echo);
- // FileNameType stdin = FileNameType.Factory.newInstance();
- // stdin.setStringValue("stdin");
- // posixApp.setInput(stdin);
- FileNameType stdout = FileNameType.Factory.newInstance();
- stdout.setStringValue("stdout");
- posixApp.setOutput(stdout);
- FileNameType error = FileNameType.Factory.newInstance();
- error.setStringValue("stderr");
- posixApp.setError(error);
- org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.DirectoryNameType working = org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.DirectoryNameType.Factory
- .newInstance();
- working.setStringValue("${GAI_JOB_WORKING_DIR}");
- //posixApp.setWorkingDirectory(working);
- jobApp.set(posix);
- jobApp.setApplicationName("GridDataTransfer");
- DataStagingType dummyStage = jsdlDec.addNewDataStaging();
- dummyStage.setFileName("${GAI_JOB_WORKING_DIR}/dummy.sh");
- dummyStage.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- dummyStage.addNewSource().setURI(
- "${WPS_DEPLOY_PROCESS_DIR}Dummy/dummy.sh");
-
- DataStagingType exitStage = jsdlDec.addNewDataStaging();
- exitStage.setFileName("exitMessage");
- exitStage.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- exitStage.addNewTarget().setURI(
- "${WPS_JOB_OUTPUTS_DIR}/exitMessage");
-
- DataStagingType outStage = jsdlDec.addNewDataStaging();
- outStage.setFileName("stdout");
- outStage.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- outStage.addNewTarget().setURI("${WPS_JOB_OUTPUTS_DIR}/stdout");
-
- DataStagingType errStage = jsdlDec.addNewDataStaging();
- errStage.setFileName("stderr");
- errStage.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- errStage.addNewTarget().setURI("${WPS_JOB_OUTPUTS_DIR}/stderr");
-
- // Modify jsdlDoc
- for (int i = 0; i < sourceListDoc.getURLList().getUrlArray().length; i++) {
- String sourceURL = sourceListDoc.getURLList().getUrlArray(i);
- String destinationURL = destinationListDoc.getURLList()
- .getUrlArray(i);
- DataStagingType staging = jsdlDoc.getJobDefinition()
- .getJobDescription().addNewDataStaging();
- staging.setFileName(sourceURL.substring(sourceURL.lastIndexOf(File.separator)+1));
- staging.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- staging.setDeleteOnTermination(true);
- staging.addNewSource().setURI(sourceURL);
- DataStagingType staging2 = jsdlDoc.getJobDefinition()
- .getJobDescription().addNewDataStaging();
- staging2.setFileName(sourceURL.substring(sourceURL.lastIndexOf(File.separator)+1));
- staging2.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- staging2.setDeleteOnTermination(true);
- staging2.addNewTarget().setURI(destinationURL);
- }
- LOGGER.info("jsdl: " + jsdlDoc.toString());
- File jsdlModifiedFile = new File(thisDir + File.separator + "jsdl_"
- + pii + ".xml");
- jsdlDoc.save(jsdlModifiedFile);
- LOGGER.info("written modified file: " + jsdlModifiedFile.getPath());
-
- Session session = SessionFactory.createSession(false);
- Context context = ContextFactory.createContext("globus");
- context.setAttribute(Context.USERPROXY, GridFilesDir + "proxy");
- session.addContext(context);
- // Get delegation to that user proxy and set propoerly context
- MyProxyClient.delegateProxyFromMyProxyServer(myProxyURL, 7512,
- myProxyUser, myProxyPassword, 604800, context);
- JobServiceImpl js = JobFactory.createJobService(session/*
- * ,
- * gridmapGLUE
- */);
- JobServiceAssistant jsa = new JobServiceAssistant(js);
- jsa.addSubstitutionVariables(WPSmap);
- JobDescription jd = (JobDescription) JobFactory
- .createJobDescription(JSDLFactory
- .createJSDLDocument(jsdlModifiedFile));
- // jsa.substituteSimpleInputs(jd, (Map)(new
- // HashMap()));
- JobImpl jobs = null;
- jobs = (JobImpl) ((JobServiceImpl) js).createJob(jd);
- // create now the job execute dirs
- String inputsDir = jobs
- .getSubstitutedVariable("WPS_JOB_INPUTS_DIR");
- String outputsDir = jobs
- .getSubstitutedVariable("WPS_JOB_OUTPUTS_DIR");
- String auditsDir = jobs
- .getSubstitutedVariable("WPS_JOB_AUDITS_DIR");
- String resultsDir = jobs
- .getSubstitutedVariable("WPS_JOB_RESULTS_DIR");
- (new File(inputsDir)).mkdirs();
- (new File(outputsDir)).mkdirs();
- (new File(auditsDir)).mkdirs();
- (new File(resultsDir)).mkdirs();
- (new File(resultsDir)).setWritable(true, false);
- jobs.addCallback(Job.JOB_STATE, new SagaCallbackManager());
- jobs.addCallback(Job.JOB_STATEDETAIL, new SagaCallbackManager());
- jobs.run();
- jobs.waitFor();
- boolean exitFault = false;
- String[][] exitMessages;
- exitMessages = jsa.readExitMessages(jobs);
- for (String[] exitMessage : exitMessages) {
- if (!exitMessage[0].trim().equals("0")) {
- exitFault = true;
- break;
- }
- }
- result.put("output", new LiteralStringBinding("Successful"));
- } catch (Exception e) {
- e.printStackTrace();
- LOGGER.info("Exception: " + e.getMessage());
- throw new RuntimeException(e);
- }
- return result;
-
- }
-
- private void getSagaRepositoryProperties() throws BadParameterException,
- NoSuccessException {
- Property[] properties = WPSConfig.getInstance()
- .getPropertiesForRepositoryName("JavaSagaRepository");
- Property WPSSaga = WPSConfig.getInstance().getPropertyForKey(
- properties, "GridFilesDir");
- if (WPSSaga == null) {
- throw new RuntimeException(
- "Error. Could not find the required GridFilesDir property in wps_config.xml");
- }
- GridFilesDir = WPSSaga.getStringValue();
- Property sagaLibProp = WPSConfig.getInstance().getPropertyForKey(
- properties, "SagaLibDir");
- if (sagaLibProp == null) {
- throw new RuntimeException(
- "Error. Could not find the required SagaLibDir property in wps_config.xml");
- }
- SagaLibDir = (sagaLibProp.getStringValue());
- Property wpsPublicRoot = WPSConfig.getInstance().getPropertyForKey(
- properties, "WPSPublicationPrefix");
- if (wpsPublicRoot == null) {
- throw new RuntimeException(
- "Error. Could not find WPSPublicationPrefix");
- }
- WPSPublicationPrefix = wpsPublicRoot.getStringValue();
-
- // Set the deployement process directory
- DeployProcessDir = (GridFilesDir + "deploy/process/");
- Property gridmap = WPSConfig.getInstance().getPropertyForKey(
- properties, "GridGlue");
- if (gridmap == null) {
- throw new RuntimeException(
- "Error. Could not find the required GridGlue property in wps_config.xml");
- }
- // Saga.location must be loaded before the following line
- GridmapGLUE = URLFactory.createURL(gridmap.getStringValue());
- // Note system properties must already be set by a previous run
- Property myProxyURLProp = WPSConfig.getInstance().getPropertyForKey(
- properties, "MyProxyURL");
- if (myProxyURLProp == null) {
- throw new RuntimeException(
- "Error. Could not find the required MyProxyUser property in wps_config.xml");
- }
- myProxyURL = myProxyURLProp.getStringValue();
-
- Property myProxyUserProp = WPSConfig.getInstance().getPropertyForKey(
- properties, "MyProxyUser");
- if (myProxyUserProp == null) {
- throw new RuntimeException(
- "Error. Could not find the required MyProxyUser property in wps_config.xml");
- }
- myProxyUser = myProxyUserProp.getStringValue();
-
- Property myProxyPasswordProp = WPSConfig.getInstance()
- .getPropertyForKey(properties, "MyProxyPassword");
- if (myProxyPasswordProp == null) {
- throw new RuntimeException(
- "Error. Could not find the required MyProxyUser property in wps_config.xml");
- }
- myProxyPassword = myProxyPasswordProp.getStringValue();
-
- }
-
- // Callback monitors job.
- public boolean cb(Monitorable m, Metric metric, Context ctxt) {
- try {
- String value = metric.getAttribute(Metric.VALUE);
- String name = metric.getAttribute(Metric.NAME);
- System.out.println("Callback called for metric " + name
- + ", value = " + value);
- } catch (Throwable e) {
- System.err.println("error" + e);
- e.printStackTrace(System.err);
- }
- // Keep the callback.
- return true;
- }
-
- public void setMyProxyURL(String myProxyURL) {
- this.myProxyURL = myProxyURL;
- }
-
- public String getMyProxyURL() {
- return myProxyURL;
- }
-
- public void setMyProxyUser(String myProxyUser) {
- this.myProxyUser = myProxyUser;
- }
-
- public String getMyProxyUser() {
- return myProxyUser;
- }
-
- public void setMyProxyPassword(String myProxyPassword) {
- this.myProxyPassword = myProxyPassword;
- }
-
- public String getMyProxyPassword() {
- return myProxyPassword;
- }
-}
\ No newline at end of file
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/algorithm/intergrid/description.xml b/52n-wps-server/src/main/java/org/n52/wps/server/algorithm/intergrid/description.xml
deleted file mode 100644
index e999f63f4..000000000
--- a/52n-wps-server/src/main/java/org/n52/wps/server/algorithm/intergrid/description.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
- GridDataTransfer
- GridDataTransfer Process
- Transfers files from one Grid to another
-
-
- sourceList
- List of source URLs
- List of URLs of source files (or directories) to be
- copied.
-
-
-
- text/xml
- http://ssegrid.esa.int/wps/JavaSAGAProfile
-
-
-
-
- text/xml
- http://ssegrid.esa.int/wps/JavaSAGAProfile
-
-
-
-
-
- destinationList
- List of destination URLs
- List of URLs of destination files (or directories) to
- be copied.
-
-
-
- text/xml
- http://ssegrid.esa.int/wps/JavaSAGAProfile
-
-
-
-
- text/xml
- http://ssegrid.esa.int/wps/JavaSAGAProfile
-
-
-
-
-
-
-
-
-
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/algorithm/intergrid/jsdl.xml b/52n-wps-server/src/main/java/org/n52/wps/server/algorithm/intergrid/jsdl.xml
deleted file mode 100644
index 59b54325d..000000000
--- a/52n-wps-server/src/main/java/org/n52/wps/server/algorithm/intergrid/jsdl.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
- GridDataTransfer_${GAI_JOB_UID}
- Transfers a file (or a directory of files) from one Grid to another.
- SSEGrid
-
-
-
- GridDataTransfer
-
- echo
- stdin
- stdout
- stderr
- ${GAI_JOB_WORKING_DIR}
-
-
-
-
-
- exitMessage
- overwrite
-
- ${WPS_JOB_OUTPUTS_DIR}/exitMessage
-
-
-
-
- stdout
- overwrite
-
- ${WPS_JOB_AUDITS_DIR}/stdout
-
-
-
-
- stderr
- overwrite
-
- ${WPS_JOB_AUDITS_DIR}/stderr
-
-
-
-
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/algorithm/publishgrid/PublishData.java b/52n-wps-server/src/main/java/org/n52/wps/server/algorithm/publishgrid/PublishData.java
deleted file mode 100644
index b46317352..000000000
--- a/52n-wps-server/src/main/java/org/n52/wps/server/algorithm/publishgrid/PublishData.java
+++ /dev/null
@@ -1,418 +0,0 @@
-package org.n52.wps.server.algorithm.publishgrid;
-
-import java.io.File;
-import java.security.MessageDigest;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.UUID;
-
-import org.apache.log4j.Logger;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.ApplicationType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.DataStagingType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDescriptionType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobIdentificationType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.impl.CreationFlagEnumerationImpl;
-import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.FileNameType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.POSIXApplicationDocument;
-import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.POSIXApplicationType;
-import org.n52.wps.PropertyDocument.Property;
-import org.n52.wps.commons.WPSConfig;
-import org.n52.wps.io.data.IData;
-import org.n52.wps.io.data.binding.complex.URLListDataBinding;
-import org.n52.wps.io.data.binding.literal.LiteralStringBinding;
-import org.n52.wps.server.AbstractSelfDescribingAlgorithm;
-import org.n52.wps.server.profiles.JavaSaga.SagaCallbackManager;
-
-import org.ogf.saga.context.Context;
-import org.ogf.saga.context.ContextFactory;
-import org.ogf.saga.error.BadParameterException;
-import org.ogf.saga.error.NoSuccessException;
-import org.ogf.saga.job.Job;
-import org.ogf.saga.monitoring.Metric;
-import org.ogf.saga.monitoring.Monitorable;
-import org.ogf.saga.session.Session;
-import org.ogf.saga.session.SessionFactory;
-import org.ogf.saga.url.URLFactory;
-import xint.esa.ssegrid.wps.javaSAGAProfile.URLListDocument;
-import xint.esa.ssegrid.wps.javaSAGAProfile.URLListDocument.URLList;
-
-import com.terradue.ogf.saga.impl.job.JobDescription;
-import com.terradue.ogf.saga.impl.job.JobFactory;
-import com.terradue.ogf.saga.impl.job.JobImpl;
-import com.terradue.ogf.saga.impl.job.JobServiceImpl;
-import com.terradue.ogf.schema.jsdl.JSDLFactory;
-import com.terradue.ssegrid.sagaext.JobServiceAssistant;
-import com.terradue.ssegrid.sagaext.MyProxyClient;
-import com.terradue.ssegrid.sagaext.ProcessingRegistry;
-
-public class PublishData extends AbstractSelfDescribingAlgorithm {
-
- private static Logger LOGGER = Logger.getLogger(PublishData.class);
-
- private static String GridFilesDir;
- private static String SagaLibDir;
- private static org.ogf.saga.url.URL GridmapGLUE;
- private ProcessingRegistry processingRegistry = null;
- private String WPSPublicationPrefix;
- private String DeployProcessDir;
- private String myProxyURL;
- private String myProxyUser;
- private String myProxyPassword;
-
-
- public List getInputIdentifiers() {
- List list = new ArrayList();
- list.add("sourceList");
- list.add("rootDir");
- return list;
- }
-
- public Class getInputDataType(String identifier) {
- if (identifier.equalsIgnoreCase("sourceList")) {
- return URLListDataBinding.class;
- }
- if (identifier.equalsIgnoreCase("rootDir")) {
- return LiteralStringBinding.class;
- }
- return null;
- }
-
- public List getOutputIdentifiers() {
- List list = new ArrayList();
- list.add("publishedList");
- return list;
- }
-
- public Class getOutputDataType(String identifier) {
- if (identifier.equalsIgnoreCase("publishedList")) {
- return URLListDataBinding.class;
- }
- return null;
- }
-
- public Map run(Map> inputData) {
- // create unique process instance id
-
- HashMap result = new HashMap();
- try {
- String pii = UUID.randomUUID().toString();
- // get JavaSaga Repository properties
- getSagaRepositoryProperties();
- // wps MAP
- // Initialize WPS Map
- String processID = "PublishData";
- HashMap WPSmap = new HashMap();
- WPSmap.put("WPS_DEPLOY_PROCESS_DIR", GridFilesDir
- + "deploy/process/");
- WPSmap.put("WPS_DEPLOY_AUXDATA_DIR", GridFilesDir
- + "deploy/auxdata/");
- WPSmap.put("WPS_JOB_INPUTS_DIR", GridFilesDir + "execute/"
- + processID + "/" + pii + "/${GAI_JOB_UID}/inputs");
- WPSmap.put("WPS_JOB_OUTPUTS_DIR", GridFilesDir + "execute/"
- + processID + "/" + pii + "/${GAI_JOB_UID}/outputs");
- WPSmap.put("WPS_JOB_AUDITS_DIR", GridFilesDir + "execute/"
- + processID + "/" + pii + "/${GAI_JOB_UID}/audits");
- WPSmap.put("WPS_JOB_RESULTS_DIR", GridFilesDir + "execute/"
- + processID + "/" + pii + "/${GAI_JOB_UID}/results");
- WPSmap.put("WPS_JOB_RESULTS_URL", WPSPublicationPrefix + "execute/"+ processID
- + "/" + pii + "/${GAI_JOB_UID}/results");
- LOGGER.info("pii:" + pii);
- // load registry
- processingRegistry = new ProcessingRegistry(false);
- // Read inputs
- List sourceListData = inputData.get("sourceList");
- if (sourceListData == null || sourceListData.size() != 1) {
- throw new RuntimeException(
- "Error while allocating input parameters");
- }
- List rootDirData = inputData.get("rootDir");
- if (rootDirData == null || rootDirData.size() != 1) {
- throw new RuntimeException(
- "Error while allocating input parameters");
- }
- URLListDocument sourceListDoc = (URLListDocument) sourceListData
- .get(0).getPayload();
- String rootDir = (String) rootDirData
- .get(0).getPayload();
- if(!rootDir.endsWith(File.separator)) {
- rootDir = rootDir + File.separator;
- }
- // Retrieve this algorithm directory path
- String thisPath = this.getClass().getProtectionDomain()
- .getCodeSource().getLocation().toString();
- thisPath = thisPath.replaceFirst("file:", "");
- thisPath = thisPath.substring(0, thisPath.indexOf("WEB-INF"))
- + "WEB-INF";
- String thisDir = thisPath + File.separator + "TempJSDL";
- LOGGER.info("thisDir: " + thisDir);
- (new File(thisDir)).mkdirs();
- String dummyDir = GridFilesDir + "deploy/process/Dummy/";
- String dummyPath = dummyDir + "dummy.sh";
- (new File(dummyDir)).mkdirs();
- LOGGER.info("dummyPath: " + dummyPath);
- (new File(dummyPath)).createNewFile();
-
- // Construct the JSDL
-
- JobDefinitionDocument jsdlDoc = JobDefinitionDocument.Factory
- .newInstance();
- JobDescriptionType jsdlDec = jsdlDoc.addNewJobDefinition()
- .addNewJobDescription();
- JobIdentificationType jobId = jsdlDec.addNewJobIdentification();
- jobId.setJobName("PublishData_${GAI_JOB_UID}");
- jobId.setDescription("Transfers a file (or a directory of files) from one Grid to another");
- jobId.addJobProject("SSEGrid");
- ApplicationType jobApp = jsdlDec.addNewApplication();
- POSIXApplicationDocument posix = POSIXApplicationDocument.Factory
- .newInstance();
-
- POSIXApplicationType posixApp = posix.addNewPOSIXApplication();
- FileNameType echo = FileNameType.Factory.newInstance();
- echo.setStringValue("dummy.sh");
- posixApp.setExecutable(echo);
- // FileNameType stdin = FileNameType.Factory.newInstance();
- // stdin.setStringValue("stdin");
- // posixApp.setInput(stdin);
- FileNameType stdout = FileNameType.Factory.newInstance();
- stdout.setStringValue("stdout");
- posixApp.setOutput(stdout);
- FileNameType error = FileNameType.Factory.newInstance();
- error.setStringValue("stderr");
- posixApp.setError(error);
- org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.DirectoryNameType working = org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.DirectoryNameType.Factory
- .newInstance();
- working.setStringValue("${GAI_JOB_WORKING_DIR}");
- //posixApp.setWorkingDirectory(working);
- jobApp.set(posix);
- jobApp.setApplicationName("PublishData");
- DataStagingType dummyStage = jsdlDec.addNewDataStaging();
- dummyStage.setFileName("${GAI_JOB_WORKING_DIR}/dummy.sh");
- dummyStage.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- dummyStage.addNewSource().setURI(
- "${WPS_DEPLOY_PROCESS_DIR}Dummy/dummy.sh");
-
- DataStagingType exitStage = jsdlDec.addNewDataStaging();
- exitStage.setFileName("${GAI_JOB_WORKING_DIR}/exitMessage");
- exitStage.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- exitStage.addNewTarget().setURI(
- "${WPS_JOB_OUTPUTS_DIR}/exitMessage");
-
- DataStagingType outStage = jsdlDec.addNewDataStaging();
- outStage.setFileName("${GAI_JOB_WORKING_DIR}/stdout");
- outStage.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- outStage.addNewTarget().setURI("${WPS_JOB_OUTPUTS_DIR}/stdout");
-
- DataStagingType errStage = jsdlDec.addNewDataStaging();
- errStage.setFileName("${GAI_JOB_WORKING_DIR}/stderr");
- errStage.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- errStage.addNewTarget().setURI("${WPS_JOB_OUTPUTS_DIR}/stderr");
-
- // Modify jsdlDoc
- for (int i = 0; i < sourceListDoc.getURLList().getUrlArray().length; i++) {
- String sourceURL = sourceListDoc.getURLList().getUrlArray(i);
- String subURL = sourceURL.substring(rootDir.length());
- MessageDigest subHash = MessageDigest.getInstance("SHA");
- String hashFile = java.net.URLEncoder.encode("TrFile"+subHash.digest(subURL.getBytes()).toString()+".tmp", "UTF-8");
- String destinationURL = "${WPS_JOB_RESULTS_DIR}/"+subURL;
- DataStagingType staging = jsdlDoc.getJobDefinition()
- .getJobDescription().addNewDataStaging();
- staging.setFileName(hashFile);
- staging.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- staging.setDeleteOnTermination(true);
- staging.addNewSource().setURI(sourceURL);
- DataStagingType staging2 = jsdlDoc.getJobDefinition()
- .getJobDescription().addNewDataStaging();
- staging2.setFileName(hashFile);
- staging2.setCreationFlag(CreationFlagEnumerationImpl.OVERWRITE);
- staging2.setDeleteOnTermination(true);
- staging2.addNewTarget().setURI(destinationURL);
- }
- LOGGER.info("jsdl: " + jsdlDoc.toString());
- File jsdlModifiedFile = new File(thisDir + File.separator + "jsdl_"
- + pii + ".xml");
- jsdlDoc.save(jsdlModifiedFile);
- LOGGER.info("written modified file: " + jsdlModifiedFile.getPath());
-
- Session session = SessionFactory.createSession(false);
- Context context = ContextFactory.createContext("globus");
- context.setAttribute(Context.USERPROXY, GridFilesDir + "proxy");
- session.addContext(context);
- // Get delegation to that user proxy and set propoerly context
- MyProxyClient.delegateProxyFromMyProxyServer(myProxyURL, 7512,
- myProxyUser, myProxyPassword, 604800, context);
- JobServiceImpl js = JobFactory.createJobService(session/*
- * ,
- * gridmapGLUE
- */);
- JobServiceAssistant jsa = new JobServiceAssistant(js);
- jsa.addSubstitutionVariables(WPSmap);
- JobDescription jd = (JobDescription) JobFactory
- .createJobDescription(JSDLFactory
- .createJSDLDocument(jsdlModifiedFile));
- // jsa.substituteSimpleInputs(jd, (Map)(new
- // HashMap()));
- JobImpl jobs = null;
- jobs = (JobImpl) ((JobServiceImpl) js).createJob(jd);
- // create now the job execute dirs
- String inputsDir = jobs
- .getSubstitutedVariable("WPS_JOB_INPUTS_DIR");
- String outputsDir = jobs
- .getSubstitutedVariable("WPS_JOB_OUTPUTS_DIR");
- String auditsDir = jobs
- .getSubstitutedVariable("WPS_JOB_AUDITS_DIR");
- String resultsDir = jobs
- .getSubstitutedVariable("WPS_JOB_RESULTS_DIR");
- String publishedDir = jobs
- .getSubstitutedVariable("WPS_JOB_RESULTS_URL");
- (new File(inputsDir)).mkdirs();
- (new File(outputsDir)).mkdirs();
- (new File(auditsDir)).mkdirs();
- (new File(resultsDir)).mkdirs();
- (new File(resultsDir)).setWritable(true, false);
- // Create all destination directories and create output URL list
- URLListDocument publishedDataDoc = URLListDocument.Factory.newInstance();
- URLList urlList = publishedDataDoc.addNewURLList();
- urlList.setCount(sourceListDoc.getURLList().getCount());
- for (int i = 0; i < sourceListDoc.getURLList().getUrlArray().length; i++) {
- String sourceURL = sourceListDoc.getURLList().getUrlArray(i);
- String subURL = sourceURL.substring(rootDir.length());
- if(subURL.startsWith(File.separator)) {
- subURL = subURL.substring(1);
- }
- String subURLDir = subURL.substring(0, subURL.lastIndexOf(File.separator)+1);
- String destinationURL = resultsDir+File.separator+subURLDir;
- File destinationFile= new File(destinationURL);
- destinationFile.mkdirs();
- destinationFile.setWritable(true,false);
- urlList.addUrl(publishedDir+ File.separator+subURL);
- }
- jobs.addCallback(Job.JOB_STATE, new SagaCallbackManager());
- jobs.addCallback(Job.JOB_STATEDETAIL, new SagaCallbackManager());
- jobs.run();
- jobs.waitFor();
- boolean exitFault = false;
- String[][] exitMessages;
- exitMessages = jsa.readExitMessages(jobs);
- for (String[] exitMessage : exitMessages) {
- if (!exitMessage[0].trim().equals("0")) {
- exitFault = true;
- break;
- }
- }
- result.put("publishedList", new URLListDataBinding(publishedDataDoc));
- } catch (Exception e) {
- e.printStackTrace();
- LOGGER.info("Exception: " + e.getMessage());
- throw new RuntimeException(e);
- }
- return result;
-
- }
-
- private void getSagaRepositoryProperties() throws BadParameterException,
- NoSuccessException {
- Property[] properties = WPSConfig.getInstance()
- .getPropertiesForRepositoryName("JavaSagaRepository");
- Property WPSSaga = WPSConfig.getInstance().getPropertyForKey(
- properties, "GridFilesDir");
- if (WPSSaga == null) {
- throw new RuntimeException(
- "Error. Could not find the required GridFilesDir property in wps_config.xml");
- }
- GridFilesDir = WPSSaga.getStringValue();
- Property sagaLibProp = WPSConfig.getInstance().getPropertyForKey(
- properties, "SagaLibDir");
- if (sagaLibProp == null) {
- throw new RuntimeException(
- "Error. Could not find the required SagaLibDir property in wps_config.xml");
- }
- SagaLibDir = (sagaLibProp.getStringValue());
- Property wpsPublicRoot = WPSConfig.getInstance().getPropertyForKey(
- properties, "WPSPublicationPrefix");
- if (wpsPublicRoot == null) {
- throw new RuntimeException(
- "Error. Could not find WPSPublicationPrefix");
- }
- WPSPublicationPrefix = wpsPublicRoot.getStringValue();
-
- // Set the deployement process directory
- DeployProcessDir = (GridFilesDir + "deploy/process/");
- Property gridmap = WPSConfig.getInstance().getPropertyForKey(
- properties, "GridGlue");
- if (gridmap == null) {
- throw new RuntimeException(
- "Error. Could not find the required GridGlue property in wps_config.xml");
- }
- // Saga.location must be loaded before the following line
- GridmapGLUE = URLFactory.createURL(gridmap.getStringValue());
- // Note system properties must already be set by a previous run
- Property myProxyURLProp = WPSConfig.getInstance().getPropertyForKey(
- properties, "MyProxyURL");
- if (myProxyURLProp == null) {
- throw new RuntimeException(
- "Error. Could not find the required MyProxyUser property in wps_config.xml");
- }
- myProxyURL = myProxyURLProp.getStringValue();
-
- Property myProxyUserProp = WPSConfig.getInstance().getPropertyForKey(
- properties, "MyProxyUser");
- if (myProxyUserProp == null) {
- throw new RuntimeException(
- "Error. Could not find the required MyProxyUser property in wps_config.xml");
- }
- myProxyUser = myProxyUserProp.getStringValue();
-
- Property myProxyPasswordProp = WPSConfig.getInstance()
- .getPropertyForKey(properties, "MyProxyPassword");
- if (myProxyPasswordProp == null) {
- throw new RuntimeException(
- "Error. Could not find the required MyProxyUser property in wps_config.xml");
- }
- myProxyPassword = myProxyPasswordProp.getStringValue();
-
- }
-
- // Callback monitors job.
- public boolean cb(Monitorable m, Metric metric, Context ctxt) {
- try {
- String value = metric.getAttribute(Metric.VALUE);
- String name = metric.getAttribute(Metric.NAME);
- System.out.println("Callback called for metric " + name
- + ", value = " + value);
- } catch (Throwable e) {
- System.err.println("error" + e);
- e.printStackTrace(System.err);
- }
- // Keep the callback.
- return true;
- }
-
- public void setMyProxyURL(String myProxyURL) {
- this.myProxyURL = myProxyURL;
- }
-
- public String getMyProxyURL() {
- return myProxyURL;
- }
-
- public void setMyProxyUser(String myProxyUser) {
- this.myProxyUser = myProxyUser;
- }
-
- public String getMyProxyUser() {
- return myProxyUser;
- }
-
- public void setMyProxyPassword(String myProxyPassword) {
- this.myProxyPassword = myProxyPassword;
- }
-
- public String getMyProxyPassword() {
- return myProxyPassword;
- }
-}
\ No newline at end of file
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/feed/movingcode/AlgorithmDescription.xsd b/52n-wps-server/src/main/java/org/n52/wps/server/feed/movingcode/AlgorithmDescription.xsd
index 19be46fad..0e99366a3 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/feed/movingcode/AlgorithmDescription.xsd
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/feed/movingcode/AlgorithmDescription.xsd
@@ -1,110 +1,110 @@
-
-
-
-
- Deployment Description for a WPS Algorithm
-
-
-
-
-
- URL pointing to the workspace root, e.g. "file://level1/level2/workspaceX"
-
-
-
-
- URL pointing to the algorithm; relative to the workspace root. If appropriate, this location can point to some location within the container, e.g. "algorithm://executables/tools.tbx?mytools/tool2"
-
-
-
-
- URN referencing the specific container, e.g. urn:n52:wps:algorithmcontainer:arctoolbox:9.3
-
-
-
-
- URN referencing a required processing backend, e.g. urn:n52:wps:gpsystem:arcgis:9.3
-
-
-
-
- A collection of the algorithm parameters
-
-
-
-
-
- The tool's parameters
-
-
-
-
- A string that acts as a seperator between parameters, e.g. " " for SPACE
-
-
-
-
-
- If true, this tool's parameters are indexed through their position as integers. Otherwise, the mapping from the ows:Identifier to the respective LegacyID is done via name strings.
-
-
-
-
-
-
-
-
-
-
- Structure for a parameter description.
-
-
-
-
- A prefix string that shall be added before this parameter, e.g. "-p("
-
-
-
-
- A suffix string that shall be added before this parameter, e.g. ")"
-
-
-
-
- A string that acts as a separator between individual parameter values, e.g. " " for SPACE
-
-
-
-
- The Legacy ID by which the parameters are defined in the Legacy environment. Use legacyIntID for sequential parameters, legacyStrindID for parameters name strings
-
-
-
-
-
-
- The WPS Input ID this parameter shall be mapped to.
-
-
-
-
- The WPS Output ID this parameter shall be mapped to.
-
-
-
-
-
-
-
- Positive integer indicationg the position of this parameter.
-
-
-
-
-
-
- String indicating the name of this parameter.
-
-
-
-
+
+
+
+
+ Deployment Description for a WPS Algorithm
+
+
+
+
+
+ URL pointing to the workspace root, e.g. "file://level1/level2/workspaceX"
+
+
+
+
+ URL pointing to the algorithm; relative to the workspace root. If appropriate, this location can point to some location within the container, e.g. "algorithm://executables/tools.tbx?mytools/tool2"
+
+
+
+
+ URN referencing the specific container, e.g. urn:n52:wps:algorithmcontainer:arctoolbox:9.3
+
+
+
+
+ URN referencing a required processing backend, e.g. urn:n52:wps:gpsystem:arcgis:9.3
+
+
+
+
+ A collection of the algorithm parameters
+
+
+
+
+
+ The tool's parameters
+
+
+
+
+ A string that acts as a seperator between parameters, e.g. " " for SPACE
+
+
+
+
+
+ If true, this tool's parameters are indexed through their position as integers. Otherwise, the mapping from the ows:Identifier to the respective LegacyID is done via name strings.
+
+
+
+
+
+
+
+
+
+
+ Structure for a parameter description.
+
+
+
+
+ A prefix string that shall be added before this parameter, e.g. "-p("
+
+
+
+
+ A suffix string that shall be added before this parameter, e.g. ")"
+
+
+
+
+ A string that acts as a separator between individual parameter values, e.g. " " for SPACE
+
+
+
+
+ The Legacy ID by which the parameters are defined in the Legacy environment. Use legacyIntID for sequential parameters, legacyStrindID for parameters name strings
+
+
+
+
+
+
+ The WPS Input ID this parameter shall be mapped to.
+
+
+
+
+ The WPS Output ID this parameter shall be mapped to.
+
+
+
+
+
+
+
+ Positive integer indicationg the position of this parameter.
+
+
+
+
+
+
+ String indicating the name of this parameter.
+
+
+
+
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/handler/RequestHandler.java b/52n-wps-server/src/main/java/org/n52/wps/server/handler/RequestHandler.java
index 1b734b06d..fb6e3b8cb 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/handler/RequestHandler.java
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/handler/RequestHandler.java
@@ -301,12 +301,14 @@ public void handle() throws ExceptionReport {
ExceptionReport exceptionReport = null;
try {
+ LOGGER.debug("submit the task for execution");
// submit the task for execution
- pool.addTask(task);
- // set status to accepted
status.setProcessAccepted("Request is queued for execution.");
task.getRequest().getExecuteResponseBuilder().setStatus(status);
+ pool.addTask(task);
+ // set status to accepted
+
if (((ExecuteRequest) req).isStoreResponse()) {
resp = new ExecuteResponse(execReq);
resp.save(os);
@@ -315,7 +317,9 @@ public void handle() throws ExceptionReport {
try {
// retrieve status with timeout enabled
try {
+ LOGGER.debug("Wait for finished");
resp = task.get();
+ LOGGER.debug("Succeeded");
// Thread.sleep(this.sleepingTime);
status.setProcessSucceeded("Process has succeeded");
status.unsetProcessAccepted();
@@ -324,6 +328,7 @@ public void handle() throws ExceptionReport {
} catch (ExecutionException ee) {
// the computation threw an error
// probably the client input is not valid
+ LOGGER.debug("Exception of execution catched");
if (ee.getCause() instanceof ExceptionReport) {
exceptionReport = (ExceptionReport) ee.getCause();
} else {
@@ -396,12 +401,15 @@ else if (resp == null) {
try {
// CancelRequest is called with the WPSTask retrieved from the
// tasks registry
+
String taskId = ((CancelRequest) req).getCancelDom()
.getCancel().getProcessInstanceIdentifier()
.getInstanceId();
+ LOGGER.debug("loading Task with PID "+taskId);
WPSTask task = pool.getTask(taskId);
resp = ((CancelRequest) req).call(task);
} catch (Exception e) {
+ e.printStackTrace();
if (e.getCause() instanceof ExceptionReport) {
exceptionReport = (ExceptionReport) e.getCause();
} else {
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/AbstractProcessManager.java b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/AbstractProcessManager.java
index 861f5287a..4c6b5a0e8 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/AbstractProcessManager.java
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/AbstractProcessManager.java
@@ -1,13 +1,43 @@
-package org.n52.wps.server.profiles;
-
-import org.n52.wps.server.repository.ITransactionalAlgorithmRepository;
-
-public abstract class AbstractProcessManager implements IProcessManager{
- protected ITransactionalAlgorithmRepository parentRepository;
-
- public AbstractProcessManager(ITransactionalAlgorithmRepository parentRepository){
- this.parentRepository = parentRepository;
- }
-
-
-}
+package org.n52.wps.server.profiles;
+
+import net.opengis.wps.x100.ExecuteResponseDocument;
+
+import org.n52.wps.server.repository.ITransactionalAlgorithmRepository;
+
+public abstract class AbstractProcessManager implements IProcessManager {
+ protected ITransactionalAlgorithmRepository parentRepository;
+ protected ExecuteResponseDocument executeResponse;
+ public AbstractProcessManager(
+ ITransactionalAlgorithmRepository parentRepository) {
+ this.parentRepository = parentRepository;
+ }
+
+ /**
+ * Wait the asynchronousCallback
+ *
+ * @throws InterruptedException
+ */
+ public synchronized void waitCallback() throws InterruptedException {
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ throw e;
+ }
+
+ catch (Exception e) {
+ System.out.println(e);
+ }
+ return;
+ }
+
+ public synchronized void notifyRequestManager() {
+ notify();
+ }
+ @Override
+ public void callback(ExecuteResponseDocument execRespDom) {
+ this.executeResponse = execRespDom;
+ this.notifyRequestManager();
+ return;
+ }
+
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/Data/DataDeploymentProfile.java b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/Data/DataDeploymentProfile.java
index ca641a462..e87b55521 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/Data/DataDeploymentProfile.java
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/Data/DataDeploymentProfile.java
@@ -1,316 +1,161 @@
-/***************************************************************
- This implementation provides a framework to publish processes to the
-web through the OGC Web Processing Service interface. The framework
-is extensible in terms of processes and data handlers.
-
- Copyright (C) 2006 by con terra GmbH
-
- Authors:
- Bastian Schaeffer, Institute for Geoinformatics, Muenster, Germany
-
- Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
- 48155 Muenster, Germany, 52n@conterra.de
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program (see gnu-gpl v2.txt); if not, write to
- the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA or visit the web page of the Free
- Software Foundation, http://www.fsf.org.
-
- ***************************************************************/
-
-package org.n52.wps.server.profiles.Data;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Map;
-
-import net.opengis.wps.x100.DataDeploymentProfileType;
-import net.opengis.wps.x100.DeployDataDocument;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.io.output.ByteArrayOutputStream;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.net.ftp.FTP;
-import org.apache.commons.net.ftp.FTPClient;
-import org.apache.commons.net.ftp.FTPFile;
-import org.apache.commons.net.ftp.FTPReply;
-import org.apache.log4j.Logger;
-import org.n52.wps.server.ExceptionReport;
-import org.n52.wps.server.request.deploy.DeploymentProfile;
-import org.w3c.dom.Node;
-
-/**
- * TODO rename ApacheOdeDeployementProfile to match to the XSD element type
- * **/
-public class DataDeploymentProfile extends DeploymentProfile {
-
- private static Logger LOGGER = Logger.getLogger(DataDeploymentProfile.class);
- private Node suitCase;
- private Node bpel;
- private Node clientWSDL;
- private Map wsdlList;
- private byte[] archive;
- private String processId;
- private boolean reference;
- private String archiveRef;
-
- public DataDeploymentProfile(DeployDataDocument deployDom,
- String processID) {
- super(deployDom, processID);
- try {
-
- extractInformation(deployDom);
- } catch (Exception e) {
-
- e.printStackTrace();
- }
-
- }
-
- public Node getSuitCase() {
- return suitCase;
- }
-
- public Node getBPEL() {
- return bpel;
- }
-
- public Node getClientWSDL() {
- return clientWSDL;
- }
-
- public Map getWSDLList() {
- return wsdlList;
- }
-
- private void extractInformation(DeployDataDocument deployDom)
- throws Exception {
-
- DataDeploymentProfileType deployProfile = deployDom.getDeployData().getDeploymentProfile();
- setDataId(deployDom.getDeployData().getDataDescription()
- .getIdentifier().getStringValue());
- if (deployProfile.isSetArchive()) {
- // Note that XMLBeans automatically decodes base64
- setArchive(deployProfile.getArchive());
- setReference(false);
- } else if (deployProfile.isSetArchiveReference()) {
- LOGGER.info("archive reference is set");
- setArchiveRef(deployProfile.getArchiveReference().getHref());
- LOGGER.info("downloading archive");
- setArchive(downloadArchive(getArchiveRef()));
- LOGGER.info("downloaded");
- setReference(true);
-
- } else if (deployProfile.isSetArchiveReference()) {
- setArchiveRef(deployProfile.getArchiveReference().getHref());
- setReference(true);
- throw new ExceptionReport("Archive Reference not supported yet",
- org.n52.wps.server.ExceptionReport.OPERATION_NOT_SUPPORTED);
- }
- }
- private byte[] downloadHTTP(String url) throws Exception {
- URL u = new URL(url);
- URLConnection uc = u.openConnection();
- String contentType = uc.getContentType();
- int contentLength = uc.getContentLength();
- InputStream raw = uc.getInputStream();
- InputStream in = new BufferedInputStream(raw);
- byte[] data = new byte[contentLength];
- int bytesRead = 0;
- int offset = 0;
- LOGGER.info("loading started...");
- while (offset < contentLength) {
- System.out.print(".");
- bytesRead = in.read(data, offset, data.length - offset);
- if (bytesRead == -1)
- break;
- offset += bytesRead;
- }
- in.close();
- if (offset != contentLength) {
- throw new IOException("Only read " + offset + " bytes; Expected " + contentLength + " bytes");
- }
- return data;
- }
-
- /**
- * This method download a binary file located at the given URL and returns the byte array
- * @param archiveRef2
- * @return
- * @throws IOException
- */
- private byte[] downloadArchive(String url) throws IOException {
- LOGGER.info("Downloading url "+url);
- URL u = new URL(url);
- if (StringUtils.startsWithIgnoreCase(url, "http://")
- || StringUtils
- .startsWithIgnoreCase(url, "https://")) {
- LOGGER.info("HTTP protocol");
- byte[] data=null;
- try {
- data = downloadHTTP(url);
- } catch (Exception e) {
- LOGGER.info(e.getMessage());
- LOGGER.info(e.getStackTrace().toString());
- e.printStackTrace();
- }
- return data;
- } else if (StringUtils.startsWithIgnoreCase(url, "ftp://")) {
- LOGGER.info("FTP protocol");
- byte[] data=null;
- try {
- data = downloadFTP(url);
- } catch (Exception e) {
- LOGGER.info(e.getMessage());
- LOGGER.info(e.getStackTrace().toString());
- e.printStackTrace();
- }
- return data;
- }
- return null;
- }
-
- private byte[] downloadFTP(String url) throws Exception {
- try {
- LOGGER.info("Downloading through FTP: "+url);
- URL u = new URL(url);
- FTPClient client = new FTPClient();
- ByteArrayOutputStream fos = null;
- int port = u.getPort() == -1 ? 21 : u.getPort();
- LOGGER.info("port: "+port+ " - connecting to "+u.getHost());
- try {
- client.connect(u.getHost(), port);
- }
- catch(Exception e) {
- LOGGER.info("connection fault:"+e.getMessage()+ " " + e.getCause().toString());
-
- throw e;
- }
- // connection error code
- int reply = client.getReplyCode();
- if (!FTPReply.isPositiveCompletion(reply)) {
- LOGGER.info("Disconnect on positive completion");
- client.disconnect();
- throw new ExceptionReport("FTP connection failed",ExceptionReport.NO_APPLICABLE_CODE);
- }
- LOGGER.info("connected");
- client.setDefaultTimeout(60000);
- client.setConnectTimeout(60000);
- // currently bugging
- //Property[] properties = WPSConfig.getInstance().getPropertiesForServer();
- //Property ftpUserProp = WPSConfig.getInstance().getPropertyForKey(
- //properties, "portalFTPUser");
- //LOGGER.info("user found in config: "+ftpUserProp.getStringValue());
- //Property ftpPassProp = WPSConfig.getInstance().getPropertyForKey(
- // properties, "portalFTPPassword");
- // LOGGER.info("password found in config: "+ftpPassProp.getStringValue());
- //client.login(ftpUserProp.getStringValue(), ftpPassProp.getStringValue());
- client.login("ftpuser", "ssegrid");
- LOGGER.info("logged");
- String filename = u.getFile();
- int slashIndex = filename.lastIndexOf('/') + 1;
- String parent = "."+filename.substring(0, slashIndex);
- String ftpFileName = filename.substring(slashIndex);
- LOGGER.info("parent:"+parent);
- LOGGER.info("filename:"+filename);
- FTPFile ftpFile = null;
- for (FTPFile f : client.listFiles(parent)) {
- if (StringUtils.equals(f.getName(), ftpFileName)) {
- LOGGER.info("found"+f.getName());
- ftpFile = f;
- }
- }
- if (ftpFile == null) {
- throw new IOException("File not found: " + ftpFileName);
- }
- int total = (int) ftpFile.getSize();
- LOGGER.info("total:"+total);
- LOGGER.info("get file name: "+filename);
- fos = new ByteArrayOutputStream();
- LOGGER.info("retrieve file....");
- //client.retrieveFile("."+filename, fos);
- // Set to Binary Mode !!!
- client.setFileType(FTP.BINARY_FILE_TYPE);
- InputStream raw = client.retrieveFileStream("."+filename);
- // InputStream in = new BufferedInputStream(raw, client.getBufferSize());
- byte[] data = new byte[total];
- data = IOUtils.toByteArray(raw);
- /** useless
- int bytesRead = 0;
- int offset = 0;
- LOGGER.info("loading started...");
- while (offset < total) {
- System.out.print(".");
- bytesRead = in.read(data, offset, client.getBufferSize());
- if (bytesRead == -1)
- break;
- offset += bytesRead;
- }
- */
- raw.close();
- /**
- if (offset != total) {
- LOGGER.info("Only read " + offset + " bytes; Expected " + total + " bytes");
- // throw new IOException("Only read " + offset + " bytes; Expected " + total + " bytes");
- }
- */
- LOGGER.info("retrieved");
- //byte[] data = fos.toByteArray();
- //fos.close();
- client.disconnect();
- LOGGER.info("Lenght of file:"+data.length);
- return data;
- }
- catch(Exception e) {
- throw new ExceptionReport("FTP exception",ExceptionReport.REMOTE_COMPUTATION_ERROR,e);
-
- }
- }
-
- public void setArchive(byte[] archive) {
- LOGGER.info("setArchive");
- this.archive = archive;
- }
-
- public byte[] getArchive() {
- return archive;
- }
-
- public void setDataId(String processId) {
- this.processId = processId;
- }
-
- public String getDataId() {
- return processId;
- }
-
- public void setReference(boolean reference) {
- this.reference = reference;
- }
-
- public boolean isReference() {
- return reference;
- }
-
- public void setArchiveRef(String string) {
- this.archiveRef = string;
- }
-
- public String getArchiveRef() {
- return archiveRef;
- }
-
-}
+/***************************************************************
+ This implementation provides a framework to publish processes to the
+web through the OGC Web Processing Service interface. The framework
+is extensible in terms of processes and data handlers.
+
+ Copyright (C) 2006 by con terra GmbH
+
+ Authors:
+ Bastian Schaeffer, Institute for Geoinformatics, Muenster, Germany
+
+ Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
+ 48155 Muenster, Germany, 52n@conterra.de
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program (see gnu-gpl v2.txt); if not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA or visit the web page of the Free
+ Software Foundation, http://www.fsf.org.
+
+ ***************************************************************/
+
+package org.n52.wps.server.profiles.Data;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Map;
+
+import net.opengis.wps.x100.DataDeploymentProfileType;
+import net.opengis.wps.x100.DeployDataDocument;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.net.ftp.FTP;
+import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPFile;
+import org.apache.commons.net.ftp.FTPReply;
+import org.apache.log4j.Logger;
+import org.n52.wps.server.ExceptionReport;
+import org.n52.wps.server.request.deploy.DeploymentProfile;
+import org.w3c.dom.Node;
+
+/**
+ * TODO rename ApacheOdeDeployementProfile to match to the XSD element type
+ * **/
+public class DataDeploymentProfile extends DeploymentProfile {
+
+ private static Logger LOGGER = Logger.getLogger(DataDeploymentProfile.class);
+ private Node suitCase;
+ private Node bpel;
+ private Node clientWSDL;
+ private Map wsdlList;
+ private byte[] archive;
+ private String processId;
+ private boolean reference;
+ private String archiveRef;
+
+ public DataDeploymentProfile(DeployDataDocument deployDom,
+ String processID) {
+ super(deployDom, processID);
+ try {
+
+ extractInformation(deployDom);
+ } catch (Exception e) {
+
+ e.printStackTrace();
+ }
+
+ }
+
+ public Node getSuitCase() {
+ return suitCase;
+ }
+
+ public Node getBPEL() {
+ return bpel;
+ }
+
+ public Node getClientWSDL() {
+ return clientWSDL;
+ }
+
+ public Map getWSDLList() {
+ return wsdlList;
+ }
+
+ private void extractInformation(DeployDataDocument deployDom)
+ throws Exception {
+
+ DataDeploymentProfileType deployProfile = deployDom.getDeployData().getDeploymentProfile();
+ setDataId(deployDom.getDeployData().getDataDescription()
+ .getIdentifier().getStringValue());
+ if (deployProfile.isSetArchive()) {
+ // Note that XMLBeans automatically decodes base64
+ setArchive(deployProfile.getArchive());
+ setReference(false);
+ } else if (deployProfile.isSetArchiveReference()) {
+ LOGGER.info("archive reference is set");
+ setArchiveRef(deployProfile.getArchiveReference().getHref());
+ LOGGER.info("downloading archive");
+ setArchive(downloadArchive(getArchiveRef()));
+ LOGGER.info("downloaded");
+ setReference(true);
+
+ } else if (deployProfile.isSetArchiveReference()) {
+ setArchiveRef(deployProfile.getArchiveReference().getHref());
+ setReference(true);
+ throw new ExceptionReport("Archive Reference not supported yet",
+ org.n52.wps.server.ExceptionReport.OPERATION_NOT_SUPPORTED);
+ }
+ }
+
+
+
+
+ public void setArchive(byte[] archive) {
+ LOGGER.info("setArchive");
+ this.archive = archive;
+ }
+
+ public byte[] getArchive() {
+ return archive;
+ }
+
+ public void setDataId(String processId) {
+ this.processId = processId;
+ }
+
+ public String getDataId() {
+ return processId;
+ }
+
+ public void setReference(boolean reference) {
+ this.reference = reference;
+ }
+
+ public boolean isReference() {
+ return reference;
+ }
+
+ public void setArchiveRef(String string) {
+ this.archiveRef = string;
+ }
+
+ public String getArchiveRef() {
+ return archiveRef;
+ }
+
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/DefaultTransactionalAlgorithm.java b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/DefaultTransactionalAlgorithm.java
index 786ab0af1..5ffca0120 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/DefaultTransactionalAlgorithm.java
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/DefaultTransactionalAlgorithm.java
@@ -1,378 +1,461 @@
-/***************************************************************
- This implementation provides a framework to publish processes to the
-web through the OGC Web Processing Service interface. The framework
-is extensible in terms of processes and data handlers.
-
- Copyright (C) 2006 by con terra GmbH
-
- Authors:
- Bastian Schaeffer, Institute for Geoinformatics, Muenster, Germany
-
- Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
- 48155 Muenster, Germany, 52n@conterra.de
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program (see gnu-gpl v2.txt); if not, write to
- the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA or visit the web page of the Free
- Software Foundation, http://www.fsf.org.
-
- ***************************************************************/
-
-package org.n52.wps.server.profiles;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CancellationException;
-
-import net.opengis.ows.x11.ExceptionReportDocument;
-import net.opengis.wps.x100.AuditTraceType;
-import net.opengis.wps.x100.ExecuteDocument;
-import net.opengis.wps.x100.ExecuteResponseDocument;
-import net.opengis.wps.x100.InputDescriptionType;
-import net.opengis.wps.x100.OutputDataType;
-import net.opengis.wps.x100.OutputDescriptionType;
-import net.opengis.wps.x100.ProcessDescriptionDocument;
-import net.opengis.wps.x100.ProcessDescriptionType;
-import org.apache.log4j.Logger;
-import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlOptions;
-import org.n52.wps.PropertyDocument.Property;
-import org.n52.wps.commons.WPSConfig;
-import org.n52.wps.io.data.IData;
-import org.n52.wps.io.data.binding.complex.GenericFileDataBinding;
-import org.n52.wps.io.data.binding.complex.URLListDataBinding;
-import org.n52.wps.io.data.binding.literal.LiteralBooleanBinding;
-import org.n52.wps.io.data.binding.literal.LiteralDoubleBinding;
-import org.n52.wps.io.data.binding.literal.LiteralIntBinding;
-import org.n52.wps.io.data.binding.literal.LiteralStringBinding;
-import org.n52.wps.server.AbstractTransactionalAlgorithm;
-import org.n52.wps.server.ExceptionReport;
-import org.n52.wps.server.repository.TransactionalRepositoryManager;
-import org.n52.wps.server.request.ExecuteRequest;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-import xint.esa.ssegrid.wps.javaSAGAProfile.URLListDocument;
-
-public class DefaultTransactionalAlgorithm extends
- AbstractTransactionalAlgorithm {
-
- private List errors;
- private static Logger LOGGER = Logger
- .getLogger(DefaultTransactionalAlgorithm.class);
- private ProcessDescriptionType processDescription;
- private IProcessManager processManager;
-
- private static final String OGC_OWS_URI = "http://www.opengeospatial.net/ows";
-
- public DefaultTransactionalAlgorithm(String processID) {
- super(processID);
- WPSConfig wpsConfig = WPSConfig.getInstance();
- Property[] properties = wpsConfig.getPropertiesForAlgorithm(processID);
- try {
- setProcessManager(TransactionalRepositoryManager
- .getProcessManagerForSchema(wpsConfig.getPropertyForKey(
- properties, "supportedFormat").getStringValue()));
- } catch (InstantiationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- this.errors = new ArrayList();
- processDescription = initializeDescription();
- }
-
- public ProcessDescriptionType getDescription() {
- return processDescription;
- }
-
- // TODO : BPEL has nothing to do here...
- public HashMap run(ExecuteRequest req)
- throws ExceptionReport {
- ExecuteResponseDocument responseDocument;
- HashMap resultHash = new HashMap();
- /**
- * Note cnl : The DefaultTransactionAlgorithm receives an
- * ExecuteResponseDocument from the backend process manager If the
- * process manager returns another kind of DOM document, another
- * TransactionalAlgorithm should handle this.
- */
- Document invokeResponse;
- LOGGER.info("DefaultTransactionAlgo Run");
- try {
- invokeResponse = getProcessManager().invoke(req, getAlgorithmID());
- /**
- * Parsing
- */
- LOGGER.info("invoke response");
- responseDocument = ExecuteResponseDocument.Factory
- .parse(invokeResponse);
- LOGGER.info(responseDocument.toString());
- OutputDataType[] resultValues = responseDocument
- .getExecuteResponse().getProcessOutputs().getOutputArray();
- for (int i = 0; i < resultValues.length; i++) {
- OutputDataType ioElement = resultValues[i];
- String key = ioElement.getIdentifier().getStringValue();
- if (ioElement.getData().isSetLiteralData()) {
- resultHash.put(key,
- OutputParser.handleLiteralValue(ioElement));
- }
- if (ioElement.getData().isSetComplexData()) {
- resultHash.put(key, OutputParser.handleComplexValue(
- ioElement, getDescription()));
- }
- /**
- * TODO if(ioElement.isSetReference()){ resultHash.put(key,
- * OutputParser.handleComplexValueReference(ioElement)); }
- */
- if (ioElement.getData().getBoundingBoxData() != null) {
- resultHash
- .put(key, OutputParser.handleBBoxValue(ioElement));
- }
- }
- } catch (CancellationException e) {
- throw e;
- } catch (ExceptionReport e) {
- e.printStackTrace();
- throw e;
- } catch (Exception e) {
- e.printStackTrace();
- String error = "Could not create ExecuteResponseDocument";
- errors.add(error);
- LOGGER.warn(error + " Reason: " + e.getMessage());
- throw new ExceptionReport(error,
- ExceptionReport.REMOTE_COMPUTATION_ERROR);
-
- }
- return resultHash;
- }
-
- public List getErrors() {
- return errors;
- }
-
- protected ProcessDescriptionType initializeDescription() {
- String fullPath = DefaultTransactionalAlgorithm.class
- .getProtectionDomain().getCodeSource().getLocation().toString();
- int searchIndex = fullPath.indexOf("WEB-INF");
- String subPath = fullPath.substring(0, searchIndex);
- subPath = subPath.replaceFirst("file:", "");
- String processID = getAlgorithmID();
- // sanitize processID: strip version number and namespace if passed in
- if (processID.contains("-"))
- processID = processID.split("-")[0];
- if (processID.contains("}"))
- processID = processID.split("}")[1];
- try {
- File xmlDesc = new File(subPath + File.separator + "WEB-INF"
- + File.separator + "ProcessDescriptions" + File.separator
- + processID + ".xml");
- XmlOptions option = new XmlOptions();
- option.setLoadTrimTextBuffer();
- ProcessDescriptionDocument doc = ProcessDescriptionDocument.Factory
- .parse(xmlDesc, option);
- if (doc == null) {
- LOGGER.warn("ProcessDescription does not contain any description");
- return null;
- }
-
- doc.getProcessDescription().getIdentifier()
- .setStringValue(processID);
-
- return doc.getProcessDescription();
- } catch (IOException e) {
- LOGGER.warn("Could not initialize algorithm, parsing error: "
- + getAlgorithmID(), e);
- } catch (XmlException e) {
- LOGGER.warn("Could not initialize algorithm, parsing error: "
- + getAlgorithmID(), e);
- }
- return null;
-
- }
-
- public boolean processDescriptionIsValid() {
- return processDescription.validate();
- }
-
- private Document checkResultDocument(Document doc) {
- if (getFirstElementNode(doc.getFirstChild()).getNodeName().equals(
- "ExceptionReport")
- && getFirstElementNode(doc.getFirstChild()).getNamespaceURI()
- .equals(OGC_OWS_URI)) {
- try {
- ExceptionReportDocument exceptionDoc = ExceptionReportDocument.Factory
- .parse(doc);
- throw new RuntimeException(
- "Error occured while executing query");
- } catch (Exception e) {
- throw new RuntimeException(
- "Error while parsing ExceptionReport retrieved from server",
- e);
- }
- }
- return doc;
- }
-
- private Node getFirstElementNode(Node node) {
- if (node == null) {
- return null;
- }
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- return node;
- } else {
- return getFirstElementNode(node.getNextSibling());
- }
-
- }
-
- public String getWellKnownName() {
- return "";
- }
-
- public Class getInputDataType(String id) {
- InputDescriptionType[] inputs = processDescription.getDataInputs()
- .getInputArray();
- for (InputDescriptionType input : inputs) {
- if (input.getIdentifier().getStringValue().equals(id)) {
- if (input.isSetLiteralData()) {
- String datatype = input.getLiteralData().getDataType()
- .getStringValue();
- if (datatype.contains("tring")) {
- return LiteralStringBinding.class;
- }
- if (datatype.contains("ollean")) {
- return LiteralBooleanBinding.class;
- }
- if (datatype.contains("loat") || datatype.contains("ouble")) {
- return LiteralDoubleBinding.class;
- }
- if (datatype.contains("nt")) {
- return LiteralIntBinding.class;
- }
- }
- if (input.isSetComplexData()) {
- LOGGER.info("-------- complex --- --- ");
- LOGGER.info(input.getComplexData().toString());
- LOGGER.info("-------- def--- --- ");
- LOGGER.info(input.getComplexData().getDefault().toString());
- LOGGER.info("--------format --- --- ");
- LOGGER.info(input.getComplexData().getDefault().getFormat()
- .toString());
- String mimeType = input.getComplexData().getDefault()
- .getFormat().getMimeType();
- if (mimeType.contains("xml") || (mimeType.contains("XML"))) {
- return URLListDataBinding.class;
- } else {
- return URLListDataBinding.class;
- }
- }
- }
- }
- throw new RuntimeException("Could not determie internal inputDataType");
- }
-
- public Class getOutputDataType(String id) {
- OutputDescriptionType[] outputs = processDescription
- .getProcessOutputs().getOutputArray();
-
- for (OutputDescriptionType output : outputs) {
- if (output.getIdentifier().getStringValue().equals(id)) {
- LOGGER.info("output is :" + id);
- if (output.isSetLiteralOutput()) {
- // Missing case when dataType is not present
- if (output.getLiteralOutput().getDataType() == null) {
- return LiteralStringBinding.class;
- }
- String datatype = output.getLiteralOutput().getDataType()
- .getStringValue();
- if (datatype.contains("tring")) {
- return LiteralStringBinding.class;
- }
- if (datatype.contains("ollean")) {
- return LiteralBooleanBinding.class;
- }
- if (datatype.contains("loat") || datatype.contains("ouble")) {
- return LiteralDoubleBinding.class;
- }
- if (datatype.contains("nt")) {
- return LiteralIntBinding.class;
- }
- }
- if (output.isSetComplexOutput()) {
- String mimeType = output.getComplexOutput().getDefault()
- .getFormat().getMimeType();
- if (mimeType.contains("xml") || (mimeType.contains("XML"))) {
- if (output.getComplexOutput().getDefault().getFormat()
- .getSchema().contains("wps")) {
- LOGGER.info("Output Data Type found is URLListDataBinding");
- return URLListDataBinding.class;
-
- } else {
- return GenericFileDataBinding.class;
- }
-
- } else {
- return GenericFileDataBinding.class;
- }
- }
- }
- }
- throw new RuntimeException("Could not determie internal inputDataType");
- }
-
- public Map run(Map> inputData) {
- // TODO Auto-generated method stub
- // processManager
- return null;
- }
-
- public void setProcessManager(IProcessManager o) {
- this.processManager = o;
- }
-
- public IProcessManager getProcessManager() {
- return processManager;
- }
-
- public AuditTraceType getAudit() throws Exception {
- LOGGER.info("short");
- return getProcessManager().getAudit();
- }
-
- public AuditTraceType getAuditLongForm() throws Exception {
- LOGGER.info("long");
- return getProcessManager().getAuditLongForm();
- }
-
- public void callback(ExecuteResponseDocument execRespDom) {
- getProcessManager().callback(execRespDom);
- return;
- }
-
- @Override
- public void cancel() {
- LOGGER.info("get process manager cancel");
- getProcessManager().cancel();
- return;
- }
-}
+/***************************************************************
+ This implementation provides a framework to publish processes to the
+web through the OGC Web Processing Service interface. The framework
+is extensible in terms of processes and data handlers.
+
+ Copyright (C) 2006 by con terra GmbH
+
+ Authors:
+ Bastian Schaeffer, Institute for Geoinformatics, Muenster, Germany
+
+ Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
+ 48155 Muenster, Germany, 52n@conterra.de
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program (see gnu-gpl v2.txt); if not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA or visit the web page of the Free
+ Software Foundation, http://www.fsf.org.
+
+ ***************************************************************/
+
+package org.n52.wps.server.profiles;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CancellationException;
+
+import net.opengis.ows.x11.ExceptionReportDocument;
+import net.opengis.wps.x100.AuditTraceType;
+import net.opengis.wps.x100.ExecuteDocument;
+import net.opengis.wps.x100.ExecuteResponseDocument;
+import net.opengis.wps.x100.InputDescriptionType;
+import net.opengis.wps.x100.OutputDataType;
+import net.opengis.wps.x100.OutputDescriptionType;
+import net.opengis.wps.x100.ProcessDescriptionDocument;
+import net.opengis.wps.x100.ProcessDescriptionType;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.FileFilterUtils;
+import org.apache.log4j.Logger;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlOptions;
+import org.n52.wps.PropertyDocument.Property;
+import org.n52.wps.commons.WPSConfig;
+import org.n52.wps.io.data.IData;
+import org.n52.wps.io.data.binding.complex.DataListDataBinding;
+import org.n52.wps.io.data.binding.complex.EODataCacheDataBinding;
+import org.n52.wps.io.data.binding.complex.GenericFileDataBinding;
+import org.n52.wps.io.data.binding.complex.URLListDataBinding;
+import org.n52.wps.io.data.binding.literal.LiteralBooleanBinding;
+import org.n52.wps.io.data.binding.literal.LiteralDoubleBinding;
+import org.n52.wps.io.data.binding.literal.LiteralIntBinding;
+import org.n52.wps.io.data.binding.literal.LiteralStringBinding;
+import org.n52.wps.server.AbstractTransactionalAlgorithm;
+import org.n52.wps.server.ExceptionReport;
+import org.n52.wps.server.profiles.java.JavaManager;
+import org.n52.wps.server.profiles.java.JavaTransactionalAlgorithm;
+import org.n52.wps.server.repository.TransactionalRepositoryManager;
+import org.n52.wps.server.request.ExecuteRequest;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+
+
+public class DefaultTransactionalAlgorithm extends
+ AbstractTransactionalAlgorithm {
+
+ private List errors;
+ private static Logger LOGGER = Logger
+ .getLogger(DefaultTransactionalAlgorithm.class);
+ private ProcessDescriptionType processDescription;
+ private IProcessManager processManager;
+
+ private static final String OGC_OWS_URI = "http://www.opengeospatial.net/ows";
+
+ public DefaultTransactionalAlgorithm(String processID) {
+ super(processID);
+ WPSConfig wpsConfig = WPSConfig.getInstance();
+ Property[] properties = wpsConfig.getPropertiesForAlgorithm(processID);
+ try {
+ setProcessManager(TransactionalRepositoryManager
+ .getProcessManagerForSchema(wpsConfig.getPropertyForKey(
+ properties, "supportedFormat").getStringValue()));
+ } catch (InstantiationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ this.errors = new ArrayList();
+ processDescription = initializeDescription();
+ }
+
+ public ProcessDescriptionType getDescription() {
+ return processDescription;
+ }
+
+ // TODO : BPEL has nothing to do here...
+ public Map run(ExecuteRequest req)
+ throws ExceptionReport {
+ ExecuteResponseDocument responseDocument;
+ HashMap resultHash = new HashMap();
+ /**
+ * Note cnl : The DefaultTransactionAlgorithm receives an
+ * ExecuteResponseDocument from the backend process manager If the
+ * process manager returns another kind of DOM document, another
+ * TransactionalAlgorithm should handle this.
+ */
+ Document invokeResponse;
+ LOGGER.info("DefaultTransactionAlgo Run");
+ try {
+ // in case of the specific case of JavaManager the invokeJava method must be called
+ // because it directly returns the Map format
+ if(getProcessManager() instanceof JavaManager) {
+ return ((JavaManager)getProcessManager()).invokeJava(req, getAlgorithmID());
+ }
+ invokeResponse = getProcessManager().invoke(req, getAlgorithmID());
+ /**
+ * Parsing
+ */
+ LOGGER.info("invoke response");
+ responseDocument = ExecuteResponseDocument.Factory
+ .parse(invokeResponse);
+ LOGGER.info(responseDocument.toString());
+ OutputDataType[] resultValues = responseDocument
+ .getExecuteResponse().getProcessOutputs().getOutputArray();
+ for (int i = 0; i < resultValues.length; i++) {
+ OutputDataType ioElement = resultValues[i];
+ String key = ioElement.getIdentifier().getStringValue();
+ if (ioElement.getData().isSetLiteralData()) {
+ resultHash.put(key,
+ OutputParser.handleLiteralValue(ioElement));
+ }
+ if (ioElement.getData().isSetComplexData()) {
+ resultHash.put(key, OutputParser.handleComplexValue(
+ ioElement, getDescription()));
+ }
+ /**
+ * TODO if(ioElement.isSetReference()){ resultHash.put(key,
+ * OutputParser.handleComplexValueReference(ioElement)); }
+ */
+ if (ioElement.getData().getBoundingBoxData() != null) {
+ resultHash
+ .put(key, OutputParser.handleBBoxValue(ioElement));
+ }
+ }
+ }
+ catch(InterruptedException e) {
+ throw new CancellationException();
+ }
+ catch (CancellationException e) {
+ throw e;
+ } catch (ExceptionReport e) {
+ e.printStackTrace();
+ throw e;
+ } catch (Exception e) {
+ e.printStackTrace();
+ String error = "Could not create ExecuteResponseDocument";
+ errors.add(error);
+ LOGGER.warn(error + " Reason: " + e.getMessage());
+ throw new ExceptionReport(error,
+ ExceptionReport.REMOTE_COMPUTATION_ERROR);
+
+ }
+ return resultHash;
+ }
+
+ public List getErrors() {
+ return errors;
+ }
+
+ protected ProcessDescriptionType initializeDescription() {
+ String fullPath = DefaultTransactionalAlgorithm.class
+ .getProtectionDomain().getCodeSource().getLocation().toString();
+ int searchIndex = fullPath.indexOf("WEB-INF");
+ String subPath = fullPath.substring(0, searchIndex);
+ subPath = subPath.replaceFirst("file:", "");
+ String processID = getAlgorithmID();
+ // sanitize processID: strip version number and namespace if passed in
+ if (processID.contains("-"))
+ processID = processID.split("-")[0];
+ if (processID.contains("}"))
+ processID = processID.split("}")[1];
+ try {
+ File xmlDesc = new File(subPath + File.separator + "WEB-INF"
+ + File.separator + "ProcessDescriptions" + File.separator
+ + processID + ".xml");
+ XmlOptions option = new XmlOptions();
+ option.setLoadTrimTextBuffer();
+ ProcessDescriptionDocument doc = ProcessDescriptionDocument.Factory
+ .parse(xmlDesc, option);
+ if (doc == null) {
+ LOGGER.warn("ProcessDescription does not contain any description");
+ return null;
+ }
+
+ doc.getProcessDescription().getIdentifier()
+ .setStringValue(processID);
+
+ return doc.getProcessDescription();
+ } catch (IOException e) {
+ LOGGER.warn("Could not initialize algorithm, parsing error: "
+ + getAlgorithmID(), e);
+ } catch (XmlException e) {
+ LOGGER.warn("Could not initialize algorithm, parsing error: "
+ + getAlgorithmID(), e);
+ }
+ return null;
+
+ }
+
+ public boolean processDescriptionIsValid() {
+ return processDescription.validate();
+ }
+
+ private Document checkResultDocument(Document doc) {
+ if (getFirstElementNode(doc.getFirstChild()).getNodeName().equals(
+ "ExceptionReport")
+ && getFirstElementNode(doc.getFirstChild()).getNamespaceURI()
+ .equals(OGC_OWS_URI)) {
+ try {
+ ExceptionReportDocument exceptionDoc = ExceptionReportDocument.Factory
+ .parse(doc);
+ throw new RuntimeException(
+ "Error occured while executing query");
+ } catch (Exception e) {
+ throw new RuntimeException(
+ "Error while parsing ExceptionReport retrieved from server",
+ e);
+ }
+ }
+ return doc;
+ }
+
+ private Node getFirstElementNode(Node node) {
+ if (node == null) {
+ return null;
+ }
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ return node;
+ } else {
+ return getFirstElementNode(node.getNextSibling());
+ }
+
+ }
+
+ public String getWellKnownName() {
+ return "";
+ }
+
+ public Class getInputDataType(String id) {
+
+ if(getProcessManager() instanceof JavaManager) {
+ try {
+ JavaManager manager = (JavaManager)getProcessManager();
+ List jarList = new ArrayList();
+ String jarDir = manager.getProcessDeploymentDirectory(getAlgorithmID());
+ // List all file in parent directory with jar suffix extension
+ Collection list = FileUtils.listFiles(new File(jarDir), FileFilterUtils.suffixFileFilter("jar"), null);
+ for(File f : list) {
+ URL jarURL = f.toURI().toURL();
+ jarList.add(jarURL);
+ }
+ ClassLoader classLoader = new URLClassLoader(jarList.toArray(new URL[jarList.size()]), this.getClass().getClassLoader());
+
+ //if( be.spacebel.ese.data.wps.DownloadEOData)
+
+ JavaTransactionalAlgorithm algorithm = (JavaTransactionalAlgorithm)classLoader.loadClass(algorithmID).newInstance();
+ Class itype = algorithm.getInputDataType(id);
+ if(itype !=null)
+ return itype;
+ }
+ catch(Exception e) {e.printStackTrace();};
+ }
+ InputDescriptionType[] inputs = processDescription.getDataInputs()
+ .getInputArray();
+ for (InputDescriptionType input : inputs) {
+ if (input.getIdentifier().getStringValue().equals(id)) {
+ if (input.isSetLiteralData()) {
+ String datatype = input.getLiteralData().getDataType()
+ .getStringValue();
+ if (datatype.contains("tring")) {
+ return LiteralStringBinding.class;
+ }
+ if (datatype.contains("ollean")) {
+ return LiteralBooleanBinding.class;
+ }
+ if (datatype.contains("loat") || datatype.contains("ouble")) {
+ return LiteralDoubleBinding.class;
+ }
+ if (datatype.contains("nt")) {
+ return LiteralIntBinding.class;
+ }
+ }
+ if (input.isSetComplexData()) {
+ LOGGER.info("-------- complex --- --- ");
+ LOGGER.info(input.getComplexData().toString());
+ LOGGER.info("-------- def--- --- ");
+ LOGGER.info(input.getComplexData().getDefault().toString());
+ LOGGER.info("--------format --- --- ");
+ LOGGER.info(input.getComplexData().getDefault().getFormat()
+ .toString());
+ String mimeType = input.getComplexData().getDefault()
+ .getFormat().getMimeType();
+ if (mimeType.contains("xml") || (mimeType.contains("XML"))) {
+ return URLListDataBinding.class;
+ } else {
+ return URLListDataBinding.class;
+ }
+ }
+ }
+ }
+ throw new RuntimeException("Could not determie internal inputDataType");
+ }
+
+ public Class getOutputDataType(String id) {
+ if(getProcessManager() instanceof JavaManager) {
+ try {
+ JavaManager manager = (JavaManager)getProcessManager();
+ List jarList = new ArrayList();
+ String jarDir = manager.getProcessDeploymentDirectory(getAlgorithmID());
+ // List all file in parent directory with jar suffix extension
+ Collection list = FileUtils.listFiles(new File(jarDir), FileFilterUtils.suffixFileFilter("jar"), null);
+ for(File f : list) {
+ URL jarURL = f.toURI().toURL();
+ jarList.add(jarURL);
+ }
+ ClassLoader classLoader = new URLClassLoader(jarList.toArray(new URL[jarList.size()]), this.getClass().getClassLoader());
+
+ //if( be.spacebel.ese.data.wps.DownloadEOData)
+
+ JavaTransactionalAlgorithm algorithm = (JavaTransactionalAlgorithm)classLoader.loadClass(algorithmID).newInstance();
+ Class itype = algorithm.getOutputDataType(id);
+ if(itype !=null) {
+ LOGGER.info("itype is not null so using the implemented local method");
+ return itype;
+ }
+
+ }
+ catch(Exception e) {e.printStackTrace();};
+ }
+ LOGGER.info("LOOKing for standard default transactional algorithm output class");
+ OutputDescriptionType[] outputs = processDescription
+ .getProcessOutputs().getOutputArray();
+
+ for (OutputDescriptionType output : outputs) {
+ if (output.getIdentifier().getStringValue().equals(id)) {
+ LOGGER.info("output is :" + id);
+ if (output.isSetLiteralOutput()) {
+ // Missing case when dataType is not present
+ if (output.getLiteralOutput().getDataType() == null) {
+ return LiteralStringBinding.class;
+ }
+ String datatype = output.getLiteralOutput().getDataType()
+ .getStringValue();
+ if (datatype.contains("tring")) {
+ return LiteralStringBinding.class;
+ }
+ if (datatype.contains("ollean")) {
+ return LiteralBooleanBinding.class;
+ }
+ if (datatype.contains("loat") || datatype.contains("ouble")) {
+ return LiteralDoubleBinding.class;
+ }
+ if (datatype.contains("nt")) {
+ return LiteralIntBinding.class;
+ }
+ }
+ if (output.isSetComplexOutput()) {
+ String mimeType = output.getComplexOutput().getDefault()
+ .getFormat().getMimeType();
+ if (mimeType.contains("xml") || (mimeType.contains("XML"))) {
+ if (output.getComplexOutput().getDefault().getFormat()
+ .getSchema().contains("URLList")) {
+ LOGGER.info("Output Data Type found is URLListDataBinding");
+ return URLListDataBinding.class;
+
+ }
+ else if (output.getComplexOutput().getDefault().getFormat()
+ .getSchema().contains("DataList")) {
+ LOGGER.info("Output Data Type found is URLListDataBinding");
+ return DataListDataBinding.class;
+
+ }
+ else if (output.getComplexOutput().getDefault().getFormat()
+ .getSchema().contains("EODataCache")) {
+ LOGGER.info("Output Data Type found is URLListDataBinding");
+ return EODataCacheDataBinding.class;
+
+ }
+
+
+ else {
+ return GenericFileDataBinding.class;
+ }
+
+ } else {
+ return GenericFileDataBinding.class;
+ }
+ }
+ }
+ }
+ throw new RuntimeException("Could not determie internal inputDataType");
+ }
+
+ public Map run(Map> inputData) {
+ // TODO Auto-generated method stub
+ // processManager
+ return null;
+ }
+
+ public void setProcessManager(IProcessManager o) {
+ this.processManager = o;
+ }
+
+ public IProcessManager getProcessManager() {
+ return processManager;
+ }
+
+ public AuditTraceType getAudit() throws Exception {
+ LOGGER.info("short");
+ return getProcessManager().getAudit();
+ }
+
+ public AuditTraceType getAuditLongForm() throws Exception {
+ LOGGER.info("long");
+ return getProcessManager().getAuditLongForm();
+ }
+
+ public void callback(ExecuteResponseDocument execRespDom) {
+ getProcessManager().callback(execRespDom);
+ return;
+ }
+
+ @Override
+ public void cancel() {
+ LOGGER.info("get process manager cancel");
+ getProcessManager().cancel();
+ return;
+ }
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IDataManager.java b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IDataManager.java
index 79aa6712e..3906a77d5 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IDataManager.java
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IDataManager.java
@@ -1,55 +1,46 @@
-/***************************************************************
- This implementation provides a framework to publish processes to the
-web through the OGC Web Processing Service interface. The framework
-is extensible in terms of processes and data handlers.
-
- Copyright (C) 2006 by con terra GmbH
-
- Authors:
- Bastian Schaeffer, Institute for Geoinformatics, Muenster, Germany
-
- Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
- 48155 Muenster, Germany, 52n@conterra.de
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program (see gnu-gpl v2.txt); if not, write to
- the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA or visit the web page of the Free
- Software Foundation, http://www.fsf.org.
-
- ***************************************************************/
-
-
-package org.n52.wps.server.profiles;
-
-import java.util.Collection;
-import java.util.HashMap;
-
-import net.opengis.wps.x100.ExecuteDocument;
-import net.opengis.wps.x100.UndeployDataDocument.UndeployData;
-
-import org.n52.wps.io.data.IData;
-import org.n52.wps.server.request.DeployDataRequest;
-import org.n52.wps.server.request.DeployProcessRequest;
-import org.n52.wps.server.request.UndeployDataRequest;
-import org.n52.wps.server.request.UndeployProcessRequest;
-import org.w3c.dom.Document;
-
-public interface IDataManager {
-
-
- boolean unDeployData(UndeployDataRequest request) throws Exception;
- boolean containsData(String processID) throws Exception;
- Collection getAllDatas() throws Exception;
- boolean deployData(DeployDataRequest request) throws Exception;
-
-}
+/***************************************************************
+ This implementation provides a framework to publish processes to the
+web through the OGC Web Processing Service interface. The framework
+is extensible in terms of processes and data handlers.
+
+ Copyright (C) 2006 by con terra GmbH
+
+ Authors:
+ Bastian Schaeffer, Institute for Geoinformatics, Muenster, Germany
+
+ Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
+ 48155 Muenster, Germany, 52n@conterra.de
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program (see gnu-gpl v2.txt); if not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA or visit the web page of the Free
+ Software Foundation, http://www.fsf.org.
+
+ ***************************************************************/
+
+
+package org.n52.wps.server.profiles;
+
+import java.util.Collection;
+import org.n52.wps.server.request.DeployDataRequest;
+import org.n52.wps.server.request.UndeployDataRequest;
+
+public interface IDataManager {
+
+
+ boolean unDeployData(UndeployDataRequest request) throws Exception;
+ boolean containsData(String processID) throws Exception;
+ Collection getAllDatas() throws Exception;
+ boolean deployData(DeployDataRequest request) throws Exception;
+
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IProcessManager.java b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IProcessManager.java
index 7d9fac6ad..0666c3dc6 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IProcessManager.java
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IProcessManager.java
@@ -1,62 +1,64 @@
-/***************************************************************
- This implementation provides a framework to publish processes to the
-web through the OGC Web Processing Service interface. The framework
-is extensible in terms of processes and data handlers.
-
- Copyright (C) 2006 by con terra GmbH
-
- Authors:
- Bastian Schaeffer, Institute for Geoinformatics, Muenster, Germany
-
- Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
- 48155 Muenster, Germany, 52n@conterra.de
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program (see gnu-gpl v2.txt); if not, write to
- the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA or visit the web page of the Free
- Software Foundation, http://www.fsf.org.
-
- ***************************************************************/
-
-
-package org.n52.wps.server.profiles;
-
-import java.util.Collection;
-import java.util.HashMap;
-
-import net.opengis.wps.x100.AuditTraceType;
-import net.opengis.wps.x100.ExecuteDocument;
-import net.opengis.wps.x100.ExecuteResponseDocument;
-
-import org.n52.wps.io.data.IData;
-import org.n52.wps.server.request.DeployProcessRequest;
-import org.n52.wps.server.request.ExecuteRequest;
-import org.n52.wps.server.request.UndeployProcessRequest;
-import org.w3c.dom.Document;
-
-public interface IProcessManager {
-
-
- boolean unDeployProcess(UndeployProcessRequest request) throws Exception;
- boolean containsProcess(String processID) throws Exception;
- Collection getAllProcesses() throws Exception;
- Document invoke(ExecuteDocument payload, String algorithmID) throws Exception;
- Document invoke(ExecuteRequest request, String algorithmID) throws Exception;
- boolean deployProcess(DeployProcessRequest request) throws Exception;
- AuditTraceType getAuditLongForm() throws Exception;
- AuditTraceType getAudit() throws Exception;
-
- String getIID();
- void callback(ExecuteResponseDocument execRespDom);
- void cancel();
-}
+/***************************************************************
+ This implementation provides a framework to publish processes to the
+web through the OGC Web Processing Service interface. The framework
+is extensible in terms of processes and data handlers.
+
+ Copyright (C) 2006 by con terra GmbH
+
+ Authors:
+ Bastian Schaeffer, Institute for Geoinformatics, Muenster, Germany
+
+ Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
+ 48155 Muenster, Germany, 52n@conterra.de
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program (see gnu-gpl v2.txt); if not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA or visit the web page of the Free
+ Software Foundation, http://www.fsf.org.
+
+ ***************************************************************/
+
+
+package org.n52.wps.server.profiles;
+
+import java.util.Collection;
+import java.util.HashMap;
+
+import net.opengis.wps.x100.AuditTraceType;
+import net.opengis.wps.x100.ExecuteDocument;
+import net.opengis.wps.x100.ExecuteResponseDocument;
+
+import org.n52.wps.io.data.IData;
+import org.n52.wps.server.request.DeployProcessRequest;
+import org.n52.wps.server.request.ExecuteRequest;
+import org.n52.wps.server.request.UndeployProcessRequest;
+import org.w3c.dom.Document;
+
+public interface IProcessManager {
+
+ boolean unDeployProcess(UndeployProcessRequest request) throws Exception;
+ boolean containsProcess(String processID) throws Exception;
+ Collection getAllProcesses() throws Exception;
+ Document invoke(ExecuteDocument payload, String algorithmID) throws Exception;
+ Document invoke(ExecuteRequest request, String algorithmID) throws Exception;
+ boolean deployProcess(DeployProcessRequest request) throws Exception;
+ AuditTraceType getAuditLongForm() throws Exception;
+ AuditTraceType getAudit() throws Exception;
+
+ String getIID();
+ void callback(ExecuteResponseDocument execRespDom);
+ void cancel();
+
+
+
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IntalioBPMS/ApacheOdeProcessManager.java b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IntalioBPMS/ApacheOdeProcessManager.java
index 8e284c59e..74c1e5e79 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IntalioBPMS/ApacheOdeProcessManager.java
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IntalioBPMS/ApacheOdeProcessManager.java
@@ -64,14 +64,14 @@
import org.n52.wps.server.request.ExecuteRequest;
import org.n52.wps.server.request.UndeployProcessRequest;
import org.n52.wps.server.request.deploy.DeploymentProfile;
-import org.w3.x2005.x08.addressing.MessageIDDocument;
-import org.w3.x2005.x08.addressing.ReplyToDocument;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import xint.esa.ssegrid.wps.javaSAGAProfile.URLListDocument;
+import xint.esa.ese.wps.format.urlList.URLListDocument;
+
+
/**
* TODO this class was based on transactional branch implementation. However the
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IntalioBPMS/BPELDeploymentProfile.java b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IntalioBPMS/BPELDeploymentProfile.java
index 27682ea9d..5e54ee17d 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IntalioBPMS/BPELDeploymentProfile.java
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IntalioBPMS/BPELDeploymentProfile.java
@@ -1,242 +1,154 @@
-/***************************************************************
- This implementation provides a framework to publish processes to the
-web through the OGC Web Processing Service interface. The framework
-is extensible in terms of processes and data handlers.
-
- Copyright (C) 2006 by con terra GmbH
-
- Authors:
- Bastian Schaeffer, Institute for Geoinformatics, Muenster, Germany
-
- Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
- 48155 Muenster, Germany, 52n@conterra.de
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program (see gnu-gpl v2.txt); if not, write to
- the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA or visit the web page of the Free
- Software Foundation, http://www.fsf.org.
-
- ***************************************************************/
-
-package org.n52.wps.server.profiles.IntalioBPMS;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Map;
-
-import net.opengis.wps.x100.ApacheOdeDeploymentProfileType;
-import net.opengis.wps.x100.DeployProcessDocument;
-
-import org.apache.commons.io.output.ByteArrayOutputStream;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.net.ftp.FTPClient;
-import org.apache.commons.net.ftp.FTPReply;
-import org.apache.log4j.Logger;
-import org.n52.wps.PropertyDocument.Property;
-import org.n52.wps.commons.WPSConfig;
-import org.n52.wps.server.ExceptionReport;
-import org.n52.wps.server.request.deploy.DeploymentProfile;
-import org.w3c.dom.Node;
-
-/**
- * TODO rename ApacheOdeDeployementProfile to match to the XSD element type
- * **/
-public class BPELDeploymentProfile extends DeploymentProfile {
-
- private static Logger LOGGER = Logger.getLogger(BPELDeploymentProfile.class);
- private Node suitCase;
- private Node bpel;
- private Node clientWSDL;
- private Map wsdlList;
- private byte[] archive;
- private String processId;
- private boolean reference;
- private String archiveRef;
-
- public BPELDeploymentProfile(DeployProcessDocument deployDom,
- String processID) {
- super(deployDom, processID);
- try {
-
- extractInformation(deployDom);
- } catch (Exception e) {
-
- e.printStackTrace();
- }
-
- }
-
- public Node getSuitCase() {
- return suitCase;
- }
-
- public Node getBPEL() {
- return bpel;
- }
-
- public Node getClientWSDL() {
- return clientWSDL;
- }
-
- public Map getWSDLList() {
- return wsdlList;
- }
-
- private void extractInformation(DeployProcessDocument deployDom)
- throws Exception {
-
- ApacheOdeDeploymentProfileType deployProfile = (ApacheOdeDeploymentProfileType) deployDom.getDeployProcess().getDeploymentProfile().changeType(ApacheOdeDeploymentProfileType.type);
- if(!deployProfile.validate()) {
- throw new ExceptionReport("BPEL Deploy Profile is not valid (according WPS schemas)",ExceptionReport.INVALID_PARAMETER_VALUE);
- }
- setProcessId(deployDom.getDeployProcess().getProcessDescription()
- .getIdentifier().getStringValue());
- if (deployProfile.isSetArchive()) {
- // Note that XMLBeans automatically decodes base64
- setArchive(deployProfile.getArchive());
- setReference(false);
- } else if (deployProfile.isSetArchiveReference()) {
- setArchiveRef(deployProfile.getArchiveReference().getHref());
- LOGGER.info("downloading archive");
- setArchive(downloadArchive(getArchiveRef()));
- setReference(true);
- }
- }
-
- private byte[] downloadHTTP(String url) throws Exception {
- URL u = new URL(url);
- URLConnection uc = u.openConnection();
- String contentType = uc.getContentType();
- int contentLength = uc.getContentLength();
- InputStream raw = uc.getInputStream();
- InputStream in = new BufferedInputStream(raw);
- byte[] data = new byte[contentLength];
- int bytesRead = 0;
- int offset = 0;
- LOGGER.info("loading started...");
- while (offset < contentLength) {
- System.out.print(".");
- bytesRead = in.read(data, offset, data.length - offset);
- if (bytesRead == -1)
- break;
- offset += bytesRead;
- }
- in.close();
- if (offset != contentLength) {
- throw new IOException("Only read " + offset + " bytes; Expected " + contentLength + " bytes");
- }
- return data;
- }
-
- /**
- * This method download a binary file located at the given URL and returns the byte array
- * TODO move to an util class
- * @param archiveRef2
- * @return
- * @throws IOException
- */
- private byte[] downloadArchive(String url) throws IOException {
- LOGGER.info("Downloading url "+url);
- URL u = new URL(url);
- if (StringUtils.startsWithIgnoreCase(url, "http://")
- || StringUtils
- .startsWithIgnoreCase(url, "https://")) {
- LOGGER.info("HTTP protocol");
- byte[] data=null;
- try {
- data = downloadHTTP(url);
- } catch (Exception e) {
- LOGGER.info(e.getMessage());
- LOGGER.info(e.getStackTrace().toString());
- e.printStackTrace();
- }
- return data;
- } else if (StringUtils.startsWithIgnoreCase(url, "ftp://")) {
- LOGGER.info("FTP protocol");
- byte[] data=null;
- try {
- data = downloadFTP(url);
- } catch (Exception e) {
- LOGGER.info(e.getMessage());
- LOGGER.info(e.getStackTrace().toString());
- e.printStackTrace();
- }
- return data;
- }
- return null;
- }
-
- private byte[] downloadFTP(String url) throws Exception {
- URL u = new URL(url);
- FTPClient client = new FTPClient();
- ByteArrayOutputStream fos = null;
- client.connect(u.getHost(), u.getPort());
- // hardcoded
- Property[] properties = WPSConfig.getInstance().getPropertiesForServer();
- Property ftpUserProp = WPSConfig.getInstance().getPropertyForKey(
- properties, "portalFTPUser");
- Property ftpPassProp = WPSConfig.getInstance().getPropertyForKey(
- properties, "portalFTPPassword");
- client.login(ftpUserProp.getStringValue(), ftpPassProp.getStringValue());
- int reply = client.getReplyCode();
- if (!FTPReply.isPositiveCompletion(reply)) {
- client.disconnect();
- }
- String filename = u.getFile();
- fos = new ByteArrayOutputStream();
- client.retrieveFile(filename, fos);
- byte[] data = fos.toByteArray();
- fos.close();
- client.disconnect();
- return data;
- }
-
-
-
- public void setArchive(byte[] archive) {
- LOGGER.info("setArchive");
- this.archive = archive;
- }
-
- public byte[] getArchive() {
- return archive;
- }
-
- public void setProcessId(String processId) {
- this.processId = processId;
- }
-
- public String getProcessId() {
- return processId;
- }
-
- public void setReference(boolean reference) {
- this.reference = reference;
- }
-
- public boolean isReference() {
- return reference;
- }
-
- public void setArchiveRef(String string) {
- this.archiveRef = string;
- }
-
- public String getArchiveRef() {
- return archiveRef;
- }
-
-}
+/***************************************************************
+ This implementation provides a framework to publish processes to the
+web through the OGC Web Processing Service interface. The framework
+is extensible in terms of processes and data handlers.
+
+ Copyright (C) 2006 by con terra GmbH
+
+ Authors:
+ Bastian Schaeffer, Institute for Geoinformatics, Muenster, Germany
+
+ Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
+ 48155 Muenster, Germany, 52n@conterra.de
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program (see gnu-gpl v2.txt); if not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA or visit the web page of the Free
+ Software Foundation, http://www.fsf.org.
+
+ ***************************************************************/
+
+package org.n52.wps.server.profiles.IntalioBPMS;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Map;
+
+import net.opengis.wps.x100.ApacheOdeDeploymentProfileType;
+import net.opengis.wps.x100.DeployProcessDocument;
+
+import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPReply;
+import org.apache.log4j.Logger;
+import org.n52.wps.PropertyDocument.Property;
+import org.n52.wps.commons.WPSConfig;
+import org.n52.wps.server.ExceptionReport;
+import org.n52.wps.server.request.deploy.DeploymentProfile;
+import org.w3c.dom.Node;
+
+/**
+ * TODO rename ApacheOdeDeployementProfile to match to the XSD element type
+ * **/
+public class BPELDeploymentProfile extends DeploymentProfile {
+
+ private static Logger LOGGER = Logger.getLogger(BPELDeploymentProfile.class);
+ private Node suitCase;
+ private Node bpel;
+ private Node clientWSDL;
+ private Map wsdlList;
+ private byte[] archive;
+ private String processId;
+ private boolean reference;
+ private String archiveRef;
+
+ public BPELDeploymentProfile(DeployProcessDocument deployDom,
+ String processID) {
+ super(deployDom, processID);
+ try {
+
+ extractInformation(deployDom);
+ } catch (Exception e) {
+
+ e.printStackTrace();
+ }
+
+ }
+
+ public Node getSuitCase() {
+ return suitCase;
+ }
+
+ public Node getBPEL() {
+ return bpel;
+ }
+
+ public Node getClientWSDL() {
+ return clientWSDL;
+ }
+
+ public Map getWSDLList() {
+ return wsdlList;
+ }
+
+ private void extractInformation(DeployProcessDocument deployDom)
+ throws Exception {
+
+ ApacheOdeDeploymentProfileType deployProfile = (ApacheOdeDeploymentProfileType) deployDom.getDeployProcess().getDeploymentProfile().changeType(ApacheOdeDeploymentProfileType.type);
+ if(!deployProfile.validate()) {
+ throw new ExceptionReport("BPEL Deploy Profile is not valid (according WPS schemas)",ExceptionReport.INVALID_PARAMETER_VALUE);
+ }
+ setProcessId(deployDom.getDeployProcess().getProcessDescription()
+ .getIdentifier().getStringValue());
+ if (deployProfile.isSetArchive()) {
+ // Note that XMLBeans automatically decodes base64
+ setArchive(deployProfile.getArchive());
+ setReference(false);
+ } else if (deployProfile.isSetArchiveReference()) {
+ setArchiveRef(deployProfile.getArchiveReference().getHref());
+ LOGGER.info("downloading archive");
+ setArchive(downloadArchive(getArchiveRef()));
+ setReference(true);
+ }
+ }
+
+
+
+ public void setArchive(byte[] archive) {
+ LOGGER.info("setArchive");
+ this.archive = archive;
+ }
+
+ public byte[] getArchive() {
+ return archive;
+ }
+
+ public void setProcessId(String processId) {
+ this.processId = processId;
+ }
+
+ public String getProcessId() {
+ return processId;
+ }
+
+ public void setReference(boolean reference) {
+ this.reference = reference;
+ }
+
+ public boolean isReference() {
+ return reference;
+ }
+
+ public void setArchiveRef(String string) {
+ this.archiveRef = string;
+ }
+
+ public String getArchiveRef() {
+ return archiveRef;
+ }
+
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IntalioBPMS/CallbackManager.java b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IntalioBPMS/CallbackManager.java
index b30a5efd7..c07c38d65 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IntalioBPMS/CallbackManager.java
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IntalioBPMS/CallbackManager.java
@@ -1,57 +1,53 @@
-package org.n52.wps.server.profiles.IntalioBPMS;
-
-import net.opengis.wps.x100.ExecuteResponseDocument;
-import net.opengis.wps.x100.ExecuteResponseDocument.ExecuteResponse;
-
-import org.apache.axis2.client.async.AxisCallback;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.saaj.util.SAAJUtil;
-import org.apache.axis2.util.XMLUtils;
-import org.apache.log4j.spi.LoggerFactory;
-import org.apache.xmlbeans.XmlException;
-import org.w3c.dom.Document;
-
-public class CallbackManager implements AxisCallback {
-
- private String id = "0";
- public boolean completed = false;
- private ApacheOdeProcessManager pm;
-
- public CallbackManager(ApacheOdeProcessManager pm) {
- this.pm = pm;
- }
-
- @Override
- public void onComplete() {
- this.pm.notifyRequestManager();
- }
-
- @Override
- public void onError(Exception arg0) {
- // TODO
- System.out.println("Unhandled error");
- }
-
- @Override
- public void onFault(MessageContext arg0) {
- // TODO Auto-generated method stub
- System.out.println("Thread #" + this.id + " fault");
- }
-
- @Override
- public void onMessage(MessageContext message) {
- Document envelope = SAAJUtil.getDocumentFromSOAPEnvelope(message
- .getEnvelope());
- ExecuteResponseDocument result = null;
- try {
- result = ExecuteResponseDocument.Factory.parse(envelope
- .getFirstChild().getChildNodes().item(1).getFirstChild());
- } catch (XmlException e) {
- e.printStackTrace();
- }
- if (result instanceof ExecuteResponseDocument) {
- this.pm.setExecuteResponse((ExecuteResponseDocument) result);
- }
- }
-
-}
+package org.n52.wps.server.profiles.IntalioBPMS;
+
+import net.opengis.wps.x100.ExecuteResponseDocument;
+import org.apache.axis2.client.async.AxisCallback;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.saaj.util.SAAJUtil;
+import org.apache.xmlbeans.XmlException;
+import org.w3c.dom.Document;
+
+public class CallbackManager implements AxisCallback {
+
+ private String id = "0";
+ public boolean completed = false;
+ private ApacheOdeProcessManager pm;
+
+ public CallbackManager(ApacheOdeProcessManager pm) {
+ this.pm = pm;
+ }
+
+ @Override
+ public void onComplete() {
+ this.pm.notifyRequestManager();
+ }
+
+ @Override
+ public void onError(Exception arg0) {
+ // TODO
+ System.out.println("Unhandled error");
+ }
+
+ @Override
+ public void onFault(MessageContext arg0) {
+ // TODO Auto-generated method stub
+ System.out.println("Thread #" + this.id + " fault");
+ }
+
+ @Override
+ public void onMessage(MessageContext message) {
+ Document envelope = SAAJUtil.getDocumentFromSOAPEnvelope(message
+ .getEnvelope());
+ ExecuteResponseDocument result = null;
+ try {
+ result = ExecuteResponseDocument.Factory.parse(envelope
+ .getFirstChild().getChildNodes().item(1).getFirstChild());
+ } catch (XmlException e) {
+ e.printStackTrace();
+ }
+ if (result instanceof ExecuteResponseDocument) {
+ this.pm.setExecuteResponse((ExecuteResponseDocument) result);
+ }
+ }
+
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IntalioBPMS/ODEServiceClient.java b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IntalioBPMS/ODEServiceClient.java
index f9931fd40..165dd3d74 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IntalioBPMS/ODEServiceClient.java
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/IntalioBPMS/ODEServiceClient.java
@@ -16,7 +16,7 @@
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.transport.http.HTTPConstants;
-import org.apache.ode.utils.Namespaces;
+
/**
*
@@ -71,7 +71,7 @@ public OMElement send(OMElement msg, String url, long timeout, String action) th
public OMElement buildMessage(String operation, String[] params, Object[] values) {
OMFactory _factory = OMAbstractFactory.getOMFactory();
- OMNamespace pmns = _factory.createOMNamespace(Namespaces.ODE_PMAPI_NS, "pmapi");
+ OMNamespace pmns = _factory.createOMNamespace("", "pmapi");
OMElement root = _factory.createOMElement(operation, pmns);
for (int m = 0; m < params.length; m++) {
OMElement omelmt = _factory.createOMElement(params[m], null);
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/JavaSaga/JavaSagaDeploymentProfile.java b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/JavaSaga/JavaSagaDeploymentProfile.java
deleted file mode 100644
index b45261149..000000000
--- a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/JavaSaga/JavaSagaDeploymentProfile.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/***************************************************************
- This implementation provides a framework to publish processes to the
-web through the OGC Web Processing Service interface. The framework
-is extensible in terms of processes and data handlers.
-
- Copyright (C) 2006 by con terra GmbH
-
- Authors:
- Bastian Schaeffer, Institute for Geoinformatics, Muenster, Germany
-
- Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
- 48155 Muenster, Germany, 52n@conterra.de
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program (see gnu-gpl v2.txt); if not, write to
- the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA or visit the web page of the Free
- Software Foundation, http://www.fsf.org.
-
- ***************************************************************/
-
-package org.n52.wps.server.profiles.JavaSaga;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Map;
-
-import net.opengis.wps.x100.DeployProcessDocument;
-import net.opengis.wps.x100.SagaDeploymentProfileType;
-import net.opengis.wps.x100.SagaDeploymentProfileType.JsdlTemplate;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.io.output.ByteArrayOutputStream;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.net.ftp.FTP;
-import org.apache.commons.net.ftp.FTPClient;
-import org.apache.commons.net.ftp.FTPFile;
-import org.apache.commons.net.ftp.FTPReply;
-
-
-import org.apache.log4j.Logger;
-import org.n52.wps.PropertyDocument.Property;
-import org.n52.wps.commons.WPSConfig;
-import org.n52.wps.server.ExceptionReport;
-import org.n52.wps.server.request.deploy.DeploymentProfile;
-import org.w3c.dom.Node;
-
-
-/**
- * TODO rename ApacheOdeDeployementProfile to match to the XSD element type
- * **/
-public class JavaSagaDeploymentProfile extends DeploymentProfile {
-
- private static Logger LOGGER = Logger.getLogger(JavaSagaDeploymentProfile.class);
- private Node suitCase;
- private Node bpel;
- private Node clientWSDL;
- private Map wsdlList;
- private byte[] archive;
- private String processId;
- private boolean reference;
- private String archiveRef;
- private JsdlTemplate jsdlTemplate;
-
- public JavaSagaDeploymentProfile(DeployProcessDocument deployDom,
- String processID) {
- super(deployDom, processID);
- LOGGER.info("Java Saga Deployement Profile creating instance");
- try {
-
- extractInformation(deployDom);
- } catch (Exception e) {
- LOGGER.info(e.getStackTrace().toString());
- e.printStackTrace();
- }
-
- }
-
- public Node getSuitCase() {
- return suitCase;
- }
-
- public Node getBPEL() {
- return bpel;
- }
-
- public Node getClientWSDL() {
- return clientWSDL;
- }
-
- public Map getWSDLList() {
- return wsdlList;
- }
-
- private void extractInformation(DeployProcessDocument deployDom)
- throws Exception {
- LOGGER.info("extract information from saga profile");
- SagaDeploymentProfileType deployProfile = (SagaDeploymentProfileType) deployDom.getDeployProcess().getDeploymentProfile().changeType(SagaDeploymentProfileType.type);
- if(!deployProfile.validate()) {
- throw new ExceptionReport("Saga Deploy Profile is not valid (according WPS schemas)",ExceptionReport.INVALID_PARAMETER_VALUE);
- }
-
- LOGGER.info("deployProfile doc:"+deployProfile.toString());
- setProcessId(deployDom.getDeployProcess().getProcessDescription()
- .getIdentifier().getStringValue());
- if (deployProfile.isSetArchive()) {
- // Note that XMLBeans automatically decodes base64
- setArchive(deployProfile.getArchive());
- setReference(false);
- } else if (deployProfile.isSetArchiveReference()) {
- LOGGER.info("archive reference is set");
- setArchiveRef(deployProfile.getArchiveReference().getHref());
- LOGGER.info("downloading archive");
- setArchive(downloadArchive(getArchiveRef()));
- LOGGER.info("downloaded");
- setReference(true);
- }
- //LOGGER.info(deployProfile.getJsdlTemplate());
- setJsdlTemplate(deployProfile.getJsdlTemplate());
- }
-
- private byte[] downloadHTTP(String url) throws Exception {
- URL u = new URL(url);
- URLConnection uc = u.openConnection();
- String contentType = uc.getContentType();
- int contentLength = uc.getContentLength();
- InputStream raw = uc.getInputStream();
- InputStream in = new BufferedInputStream(raw);
- byte[] data = new byte[contentLength];
- int bytesRead = 0;
- int offset = 0;
- LOGGER.info("loading started...");
- while (offset < contentLength) {
- System.out.print(".");
- bytesRead = in.read(data, offset, data.length - offset);
- if (bytesRead == -1)
- break;
- offset += bytesRead;
- }
- in.close();
- if (offset != contentLength) {
- throw new IOException("Only read " + offset + " bytes; Expected " + contentLength + " bytes");
- }
- return data;
- }
-
- /**
- * This method download a binary file located at the given URL and returns the byte array
- * @param archiveRef2
- * @return
- * @throws IOException
- */
- private byte[] downloadArchive(String url) throws IOException {
- LOGGER.info("Downloading url "+url);
- URL u = new URL(url);
- if (StringUtils.startsWithIgnoreCase(url, "http://")
- || StringUtils
- .startsWithIgnoreCase(url, "https://")) {
- LOGGER.info("HTTP protocol");
- byte[] data=null;
- try {
- data = downloadHTTP(url);
- } catch (Exception e) {
- LOGGER.info(e.getMessage());
- LOGGER.info(e.getStackTrace().toString());
- e.printStackTrace();
- }
- return data;
- } else if (StringUtils.startsWithIgnoreCase(url, "ftp://")) {
- LOGGER.info("FTP protocol");
- byte[] data=null;
- try {
- data = downloadFTP(url);
- } catch (Exception e) {
- LOGGER.info(e.getMessage());
- LOGGER.info(e.getStackTrace().toString());
- e.printStackTrace();
- }
- return data;
- }
- return null;
- }
-
- private byte[] downloadFTP(String url) throws Exception {
- try {
- LOGGER.info("Downloading through FTP: "+url);
- URL u = new URL(url);
- FTPClient client = new FTPClient();
- ByteArrayOutputStream fos = null;
- int port = u.getPort() == -1 ? 21 : u.getPort();
- LOGGER.info("port: "+port+ " - connecting to "+u.getHost());
- try {
- client.connect(u.getHost(), port);
- }
- catch(Exception e) {
- LOGGER.info("connection fault:"+e.getMessage()+ " " + e.getCause().toString());
-
- throw e;
- }
- // connection error code
- int reply = client.getReplyCode();
- if (!FTPReply.isPositiveCompletion(reply)) {
- LOGGER.info("Disconnect on positive completion");
- client.disconnect();
- throw new ExceptionReport("FTP connection failed",ExceptionReport.NO_APPLICABLE_CODE);
- }
- LOGGER.info("connected");
- client.setDefaultTimeout(60000);
- client.setConnectTimeout(60000);
- // currently bugging
- //Property[] properties = WPSConfig.getInstance().getPropertiesForServer();
- //Property ftpUserProp = WPSConfig.getInstance().getPropertyForKey(
- //properties, "portalFTPUser");
- //LOGGER.info("user found in config: "+ftpUserProp.getStringValue());
- //Property ftpPassProp = WPSConfig.getInstance().getPropertyForKey(
- // properties, "portalFTPPassword");
- // LOGGER.info("password found in config: "+ftpPassProp.getStringValue());
- //client.login(ftpUserProp.getStringValue(), ftpPassProp.getStringValue());
- client.login("ftpuser", "ssegrid");
- LOGGER.info("logged");
- String filename = u.getFile();
- int slashIndex = filename.lastIndexOf('/') + 1;
- String parent = "."+filename.substring(0, slashIndex);
- String ftpFileName = filename.substring(slashIndex);
- LOGGER.info("parent:"+parent);
- LOGGER.info("filename:"+filename);
- FTPFile ftpFile = null;
- for (FTPFile f : client.listFiles(parent)) {
- if (StringUtils.equals(f.getName(), ftpFileName)) {
- LOGGER.info("found"+f.getName());
- ftpFile = f;
- }
- }
- if (ftpFile == null) {
- throw new IOException("File not found: " + ftpFileName);
- }
- int total = (int) ftpFile.getSize();
- LOGGER.info("total:"+total);
- LOGGER.info("get file name: "+filename);
- fos = new ByteArrayOutputStream();
- LOGGER.info("retrieve file....");
- //client.retrieveFile("."+filename, fos);
- // Set to Binary Mode !!!
- client.setFileType(FTP.BINARY_FILE_TYPE);
- InputStream raw = client.retrieveFileStream("."+filename);
- // InputStream in = new BufferedInputStream(raw, client.getBufferSize());
- byte[] data = new byte[total];
- data = IOUtils.toByteArray(raw);
- /** useless
- int bytesRead = 0;
- int offset = 0;
- LOGGER.info("loading started...");
- while (offset < total) {
- System.out.print(".");
- bytesRead = in.read(data, offset, client.getBufferSize());
- if (bytesRead == -1)
- break;
- offset += bytesRead;
- }
- */
- raw.close();
- /**
- if (offset != total) {
- LOGGER.info("Only read " + offset + " bytes; Expected " + total + " bytes");
- // throw new IOException("Only read " + offset + " bytes; Expected " + total + " bytes");
- }
- */
- LOGGER.info("retrieved");
- //byte[] data = fos.toByteArray();
- //fos.close();
- client.disconnect();
- LOGGER.info("Lenght of file:"+data.length);
- return data;
- }
- catch(Exception e) {
- throw new ExceptionReport("FTP exception",ExceptionReport.REMOTE_COMPUTATION_ERROR,e);
-
- }
- }
-
- public void setArchive(byte[] archive) {
- LOGGER.info("setArchive");
- this.archive = archive;
- }
-
- public byte[] getArchive() {
- return archive;
- }
-
- public void setProcessId(String processId) {
- this.processId = processId;
- }
-
- public String getProcessId() {
- return processId;
- }
-
- public void setReference(boolean reference) {
- this.reference = reference;
- }
-
- public boolean isReference() {
- return reference;
- }
-
- public void setArchiveRef(String string) {
- this.archiveRef = string;
- }
-
- public String getArchiveRef() {
- return archiveRef;
- }
-
- public void setJsdlTemplate(JsdlTemplate jsdlTemplate) {
- this.jsdlTemplate = jsdlTemplate;
- }
-
- public JsdlTemplate getJsdlTemplate() {
- return jsdlTemplate;
- }
-
-}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/JavaSaga/JavaSagaProcessManager.java b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/JavaSaga/JavaSagaProcessManager.java
deleted file mode 100644
index 6228e7d74..000000000
--- a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/JavaSaga/JavaSagaProcessManager.java
+++ /dev/null
@@ -1,1274 +0,0 @@
-package org.n52.wps.server.profiles.JavaSaga;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.NoSuchElementException;
-import java.util.Vector;
-import java.util.concurrent.CancellationException;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathFactory;
-
-// XMLBeans schemas import
-import net.opengis.ows.x11.ExceptionReportDocument;
-import net.opengis.ows.x11.ExceptionType;
-import net.opengis.wps.x100.AuditTraceType;
-import net.opengis.wps.x100.DataInputsType;
-import net.opengis.wps.x100.DocumentOutputDefinitionType;
-import net.opengis.wps.x100.ExecuteDocument;
-import net.opengis.wps.x100.ExecuteResponseDocument;
-import net.opengis.wps.x100.ExecuteResponseDocument.ExecuteResponse.ProcessOutputs;
-import net.opengis.wps.x100.InputType;
-import net.opengis.wps.x100.OutputDataType;
-import net.opengis.wps.x100.OutputDescriptionType;
-import net.opengis.wps.x100.SagaDeploymentProfileType.JsdlTemplate;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument;
-import xint.esa.ssegrid.wps.javaSAGAProfile.URLListDocument;
-
-// Apache import
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMAttribute;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axiom.soap.SOAPHeaderBlock;
-import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.util.XMLUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlOptions;
-
-import org.n52.wps.PropertyDocument.Property;
-import org.n52.wps.commons.WPSConfig;
-import org.n52.wps.server.ComplexExceptionReport;
-import org.n52.wps.server.ExceptionReport;
-import org.n52.wps.server.profiles.AbstractProcessManager;
-import org.n52.wps.server.repository.ITransactionalAlgorithmRepository;
-import org.n52.wps.server.request.DeployProcessRequest;
-import org.n52.wps.server.request.ExecuteRequest;
-import org.n52.wps.server.request.UndeployProcessRequest;
-import org.n52.wps.server.request.deploy.DeploymentProfile;
-
-// Saga import
-import org.ogf.saga.context.Context;
-import org.ogf.saga.context.ContextFactory;
-import org.ogf.saga.error.BadParameterException;
-import org.ogf.saga.error.NoSuccessException;
-import org.ogf.saga.job.Job;
-import org.ogf.saga.session.Session;
-import org.ogf.saga.session.SessionFactory;
-import org.ogf.saga.task.State;
-import org.ogf.saga.url.URLFactory;
-import com.terradue.ogf.saga.impl.job.JobDescription;
-import com.terradue.ogf.saga.impl.job.JobFactory;
-import com.terradue.ogf.saga.impl.job.JobImpl;
-import com.terradue.ogf.saga.impl.job.JobServiceImpl;
-import com.terradue.ogf.schema.jsdl.JSDLException;
-import com.terradue.ogf.schema.jsdl.JSDLFactory;
-import com.terradue.ssegrid.sagaext.JSDLNotApplicableException;
-import com.terradue.ssegrid.sagaext.JobServiceAssistant;
-import com.terradue.ssegrid.sagaext.MyProxyClient;
-import com.terradue.ssegrid.sagaext.ProcessingRegistry;
-
-import org.w3.x2005.x08.addressing.MessageIDDocument;
-import org.w3.x2005.x08.addressing.ReplyToDocument;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-
-public class JavaSagaProcessManager extends AbstractProcessManager {
-
- // WPS Logger
- private static Logger LOGGER = Logger
- .getLogger(JavaSagaProcessManager.class);
-
- private String processesPrefix;
- // Location for process deployement
- private String deployProcessDir;
- private String WPSPublicationPrefix;
- private HashMap WPSmap;
- private String myProxyURL;
- private String myProxyUser;
- private String myProxyPassword;
-
- private String IID;
- private String processInstanceID;
-
- private String processID;
- private static String GridFilesDir;
- private static String SagaLibDir;
- private static org.ogf.saga.url.URL gridmapGLUE;
- private static ProcessingRegistry pr;
- private JobImpl runningJob;
- private boolean cancelHack;
- // Asychronous execute client must be shared between threads
- /**
- * TODO delete
- */
- public static ServiceClient executeClient;
-
- /**
- * @param repository
- * @throws NoSuccessException
- * @throws BadParameterException
- * @throws JSDLException
- * @throws JSDLNotApplicableException
- * @throws IOException
- * @throws FileNotFoundException
- */
- public JavaSagaProcessManager(ITransactionalAlgorithmRepository repository)
- throws BadParameterException, NoSuccessException,
- FileNotFoundException, IOException, JSDLNotApplicableException,
- JSDLException {
- super(repository);
- /**
- * Get useful properties from the repository configuration file: - SAGA
- * Home : home directory for saga files - GridmapGLUE : the gridmapGLUE
- * file location
- */
- Property[] properties = WPSConfig.getInstance()
- .getPropertiesForRepositoryName("JavaSagaRepository");
- Property WPSSaga = WPSConfig.getInstance().getPropertyForKey(
- properties, "GridFilesDir");
- if (WPSSaga == null) {
- throw new RuntimeException(
- "Error. Could not find the required GridFilesDir property in wps_config.xml");
- }
- setGridFilesDir(WPSSaga.getStringValue());
- Property sagaLibProp = WPSConfig.getInstance().getPropertyForKey(
- properties, "SagaLibDir");
- if (sagaLibProp == null) {
- throw new RuntimeException(
- "Error. Could not find the required SagaLibDir property in wps_config.xml");
- }
- setSagaLibDir(sagaLibProp.getStringValue());
-
- Property myProxyURLProp = WPSConfig.getInstance().getPropertyForKey(
- properties, "MyProxyURL");
- if (myProxyURLProp == null) {
- throw new RuntimeException(
- "Error. Could not find the required MyProxyUser property in wps_config.xml");
- }
- myProxyURL = myProxyURLProp.getStringValue();
-
- Property myProxyUserProp = WPSConfig.getInstance().getPropertyForKey(
- properties, "MyProxyUser");
- if (myProxyUserProp == null) {
- throw new RuntimeException(
- "Error. Could not find the required MyProxyUser property in wps_config.xml");
- }
- myProxyUser = myProxyUserProp.getStringValue();
-
- Property myProxyPasswordProp = WPSConfig.getInstance()
- .getPropertyForKey(properties, "MyProxyPassword");
- if (myProxyPasswordProp == null) {
- throw new RuntimeException(
- "Error. Could not find the required MyProxyUser property in wps_config.xml");
- }
- myProxyPassword = myProxyPasswordProp.getStringValue();
-
- System.setProperty("saga.location", getSagaLibDir());
- Property wpsPublicRoot = WPSConfig.getInstance().getPropertyForKey(
- properties, "WPSPublicationPrefix");
- if (wpsPublicRoot == null) {
- throw new RuntimeException(
- "Error. Could not find WPSPublicationPrefix");
- }
- setWPSPublicationPrefix(wpsPublicRoot.getStringValue());
-
- // Set the deployement process directory
- setDeployProcessDir(GridFilesDir + "deploy/process/");
- Property gridmap = WPSConfig.getInstance().getPropertyForKey(
- properties, "GridGlue");
- if (gridmap == null) {
- throw new RuntimeException(
- "Error. Could not find the required GridGlue property in wps_config.xml");
- }
- // Saga.location must be loaded before the following line
- JavaSagaProcessManager.gridmapGLUE = URLFactory.createURL(gridmap
- .getStringValue());
- /**
- * Set the required system properties (instead of setting them from
- * tomcat script)
- */
-
- System.setProperty("gai.default.rm", gridmapGLUE.toString());
- System.setProperty("gai.debug.working.dir", "true");
- System.setProperty("org.globus.tcp.port.range", "20000,22000");
- System.setProperty("gai.deploy.process.path", getDeployProcessDir());
- // Add port range prop org.globus.tcp.port.range="20000,20200"
- // TODO remove (useless here : getPRInstance();)
-
- }
-
- /**
- * Singleton for the ProcessingRegistry
- *
- * @return
- * @throws FileNotFoundException
- * @throws IOException
- * @throws JSDLNotApplicableException
- * @throws JSDLException
- */
- public static ProcessingRegistry getPRInstance()
- throws FileNotFoundException, IOException,
- JSDLNotApplicableException, JSDLException {
- if (pr == null) {
- LOGGER.info("ProcessingRegistry was not already instantiated.");
- try {
- pr = new ProcessingRegistry(true);
- } catch (FileNotFoundException e) {
- pr = new ProcessingRegistry(false);
- }
- // If recover is not working this should work
- /**
- * FindFilter fileFilter = new FindFilter("*.xml"); File[] files =
- * new File(getWPSSagaHome()).listFiles(fileFilter); if (files !=
- * null && files.length > 0) { for (File JSDLFile : files) {
- * LOGGER.info("Registering JSDL :" + JSDLFile.getAbsolutePath());
- * pr.registerProcessing(JSDLFactory .createJSDLDocument(JSDLFile));
- * } }
- */
- }
- return pr;
- }
-
- /**
- * Get the WPS Saga home directory
- *
- * @return
- */
- public static String getGridFilesDir() {
- return GridFilesDir;
- }
-
- /**
- * Set the WPS Saga home directory
- *
- * @param wPSSagaHome
- */
- public static void setGridFilesDir(String gFilesDir) {
- GridFilesDir = gFilesDir;
- }
-
- /**
- * Deploy a process : register the JSDL, store the archive (parsed by the
- * saga deployement profile) TODO interface signature should move to void
- * (exception is thrown on failure)
- *
- * @throws ExceptionReport
- */
- public boolean deployProcess(DeployProcessRequest request)
- throws ExceptionReport {
- DeploymentProfile profile = request.getDeploymentProfile();
- if (!(profile instanceof JavaSagaDeploymentProfile)) {
- throw new ExceptionReport("JavaSaga Deployement Profile not valid",
- ExceptionReport.INVALID_PARAMETER_VALUE);
- }
- JavaSagaDeploymentProfile deploymentProfile = (JavaSagaDeploymentProfile) profile;
- String processID = deploymentProfile.getProcessID();
- LOGGER.info("Saga deployement process for: " + processID);
- try {
- LOGGER.info("storing archive");
- storeArchive(deploymentProfile.getArchive(), processID);
- LOGGER.info("register JSDL");
- registerJSDL(processID, deploymentProfile.getJsdlTemplate());
-
- } catch (Exception e) {
- e.printStackTrace();
- throw new ExceptionReport("IO Exception during deployement",
- ExceptionReport.NO_APPLICABLE_CODE, e);
- }
- return true;
- }
-
- /**
- * Unzip a collection of files contained in a archive zip file and write
- * onto disk
- *
- * @param archive
- * @throws IOException
- */
- private void storeArchive(byte[] archive, String processId)
- throws IOException {
- LOGGER.info("Store Archive");
- String archiveDir = getDeployProcessDir() + processId + File.separator;
- // create dir
- File archiveFile = new File(archiveDir);
- if (!archiveFile.exists()) {
- archiveFile.mkdirs();
- }
- LOGGER.info("Storing archive in " + archiveDir);
- ByteArrayInputStream bais = new ByteArrayInputStream(archive);
- byte[] buf = new byte[1024];
- ZipInputStream zis = new ZipInputStream(bais);
- ZipEntry zipentry = zis.getNextEntry();
- while (zipentry != null) {
- String entryName = zipentry.getName();
- LOGGER.info("Writing file " + entryName);
- int n;
- FileOutputStream fileoutputstream;
- File newFile = new File(entryName);
- String directory = newFile.getParent();
- if (directory == null) {
- if (newFile.isDirectory())
- break;
- }
- fileoutputstream = new FileOutputStream(archiveDir + entryName);
- while ((n = zis.read(buf, 0, 1024)) > -1)
- fileoutputstream.write(buf, 0, n);
- fileoutputstream.close();
- zis.closeEntry();
- zipentry = zis.getNextEntry();
- }
- zis.close();
- }
-
- private void unstoreArchive(String processId) throws IOException {
- String archiveDir = getDeployProcessDir() + processId + File.separator;
- LOGGER.info("unstoring archive in " + archiveDir);
- File archFile = new File(archiveDir);
- deleteDir(archFile);
- }
-
- // Deletes all files and subdirectories under dir.
- // Returns true if all deletions were successful.
- // If a deletion fails, the method stops attempting to delete and returns
- // false.
- public static boolean deleteDir(File dir) {
- if (dir.isDirectory()) {
- String[] children = dir.list();
- for (int i = 0; i < children.length; i++) {
- boolean success = deleteDir(new File(dir, children[i]));
- if (!success) {
- return false;
- }
- }
- }
-
- // The directory is now empty so delete it
- return dir.delete();
- }
-
- /**
- * Store the given jsdl document in the DEPLOY_DIR and register with the
- * Processing Registry.
- *
- * @param processId
- * @param jsdlTemplate
- * @throws IOException
- * @throws TransformerFactoryConfigurationError
- * @throws TransformerException
- * @throws ParserConfigurationException
- * @throws NoSuccessException
- * @throws BadParameterException
- * @throws ExceptionReport
- * @throws JSDLException
- * @throws JSDLNotApplicableException
- */
- private void registerJSDL(String processId, JsdlTemplate jsdlTemplate)
- throws IOException, TransformerFactoryConfigurationError,
- TransformerException, ParserConfigurationException,
- BadParameterException, NoSuccessException, ExceptionReport,
- JSDLNotApplicableException, JSDLException {
- JobDefinitionDocument jsdl = JobDefinitionDocument.Factory
- .newInstance();
- jsdl.addNewJobDefinition().set(jsdlTemplate.getJobDefinition());
- LOGGER.info("JSDL to wrile:" + jsdl);
- String dirPath = GridFilesDir + "JSDLtemplates";
- LOGGER.info(dirPath);
- File directory = new File(dirPath);
- if (!directory.exists()) {
- directory.mkdirs();
- }
- String jsdlPath = dirPath + File.separator + processId + ".xml";
- File f = new File(jsdlPath);
- jsdl.save(f);
- LOGGER.info("Store JSDL in " + jsdlPath);
- // Register the JSDL
- File procJSDL = new File(jsdlPath);
- String regProcId = getPRInstance().registerProcessing(
- JSDLFactory.createJSDLDocument(procJSDL));
- if (!regProcId.equals(processId)) {
- LOGGER.info("matching failed between : " + regProcId + " - "
- + processId);
- throw new ExceptionReport(
- "Registered process id does not match the right process id",
- ExceptionReport.NO_APPLICABLE_CODE);
- }
- LOGGER.info("registering end...");
- }
-
- private void unregisterJSDL(String processId)
- throws NoSuchElementException, FileNotFoundException, IOException,
- JSDLNotApplicableException, JSDLException {
- String dirPath = GridFilesDir + "JSDLtemplates";
- String jsdlPath = dirPath + File.separator + processId + ".xml";
- File f = new File(jsdlPath);
- f.delete();
- LOGGER.info("Deleted JSDL in " + jsdlPath);
- // Unregister the JSDL
- try {
- getPRInstance().unregisterProcessing(processId);
- } catch (Exception e) {
- LOGGER.warn("-- PR Unregister failed -");
- }
-
- }
-
- /**
- * TODO
- *
- * @param processID
- * @return
- * @throws Exception
- */
- public boolean unDeployProcess(String processID) throws Exception {
- // Prepare undeploy message
- // TODO
- // Undeploy
- // sendToDeployment(root);
- unregisterJSDL(processID);
- unstoreArchive(processID);
-
- return true;
- }
-
- public String getStringFromDocument(Document doc) {
- try {
- DOMSource domSource = new DOMSource(doc);
- StringWriter writer = new StringWriter();
- StreamResult result = new StreamResult(writer);
- TransformerFactory tf = TransformerFactory.newInstance();
- Transformer transformer = tf.newTransformer();
- transformer.transform(domSource, result);
- return writer.toString();
- } catch (TransformerException ex) {
- ex.printStackTrace();
- return null;
- }
- }
-
- public Document invoke(ExecuteRequest req, String algorithmID)
- throws Exception {
- cancelHack = false;
- setProcessInstanceID(req.getId());
- ExecuteDocument doc = req.getExecDom();
- this.processID = algorithmID;
- // Initialize WPS Map
- WPSmap = new HashMap();
- WPSmap.put("WPS_DEPLOY_PROCESS_DIR", GridFilesDir + "deploy/process/");
- WPSmap.put("WPS_DEPLOY_AUXDATA_DIR", GridFilesDir + "deploy/auxdata/");
- WPSmap.put("WPS_JOB_INPUTS_DIR", GridFilesDir + "execute/" + processID
- + "/" + getProcessInstanceID() + "/${GAI_JOB_UID}/inputs");
- WPSmap.put("WPS_JOB_OUTPUTS_DIR", GridFilesDir + "execute/" + processID
- + "/" + getProcessInstanceID() + "/${GAI_JOB_UID}/outputs");
- WPSmap.put("WPS_JOB_AUDITS_DIR", GridFilesDir + "execute/" + processID
- + "/" + getProcessInstanceID() + "/${GAI_JOB_UID}/audits");
- WPSmap.put("WPS_JOB_RESULTS_DIR", GridFilesDir + "execute/" + processID
- + "/" + getProcessInstanceID() + "/${GAI_JOB_UID}/results");
- WPSmap.put("WPS_JOB_RESULTS_URL", WPSPublicationPrefix + "execute/"
- + processID + "/" + getProcessInstanceID()
- + "/${GAI_JOB_UID}/results");
-
- ExecuteResponseDocument execRepDom = null;
- this.setProcessID(algorithmID);
- // First create a session containing at least a context
- // for user credentials information
- Session session = SessionFactory.createSession(false);
- Context context = ContextFactory.createContext("globus");
- context.setAttribute(Context.USERPROXY, GridFilesDir + "proxy");
- session.addContext(context);
- LOGGER.info(context.getAttribute(Context.USERPROXY));
- // Get delegation to that user proxy and set propoerly context
- String cnName = null;
- try {
-
- for (SOAPHeaderBlock samlHeader : req.getSamlHeader()) {
- LOGGER.info("LocalName = " + samlHeader.getLocalName());
- OMElement assertion = (OMElement) samlHeader
- .getChildrenWithLocalName("Assertion").next();
- LOGGER.info("Assertion found:"+assertion.toString());
- OMElement attributeStatement = (OMElement) assertion
- .getChildrenWithLocalName("AttributeStatement").next();
- LOGGER.info("AttributeStatement found");
- OMElement subject = (OMElement) attributeStatement
- .getChildrenWithLocalName("Subject").next();
- LOGGER.info("Subject found:"+subject.toString());
- OMElement nameIdentifier = (OMElement) subject
- .getChildrenWithLocalName("NameIdentifier").next();
- LOGGER.info("Name Id found"+nameIdentifier.toString());
- cnName = nameIdentifier.getText();
- LOGGER.info(cnName);
- }
-
- } catch (Exception e) {
- }
-
- if (cnName != null && !cnName.equals("spb") && !cnName.equals("vito")
- && !cnName.equals("superuser") && !cnName.equals("esasp")) {
- throw new ExceptionReport(
- "No Grid Proxy account is associated with the user",
- ExceptionReport.REMOTE_COMPUTATION_ERROR);
- }
- MyProxyClient.delegateProxyFromMyProxyServer(myProxyURL, 7512,
- myProxyUser, myProxyPassword, 604800, context);
- // then create a JobService from the JobFactory
- // that is ready to handle job submission passing the session
- // information
- // and the Resource Manager
- // N.B. here is an "extended" JobService
- JobServiceImpl js = JobFactory
- .createJobService(session/* , gridmapGLUE */);
- // Pass the additional substitution
- // create the JobServiceAssistant in order to provide
- // useful methods for the backend WPS process manager
- JobServiceAssistant jsa = new JobServiceAssistant(js);
- jsa.addSubstitutionVariables(WPSmap);
- // initialize a job description from the registered processing
- JobDescription jd = (JobDescription) JobFactory
- .createJobDescription(getPRInstance().getJSDLFromProc(
- algorithmID));
- // Build literal and complex inputs maps
- Map literalInputs = new HashMap();
- Map complexInputs = new HashMap();
- InputType[] inputs = doc.getExecute().getDataInputs().getInputArray();
- int numberOfTasks = 0;
- for (int i = 0; i < inputs.length; i++) {
- if (inputs[i].getData().isSetLiteralData()) {
- LOGGER.info("Found literal data: "
- + inputs[i].getIdentifier().getStringValue() + " - "
- + inputs[i].getData().getLiteralData().getStringValue());
- if (inputs[i].getIdentifier().getStringValue()
- .equals("numberOfTasks")) {
- numberOfTasks = Integer.parseInt(inputs[i].getData()
- .getLiteralData().getStringValue());
- } else {
- literalInputs.put("WPS_INPUT_"
- + inputs[i].getIdentifier().getStringValue(),
- inputs[i].getData().getLiteralData()
- .getStringValue());
- }
- }
- if (inputs[i].getData().isSetComplexData()) {
- LOGGER.info("Found complex data: "
- + inputs[i].getIdentifier().getStringValue() + " - "
- + inputs[i].getData().getComplexData().xmlText());
- // TODO the following conversion to String can be simplified
- StringWriter stringWriter = new StringWriter();
- Transformer transformer = TransformerFactory.newInstance()
- .newTransformer();
- transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,
- "no");
- NodeList nodeList = inputs[i].getData().getComplexData()
- .getDomNode().getChildNodes();
- Node urlListNode = null;
- for (int k = 0; k < nodeList.getLength(); k++) {
- if (nodeList.item(k).getLocalName() != null
- && nodeList.item(k).getLocalName()
- .equals("URLList")) {
- urlListNode = nodeList.item(k);
- break;
- }
- }
- transformer.transform(new DOMSource(urlListNode),
- new StreamResult(stringWriter));
-
- // XMLBeans parsing for validation (exception is thrown on
- // failure)
- LOGGER.info("String writer contains : "
- + stringWriter.toString());
- XmlOptions options = new XmlOptions();
- URLListDocument urlDom = URLListDocument.Factory.parse(
- stringWriter.toString(), options);
- // Namespace-non-aware document used as workaround for the
- // extension bug (xpath does not include namespace)
- // -> xpath.compile("/URLList/url/text()"); int m = ((Double)
- String sampleString = stringWriter.toString();
- InputSource is = new InputSource(new StringReader(sampleString));
- DocumentBuilderFactory dbf = DocumentBuilderFactory
- .newInstance();
- DocumentBuilder db = dbf.newDocumentBuilder();
- Document inputXML = db.parse(is);
- LOGGER.info("Complex Document Added: "
- + inputs[i].getIdentifier().getStringValue() + " - "
- + getStringFromDocument(inputXML));
- complexInputs.put(inputs[i].getIdentifier().getStringValue(),
- inputXML);
- }
- }
- if (literalInputs.size() > 0) {
- try {
- jsa.substituteSimpleInputs(jd, literalInputs);
- } catch (Exception e) {
- throw new ExceptionReport(e.getMessage(),
- ExceptionReport.INVALID_PARAMETER_VALUE, e);
- }
- }
- // Once JobDescription ready to run, create the jobs, run them, and wait
- // for them.
- // N.B. In this case, the "extension" provides a new class to handle an
- // array of jobs; they are still accessible individually from the
- // attributes
- // System.out.println("Creating job in "
- // + jd.getAttribute("NUMBEROFPROCESSES") + " instances");
- if (((com.terradue.ogf.saga.impl.job.JobDescriptionImpl) jd)
- .getAttribute("NumberOfProcesses") != null) {
- LOGGER.info("Creating job in "
- + ((com.terradue.ogf.saga.impl.job.JobDescriptionImpl) jd)
- .getAttribute("NumberOfProcesses") + " instances");
- } else {
- LOGGER.info("NumberOfProcesses attribute is null");
- }
- JobImpl jobs = null;
- if (numberOfTasks == 0) {
- jobs = ((JobServiceImpl) js).createJob(jd);
- } else {
- jobs = ((JobServiceImpl) js).createJob(jd, numberOfTasks);
- }
- // create now the job execute dirs
- String inputsDir = jobs.getSubstitutedVariable("WPS_JOB_INPUTS_DIR");
- String outputsDir = jobs.getSubstitutedVariable("WPS_JOB_OUTPUTS_DIR");
- String auditsDir = jobs.getSubstitutedVariable("WPS_JOB_AUDITS_DIR");
- String resultsDir = jobs.getSubstitutedVariable("WPS_JOB_RESULTS_DIR");
- LOGGER.info("Creating inputsDir:" + inputsDir);
- (new File(inputsDir)).mkdirs();
- (new File(outputsDir)).mkdirs();
- (new File(auditsDir)).mkdirs();
- (new File(resultsDir)).mkdirs();
- (new File(resultsDir)).setWritable(true, false);
- if (complexInputs.size() > 0) {
- try {
- jsa.writeComplexInputs(jobs, complexInputs);
- } catch (Exception e) {
- throw new ExceptionReport(e.getMessage(),
- ExceptionReport.INVALID_PARAMETER_VALUE, e);
- }
- }
- // Callbacks
- jobs.addCallback(Job.JOB_STATE, new SagaCallbackManager());
- jobs.addCallback(Job.JOB_STATEDETAIL, new SagaCallbackManager());
- LOGGER.info("Running job...");
- setRunningJob(jobs);
- jobs.run();
- LOGGER.info("saga job id:" + jobs.getId());
- setIID(jobs.getId());
- LOGGER.info("jobs.run() returned " + jobs.getState().getValue());
- // wait for all jobs in the job array
- LOGGER.info("Waiting for...");
- jobs.waitFor();
- if (jobs.isCancelled() || cancelHack) {
- LOGGER.info("Force cancel if interruption not successful");
- throw new CancellationException();
- }
- // Check if any exitMessage is non null
- boolean exitFault = false;
- String[][] exitMessages;
- try {
- exitMessages = jsa.readExitMessages(jobs);
- for (String[] exitMessage : exitMessages) {
- if (!exitMessage[0].trim().equals("0")) {
- exitFault = true;
- LOGGER.info("exitFault is true: " + exitMessage[0] + "-"
- + exitMessage[1]);
- break;
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- throw new ExceptionReport(
- "No exitMessage file is present: check the Grid infrastructure or the application script file.",
- ExceptionReport.REMOTE_COMPUTATION_ERROR);
- }
- LOGGER.info("Job state:" + jobs.getState());
- if (jobs.getState() == State.DONE & !exitFault) {
- LOGGER.info("Jobs completed");
- OutputDescriptionType[] outputsDesc = this.parentRepository
- .getProcessDescription(algorithmID).getProcessOutputs()
- .getOutputArray();
- Vector literalOutputNames = new Vector();
- Vector complexOutputNames = new Vector();
- // TODO other case ? and check valid ?
- LOGGER.info("Building outputs");
- if (doc.getExecute().getResponseForm() != null) {
- DocumentOutputDefinitionType[] outputs = doc.getExecute()
- .getResponseForm().getResponseDocument()
- .getOutputArray();
- for (int i = 0; i < outputs.length; i++) {
- String id = outputs[i].getIdentifier().getStringValue();
- for (int j = 0; j < outputsDesc.length; j++) {
- if (outputsDesc[j].getIdentifier().getStringValue()
- .equals(id)) {
- if (outputsDesc[j].isSetLiteralOutput()) {
- literalOutputNames.add(id);
- }
- if (outputsDesc[j].isSetComplexOutput()) {
- complexOutputNames.add(id);
- }
- }
- }
- }
- } else {
- for (int j = 0; j < outputsDesc.length; j++) {
-
- if (outputsDesc[j].isSetLiteralOutput()) {
- literalOutputNames.add(outputsDesc[j].getIdentifier()
- .getStringValue());
- LOGGER.info("Literal output:"
- + outputsDesc[j].getIdentifier()
- .getStringValue());
- }
- if (outputsDesc[j].isSetComplexOutput()) {
- complexOutputNames.add(outputsDesc[j].getIdentifier()
- .getStringValue());
- LOGGER.info("Complex Output:"
- + outputsDesc[j].getIdentifier()
- .getStringValue());
- }
- }
- }
-
- // Preparing an ExecuteResponse document
- // (This is the fastest way to implement but probably not the right
- // way to go)
- execRepDom = ExecuteResponseDocument.Factory.newInstance();
- execRepDom.addNewExecuteResponse();
- execRepDom.getExecuteResponse().setLang("en");
- execRepDom.getExecuteResponse().addNewProcessInstanceIdentifier()
- .setInstanceId(req.getId());
- execRepDom.getExecuteResponse().addNewStatus()
- .setProcessSucceeded("success");
- execRepDom.getExecuteResponse().addNewProcessOutputs();
- ProcessOutputs outputsDom = execRepDom.getExecuteResponse()
- .getProcessOutputs();
- if (complexOutputNames.size() > 0) {
- Map complexOutputMap = jsa
- .readComplexOutputs(jobs, (String[]) complexOutputNames
- .toArray(new String[complexOutputNames.size()]));
- Iterator> complexOutputsIterator = complexOutputMap
- .entrySet().iterator();
- while (complexOutputsIterator.hasNext()) {
- Entry entry = complexOutputsIterator
- .next();
- LOGGER.info("Found Complex Output:" + entry.getKey()
- + " - " + nodeToString(entry.getValue()));
- OutputDataType newOutput = outputsDom.addNewOutput();
- newOutput.addNewIdentifier().setStringValue(entry.getKey());
- newOutput
- .addNewData()
- .addNewComplexData()
- .set(URLListDocument.Factory
- .parse(nodeToString(entry.getValue())));
- LOGGER.info("test:"
- + URLListDocument.Factory.parse(
- nodeToString(entry.getValue())).toString());
- }
- }
- if (literalOutputNames.size() > 0) {
- Iterator> simpleOutputsIterator = jsa
- .readSimpleOutputs(jobs).entrySet().iterator();
- // build map
- while (simpleOutputsIterator.hasNext()) {
- Entry entry = simpleOutputsIterator.next();
- OutputDataType newOutput = outputsDom.addNewOutput();
- newOutput.addNewIdentifier().setStringValue(entry.getKey());
- newOutput.addNewData().addNewLiteralData()
- .setStringValue(entry.getValue());
- LOGGER.info("Found Literal Output:" + entry.getKey()
- + " - " + entry.getValue());
- }
- }
- LOGGER.info("Execution Output Document: " + outputsDom.toString());
-
- System.out.println("END");
-
- } else {
- LOGGER.info("Jobs failed, throwing exception");
- // TODO handle ExitMessages
- throw new ComplexExceptionReport(
- "Grid Jobs failed throwing exceptions",
- buildExceptionReportDom(exitMessages),
- ExceptionReport.REMOTE_COMPUTATION_ERROR);
-
- }
-
- return (Document) execRepDom.getDomNode();
-
- }
-
- private void setProcessInstanceID(String instanceID) {
- this.processInstanceID = instanceID;
-
- }
-
- private void setIID(String id) {
- this.IID = id;
-
- }
-
- public ExceptionReportDocument buildExceptionReportDom(
- String[][] exitMessages) {
- // Printing serivce Exception
- ExceptionReportDocument report = ExceptionReportDocument.Factory
- .newInstance();
- net.opengis.ows.x11.ExceptionReportDocument.ExceptionReport exceptionReport = report
- .addNewExceptionReport();
- for (int i = 0; i < exitMessages.length; i++) {
- String[] exitMessage = exitMessages[i];
- LOGGER.info("exitMessage:" + exitMessages[i]);
- ExceptionType ex = exceptionReport.addNewException();
- ex.setExceptionCode(exitMessage[0]);
- ex.setLocator("Task" + (i + 1));
- ex.addExceptionText(exitMessage[1]);
- }
- // Adding additional Java exception
- return report;
- }
-
- public Collection getAllProcesses() {
- LOGGER.info("TODO should not be reached yet");
- return null;
- }
-
- public boolean containsProcess(String processID) throws Exception {
- boolean containsProcess = false;
- // need to filter out the namespace if it is passed in.
- if (processID.contains("}"))
- processID = processID.split("}")[1];
-
- // return getAllProcesses().contains(processID);
- return containsProcess;
- // throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public boolean unDeployProcess(UndeployProcessRequest request)
- throws Exception {
- // unDeployProcess(String processID) is implemented though...
- LOGGER.info("Saga undeploying...");
- return unDeployProcess((String) request.getProcessID());
- // return false;
- // throw new UnsupportedOperationException("Not supported yet.");
- }
-
- /**
- * private OMElement sendToPM(OMElement msg) throws AxisFault { return
- * _client.send(msg, this.processManagerEndpoint); // return
- * _PMclient.send(msg, this.processManagerEndpoint,10000); }
- *
- * private OMElement sendToDeployment(OMElement msg) throws AxisFault {
- * return _client.send(msg, this.deploymentEndpoint);
- *
- * // return _DEPclient.send(msg,this.deploymentEndpoint,10000); }
- */
- private ByteArrayOutputStream writeXMLToStream(Source source)
- throws TransformerException {
- // Prepare the DOM document for writing
-
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- // Prepare the output file
-
- Result result = new StreamResult(out);
- // System.etProperty("javax.xml.transform.TransformerFactory","com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");
- // Write the DOM document to the file
- TransformerFactory x = TransformerFactory.newInstance();
- Transformer xformer = x.newTransformer();
- xformer.transform(source, result);
-
- return out;
- }
-
- private String nodeToString(Node node)
- throws TransformerFactoryConfigurationError, TransformerException {
- StringWriter stringWriter = new StringWriter();
- Transformer transformer = TransformerFactory.newInstance()
- .newTransformer();
- transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
- transformer.transform(new DOMSource(node), new StreamResult(
- stringWriter));
-
- return stringWriter.toString();
- }
-
- public SOAPEnvelope createSOAPEnvelope(Node domNode) {
- SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
- SOAPEnvelope envelope = fac.getDefaultEnvelope();
-
- NamespaceContext ctx = new NamespaceContext() {
-
- public String getNamespaceURI(String prefix) {
- String uri;
- if (prefix.equals("wps"))
- uri = "http://www.opengis.net/wps/1.0.0";
- else if (prefix.equals("ows"))
- uri = "http://www.opengis.net/ows/1.1";
- else
- uri = null;
- return uri;
- }
-
- public String getPrefix(String namespaceURI) {
- return null;
- }
-
- public Iterator getPrefixes(String namespaceURI) {
- return null;
- }
- };
-
- XPathFactory xpathFact = XPathFactory.newInstance();
- XPath xpath = xpathFact.newXPath();
- xpath.setNamespaceContext(ctx);
-
- String identifier = null;
- String input = null;
- String xpathidentifier = "//ows:Identifier";
- String xpathinput = "//wps:DataInputs/wps:Input/wps:Data/wps:LiteralData";
-
- try {
- identifier = xpath.evaluate(xpathidentifier, domNode);
- input = xpath.evaluate(xpathinput, domNode);
- } catch (Exception e) {
- e.printStackTrace();
- }
- // OMNamespace wpsNs =
- // fac.createOMNamespace("http://scenz.lcr.co.nz/wpsHelloWorld", "wps");
- OMNamespace wpsNs = fac.createOMNamespace("http://scenz.lcr.co.nz/"
- + identifier, "wps");
- // creating the payload
-
- // TODO: parse the domNode to a request doc
- // OMElement method = fac.createOMElement("wpsHelloWorldRequest",
- // wpsNs);
- OMElement method = fac.createOMElement(identifier + "Request", wpsNs);
- OMElement value = fac.createOMElement("input", wpsNs);
- // value.setText("Niels");
- value.setText(input);
- method.addChild(value);
- envelope.getBody().addChild(method);
- return envelope;
- }
-
- @SuppressWarnings("unchecked")
- private SOAPEnvelope createSOAPEnvelope(ExecuteDocument execDoc) {
-
- SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
- SOAPEnvelope envelope = fac.getDefaultEnvelope();
-
- new NamespaceContext() {
-
- public String getNamespaceURI(String prefix) {
- String uri;
- if (prefix.equals("wps"))
- uri = "http://www.opengis.net/wps/1.0.0";
- else if (prefix.equals("ows"))
- uri = "http://www.opengis.net/ows/1.1";
- else
- uri = null;
- return uri;
- }
-
- public String getPrefix(String namespaceURI) {
- return null;
- }
-
- public Iterator getPrefixes(String namespaceURI) {
- return null;
- }
- };
-
- // _client = new ODEServiceClient();
- HashMap allProcesses = new HashMap();
-
- // OMElement listRoot = _client.buildMessage("listAllProcesses",
- // new String[] {}, new String[] {});
-
- OMElement result = null;
- /**
- * try { //result = sendToPM(listRoot); } catch (AxisFault e) { // TODO
- * Auto-generated catch block e.printStackTrace(); }
- */
- Iterator pi = result.getFirstElement().getChildrenWithName(
- new QName("http://www.apache.org/ode/pmapi/types/2006/08/02/",
- "process-info"));
-
- while (pi.hasNext()) {
- OMElement omPID = pi.next();
-
- String fullName = omPID
- .getFirstChildWithName(
- new QName(
- "http://www.apache.org/ode/pmapi/types/2006/08/02/",
- "pid")).getText();
- allProcesses.put(
- fullName.substring(fullName.indexOf("}") + 1,
- fullName.indexOf("-")),
- fullName.substring(1, fullName.indexOf("}")));
-
- }
-
- String identifier = execDoc.getExecute().getIdentifier()
- .getStringValue();
-
- OMNamespace wpsNs = null;
-
- for (String string : allProcesses.keySet()) {
-
- if (string.equals(identifier)) {
- wpsNs = fac.createOMNamespace(allProcesses.get(string), "nas");
- break;
- }
-
- }
- // creating the payload
-
- // TODO: parse the domNode to a request doc
- // OMElement method = fac.createOMElement("wpsHelloWorldRequest",
- // wpsNs);
- OMElement method = fac.createOMElement(identifier + "Request", wpsNs);
- envelope.getBody().addChild(method);
-
- DataInputsType datainputs = execDoc.getExecute().getDataInputs();
-
- for (InputType input1 : datainputs.getInputArray()) {
-
- String inputIdentifier = input1.getIdentifier().getStringValue();
- OMElement value = fac.createOMElement(inputIdentifier, "", "");
- if (input1.getData() != null
- && input1.getData().getLiteralData() != null) {
- value.setText(input1.getData().getLiteralData()
- .getStringValue());
- } else {
- // Node no =
- // input1.getData().getComplexData().getDomNode().getChildNodes().item(1);
- // value.setText("");
- // value.addChild(no);
- OMElement reference = fac.createOMElement("Reference",
- "http://www.opengis.net/wps/1.0.0", "wps");
- OMNamespace xlin = fac.createOMNamespace(
- "http://www.w3.org/1999/xlink", "xlin");
-
- OMAttribute attr = fac.createOMAttribute("href", xlin, input1
- .getReference().getHref());
- reference.addAttribute(attr);
- reference.addAttribute("schema", input1.getReference()
- .getSchema(), fac.createOMNamespace("", ""));
- value.addChild(reference);
- }
- method.addChild(value);
- }
-
- return envelope;
-
- }
-
- public void setProcessesPrefix(String processesPrefix) {
- this.processesPrefix = processesPrefix;
- }
-
- public String getProcessesPrefix() {
- return processesPrefix;
- }
-
- /**
- * Wait the asynchronousCallback
- */
- public synchronized void waitCallback() {
- try {
- LOGGER.info("Waiting callback");
- wait();
- LOGGER.info("Callback received");
- } catch (Exception e) {
- System.out.println(e);
- }
- return;
- }
-
- public synchronized void notifyRequestManager() {
- notify();
- }
-
- public void setDeployProcessDir(String deployProcessDir) {
- deployProcessDir.replace('/', File.separatorChar);
- deployProcessDir.replace('\\', File.separatorChar);
- if (deployProcessDir.endsWith("/") || deployProcessDir.endsWith("\\")) {
- this.deployProcessDir = deployProcessDir;
- } else {
- this.deployProcessDir = deployProcessDir + File.separator;
- }
- }
-
- public String getDeployProcessDir() {
- return deployProcessDir;
- }
-
- public AuditTraceType getAudit() {
- LOGGER.info("short form apache get audit");
- AuditTraceType audit = null;
- URLListDocument auditURLS = URLListDocument.Factory.newInstance();
- File auditDir = new File(GridFilesDir + "execute" + File.separator
- + processID + File.separator + getProcessInstanceID()
- + File.separator + getIID() + File.separator + "audits"
- + File.separator);
-
- LOGGER.info("--------------------------------------------------------------------");
- LOGGER.info("Audit dir: " + GridFilesDir + "execute" + File.separator
- + processID + File.separator + getProcessInstanceID()
- + File.separator + getIID() + File.separator + "audits"
- + File.separator);
- String[] filenames = auditDir.list();
- auditURLS.addNewURLList().setCount(filenames.length);
- for (String filename : filenames) {
- auditURLS
- .getURLList()
- .addNewUrl()
- .setStringValue(
- getWPSPublicationPrefix() + "execute"
- + File.separator + processID
- + File.separator + getProcessInstanceID()
- + File.separator + getIID()
- + File.separator + "audits"
- + File.separator + filename);
- }
- try {
- audit = AuditTraceType.Factory.parse(auditURLS.getDomNode());
- } catch (XmlException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return null;
- }
- // LOGGER.info(audit.toString());
- return audit;
-
- }
-
- public AuditTraceType getAuditLongForm() {
- LOGGER.info("long form saga get audit");
-
- return getAudit();
-
- }
-
- @Override
- public String getIID() {
- // TODO Auto-generated method stub
- return this.IID;
- }
-
- public void setProcessID(String processID) {
- this.processID = processID;
- }
-
- public String getProcessID() {
- return processID;
- }
-
- /**
- * TODO : re design the IProcessManager : instanceID is required for some
- * backend. All request information should be available at backend. To be
- * discussed...
- */
-
- @Override
- public Document invoke(ExecuteDocument payload, String algorithmID)
- throws Exception {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void callback(ExecuteResponseDocument execRespDom) {
- // TODO Auto-generated method stub
- return;
- }
-
- public void setWPSPublicationPrefix(String wPSPublicationPrefix) {
- WPSPublicationPrefix = wPSPublicationPrefix;
- }
-
- public String getWPSPublicationPrefix() {
- return WPSPublicationPrefix;
- }
-
- public String getProcessInstanceID() {
- return processInstanceID;
- }
-
- public static void setSagaLibDir(String sagaLibDir) {
- SagaLibDir = sagaLibDir;
- }
-
- public static String getSagaLibDir() {
- return SagaLibDir;
- }
-
- public void cancel() {
- LOGGER.info("getrunning job cancel");
- this.cancelHack = true;
- this.getRunningJob().cancel(true);
- }
-
- public void setRunningJob(JobImpl runningJob) {
- this.runningJob = runningJob;
- }
-
- public JobImpl getRunningJob() {
- return runningJob;
- }
-
- public String getMyProxyURL() {
- return myProxyURL;
- }
-
- public void setMyProxyURL(String myProxyURL) {
- this.myProxyURL = myProxyURL;
- }
-
- public String getMyProxyUser() {
- return myProxyUser;
- }
-
- public void setMyProxyUser(String myProxyUser) {
- this.myProxyUser = myProxyUser;
- }
-
- public String getMyProxyPassword() {
- return myProxyPassword;
- }
-
- public void setMyProxyPassword(String myProxyPassword) {
- this.myProxyPassword = myProxyPassword;
- }
-
-}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/JavaSaga/SagaCallbackManager.java b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/JavaSaga/SagaCallbackManager.java
deleted file mode 100644
index 222eef653..000000000
--- a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/JavaSaga/SagaCallbackManager.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.n52.wps.server.profiles.JavaSaga;
-
-import org.ogf.saga.context.Context;
-import org.ogf.saga.error.AuthorizationFailedException;
-import org.ogf.saga.error.NotImplementedException;
-import org.ogf.saga.monitoring.Callback;
-import org.ogf.saga.monitoring.Metric;
-import org.ogf.saga.monitoring.Monitorable;
-
-public class SagaCallbackManager implements Callback {
-
- @Override
- public boolean cb(Monitorable monitorable, Metric metric, Context context)
- throws NotImplementedException, AuthorizationFailedException {
- try {
- String value = metric.getAttribute(Metric.VALUE);
- String name = metric.getAttribute(Metric.NAME);
- System.out.println("Callback called for metric " + name + ", value = "
- + value);
- } catch (Throwable e) {
- System.err.println("error" + e);
- e.printStackTrace(System.err);
- }
-
- // Keep the callback.
- return true;
- }
-
-}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/OutputParser.java b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/OutputParser.java
index ef9d95e7f..f05c61f15 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/OutputParser.java
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/OutputParser.java
@@ -1,197 +1,196 @@
-/***************************************************************
- This implementation provides a framework to publish processes to the
-web through the OGC Web Processing Service interface. The framework
-is extensible in terms of processes and data handlers.
-
- Copyright (C) 2006 by con terra GmbH
-
- Authors:
- Bastian Schaeffer, Institute for Geoinformatics, Muenster, Germany
-
- Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
- 48155 Muenster, Germany, 52n@conterra.de
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program (see gnu-gpl v2.txt); if not, write to
- the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA or visit the web page of the Free
- Software Foundation, http://www.fsf.org.
-
- ***************************************************************/
-
-
-package org.n52.wps.server.profiles;
-import net.opengis.wps.x100.OutputDataType;
-import net.opengis.wps.x100.OutputDescriptionType;
-import net.opengis.wps.x100.ProcessDescriptionType;
-
-import org.apache.log4j.Logger;
-import org.n52.wps.io.IParser;
-import org.n52.wps.io.ParserFactory;
-import org.n52.wps.io.data.IData;
-import org.n52.wps.io.data.binding.complex.GTRasterDataBinding;
-import org.n52.wps.io.data.binding.complex.GTVectorDataBinding;
-import org.n52.wps.io.data.binding.complex.URLListDataBinding;
-import org.n52.wps.io.data.binding.literal.LiteralBooleanBinding;
-import org.n52.wps.io.data.binding.literal.LiteralDoubleBinding;
-import org.n52.wps.io.data.binding.literal.LiteralIntBinding;
-import org.n52.wps.io.data.binding.literal.LiteralStringBinding;
-import org.n52.wps.io.datahandler.xml.AbstractXMLParser;
-import org.n52.wps.server.ExceptionReport;
-import org.n52.wps.util.BasicXMLTypeFactory;
-
-
-public class OutputParser {
-
- private static Logger LOGGER = Logger
- .getLogger(OutputParser.class);
-
- /**
- * Handles the ComplexValueReference
- * @param class1
- * @param input The client input
- * @throws ExceptionReport If the input (as url) is invalid, or there is an error while parsing the XML.
- */
- protected static String handleComplexValueReference(OutputDataType output) throws ExceptionReport{
- return output.getReference().getHref();
-
- }
-
- /**
- * Handles the complexValue, which in this case should always include XML
- * which can be parsed into a FeatureCollection.
- * @param class1
- * @param input The client input
- * @throws ExceptionReport If error occured while parsing XML
- */
- protected static IData handleComplexValue(OutputDataType output, ProcessDescriptionType processDescription) throws ExceptionReport{
- String outputID = output.getIdentifier().getStringValue();
- String complexValue = output.getData().getComplexData().toString();
- OutputDescriptionType outputDesc = null;
- for(OutputDescriptionType tempDesc : processDescription.getProcessOutputs().getOutputArray()) {
- if((tempDesc.getIdentifier().getStringValue().startsWith(outputID))) {
- outputDesc = tempDesc;
- break;
- }
- }
-
- if(outputDesc == null) {
- throw new RuntimeException("output cannot be found in description for " + processDescription.getIdentifier().getStringValue() + "," + outputID);
- }
-
- String schema = output.getData().getComplexData().getSchema();
- String encoding = output.getData().getComplexData().getEncoding();
- String format = output.getData().getComplexData().getMimeType();
- if(schema == null) {
- schema = outputDesc.getComplexOutput().getDefault().getFormat().getSchema();
- }
- if(format == null) {
- format = outputDesc.getComplexOutput().getDefault().getFormat().getMimeType();
- }
- if(encoding == null) {
- encoding = outputDesc.getComplexOutput().getDefault().getFormat().getEncoding();
- }
- LOGGER.info(schema+" "+encoding+" "+format);
- Class outputDataType = determineOutputDataType(outputID, outputDesc);
-
- IParser parser=null;
- try {
- parser = ParserFactory.getInstance().getParser(schema, format, encoding, outputDataType);
- } catch (Exception e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- if(parser == null) {
- parser = ParserFactory.getInstance().getSimpleParser();
- }
- IData collection = null;
- if(parser instanceof AbstractXMLParser) {
- try {
- collection = ((AbstractXMLParser)parser).parseXML(complexValue);
- }
- catch(RuntimeException e) {
- throw new ExceptionReport("Error occured, while XML parsing",
- ExceptionReport.NO_APPLICABLE_CODE, e);
- }
- }
- else {
- throw new ExceptionReport("parser does not support operation: " + parser.getClass().getName(), ExceptionReport.INVALID_PARAMETER_VALUE);
- }
- return collection;
- }
-
-
-
- private static Class determineOutputDataType(String outputID, OutputDescriptionType output) {
-
- if(output.isSetLiteralOutput()){
- String datatype = output.getLiteralOutput().getDataType().getStringValue();
- if(datatype.contains("tring")){
- return LiteralStringBinding.class;
- }
- if(datatype.contains("ollean")){
- return LiteralBooleanBinding.class;
- }
- if(datatype.contains("loat") || datatype.contains("ouble")){
- return LiteralDoubleBinding.class;
- }
- if(datatype.contains("nt")){
- return LiteralIntBinding.class;
- }
- }
- if(output.isSetComplexOutput()){
- String mimeType = output.getComplexOutput().getDefault().getFormat().getMimeType();
- if(mimeType.contains("xml") || (mimeType.contains("XML"))){
- if(output.getComplexOutput().getDefault().getFormat().getSchema().contains("wps"))
- {
- return URLListDataBinding.class;
- }
- else {
- return GTVectorDataBinding.class;}
- }else{
- return GTRasterDataBinding.class;
- }
- }
-
- throw new RuntimeException("Could not determie internal inputDataType");
- }
-
- public static IData handleLiteralValue(OutputDataType output) throws ExceptionReport {
-
- String parameter = output.getData().getLiteralData().getStringValue();
- String xmlDataType = output.getData().getLiteralData().getDataType();
- IData parameterObj = null;
- try {
- parameterObj = BasicXMLTypeFactory.getBasicJavaObject(xmlDataType, parameter);
- }
- catch(RuntimeException e) {
- throw new ExceptionReport("The passed parameterValue: " + parameter + ", but should be of type: " + xmlDataType, ExceptionReport.INVALID_PARAMETER_VALUE);
- }
- if(parameterObj == null) {
- throw new ExceptionReport("XML datatype as LiteralParameter is not supported by the server: dataType " + xmlDataType,
- ExceptionReport.INVALID_PARAMETER_VALUE);
- }
- return parameterObj;
-
- }
-
- /**
- * Handles BBoxValue
- * @param input The client input
- * @param class1
- */
- protected static IData handleBBoxValue(OutputDataType input) throws ExceptionReport{
- //String inputID = input.getIdentifier().getStringValue();
- throw new ExceptionReport("BBox is not supported", ExceptionReport.OPERATION_NOT_SUPPORTED);
- }
-
-}
+/***************************************************************
+ This implementation provides a framework to publish processes to the
+web through the OGC Web Processing Service interface. The framework
+is extensible in terms of processes and data handlers.
+
+ Copyright (C) 2006 by con terra GmbH
+
+ Authors:
+ Bastian Schaeffer, Institute for Geoinformatics, Muenster, Germany
+
+ Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
+ 48155 Muenster, Germany, 52n@conterra.de
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program (see gnu-gpl v2.txt); if not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA or visit the web page of the Free
+ Software Foundation, http://www.fsf.org.
+
+ ***************************************************************/
+
+
+package org.n52.wps.server.profiles;
+import net.opengis.wps.x100.OutputDataType;
+import net.opengis.wps.x100.OutputDescriptionType;
+import net.opengis.wps.x100.ProcessDescriptionType;
+
+import org.apache.log4j.Logger;
+import org.n52.wps.io.IParser;
+import org.n52.wps.io.ParserFactory;
+import org.n52.wps.io.data.IData;
+import org.n52.wps.io.data.binding.complex.GTRasterDataBinding;
+import org.n52.wps.io.data.binding.complex.GTVectorDataBinding;
+import org.n52.wps.io.data.binding.complex.URLListDataBinding;
+import org.n52.wps.io.data.binding.literal.LiteralBooleanBinding;
+import org.n52.wps.io.data.binding.literal.LiteralDoubleBinding;
+import org.n52.wps.io.data.binding.literal.LiteralIntBinding;
+import org.n52.wps.io.data.binding.literal.LiteralStringBinding;
+import org.n52.wps.io.datahandler.xml.AbstractXMLParser;
+import org.n52.wps.server.ExceptionReport;
+import org.n52.wps.util.BasicXMLTypeFactory;
+
+
+public class OutputParser {
+
+ private static Logger LOGGER = Logger
+ .getLogger(OutputParser.class);
+
+ /**
+ * Handles the ComplexValueReference
+ * @param class1
+ * @param input The client input
+ * @throws ExceptionReport If the input (as url) is invalid, or there is an error while parsing the XML.
+ */
+ protected static String handleComplexValueReference(OutputDataType output) throws ExceptionReport{
+ return output.getReference().getHref();
+
+ }
+
+ /**
+ * Handles the complexValue, which in this case should always include XML
+ * which can be parsed into a FeatureCollection.
+ * @param class1
+ * @param input The client input
+ * @throws ExceptionReport If error occured while parsing XML
+ */
+ protected static IData handleComplexValue(OutputDataType output, ProcessDescriptionType processDescription) throws ExceptionReport{
+ String outputID = output.getIdentifier().getStringValue();
+ String complexValue = output.getData().getComplexData().toString();
+ OutputDescriptionType outputDesc = null;
+ for(OutputDescriptionType tempDesc : processDescription.getProcessOutputs().getOutputArray()) {
+ if((tempDesc.getIdentifier().getStringValue().startsWith(outputID))) {
+ outputDesc = tempDesc;
+ break;
+ }
+ }
+
+ if(outputDesc == null) {
+ throw new RuntimeException("output cannot be found in description for " + processDescription.getIdentifier().getStringValue() + "," + outputID);
+ }
+
+ String schema = output.getData().getComplexData().getSchema();
+ String encoding = output.getData().getComplexData().getEncoding();
+ String format = output.getData().getComplexData().getMimeType();
+ if(schema == null) {
+ schema = outputDesc.getComplexOutput().getDefault().getFormat().getSchema();
+ }
+ if(format == null) {
+ format = outputDesc.getComplexOutput().getDefault().getFormat().getMimeType();
+ }
+ if(encoding == null) {
+ encoding = outputDesc.getComplexOutput().getDefault().getFormat().getEncoding();
+ }
+ LOGGER.info(schema+" "+encoding+" "+format);
+ Class outputDataType = determineOutputDataType(outputID, outputDesc);
+
+ IParser parser=null;
+ try {
+ parser = ParserFactory.getInstance().getParser(schema, format, encoding, outputDataType);
+ } catch (Exception e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ if(parser == null) {
+ parser = ParserFactory.getInstance().getSimpleParser();
+ }
+ IData collection = null;
+ if(parser instanceof AbstractXMLParser) {
+ try {
+ collection = ((AbstractXMLParser)parser).parseXML(complexValue);
+ }
+ catch(RuntimeException e) {
+ throw new ExceptionReport("Error occured, while XML parsing",
+ ExceptionReport.NO_APPLICABLE_CODE, e);
+ }
+ }
+ else {
+ throw new ExceptionReport("parser does not support operation: " + parser.getClass().getName(), ExceptionReport.INVALID_PARAMETER_VALUE);
+ }
+ return collection;
+ }
+
+
+
+ private static Class determineOutputDataType(String outputID, OutputDescriptionType output) {
+
+ if(output.isSetLiteralOutput()){
+ String datatype = output.getLiteralOutput().getDataType().getStringValue();
+ if(datatype.contains("tring")){
+ return LiteralStringBinding.class;
+ }
+ if(datatype.contains("ollean")){
+ return LiteralBooleanBinding.class;
+ }
+ if(datatype.contains("loat") || datatype.contains("ouble")){
+ return LiteralDoubleBinding.class;
+ }
+ if(datatype.contains("nt")){
+ return LiteralIntBinding.class;
+ }
+ }
+ if(output.isSetComplexOutput()){
+ String mimeType = output.getComplexOutput().getDefault().getFormat().getMimeType();
+ if(mimeType.contains("xml") || (mimeType.contains("XML"))){
+ if(output.getComplexOutput().getDefault().getFormat().getSchema().contains("wps"))
+ {
+ return URLListDataBinding.class;
+ }
+ else {
+ return GTVectorDataBinding.class;}
+ }else{
+ return GTRasterDataBinding.class;
+ }
+ }
+
+ throw new RuntimeException("Could not determie internal inputDataType");
+ }
+
+ public static IData handleLiteralValue(OutputDataType output) throws ExceptionReport {
+ String parameter = output.getData().getLiteralData().getStringValue();
+ String xmlDataType = output.getData().getLiteralData().getDataType();
+ IData parameterObj = null;
+ try {
+ parameterObj = BasicXMLTypeFactory.getBasicJavaObject(xmlDataType, parameter);
+ }
+ catch(RuntimeException e) {
+ throw new ExceptionReport("The passed parameterValue: " + parameter + ", but should be of type: " + xmlDataType, ExceptionReport.INVALID_PARAMETER_VALUE);
+ }
+ if(parameterObj == null) {
+ throw new ExceptionReport("XML datatype as LiteralParameter is not supported by the server: dataType " + xmlDataType,
+ ExceptionReport.INVALID_PARAMETER_VALUE);
+ }
+ return parameterObj;
+
+ }
+
+ /**
+ * Handles BBoxValue
+ * @param input The client input
+ * @param class1
+ */
+ protected static IData handleBBoxValue(OutputDataType input) throws ExceptionReport{
+ //String inputID = input.getIdentifier().getStringValue();
+ throw new ExceptionReport("BBox is not supported", ExceptionReport.OPERATION_NOT_SUPPORTED);
+ }
+
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/java/JavaDeploymentProfile.java b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/java/JavaDeploymentProfile.java
new file mode 100644
index 000000000..06c794f8a
--- /dev/null
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/java/JavaDeploymentProfile.java
@@ -0,0 +1,154 @@
+/***************************************************************
+ This implementation provides a framework to publish processes to the
+web through the OGC Web Processing Service interface. The framework
+is extensible in terms of processes and data handlers.
+
+ Copyright (C) 2006 by con terra GmbH
+
+ Authors:
+ Bastian Schaeffer, Institute for Geoinformatics, Muenster, Germany
+
+ Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
+ 48155 Muenster, Germany, 52n@conterra.de
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program (see gnu-gpl v2.txt); if not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA or visit the web page of the Free
+ Software Foundation, http://www.fsf.org.
+
+ ***************************************************************/
+
+package org.n52.wps.server.profiles.java;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Map;
+
+import net.opengis.wps.x100.ApacheOdeDeploymentProfileType;
+import net.opengis.wps.x100.DeployProcessDocument;
+
+import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPReply;
+import org.apache.log4j.Logger;
+import org.n52.wps.PropertyDocument.Property;
+import org.n52.wps.commons.WPSConfig;
+import org.n52.wps.server.ExceptionReport;
+import org.n52.wps.server.request.deploy.DeploymentProfile;
+import org.w3c.dom.Node;
+
+/**
+ * TODO rename ApacheOdeDeployementProfile to match to the XSD element type
+ * **/
+public class JavaDeploymentProfile extends DeploymentProfile {
+
+ private static Logger LOGGER = Logger.getLogger(JavaDeploymentProfile.class);
+ private Node suitCase;
+ private Node bpel;
+ private Node clientWSDL;
+ private Map wsdlList;
+ private byte[] archive;
+ private String processId;
+ private boolean reference;
+ private String archiveRef;
+
+ public JavaDeploymentProfile(DeployProcessDocument deployDom,
+ String processID) {
+ super(deployDom, processID);
+ try {
+ Property[] properties = WPSConfig.getInstance()
+ .getPropertiesForRepositoryName("JavaRepository");
+ extractInformation(deployDom);
+ } catch (Exception e) {
+
+ e.printStackTrace();
+ }
+
+ }
+
+ public Node getSuitCase() {
+ return suitCase;
+ }
+
+ public Node getBPEL() {
+ return bpel;
+ }
+
+ public Node getClientWSDL() {
+ return clientWSDL;
+ }
+
+ public Map getWSDLList() {
+ return wsdlList;
+ }
+
+ private void extractInformation(DeployProcessDocument deployDom)
+ throws Exception {
+
+ ApacheOdeDeploymentProfileType deployProfile = (ApacheOdeDeploymentProfileType) deployDom.getDeployProcess().getDeploymentProfile().changeType(ApacheOdeDeploymentProfileType.type);
+ if(!deployProfile.validate()) {
+ throw new ExceptionReport("Oozie Deploy Profile is not valid (according WPS schemas)",ExceptionReport.INVALID_PARAMETER_VALUE);
+ }
+ setProcessId(deployDom.getDeployProcess().getProcessDescription()
+ .getIdentifier().getStringValue());
+ if (deployProfile.isSetArchive()) {
+ // Note that XMLBeans automatically decodes base64
+ setArchive(deployProfile.getArchive());
+ setReference(false);
+ } else if (deployProfile.isSetArchiveReference()) {
+ setArchiveRef(deployProfile.getArchiveReference().getHref());
+ LOGGER.info("downloading archive");
+ setArchive(downloadArchive(getArchiveRef()));
+ setReference(true);
+ }
+ }
+
+
+ public void setArchive(byte[] archive) {
+ LOGGER.info("setArchive");
+ this.archive = archive;
+ }
+
+ public byte[] getArchive() {
+ return archive;
+ }
+
+ public void setProcessId(String processId) {
+ this.processId = processId;
+ }
+
+ public String getProcessId() {
+ return processId;
+ }
+
+ public void setReference(boolean reference) {
+ this.reference = reference;
+ }
+
+ public boolean isReference() {
+ return reference;
+ }
+
+ public void setArchiveRef(String string) {
+ this.archiveRef = string;
+ }
+
+ public String getArchiveRef() {
+ return archiveRef;
+ }
+
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/java/JavaManager.java b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/java/JavaManager.java
new file mode 100644
index 000000000..4cd6d0e05
--- /dev/null
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/java/JavaManager.java
@@ -0,0 +1,420 @@
+package org.n52.wps.server.profiles.java;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import net.opengis.wps.x100.AuditTraceType;
+import net.opengis.wps.x100.ExecuteDocument;
+import net.opengis.wps.x100.InputType;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.filefilter.DirectoryFileFilter;
+import org.apache.commons.io.filefilter.FileFilterUtils;
+import org.apache.log4j.Logger;
+import org.n52.wps.PropertyDocument.Property;
+import org.n52.wps.commons.WPSConfig;
+import org.n52.wps.io.data.IData;
+import org.n52.wps.server.ExceptionReport;
+import org.n52.wps.server.profiles.AbstractProcessManager;
+import org.n52.wps.server.repository.ITransactionalAlgorithmRepository;
+import org.n52.wps.server.request.DeployProcessRequest;
+import org.n52.wps.server.request.ExecuteRequest;
+import org.n52.wps.server.request.InputHandler;
+import org.n52.wps.server.request.UndeployProcessRequest;
+import org.n52.wps.server.request.deploy.DeploymentProfile;
+import org.n52.wps.util.StreamUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+
+
+
+/**
+ * TODO this class was based on transactional branch implementation. However the
+ * invoke method was reimplemented Therefore there is a doublon implementation
+ * for sending request. *
+ *
+ * @author cnl
+ *
+ */
+public class JavaManager extends AbstractProcessManager {
+ // logger for debug purpose
+ private final Logger log = Logger.getLogger(getClass());
+ private String deployDirectory;
+ // the WPS instance ID (not expected to be the same)
+ private String taskId;
+ // the oozie instance ID
+ private String jobId;
+ // Client for Oozie (oozie jar)
+ // HDFS manager (for file system operations)
+ private String jobTrackerUrl;
+ private JavaTransactionalAlgorithm algorithm;
+
+
+ /**
+ * Contructor
+ *
+ * @param parentRepository
+ */
+ public JavaManager(ITransactionalAlgorithmRepository parentRepository) {
+ super(parentRepository);
+ // Retrieve repository properties from wps_config.xml (WEB-INF/config)
+ Property[] properties = WPSConfig.getInstance()
+ .getPropertiesForRepositoryName("JavaRepository");
+ String fullPath = this.getClass()
+ .getProtectionDomain().getCodeSource().getLocation().toString();
+ int searchIndex = fullPath.indexOf("WEB-INF");
+ String subPath = fullPath.substring(0, searchIndex);
+ subPath = subPath.replaceFirst("file:", "");
+ String path = subPath + "WEB-INF/JavaProcesses/";
+ this.setDeployDirectory(path);
+ // Todo include the configuration files
+
+ }
+
+ /**
+ * undeploy a process
+ */
+ @Override
+ public boolean unDeployProcess(UndeployProcessRequest request)
+ throws Exception {
+ return unstoreArchive(request.getProcessID());
+ }
+
+ @Override
+ public boolean containsProcess(String processID) throws Exception {
+ // Not used, inherited historically
+ return false;
+ }
+
+ @Override
+ public Collection getAllProcesses() throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Document invoke(ExecuteDocument payload, String algorithmID)
+ throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public Map invokeJava(ExecuteRequest request, String algorithmID)
+ throws Exception {
+
+ Properties outputProps = null;
+ //String processPath = getProcessJar(algorithmID);
+ // Get the user from the SOAP header
+ // String user = getUser(request);
+ // TODO replace user by saml token value
+ String user = "christophe";
+ // Get the WPS process instance id (task id)
+ String taskId = request.getId();
+ // set the username
+ // set the namenode and jobtracker URLs
+ // do not change the IP of the jobTracker and the nameNode
+ String inputDir = "/user/" + user + File.separator + algorithmID + File.separator+ "/results/" + taskId + "/inputs";
+ String outputDir = "/user/" + user + File.separator + algorithmID + File.separator + "/results/" + taskId + "/ouputs";
+ List jarList = new ArrayList();
+ // Jar file
+ String jarDir = getProcessDeploymentDirectory(algorithmID);
+ // List all file in parent directory with jar suffix extension
+ Collection list = FileUtils.listFiles(new File(jarDir), FileFilterUtils.suffixFileFilter("jar"), null);
+ for(File f : list) {
+ URL jarURL = f.toURI().toURL();
+ jarList.add(jarURL);
+ }
+ ClassLoader classLoader = new URLClassLoader(jarList.toArray(new URL[jarList.size()]), this.getClass().getClassLoader());
+
+ //if( be.spacebel.ese.data.wps.DownloadEOData)
+
+ JavaTransactionalAlgorithm algorithm = (JavaTransactionalAlgorithm)classLoader.loadClass(algorithmID).newInstance();
+ InputType[] inputs = new InputType[0];
+ if (request.getExecute().getDataInputs() != null) {
+ inputs = request.getExecute().getDataInputs().getInputArray();
+ }
+ InputHandler parser = new InputHandler(inputs,algorithmID);
+ algorithm.setInstanceId(taskId);
+ this.setAlgorithm(algorithm);
+ Map outputs = algorithm.run(parser.getParsedInputData());
+ return outputs;
+
+
+
+ }
+
+ @Override
+ public boolean deployProcess(DeployProcessRequest request) throws Exception {
+ // Get the the deployment profile from the request
+ DeploymentProfile profile = request.getDeploymentProfile();
+ if (!(profile instanceof JavaDeploymentProfile)) {
+ throw new Exception("Requested Deployment Profile not supported");
+ }
+ JavaDeploymentProfile deploymentProfile = (JavaDeploymentProfile) profile;
+ String processID = deploymentProfile.getProcessID();
+ // Store the archive from the request
+ writePackage(deploymentProfile.getArchive(), processID);
+ log.debug("Stored Archive:" + deploymentProfile.getArchive());
+ return true;
+ }
+
+ /**
+ * Write a jar file
+ *
+ * @param archive
+ * @param processID
+ * @throws IOException
+ */
+ private void writePackage(byte[] archive, String processID)
+ throws IOException {
+ // Deployment directory (definition)
+ String archiveDir = getProcessDeploymentDirectory(processID);
+ File directory = new File(archiveDir);
+ if (!directory.exists()) {
+ log.info("Creating directory " + archiveDir);
+ directory.mkdirs();
+ }
+ ByteArrayInputStream bais = new ByteArrayInputStream(archive);
+ byte[] buf = new byte[1024];
+ ZipInputStream zis = new ZipInputStream(bais);
+ ZipEntry zipentry = null;
+ // For each zip entry (file), create the directory, then write the file
+ while ((zipentry = zis.getNextEntry()) != null) {
+ String entryName = zipentry.getName();
+ if (zipentry.isDirectory()) {
+ log.info("Create dir " + entryName);
+ File entryFile = new File(archiveDir+entryName);
+ if(!directory.exists())
+ directory.mkdirs();
+ //this.getHdfsManager().mkdir(archiveDir + entryName);
+ } else {
+ log.info("Writing file " + entryName);
+ File entryFile = new File(archiveDir+entryName);
+ byte[] byteArray = IOUtils.toByteArray(zis);
+ // note: cannot use write Stream to file because it closes the input stream.
+ FileUtils.writeByteArrayToFile(new File(archiveDir+entryName),byteArray);
+ }
+ zis.closeEntry();
+
+ }
+
+ zis.close();
+ log.info("Stored archive in " + archiveDir);
+
+ }
+
+ /**
+ * Unstore Archive
+ *
+ * @param processId
+ * @return
+ * @throws IOException
+ */
+ private boolean unstoreArchive(String processId) throws IOException {
+ String archiveDir = getProcessDeploymentDirectory(processId);
+ FileUtils.deleteDirectory(new File(archiveDir));
+ return true;
+
+ }
+
+ /**
+ * Deletes all files and subdirectories under dir. Returns true if all
+ * deletions were successful. If a deletion fails, the method stops
+ * attempting to delete and returns false.
+ *
+ * @param dir
+ * @return
+ */
+ public static boolean deleteDir(File dir) {
+ if (dir.isDirectory()) {
+ String[] children = dir.list();
+ for (int i = 0; i < children.length; i++) {
+ boolean success = deleteDir(new File(dir, children[i]));
+ if (!success) {
+ return false;
+ }
+ }
+ }
+
+ // The directory is now empty so delete it
+ return dir.delete();
+ }
+
+ /**
+ * Get the deployment directory of a process
+ *
+ * @param processID
+ * @return
+ */
+ public String getProcessDeploymentDirectory(String processID) {
+ return this.getDeployDirectory() + processID + File.separator;
+ }
+
+
+
+ @Override
+ public AuditTraceType getAuditLongForm() throws Exception {
+ log.debug("long form");
+
+ // Get the job log
+ System.out.print("JobLog:");
+ // Create a new empty XML document
+ DocumentBuilderFactory docFactory = DocumentBuilderFactory
+ .newInstance();
+ DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+ Document doc = docBuilder.newDocument();
+ // Create a "Log" root element
+ Element rootElement = doc.createElement("Log");
+ // Set the log as text content
+ rootElement.setTextContent(this.getAlgorithm().getAudit());
+ doc.appendChild(rootElement);
+ // Parse the Audit Trace document (any el / any att type)
+ AuditTraceType audit = AuditTraceType.Factory.parse(doc);
+ return audit;
+ }
+
+ @Override
+ public AuditTraceType getAudit() throws Exception {
+ // TODO Auto-generated method stub
+
+ return AuditTraceType.Factory.newInstance();
+ }
+
+ @Override
+ public String getIID() {
+ return this.getTaskId();
+ }
+
+ @Override
+ public void cancel() {
+ try {
+ //this.getClient().kill(this.jobId);
+ this.getAlgorithm().cancel();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ * Utility method that should better be implemented in WPSConfig class Get
+ * the property string value and throws exception if null
+ */
+
+ private String getPropertyUtil(String property, Property[] properties) {
+ Property prop = WPSConfig.getInstance().getPropertyForKey(properties,
+ property);
+ if (prop == null) {
+ throw new RuntimeException("Error. Could not find " + property);
+ }
+ return prop.getStringValue();
+
+ }
+
+
+
+ public String getDeployDirectory() {
+ return this.deployDirectory;
+ }
+
+ public void setDeployDirectory(String deployDirectory) {
+ this.deployDirectory = deployDirectory;
+ }
+
+ private String getUser(ExecuteRequest req) {
+ String cnName = null;
+ try {
+
+ for (SOAPHeaderBlock samlHeader : req.getSamlHeader()) {
+ log.info("LocalName = " + samlHeader.getLocalName());
+ OMElement assertion = (OMElement) samlHeader
+ .getChildrenWithLocalName("Assertion").next();
+ log.info("Assertion found:" + assertion.toString());
+ OMElement attributeStatement = (OMElement) assertion
+ .getChildrenWithLocalName("AttributeStatement").next();
+ log.info("AttributeStatement found");
+ OMElement subject = (OMElement) attributeStatement
+ .getChildrenWithLocalName("Subject").next();
+ log.info("Subject found:" + subject.toString());
+ OMElement nameIdentifier = (OMElement) subject
+ .getChildrenWithLocalName("NameIdentifier").next();
+ log.info("Name Id found" + nameIdentifier.toString());
+ cnName = nameIdentifier.getText();
+ log.info(cnName);
+ }
+
+ } catch (Exception e) {
+ }
+
+ return cnName;
+ }
+
+ public String getTaskId() {
+ return taskId;
+ }
+
+ public void setTaskId(String taskId) {
+ this.taskId = taskId;
+ }
+
+ public String getJobId() {
+ return jobId;
+ }
+
+ public void setJobId(String jobId) {
+ this.jobId = jobId;
+ }
+
+
+
+ public String getJobTrackerUrl() {
+ return jobTrackerUrl;
+ }
+
+ public void setJobTrackerUrl(String jobTrackerUrl) {
+ this.jobTrackerUrl = jobTrackerUrl;
+ }
+
+ public static String getJavaProcessPath(String process) {
+ String fullPath = JavaManager.class
+ .getProtectionDomain().getCodeSource().getLocation().toString();
+ int searchIndex = fullPath.indexOf("WEB-INF");
+ String subPath = fullPath.substring(0, searchIndex);
+ subPath = subPath.replaceFirst("file:", "");
+ String javaProcessPath = subPath + "WEB-INF/JavaRepository/"+process+"/";
+ return javaProcessPath;
+ }
+
+ @Override
+ public Document invoke(ExecuteRequest request, String algorithmID)
+ throws Exception {
+ throw new ExceptionReport("This method should not have been called. Implementation error.", "1", "none");
+ }
+
+ public JavaTransactionalAlgorithm getAlgorithm() {
+ return algorithm;
+ }
+
+ public void setAlgorithm(JavaTransactionalAlgorithm algorithm) {
+ this.algorithm = algorithm;
+ }
+
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/java/JavaTransactionalAlgorithm.java b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/java/JavaTransactionalAlgorithm.java
new file mode 100644
index 000000000..b75bc653d
--- /dev/null
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/java/JavaTransactionalAlgorithm.java
@@ -0,0 +1,47 @@
+package org.n52.wps.server.profiles.java;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.n52.wps.io.data.IData;
+import org.n52.wps.server.ITransactionalAlgorithm;
+
+public abstract class JavaTransactionalAlgorithm implements ITransactionalAlgorithm {
+
+ private String instanceId;
+
+
+
+
+ @Override
+ public void cancel() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Map run(Map> inputData)
+ throws InterruptedException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getAudit() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getInstanceId() {
+ return instanceId;
+ }
+
+ public void setInstanceId(String instanceId) {
+ this.instanceId = instanceId;
+ }
+
+ public abstract Class getInputDataType(String id);
+ public abstract Class getOutputDataType(String id);
+
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/oozie/HDFSClient.java b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/oozie/HDFSClient.java
new file mode 100644
index 000000000..9c83abd94
--- /dev/null
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/oozie/HDFSClient.java
@@ -0,0 +1,480 @@
+/*
+ This file is a modification of the free code given on the link below:
+ http://linuxjunkies.wordpress.com/
+
+ 2011
+ */
+package org.n52.wps.server.profiles.oozie;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.PrivilegedExceptionAction;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.BlockLocation;
+import org.apache.hadoop.fs.FSDataInputStream;
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hdfs.DistributedFileSystem;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.log4j.Logger;
+
+public class HDFSClient {
+
+ // HDFS System configuration files
+ private Logger log = Logger.getLogger(getClass());
+ private String hdfsURL;
+ private String user;
+ private Configuration configuration;
+
+ /**
+ * If needed, creates the home directory for the user because Oozie expects
+ * this directory to exist.
+ *
+ * @param userId
+ * user id for which the home directory is checked (and created).
+ * @throws Exception
+ */
+ public void createHomeDirectoryIfNeeded(final String userId)
+ throws Exception {
+
+ try {
+ final FileSystem fs = FileSystem.get(this.getConfiguration());
+ UserGroupInformation ugi = UserGroupInformation
+ .createRemoteUser(this.getUser());
+ log.debug("Creating home directory of user "+userId+" using privilege of user "+this.getUser());
+ ugi.doAs(new PrivilegedExceptionAction() {
+
+ public Void run() throws Exception {
+
+ org.apache.hadoop.fs.Path homeDir = new org.apache.hadoop.fs.Path(
+ "/user/" + userId);
+ if (!fs.exists(homeDir)) {
+ fs.mkdirs(homeDir);
+ fs.setOwner(homeDir, userId, userId);
+ }
+
+ return null;
+
+ }
+ });
+ } catch (Exception ex) {
+ log.error(
+ "Error occured while trying to create the Oozie home directory: "
+ + ex.getMessage(), ex);
+ throw new Exception(
+ "Error occured while trying to create the Oozie home directory: "
+ + ex.getMessage(), null);
+ }
+
+ }
+
+ public static void main(String[] args) throws IOException,
+ InterruptedException {
+ HDFSClient client = new HDFSClient("hdfs://quickstart.cloudera:8020",
+ "hdfs");
+ String deployDirectory = "/user/christophe/deploy";
+
+ // Deployment directory (definition)
+ String archiveDir = deployDirectory + File.separator + "test3"
+ + File.separator;
+ // Creation of deployment directory
+ client.mkdir(archiveDir);
+
+ try {
+ client.createHomeDirectoryIfNeeded("pouet");
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ // Read the zip archive
+
+ }
+
+ public HDFSClient(String url, String hdfsAdmin) {
+ this.setHdfsURL(url);
+ this.setUser(hdfsAdmin);
+ System.setProperty("HADOOP_USER_NAME", "hdfs");
+ Configuration conf = new Configuration();
+ //conf.set("user.name", hdfsAdmin);
+ //conf.set("hadoop.job.ugi", "hdfs");
+ conf.set("fs.defaultFS", url);
+ conf.set("fs.trash.interval", "1");
+ conf.set("io.file.buffer.size", "65536");
+ conf.set("dfs.namenode.servicerpc-address", "192.168.56.101:8022");
+ conf.set("dfs.https.address", "192.168.56.101:50470");
+ conf.set("dfs.https.port", "50470");
+ conf.set("dfs.namenode.http-address", "192.168.56.101:50070");
+ conf.set("dfs.blocksize", "134217728");
+ conf.set("dfs.replication", "3");
+ conf.set("dfs.client.use.datanode.hostname", "true");
+
+ this.setConfiguration(conf);
+ }
+
+ public static void printUsage() {
+ System.out
+ .println("Usage: hdfsclient add" + " ");
+ System.out.println("Usage: hdfsclient read" + "");
+ System.out.println("Usage: hdfsclient delete" + "");
+ System.out.println("Usage: hdfsclient mkdir" + "");
+ System.out.println("Usage: hdfsclient copyfromlocal"
+ + " ");
+ System.out.println("Usage: hdfsclient copytolocal"
+ + " ");
+ System.out
+ .println("Usage: hdfsclient modificationtime" + "");
+ System.out.println("Usage: hdfsclient getblocklocations"
+ + "");
+ System.out.println("Usage: hdfsclient gethostnames");
+ }
+
+ public boolean ifExists(Path source) throws IOException {
+
+ FileSystem hdfs = FileSystem.get(this.getConfiguration());
+ boolean isExists = hdfs.exists(source);
+ return isExists;
+ }
+
+ public void getHostnames() throws IOException {
+ FileSystem fs = FileSystem.get(this.getConfiguration());
+ DistributedFileSystem hdfs = (DistributedFileSystem) fs;
+ DatanodeInfo[] dataNodeStats = hdfs.getDataNodeStats();
+
+ String[] names = new String[dataNodeStats.length];
+ for (int i = 0; i < dataNodeStats.length; i++) {
+ names[i] = dataNodeStats[i].getHostName();
+ System.out.println((dataNodeStats[i].getHostName()));
+ }
+ }
+
+ public void getBlockLocations(String source) throws IOException {
+
+ FileSystem fileSystem = FileSystem.get(this.getConfiguration());
+ Path srcPath = new Path(source);
+
+ // Check if the file already exists
+ if (!(ifExists(srcPath))) {
+ System.out.println("No such destination " + srcPath);
+ return;
+ }
+ // Get the filename out of the file path
+ String filename = source.substring(source.lastIndexOf('/') + 1,
+ source.length());
+
+ FileStatus fileStatus = fileSystem.getFileStatus(srcPath);
+
+ BlockLocation[] blkLocations = fileSystem.getFileBlockLocations(
+ fileStatus, 0, fileStatus.getLen());
+ int blkCount = blkLocations.length;
+
+ System.out.println("File :" + filename + "stored at:");
+ for (int i = 0; i < blkCount; i++) {
+ String[] hosts = blkLocations[i].getHosts();
+ System.out.format("Host %d: %s %n", i, hosts);
+ }
+
+ }
+
+ public void getModificationTime(String source) throws IOException {
+
+ FileSystem fileSystem = FileSystem.get(this.getConfiguration());
+ Path srcPath = new Path(source);
+
+ // Check if the file already exists
+ if (!(fileSystem.exists(srcPath))) {
+ System.out.println("No such destination " + srcPath);
+ return;
+ }
+ // Get the filename out of the file path
+ String filename = source.substring(source.lastIndexOf('/') + 1,
+ source.length());
+
+ FileStatus fileStatus = fileSystem.getFileStatus(srcPath);
+ long modificationTime = fileStatus.getModificationTime();
+
+ System.out.format("File %s; Modification time : %0.2f %n", filename,
+ modificationTime);
+
+ }
+
+ public Configuration getConfiguration() {
+ return this.configuration;
+ }
+
+ public void writeFile(final InputStream in, final String dest)
+ throws IOException, InterruptedException {
+ final Path path = new Path(dest);
+ log.debug("Writing file on HDFS by using privilege of user "+this.getUser());
+ UserGroupInformation ugi = UserGroupInformation.createRemoteUser(this
+ .getUser());
+ final FileSystem fileSystem = FileSystem.get(this.getConfiguration());
+ /*
+ * // Create the destination path including the filename. if
+ * (dest.charAt(dest.length() - 1) != '/') { dest = dest + "/" +
+ * filename; } else { dest = dest + filename; }
+ *
+ * // Check if the file already exists
+ *
+ * if (fileSystem.exists(path)) { System.out.println("File " + dest +
+ * " already exists"); return; } // if parent directory does not exist
+ * if (path.getParent() != null && !fileSystem.exists(path.getParent()))
+ * { log.debug("MKDIR in writeFile "+path.getParent());
+ * fileSystem.mkdirs(path.getParent()); }
+ */
+ // Create a new file and write data to it.
+ ugi.doAs(new PrivilegedExceptionAction() {
+ public Void run() throws Exception {
+ FSDataOutputStream out;
+ log.debug("create file system file:" + path);
+ out = fileSystem.create(path);
+ byte[] b = new byte[1024];
+ int numBytes = 0;
+ while ((numBytes = in.read(b)) > 0) {
+ out.write(b, 0, numBytes);
+ }
+
+ // Close all the file descripters
+ // in.close();
+ out.close();
+ log.debug("closing fs");
+ fileSystem.close();
+ return null;
+ }
+ });
+ }
+
+ public void copyFromLocal(String source, String dest) throws IOException {
+
+ FileSystem fileSystem = FileSystem.get(this.getConfiguration());
+ Path srcPath = new Path(source);
+
+ Path dstPath = new Path(dest);
+ // Check if the file already exists
+ if (!(fileSystem.exists(dstPath))) {
+ System.out.println("No such destination " + dstPath);
+ return;
+ }
+
+ // Get the filename out of the file path
+ String filename = source.substring(source.lastIndexOf('/') + 1,
+ source.length());
+
+ try {
+ fileSystem.copyFromLocalFile(srcPath, dstPath);
+ System.out.println("File " + filename + "copied to " + dest);
+ } catch (Exception e) {
+ System.err.println("Exception caught! :" + e);
+ System.exit(1);
+ } finally {
+ fileSystem.close();
+ }
+ }
+
+ public void copyToLocal(String source, String dest) throws IOException {
+
+ FileSystem fileSystem = FileSystem.get(this.getConfiguration());
+ Path srcPath = new Path(source);
+
+ Path dstPath = new Path(dest);
+ // Check if the file already exists
+ if (!(fileSystem.exists(srcPath))) {
+ System.out.println("No such destination " + srcPath);
+ return;
+ }
+
+ // Get the filename out of the file path
+ String filename = source.substring(source.lastIndexOf('/') + 1,
+ source.length());
+
+ try {
+ fileSystem.copyToLocalFile(srcPath, dstPath);
+ System.out.println("File " + filename + "copied to " + dest);
+ } catch (Exception e) {
+ System.err.println("Exception caught! :" + e);
+ System.exit(1);
+ } finally {
+ fileSystem.close();
+ }
+ }
+
+ public void renameFile(String fromthis, String tothis) throws IOException {
+
+ FileSystem fileSystem = FileSystem.get(this.getConfiguration());
+ Path fromPath = new Path(fromthis);
+ Path toPath = new Path(tothis);
+
+ if (!(fileSystem.exists(fromPath))) {
+ System.out.println("No such destination " + fromPath);
+ return;
+ }
+
+ if (fileSystem.exists(toPath)) {
+ System.out.println("Already exists! " + toPath);
+ return;
+ }
+
+ try {
+ boolean isRenamed = fileSystem.rename(fromPath, toPath);
+ if (isRenamed) {
+ System.out.println("Renamed from " + fromthis + "to " + tothis);
+ }
+ } catch (Exception e) {
+ System.out.println("Exception :" + e);
+ System.exit(1);
+ } finally {
+ fileSystem.close();
+ }
+
+ }
+
+ public void addFile(String source, String dest) throws IOException {
+
+ FileSystem fileSystem = FileSystem.get(this.getConfiguration());
+
+ // Get the filename out of the file path
+ String filename = source.substring(source.lastIndexOf('/') + 1,
+ source.length());
+
+ // Create the destination path including the filename.
+ if (dest.charAt(dest.length() - 1) != '/') {
+ dest = dest + "/" + filename;
+ } else {
+ dest = dest + filename;
+ }
+
+ // Check if the file already exists
+ Path path = new Path(dest);
+ if (fileSystem.exists(path)) {
+ System.out.println("File " + dest + " already exists");
+ return;
+ }
+
+ // Create a new file and write data to it.
+ FSDataOutputStream out = fileSystem.create(path);
+ InputStream in = new BufferedInputStream(new FileInputStream(new File(
+ source)));
+
+ byte[] b = new byte[1024];
+ int numBytes = 0;
+ while ((numBytes = in.read(b)) > 0) {
+ out.write(b, 0, numBytes);
+ }
+
+ // Close all the file descripters
+ in.close();
+ out.close();
+ fileSystem.close();
+ }
+
+ public void readFile(String file) throws IOException {
+
+ FileSystem fileSystem = FileSystem.get(this.getConfiguration());
+
+ Path path = new Path(file);
+ if (!fileSystem.exists(path)) {
+ System.out.println("File " + file + " does not exists");
+ return;
+ }
+
+ FSDataInputStream in = fileSystem.open(path);
+
+ String filename = file.substring(file.lastIndexOf('/') + 1,
+ file.length());
+
+ OutputStream out = new BufferedOutputStream(new FileOutputStream(
+ new File(filename)));
+
+ byte[] b = new byte[1024];
+ int numBytes = 0;
+ while ((numBytes = in.read(b)) > 0) {
+ out.write(b, 0, numBytes);
+ }
+
+ in.close();
+ out.close();
+ fileSystem.close();
+ }
+
+ public void deleteFile(final String file) throws IOException,
+ InterruptedException {
+ log.debug("Delete file using the privilege of user "+this.getUser());
+ final FileSystem fileSystem = FileSystem.get(this.getConfiguration());
+ final Path path = new Path(file);
+ UserGroupInformation ugi = UserGroupInformation.createRemoteUser(this
+ .getUser());
+ ugi.doAs(new PrivilegedExceptionAction() {
+ public Void run() throws Exception {
+
+ if (!fileSystem.exists(path)) {
+ System.out.println("File " + file + " does not exists");
+ return null;
+ }
+ fileSystem.delete(new Path(file), true);
+ fileSystem.close();
+ return null;
+ }
+ });
+ }
+
+ /**
+ * Configured user (admin) creates a directory
+ *
+ * @param dir
+ * @throws IOException
+ * @throws InterruptedException
+ */
+ public void mkdir(final String dir) throws IOException,
+ InterruptedException {
+ log.debug("MKDIR " + dir);
+ UserGroupInformation ugi = UserGroupInformation.createRemoteUser(this
+ .getUser());
+
+ final FileSystem fileSystem = FileSystem.get(this.getConfiguration());
+
+ ugi.doAs(new PrivilegedExceptionAction() {
+
+ public Void run() throws Exception {
+
+ Path path = new Path(dir);
+ if (fileSystem.exists(path)) {
+ System.out.println("Dir " + dir + " already exists!");
+ return null;
+ }
+ fileSystem.mkdirs(path);
+ fileSystem.close();
+ return null;
+ }
+ });
+
+ }
+
+ public void setConfiguration(Configuration configuration) {
+ this.configuration = configuration;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ public String getHdfsURL() {
+ return hdfsURL;
+ }
+
+ public void setHdfsURL(String hdfsURL) {
+ this.hdfsURL = hdfsURL;
+ }
+
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/oozie/OozieDeploymentProfile.java b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/oozie/OozieDeploymentProfile.java
new file mode 100644
index 000000000..387af5701
--- /dev/null
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/oozie/OozieDeploymentProfile.java
@@ -0,0 +1,143 @@
+/***************************************************************
+ This implementation provides a framework to publish processes to the
+web through the OGC Web Processing Service interface. The framework
+is extensible in terms of processes and data handlers.
+
+ Copyright (C) 2006 by con terra GmbH
+
+ Authors:
+ Bastian Schaeffer, Institute for Geoinformatics, Muenster, Germany
+
+ Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
+ 48155 Muenster, Germany, 52n@conterra.de
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program (see gnu-gpl v2.txt); if not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA or visit the web page of the Free
+ Software Foundation, http://www.fsf.org.
+
+ ***************************************************************/
+
+package org.n52.wps.server.profiles.oozie;
+
+import java.util.Map;
+
+import net.opengis.wps.x100.DeployProcessDocument;
+import net.opengis.wps.x100.OozieDeploymentProfileType;
+
+import org.apache.log4j.Logger;
+import org.n52.wps.server.ExceptionReport;
+import org.n52.wps.server.request.deploy.DeploymentProfile;
+import org.w3c.dom.Node;
+
+/**
+ * TODO rename ApacheOdeDeployementProfile to match to the XSD element type
+ * **/
+public class OozieDeploymentProfile extends DeploymentProfile {
+
+ private static Logger LOGGER = Logger.getLogger(OozieDeploymentProfile.class);
+ private Node suitCase;
+ private Node bpel;
+ private Node clientWSDL;
+ private Map wsdlList;
+ private byte[] archive;
+ private String processId;
+ private boolean reference;
+ private String archiveRef;
+
+ public OozieDeploymentProfile(DeployProcessDocument deployDom,
+ String processID) {
+ super(deployDom, processID);
+ try {
+
+ extractInformation(deployDom);
+ } catch (Exception e) {
+
+ e.printStackTrace();
+ }
+
+ }
+
+ public Node getSuitCase() {
+ return suitCase;
+ }
+
+ public Node getBPEL() {
+ return bpel;
+ }
+
+ public Node getClientWSDL() {
+ return clientWSDL;
+ }
+
+ public Map getWSDLList() {
+ return wsdlList;
+ }
+
+ private void extractInformation(DeployProcessDocument deployDom)
+ throws Exception {
+
+ OozieDeploymentProfileType deployProfile = (OozieDeploymentProfileType) deployDom.getDeployProcess().getDeploymentProfile().changeType(OozieDeploymentProfileType.type);
+ if(!deployProfile.validate()) {
+ throw new ExceptionReport("Oozie Deploy Profile is not valid (according WPS schemas)",ExceptionReport.INVALID_PARAMETER_VALUE);
+ }
+ setProcessId(deployDom.getDeployProcess().getProcessDescription()
+ .getIdentifier().getStringValue());
+ if (deployProfile.isSetArchive()) {
+ // Note that XMLBeans automatically decodes base64
+ setArchive(deployProfile.getArchive());
+ setReference(false);
+ } else if (deployProfile.isSetArchiveReference()) {
+ setArchiveRef(deployProfile.getArchiveReference().getHref());
+ LOGGER.info("downloading archive");
+ setArchive(downloadArchive(getArchiveRef()));
+ setReference(true);
+ }
+ }
+
+
+
+ public void setArchive(byte[] archive) {
+ LOGGER.info("setArchive");
+ this.archive = archive;
+ }
+
+ public byte[] getArchive() {
+ return archive;
+ }
+
+ public void setProcessId(String processId) {
+ this.processId = processId;
+ }
+
+ public String getProcessId() {
+ return processId;
+ }
+
+ public void setReference(boolean reference) {
+ this.reference = reference;
+ }
+
+ public boolean isReference() {
+ return reference;
+ }
+
+ public void setArchiveRef(String string) {
+ this.archiveRef = string;
+ }
+
+ public String getArchiveRef() {
+ return archiveRef;
+ }
+
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/profiles/oozie/OozieManager.java b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/oozie/OozieManager.java
new file mode 100644
index 000000000..7aad38172
--- /dev/null
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/profiles/oozie/OozieManager.java
@@ -0,0 +1,784 @@
+package org.n52.wps.server.profiles.oozie;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import net.opengis.wps.x100.AuditTraceType;
+import net.opengis.wps.x100.DocumentOutputDefinitionType;
+import net.opengis.wps.x100.ExecuteDocument;
+import net.opengis.wps.x100.ExecuteResponseDocument;
+import net.opengis.wps.x100.ExecuteResponseDocument.ExecuteResponse.ProcessOutputs;
+import net.opengis.wps.x100.InputType;
+import net.opengis.wps.x100.OutputDataType;
+import net.opengis.wps.x100.OutputDescriptionType;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.apache.oozie.client.OozieClient;
+import org.apache.oozie.client.OozieClientException;
+import org.apache.oozie.client.WorkflowAction;
+import org.apache.oozie.client.WorkflowJob;
+import org.apache.oozie.client.WorkflowJob.Status;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlString;
+import org.n52.wps.PropertyDocument.Property;
+import org.n52.wps.commons.WPSConfig;
+import org.n52.wps.server.ExceptionReport;
+import org.n52.wps.server.profiles.AbstractProcessManager;
+import org.n52.wps.server.repository.ITransactionalAlgorithmRepository;
+import org.n52.wps.server.request.DeployProcessRequest;
+import org.n52.wps.server.request.ExecuteRequest;
+import org.n52.wps.server.request.UndeployProcessRequest;
+import org.n52.wps.server.request.deploy.DeploymentProfile;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import xint.esa.ese.wps.format.urlList.URLListDocument;
+import xint.esa.ese.wps.format.urlList.URLListDocument.URLList;
+
+/**
+ * TODO this class was based on transactional branch implementation. However the
+ * invoke method was reimplemented Therefore there is a doublon implementation
+ * for sending request. *
+ *
+ * @author cnl
+ *
+ */
+public class OozieManager extends AbstractProcessManager {
+ // TODO rename to Oozie instead ozzie
+ // logger for debug purpose
+ private final Logger log = Logger.getLogger(getClass());
+ private String oozieUrl;
+ private String deployDirectory;
+ private String hdfsUrl;
+
+ // the WPS instance ID (not expected to be the same)
+ private String taskId;
+ // the oozie instance ID
+ private String jobId;
+ // Client for Oozie (oozie jar)
+ private OozieClient client;
+ // HDFS manager (for file system operations)
+ private HDFSClient hdfsManager;
+ private String jobTrackerUrl;
+ private String hadoopDefaultUser;
+
+ /**
+ * Singleton for the Oozie client
+ *
+ * @return
+ */
+ private OozieClient getClient() {
+ if (this.client == null) {
+ this.client = new OozieClient(this.getOozieUrl());
+ }
+ return this.client;
+ }
+
+
+ public String getPriority(ArrayList priority) {
+ String cnName = null;
+ try {
+ for (SOAPHeaderBlock samlHeader : priority) {
+ OMElement priority1 = (OMElement) samlHeader
+ .getChildrenWithLocalName("Priority").next();
+
+ cnName = priority1.getText();
+ log.debug("discovered CNAME is "+cnName);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ if (StringUtils.isBlank(cnName)) {
+ return null;
+ }
+ return cnName;
+ }
+
+
+ public String getSAMLUserName(ArrayList saml) {
+ String cnName = null;
+ try {
+ for (SOAPHeaderBlock samlHeader : saml) {
+ OMElement assertion = (OMElement) samlHeader
+ .getChildrenWithLocalName("Assertion").next();
+ OMElement attributeStatement = (OMElement) assertion
+ .getChildrenWithLocalName("AttributeStatement").next();
+ OMElement subject = (OMElement) attributeStatement
+ .getChildrenWithLocalName("Subject").next();
+ OMElement nameIdentifier = (OMElement) subject
+ .getChildrenWithLocalName("NameIdentifier").next();
+ cnName = nameIdentifier.getText();
+ }
+ } catch (Exception e) {
+ }
+ if (StringUtils.isBlank(cnName)) {
+ return this.getHadoopDefaultUser();
+ }
+ return cnName;
+ }
+
+ /**
+ * Contructor
+ *
+ * @param parentRepository
+ */
+ public OozieManager(ITransactionalAlgorithmRepository parentRepository) {
+ super(parentRepository);
+ // Retrieve repository properties from wps_config.xml (WEB-INF/config)
+ Property[] properties = WPSConfig.getInstance()
+ .getPropertiesForRepositoryName("OozieRepository");
+ // Get the Oozie URL property
+ this.setOozieUrl(getPropertyUtil("Oozie_URL", properties));
+ this.setDeployDirectory(getPropertyUtil("HDFS_Deploy_Directory",
+ properties));
+ this.hdfsUrl = getPropertyUtil("HDFS_Local_URL", properties);
+ this.jobTrackerUrl = getPropertyUtil("JobTracker_URL", properties);
+ // Todo include the configuration files
+ this.setHdfsManager(new HDFSClient(getPropertyUtil("HDFS_Remote_URL",
+ properties), getPropertyUtil("HDFS_Admin_User", properties)));
+ this.setHadoopDefaultUser(getPropertyUtil("Hadoop_Default_User",
+ properties));
+ }
+
+ /**
+ * undeploy a process
+ */
+ @Override
+ public boolean unDeployProcess(UndeployProcessRequest request)
+ throws Exception {
+ return unstoreArchive(request.getProcessID());
+ }
+
+ @Override
+ public boolean containsProcess(String processID) throws Exception {
+ // Not used, inherited historically
+ return false;
+ }
+
+ @Override
+ public Collection getAllProcesses() throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Document invoke(ExecuteDocument payload, String algorithmID)
+ throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Document invoke(ExecuteRequest request, String algorithmID)
+ throws Exception {
+ Properties outputProps = null;
+ Properties conf = this.getClient().createConfiguration();
+ // Get the user from the SOAP header
+ // String user = getUser(request);
+ // TODO replace user by saml token value
+ String user = this.getSAMLUserName(request.getSamlHeader());
+ // Get the WPS process instance id (task id)
+ String taskId = request.getId();
+ // set the username
+ conf.setProperty("user.name", user);
+ log.debug("has set the user name: " + user);
+ // create the user home directory if necessary
+ try {
+ this.getHdfsManager().createHomeDirectoryIfNeeded(user);
+ }
+ catch(Exception e) {
+ // create Home directory error.
+ }
+ String priority = this.getPriority(request.getQOSHeaderBlocks());
+ if(priority != null) {
+ conf.setProperty("priority",priority);
+ log.debug("priority property set :"+priority);
+ }
+ // set the namenode and jobtracker URLs
+ conf.setProperty("jobTracker", this.getJobTrackerUrl());
+ // do not change the IP of the jobTracker and the nameNode
+ conf.setProperty("nameNode", this.getHdfsUrl());
+ ///conf.setProperty("jobTracker", this.getJobTrackerUrl());
+ // set the path to the workflow that is deployed on HDFS
+ conf.setProperty(
+ "oozie.wf.application.path",
+ "${nameNode}" + this.getDeployDirectory()
+ + request.getAlgorithmIdentifier() + "/workflow.xml");
+ // String inputDir = "/user/" + user + "/results/" + taskId + "/inputs";
+ String outputDir = "/user/" + user + "/results/" + taskId + "/ouputs";
+ // this.getHdfsManager().mkdir(inputDir);
+ // this.getHdfsManager().mkdir(outputDir);
+ // conf.setProperty("inputDir", "${nameNode}/user/" + user + "/eodata");
+ // conf.setProperty("outputDir", "${nameNode}/user/" + user +
+ // "/results");
+ // conf.setProperty("inputDir", "${nameNode}" + inputDir);
+ // conf.setProperty("outputDir", "${nameNode}" + outputDir);
+
+ InputType[] inputs = request.getExecute().getDataInputs()
+ .getInputArray();
+
+ for (InputType input : inputs) {
+ if (input.getData().isSetLiteralData()) {
+ String identifier = input.getIdentifier().getStringValue();
+ String value = input.getData().getLiteralData()
+ .getStringValue();
+ conf.setProperty(identifier, value);
+ }
+ if (input.getData().isSetComplexData()) {
+ log.debug("INPUT:" + input.toString());
+ URLListDocument doc = URLListDocument.Factory.parse(input
+ .getData().getComplexData().newInputStream());
+ StringBuffer sb = new StringBuffer();
+ for (String url : doc.getURLList().getUrlArray()) {
+ if (sb.length() > 0) {
+ sb.append(",");
+ }
+ sb.append(url);
+ }
+ String identifier = input.getIdentifier().getStringValue();
+ conf.setProperty(identifier, sb.toString());
+ }
+ if (input.getData().isSetBoundingBoxData()) {
+ log.debug("INPUT:" + input.toString());
+ List upCorner = (List)input.getData().getBoundingBoxData().getUpperCorner();
+ List lowCorner = (List) input.getData().getBoundingBoxData().getLowerCorner();
+ String identifier = input.getIdentifier().getStringValue();
+ conf.setProperty(identifier+"_tlx", lowCorner.get(1).toString());
+ conf.setProperty(identifier+"_tly", upCorner.get(0).toString());
+ conf.setProperty(identifier+"_brx", upCorner.get(1).toString());
+ conf.setProperty(identifier+"_bry", lowCorner.get(0).toString());
+ }
+ }
+ try {
+ this.jobId = this.getClient().run(conf);
+ System.out.println("Job ID: " + this.jobId);
+ WorkflowJob workflowJob = this.getClient().getJobInfo(this.jobId);
+ Status status = workflowJob.getStatus();
+ int sleepStrategy = 150;
+ while (status != WorkflowJob.Status.SUCCEEDED
+ && status != WorkflowJob.Status.FAILED
+ && status != WorkflowJob.Status.KILLED) {
+ Thread.sleep(sleepStrategy);
+ log.debug("sleeping for " + sleepStrategy + " ms");
+ if (sleepStrategy < 3000)
+ sleepStrategy = sleepStrategy * 2;
+ workflowJob = this.getClient().getJobInfo(this.jobId);
+ status = workflowJob.getStatus();
+
+ }
+ if (status == WorkflowJob.Status.SUCCEEDED) {
+ log.debug("publishing");
+ for (WorkflowAction action : workflowJob.getActions()) {
+ if (action.getName().equals("Publish")) {
+ System.out.println("Data: " + action.getData());
+ outputProps = new Properties();
+ outputProps.load(new StringReader(action.getData()));
+ log.debug(outputProps.toString());
+ }
+ }
+ } else {
+ if (status == WorkflowJob.Status.KILLED) {
+ String errorMessage = "Killed Process - Failed Actions:";
+
+ for (WorkflowAction action : workflowJob.getActions()) {
+ if (action.getStatus() == WorkflowAction.Status.ERROR) {
+ WorkflowAction realAction;
+ if(action.getErrorMessage()==null){
+ realAction = guessSubWorkflowErrorMessage(action.getExternalId());
+ }
+ else {
+ realAction= action;
+ }
+ errorMessage = errorMessage.concat("\n"
+ + realAction.getName() + "(id:"
+ + realAction.getId() + ") - status:"
+ + realAction.getStatus().toString()
+ + " -start time:"
+ + realAction.getStartTime().toGMTString()
+ + " - error code:" + realAction.getErrorCode()
+ + " - message:" + realAction.getErrorMessage());
+ }
+
+ }
+
+ ExceptionReport exReport = new ExceptionReport(
+ errorMessage, ExceptionReport.NO_APPLICABLE_CODE);
+ log.debug("killed");
+ exReport.printStackTrace();
+ throw exReport;
+
+ }
+ if (status == WorkflowJob.Status.FAILED) {
+ String errorMessage = "Failed Process - Failed Actions:";
+
+ for (WorkflowAction action : workflowJob.getActions()) {
+ if (action.getStatus() == WorkflowAction.Status.ERROR) {
+ WorkflowAction realAction;
+ if(action.getErrorMessage()==null){
+ realAction = guessSubWorkflowErrorMessage(action.getExternalId());
+ }
+ else {
+ realAction= action;
+ }
+ errorMessage = errorMessage.concat("\n"
+ + realAction.getName() + "(id:"
+ + realAction.getId() + ") - status:"
+ + realAction.getStatus().toString()
+ + " -start time:"
+ + realAction.getStartTime().toGMTString()
+ + " - error code:" + realAction.getErrorCode()
+ + " - message:" + realAction.getErrorMessage());
+ }
+
+ }
+ ExceptionReport exReport = new ExceptionReport(
+ errorMessage, ExceptionReport.NO_APPLICABLE_CODE);
+ log.debug("killed");
+ exReport.printStackTrace();
+ throw exReport;
+
+ }
+ log.debug("untrowned exception");
+ throw new ExceptionReport("Oozie - Not successful job",
+ ExceptionReport.NO_APPLICABLE_CODE);
+ }
+ }
+
+ catch (OozieClientException ex) {
+ ex.printStackTrace();
+ throw new ExceptionReport("Oozie client exception", "1", "none");
+ }
+ ExecuteResponseDocument execRepDom = ExecuteResponseDocument.Factory
+ .newInstance();
+ execRepDom.addNewExecuteResponse();
+ execRepDom.getExecuteResponse().setLang("en");
+ execRepDom.getExecuteResponse().addNewProcessInstanceIdentifier()
+ .setInstanceId(taskId);
+ execRepDom.getExecuteResponse().addNewStatus()
+ .setProcessSucceeded("success");
+ execRepDom.getExecuteResponse().addNewProcessOutputs();
+ execRepDom.getExecuteResponse().addNewProcessOutputs();
+ ProcessOutputs outputsDom = execRepDom.getExecuteResponse()
+ .getProcessOutputs();
+
+ for (DocumentOutputDefinitionType outputEntry : request.getExecute()
+ .getResponseForm().getResponseDocument().getOutputArray()) {
+ String outputName = outputEntry.getIdentifier().getStringValue();
+ String value = outputProps.getProperty(outputName);
+ OutputDataType output = outputsDom.addNewOutput();
+ output.addNewIdentifier().setStringValue(outputName);
+ OutputDescriptionType desc = getOutputDescription(
+ request.getAlgorithmIdentifier(), outputName);
+ if (desc != null && desc.isSetComplexOutput()) {
+ output.addNewData().addNewComplexData()
+ .set(this.createURLList(value));
+ } else {
+ output.addNewData().addNewLiteralData().setStringValue(value);
+ }
+ }
+
+ log.debug(execRepDom.toString());
+ // ProcessOutputs outputsDom = execRepDom.getExecuteResponse()
+ return (Document) execRepDom.getDomNode();
+ }
+
+ private URLListDocument createURLList(String urls) {
+ URLListDocument urlListDocument = URLListDocument.Factory.newInstance();
+ URLList list = urlListDocument.addNewURLList();
+ StringTokenizer st = new StringTokenizer(urls, ",");
+ while (st.hasMoreTokens()) {
+ list.addNewUrl().setStringValue(st.nextToken());
+ }
+ return urlListDocument;
+ }
+
+ private WorkflowAction guessSubWorkflowErrorMessage(String oozieSubWorkflowId) throws OozieClientException {
+
+ WorkflowJob workflowJob = this.getClient().getJobInfo(
+ oozieSubWorkflowId);
+ List workflowActions = workflowJob.getActions();
+ for (WorkflowAction workflowAction : workflowActions) {
+ if (workflowAction.getErrorMessage() != null) {
+ return workflowAction;
+ } else if ("sub-workflow".equals(workflowAction.getType())) {
+ return guessSubWorkflowErrorMessage(workflowAction
+ .getExternalId());
+ }
+ }
+ return null;
+ }
+
+ public OutputDescriptionType getOutputDescription(String algo,
+ String identifier) {
+ OutputDescriptionType[] outputsDesc = this.parentRepository
+ .getProcessDescription(algo).getProcessOutputs()
+ .getOutputArray();
+ for (OutputDescriptionType desc : outputsDesc) {
+ if (desc.getIdentifier().getStringValue()
+ .equalsIgnoreCase(identifier)) {
+ return desc;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public boolean deployProcess(DeployProcessRequest request) throws Exception {
+ // Get the the deployment profile from the request
+ DeploymentProfile profile = request.getDeploymentProfile();
+ if (!(profile instanceof OozieDeploymentProfile)) {
+ throw new Exception("Requested Deployment Profile not supported");
+ }
+ OozieDeploymentProfile deploymentProfile = (OozieDeploymentProfile) profile;
+ String processID = deploymentProfile.getProcessID();
+ // Store the archive from the request
+ storeArchive(deploymentProfile.getArchive(), processID);
+ log.debug("Stored Archive:" + deploymentProfile.getArchive());
+ return true;
+ }
+
+ /**
+ * Unzip a collection of files contained in a archive zip file and write
+ * onto hdfs
+ *
+ * @param archive
+ * @param processID
+ * @throws IOException
+ * @throws InterruptedException
+ */
+ private void storeArchive(byte[] archive, String processID)
+ throws IOException, InterruptedException {
+ // Deployment directory (definition)
+ String archiveDir = getProcessDeploymentDirectory(processID);
+ // Creation of deployment directory
+ log.info("Creating directory " + archiveDir);
+ this.getHdfsManager().mkdir(archiveDir);
+ log.info("Storing archive in " + archiveDir);
+ // Read the zip archive
+ ByteArrayInputStream bais = new ByteArrayInputStream(archive);
+ byte[] buf = new byte[1024];
+ ZipInputStream zis = new ZipInputStream(bais);
+ ZipEntry zipentry = null;
+ // For each zip entry (file), create the directory, then write the file
+ while ((zipentry = zis.getNextEntry()) != null) {
+ String entryName = zipentry.getName();
+ if (zipentry.isDirectory()) {
+ log.info("Create dir " + entryName);
+ this.getHdfsManager().mkdir(archiveDir + entryName);
+ } else {
+ log.info("Writing file " + entryName);
+ this.getHdfsManager().writeFile(zis, archiveDir + entryName);
+ }
+ zis.closeEntry();
+
+ }
+
+ zis.close();
+
+ }
+
+ /**
+ * Unstore Archive
+ *
+ * @param processId
+ * @return
+ * @throws IOException
+ * @throws InterruptedException
+ */
+ private boolean unstoreArchive(String processId) throws IOException, InterruptedException {
+ String archiveDir = getProcessDeploymentDirectory(processId);
+ this.getHdfsManager().deleteFile(archiveDir);
+ ;
+
+ return true;
+ }
+
+ /**
+ * Deletes all files and subdirectories under dir. Returns true if all
+ * deletions were successful. If a deletion fails, the method stops
+ * attempting to delete and returns false.
+ *
+ * @param dir
+ * @return
+ */
+ public static boolean deleteDir(File dir) {
+ if (dir.isDirectory()) {
+ String[] children = dir.list();
+ for (int i = 0; i < children.length; i++) {
+ boolean success = deleteDir(new File(dir, children[i]));
+ if (!success) {
+ return false;
+ }
+ }
+ }
+
+ // The directory is now empty so delete it
+ return dir.delete();
+ }
+
+ /**
+ * Get the deployment directory of a process
+ *
+ * @param processID
+ * @return
+ */
+ private String getProcessDeploymentDirectory(String processID) {
+ return this.getDeployDirectory() + processID + File.separator;
+ }
+
+ @Override
+ public AuditTraceType getAuditLongForm() throws Exception {
+ log.debug("long form");
+ if (this.getJobId() == null) {
+ throw new RuntimeException(
+ "Error. WPS service has not created the Oozie job yet.");
+ }
+ // Get the job log
+ String jobLog = this.getClient().getJobLog(jobId);
+ System.out.print("JobLog:"+jobLog);
+
+ DocumentBuilderFactory docFactory = DocumentBuilderFactory
+ .newInstance();
+ DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+ Document doc = docBuilder.newDocument();
+ // Create a "Log" root element
+ Element rootElement = doc.createElement("Audit");
+ // Set the log as text content
+ rootElement.setTextContent(jobLog);
+
+ //doc.appendChild(rootElement);
+ // Parse the Audit Trace document (any el / any att type)
+ //AuditTraceType audit = AuditTraceType.Factory.parse(jobLog);
+ AuditTraceType audit = AuditTraceType.Factory.parse(rootElement);
+ return audit;
+ }
+
+ public static void main(String[] args) throws XmlException, ParserConfigurationException {
+ XmlString xmlString =XmlString.Factory.newInstance();
+ xmlString.setStringValue("1");
+ AuditTraceType audit = AuditTraceType.Factory.parse(xmlString.getDomNode());
+ audit.setShortForm(true);
+
+ //audit.set(xmlString);
+
+ /**
+ DocumentBuilderFactory docFactory = DocumentBuilderFactory
+ .newInstance();
+ DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+ Document doc = docBuilder.newDocument();
+ // Create a "Log" root element
+ Element rootElement = doc.createElement("Audit");
+ // Set the log as text content
+ rootElement.setTextContent(test);
+
+ //doc.appendChild(rootElement);
+ //AuditTraceType audit = AuditTraceType.Factory.parse(rootElement);
+ AuditTraceType audit = AuditTraceType.Factory.newInstance();
+ */
+ XmlString x = XmlString.Factory.parse(audit.getDomNode());
+
+ System.out.println(x.getStringValue());
+
+ }
+
+ @Override
+ public AuditTraceType getAudit() throws Exception {
+ // TODO Auto-generated method stub
+ XmlString xmlString =XmlString.Factory.newInstance();
+ xmlString.setStringValue(this.jobId);
+ AuditTraceType audit = AuditTraceType.Factory.parse(xmlString.getDomNode());
+ audit.setShortForm(true);
+return audit;
+
+ }
+
+ @Override
+ public String getIID() {
+ return this.getTaskId();
+ }
+
+ @Override
+ public void cancel() {
+ try {
+ if (StringUtils.isNotBlank(this.jobId)) {
+ this.getClient().kill(this.jobId);
+ }
+ } catch (OozieClientException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ * Utility method that should better be implemented in WPSConfig class Get
+ * the property string value and throws exception if null
+ */
+
+ private String getPropertyUtil(String property, Property[] properties) {
+ Property prop = WPSConfig.getInstance().getPropertyForKey(properties,
+ property);
+ if (prop == null) {
+ throw new RuntimeException("Error. Could not find " + property);
+ }
+ return prop.getStringValue();
+
+ }
+
+ public String getOozieUrl() {
+ return oozieUrl;
+ }
+
+ public void setOozieUrl(String oozieUrl) {
+ this.oozieUrl = oozieUrl;
+ }
+
+ public String getDeployDirectory() {
+ if (!deployDirectory.endsWith(File.separator)) {
+ deployDirectory = deployDirectory.concat(File.separator);
+ }
+ return deployDirectory;
+ }
+
+ public void setDeployDirectory(String deployDirectory) {
+ this.deployDirectory = deployDirectory;
+ }
+
+ private String getUser(ExecuteRequest req) {
+ String cnName = null;
+ try {
+
+ for (SOAPHeaderBlock samlHeader : req.getSamlHeader()) {
+ log.info("LocalName = " + samlHeader.getLocalName());
+ OMElement assertion = (OMElement) samlHeader
+ .getChildrenWithLocalName("Assertion").next();
+ log.info("Assertion found:" + assertion.toString());
+ OMElement attributeStatement = (OMElement) assertion
+ .getChildrenWithLocalName("AttributeStatement").next();
+ log.info("AttributeStatement found");
+ OMElement subject = (OMElement) attributeStatement
+ .getChildrenWithLocalName("Subject").next();
+ log.info("Subject found:" + subject.toString());
+ OMElement nameIdentifier = (OMElement) subject
+ .getChildrenWithLocalName("NameIdentifier").next();
+ log.info("Name Id found" + nameIdentifier.toString());
+ cnName = nameIdentifier.getText();
+ log.info(cnName);
+ }
+
+ } catch (Exception e) {
+ }
+
+ return cnName;
+ }
+
+ public String getTaskId() {
+ return taskId;
+ }
+
+ public void setTaskId(String taskId) {
+ this.taskId = taskId;
+ }
+
+ public String getJobId() {
+ return jobId;
+ }
+
+ public void setJobId(String jobId) {
+ this.jobId = jobId;
+ }
+
+ public HDFSClient getHdfsManager() {
+ return hdfsManager;
+ }
+
+ public void setHdfsManager(HDFSClient hdfsManager) {
+ this.hdfsManager = hdfsManager;
+ }
+
+ public String getJobTrackerUrl() {
+ return jobTrackerUrl;
+ }
+
+ public void setJobTrackerUrl(String jobTrackerUrl) {
+ this.jobTrackerUrl = jobTrackerUrl;
+ }
+
+ public static void main2(String[] args) {
+ OozieClient xclient = new OozieClient(
+ "http://192.168.56.101:11000/oozie/");
+ Properties conf = xclient.createConfiguration();
+
+ // set the username
+ // conf.setProperty("user.name", "oozie");
+ conf.setProperty("user.name", "christophe");
+ // set the namenode and jobtracker URLs
+
+ // do not change the IP of the jobTracker and the nameNode
+ conf.setProperty("nameNode", "hdfs://localhost.localdomain:8020");
+ conf.setProperty("jobTracker", "localhost.localdomain:8021");
+
+ // set the path to the workflow that is deployed on HDFS
+ conf.setProperty("oozie.wf.application.path",
+ "${nameNode}/user/christophe/workflows/parent/workflow.xml");
+ // set additional parameters for the Oozie workflow
+ conf.setProperty("roiX", "4000");
+ conf.setProperty("roiY", "4000");
+ conf.setProperty("roiW", "1000");
+ conf.setProperty("roiH", "1000");
+ conf.setProperty("byteDepth", "1");
+ conf.setProperty("inputDir", "${nameNode}/user/christophe/eodata");
+ conf.setProperty("outputDir", "${nameNode}/user/christophe/results");
+ try {
+ String jobId = xclient.run(conf);
+ System.out.println("Workflow job submitted : " + jobId);
+ WorkflowJob workflowJob = xclient.getJobInfo(jobId);
+ Status status = workflowJob.getStatus();
+ while (status != WorkflowJob.Status.SUCCEEDED) {
+ String jobLog = xclient.getJobLog(jobId);
+ System.out.print("JobLog:");
+ System.out.println(jobLog);
+
+ Thread.sleep(5000);
+ workflowJob = xclient.getJobInfo(jobId);
+ status = workflowJob.getStatus();
+
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ public String getHdfsUrl() {
+ return hdfsUrl;
+ }
+
+ public void setHdfsUrl(String hdfsUrl) {
+ this.hdfsUrl = hdfsUrl;
+ }
+
+ public String getHadoopDefaultUser() {
+ return hadoopDefaultUser;
+ }
+
+ public void setHadoopDefaultUser(String hadoopDefaultUser) {
+ this.hadoopDefaultUser = hadoopDefaultUser;
+ }
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/repository/DefaultTransactionalProcessRepository.java b/52n-wps-server/src/main/java/org/n52/wps/server/repository/DefaultTransactionalProcessRepository.java
index f5450de99..61670c64b 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/repository/DefaultTransactionalProcessRepository.java
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/repository/DefaultTransactionalProcessRepository.java
@@ -1,355 +1,356 @@
-package org.n52.wps.server.repository;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import net.opengis.wps.x100.DataDescriptionType;
-import net.opengis.wps.x100.ProcessDescriptionType;
-
-import org.apache.log4j.Logger;
-import org.n52.wps.PropertyDocument.Property;
-import org.n52.wps.RepositoryDocument.Repository;
-import org.n52.wps.commons.WPSConfig;
-import org.n52.wps.server.AbstractTransactionalAlgorithm;
-import org.n52.wps.server.AbstractTransactionalData;
-import org.n52.wps.server.ExceptionReport;
-import org.n52.wps.server.IAlgorithm;
-import org.n52.wps.server.profiles.AbstractProcessManager;
-import org.n52.wps.server.profiles.DefaultTransactionalAlgorithm;
-import org.n52.wps.server.profiles.IProcessManager;
-import org.n52.wps.server.request.DeployProcessRequest;
-import org.n52.wps.server.request.ExecuteRequest;
-import org.n52.wps.server.request.UndeployProcessRequest;
-
-/**
- * DefaultTransactionalProcessRepository is a default repository which include :
- * -profile deployement class - process manager class - schema related to the
- * profile - algorithm class
- *
- */
-public class DefaultTransactionalProcessRepository implements
- ITransactionalAlgorithmRepository {
- private static Logger LOGGER = Logger
- .getLogger(DefaultTransactionalProcessRepository.class);
- protected Map processDescriptionMap;
- protected Map dataDescriptionMap;
- protected String format;
-
- public String getFormat() {
- return format;
- }
-
- public void setFormat(String format) {
- this.format = format;
- }
-
- protected IProcessManager processManager;
- private Repository repository;
-
- public DefaultTransactionalProcessRepository(String format) {
- setFormat(format);
- LOGGER.info("DefaultTransactionalProcessRepository - format:" + format);
- setRepository(WPSConfig.getInstance().getRepositoryForFormat(format));
-
- // DONE think of multiple instance of this class registered (yet not
- // possible since singleton)
- Property processManagerXML = getPropertyForKey("ProcessManager");
- if (processManagerXML == null) {
- throw new RuntimeException(
- "Error. Could not find matching ProcessManager");
- }
- LOGGER.info("found process maanger");
- processDescriptionMap = new HashMap();
- dataDescriptionMap = new HashMap();
- // TODO check repository is active
- /**
- * algorithmMap = new HashMap(); for (Property property
- * : getRepository().getPropertyArray()) { if
- * (property.getName().equalsIgnoreCase("Algorithm") &&
- * property.getActive()) { algorithmMap.put(property.getStringValue(),
- * property.getStringValue()); } }
- */
- String className = processManagerXML.getStringValue();
- try {
- LOGGER.info("Process Manager class: "
- + processManagerXML.getStringValue());
- Class> processManagerClass = Class.forName(className);
- if (processManagerClass.asSubclass(AbstractProcessManager.class)
- .equals(processManagerClass)) {
- Constructor constructor = processManagerClass
- .getConstructor(ITransactionalAlgorithmRepository.class);
- processManager = (IProcessManager) constructor
- .newInstance(this);
- LOGGER.info("asSubclass");
- } else {
- processManager = (IProcessManager) processManagerClass
- .newInstance();
- }
-
- } catch (InstantiationException e) {
- e.printStackTrace();
- throw new RuntimeException(
- "Error. Could not find matching DeployManager");
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- throw new RuntimeException(
- "Error. Could not find matching DeployManager");
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- throw new RuntimeException(
- "Error. Could not find matching DeployManager");
- } catch (SecurityException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- LOGGER.info("end constructor DefaultTrans");
- }
-
- public Repository getRepository() {
- return repository;
- }
-
- public void setRepository(Repository repository) {
- this.repository = repository;
- }
-
- public Property getPropertyForKey(String key) {
- for (Property property : getRepository().getPropertyArray()) {
- if (property.getName().equals(key)) {
- return property;
- }
- }
- return null;
- }
-
- public boolean addAlgorithm(Object process) {
- /** Should not be used anymore (see new signature)
- * if (!(process instanceof DeployProcessRequest)) {
- return false;
- }
- DeployProcessRequest request = (DeployProcessRequest) process;
- try {
- if(containsAlgorithm(request.getProcessID())) {
- throw new ExceptionReport("Process already exists. Please undeploy before redeploying a Process.",
- ExceptionReport.NO_APPLICABLE_CODE);
- }
- LOGGER.info("Adding process for profile: " + this.getFormat());
- processManager.deployProcess(request);
- Property algoProp = getRepository().addNewProperty();
- algoProp.setName("Algorithm");
- algoProp.setActive(true);
- algoProp.setStringValue(request.getProcessID());
- WPSConfig.getInstance().save();
- } catch (Exception e) {
- LOGGER.warn("Could not instantiate algorithm: " + request);
- e.printStackTrace();
- return false;
- }*/
- return false;
- }
-
- public void addAlgorithm(DeployProcessRequest request) throws ExceptionReport {
- if(containsAlgorithm(request.getProcessID())) {
- throw new ExceptionReport("Process already exists. Please undeploy before redeploying a Process.",
- ExceptionReport.NO_APPLICABLE_CODE);
- }
- LOGGER.info("Adding process for profile: " + this.getFormat());
- try {
- processManager.deployProcess(request);
- /**
- * Moved (TODO delete)
- Property algoProp = getRepository().addNewProperty();
- algoProp.setName("Algorithm");
- algoProp.setActive(true);
- algoProp.setStringValue(request.getProcessID());
- WPSConfig.getInstance().save();
- */
- } catch (Exception e) {
- e.printStackTrace();
- throw new ExceptionReport("Deployment failed.",
- ExceptionReport.NO_APPLICABLE_CODE);
- }
- return;
- }
-
- /**
- * TODO : check if the remote contains also the process --- return
- * processManager.containsProcess(processID); Note: for some profile the
- * backend doesn't support any deploy / undeploy / contains operation ->
- * done through WPS
- */
- public boolean containsAlgorithm(String processID) {
- try {
- for (Property property : getRepository().getPropertyArray()) {
- if (property.getName().equalsIgnoreCase("Algorithm")
- && property.getActive()) {
- if (property.getStringValue().equals(processID)) {
- return true;
- }
- }
- }
- return false;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
-
- public IAlgorithm getAlgorithm(String processID,
- ExecuteRequest executeRequest) {
- return new DefaultTransactionalAlgorithm(processID);
-
- }
- public Collection getDataNames() {
- LOGGER.info("Get data names...");
- Collection dataNames= new ArrayList();
- try {
- for (Property property : getRepository().getPropertyArray()) {
- if (property.getName().equalsIgnoreCase("Data")
- && property.getActive()) {
- if (!property.getStringValue().isEmpty()) {
- dataNames.add(property.getStringValue());
- LOGGER.info(property.getStringValue());
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- return dataNames;
- }
- public Collection getAlgorithmNames() {
- Collection algoNames= new ArrayList();
- try {
- for (Property property : getRepository().getPropertyArray()) {
- if (property.getName().equalsIgnoreCase("Algorithm")
- && property.getActive()) {
- if (!property.getStringValue().isEmpty()) {
- algoNames.add(property.getStringValue());
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- return algoNames;
- /**
- * Previous implementation which request backend :
- * in SSEGRid this is not the case
- *
- try {
-
- return processManager.getAllProcesses();
- } catch (Exception e) {
- e.printStackTrace();
- return new ArrayList();
- }
- */
- }
-
- public Collection getAlgorithms() {
- Collection result = new ArrayList();
- Collection allAlgorithms;
- try {
- LOGGER.info("class of processManager:"
- + processManager.getClass().getName());
- allAlgorithms = processManager.getAllProcesses();
- } catch (Exception e) {
- e.printStackTrace();
- return new ArrayList();
- }
- for (String processID : allAlgorithms) {
- result.add(new DefaultTransactionalAlgorithm(processID));
- }
- return result;
- }
-
- public boolean removeAlgorithm(Object process) {
- LOGGER.info("removeAlgorithm");
- if (!(process instanceof UndeployProcessRequest)) {
- LOGGER.info("not instance");
- return false;
- }
- UndeployProcessRequest request = (UndeployProcessRequest) process;
- try {
- LOGGER.info("try undeploy");
- processManager.unDeployProcess(request);
- Property[] propArray = getRepository().getPropertyArray();
- for (int i = 0; i < propArray.length; i++) {
- LOGGER.info(i);
- Property algoProp = propArray[i];
- if (algoProp.getName().equalsIgnoreCase("Algorithm")
- && algoProp.getActive()) {
- if (algoProp.getStringValue()
- .equals(request.getProcessID())) {
- getRepository().removeProperty(i);
- WPSConfig.getInstance().save();
- processDescriptionMap.remove(request.getProcessID());
- return true;
- }
- }
- }
-
- } catch (Exception e) {
- LOGGER.warn("Could not remove algorithm: " + request);
- e.printStackTrace();
- return false;
- }
- return false;
-
- }
-
- @Override
- public ProcessDescriptionType getProcessDescription(String processID) {
- if (!processDescriptionMap.containsKey(processID)) {
- LOGGER.info("Adding new process description to the map.");
- processDescriptionMap.put(processID,
- AbstractTransactionalAlgorithm.getDescription(processID));
- }
- return processDescriptionMap.get(processID);
- }
-
- public boolean containsData(String dataName) {
- try {
- for (Property property : getRepository().getPropertyArray()) {
- if (property.getName().equalsIgnoreCase("Data")
- && property.getActive()) {
- if (property.getStringValue().equals(dataName)) {
- return true;
- }
- }
- }
- return false;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
-
- public DataDescriptionType getDataDescription(String dataName) {
- LOGGER.info("start");
- if (!dataDescriptionMap.containsKey(dataName)) {
- LOGGER.info("Adding new process description to the map.");
- dataDescriptionMap.put(dataName,
- AbstractTransactionalData.getDescription(dataName));
- }
- return dataDescriptionMap.get(dataName);
-
- }
-
-}
+package org.n52.wps.server.repository;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import net.opengis.wps.x100.DataDescriptionType;
+import net.opengis.wps.x100.ProcessDescriptionType;
+
+import org.apache.log4j.Logger;
+import org.n52.wps.PropertyDocument.Property;
+import org.n52.wps.RepositoryDocument.Repository;
+import org.n52.wps.commons.WPSConfig;
+import org.n52.wps.server.AbstractTransactionalAlgorithm;
+import org.n52.wps.server.AbstractTransactionalData;
+import org.n52.wps.server.ExceptionReport;
+import org.n52.wps.server.IAlgorithm;
+import org.n52.wps.server.profiles.AbstractProcessManager;
+import org.n52.wps.server.profiles.DefaultTransactionalAlgorithm;
+import org.n52.wps.server.profiles.IProcessManager;
+import org.n52.wps.server.request.DeployProcessRequest;
+import org.n52.wps.server.request.ExecuteRequest;
+import org.n52.wps.server.request.UndeployProcessRequest;
+
+/**
+ * DefaultTransactionalProcessRepository is a default repository which include :
+ * -profile deployement class - process manager class - schema related to the
+ * profile - algorithm class
+ *
+ */
+public class DefaultTransactionalProcessRepository implements
+ ITransactionalAlgorithmRepository {
+ private static Logger LOGGER = Logger
+ .getLogger(DefaultTransactionalProcessRepository.class);
+ protected Map processDescriptionMap;
+ protected Map dataDescriptionMap;
+ protected String format;
+
+ public String getFormat() {
+ return format;
+ }
+
+ public void setFormat(String format) {
+ this.format = format;
+ }
+
+ protected IProcessManager processManager;
+ private Repository repository;
+
+ public DefaultTransactionalProcessRepository(String format) {
+ setFormat(format);
+ LOGGER.info("DefaultTransactionalProcessRepository - format:" + format);
+ setRepository(WPSConfig.getInstance().getRepositoryForFormat(format));
+
+ // DONE think of multiple instance of this class registered (yet not
+ // possible since singleton)
+ Property processManagerXML = getPropertyForKey("ProcessManager");
+ if (processManagerXML == null) {
+ throw new RuntimeException(
+ "Error. Could not find matching ProcessManager");
+ }
+ LOGGER.info("found process maanger");
+ processDescriptionMap = new HashMap();
+ dataDescriptionMap = new HashMap();
+ // TODO check repository is active
+ /**
+ * algorithmMap = new HashMap(); for (Property property
+ * : getRepository().getPropertyArray()) { if
+ * (property.getName().equalsIgnoreCase("Algorithm") &&
+ * property.getActive()) { algorithmMap.put(property.getStringValue(),
+ * property.getStringValue()); } }
+ */
+ String className = processManagerXML.getStringValue();
+ try {
+ LOGGER.info("Process Manager class: "
+ + processManagerXML.getStringValue());
+ Class> processManagerClass = Class.forName(className);
+ if (processManagerClass.asSubclass(AbstractProcessManager.class)
+ .equals(processManagerClass)) {
+ Constructor constructor = processManagerClass
+ .getConstructor(ITransactionalAlgorithmRepository.class);
+ processManager = (IProcessManager) constructor
+ .newInstance(this);
+ LOGGER.info("asSubclass");
+ } else {
+ processManager = (IProcessManager) processManagerClass
+ .newInstance();
+ }
+
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ throw new RuntimeException(
+ "Error. Could not find matching DeployManager");
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ throw new RuntimeException(
+ "Error. Could not find matching DeployManager");
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ throw new RuntimeException(
+ "Error. Could not find matching DeployManager");
+ } catch (SecurityException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ LOGGER.info("end constructor DefaultTrans");
+ }
+
+ public Repository getRepository() {
+ return repository;
+ }
+
+ public void setRepository(Repository repository) {
+ this.repository = repository;
+ }
+
+ public Property getPropertyForKey(String key) {
+ for (Property property : getRepository().getPropertyArray()) {
+ if (property.getName().equals(key)) {
+ return property;
+ }
+ }
+ return null;
+ }
+
+ public boolean addAlgorithm(Object process) {
+ /** Should not be used anymore (see new signature)
+ * if (!(process instanceof DeployProcessRequest)) {
+ return false;
+ }
+ DeployProcessRequest request = (DeployProcessRequest) process;
+ try {
+ if(containsAlgorithm(request.getProcessID())) {
+ throw new ExceptionReport("Process already exists. Please undeploy before redeploying a Process.",
+ ExceptionReport.NO_APPLICABLE_CODE);
+ }
+ LOGGER.info("Adding process for profile: " + this.getFormat());
+ processManager.deployProcess(request);
+ Property algoProp = getRepository().addNewProperty();
+ algoProp.setName("Algorithm");
+ algoProp.setActive(true);
+ algoProp.setStringValue(request.getProcessID());
+ WPSConfig.getInstance().save();
+ } catch (Exception e) {
+ LOGGER.warn("Could not instantiate algorithm: " + request);
+ e.printStackTrace();
+ return false;
+ }*/
+ return false;
+ }
+
+ public void addAlgorithm(DeployProcessRequest request) throws ExceptionReport {
+ if(containsAlgorithm(request.getProcessID())) {
+ throw new ExceptionReport("Process already exists. Please undeploy before redeploying a Process.",
+ ExceptionReport.NO_APPLICABLE_CODE);
+ }
+ LOGGER.info("Adding process for profile: " + this.getFormat());
+ try {
+ processManager.deployProcess(request);
+ /**
+ * Moved (TODO delete)
+ Property algoProp = getRepository().addNewProperty();
+ algoProp.setName("Algorithm");
+ algoProp.setActive(true);
+ algoProp.setStringValue(request.getProcessID());
+ WPSConfig.getInstance().save();
+ */
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new ExceptionReport("Deployment failed.",
+ ExceptionReport.NO_APPLICABLE_CODE);
+ }
+ return;
+ }
+
+ /**
+ * TODO : check if the remote contains also the process --- return
+ * processManager.containsProcess(processID); Note: for some profile the
+ * backend doesn't support any deploy / undeploy / contains operation ->
+ * done through WPS
+ */
+ public boolean containsAlgorithm(String processID) {
+ try {
+ for (Property property : getRepository().getPropertyArray()) {
+ if (property.getName().equalsIgnoreCase("Algorithm")
+ && property.getActive()) {
+ if (property.getStringValue().equals(processID)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ public IAlgorithm getAlgorithm(String processID,
+ ExecuteRequest executeRequest) {
+ return new DefaultTransactionalAlgorithm(processID);
+
+ }
+ public Collection getDataNames() {
+ LOGGER.info("Get data names...");
+ Collection dataNames= new ArrayList();
+ try {
+ for (Property property : getRepository().getPropertyArray()) {
+ if (property.getName().equalsIgnoreCase("Data")
+ && property.getActive()) {
+ if (!property.getStringValue().isEmpty()) {
+ dataNames.add(property.getStringValue());
+ LOGGER.info(property.getStringValue());
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ return dataNames;
+ }
+ public Collection getAlgorithmNames() {
+ Collection algoNames= new ArrayList();
+ try {
+ for (Property property : getRepository().getPropertyArray()) {
+ if (property.getName().equalsIgnoreCase("Algorithm")
+ && property.getActive()) {
+ if (!property.getStringValue().isEmpty()) {
+ algoNames.add(property.getStringValue());
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ return algoNames;
+ /**
+ * Previous implementation which request backend :
+ * in SSEGRid this is not the case
+ *
+ try {
+
+ return processManager.getAllProcesses();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return new ArrayList();
+ }
+ */
+ }
+
+ public Collection getAlgorithms() {
+ Collection result = new ArrayList();
+ Collection allAlgorithms;
+ try {
+ LOGGER.info("class of processManager:"
+ + processManager.getClass().getName());
+ allAlgorithms = processManager.getAllProcesses();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return new ArrayList();
+ }
+ for (String processID : allAlgorithms) {
+ result.add(new DefaultTransactionalAlgorithm(processID));
+ }
+ return result;
+ }
+
+ public boolean removeAlgorithm(Object process) {
+ LOGGER.info("removeAlgorithm");
+ if (!(process instanceof UndeployProcessRequest)) {
+ LOGGER.info("not instance");
+ return false;
+ }
+ UndeployProcessRequest request = (UndeployProcessRequest) process;
+ try {
+ LOGGER.info("try undeploy");
+ Property[] propArray = getRepository().getPropertyArray();
+ for (int i = 0; i < propArray.length; i++) {
+ LOGGER.info(i);
+ Property algoProp = propArray[i];
+ if (algoProp.getName().equalsIgnoreCase("Algorithm")
+ && algoProp.getActive()) {
+ if (algoProp.getStringValue()
+ .equals(request.getProcessID())) {
+ getRepository().removeProperty(i);
+ WPSConfig.getInstance().save();
+ processDescriptionMap.remove(request.getProcessID());
+ return true;
+ }
+ }
+ }
+ processManager.unDeployProcess(request);
+
+
+ } catch (Exception e) {
+ LOGGER.warn("Could not remove algorithm: " + request);
+ e.printStackTrace();
+ return false;
+ }
+ return false;
+
+ }
+
+ @Override
+ public ProcessDescriptionType getProcessDescription(String processID) {
+ if (!processDescriptionMap.containsKey(processID)) {
+ LOGGER.info("Adding new process description to the map.");
+ processDescriptionMap.put(processID,
+ AbstractTransactionalAlgorithm.getDescription(processID));
+ }
+ return processDescriptionMap.get(processID);
+ }
+
+ public boolean containsData(String dataName) {
+ try {
+ for (Property property : getRepository().getPropertyArray()) {
+ if (property.getName().equalsIgnoreCase("Data")
+ && property.getActive()) {
+ if (property.getStringValue().equals(dataName)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ public DataDescriptionType getDataDescription(String dataName) {
+ LOGGER.info("start");
+ if (!dataDescriptionMap.containsKey(dataName)) {
+ LOGGER.info("Adding new process description to the map.");
+ dataDescriptionMap.put(dataName,
+ AbstractTransactionalData.getDescription(dataName));
+ }
+ return dataDescriptionMap.get(dataName);
+
+ }
+
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/request/CancelRequest.java b/52n-wps-server/src/main/java/org/n52/wps/server/request/CancelRequest.java
index 736d6e00c..3f93659a5 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/request/CancelRequest.java
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/request/CancelRequest.java
@@ -1,169 +1,185 @@
-package org.n52.wps.server.request;
-
-import net.opengis.wps.x100.CancelDocument;
-import net.opengis.wps.x100.ExecuteResponseDocument;
-import net.opengis.wps.x100.GetStatusDocument;
-import net.opengis.wps.x100.StatusType;
-
-import org.apache.commons.collections.map.CaseInsensitiveMap;
-import org.apache.log4j.Logger;
-import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlOptions;
-import org.n52.wps.server.AbstractTransactionalAlgorithm;
-import org.n52.wps.server.ExceptionReport;
-import org.n52.wps.server.handler.WPSTask;
-import org.n52.wps.server.response.CancelResponse;
-import org.n52.wps.server.response.ExecuteResponse;
-import org.n52.wps.server.response.Response;
-import org.n52.wps.server.response.builder.CancelResponseBuilder;
-import org.n52.wps.server.response.builder.GetStatusResponseBuilder;
-import org.w3c.dom.Document;
-
-public class CancelRequest extends Request {
-
- private static Logger LOGGER = Logger.getLogger(CancelRequest.class);
- private CancelDocument cancelDom;
- private CancelResponseBuilder cancelRespBuilder;
- private WPSTask task;
-
- // not implemented yet (HTTP GET)
- public CancelRequest(CaseInsensitiveMap map) throws ExceptionReport {
- super(map);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * Create a Cancel Request based on Document (HTTP Post)
- *
- * @param doc
- * @throws ExceptionReport
- */
- public CancelRequest(Document doc) throws ExceptionReport {
- super(doc);
- try {
- /**
- * XMLBeans option : the underlying xml text buffer is trimmed
- * immediately after parsing a document resulting in a smaller
- * memory footprint.
- */
- XmlOptions option = new XmlOptions();
- option.setLoadTrimTextBuffer();
- this.cancelDom = CancelDocument.Factory.parse(doc, option);
- if (this.cancelDom == null) {
- LOGGER.fatal("CancelDocument is null");
- throw new ExceptionReport("Error while parsing post data",
- ExceptionReport.MISSING_PARAMETER_VALUE);
- }
- } catch (XmlException e) {
- throw new ExceptionReport("Error while parsing post data",
- ExceptionReport.MISSING_PARAMETER_VALUE, e);
- }
- // Validate the request
- if(!this.cancelDom.validate()) {
- throw new ExceptionReport("Cancel request is not valid (according WPS schemas)",ExceptionReport.INVALID_PARAMETER_VALUE);
- }
- // create an initial response
- }
-
- public CancelDocument getCancelDom() {
- return cancelDom;
- }
-
- public void setCancelDom(CancelDocument cancelDom) {
- this.cancelDom = cancelDom;
- }
-
- @Override
- public Object getAttachedResult() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Response call() throws ExceptionReport {
- LOGGER.info("Cancel call()");
- if (getTask() == null) {
- // TODO check if ExecuteResponse document available (failed,
- // cancelled) to be more precised
- LOGGER.info("task doesn't exist");
- throw new ExceptionReport(
- "The process instance identifier is not valid. The taks may have been already cancelled.",
- ExceptionReport.INVALID_TASKID);
- }
- try {
- // If a task is already started, the backend should also
- // cancel the task
- if (getTaskStatus().isSetProcessStarted()) {
- LOGGER.info("Doing Process Cancellation");
- getTask().cancel(true);
- if (getTask().isCancelled()) {
- LOGGER.info("ProcessCancelled Yes");
- }
- LOGGER.info("Process is started --> cancel backend");
- if (getTask().getRequest().getAlgorithm() instanceof AbstractTransactionalAlgorithm) {
- LOGGER.info("Process is started --> cancel backend");
- ((AbstractTransactionalAlgorithm) getTask().getRequest()
- .getAlgorithm()).cancel();
- }
- // then cancel the task (the previous step generated an
- // Exception if a problem occured)
-
- // update database (status file) with new status cancelled
- // TODO replace with ProcessCancelled
- getTaskStatus().unsetProcessStarted();
- getTaskStatus().setProcessCancelled("");
- ExecuteResponse resp = new ExecuteResponse(getTask()
- .getRequest());
- }
- } catch (Exception e) {
- LOGGER.info("Task cannot be cancelled");
- throw new ExceptionReport("The task cannot be cancelled.",
- ExceptionReport.CANCELLATION_FAILED);
- }
- // The CancelResponse is only returned if no exception occurs
- setCancelRespBuilder(new CancelResponseBuilder(this));
- return new CancelResponse(this);
- }
-
- private StatusType getTaskStatus() {
- return getTask().getRequest().getExecuteResponseBuilder().getDoc()
- .getExecuteResponse().getStatus();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.n52.wps.server.request.Request#validate() TODO not implemented
- * yet
- */
- @Override
- public boolean validate() throws ExceptionReport {
- return true;
- }
-
- public void setCancelRespBuilder(CancelResponseBuilder cancelRespBuilder) {
- this.cancelRespBuilder = cancelRespBuilder;
- }
-
- public CancelResponseBuilder getCancelRespBuilder() {
- return cancelRespBuilder;
- }
-
- public Response call(WPSTask task) throws ExceptionReport {
- setTask(task);
- return call();
- }
-
- public void setTask(WPSTask task) {
- this.task = task;
- }
-
- public ExecuteResponseDocument getDoc() {
- return getTask().getRequest().getExecuteResponseBuilder().getDoc();
- }
-
- public WPSTask getTask() {
- return task;
- }
-
-}
+package org.n52.wps.server.request;
+
+import net.opengis.wps.x100.CancelDocument;
+import net.opengis.wps.x100.ExecuteResponseDocument;
+import net.opengis.wps.x100.GetStatusDocument;
+import net.opengis.wps.x100.StatusType;
+
+import org.apache.commons.collections.map.CaseInsensitiveMap;
+import org.apache.log4j.Logger;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlOptions;
+import org.mortbay.log.Log;
+import org.n52.wps.server.AbstractCancellableAlgorithm;
+import org.n52.wps.server.AbstractTransactionalAlgorithm;
+import org.n52.wps.server.ExceptionReport;
+import org.n52.wps.server.handler.WPSTask;
+import org.n52.wps.server.response.CancelResponse;
+import org.n52.wps.server.response.ExecuteResponse;
+import org.n52.wps.server.response.Response;
+import org.n52.wps.server.response.builder.CancelResponseBuilder;
+import org.n52.wps.server.response.builder.GetStatusResponseBuilder;
+import org.w3c.dom.Document;
+
+public class CancelRequest extends Request {
+
+ private static Logger LOGGER = Logger.getLogger(CancelRequest.class);
+ private CancelDocument cancelDom;
+ private CancelResponseBuilder cancelRespBuilder;
+ private WPSTask task;
+
+ // not implemented yet (HTTP GET)
+ public CancelRequest(CaseInsensitiveMap map) throws ExceptionReport {
+ super(map);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * Create a Cancel Request based on Document (HTTP Post)
+ *
+ * @param doc
+ * @throws ExceptionReport
+ */
+ public CancelRequest(Document doc) throws ExceptionReport {
+ super(doc);
+ try {
+ /**
+ * XMLBeans option : the underlying xml text buffer is trimmed
+ * immediately after parsing a document resulting in a smaller
+ * memory footprint.
+ */
+ XmlOptions option = new XmlOptions();
+ option.setLoadTrimTextBuffer();
+ this.cancelDom = CancelDocument.Factory.parse(doc, option);
+ if (this.cancelDom == null) {
+ LOGGER.fatal("CancelDocument is null");
+ throw new ExceptionReport("Error while parsing post data",
+ ExceptionReport.MISSING_PARAMETER_VALUE);
+ }
+ } catch (XmlException e) {
+ throw new ExceptionReport("Error while parsing post data",
+ ExceptionReport.MISSING_PARAMETER_VALUE, e);
+ }
+ // Validate the request
+ if(!this.cancelDom.validate()) {
+ throw new ExceptionReport("Cancel request is not valid (according WPS schemas)",ExceptionReport.INVALID_PARAMETER_VALUE);
+ }
+ // create an initial response
+ }
+
+ public CancelDocument getCancelDom() {
+ return cancelDom;
+ }
+
+ public void setCancelDom(CancelDocument cancelDom) {
+ this.cancelDom = cancelDom;
+ }
+
+ @Override
+ public Object getAttachedResult() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Response call() throws ExceptionReport {
+ LOGGER.info("Cancel call()");
+ if (getTask() == null) {
+ // TODO check if ExecuteResponse document available (failed,
+ // cancelled) to be more precised
+ LOGGER.info("task doesn't exist");
+ throw new ExceptionReport(
+ "The process instance identifier is not valid. The taks may have been already cancelled.",
+ ExceptionReport.INVALID_TASKID);
+ }
+ try {
+ if (getTaskStatus().isSetProcessStarted() || getTaskStatus().isSetProcessAccepted()) {
+ getTask().cancel(true);
+
+ }
+ // If a task is already started, the backend should also
+ // cancel the task
+ if (getTaskStatus().isSetProcessStarted()) {
+ LOGGER.info("Doing Process Cancellation");
+ if (getTask().isCancelled()) {
+ LOGGER.info("ProcessCancelled Yes");
+ }
+ LOGGER.info("Process is started --> cancel backend");
+ if (getTask().getRequest().getAlgorithm() instanceof AbstractTransactionalAlgorithm) {
+ LOGGER.info("Process is started --> cancel backend");
+ ((AbstractTransactionalAlgorithm) getTask().getRequest()
+ .getAlgorithm()).cancel();
+ }
+ if (getTask().getRequest().getAlgorithm() instanceof AbstractCancellableAlgorithm) {
+ LOGGER.info("Process is started --> cancel backend");
+ ((AbstractCancellableAlgorithm) getTask().getRequest()
+ .getAlgorithm()).cancel();
+ }
+ // then cancel the task (the previous step generated an
+ // Exception if a problem occured)
+
+ // update database (status file) with new status cancelled
+ // TODO replace with ProcessCancelled
+ try {
+ getTaskStatus().unsetProcessStarted();
+ }
+ catch(Exception e) {
+ Log.debug(getTaskStatus().toString());
+ }
+ getTaskStatus().setProcessCancelled("");
+ ExecuteResponse resp = new ExecuteResponse(getTask()
+ .getRequest());
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ LOGGER.info("Task cannot be cancelled");
+ throw new ExceptionReport("The task cannot be cancelled.",
+ ExceptionReport.CANCELLATION_FAILED);
+ }
+ // The CancelResponse is only returned if no exception occurs
+ setCancelRespBuilder(new CancelResponseBuilder(this));
+ return new CancelResponse(this);
+ }
+
+ private StatusType getTaskStatus() {
+ return getTask().getRequest().getExecuteResponseBuilder().getDoc()
+ .getExecuteResponse().getStatus();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.n52.wps.server.request.Request#validate() TODO not implemented
+ * yet
+ */
+ @Override
+ public boolean validate() throws ExceptionReport {
+ return true;
+ }
+
+ public void setCancelRespBuilder(CancelResponseBuilder cancelRespBuilder) {
+ this.cancelRespBuilder = cancelRespBuilder;
+ }
+
+ public CancelResponseBuilder getCancelRespBuilder() {
+ return cancelRespBuilder;
+ }
+
+ public Response call(WPSTask task) throws ExceptionReport {
+ setTask(task);
+ return call();
+ }
+
+ public void setTask(WPSTask task) {
+ this.task = task;
+ }
+
+ public ExecuteResponseDocument getDoc() {
+ return getTask().getRequest().getExecuteResponseBuilder().getDoc();
+ }
+
+ public WPSTask getTask() {
+ return task;
+ }
+
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/request/DeployProcessRequest.java b/52n-wps-server/src/main/java/org/n52/wps/server/request/DeployProcessRequest.java
index 9720aa94d..2743963b5 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/request/DeployProcessRequest.java
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/request/DeployProcessRequest.java
@@ -1,226 +1,303 @@
-package org.n52.wps.server.request;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-import net.opengis.wps.x100.DeployProcessDocument;
-import net.opengis.wps.x100.ProcessDescriptionType;
-
-import org.apache.commons.collections.map.CaseInsensitiveMap;
-import org.apache.log4j.Logger;
-import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlOptions;
-import org.n52.wps.PropertyDocument.Property;
-import org.n52.wps.commons.WPSConfig;
-import org.n52.wps.server.AbstractTransactionalAlgorithm;
-import org.n52.wps.server.ExceptionReport;
-import org.n52.wps.server.repository.ITransactionalAlgorithmRepository;
-import org.n52.wps.server.repository.TransactionalRepositoryManager;
-import org.n52.wps.server.request.deploy.DeploymentProfile;
-import org.n52.wps.server.response.DeployProcessResponse;
-import org.n52.wps.server.response.Response;
-import org.n52.wps.server.response.builder.DeployProcessResponseBuilder;
-import org.w3c.dom.Document;
-
-public class DeployProcessRequest extends Request {
-
- private DeployProcessDocument deployProcessDom;
- private static Logger LOGGER = Logger.getLogger(DeployProcessRequest.class);
- private DeployProcessResponseBuilder deployProcessRespBuilder;
- private String processID;
- private String schema;
- private ProcessDescriptionType processDescription;
- private DeploymentProfile deploymentProfile;
- private ITransactionalAlgorithmRepository repositoryManager;
-
- public DeployProcessRequest(CaseInsensitiveMap map) throws ExceptionReport {
- super(map);
- // TODO use optionally for HTTP Get (not supported)
- }
-
- public DeployProcessRequest(Document doc) throws ExceptionReport {
- super(doc);
- /**
- * XMLBeans option : the underlying xml text buffer is trimmed
- * immediately after parsing a document resulting in a smaller memory
- * footprint.
- */
- try {
- XmlOptions option = new XmlOptions();
- option.setLoadTrimTextBuffer();
- // Parse (with XMLBeans generated library) the request
- this.deployProcessDom = DeployProcessDocument.Factory.parse(doc,
- option);
- } catch (XmlException e) {
- throw new ExceptionReport("Error while parsing post data",
- ExceptionReport.MISSING_PARAMETER_VALUE, e);
- }
- if (this.deployProcessDom == null ) {
- LOGGER.fatal("DeployProcessDocument is null");
- throw new ExceptionReport("Error while parsing post data",
- ExceptionReport.MISSING_PARAMETER_VALUE);
- }
- if(!this.deployProcessDom.validate()) {
- throw new ExceptionReport("DeployProcess request is not valid (according WPS schemas)",ExceptionReport.INVALID_PARAMETER_VALUE);
- }
- // TODO Validate the request (semantic compliance)
- // validate();
- // Get useful infos
- processID = getDeployProcessDom().getDeployProcess()
- .getProcessDescription().getIdentifier().getStringValue();
- if (processID == null) {
- throw new ExceptionReport(
- "Error. Could not find process identifier in the process description",
- ExceptionReport.MISSING_PARAMETER_VALUE);
- }
- processDescription = getDeployProcessDom().getDeployProcess()
- .getProcessDescription();
- if(!processDescription.validate()) {
- throw new ExceptionReport("Process Description is not valid according to the schema!",ExceptionReport.INVALID_PARAMETER_VALUE);
- }
- schema = getDeployProcessDom().getDeployProcess()
- .getDeploymentProfile().getSchema().getHref();
- if (schema == null) {
- throw new ExceptionReport(
- "Error. Could not find schema in the deployment profile",
- ExceptionReport.MISSING_PARAMETER_VALUE);
- }
- LOGGER.info("Deploying process ID: " + processID);
- // Parse the specialized part (profile)
- try {
- // Get the DeployementProfile specialized for this profile
- String deployementProfileClass = TransactionalRepositoryManager
- .getDeploymentProfileForSchema(schema);
- LOGGER.info("deployementprofile class:" + deployementProfileClass);
- // Load the DeployementProfile Constructor for parsing the specific
- // profile part
- Constructor> constructor;
- constructor = Class.forName(deployementProfileClass)
- .getConstructor(DeployProcessDocument.class, String.class);
- LOGGER.info("Constructor loaded");
- setDeploymentProfile((DeploymentProfile) constructor.newInstance(
- getDeployProcessDom(), processID));
- LOGGER.info("Deployement Profile Set");
- } catch (NoSuchMethodException e) {
- throw new ExceptionReport("An error has occurred while obtaining "
- + "the deployment profile",
- ExceptionReport.NO_APPLICABLE_CODE, e);
- } catch (ClassNotFoundException e) {
- throw new ExceptionReport("An error has occurred while obtaining "
- + "the deployment profile",
- ExceptionReport.NO_APPLICABLE_CODE, e);
- } catch (InstantiationException e) {
- throw new ExceptionReport("An error has occurred while obtaining "
- + "the deployment profile",
- ExceptionReport.NO_APPLICABLE_CODE, e);
- } catch (IllegalAccessException e) {
- throw new ExceptionReport("An error has occurred while obtaining "
- + "the deployment profile",
- ExceptionReport.NO_APPLICABLE_CODE, e);
- } catch (InvocationTargetException e) {
- throw new ExceptionReport("An error has occurred while obtaining "
- + "the deployment profile",
- ExceptionReport.NO_APPLICABLE_CODE, e);
- }
-
- }
-
- public String getProcessID() {
- return processID;
- }
-
- public void setProcessID(String processID) {
- this.processID = processID;
- }
-
- public DeployProcessDocument getDeployProcessDom() {
- return deployProcessDom;
- }
-
- public void setDeployProcessDom(DeployProcessDocument deployProcessDom) {
- this.deployProcessDom = deployProcessDom;
- }
-
- @Override
- public Object getAttachedResult() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Response call() throws ExceptionReport {
- // stores the Process Description (in WEB-INF)
- // TODO check to enhance with FlatFileDatabase (?)
- LOGGER.info("Starting the deployement...");
- // Get the repository manager (typically the
- // DefaultTransactionalProcessRepository)
- repositoryManager = TransactionalRepositoryManager
- .getMatchingTransactionalRepository(schema);
- LOGGER.info("*************************=========... match");
-
- if (repositoryManager == null) {
- LOGGER.info("*************************=========... not found");
- throw new ExceptionReport("Could not find matching repository",
- ExceptionReport.NO_APPLICABLE_CODE);
-
-
- }
- // Add the algorithm the repository of the specific profile
- repositoryManager.addAlgorithm(this);
- LOGGER.info("*************************=========... addedAlgo");
- // if Deployement Successful then store the process description
- /**
- * TODO I suggest not to use AbstractTransactionalAlgorithm but a
- * ProcessDescriptionManager class instead
- * */
- AbstractTransactionalAlgorithm.setDescription(this.getProcessID(),
- this.getProcessDescription());
- Property algoProp = WPSConfig.getInstance().getRepositoryForFormat(schema).addNewProperty();
- algoProp.setName("Algorithm");
- algoProp.setActive(true);
- algoProp.setStringValue(this.getProcessID());
- WPSConfig.getInstance().save();
- setDeployProcessRespBuilder(new DeployProcessResponseBuilder(this));
- return new DeployProcessResponse(this);
- }
-
- @Override
- public boolean validate() throws ExceptionReport {
- // TODO Auto-generated method stub
- return false;
- }
-
- public void setDeployProcessRespBuilder(
- DeployProcessResponseBuilder deployProcessRespBuilder) {
- this.deployProcessRespBuilder = deployProcessRespBuilder;
- }
-
- public DeployProcessResponseBuilder getDeployProcessRespBuilder() {
- return deployProcessRespBuilder;
- }
-
- public void setDeploymentProfile(DeploymentProfile deploymentProfile) {
- this.deploymentProfile = deploymentProfile;
- }
-
- public DeploymentProfile getDeploymentProfile() {
- return deploymentProfile;
- }
-
- public ProcessDescriptionType getProcessDescription() {
- return processDescription;
- }
-
- public void setProcessDescription(ProcessDescriptionType processDescription) {
- this.processDescription = processDescription;
- }
-
- public String getSchema() {
- return schema;
- }
-
- public void setSchema(String schema) {
- this.schema = schema;
- }
-
-}
+package org.n52.wps.server.request;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.xml.namespace.QName;
+
+import net.opengis.ows.x11.MetadataType;
+import net.opengis.wps.x100.DeployProcessDocument;
+import net.opengis.wps.x100.ProcessDescriptionDocument;
+import net.opengis.wps.x100.ProcessDescriptionType;
+
+import org.apache.commons.collections.map.CaseInsensitiveMap;
+import org.apache.log4j.Logger;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlOptions;
+import org.n52.wps.PropertyDocument.Property;
+import org.n52.wps.commons.WPSConfig;
+import org.n52.wps.server.AbstractTransactionalAlgorithm;
+import org.n52.wps.server.ExceptionReport;
+import org.n52.wps.server.repository.ITransactionalAlgorithmRepository;
+import org.n52.wps.server.repository.TransactionalRepositoryManager;
+import org.n52.wps.server.request.deploy.DeploymentProfile;
+import org.n52.wps.server.response.DeployProcessResponse;
+import org.n52.wps.server.response.Response;
+import org.n52.wps.server.response.builder.DeployProcessResponseBuilder;
+import org.w3c.dom.Document;
+
+import xint.esa.ese.wps.metadata.MetadataDocument;
+
+public class DeployProcessRequest extends Request {
+
+ private DeployProcessDocument deployProcessDom;
+ private static Logger LOGGER = Logger.getLogger(DeployProcessRequest.class);
+ private DeployProcessResponseBuilder deployProcessRespBuilder;
+ private String processID;
+ private String schema;
+ private ProcessDescriptionType processDescription;
+ private DeploymentProfile deploymentProfile;
+ private ITransactionalAlgorithmRepository repositoryManager;
+
+ public static void main(String[] args) {
+ try {
+ File f = new File("D:\\users\\cnl\\project\\ESE\\meetings\\demo\\OozieURLList\\OozieURL-Estimates.xml");
+ ProcessDescriptionDocument docx = ProcessDescriptionDocument.Factory.parse(f);
+ System.out.println(docx.toString());
+ System.out.println(docx.validate());
+
+ f = new File("D:\\users\\cnl\\project\\ESE\\meetings\\demo\\OozieURLList\\DeployProcessRequest.txt");
+
+ DeployProcessDocument doc = DeployProcessDocument.Factory.parse(f);
+ MetadataType test = doc.getDeployProcess().getProcessDescription().getMetadataArray()[0];
+
+ System.out.println("validation is "+doc.validate());
+ System.out.println("validation is "+doc.getDeployProcess().getProcessDescription().getMetadataArray()[0].validate());
+ System.out.println(doc.getDeployProcess().getProcessDescription().getMetadataArray()[0].toString());
+
+ //MetadataDcument doc2 = (MetadataDocument) doc.getDeployProcess().getProcessDescription().getMetadataArray()[0].getAbstractMetaData();
+// QName qname = new javax.xml.namespace.QName("http://ese.esa.int/wps/metadata", "Metadata");
+ // doc2 = (MetadataDocument) doc.getDeployProcess().getProcessDescription().getMetadataArray()[0].getAbstractMetaData().substitute(qname, MetadataDocument.type);
+ // System.out.println(doc2.toString());
+ //DeployProcessDocument doc = DeployProcessDocument.Factory.parse(f);
+ MetadataDocument doc2 = MetadataDocument.Factory.parse(doc.getDeployProcess().getProcessDescription().getMetadataArray()[0].toString());
+ doc.getDeployProcess().getProcessDescription().removeMetadata(0);
+ doc.getDeployProcess().getProcessDescription().addNewMetadata().set(doc2);
+ System.out.println(doc.toString());
+
+ System.out.println("validation is "+doc.validate( ));
+ System.out.println("validation is "+doc2.getMetadata().validate());
+ System.out.println("validation is "+doc2.getMetadata().getResourceEstimates().validate());
+
+ } catch (XmlException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ public DeployProcessRequest(CaseInsensitiveMap map) throws ExceptionReport {
+ super(map);
+ // TODO use optionally for HTTP Get (not supported)
+ }
+
+ public DeployProcessRequest(Document doc) throws ExceptionReport {
+ super(doc);
+ /**
+ * XMLBeans option : the underlying xml text buffer is trimmed
+ * immediately after parsing a document resulting in a smaller memory
+ * footprint.
+ */
+ try {
+ LOGGER.debug("Starting DeployProcessREquest constructor");
+ XmlOptions option = new XmlOptions();
+ option.setLoadTrimTextBuffer();
+ // Parse (with XMLBeans generated library) the request
+ LOGGER.debug("Parsing");
+ this.deployProcessDom = DeployProcessDocument.Factory.parse(doc,
+ option);
+ /**
+ * XMLBeans workaround: xmlbeans does not parse correctly the document when including an abstract element
+ * The workaround rebuild the object as expected
+ */
+ if(this.deployProcessDom.getDeployProcess().getProcessDescription().getMetadataArray() !=null && this.deployProcessDom.getDeployProcess().getProcessDescription().getMetadataArray().length > 0) {
+ MetadataDocument substElement = MetadataDocument.Factory.parse(this.deployProcessDom.getDeployProcess().getProcessDescription().getMetadataArray()[0].toString());
+ this.deployProcessDom.getDeployProcess().getProcessDescription().removeMetadata(0);
+ this.deployProcessDom.getDeployProcess().getProcessDescription().addNewMetadata().set(substElement);
+ }
+
+
+ } catch (XmlException e) {
+ throw new ExceptionReport("Error while parsing post data",
+ ExceptionReport.MISSING_PARAMETER_VALUE, e);
+ }
+ if (this.deployProcessDom == null ) {
+ LOGGER.fatal("DeployProcessDocument is null");
+ throw new ExceptionReport("Error while parsing post data",
+ ExceptionReport.MISSING_PARAMETER_VALUE);
+ }
+ if(!this.deployProcessDom.getDeployProcess().getDeploymentProfile().validate()) {
+ throw new ExceptionReport("DeployProcess request (deployement profile section) is not valid against WPS-G schemas)",ExceptionReport.INVALID_PARAMETER_VALUE);
+ }
+ if(!this.deployProcessDom.getDeployProcess().getProcessDescription().getDataInputs().validate()) {
+ throw new ExceptionReport("DeployProcess request (data inputs section) is not valid against WPS-G schemas)",ExceptionReport.INVALID_PARAMETER_VALUE);
+ }
+ if(!this.deployProcessDom.getDeployProcess().getProcessDescription().getProcessOutputs().validate()) {
+ throw new ExceptionReport("DeployProcess request is not valid against WPS-G schemas)",ExceptionReport.INVALID_PARAMETER_VALUE);
+ }
+ if(this.deployProcessDom.getDeployProcess().getProcessDescription().getMetadataArray()!=null && this.deployProcessDom.getDeployProcess().getProcessDescription().getMetadataArray().length > 0) {
+ try {
+ MetadataDocument doc2 = MetadataDocument.Factory.parse(this.deployProcessDom.getDeployProcess().getProcessDescription().getMetadataArray()[0].toString());
+ if(!doc2.validate()) {
+ throw new ExceptionReport("DeployProcess request (in Metadata section) is not valid against WPS-G schemas)",ExceptionReport.INVALID_PARAMETER_VALUE);
+ }
+ } catch (XmlException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ // TODO Validate the request (semantic compliance)
+ // validate();
+ // Get useful infos
+ processID = getDeployProcessDom().getDeployProcess()
+ .getProcessDescription().getIdentifier().getStringValue();
+ if (processID == null) {
+ throw new ExceptionReport(
+ "Error. Could not find process identifier in the process description",
+ ExceptionReport.MISSING_PARAMETER_VALUE);
+ }
+ processDescription = getDeployProcessDom().getDeployProcess()
+ .getProcessDescription();
+
+ schema = getDeployProcessDom().getDeployProcess()
+ .getDeploymentProfile().getSchema().getHref();
+ if (schema == null) {
+ throw new ExceptionReport(
+ "Error. Could not find schema in the deployment profile",
+ ExceptionReport.MISSING_PARAMETER_VALUE);
+ }
+ LOGGER.info("Deploying process ID: " + processID);
+ // Parse the specialized part (profile)
+ try {
+ // Get the DeployementProfile specialized for this profile
+ String deployementProfileClass = TransactionalRepositoryManager
+ .getDeploymentProfileForSchema(schema);
+ LOGGER.info("deployementprofile class:" + deployementProfileClass);
+ // Load the DeployementProfile Constructor for parsing the specific
+ // profile part
+ Constructor> constructor;
+ constructor = Class.forName(deployementProfileClass)
+ .getConstructor(DeployProcessDocument.class, String.class);
+ LOGGER.info("Constructor loaded");
+ setDeploymentProfile((DeploymentProfile) constructor.newInstance(
+ getDeployProcessDom(), processID));
+ LOGGER.info("Deployement Profile Set");
+ } catch (NoSuchMethodException e) {
+ throw new ExceptionReport("An error has occurred while obtaining "
+ + "the deployment profile",
+ ExceptionReport.NO_APPLICABLE_CODE, e);
+ } catch (ClassNotFoundException e) {
+ throw new ExceptionReport("An error has occurred while obtaining "
+ + "the deployment profile",
+ ExceptionReport.NO_APPLICABLE_CODE, e);
+ } catch (InstantiationException e) {
+ throw new ExceptionReport("An error has occurred while obtaining "
+ + "the deployment profile",
+ ExceptionReport.NO_APPLICABLE_CODE, e);
+ } catch (IllegalAccessException e) {
+ throw new ExceptionReport("An error has occurred while obtaining "
+ + "the deployment profile",
+ ExceptionReport.NO_APPLICABLE_CODE, e);
+ } catch (InvocationTargetException e) {
+ throw new ExceptionReport("An error has occurred while obtaining "
+ + "the deployment profile",
+ ExceptionReport.NO_APPLICABLE_CODE, e);
+ }
+
+ }
+
+ public String getProcessID() {
+ return processID;
+ }
+
+ public void setProcessID(String processID) {
+ this.processID = processID;
+ }
+
+ public DeployProcessDocument getDeployProcessDom() {
+ return deployProcessDom;
+ }
+
+ public void setDeployProcessDom(DeployProcessDocument deployProcessDom) {
+ this.deployProcessDom = deployProcessDom;
+ }
+
+ @Override
+ public Object getAttachedResult() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Response call() throws ExceptionReport {
+ // stores the Process Description (in WEB-INF)
+ // TODO check to enhance with FlatFileDatabase (?)
+ LOGGER.info("Starting the deployement...");
+ // Get the repository manager (typically the
+ // DefaultTransactionalProcessRepository)
+ repositoryManager = TransactionalRepositoryManager
+ .getMatchingTransactionalRepository(schema);
+ LOGGER.info("*************************=========... match");
+
+ if (repositoryManager == null) {
+ LOGGER.info("*************************=========... not found");
+ throw new ExceptionReport("Could not find matching repository",
+ ExceptionReport.NO_APPLICABLE_CODE);
+
+
+ }
+ // Add the algorithm the repository of the specific profile
+ repositoryManager.addAlgorithm(this);
+ LOGGER.info("*************************=========... addedAlgo");
+ // if Deployement Successful then store the process description
+ /**
+ * TODO I suggest not to use AbstractTransactionalAlgorithm but a
+ * ProcessDescriptionManager class instead
+ * */
+ AbstractTransactionalAlgorithm.setDescription(this.getProcessID(),
+ this.getProcessDescription());
+ Property algoProp = WPSConfig.getInstance().getRepositoryForFormat(schema).addNewProperty();
+ algoProp.setName("Algorithm");
+ algoProp.setActive(true);
+ algoProp.setStringValue(this.getProcessID());
+ WPSConfig.getInstance().save();
+ setDeployProcessRespBuilder(new DeployProcessResponseBuilder(this));
+ return new DeployProcessResponse(this);
+ }
+
+ @Override
+ public boolean validate() throws ExceptionReport {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void setDeployProcessRespBuilder(
+ DeployProcessResponseBuilder deployProcessRespBuilder) {
+ this.deployProcessRespBuilder = deployProcessRespBuilder;
+ }
+
+ public DeployProcessResponseBuilder getDeployProcessRespBuilder() {
+ return deployProcessRespBuilder;
+ }
+
+ public void setDeploymentProfile(DeploymentProfile deploymentProfile) {
+ this.deploymentProfile = deploymentProfile;
+ }
+
+ public DeploymentProfile getDeploymentProfile() {
+ return deploymentProfile;
+ }
+
+ public ProcessDescriptionType getProcessDescription() {
+ return processDescription;
+ }
+
+ public void setProcessDescription(ProcessDescriptionType processDescription) {
+ this.processDescription = processDescription;
+ }
+
+ public String getSchema() {
+ return schema;
+ }
+
+ public void setSchema(String schema) {
+ this.schema = schema;
+ }
+
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/request/ExecuteRequest.java b/52n-wps-server/src/main/java/org/n52/wps/server/request/ExecuteRequest.java
index d04b16218..58555bf4e 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/request/ExecuteRequest.java
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/request/ExecuteRequest.java
@@ -68,6 +68,7 @@
import org.n52.wps.commons.context.ExecutionContext;
import org.n52.wps.commons.context.ExecutionContextFactory;
import org.n52.wps.io.data.IData;
+import org.n52.wps.server.AbstractCancellableAlgorithm;
import org.n52.wps.server.AbstractTransactionalAlgorithm;
import org.n52.wps.server.ExceptionReport;
import org.n52.wps.server.IAlgorithm;
@@ -126,8 +127,8 @@ public ExecuteRequest(Document inputDoc, SOAPHeader mySOAPHeader)
MessageContext context = MessageContext.getCurrentMessageContext();
if (context != null) {
ServiceContext serviceContext = context.getServiceContext();
- String address = serviceContext.getMyEPR().getAddress();
- setMyEPR(address);
+ //String address = serviceContext.getMyEPR(arg0)getMyEPR().getAddress();
+ //setMyEPR(address);
}
}
@@ -187,6 +188,7 @@ public ExecuteRequest(Document doc) throws ExceptionReport {
*/
public ExecuteRequest(CaseInsensitiveMap ciMap) throws ExceptionReport {
super(ciMap);
+ getUniqueId();
initForGET(ciMap);
// validate the client input
validate();
@@ -523,7 +525,9 @@ public boolean validate() throws ExceptionReport {
}
}
}
- // For each input supplied by the client
+ // For each input supplied by the client;
+ if(getExecute().getDataInputs()==null)
+ return true;
for (InputType input : getExecute().getDataInputs().getInputArray()) {
boolean identifierMatched = false;
// Try to match the input with one of the descriptions
@@ -621,6 +625,7 @@ public Response call() throws ExceptionReport {
// register so that any function that calls
// ExecuteContextFactory.getContext() gets the instance registered
// with this thread
+ LOGGER.debug("Registered Execution Context with Id:"+getId());
ExecutionContext context = new ExecutionContext(getId());
ExecutionContextFactory.registerContext(context);
@@ -630,9 +635,7 @@ public Response call() throws ExceptionReport {
if (getExecute().getDataInputs() != null) {
inputs = getExecute().getDataInputs().getInputArray();
}
- // The input handler parses (and validates) the inputs.
- InputHandler parser = new InputHandler(inputs,
- getAlgorithmIdentifier());
+
// TODO (Spacebel) OutputHandler for validation
// we got so far:
// get the algorithm, and run it with the clients input
@@ -646,7 +649,13 @@ public Response call() throws ExceptionReport {
*/
algorithm = RepositoryManager.getInstance().getAlgorithm(
getAlgorithmIdentifier(), this);
-
+
+ if(algorithm == null) {
+ LOGGER.error("Algorithm is null - unexpected");
+ throw new ExceptionReport("Impossible to instantiate algorithm : " + getAlgorithmIdentifier(), ExceptionReport.NO_APPLICABLE_CODE);
+
+ }
+
if (algorithm instanceof ISubject) {
ISubject subject = (ISubject) algorithm;
subject.addObserver(this);
@@ -654,9 +663,11 @@ public Response call() throws ExceptionReport {
}
if (algorithm instanceof AbstractTransactionalAlgorithm) {
+ LOGGER.info("running the script");
returnResults = ((AbstractTransactionalAlgorithm) algorithm)
.run(this);
- LOGGER.info("Storing audit...");
+
+ LOGGER.info("Ends run - Storing audit...");
try {
AbstractTransactionalAlgorithm.storeAuditLongDocument(this
.getUniqueId().toString(),
@@ -668,6 +679,7 @@ public Response call() throws ExceptionReport {
.getAudit());
}
catch(Exception e) {
+ e.printStackTrace();
LOGGER.warn("Cannot store audit after process run !");
}
}
@@ -692,6 +704,12 @@ public Response call() throws ExceptionReport {
&& !(algorithm instanceof AbstractTransactionalAlgorithm)) {
// TODO maybe this method signature should disappear
// (getParsedInputData can be called later)
+ if(algorithm instanceof AbstractCancellableAlgorithm) {
+ ((AbstractCancellableAlgorithm)algorithm).setInstanceId(this.getId());
+ }
+ // The input handler parses (and validates) the inputs.
+ InputHandler parser = new InputHandler(inputs,
+ getAlgorithmIdentifier());
returnResults = algorithm.run(parser.getParsedInputData());
}
/**
@@ -706,9 +724,13 @@ public Response call() throws ExceptionReport {
}
} catch (CancellationException e) {
+ LOGGER.info("catch cancelllation exception");
return null;
+
} catch (Exception e) {
- if(!(algorithm instanceof AbstractTransactionalAlgorithm)) {
+ LOGGER.info("catch exception");
+ e.printStackTrace();
+ if(!(algorithm instanceof AbstractTransactionalAlgorithm) && !(algorithm instanceof AbstractCancellableAlgorithm)) {
LOGGER.debug("RuntimeException:" + e.getMessage());
StatusType statusFailed = StatusType.Factory.newInstance();
statusFailed.addNewProcessFailed();
@@ -727,7 +749,7 @@ public Response call() throws ExceptionReport {
ExceptionReport.NO_APPLICABLE_CODE, e);
}
try {
- LOGGER.info("Storing audit...");
+ LOGGER.info("Storing audit (exception case)...");
AbstractTransactionalAlgorithm.storeAuditLongDocument(this
.getUniqueId().toString(),
((AbstractTransactionalAlgorithm) algorithm)
@@ -736,6 +758,7 @@ public Response call() throws ExceptionReport {
.storeAuditDocument(this.getUniqueId().toString(),
((AbstractTransactionalAlgorithm) algorithm)
.getAudit());
+ LOGGER.info("Audit stored");
} catch (Exception e1) {
// TODO Auto-generated catch block
LOGGER.info("Audit storing failed");
@@ -743,6 +766,7 @@ public Response call() throws ExceptionReport {
}
// send callback with exception
if (addressingHeader != null) {
+ LOGGER.info("found addressing header");
try {
StatusType status = StatusType.Factory.newInstance();
status.addNewProcessFailed().setExceptionReport(
@@ -758,6 +782,9 @@ public Response call() throws ExceptionReport {
e2.printStackTrace();
}
}
+ else {
+ LOGGER.info("header not found");
+ }
throw exReport;
} finally {
// you ***MUST*** call this or else you will have a PermGen
@@ -807,6 +834,26 @@ public Response call() throws ExceptionReport {
}
+ public ArrayList getQOSHeaderBlocks() {
+ LOGGER.info("Addressing header");
+ // TODO Auto-generated method stub
+ if (this.soapHeader == null) {
+ LOGGER.info("soap Header is null");
+ return null;
+ }
+ try {
+ ArrayList headerBlocks = this.soapHeader
+ .getHeaderBlocksWithNSURI("http://ese.esa.int/wps/qos");
+ LOGGER.info(headerBlocks.toString());
+ // sendCallback(headerBlocks);
+ return headerBlocks;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+
private ArrayList getSAMLHeaderBlocks() {
LOGGER.info("Addressing header");
// TODO Auto-generated method stub
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/request/InputHandler.java b/52n-wps-server/src/main/java/org/n52/wps/server/request/InputHandler.java
index 28380ce86..de25671fb 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/request/InputHandler.java
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/request/InputHandler.java
@@ -58,6 +58,7 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+import net.opengis.ows.x11.BoundingBoxType;
import net.opengis.ows.x11.DomainMetadataType;
import net.opengis.wps.x100.InputDescriptionType;
import net.opengis.wps.x100.InputType;
@@ -67,6 +68,7 @@
import org.n52.wps.io.IParser;
import org.n52.wps.io.ParserFactory;
import org.n52.wps.io.data.IData;
+import org.n52.wps.io.data.SimpleBBoxBinding;
import org.n52.wps.io.datahandler.xml.AbstractXMLParser;
import org.n52.wps.io.datahandler.xml.GML2BasicParser;
import org.n52.wps.io.datahandler.xml.GML3BasicParser;
@@ -417,7 +419,13 @@ protected void handleComplexValueReference(InputType input) throws ExceptionRepo
*/
protected void handleBBoxValue(InputType input) throws ExceptionReport{
//String inputID = input.getIdentifier().getStringValue();
- throw new ExceptionReport("BBox is not supported", ExceptionReport.OPERATION_NOT_SUPPORTED);
+ String inputID = input.getIdentifier().getStringValue();
+ BoundingBoxType bbox = input.getData().getBoundingBoxData();
+
+ List list = new ArrayList();
+ list.add(new SimpleBBoxBinding(bbox));
+ inputData.put(inputID, list);
+
}
/**
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/request/deploy/DeploymentProfile.java b/52n-wps-server/src/main/java/org/n52/wps/server/request/deploy/DeploymentProfile.java
index 67cecd488..8d5789dd0 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/request/deploy/DeploymentProfile.java
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/request/deploy/DeploymentProfile.java
@@ -1,84 +1,187 @@
-/***************************************************************
- This implementation provides a framework to publish processes to the
-web through the OGC Web Processing Service interface. The framework
-is extensible in terms of processes and data handlers.
-
- Copyright (C) 2006 by con terra GmbH
-
- Authors:
- Bastian Schaeffer, Institute for Geoinformatics, Muenster, Germany
-
- Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
- 48155 Muenster, Germany, 52n@conterra.de
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program (see gnu-gpl v2.txt); if not, write to
- the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA or visit the web page of the Free
- Software Foundation, http://www.fsf.org.
-
- ***************************************************************/
-
-
-package org.n52.wps.server.request.deploy;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import net.opengis.wps.x100.DeployDataDocument;
-import net.opengis.wps.x100.DeployProcessDocument;
-
-import org.n52.wps.server.repository.TransactionalRepositoryManager;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-public abstract class DeploymentProfile {
-
- private Object payload;
- private String processID;
-
- public DeploymentProfile(DeployProcessDocument deployDom, String processID){
- this.processID = processID;
- this.payload = payload;
-
- }
- public DeploymentProfile(DeployDataDocument deployDom, String processID){
- this.processID = processID;
- this.payload = payload;
-
- }
-
- public String getProcessID() {
- return processID;
- }
-
- public Object getPayload() {
- return payload;
- }
-
-
-
-}
+/***************************************************************
+ This implementation provides a framework to publish processes to the
+web through the OGC Web Processing Service interface. The framework
+is extensible in terms of processes and data handlers.
+
+ Copyright (C) 2006 by con terra GmbH
+
+ Authors:
+ Bastian Schaeffer, Institute for Geoinformatics, Muenster, Germany
+
+ Contact: Albert Remke, con terra GmbH, Martin-Luther-King-Weg 24,
+ 48155 Muenster, Germany, 52n@conterra.de
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program (see gnu-gpl v2.txt); if not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA or visit the web page of the Free
+ Software Foundation, http://www.fsf.org.
+
+ ***************************************************************/
+
+package org.n52.wps.server.request.deploy;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.net.URLConnection;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import net.opengis.wps.x100.DeployDataDocument;
+import net.opengis.wps.x100.DeployProcessDocument;
+
+import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPReply;
+import org.apache.log4j.Logger;
+import org.n52.wps.PropertyDocument.Property;
+import org.n52.wps.commons.WPSConfig;
+import org.n52.wps.server.profiles.oozie.OozieDeploymentProfile;
+import org.n52.wps.server.repository.TransactionalRepositoryManager;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+public abstract class DeploymentProfile {
+
+ private static Logger LOGGER = Logger
+ .getLogger(OozieDeploymentProfile.class);
+
+ private Object payload;
+ private String processID;
+
+ public DeploymentProfile(DeployProcessDocument deployDom, String processID) {
+ this.processID = processID;
+ this.payload = payload;
+
+ }
+
+ public DeploymentProfile(DeployDataDocument deployDom, String processID) {
+ this.processID = processID;
+ this.payload = payload;
+
+ }
+
+ public String getProcessID() {
+ return processID;
+ }
+
+ public Object getPayload() {
+ return payload;
+ }
+
+ protected byte[] downloadHTTP(String url) throws Exception {
+ URL u = new URL(url);
+ URLConnection uc = u.openConnection();
+ String contentType = uc.getContentType();
+ int contentLength = uc.getContentLength();
+ InputStream raw = uc.getInputStream();
+ InputStream in = new BufferedInputStream(raw);
+ byte[] data = new byte[contentLength];
+ int bytesRead = 0;
+ int offset = 0;
+ LOGGER.info("loading started...");
+ while (offset < contentLength) {
+ System.out.print(".");
+ bytesRead = in.read(data, offset, data.length - offset);
+ if (bytesRead == -1)
+ break;
+ offset += bytesRead;
+ }
+ in.close();
+ if (offset != contentLength) {
+ throw new IOException("Only read " + offset + " bytes; Expected "
+ + contentLength + " bytes");
+ }
+ return data;
+ }
+
+ /**
+ * This method download a binary file located at the given URL and returns
+ * the byte array TODO move to an util class
+ *
+ * @param archiveRef2
+ * @return
+ * @throws IOException
+ */
+ protected byte[] downloadArchive(String url) throws IOException {
+ LOGGER.info("Downloading url " + url);
+ URL u = new URL(url);
+ if (StringUtils.startsWithIgnoreCase(url, "http://")
+ || StringUtils.startsWithIgnoreCase(url, "https://")) {
+ LOGGER.info("HTTP protocol");
+ byte[] data = null;
+ try {
+ data = downloadHTTP(url);
+ } catch (Exception e) {
+ LOGGER.info(e.getMessage());
+ LOGGER.info(e.getStackTrace().toString());
+ e.printStackTrace();
+ }
+ return data;
+ } else if (StringUtils.startsWithIgnoreCase(url, "ftp://")) {
+ LOGGER.info("FTP protocol");
+ byte[] data = null;
+ try {
+ data = downloadFTP(url);
+ } catch (Exception e) {
+ LOGGER.info(e.getMessage());
+ LOGGER.info(e.getStackTrace().toString());
+ e.printStackTrace();
+ }
+ return data;
+ }
+ return null;
+ }
+
+ private byte[] downloadFTP(String url) throws Exception {
+ URL u = new URL(url);
+ FTPClient client = new FTPClient();
+ ByteArrayOutputStream fos = null;
+ client.connect(u.getHost(), u.getPort());
+ // hardcoded
+ Property[] properties = WPSConfig.getInstance()
+ .getPropertiesForServer();
+ Property ftpUserProp = WPSConfig.getInstance().getPropertyForKey(
+ properties, "portalFTPUser");
+ Property ftpPassProp = WPSConfig.getInstance().getPropertyForKey(
+ properties, "portalFTPPassword");
+ client.login(ftpUserProp.getStringValue(), ftpPassProp.getStringValue());
+ int reply = client.getReplyCode();
+ if (!FTPReply.isPositiveCompletion(reply)) {
+ client.disconnect();
+ }
+ String filename = u.getFile();
+ fos = new ByteArrayOutputStream();
+ client.retrieveFile(filename, fos);
+ byte[] data = fos.toByteArray();
+ fos.close();
+ client.disconnect();
+ return data;
+ }
+
+}
diff --git a/52n-wps-server/src/main/java/org/n52/wps/server/response/ExecuteResponse.java b/52n-wps-server/src/main/java/org/n52/wps/server/response/ExecuteResponse.java
index 5849a9f6f..556bbacbf 100644
--- a/52n-wps-server/src/main/java/org/n52/wps/server/response/ExecuteResponse.java
+++ b/52n-wps-server/src/main/java/org/n52/wps/server/response/ExecuteResponse.java
@@ -148,7 +148,11 @@ public void sendCallback(ArrayList