diff --git a/changelog.xml b/changelog.xml index c5d0e34..7866a15 100644 --- a/changelog.xml +++ b/changelog.xml @@ -1,4 +1,7 @@ + + Porting on the new XMLCollectionAccess portType exposed by the IS-Collector + Classes of living resources configurable via JNDI diff --git a/etc/profile.xml b/etc/profile.xml index f5fe23f..077a434 100644 --- a/etc/profile.xml +++ b/etc/profile.xml @@ -18,7 +18,7 @@
IS-Registry: validate, register and unregister GCUBE resources to/from the IS. It also publishes Topics for notifications about GCUBE resource events IS-Registry-service - 1.4.0 + 2.0.0 @@ -32,7 +32,7 @@ 1.0.0 IS-Registry-stubs - 1.4.0 + 2.0.0 false @@ -52,7 +52,7 @@ IS-Registry: validate, register and unregister GCUBE resources to/from the IS. It also publishes Topics for notifications about GCUBE resource events IS-Registry-stubs - 1.4.0 + 2.0.0 diff --git a/src/org/gcube/informationsystem/registry/impl/profilemanagement/ProfileManager.java b/src/org/gcube/informationsystem/registry/impl/profilemanagement/ProfileManager.java index d5bdc55..6759e08 100644 --- a/src/org/gcube/informationsystem/registry/impl/profilemanagement/ProfileManager.java +++ b/src/org/gcube/informationsystem/registry/impl/profilemanagement/ProfileManager.java @@ -1,11 +1,14 @@ 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.scope.GCUBEScope; @@ -14,9 +17,16 @@ 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.DeleteProfileParams; -import org.gcube.informationsystem.collector.stubs.XMLCollectionAccessPortType; -import org.gcube.informationsystem.collector.stubs.service.XMLCollectionAccessServiceLocator; +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 { @@ -63,74 +73,69 @@ public class ProfileManager { public void removeFromISIC(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 - DeleteProfileParams params = new DeleteProfileParams(); - params.setID(uniqueID); - if (type != null && type.compareTo("") != 0) { - try { - logger.debug("Removing profile from sink " + isIcAddress); - params.setProfileType(type); - XMLCollectionAccessPortType port = new XMLCollectionAccessServiceLocator().getXMLCollectionAccessPortTypePort(new URL(isIcAddress)); - port = GCUBERemotePortTypeContext.getProxy(port, scope, manager); - port.deleteProfile(params); - } 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); - XMLCollectionAccessPortType port = new XMLCollectionAccessServiceLocator().getXMLCollectionAccessPortTypePort(new URL(isIcAddress)); - port = GCUBERemotePortTypeContext.getProxy(port, scope, manager); - for (int n = 0; n < ResourceTypes.values().length; n++) { - params.setProfileType(ResourceTypes.values()[n].toString()); - logger.debug("Removing profile from sink " + isIcAddress.toString()); - port.deleteProfile(params); + 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); + } } - } 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); } - } - } } /** - * Queries the IS to find a GCUBEResource given its ID - * - * @param ID - * @param resourceClass - * @return - * @throws ISMalformedQueryException - * @throws ISInvalidQueryException - * @throws ISException - */ - /*public static GCUBEResource getProfileFromIS(String ID, Class resourceClass) throws ISMalformedQueryException, ISInvalidQueryException, ISException { - - GCUBEGenericQuery query = client.getQuery("GCUBEResourceQuery"); - - GCUBEResourceFromIDQuery query =client.getQuery(GCUBEResourceFromIDQuery.class); - query.setResourceClass(resourceClass); - query.setResourceID(ID); - List resource = client.execute(query, GHNContext.getContext().getDefaultScope()); - if (resource != null) return resource.get(0); - else return null; - - }*/ - + * 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 documentes", e); + } + return stubs.removeDocuments(request); + } + private void getSinks(final ServiceMap map) throws Exception { Set tmpEPRs = new HashSet();