corrections in WPS output

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngineWPSExtension@97127 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Gianpaolo Coro 2014-06-09 11:39:30 +00:00
parent 1223b5ddb9
commit aeaef90e6b
3 changed files with 68 additions and 42 deletions

View File

@ -120,18 +120,18 @@ public class WPSClient {
public void describeProcess(String processID, URL processDescriptionURL) throws Exception {
WPSClientSession wpsClient = WPSClientSession.getInstance();
try {
AnalysisLogger.getLogger().debug("Describe Process WPS URL: "+wpsServiceURL);
AnalysisLogger.getLogger().debug("Describe Process WPS URL: " + wpsServiceURL);
ProcessDescriptionType processDescription = null;
for (int k=0;k<=3;k++){
try{
for (int k = 0; k <= 3; k++) {
try {
processDescription = wpsClient.getProcessDescription(wpsServiceURL, processID);
}catch(Exception e){
AnalysisLogger.getLogger().debug("Retrying with WPS URL: "+wpsServiceURL);
if (k==3)
} catch (Exception e) {
AnalysisLogger.getLogger().debug("Retrying with WPS URL: " + wpsServiceURL);
if (k == 3)
throw e;
}
if (processDescription!=null)
break;
if (processDescription != null)
break;
}
this.currentProcessDescription = processDescription;
// processDescription.set(XmlString.Factory.parse(new URL("http://schemas.opengis.net/wps/1.0.0/examples/40_wpsDescribeProcess_response.xml")));
@ -230,9 +230,8 @@ public class WPSClient {
executeBuilder.setMimeTypeForOutput("text/xml", odt.getIdentifier().getStringValue());
}
} catch (Exception e) {
e.printStackTrace();
AnalysisLogger.getLogger().debug("Execute Process-> Warning, no xml structured objects will be provided");
AnalysisLogger.getLogger().debug(e);
AnalysisLogger.getLogger().debug("Execute Process-> Warning, no xml structured objects will be provided: " + e.getLocalizedMessage());
}
// executeBuilder.setSchemaForOutput("http://schemas.opengis.net/gml/3.1.1/base/feature.xsd", "result");
@ -294,11 +293,10 @@ public class WPSClient {
}
Thread.sleep(2000);
if (statusLocation!=null && statusLocation.length()>0)
if (statusLocation != null && statusLocation.length() > 0)
responseObject = wpsClient.executeViaGET(statusLocation, "");
else
if (wpsstatus!=100)
throw new Exception("Cannot retrieve process status");
else if (wpsstatus != 100)
throw new Exception("Cannot retrieve process status");
// AnalysisLogger.getLogger().debug("ResponseOBJ:\n" + responseObject);
} else
@ -310,30 +308,14 @@ public class WPSClient {
wpsstatus = 100f;
return ((ExecuteResponseDocument) responseObject).getExecuteResponse().getProcessOutputs();
} catch (Exception e) {
e.printStackTrace();
AnalysisLogger.getLogger().debug(e);
AnalysisLogger.getLogger().debug("WPSClient->Caught a WPS exception: " + e.getLocalizedMessage() + " Returning the exception");
throw e;
} finally {
wpsClient.disconnect(wpsServiceURL);
}
}
public static void main(String[] args) throws Exception {
AnalysisLogger.setLogger("./cfg/ALog.properties");
// WPSClient client = new WPSClient("http://wps01.i-marine.d4science.org/wps/WebProcessingService");
WPSClient client = new WPSClient("http://geoprocessing.demo.52north.org:8080/wps/WebProcessingService");
client.requestGetCapabilities();
// client.describeProcess("com.terradue.wps_hadoop.processes.examples.async.Async", new URL("file:///C:/Users/coro/Desktop/WorkFolder/Workspace/EcologicalEngineWPSExtension/cfg/test.xml"));
// client.describeProcess("org.n52.wps.extension.GetFuelPriceProcess");
// client.describeProcess("org.n52.wps.server.algorithm.test.DummyTestClass");
// client.describeProcess("org.n52.wps.server.algorithm.coordinatetransform.CoordinateTransformAlgorithm");
// client.describeProcess("org.n52.wps.extension.GetFuelPriceProcess");
// client.describeProcess("com.terradue.wps_hadoop.processes.examples.async.Async");
client.describeProcess("org.n52.wps.server.algorithm.SimpleBufferAlgorithm");
}
public static int calculateBBDimensions(String bbstring) {
String[] bbinput = bbstring.split(",");
int dimcounter = 0;
@ -387,6 +369,26 @@ public class WPSClient {
return urls;
}
public static String getExceptionText(String exceptionText) {
try {
String excText = "ExceptionText>";
int idx = exceptionText.indexOf(excText);
if (idx >= 0) {
String exception = exceptionText.substring(idx + excText.length());
exception = exception.substring(0, exception.indexOf("</"));
exception = exception.replace("<", "").replace(">", "").replace("/", " ").replace("\\", " ").replaceAll("[\\]\\[!\"#$%&'\\(\\)*+/:;<=>?@\\^_`{\\|}~-]", "_").trim();
exception = exception.replaceAll("[ ]+"," ");
if (exception.length()>200)
exception = exception.substring(0, 200)+"...";
return exception;
} else
return "Process error in WPS Execution";
} catch (Exception e) {
e.printStackTrace();
return "Backend error in WPS Execution";
}
}
private static List<String> getURLFromXML(org.w3c.dom.Node node) {
List<String> urls = new ArrayList<String>();
@ -398,9 +400,9 @@ public class WPSClient {
if (nChildren == 0) {
String text = node.getNodeValue();
if (text!= null && (text.startsWith("https:") || text.startsWith("http:") || text.startsWith("ftp:") || text.startsWith("smp:") || text.startsWith("file:")))
if (text != null && (text.startsWith("https:") || text.startsWith("http:") || text.startsWith("ftp:") || text.startsWith("smp:") || text.startsWith("file:")))
urls.add(text.trim());
else if (text!= null && text.trim().length()>0)
else if (text != null && text.trim().length() > 0)
urls.add(text.trim());
} else {
for (int i = 0; i < nChildren; i++) {
@ -411,4 +413,25 @@ public class WPSClient {
}
return urls;
}
public static void main1(String[] args) throws Exception {
AnalysisLogger.setLogger("./cfg/ALog.properties");
// WPSClient client = new WPSClient("http://wps01.i-marine.d4science.org/wps/WebProcessingService");
WPSClient client = new WPSClient("http://geoprocessing.demo.52north.org:8080/wps/WebProcessingService");
client.requestGetCapabilities();
// client.describeProcess("com.terradue.wps_hadoop.processes.examples.async.Async", new URL("file:///C:/Users/coro/Desktop/WorkFolder/Workspace/EcologicalEngineWPSExtension/cfg/test.xml"));
// client.describeProcess("org.n52.wps.extension.GetFuelPriceProcess");
// client.describeProcess("org.n52.wps.server.algorithm.test.DummyTestClass");
// client.describeProcess("org.n52.wps.server.algorithm.coordinatetransform.CoordinateTransformAlgorithm");
// client.describeProcess("org.n52.wps.extension.GetFuelPriceProcess");
// client.describeProcess("com.terradue.wps_hadoop.processes.examples.async.Async");
client.describeProcess("org.n52.wps.server.algorithm.SimpleBufferAlgorithm");
}
public static void main(String[] args) {
String exception = "<xml-fragment xmlns:ns1=\"http://www.opengis.net/ows/1.1\" xmlns:ns=\"http://www.opengis.net/wps/1.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"> <ns1:Exception> <ns1:ExceptionText>org.n52.wps.server.ExceptionReport: Statistical Manager Computation Failed:java.io.FileNotFoundException: /home/gcube2/gCore/etc/statistical-manager-service-full-1.4.0-SNAPSHOT/cfg/PARALLEL_PROCESSING/matcherOutput0e2f68f72b5e48f7a39dfc5bf999c168.csv (No such file or directory)</ns1:ExceptionText> </ns1:Exception>";
System.out.println(getExceptionText(exception));
}
}

View File

@ -91,6 +91,7 @@ public class WPSProcess implements Transducerer {
currentProcess=client;
AnalysisLogger.getLogger().debug("Starting Process");
ProcessOutputs outs = client.executeProcess(executeBuilder, processDescription);
AnalysisLogger.getLogger().debug("Process Executed");
// retrieve the output objs
if (outs == null)
throw new Exception("Error during the execution of the WPS process: returned an empty document");
@ -138,8 +139,9 @@ public class WPSProcess implements Transducerer {
}
} catch (Exception e) {
e.printStackTrace();
throw e;
String exceptiontext = WPSClient.getExceptionText(e.getLocalizedMessage());
AnalysisLogger.getLogger().debug("WPSProcess->Returning Exception to the SM:" + exceptiontext);
throw new Exception(exceptiontext);
} finally {
status = 100;
}

View File

@ -11,8 +11,9 @@ public class TestWPSProcessStatistical {
static String[] algorithms = { "org.gcube.dataanalysis.statistical_manager_wps_algorithms.generated.Bionym_local"};
static String wps = "http://146.48.87.227:8080/wps/WebProcessingService";
// static String wps = "http://146.48.87.227:8080/wps/WebProcessingService";
static String wps = "http://wps.statistical.d4science.org/wps/WebProcessingService";
static AlgorithmConfiguration[] configs = { testBionymLocal()};
public static void main(String[] args) throws Exception {
@ -37,7 +38,7 @@ public class TestWPSProcessStatistical {
// dataInputs=geoColumn=field0;quantityColumn=field4;sourceAreaLayerName=FAO_AREAS;targetAreaLayerName=EEZ_HIGHSEAS;dataUrls=https://dl.dropboxusercontent.com/u/24368142/timeseries_100.json;&ResponseDocument=result
AlgorithmConfiguration config = Regressor.getConfig();
config.setParam("username", "gadus.morhua");
config.setParam("username", "captain.buccaneer");
config.setParam("SpeciesAuthorName", "Gadus morhua (Linnaeus, 1758)");
config.setParam("Taxa_Authority_File", "FISHBASE");
config.setParam("Parser_Name", "SIMPLE");
@ -45,9 +46,9 @@ public class TestWPSProcessStatistical {
config.setParam("Use_Stemmed_Genus_and_Species", "false");
config.setParam("Accuracy_vs_Speed", "false");
config.setParam("Matcher_1", "LEVENSHTEIN");
config.setParam("Threshold_1", "0.6");
config.setParam("Threshold_1", "0.7");
config.setParam("MaxResults_1", "10");
return config;
}
}
}