diff --git a/etc/build.properties b/etc/build.properties
index b7aabce..90df516 100755
--- a/etc/build.properties
+++ b/etc/build.properties
@@ -3,5 +3,6 @@ package = org.gcube.informationsystem.registry
lib.dir = Dependencies/ISREGISTRY
wsdl.1 = RegistryFactory
wsdl.2 = Registry
+wsdl.3 = ResourceRegistration
namespace.1=http://gcube-system.org/namespaces/informationsystem/registry
diff --git a/etc/deploy-server.wsdd b/etc/deploy-server.wsdd
index cc7174f..e271007 100644
--- a/etc/deploy-server.wsdd
+++ b/etc/deploy-server.wsdd
@@ -31,4 +31,15 @@
+
+
+ share/schema/org.gcube.informationsystem.registry/ResourceRegistration_service.wsdl
+
+
+
+
+
+
+
+
diff --git a/schema/ResourceRegistration.wsdl b/schema/ResourceRegistration.wsdl
index 2e80d4f..4ccc5b4 100644
--- a/schema/ResourceRegistration.wsdl
+++ b/schema/ResourceRegistration.wsdl
@@ -1,105 +1,149 @@
+ targetNamespace="http://gcube-system.org/namespaces/informationsystem/registry"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://gcube-system.org/namespaces/informationsystem/registry"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:provider="http://gcube-system.org/namespaces/common/core/porttypes/GCUBEProvider"
+ xmlns:wsdlpp="http://www.globus.org/namespaces/2004/10/WSDLPreprocessor"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/org/gcube/informationsystem/registry/impl/porttypes/RegistryFactory.java b/src/org/gcube/informationsystem/registry/impl/porttypes/RegistryFactory.java
index 95eeab7..3e1d66e 100644
--- a/src/org/gcube/informationsystem/registry/impl/porttypes/RegistryFactory.java
+++ b/src/org/gcube/informationsystem/registry/impl/porttypes/RegistryFactory.java
@@ -15,7 +15,9 @@ import java.util.List;
import org.apache.axis.components.uuid.UUIDGen;
import org.apache.axis.components.uuid.UUIDGenFactory;
import org.gcube.common.core.contexts.GCUBEServiceContext;
+import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.faults.GCUBEFault;
+import org.gcube.common.core.informationsystem.publisher.ISResourcePublisher;
import org.gcube.common.core.porttypes.GCUBEPortType;
import org.gcube.common.core.resources.GCUBEHostingNode;
import org.gcube.common.core.resources.GCUBEResource;
@@ -28,7 +30,6 @@ import org.gcube.informationsystem.registry.impl.contexts.ProfileContext;
import org.gcube.informationsystem.registry.impl.contexts.ServiceContext;
import org.gcube.informationsystem.registry.impl.filters.FilterManager;
import org.gcube.informationsystem.registry.impl.filters.FilterExecutor.InvalidFilterException;
-import org.gcube.informationsystem.registry.impl.profilemanagement.ProfileManager;
import org.gcube.informationsystem.registry.impl.profilemanagement.GHN;
import org.gcube.informationsystem.registry.impl.resourcemanagement.Pair;
import org.gcube.informationsystem.registry.impl.state.ProfileResource;
@@ -40,6 +41,7 @@ import org.gcube.informationsystem.registry.stubs.RemoveResourceMessage;
import org.gcube.informationsystem.registry.stubs.RemoveResourceResponse;
import org.gcube.informationsystem.registry.stubs.ResourceNotAcceptedFault;
import org.gcube.informationsystem.registry.stubs.SchemaValidationFault;
+import org.gcube.informationsystem.registry.stubs.UpdateFault;
import org.gcube.informationsystem.registry.stubs.UpdateResourceMessage;
import org.gcube.informationsystem.registry.stubs.UpdateResourceResponse;
@@ -255,8 +257,7 @@ public class RegistryFactory extends GCUBEPortType {
logger.info("UpdateResource operation invoked");
String ID = mess.getUniqueID();
String xmlProfile = mess.getXmlProfile();
- GCUBEResource resource = null;
- CreateResourceMessage input = null;
+ GCUBEResource resource = null;
// validating input parameters
if (ID == null || ID.compareTo("") == 0) {
logger.debug(" ID missing ");
@@ -268,7 +269,7 @@ public class RegistryFactory extends GCUBEPortType {
}
// check if the profile exist
if (!isResourceCreated(ID)) {
- input = new CreateResourceMessage();
+ CreateResourceMessage input = new CreateResourceMessage();
input.setProfile(xmlProfile);
input.setType(mess.getType());
this.createResource(input);
@@ -332,15 +333,14 @@ public class RegistryFactory extends GCUBEPortType {
logger.warn("Resource ID is missing, cannot manage the resource");
throw new RemoteException("Resource ID is missing, cannot manage the resource");
}
- //TODO: delete the profile with the GCUBEPublisher
try {
logger.debug("Trying to remove the resource from the IS-IC");
- new ProfileManager().remove(ID, type, ServiceContext.getContext().getScope(), ServiceContext.getContext());
- logger.info("Resource removed from the IS-IC");
+ ISResourcePublisher publisher = GHNContext.getImplementation(ISResourcePublisher.class);
+ publisher.remove(ID, type, ServiceContext.getContext().getScope(), ServiceContext.getContext());
+ logger.debug("Resource " + ID+ " successfully removed");
} catch (Exception e) {
- logger.error("Unable to remove the resource", e);
- throw ServiceContext.getContext().getDefaultException("", e).toFault(
- "Unable to remove the resource: the remote IS-IC returned an error");
+ logger.error("Unable to remove the resource " + ID, e);
+ throw new UpdateFault();
}
// if the resource is a GHN, remove also the related RIs
try {
diff --git a/src/org/gcube/informationsystem/registry/impl/porttypes/ResourceRegistration.java b/src/org/gcube/informationsystem/registry/impl/porttypes/ResourceRegistration.java
index 19835c3..3e368ac 100644
--- a/src/org/gcube/informationsystem/registry/impl/porttypes/ResourceRegistration.java
+++ b/src/org/gcube/informationsystem/registry/impl/porttypes/ResourceRegistration.java
@@ -1,11 +1,201 @@
package org.gcube.informationsystem.registry.impl.porttypes;
-import org.gcube.common.core.contexts.GCUBEServiceContext;
-import org.gcube.common.core.porttypes.GCUBEPortType;
-import org.gcube.informationsystem.registry.impl.contexts.ServiceContext;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.InputStreamReader;
+import java.rmi.RemoteException;
+import org.apache.axis.components.uuid.UUIDGen;
+import org.apache.axis.components.uuid.UUIDGenFactory;
+import org.gcube.common.core.contexts.GCUBEServiceContext;
+import org.gcube.common.core.contexts.GHNContext;
+import org.gcube.common.core.informationsystem.publisher.ISResourcePublisher;
+import org.gcube.common.core.porttypes.GCUBEPortType;
+import org.gcube.common.core.resources.GCUBEHostingNode;
+import org.gcube.common.core.resources.GCUBEResource;
+import org.gcube.common.core.utils.logging.GCUBELog;
+import org.gcube.informationsystem.registry.impl.contexts.ServiceContext;
+import org.gcube.informationsystem.registry.impl.filters.FilterManager;
+import org.gcube.informationsystem.registry.impl.filters.FilterExecutor.InvalidFilterException;
+import org.gcube.informationsystem.registry.impl.profilemanagement.GHN;
+import org.gcube.informationsystem.registry.impl.state.Definitions.ResourceType;
+import org.gcube.informationsystem.registry.stubs.CreateFault;
+import org.gcube.informationsystem.registry.stubs.CreateMessage;
+import org.gcube.informationsystem.registry.stubs.CreateResponse;
+import org.gcube.informationsystem.registry.stubs.InvalidResourceFault;
+import org.gcube.informationsystem.registry.stubs.RemoveFault;
+import org.gcube.informationsystem.registry.stubs.RemoveMessage;
+import org.gcube.informationsystem.registry.stubs.RemoveResponse;
+import org.gcube.informationsystem.registry.stubs.ResourceNotAcceptedFault;
+import org.gcube.informationsystem.registry.stubs.UpdateFault;
+import org.gcube.informationsystem.registry.stubs.UpdateMessage;
+import org.gcube.informationsystem.registry.stubs.UpdateResponse;
+
+/**
+ *
+ * Implementation of the ResourceRegistration portType
+ *
+ * @author Manuele Simi (ISTI-CNR)
+ *
+ */
public class ResourceRegistration extends GCUBEPortType {
+ protected final GCUBELog logger = new GCUBELog(ResourceRegistration.class);
+
+ /** The UUIDGen */
+ private static final UUIDGen uuidgen = UUIDGenFactory.getUUIDGen();
+
+
+ /**
+ * Creates a new resource
+ * @param message
+ * @return
+ * @throws SchemaValidationFault
+ * @throws ResourceNotAcceptedFault
+ * @throws CreateFaultType
+ */
+ public CreateResponse create(CreateMessage message)
+ throws InvalidResourceFault, ResourceNotAcceptedFault, CreateFault {
+
+ logger.info("CreateResource operation invoked in scope " + ServiceContext.getContext().getScope());
+ GCUBEResource resource = this.load(message.getType(),message.getProfile());
+ this.applyFilters(resource);
+ //create the new resource with the publisher
+ try {
+ ISResourcePublisher publisher = GHNContext.getImplementation(ISResourcePublisher.class);
+ publisher.register(resource, ServiceContext.getContext().getScope(), ServiceContext.getContext());
+ logger.debug("Resource " + resource.getID() + " successfully created");
+ } catch (Exception e) {
+ logger.error("Unable to register the resource", e);
+ throw new CreateFault();
+ }
+
+ return new CreateResponse();
+ }
+
+ /**
+ * Updates an existing resource
+ * @param message
+ * @return
+ * @throws SchemaValidationFault
+ * @throws ResourceNotAcceptedFault
+ * @throws UpdateFaultType
+ */
+ public UpdateResponse update(UpdateMessage message)
+ throws InvalidResourceFault, ResourceNotAcceptedFault, UpdateFault {
+
+ logger.info("UpdateResource operation invoked in scope " + ServiceContext.getContext().getScope());
+
+ GCUBEResource resource = this.load(message.getType(), message.getXmlProfile(), message.getUniqueID());
+ this.applyFilters(resource);
+ //update the resource with the publisher
+ try {
+ ISResourcePublisher publisher = GHNContext.getImplementation(ISResourcePublisher.class);
+ publisher.register(resource, ServiceContext.getContext().getScope(), ServiceContext.getContext());
+ logger.debug("Resource " + resource.getID() + " successfully updated");
+ } catch (Exception e) {
+ logger.error("Unable to update the resource", e);
+ throw new UpdateFault();
+ }
+ return new UpdateResponse();
+
+ }
+
+ /**
+ *
+ * @param message
+ * @return
+ * @throws ResourceDoesNotExistFaultType
+ * @throws RemoveFaultType
+ */
+ public RemoveResponse remove(RemoveMessage message) throws RemoveFault,RemoteException {
+ String ID = message.getUniqueID();
+ String type = message.getType();
+ logger.info("RemoveResource operation invoked on resource ID=" + ID + ", type=" + type);
+ if (ID == null || ID.compareTo("") == 0) {
+ logger.warn("Resource ID is missing, cannot manage the resource");
+ throw new RemoteException("Resource ID is missing, cannot manage the resource");
+ }
+ try {
+ ISResourcePublisher publisher = GHNContext.getImplementation(ISResourcePublisher.class);
+ publisher.remove(ID, type, ServiceContext.getContext().getScope(), ServiceContext.getContext());
+ logger.debug("Resource " + ID+ " successfully removed");
+ } catch (Exception e) {
+ logger.error("Unable to remove the resource " + ID, e);
+ throw new UpdateFault();
+ }
+
+ // if the resource is a GHN, remove also the related RIs
+ try {
+ if (type.compareTo(GCUBEHostingNode.TYPE) == 0) {
+ logger.debug("Removing the related RIs");
+ GHN ghn = new GHN(ID);
+ ghn.unregisterHostedRI();
+ logger.debug("Related RIs removed");
+ }
+ } catch (Exception e) {
+ logger.error("Error while removing RI profiles related to the GHN", e);
+ }
+
+ return new RemoveResponse();
+ }
+
+ /**
+ * Loads the {@link GCUBEResource} from its serialization
+ * @param type the type of the resource to load
+ * @param profile the serialization
+ * @param id the optional identifier to assign
+ * @return the resource
+ * @throws InvalidResourceFault if the resource was null
+ * @throws ResourceNotAcceptedFault if the resource was not accepted
+ */
+ private GCUBEResource load(String type, String profile, String ... id)
+ throws InvalidResourceFault,ResourceNotAcceptedFault {
+
+ if (profile == null || profile.compareTo("") == 0) {
+ logger.error("The input resource is null");
+ throw new InvalidResourceFault();
+ }
+ GCUBEResource resource;
+ try {
+ resource = ResourceType.valueOf(type).getResourceClass();
+ resource.load(new BufferedReader(new InputStreamReader( new ByteArrayInputStream(profile.getBytes("UTF-8")),"UTF-8")));
+ resource.addScope(ServiceContext.getContext().getScope());
+
+ // check the ID
+ if (resource.getID() == null || resource.getID().compareTo("") == 0) {
+ String newid = (id != null && id.length>0) ? id[0] : uuidgen.nextUUID();
+ if (!resource.setID(newid)) {
+ logger.error("Unable to set a new ID to the resource");
+ throw new ResourceNotAcceptedFault();
+ }
+ }
+ return resource;
+ } catch (Exception ex) {
+ logger.error("Error trying to load profile", ex);
+ throw new InvalidResourceFault();
+ }
+ }
+
+ /**
+ * Applies the configured filters to the resource
+ * @param resource the resource to filter
+ * @throws ResourceNotAcceptedFault if the resource was not accepted
+ */
+ private void applyFilters(GCUBEResource resource) throws ResourceNotAcceptedFault {
+ // apply resource filter
+ try {
+ if (!FilterManager.getExecutor(resource.getType()).accept(resource)) {
+ logger.warn("Resource " + resource.getID() + " NOT accepted ");
+ throw new ResourceNotAcceptedFault();
+ }
+ logger.trace("Resource " + resource.getID() + " accepted ");
+ } catch (InvalidFilterException e) {
+ logger.warn("Invalid filter selected, the resource "+ resource.getID() + " CANNOT be filtered ");
+ }
+ }
+
+
@Override
protected GCUBEServiceContext getServiceContext() {
return ServiceContext.getContext();
diff --git a/src/org/gcube/informationsystem/registry/impl/profilemanagement/GHN.java b/src/org/gcube/informationsystem/registry/impl/profilemanagement/GHN.java
index bf4cf09..e80e466 100644
--- a/src/org/gcube/informationsystem/registry/impl/profilemanagement/GHN.java
+++ b/src/org/gcube/informationsystem/registry/impl/profilemanagement/GHN.java
@@ -11,6 +11,7 @@ import org.gcube.common.core.informationsystem.client.QueryParameter;
import org.gcube.common.core.informationsystem.client.XMLResult;
import org.gcube.common.core.informationsystem.client.ISClient.ISMalformedQueryException;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericQuery;
+import org.gcube.common.core.informationsystem.publisher.ISResourcePublisher;
import org.gcube.common.core.resources.GCUBERunningInstance;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.informationsystem.registry.impl.porttypes.RegistryFactory;
@@ -26,47 +27,69 @@ import org.gcube.informationsystem.registry.stubs.RemoveResourceMessage;
*/
public class GHN {
- public static ISClient client = null;
+ public static ISClient client = null;
- protected static final GCUBELog logger = new GCUBELog(GHN.class);
-
- private String id = null;
+ protected static final GCUBELog logger = new GCUBELog(GHN.class);
- public GHN(String id) {
- this.id = id;
- }
-
- /**
- * Unregisters all the RIs hosted on the gHN
- *
- * @param service
- * @throws ISMalformedQueryException
- * @throws ISInvalidQueryException
- * @throws ISException
- * @throws GCUBEFault
- * @throws RemoteException
- */
- public void unregisterHostedRIs(RegistryFactory service) throws Exception {
- if (client == null)
- client = GHNContext.getImplementation(ISClient.class);
- RemoveResourceMessage message = null;
- GCUBEGenericQuery query = client.getQuery("RIOnGHN");
- query.addParameters(new QueryParameter("ID", this.id));
-
- // query to IS on order to retrieve the RI deployed on the GHN;
- List resources = client.execute(query, ServiceContext.getContext().getScope());
-
- if (resources.size() != 0) {
- for (XMLResult resource : resources) {
- try {
- message = new RemoveResourceMessage();
- message.setType(GCUBERunningInstance.TYPE);
- message.setUniqueID(resource.evaluate("/Resource/ID/text()").get(0));
- service.removeResource(message);
- } catch (RemoteException rme) {
- }
- }
+ private String id = null;
+ public GHN(String id) {
+ this.id = id;
}
- }
+
+ /**
+ * Unregisters all the RIs hosted on the gHN
+ *
+ * @throws RemoteException
+ * @deprecated
+ */
+ public void unregisterHostedRIs(RegistryFactory service) throws Exception {
+ if (client == null)
+ client = GHNContext.getImplementation(ISClient.class);
+ RemoveResourceMessage message = null;
+ GCUBEGenericQuery query = client.getQuery("RIOnGHN");
+ query.addParameters(new QueryParameter("ID", this.id));
+
+ // query to IS on order to retrieve the RI deployed on the GHN;
+ List resources = client.execute(query, ServiceContext.getContext().getScope());
+
+ if (resources.size() != 0) {
+ for (XMLResult resource : resources) {
+ try {
+ message = new RemoveResourceMessage();
+ message.setType(GCUBERunningInstance.TYPE);
+ message.setUniqueID(resource.evaluate("/Resource/ID/text()").get(0));
+ service.removeResource(message);
+ } catch (RemoteException rme) {
+ }
+ }
+
+ }
+ }
+
+ public void unregisterHostedRI() throws Exception {
+ if (client == null)
+ client = GHNContext.getImplementation(ISClient.class);
+
+ GCUBEGenericQuery query = client.getQuery("RIOnGHN");
+ query.addParameters(new QueryParameter("ID", this.id));
+
+ // query to IS on order to retrieve the RI deployed on the GHN;
+ List resources = client.execute(query, ServiceContext.getContext().getScope());
+
+ if (resources.size() != 0) {
+ for (XMLResult resource : resources) {
+ try {
+ String id = resource.evaluate("/Resource/ID/text()").get(0);
+ ISResourcePublisher publisher = GHNContext.getImplementation(ISResourcePublisher.class);
+ publisher.remove(id, GCUBERunningInstance.TYPE, ServiceContext.getContext().getScope(), ServiceContext.getContext());
+ logger.debug("Resource " + id+ " successfully removed");
+ } catch (Exception e) {
+ logger.error("Failed to remove a hosted RI from ghn " + this.id, e);
+ }
+ }
+ }
+ }
+
+
}
diff --git a/src/org/gcube/informationsystem/registry/impl/profilemanagement/ProfileManager.java b/src/org/gcube/informationsystem/registry/impl/profilemanagement/ProfileManager.java
deleted file mode 100644
index 527769d..0000000
--- a/src/org/gcube/informationsystem/registry/impl/profilemanagement/ProfileManager.java
+++ /dev/null
@@ -1,162 +0,0 @@
-package org.gcube.informationsystem.registry.impl.profilemanagement;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.rmi.RemoteException;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.axis.message.addressing.AttributedURI;
-import org.apache.axis.message.addressing.EndpointReferenceType;
-import org.apache.axis.types.URI;
-
-import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
-import org.gcube.common.core.resources.GCUBEResource;
-import org.gcube.common.core.scope.GCUBEScope;
-import org.gcube.common.core.scope.GCUBEScopeNotSupportedException;
-import org.gcube.common.core.scope.ServiceMap;
-import org.gcube.common.core.scope.ServiceMap.ServiceType;
-import org.gcube.common.core.security.GCUBEServiceSecurityManager;
-import org.gcube.common.core.utils.logging.GCUBELog;
-import org.gcube.informationsystem.collector.stubs.wsdai.DataResourceUnavailableFaultType;
-import org.gcube.informationsystem.collector.stubs.wsdai.InvalidResourceNameFaultType;
-import org.gcube.informationsystem.collector.stubs.wsdai.NotAuthorizedFaultType;
-import org.gcube.informationsystem.collector.stubs.wsdai.ServiceBusyFaultType;
-import org.gcube.informationsystem.collector.stubs.wsdaix.InvalidCollectionNameFaultType;
-import org.gcube.informationsystem.collector.stubs.wsdaix.RemoveDocumentRequestWrapper;
-import org.gcube.informationsystem.collector.stubs.wsdaix.RemoveDocumentsRequest;
-import org.gcube.informationsystem.collector.stubs.wsdaix.RemoveDocumentsResponse;
-import org.gcube.informationsystem.collector.stubs.wsdaix.XMLCollectionAccessPT;
-import org.gcube.informationsystem.collector.stubs.wsdaix.service.WsdaixServiceAddressingLocator;
-import org.gcube.informationsystem.registry.impl.contexts.ServiceContext;
-
-public class ProfileManager {
-
- protected static final GCUBELog logger = new GCUBELog(ProfileManager.class);
-
- protected Set ICEprs = new HashSet();
-
- protected String VOMapName;
-
- public enum ResourceTypes {
- Service, CS, CSInstance, Collection, RunningInstance, ExternalRunningInstance, GHN, gLiteResource, MetadataCollection, GenericResource
- }
-
- public ProfileManager() throws Exception {
-
- GCUBEScope scope = ServiceContext.getContext().getScope();
-
- ServiceMap map;
- try {
- map = scope.getServiceMap();
- } catch (GCUBEScopeNotSupportedException e1) {
- logger.error("error retrieving service map for scope "
- + scope.toString(), e1);
- throw new Exception(e1);
- }
- this.getSinks(map);
- VOMapName = scope.getName();
- }
-
-
- public void add(GCUBEResource resource, GCUBEScope scope, GCUBEServiceSecurityManager manager) throws Exception {
-
- }
-
- /**
- * Removes a {@link GCUBEResource} from the IS
- *
- * @param uniqueID the uniqueID to of the GCUBEResource to remove
- * @param type the type of Profile
- *
- * @throws Exception if the unregistration fails
- */
-
- public void remove(String uniqueID, String type, GCUBEScope scope,
- GCUBEServiceSecurityManager manager) throws Exception {
-
- for (EndpointReferenceType sink : this.ICEprs) {
- String isIcAddress = sink.getAddress().toString();
- // check if the type has been specified
- if (type != null && type.compareTo("") != 0) {
- try {
- logger.debug("Removing profile from sink " + isIcAddress);
- this.removeDocuments(isIcAddress, scope, new URI("gcube://resource"), new URI("gcube://Profiles/"+ type), uniqueID);
- } catch (Exception e) {
- logger.error(
- "An error occurs while trying to remove the GCUBE Profile with ID "
- + uniqueID, e);
- throw new Exception(
- "Unregistration failed for the GCUBE Profile with ID "
- + uniqueID);
- }
- } else {
- try {
- // the type of the resource to delete is not specified, try
- // all the resource types
- logger.debug(" trying to remove profile with UniqueID" + uniqueID);
- for (int n = 0; n < ResourceTypes.values().length; n++) {
- this.removeDocuments(isIcAddress, scope, new URI("gcube://resource"),
- new URI("gcube://Profiles/"+ ResourceTypes.values()[n].toString()), uniqueID);
- }
- } catch (Exception e) {
- logger.error(
- " An error occurs while trying to remove the GCUBE Profile with ID "
- + uniqueID, e);
- throw new Exception(
- "Unregistration failed for the GCUBE Profile with ID "
- + uniqueID);
- }
- }
- }
- }
-
- /**
- * Executes the RemoveDocuments operation
- * @param serviceURL The URL of the data service
- * @param resourceName The abstract name of the data resource
- * @param collectionURI The URI of the collection from which documents should be removed
- * @param documentNames An array of document names that should be removed
- */
- private RemoveDocumentsResponse removeDocuments(String serviceURL, GCUBEScope scope,
- URI resourceName, URI collectionURI, String documentName)
- throws DataResourceUnavailableFaultType, MalformedURLException, RemoteException, ServiceBusyFaultType,
- InvalidResourceNameFaultType, InvalidCollectionNameFaultType, NotAuthorizedFaultType {
- RemoveDocumentsRequest request = new RemoveDocumentsRequest();
- request.setDataResourceAbstractName(resourceName);
- RemoveDocumentRequestWrapper[] wrappers = new RemoveDocumentRequestWrapper[1];
- wrappers[0] = new RemoveDocumentRequestWrapper();
- wrappers[0].setDocumentName(documentName);
- request.setRemoveDocumentRequestWrapper(wrappers);
- request.setCollectionName(collectionURI);
- XMLCollectionAccessPT stubs = null;
- try {
- stubs = new WsdaixServiceAddressingLocator().getXMLCollectionAccessPTPort(new URL(serviceURL));
- stubs = GCUBERemotePortTypeContext.getProxy(stubs, scope);
- } catch (Exception e) {
- logger.error("Failed to get documents", e);
- }
- return stubs.removeDocuments(request);
- }
-
- private void getSinks(final ServiceMap map) throws Exception {
-
- Set tmpEPRs = new HashSet();
- // get the list of IC where to register the RPs
- if (map.getEndpoints(ServiceType.ISICProfileQueryPT) != null)
- tmpEPRs.addAll(map.getEndpoints(ServiceType.ISICProfileQueryPT));
-
- if (map.getEndpoints(ServiceType.ISICAllQueryPT) != null)
- tmpEPRs.addAll(map.getEndpoints(ServiceType.ISICAllQueryPT));
-
- //TODO: temporary patch, to remove when XMLDocumentAccess will be available in the servicemap (gcore >= 0.5.1)
- for (EndpointReferenceType epr : tmpEPRs) {
- EndpointReferenceType newepr = new EndpointReferenceType();
- String path = epr.getAddress().toString();
- newepr.setAddress(new AttributedURI(path.replace("XQueryAccess", "XMLCollectionAccess")));
- this.ICEprs.add(newepr);
- }
- if (this.ICEprs.size() == 0)
- throw new Exception("No sink available in the Service Map");
- }
-}