Initial commit for 2.0.0 release: porting on the new XMLCollectionAccess portType exposed by the IS-Collector

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@31227 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Manuele Simi 2010-11-08 01:25:49 +00:00
parent 51dfef335b
commit 106e858284
3 changed files with 77 additions and 69 deletions

View File

@ -1,4 +1,7 @@
<ReleaseNotes> <ReleaseNotes>
<Changeset component="org.gcube.information-system.registry.2-0-0" date="">
<Change>Porting on the new XMLCollectionAccess portType exposed by the IS-Collector</Change>
</Changeset>
<Changeset component="org.gcube.information-system.registry.1-4-0" date="2010-08-30"> <Changeset component="org.gcube.information-system.registry.1-4-0" date="2010-08-30">
<Change>Classes of living resources configurable via JNDI</Change> <Change>Classes of living resources configurable via JNDI</Change>
</Changeset> </Changeset>

View File

@ -18,7 +18,7 @@
<Main> <Main>
<Description>IS-Registry: validate, register and unregister GCUBE resources to/from the IS. It also publishes Topics for notifications about GCUBE resource events</Description> <Description>IS-Registry: validate, register and unregister GCUBE resources to/from the IS. It also publishes Topics for notifications about GCUBE resource events</Description>
<Name>IS-Registry-service</Name> <Name>IS-Registry-service</Name>
<Version>1.4.0</Version> <Version>2.0.0</Version>
<Mandatory level="VO"/> <Mandatory level="VO"/>
<Shareable level="VO"/> <Shareable level="VO"/>
<GHNRequirements> <GHNRequirements>
@ -32,7 +32,7 @@
<Version>1.0.0</Version> <Version>1.0.0</Version>
</Service> </Service>
<Package>IS-Registry-stubs</Package> <Package>IS-Registry-stubs</Package>
<Version>1.4.0</Version> <Version>2.0.0</Version>
<Scope level="GHN"/> <Scope level="GHN"/>
<Optional>false</Optional> <Optional>false</Optional>
</Dependency> </Dependency>
@ -52,7 +52,7 @@
<Software> <Software>
<Description>IS-Registry: validate, register and unregister GCUBE resources to/from the IS. It also publishes Topics for notifications about GCUBE resource events</Description> <Description>IS-Registry: validate, register and unregister GCUBE resources to/from the IS. It also publishes Topics for notifications about GCUBE resource events</Description>
<Name>IS-Registry-stubs</Name> <Name>IS-Registry-stubs</Name>
<Version>1.4.0</Version> <Version>2.0.0</Version>
<MultiVersion value="true"/> <MultiVersion value="true"/>
<Mandatory level="GHN"/> <Mandatory level="GHN"/>
<Shareable level="VO"/> <Shareable level="VO"/>

View File

