diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClient4WPS.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClient4WPS.java index 3b0e2ce..bac359d 100644 --- a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClient4WPS.java +++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClient4WPS.java @@ -48,7 +48,6 @@ import org.gcube.data.analysis.dataminermanagercl.shared.process.Operator; import org.gcube.data.analysis.dataminermanagercl.shared.process.OperatorCategory; import org.gcube.data.analysis.dataminermanagercl.shared.process.OperatorsClassification; import org.gcube.data.analysis.dataminermanagercl.shared.service.ServiceInfo; -import org.gcube.data.analysis.dataminermanagercl.shared.service.ServiceInfoData; import org.n52.wps.client.ExecuteRequestBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -216,19 +215,18 @@ public class SClient4WPS extends SClient { @Override public ServiceInfo getServiceInfo() throws ServiceException { try { - ArrayList serviceProperties = new ArrayList<>(); + + ServiceInfo serviceInfo=null; if (discoveredByIS) { logger.info("DataMiner Service discovered by IS"); - serviceProperties = InformationSystemUtils.retrieveServiceProperties( + serviceInfo = InformationSystemUtils.retrieveServiceInfo( Constants.DATAMINER_SERVICE_CATEGORY, Constants.DATA_MINER_SERVICE_NAME, serviceCredentials.getScope()); } else { logger.info("DataMiner Service not discovered by IS no properties available"); - serviceProperties - .add(new ServiceInfoData("Address", serviceAddress, Constants.DEFAULT_SERVICE_INFO_CATEGORY)); + serviceInfo=new ServiceInfo(serviceAddress,null); } - ServiceInfo serviceInfo = new ServiceInfo(serviceProperties); logger.info("Service Info retrieved: " + serviceInfo); return serviceInfo; diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/is/InformationSystemUtils.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/is/InformationSystemUtils.java index fa64a0d..68340f5 100644 --- a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/is/InformationSystemUtils.java +++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/is/InformationSystemUtils.java @@ -9,6 +9,7 @@ import org.gcube.common.resources.gcore.ServiceEndpoint.Property; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.data.analysis.dataminermanagercl.shared.Constants; import org.gcube.data.analysis.dataminermanagercl.shared.exception.ServiceException; +import org.gcube.data.analysis.dataminermanagercl.shared.service.ServiceInfo; import org.gcube.data.analysis.dataminermanagercl.shared.service.ServiceInfoData; import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.queries.api.SimpleQuery; @@ -69,13 +70,13 @@ public class InformationSystemUtils { } } - public static ArrayList retrieveServiceProperties(String category, String name, String scope) + public static ServiceInfo retrieveServiceInfo(String category, String name, String scope) throws Exception { try { logger.debug("Retrieve Service Properties"); - ArrayList serviceProperties = new ArrayList<>(); + if (scope == null || scope.length() == 0) - return serviceProperties; + return null; ScopeProvider.instance.set(scope); @@ -85,15 +86,17 @@ public class InformationSystemUtils { .setResult("$resource/Profile/AccessPoint"); DiscoveryClient client = ICFactory.clientFor(AccessPoint.class); List accessPointList = client.submit(query); - + + String serviceAddress=null; + ArrayList serviceProperties = new ArrayList<>(); + if (accessPointList != null && !accessPointList.isEmpty()) { AccessPoint accessPoint = accessPointList.get(0); if (accessPoint.address() != null && !accessPoint.address().isEmpty()) { String accessPointAddress = accessPoint.address(); int wpsWebProcessingServiceIndex = accessPointAddress.indexOf(Constants.WPSWebProcessingService); if (wpsWebProcessingServiceIndex > 0) { - String address = accessPointAddress.substring(0, wpsWebProcessingServiceIndex); - serviceProperties.add(new ServiceInfoData("Address", address, Constants.DEFAULT_SERVICE_INFO_CATEGORY)); + serviceAddress = accessPointAddress.substring(0, wpsWebProcessingServiceIndex); } } @@ -118,11 +121,13 @@ public class InformationSystemUtils { } } - logger.debug("Service Properties: " + serviceProperties); - return serviceProperties; + ServiceInfo serviceInfo=new ServiceInfo(serviceAddress,serviceProperties); + + logger.debug("Service Info: " + serviceInfo); + return serviceInfo; } catch (Throwable e) { - logger.error("Error in discovery DataMiner Service Endpoint Properties in scope: " + scope); + logger.error("Error in discovery DataMiner Service Endpoint Info in scope: " + scope); logger.error(e.getLocalizedMessage(), e); throw e; } diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/service/ServiceInfo.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/service/ServiceInfo.java index 2cd3f4b..15a06aa 100644 --- a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/service/ServiceInfo.java +++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/service/ServiceInfo.java @@ -12,17 +12,27 @@ import java.util.ArrayList; public class ServiceInfo implements Serializable { private static final long serialVersionUID = 9046784925213335261L; + private String serviceAddress; private ArrayList serviceProperties; public ServiceInfo() { super(); } - public ServiceInfo(ArrayList serviceProperties) { + public ServiceInfo(String serviceAddress, ArrayList serviceProperties) { super(); + this.serviceAddress = serviceAddress; this.serviceProperties = serviceProperties; } + public String getServiceAddress() { + return serviceAddress; + } + + public void setServiceAddress(String serviceAddress) { + this.serviceAddress = serviceAddress; + } + public ArrayList getServiceProperties() { return serviceProperties; } @@ -33,7 +43,7 @@ public class ServiceInfo implements Serializable { @Override public String toString() { - return "ServiceInfo [serviceProperties=" + serviceProperties + "]"; + return "ServiceInfo [serviceAddress=" + serviceAddress + ", serviceProperties=" + serviceProperties + "]"; } }