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 {
@ -63,74 +73,69 @@ public class ProfileManager {
public void removeFromISIC(String uniqueID, String type, GCUBEScope scope, public void removeFromISIC(String uniqueID, String type, GCUBEScope scope,
GCUBEServiceSecurityManager manager) throws Exception { GCUBEServiceSecurityManager manager) throws Exception {
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(); if (type != null && type.compareTo("") != 0) {
params.setID(uniqueID); try {
if (type != null && type.compareTo("") != 0) { logger.debug("Removing profile from sink " + isIcAddress);
try { this.removeDocuments(isIcAddress, scope, new URI("gcube://resource"), new URI("gcube://Profiles/"+ type), uniqueID);
logger.debug("Removing profile from sink " + isIcAddress); } catch (Exception e) {
params.setProfileType(type); logger.error(
XMLCollectionAccessPortType port = new XMLCollectionAccessServiceLocator().getXMLCollectionAccessPortTypePort(new URL(isIcAddress)); "An error occurs while trying to remove the GCUBE Profile with ID "
port = GCUBERemotePortTypeContext.getProxy(port, scope, manager); + uniqueID, e);
port.deleteProfile(params); throw new Exception(
} catch (Exception e) { "Unregistration failed for the GCUBE Profile with ID "
logger.error( + uniqueID);
"An error occurs while trying to remove the GCUBE Profile with ID " }
+ uniqueID, e); } else {
throw new Exception( try {
"Unregistration failed for the GCUBE Profile with ID " // the type of the resource to delete is not specified, try
+ uniqueID); // all the resource types
} logger.debug(" trying to remove profile with UniqueID" + uniqueID);
for (int n = 0; n < ResourceTypes.values().length; n++) {
} else { this.removeDocuments(isIcAddress, scope, new URI("gcube://resource"), new URI("gcube://Profiles/"+ ResourceTypes.values()[n].toString()), uniqueID);
try { }
// the type of the resource to delete is not specified, try } catch (Exception e) {
// all the resource types logger.error(
logger.debug(" trying to remove profile with UniqueID" + uniqueID); " An error occurs while trying to remove the GCUBE Profile with ID "
XMLCollectionAccessPortType port = new XMLCollectionAccessServiceLocator().getXMLCollectionAccessPortTypePort(new URL(isIcAddress)); + uniqueID, e);
port = GCUBERemotePortTypeContext.getProxy(port, scope, manager); throw new Exception(
for (int n = 0; n < ResourceTypes.values().length; n++) { "Unregistration failed for the GCUBE Profile with ID "
params.setProfileType(ResourceTypes.values()[n].toString()); + uniqueID);
logger.debug("Removing profile from sink " + isIcAddress.toString()); }
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);
} }
}
}
} }
/** /**
* 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 private RemoveDocumentsResponse removeDocuments(String serviceURL, GCUBEScope scope,
* @throws ISException URI resourceName, URI collectionURI, String documentName)
*/ throws DataResourceUnavailableFaultType, MalformedURLException, RemoteException, ServiceBusyFaultType,
/*public static GCUBEResource getProfileFromIS(String ID, Class<? extends GCUBEResource> resourceClass) throws ISMalformedQueryException, ISInvalidQueryException, ISException { InvalidResourceNameFaultType, InvalidCollectionNameFaultType, NotAuthorizedFaultType {
RemoveDocumentsRequest request = new RemoveDocumentsRequest();
GCUBEGenericQuery query = client.getQuery("GCUBEResourceQuery"); request.setDataResourceAbstractName(resourceName);
RemoveDocumentRequestWrapper[] wrappers = new RemoveDocumentRequestWrapper[1];
GCUBEResourceFromIDQuery query =client.getQuery(GCUBEResourceFromIDQuery.class); wrappers[0] = new RemoveDocumentRequestWrapper();
query.setResourceClass(resourceClass); wrappers[0].setDocumentName(documentName);
query.setResourceID(ID); request.setRemoveDocumentRequestWrapper(wrappers);
List<GCUBEResource> resource = client.execute(query, GHNContext.getContext().getDefaultScope()); request.setCollectionName(collectionURI);
if (resource != null) return resource.get(0); XMLCollectionAccessPT stubs = null;
else return 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 {
Set<EndpointReferenceType> tmpEPRs = new HashSet<EndpointReferenceType>(); Set<EndpointReferenceType> tmpEPRs = new HashSet<EndpointReferenceType>();