@ -1,11 +1,14 @@
package org.gcube.informationsystem.registry.impl.profilemanagement; package org.gcube.informationsystem.registry.impl.profilemanagement;
import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.rmi.RemoteException;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.apache.axis.message.addressing.AttributedURI; import org.apache.axis.message.addressing.AttributedURI;
import org.apache.axis.message.addressing.EndpointReferenceType; 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.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.scope.GCUBEScope; 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.scope.ServiceMap.ServiceType;
import org.gcube.common.core.security.GCUBEServiceSecurityManager; import org.gcube.common.core.security.GCUBEServiceSecurityManager;
import org.gcube.common.core.utils.logging.GCUBELog; import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.informationsystem.collector.stubs.DeleteProfileParams; import org.gcube.informationsystem.collector.stubs.wsdai.DataResourceUnavailableFaultType;
import org.gcube.informationsystem.collector.stubs.XMLCollectionAccessPortType; import org.gcube.informationsystem.collector.stubs.wsdai.InvalidResourceNameFaultType;
import org.gcube.informationsystem.collector.stubs.service.XMLCollectionAccessServiceLocator; 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; import org.gcube.informationsystem.registry.impl.contexts.ServiceContext;
public class ProfileManager { public class ProfileManager {
@ -66,15 +76,10 @@ public class ProfileManager {
for (EndpointReferenceType sink : this.ICEprs) { for (EndpointReferenceType sink : this.ICEprs) {
String isIcAddress = sink.getAddress().toString(); String isIcAddress = sink.getAddress().toString();
// check if the type has been specified // check if the type has been specified
DeleteProfileParams params = new DeleteProfileParams();
params.setID(uniqueID);
if (type != null && type.compareTo("") != 0) { if (type != null && type.compareTo("") != 0) {
try { try {
logger.debug("Removing profile from sink " + isIcAddress); logger.debug("Removing profile from sink " + isIcAddress);
params.setProfileType(type); this.removeDocuments(isIcAddress, scope, new URI("gcube://resource"), new URI("gcube://Profiles/"+ type), uniqueID);
XMLCollectionAccessPortType port = new XMLCollectionAccessServiceLocator().getXMLCollectionAccessPortTypePort(new URL(isIcAddress));
port = GCUBERemotePortTypeContext.getProxy(port, scope, manager);
port.deleteProfile(params);
} catch (Exception e) { } catch (Exception e) {
logger.error( logger.error(
"An error occurs while trying to remove the GCUBE Profile with ID " "An error occurs while trying to remove the GCUBE Profile with ID "
@ -83,18 +88,13 @@ public class ProfileManager {
"Unregistration failed for the GCUBE Profile with ID " "Unregistration failed for the GCUBE Profile with ID "
+ uniqueID); + uniqueID);
} }
} else { } else {
try { try {
// the type of the resource to delete is not specified, try // the type of the resource to delete is not specified, try
// all the resource types // all the resource types
logger.debug(" trying to remove profile with UniqueID" + uniqueID); 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++) { for (int n = 0; n < ResourceTypes.values().length; n++) {
params.setProfileType(ResourceTypes.values()[n].toString()); this.removeDocuments(isIcAddress, scope, new URI("gcube://resource"), new URI("gcube://Profiles/"+ ResourceTypes.values()[n].toString()), uniqueID);
logger.debug("Removing profile from sink " + isIcAddress.toString());
port.deleteProfile(params);
} }
} catch (Exception e) { } catch (Exception e) {
logger.error( logger.error(
@ -109,27 +109,32 @@ public class ProfileManager {
} }
/** /**
* Queries the IS to find a GCUBEResource given its ID * Executes the RemoveDocuments operation
* * @param serviceURL The URL of the data service
* @param ID * @param resourceName The abstract name of the data resource
* @param resourceClass * @param collectionURI The URI of the collection from which documents should be removed
* @return * @param documentNames An array of document names that should be removed
* @throws ISMalformedQueryException
* @throws ISInvalidQueryException
* @throws ISException
*/ */
/*public static GCUBEResource getProfileFromIS(String ID, Class<? extends GCUBEResource> resourceClass) throws ISMalformedQueryException, ISInvalidQueryException, ISException { private RemoveDocumentsResponse removeDocuments(String serviceURL, GCUBEScope scope,
URI resourceName, URI collectionURI, String documentName)
GCUBEGenericQuery query = client.getQuery("GCUBEResourceQuery"); throws DataResourceUnavailableFaultType, MalformedURLException, RemoteException, ServiceBusyFaultType,
InvalidResourceNameFaultType, InvalidCollectionNameFaultType, NotAuthorizedFaultType {
GCUBEResourceFromIDQuery query =client.getQuery(GCUBEResourceFromIDQuery.class); RemoveDocumentsRequest request = new RemoveDocumentsRequest();
query.setResourceClass(resourceClass); request.setDataResourceAbstractName(resourceName);
query.setResourceID(ID); RemoveDocumentRequestWrapper[] wrappers = new RemoveDocumentRequestWrapper[1];
List<GCUBEResource> resource = client.execute(query, GHNContext.getContext().getDefaultScope()); wrappers[0] = new RemoveDocumentRequestWrapper();
if (resource != null) return resource.get(0); wrappers[0].setDocumentName(documentName);
else return null; 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 { private void getSinks(final ServiceMap map) throws Exception {