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>
<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">
<Change>Classes of living resources configurable via JNDI</Change>
</Changeset>

View File

@ -18,7 +18,7 @@
<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>
<Name>IS-Registry-service</Name>
<Version>1.4.0</Version>
<Version>2.0.0</Version>
<Mandatory level="VO"/>
<Shareable level="VO"/>
<GHNRequirements>
@ -32,7 +32,7 @@
<Version>1.0.0</Version>
</Service>
<Package>IS-Registry-stubs</Package>
<Version>1.4.0</Version>
<Version>2.0.0</Version>
<Scope level="GHN"/>
<Optional>false</Optional>
</Dependency>
@ -52,7 +52,7 @@
<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>
<Name>IS-Registry-stubs</Name>
<Version>1.4.0</Version>
<Version>2.0.0</Version>
<MultiVersion value="true"/>
<Mandatory level="GHN"/>
<Shareable level="VO"/>

View File

@ -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<? extends GCUBEResource> resourceClass) throws ISMalformedQueryException, ISInvalidQueryException, ISException {
GCUBEGenericQuery query = client.getQuery("GCUBEResourceQuery");
GCUBEResourceFromIDQuery query =client.getQuery(GCUBEResourceFromIDQuery.class);
query.setResourceClass(resourceClass);
query.setResourceID(ID);
List<GCUBEResource> 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<EndpointReferenceType> tmpEPRs = new HashSet<EndpointReferenceType>();