Updated client library for netcdf files

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/data-miner-manager-cl@167296 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2018-05-03 12:43:24 +00:00
parent 70006d0a38
commit f65236e7ba
15 changed files with 168 additions and 87 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/data-miner-manager-cl-1.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/data-miner-manager-cl-1.4.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/data-miner-manager-cl-1.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<classpathentry excluding="**" kind="src" output="target/data-miner-manager-cl-1.4.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -28,10 +28,10 @@
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="owner.project.facets" value="java"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/data-miner-manager-cl-1.3.0-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/data-miner-manager-cl-1.4.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -1,8 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
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.8
org.eclipse.jdt.core.compiler.source=1.7

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="jst.utility" version="1.0"/>
<installed facet="java" version="1.8"/>
<installed facet="java" version="1.7"/>
</faceted-project>

View File

@ -1,4 +1,8 @@
<ReleaseNotes>
<Changeset component="org.gcube.data.analysis.data-miner-manager-cl.1-4-0"
date="2018-04-03">
<Change>Updated to support netcdf files</Change>
</Changeset>
<Changeset component="org.gcube.data.analysis.data-miner-manager-cl.1-3-0"
date="2017-06-12">
<Change>Support Java 8 compatibility [ticket #8471]</Change>

View File

@ -11,7 +11,7 @@
<groupId>org.gcube.data.analysis</groupId>
<artifactId>data-miner-manager-cl</artifactId>
<version>1.3.0-SNAPSHOT</version>
<version>1.4.0-SNAPSHOT</version>
<name>data-miner-manager-cl</name>
<description>DataMiner Manager Client Library</description>

View File

@ -3,13 +3,7 @@
<inherits name='com.google.gwt.user.User' />
<inherits name="com.google.gwt.http.HTTP" />
<!-- <inherits name='com.google.gwt.user.theme.clean.Clean' /> -->
<inherits name='com.sencha.gxt.ui.GXT' />
<!-- <inherits name="com.extjs.gxt.ui.GXT" /> -->
<!-- <inherits name="com.google.gwt.logging.Logging" /> -->
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
<!--
<entry-point
class='org.gcube.portlets.widgets.dataminermanagerwidget.client.DataMinerManager' />
@ -19,12 +13,12 @@
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
/> -->
<!--
<set-property name="log_ConsoleLogger" value="DISABLED" />
<set-property name="log_DivLogger" value="DISABLED" />
<set-property name="log_GWTLogger" value="DISABLED" />
<set-property name="log_SystemLogger" value="DISABLED" />
-->
<source path='client' />

View File

@ -53,6 +53,7 @@ import org.gcube.data.analysis.dataminermanagercl.shared.data.output.MapResource
import org.gcube.data.analysis.dataminermanagercl.shared.data.output.ObjectResource;
import org.gcube.data.analysis.dataminermanagercl.shared.data.output.Resource;
import org.gcube.data.analysis.dataminermanagercl.shared.exception.ServiceException;
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.FileParameter;
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ObjectParameter;
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.TabularListParameter;
@ -410,8 +411,7 @@ public class SClient4WPS extends SClient {
return processInformations;
} catch (Throwable e) {
logger.error(e.getLocalizedMessage());
e.printStackTrace();
logger.error(e.getLocalizedMessage(),e);
throw new ServiceException(e.getLocalizedMessage(), e);
} finally {
wpsClient.disconnect(wpsProcessingServlet);
@ -928,8 +928,7 @@ public class SClient4WPS extends SClient {
return statusLocation;
} catch (Throwable e) {
logger.error(e.getLocalizedMessage());
e.printStackTrace();
logger.error(e.getLocalizedMessage(),e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
@ -1041,8 +1040,7 @@ public class SClient4WPS extends SClient {
}
} catch (Throwable e) {
logger.error("MonitorProcess: " + e.getLocalizedMessage());
e.printStackTrace();
logger.error("MonitorProcess: " + e.getLocalizedMessage(),e);
throw new ServiceException(e.getLocalizedMessage(), e);
} finally {
wpsClient.disconnect(wpsProcessingServlet);
@ -1146,9 +1144,24 @@ public class SClient4WPS extends SClient {
if (responseWPS.getData().startsWith("http:")
|| responseWPS.getData().startsWith("https:")
|| responseWPS.getData().startsWith("smp:")) {
resource = new FileResource(key, responseWPS.getDescription(),
responseWPS.getDescription(), responseWPS.getData(),
responseWPS.getMimeType());
Parameter complexParameter = outputParameters.get(outputID);
if (complexParameter instanceof FileParameter) {
FileParameter fileParameter = (FileParameter) complexParameter;
if (fileParameter.isNetcdf()) {
resource = new FileResource(key, responseWPS.getDescription(),
responseWPS.getDescription(), responseWPS.getData(),
responseWPS.getMimeType(), true);
} else {
resource = new FileResource(key, responseWPS.getDescription(),
responseWPS.getDescription(), responseWPS.getData(),
responseWPS.getMimeType(), false);
}
} else {
resource = new FileResource(key, responseWPS.getDescription(),
responseWPS.getDescription(), responseWPS.getData(),
responseWPS.getMimeType(), false);
}
outputResource.put(key, resource);
} else {
resource = new ObjectResource(key, responseWPS.getDescription(),
@ -1167,9 +1180,23 @@ public class SClient4WPS extends SClient {
if (responseWPS.getData().startsWith("http:")
|| responseWPS.getData().startsWith("https:")
|| responseWPS.getData().startsWith("smp:")) {
resource = new FileResource(key, responseWPS.getDescription(),
responseWPS.getDescription(), responseWPS.getData(),
responseWPS.getMimeType());
Parameter complexParameter = outputParameters.get(outputID);
if (complexParameter instanceof FileParameter) {
FileParameter fileParameter = (FileParameter) complexParameter;
if (fileParameter.isNetcdf()) {
resource = new FileResource(key, responseWPS.getDescription(),
responseWPS.getDescription(), responseWPS.getData(),
responseWPS.getMimeType(), true);
} else {
resource = new FileResource(key, responseWPS.getDescription(),
responseWPS.getDescription(), responseWPS.getData(),
responseWPS.getMimeType(), false);
}
} else {
resource = new FileResource(key, responseWPS.getDescription(),
responseWPS.getDescription(), responseWPS.getData(),
responseWPS.getMimeType(), false);
}
outputResource.put(key, resource);
} else {
resource = new ObjectResource(key, responseWPS.getDescription(),
@ -1206,7 +1233,7 @@ public class SClient4WPS extends SClient {
return result;
} catch (Throwable e) {
e.printStackTrace();
logger.error(e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
} finally {
if (wpsClient != null) {
@ -1216,6 +1243,7 @@ public class SClient4WPS extends SClient {
}
@Override
public ComputationId resubmitComputation(Map<String, String> computationProperties) throws ServiceException {
ProcessInformations processInformations;
if (computationProperties == null || computationProperties.isEmpty()) {

View File

@ -537,17 +537,20 @@ public class SClient4WPSSession implements Serializable {
URL url = new URL(urlString);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Authorization", "Basic " + encoded);
conn.setRequestProperty("Accept-Encoding", "gzip");
conn.setRequestProperty("Content-Type", "text/xml");
conn.setRequestProperty("Content-Type", "text/xml; charset=UTF-8");
conn.setDoOutput(true);
obj.save(conn.getOutputStream());
InputStream input = null;
String encoding = conn.getContentEncoding();
if (encoding != null && encoding.equalsIgnoreCase("gzip")) {
logger.debug("Read encoding GZIP");
input = new GZIPInputStream(conn.getInputStream());
} else {
logger.debug("Read encoding: "+encoding);
input = conn.getInputStream();
}
return input;

View File

@ -50,16 +50,16 @@ public class WPS2DM {
* @param title
* title
* @param minOcc
* min occurences
* min occurrences
* @param maxOcc
* max occurences
* max occurrences
* @param rangeOccs
* range occurences
* range occurrences
* @param id
* id
* @param crs
* crs
* @return Parameter
* @return parameter
*/
public static Parameter manageBoundingBoxInformation(String title, int minOcc, int maxOcc, int rangeOccs, String id,
String crs) {
@ -83,7 +83,7 @@ public class WPS2DM {
* @param title
* title
* @param minOcc
* min occurences
* min occurrences
* @param maxOcc
* max occurences
* @param rangeOccs
@ -96,7 +96,7 @@ public class WPS2DM {
* uoms
* @param type
* type
* @return Parameter
* @return parameter
*/
public static Parameter manageLiteral(String title, int minOcc, int maxOcc, int rangeOccs, String defaultValue,
String id, String uoms, DomainMetadataType type) {
@ -255,18 +255,18 @@ public class WPS2DM {
* @param title
* title
* @param minOcc
* min occurences
* min occurrences
* @param maxOcc
* max occurences
* max occurrences
* @param rangeOccs
* range occurences
* range occurrences
* @param id
* id
* @param defaultType
* default type
* @param supportedTypes
* supported types
* @return Parameter
* supported type
* @return parameter
*/
public static Parameter manageComplexData(String maxMegaBytes, String title, int minOcc, int maxOcc, int rangeOccs,
String id, ComplexDataDescriptionType defaultType, ComplexDataDescriptionType[] supportedTypes) {
@ -297,7 +297,11 @@ public class WPS2DM {
supportedMimeTypes);
} else {
if (title.contains("[a http link to a file")) {
converted = new FileParameter(id, title, mimeType, supportedMimeTypes);
if (title.contains("[NETCDF]")) {
converted = new FileParameter(id, title, mimeType, supportedMimeTypes, true);
} else {
converted = new FileParameter(id, title, mimeType, supportedMimeTypes, false);
}
} else {
if (title.contains("[a sequence of http links")) {
Pattern pattern = Pattern.compile(
@ -317,18 +321,26 @@ public class WPS2DM {
converted = new TabularListParameter(id, title, separator, mimeType,
supportedMimeTypes);
} else {
converted = new FileParameter(id, title, mimeType, supportedMimeTypes);
if (title.contains("[NETCDF]")) {
converted = new FileParameter(id, title, mimeType, supportedMimeTypes, true);
} else {
converted = new FileParameter(id, title, mimeType, supportedMimeTypes, false);
}
}
} else {
converted = new FileParameter(id, title, mimeType, supportedMimeTypes);
if (title.contains("[NETCDF]")) {
converted = new FileParameter(id, title, mimeType, supportedMimeTypes, true);
} else {
converted = new FileParameter(id, title, mimeType, supportedMimeTypes, false);
}
}
}
}
} else {
converted = new FileParameter(id, title, mimeType, supportedMimeTypes);
converted = new FileParameter(id, title, mimeType, supportedMimeTypes, false);
}
} else {
converted = new FileParameter(id, title, mimeType, supportedMimeTypes);
converted = new FileParameter(id, title, mimeType, supportedMimeTypes, false);
}
return converted;
}
@ -445,7 +457,7 @@ public class WPS2DM {
* @param maxMegabytes
* max mega bytes
* @param UoM
* uom
* UoM
* @param minElements
* min elements
* @param maxElements

View File

@ -33,10 +33,9 @@ public class ComputationValueBuilder {
this.valueParameters = valueParameters;
}
/**
*
* @return map of computation value
* @return map from parameter to computation value
*/
public LinkedHashMap<String, ComputationValue> create() {
computationsValueParameters = new LinkedHashMap<String, ComputationValue>();
@ -97,7 +96,7 @@ public class ComputationValueBuilder {
} catch (Throwable e) {
logger.error("Retrieve File Name: " + e.getLocalizedMessage());
e.printStackTrace();
return new ComputationValueFile(value, null, null);
return new ComputationValueFile(value, null, null,false);
}
}
@ -148,8 +147,12 @@ public class ComputationValueBuilder {
computationValue = new ComputationValueImage(value, fileName,
mimeType);
} else {
computationValue = new ComputationValueFile(value, fileName,
mimeType);
if ((mimeType != null && mimeType.compareToIgnoreCase("application/x-netcdf") == 0)
|| fileName != null && fileName.endsWith(".nc")) {
computationValue = new ComputationValueFile(value, fileName, mimeType, true);
} else {
computationValue = new ComputationValueFile(value, fileName, mimeType, false);
}
}
return computationValue;

View File

@ -12,12 +12,7 @@ public class Constants {
public static final String DEFAULT_USER = "giancarlo.panichi";
public final static String DEFAULT_SCOPE = "/gcube/devNext/NextNext";
public final static String DEFAULT_TOKEN = "ae1208f0-210d-47c9-9b24-d3f2dfcce05f-98187548";
//public final static String DEFAULT_SCOPE = "/gcube/preprod/preVRE";
//public final static String DEFAULT_TOKEN = "04269c7d-dab7-498a-841d-8d38ae2d482b-98187548";
public final static String DEFAULT_TOKEN = "";
public static final String DATAMINER_SERVICE_CATEGORY = "DataAnalysis";
public static final String DATA_MINER_SERVICE_NAME = "DataMiner";

View File

@ -11,15 +11,17 @@ public class ComputationValueFile extends ComputationValue {
private String fileName;
private String mimeType;
private boolean netcdf;
public ComputationValueFile() {
super(ComputationValueType.File);
}
public ComputationValueFile(String url, String fileName, String mimeType) {
public ComputationValueFile(String url, String fileName, String mimeType, boolean netcdf) {
super(ComputationValueType.File, url);
this.fileName = fileName;
this.mimeType = mimeType;
this.netcdf = netcdf;
}
public String getFileName() {
@ -38,12 +40,17 @@ public class ComputationValueFile extends ComputationValue {
this.mimeType = mimeType;
}
@Override
public String toString() {
return "ComputationValueFile [fileName=" + fileName + ", mimeType="
+ mimeType + ", type=" + type + ", value=" + value + "]";
public boolean isNetcdf() {
return netcdf;
}
public void setNetcdf(boolean netcdf) {
this.netcdf = netcdf;
}
@Override
public String toString() {
return "ComputationValueFile [fileName=" + fileName + ", mimeType=" + mimeType + ", netcdf=" + netcdf + "]";
}
}

View File

@ -18,6 +18,7 @@ public class FileResource extends Resource {
private String url;
private String mimeType;
private boolean netcdf;
/**
*
@ -39,11 +40,15 @@ public class FileResource extends Resource {
* url
* @param mimeType
* mime type
* @param netcdf
* netcdf
*/
public FileResource(String resourceId, String name, String description, String url, String mimeType) {
public FileResource(String resourceId, String name, String description, String url, String mimeType,
boolean netcdf) {
super(resourceId, name, description, ResourceType.FILE);
this.url = url;
this.mimeType = mimeType;
this.netcdf = netcdf;
}
/**
@ -76,11 +81,33 @@ public class FileResource extends Resource {
this.mimeType = mimeType;
}
@Override
public String toString() {
return "FileResource [url=" + url + ", mimeType=" + mimeType + ", getResourceId()=" + getResourceId()
+ ", getName()=" + getName() + ", getDescription()=" + getDescription() + ", getResourceType()="
+ getResourceType() + "]";
/**
*
* @return true if is NetCDF file
*/
public boolean isNetcdf() {
return netcdf;
}
/**
*
* @param netcdf
* true if is NetCDF file
*/
public void setNetcdf(boolean netcdf) {
this.netcdf = netcdf;
}
@Override
public String toString() {
return "FileResource [url=" + url + ", mimeType=" + mimeType + ", netcdf=" + netcdf + ", getResourceId()="
+ getResourceId() + ", getName()=" + getName() + ", getDescription()=" + getDescription()
+ ", getResourceType()=" + getResourceType() + ", isTabular()=" + isTabular() + ", isObject()="
+ isObject() + ", isFile()=" + isFile() + ", isMap()=" + isMap() + ", isImages()=" + isImages()
+ ", toString()=" + super.toString() + ", getClass()=" + getClass() + ", hashCode()=" + hashCode()
+ "]";
}
}

View File

@ -16,6 +16,7 @@ public class FileParameter extends Parameter {
private static final long serialVersionUID = -2967577990287112937L;
private String defaultMimeType;
private ArrayList<String> supportedMimeTypes;
private boolean netcdf;
/**
*
@ -23,6 +24,7 @@ public class FileParameter extends Parameter {
public FileParameter() {
super();
this.typology = ParameterType.FILE;
netcdf = false;
}
/**
@ -34,13 +36,16 @@ public class FileParameter extends Parameter {
* @param defaultMimeType
* default mime type
* @param supportedMimeTypes
* supported mime type
* supported mime types
* @param netcdf
* is netcdf file
*/
public FileParameter(String name, String description, String defaultMimeType,
ArrayList<String> supportedMimeTypes) {
public FileParameter(String name, String description, String defaultMimeType, ArrayList<String> supportedMimeTypes,
boolean netcdf) {
super(name, ParameterType.FILE, description);
this.defaultMimeType = defaultMimeType;
this.supportedMimeTypes = supportedMimeTypes;
this.netcdf = netcdf;
}
public String getDefaultMimeType() {
@ -59,11 +64,19 @@ public class FileParameter extends Parameter {
this.supportedMimeTypes = supportedMimeTypes;
}
public boolean isNetcdf() {
return netcdf;
}
public void setNetcdf(boolean netcdf) {
this.netcdf = netcdf;
}
@Override
public String toString() {
return "FileParameter [value=" + value + ", defaultMimeType=" + defaultMimeType + ", supportedMimeTypes="
+ supportedMimeTypes + ", name=" + name + ", description=" + description + ", typology=" + typology
+ "]";
return "FileParameter [defaultMimeType=" + defaultMimeType + ", supportedMimeTypes=" + supportedMimeTypes
+ ", netcdf=" + netcdf + ", name=" + name + ", description=" + description + ", typology=" + typology
+ ", value=" + value + "]";
}
}

View File

@ -3,13 +3,7 @@
<inherits name='com.google.gwt.user.User' />
<inherits name="com.google.gwt.http.HTTP" />
<!-- <inherits name='com.google.gwt.user.theme.clean.Clean' /> -->
<inherits name='com.sencha.gxt.ui.GXT' />
<!-- <inherits name="com.extjs.gxt.ui.GXT" /> -->
<!-- <inherits name="com.google.gwt.logging.Logging" /> -->
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
<!--
<entry-point
class='org.gcube.portlets.widgets.dataminermanagerwidget.client.DataMinerManager' />
@ -19,11 +13,12 @@
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
/> -->
<!--
<set-property name="log_ConsoleLogger" value="DISABLED" />
<set-property name="log_DivLogger" value="DISABLED" />
<set-property name="log_GWTLogger" value="DISABLED" />
<set-property name="log_SystemLogger" value="DISABLED" />
-->