Early implementation of the new design

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@34300 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Manuele Simi 2011-01-27 01:52:11 +00:00
parent 106e858284
commit 5747a6b48f
13 changed files with 244 additions and 433 deletions

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry excluding="src/|build/|schema/|etc/|src/|lib/" kind="src" path=""/> <classpathentry excluding="src/|build/|schema/|etc/|src/|lib/|test/" kind="src" path=""/>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.USER_LIBRARY/GCORELIBS"/> <classpathentry exported="true" kind="con" path="org.eclipse.jdt.USER_LIBRARY/GCORELIBS"/>
<classpathentry combineaccessrules="false" kind="src" path="/DISTRO.RESOURCES"/> <classpathentry combineaccessrules="false" kind="src" path="/DISTRO.RESOURCES"/>

View File

@ -48,7 +48,7 @@
</parameter> </parameter>
<parameter> <parameter>
<name>mode</name> <name>mode</name>
<value>pull</value> <value>push</value>
</parameter> </parameter>
<parameter> <parameter>
<name>fileName</name> <name>fileName</name>
@ -69,12 +69,7 @@
<name>resourceClass</name> <name>resourceClass</name>
<value>org.gcube.informationsystem.registry.impl.state.ProfileResource <value>org.gcube.informationsystem.registry.impl.state.ProfileResource
</value> </value>
</parameter> </parameter>
<parameter>
<name>persistenceDelegateClass</name>
<value>org.gcube.informationsystem.registry.impl.persistence.RegistryPersistenceDelegate
</value>
</parameter>
<parameter> <parameter>
<name>sweeperDelay</name> <name>sweeperDelay</name>
<value>10000</value> <value>10000</value>
@ -106,12 +101,7 @@
<name>resourceClass</name> <name>resourceClass</name>
<value>org.gcube.informationsystem.registry.impl.state.RegistryFactoryResource <value>org.gcube.informationsystem.registry.impl.state.RegistryFactoryResource
</value> </value>
</parameter> </parameter>
<parameter>
<name>persistenceDelegateClass</name>
<value>org.gcube.informationsystem.registry.impl.persistence.RegistryFactoryPersistenceDelegate
</value>
</parameter>
</resourceParams> </resourceParams>

View File

@ -12,7 +12,7 @@
<parameter name="handlerClass" value="org.globus.axis.providers.RPCProvider"/> <parameter name="handlerClass" value="org.globus.axis.providers.RPCProvider"/>
<parameter name="scope" value="Application"/> <parameter name="scope" value="Application"/>
<parameter name="providers" value="GCUBEProvider SubscribeProvider DestroyProvider GetCurrentMessageProvider "/> <parameter name="providers" value="GCUBEProvider SubscribeProvider DestroyProvider GetCurrentMessageProvider "/>
<parameter name="loadOnStartup" value="false"/> <parameter name="loadOnStartup" value="true"/>
<!-- <parameter name="securityDescriptor" value="@config.dir@/security-descriptor-Service.xml"/> --> <!-- <parameter name="securityDescriptor" value="@config.dir@/security-descriptor-Service.xml"/> -->
</service> </service>

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<securityConfig xmlns="http://www.globus.org" >
<authz value="none"/>
<method name="createResource">
<auth-method>
<GSISecureConversation>
</GSISecureConversation>
</auth-method>
<run-as>
<caller-identity/>
</run-as>
</method>
<method name="updateResource">
<auth-method>
<GSISecureConversation>
</GSISecureConversation>
</auth-method>
<run-as>
<caller-identity/>
</run-as>
</method>
<method name="removeResource">
<auth-method>
<GSISecureConversation>
</GSISecureConversation>
</auth-method>
<run-as>
<caller-identity/>
</run-as>
</method>
<method name="updateProfileWithDL">
<auth-method>
<GSISecureConversation>
</GSISecureConversation>
</auth-method>
<run-as>
<caller-identity/>
</run-as>
</method>
<method name="removeProfileWithDL">
<auth-method>
<GSISecureConversation>
</GSISecureConversation>
</auth-method>
<run-as>
<caller-identity/>
</run-as>
</method>
<method name="updateState">
<auth-method>
<GSISecureConversation>
</GSISecureConversation>
</auth-method>
<run-as>
<caller-identity/>
</run-as>
</method>
<method name="startRegistration">
<auth-method>
<GSISecureConversation>
</GSISecureConversation>
</auth-method>
<run-as>
<caller-identity/>
</run-as>
</method>
<method name="validateProfile">
<auth-method>
<GSISecureConversation>
</GSISecureConversation>
</auth-method>
<run-as>
<caller-identity/>
</run-as>
</method>
<method name="getMultipleResourceProperties">
<auth-method>
<none/>
</auth-method>
</method>
<method name="queryResourceProperties">
<auth-method>
<none/>
</auth-method>
</method>
<method name="subscribe">
<auth-method>
<none/>
</auth-method>
</method>
<method name="getCurrentMessage">
<auth-method>
<none/>
</auth-method>
</method>
</securityConfig>

View File

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<securityConfig xmlns="http://www.globus.org" >
<authz value="none"/>
<method name="getMultipleResourceProperties">
<auth-method>
<none/>
</auth-method>
</method>
<method name="queryResourceProperties">
<auth-method>
<none/>
</auth-method>
</method>
<method name="subscribe">
<auth-method>
<none/>
</auth-method>
</method>
<method name="getCurrentMessage">
<auth-method>
<none/>
</auth-method>
</method>
</securityConfig>

View File

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="Registry"
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">
<types>
<xsd:schema targetNamespace="http://gcube-system.org/namespaces/informationsystem/registry"
xmlns:tns="http://gcube-system.org/namespaces/informationsystem/registry"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="SchemaValidationFaultType"/>
<xsd:element name="SchemaValidationFault" type="SchemaValidationFaultType"/>
<xsd:complexType name="ResourceNotAcceptedFaultType"/>
<xsd:element name="ResourceNotAcceptedFault" type="ResourceNotAcceptedFaultType"/>
<xsd:complexType name="CreateFaultType"/>
<xsd:element name="CreateFault" type="CreateFaultType"/>
<xsd:complexType name="UpdateFaultType"/>
<xsd:element name="UpdateFault" type="UpdateFaultType"/>
<xsd:complexType name="RemoveFaultType"/>
<xsd:element name="RemoveFault" type="RemoveFaultType"/>
<xsd:complexType name="ResourceDoesNotExistFaultType"/>
<xsd:element name="ResourceDoesNotExistFault" type="ResourceDoesNotExistFaultType"/>
</xsd:schema>
</types>
<message name="CreateRequest">
<part name="request" element="tns:createResource"/>
</message>
<message name="CreateResponse">
<part name="response" element="tns:createResponse"/>
</message>
<message name="UpdateRequest">
<part name="request" element="tns:updateResource"/>
</message>
<message name="UpdateResponse">
<part name="response" element="tns:updateResponse"/>
</message>
<message name="RemoveRequest">
<part name="request" element="tns:removeResource"/>
</message>
<message name="RemoveResponse">
<part name="response" element="tns:removeResponse"/>
</message>
<message name="SchemaValidationFaultMessage">
<part name="fault" element="tns:SchemaValidationFault"/>
</message>
<message name="ResourceNotAcceptedFaultMessage">
<part name="fault" element="tns:ResourceNotAcceptedFault"/>
</message>
<message name="CreateFaultMessage">
<part name="fault" element="tns:CreateFault"/>
</message>
<message name="UpdateFaultMessage">
<part name="fault" element="tns:UpdateFault"/>
</message>
<message name="RemoveFaultMessage">
<part name="fault" element="tns:RemoveFault"/>
</message>
<message name="ResourceDoesNotExistFaultMessage">
<part name="fault" element="tns:ResourceDoesNotExistFault"/>
</message>
<!--============================================================
P O R T T Y P E
============================================================-->
<portType name="ResourceRegistrationPortType">
<operation name="create">
<input message="tns:CreateRequest"/>
<output message="tns:CreateResponse"/>
<fault name="fault" message="tns:SchemaValidationFaultMessage"/>
<fault name="fault" message="tns:ResourceNotAcceptedFaultMessage"/>
<fault name="fault" message="tns:CreateFaultMessage"/>
</operation>
<operation name="update">
<input message="tns:UpdateRequest"/>
<output message="tns:UpdateResponse"/>
<fault name="fault" message="tns:SchemaValidationFaultMessage"/>
<fault name="fault" message="tns:ResourceNotAcceptedFaultMessage"/>
<fault name="fault" message="tns:UpdateFaultMessage"/>
</operation>
<operation name="remove">
<input message="tns:RemoveRequest"/>
<output message="tns:RemoveResponse"/>
<fault name="fault" message="tns:RemoveFaultMessage"/>
<fault name="fault" message="tns:ResourceDoesNotExistFaultMessage"/>
</operation>
</portType>
</definitions>

View File

@ -158,7 +158,10 @@ public class ServiceContext extends GCUBEServiceContext {
/**
* Listeners for local events
* @throws Exception
*/
private void subscribeToLocalRegistrationEvents() throws Exception{ private void subscribeToLocalRegistrationEvents() throws Exception{
ISLocalPublisher pub = GHNContext.getImplementation(ISLocalPublisher.class); ISLocalPublisher pub = GHNContext.getImplementation(ISLocalPublisher.class);
LocalProfileConsumer cons = new LocalProfileConsumer() { LocalProfileConsumer cons = new LocalProfileConsumer() {
@ -167,21 +170,29 @@ public class ServiceContext extends GCUBEServiceContext {
* @see org.gcube.common.core.informationsystem.publisher.ISLocalPublisher.LocalProfileConsumer#onProfileRegistered(org.gcube.common.core.resources.GCUBEResource) * @see org.gcube.common.core.informationsystem.publisher.ISLocalPublisher.LocalProfileConsumer#onProfileRegistered(org.gcube.common.core.resources.GCUBEResource)
*/ */
@Override @Override
protected void onProfileRegistered(GCUBEResource resource, GCUBEScope scope) { protected void onProfileRegistered(final GCUBEResource resource, final GCUBEScope scope) {
logger.debug("onProfileRegistered event received" ); logger.debug("onProfileRegistered event received in scope " + scope );
RegistryFactory factory= new RegistryFactory(); new Thread() {
try { @Override
ServiceContext.getContext().setScope(scope); public void run() {
CreateResourceMessage crm = new CreateResourceMessage(); ServiceContext.this.waitUntilReady();
StringWriter writer = new StringWriter(); RegistryFactory factory= new RegistryFactory();
resource.store(writer); try {
crm.setProfile(writer.toString()); ServiceContext.getContext().setScope(scope);
crm.setType(resource.getType()); CreateResourceMessage crm = new CreateResourceMessage();
factory.createResource(crm); StringWriter writer = new StringWriter();
logger.trace("create Event handled"); resource.store(writer);
} catch (Exception e) { crm.setProfile(writer.toString());
logger.error("cannot handle the create resource event"+e); crm.setType(resource.getType());
} //crm.setScopes(new String[] {scope.toString()});
factory.createResource(crm);
} catch (Exception e) {
logger.error("cannot handle the create resource event"+e);
}
}
}.start();
} }
@ -189,19 +200,25 @@ public class ServiceContext extends GCUBEServiceContext {
* @see org.gcube.common.core.informationsystem.publisher.ISLocalPublisher.LocalProfileConsumer#onProfileRemoved(java.lang.String, java.lang.String) * @see org.gcube.common.core.informationsystem.publisher.ISLocalPublisher.LocalProfileConsumer#onProfileRemoved(java.lang.String, java.lang.String)
*/ */
@Override @Override
protected void onProfileRemoved(String resourceID, String type, GCUBEScope scope) { protected void onProfileRemoved(final String resourceID, final String type, final GCUBEScope scope) {
ServiceContext.getContext().setScope(scope); logger.debug("onProfileRemoved event received" );
RegistryFactory factory= new RegistryFactory(); new Thread() {
RemoveResourceMessage rrm= new RemoveResourceMessage(); @Override
rrm.setType(type); public void run() {
rrm.setUniqueID(resourceID); ServiceContext.this.waitUntilReady();
logger.trace("remove Event handled"); ServiceContext.getContext().setScope(scope);
try { RegistryFactory factory= new RegistryFactory();
factory.removeResource(rrm); RemoveResourceMessage rrm= new RemoveResourceMessage();
} catch (Exception e) { rrm.setType(type);
logger.error("cannot handle the remove resource event"+e); rrm.setUniqueID(resourceID);
try {
} factory.removeResource(rrm);
} catch (Exception e) {
logger.error("cannot handle the remove resource event"+e);
}
}
}.start();
} }
@ -209,28 +226,46 @@ public class ServiceContext extends GCUBEServiceContext {
* @see org.gcube.common.core.informationsystem.publisher.ISLocalPublisher.LocalProfileConsumer#onProfileUpdated(org.gcube.common.core.resources.GCUBEResource) * @see org.gcube.common.core.informationsystem.publisher.ISLocalPublisher.LocalProfileConsumer#onProfileUpdated(org.gcube.common.core.resources.GCUBEResource)
*/ */
@Override @Override
protected void onProfileUpdated(GCUBEResource resource, GCUBEScope scope) { protected void onProfileUpdated(final GCUBEResource resource, final GCUBEScope scope) {
logger.debug("onProfileUpdated event received" ); logger.debug("onProfileUpdated event received" );
ServiceContext.getContext().setScope(scope); new Thread() {
RegistryFactory factory= new RegistryFactory(); @Override
try { public void run() {
UpdateResourceMessage urm= new UpdateResourceMessage(); ServiceContext.this.waitUntilReady();
StringWriter writer = new StringWriter(); ServiceContext.getContext().setScope(scope);
resource.store(writer); RegistryFactory factory= new RegistryFactory();
urm.setXmlProfile(writer.toString()); try {
urm.setType(resource.getType()); UpdateResourceMessage urm= new UpdateResourceMessage();
urm.setUniqueID(resource.getID()); StringWriter writer = new StringWriter();
factory.updateResource(urm); resource.store(writer);
logger.trace("Update Event handled"); urm.setXmlProfile(writer.toString());
} catch (Exception e) { urm.setType(resource.getType());
logger.error("cannot handle the update resource event"+e); urm.setUniqueID(resource.getID());
} factory.updateResource(urm);
} catch (Exception e) {
logger.error("cannot handle the update resource event"+e);
}
}
}.start();
} }
}; };
pub.subscribeLocalProfileEvents(cons); pub.subscribeLocalProfileEvents(cons);
} }
private void waitUntilReady() {
while (true) {
if (ServiceContext.getContext().getStatus() != Status.READIED)
break;
else
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
break;
}
}
}
} }

View File

@ -1,59 +0,0 @@
package org.gcube.informationsystem.registry.impl.persistence;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import org.gcube.common.core.persistence.GCUBEWSFilePersistenceDelegate;
import org.gcube.informationsystem.registry.impl.state.RegistryFactoryResource;
import org.gcube.informationsystem.registry.stubs.RegistryProperty;
import org.globus.wsrf.utils.SubscriptionPersistenceUtils;
public class RegistryFactoryPersistenceDelegate extends GCUBEWSFilePersistenceDelegate<RegistryFactoryResource>{
protected void onLoad(RegistryFactoryResource resource, ObjectInputStream ois) throws Exception {
super.onLoad(resource, ois);
resource.setGLiteCE((RegistryProperty)ois.readObject());
resource.setGLiteSE((RegistryProperty)ois.readObject());
resource.setGLiteService((RegistryProperty)ois.readObject());
resource.setGLiteSite((RegistryProperty)ois.readObject());
resource.setCollection((RegistryProperty)ois.readObject());
resource.setCS((RegistryProperty)ois.readObject());
resource.setCSInstance((RegistryProperty)ois.readObject());
resource.setGHN((RegistryProperty)ois.readObject());
resource.setExternalRunningInstance((RegistryProperty)ois.readObject());
resource.setMetadataCollection((RegistryProperty)ois.readObject());
resource.setRunningInstance((RegistryProperty)ois.readObject());
resource.setService((RegistryProperty)ois.readObject());
resource.setVRE((RegistryProperty)ois.readObject());
resource.setGenericResource((RegistryProperty)ois.readObject());
SubscriptionPersistenceUtils.loadSubscriptionListeners(
resource.getTopicList(), ois);
}
protected void onStore(RegistryFactoryResource resource,ObjectOutputStream oos) throws Exception {
super.onStore(resource, oos);
oos.writeObject(resource.getGLiteCE());
oos.writeObject(resource.getGLiteSE());
oos.writeObject(resource.getGLiteService());
oos.writeObject(resource.getGLiteSite());
oos.writeObject(resource.getCollection());
oos.writeObject(resource.getCS());
oos.writeObject(resource.getCSInstance());
oos.writeObject(resource.getGHN());
oos.writeObject(resource.getExternalRunningInstance());
oos.writeObject(resource.getMetadataCollection());
oos.writeObject(resource.getRunningInstance());
oos.writeObject(resource.getService());
oos.writeObject(resource.getVRE());
oos.writeObject(resource.getGenericResource());
SubscriptionPersistenceUtils.storeSubscriptionListeners(
resource.getTopicList(), oos);
}
}

View File

@ -1,25 +0,0 @@
package org.gcube.informationsystem.registry.impl.persistence;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import org.gcube.common.core.persistence.GCUBEWSFilePersistenceDelegate;
import org.gcube.informationsystem.registry.impl.state.ProfileResource;
import org.w3c.dom.Document;
public class RegistryPersistenceDelegate extends GCUBEWSFilePersistenceDelegate<ProfileResource> {
protected void onLoad(ProfileResource resource, ObjectInputStream ois) throws Exception {
super.onLoad(resource, ois);
resource.setProfile((Document)ois.readObject());
//resource.setNotificationProfile(resource.getProfile());
}
protected void onStore(ProfileResource resource,ObjectOutputStream oos) throws Exception {
super.onStore(resource, oos);
oos.writeObject((Document)resource.getProfile());
}
}

View File

@ -20,6 +20,7 @@ import org.gcube.common.core.porttypes.GCUBEPortType;
import org.gcube.common.core.resources.GCUBEHostingNode; import org.gcube.common.core.resources.GCUBEHostingNode;
import org.gcube.common.core.resources.GCUBEResource; import org.gcube.common.core.resources.GCUBEResource;
import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.state.GCUBEWSResourceKey;
import org.gcube.common.core.utils.events.GCUBEEvent; import org.gcube.common.core.utils.events.GCUBEEvent;
import org.gcube.common.core.utils.logging.GCUBELog; import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.informationsystem.registry.impl.contexts.FactoryContext; import org.gcube.informationsystem.registry.impl.contexts.FactoryContext;
@ -41,7 +42,8 @@ import org.gcube.informationsystem.registry.stubs.ResourceNotAcceptedFault;
import org.gcube.informationsystem.registry.stubs.SchemaValidationFault; import org.gcube.informationsystem.registry.stubs.SchemaValidationFault;
import org.gcube.informationsystem.registry.stubs.UpdateResourceMessage; import org.gcube.informationsystem.registry.stubs.UpdateResourceMessage;
import org.gcube.informationsystem.registry.stubs.UpdateResourceResponse; import org.gcube.informationsystem.registry.stubs.UpdateResourceResponse;
import static org.gcube.informationsystem.registry.impl.core.RegistryConfiguration.ResourceType;
import static org.gcube.informationsystem.registry.impl.state.Definitions.ResourceType;
/** /**
* Implementation of the <em>Registry Factory</em> portType * Implementation of the <em>Registry Factory</em> portType
@ -112,7 +114,7 @@ public class RegistryFactory extends GCUBEPortType {
GCUBEResource resource = null; GCUBEResource resource = null;
logger.info("CreateResource operation invoked"); logger.info("CreateResource operation invoked in scope " + ServiceContext.getContext().getScope());
// logSecurityInfo("createResource"); // logSecurityInfo("createResource");
String profile = mess.getProfile(); String profile = mess.getProfile();
@ -173,9 +175,9 @@ public class RegistryFactory extends GCUBEPortType {
// try to create resource // try to create resource
try { try {
logger.debug("Creating the stateful resource N."+ ++resourceCounter + " for " + resource.getID()); logger.debug("Creating the stateful resource N."+ ++resourceCounter + " for " + resource.getID());
GCUBEWSResourceKey key = ProfileContext.getContext().makeKey(resource.getID());
ProfileResource presource = (ProfileResource) ProfileContext logger.trace("Resource key is " + key);
.getContext().getWSHome().create(ProfileContext.getContext().makeKey(resource.getID()), resource); ProfileResource presource = (ProfileResource) ProfileContext.getContext().getWSHome().create(key, resource);
presource.store(); presource.store();
// Deleting the WSResource created if != from GHN || RI // Deleting the WSResource created if != from GHN || RI
@ -202,14 +204,15 @@ public class RegistryFactory extends GCUBEPortType {
StringWriter writer = new StringWriter(); StringWriter writer = new StringWriter();
try { try {
logger.debug("Persisting the stateful resource for " + resource.getID());
resource.store(writer); resource.store(writer);
logger.info("Profile " + resource.getID() + " created ");
return writer.toString();
} catch (Exception e) { } catch (Exception e) {
logger.error("Persistence failed for " + resource.getID(), e); logger.error("Persistence failed for " + resource.getID(), e);
return null;
} }
logger.info("Profile " + resource.getID() + " created ");
return writer.toString();
} }
/** /**
@ -324,25 +327,19 @@ public class RegistryFactory extends GCUBEPortType {
String ID = inputMessage.getUniqueID(); String ID = inputMessage.getUniqueID();
String type = inputMessage.getType(); String type = inputMessage.getType();
logger.info("RemoveResource operation invoked on resource ID=" + ID logger.info("RemoveResource operation invoked on resource ID=" + ID + ", type=" + type);
+ ", type=" + type);
if (ID == null || ID.compareTo("") == 0) { if (ID == null || ID.compareTo("") == 0) {
logger.warn("Resource ID is missing, cannot manage the resource"); logger.warn("Resource ID is missing, cannot manage the resource");
throw new RemoteException( throw new RemoteException("Resource ID is missing, cannot manage the resource");
"Resource ID is missing, cannot manage the resource");
} }
//TODO: delete the profile with the GCUBEPublisher
try { try {
logger.debug("Trying to remove the resource from the IS-IC"); logger.debug("Trying to remove the resource from the IS-IC");
new ProfileManager().removeFromISIC(ID, type, ServiceContext new ProfileManager().remove(ID, type, ServiceContext.getContext().getScope(), ServiceContext.getContext());
.getContext().getScope(), ServiceContext.getContext());
logger.info("Resource removed from the IS-IC"); logger.info("Resource removed from the IS-IC");
} catch (Exception e) { } catch (Exception e) {
logger.error("Unable to remove the resource", e); logger.error("Unable to remove the resource", e);
throw ServiceContext throw ServiceContext.getContext().getDefaultException("", e).toFault(
.getContext()
.getDefaultException("", e)
.toFault(
"Unable to remove the resource: the remote IS-IC returned an error"); "Unable to remove the resource: the remote IS-IC returned an error");
} }
// if the resource is a GHN, remove also the related RIs // if the resource is a GHN, remove also the related RIs
@ -354,16 +351,14 @@ public class RegistryFactory extends GCUBEPortType {
logger.debug("Related RIs removed"); logger.debug("Related RIs removed");
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("Error while removing RI profiles related to the GHN", logger.error("Error while removing RI profiles related to the GHN", e);
e);
} }
if (this.isResourceCreated(ID)) { if (this.isResourceCreated(ID)) {
// destroy the resource // destroy the resource
try { try {
logger.debug("Destroying the local stateful Resoruce"); logger.debug("Destroying the local stateful Resoruce");
ProfileContext.getContext().getWSHome().remove( ProfileContext.getContext().getWSHome().remove(ProfileContext.getContext().makeKey(ID));
ProfileContext.getContext().makeKey(ID));
logger.info(" Resource Destroyed"); logger.info(" Resource Destroyed");
} catch (Exception e) { } catch (Exception e) {
logger.error("Error removing resource for ID ", e); logger.error("Error removing resource for ID ", e);
@ -371,14 +366,11 @@ public class RegistryFactory extends GCUBEPortType {
} }
try { try {
GCUBEEvent<ServiceContext.RegistryTopic, GCUBEResource> event = new GCUBEEvent<ServiceContext.RegistryTopic, GCUBEResource>(); GCUBEEvent<ServiceContext.RegistryTopic, GCUBEResource> event = new GCUBEEvent<ServiceContext.RegistryTopic, GCUBEResource>();
GCUBEResource resource = ResourceType.valueOf(type) GCUBEResource resource = ResourceType.valueOf(type).getResourceClass();
.getResourceClass();
resource.setID(ID); resource.setID(ID);
event.setPayload(resource); event.setPayload(resource);
ServiceContext.getContext().getTopicProducer().notify( ServiceContext.getContext().getTopicProducer().notify(ServiceContext.RegistryTopic.REMOVE, event);
ServiceContext.RegistryTopic.REMOVE, event); updateCounterInfo(ID, ResourceType.valueOf(type),OperationType.destroy, Calendar.getInstance(), null);
updateCounterInfo(ID, ResourceType.valueOf(type),
OperationType.destroy, Calendar.getInstance(), null);
} catch (Exception e) { } catch (Exception e) {
logger.warn( logger.warn(
"Error updating counting info for resource with ID " "Error updating counting info for resource with ID "

View File

@ -0,0 +1,14 @@
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;
public class ResourceRegistration extends GCUBEPortType {
@Override
protected GCUBEServiceContext getServiceContext() {
return ServiceContext.getContext();
}
}

View File

@ -11,6 +11,7 @@ import org.apache.axis.message.addressing.EndpointReferenceType;
import org.apache.axis.types.URI; 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.resources.GCUBEResource;
import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.scope.GCUBEScopeNotSupportedException; import org.gcube.common.core.scope.GCUBEScopeNotSupportedException;
import org.gcube.common.core.scope.ServiceMap; import org.gcube.common.core.scope.ServiceMap;
@ -57,20 +58,21 @@ public class ProfileManager {
VOMapName = scope.getName(); VOMapName = scope.getName();
} }
public void add(GCUBEResource resource, GCUBEScope scope, GCUBEServiceSecurityManager manager) throws Exception {
}
/** /**
* Removes from IS-IC a GCUBEResource profile ( not knowing the Resurce Type * Removes a {@link GCUBEResource} from the IS
* the removal has been done once for every type of GCUBE Resource
* *
* @param uniqueID * @param uniqueID the uniqueID to of the GCUBEResource to remove
* the uniqueID to of the GCUBEResource to remove * @param type the type of Profile
* @param type
* the type of Profile
* *
* @throws Exception * @throws Exception if the unregistration fails
* if the unregistration fails
*/ */
public void removeFromISIC(String uniqueID, String type, GCUBEScope scope, public void remove(String uniqueID, String type, GCUBEScope scope,
GCUBEServiceSecurityManager manager) throws Exception { GCUBEServiceSecurityManager manager) throws Exception {
for (EndpointReferenceType sink : this.ICEprs) { for (EndpointReferenceType sink : this.ICEprs) {
@ -94,7 +96,8 @@ public class ProfileManager {
// 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);
for (int n = 0; n < ResourceTypes.values().length; n++) { 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); this.removeDocuments(isIcAddress, scope, new URI("gcube://resource"),
new URI("gcube://Profiles/"+ ResourceTypes.values()[n].toString()), uniqueID);
} }
} catch (Exception e) { } catch (Exception e) {
logger.error( logger.error(
@ -131,7 +134,7 @@ public class ProfileManager {
stubs = new WsdaixServiceAddressingLocator().getXMLCollectionAccessPTPort(new URL(serviceURL)); stubs = new WsdaixServiceAddressingLocator().getXMLCollectionAccessPTPort(new URL(serviceURL));
stubs = GCUBERemotePortTypeContext.getProxy(stubs, scope); stubs = GCUBERemotePortTypeContext.getProxy(stubs, scope);
} catch (Exception e) { } catch (Exception e) {
logger.error("Failed to get documentes", e); logger.error("Failed to get documents", e);
} }
return stubs.removeDocuments(request); return stubs.removeDocuments(request);
} }

View File

@ -1,4 +1,4 @@
package org.gcube.informationsystem.registry.impl.core; package org.gcube.informationsystem.registry.impl.state;
import org.gcube.common.core.contexts.GHNContext; import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.resources.GCUBECS; import org.gcube.common.core.resources.GCUBECS;
@ -14,24 +14,13 @@ import org.gcube.common.core.resources.GCUBEService;
/** /**
* *
* Local Configuration of the IS-Registry * Collection of definitions
*
* @author Andrea Manzi, Manuele Simi (CNR)
* *
*/ */
public class RegistryConfiguration { public class Definitions {
/** The root service to take care at service's startup */
public static enum ROOT_SERVICES {
ISIC() { public String getClazz() {return "InformationSystem";} public String getName() {return "IS-IC";}},
ISNOTIFIER() {public String getClazz() {return "InformationSystem";} public String getName() {return "IS-Notifier";}},
GHNMANAGER() {public String getClazz() {return "VREManagement";} public String getName() {return "GHNManager";}},
DEPLOYER() {public String getClazz() {return "VREManagement";} public String getName() {return "Deployer";}};
abstract public String getName();
abstract public String getClazz();
}
/** The Resource Type */ /** The Resource Type */
public static enum ResourceType { public static enum ResourceType {
@ -53,89 +42,6 @@ public class RegistryConfiguration {
}; };
/**
*
*/
private String profilesBase = null;
/**
*
*/
private String propertiesFile = null;
/**
*
*/
private String registrationType = null;
/**
*
*/
private int registrationRemovalInterval = 140;
/**
* Constructor
*/
public RegistryConfiguration () {}
/**
* Get the profile base folder
* @return the profile base folder
*/
public String getProfilesBase() {
return profilesBase;
}
/**
* Set the profile base folder
*
* @param b the profile base folder
*/
public void setProfilesBase(String b) {
profilesBase = b;
}
/**
* The propertie file dir
* @return The propertie file dir
*/
public String getPropertiesFile() {
return propertiesFile;
}
/**
* Set the propertyFile dir
* @param file the file
*/
public void setPropertiesFile(String file) {
propertiesFile = file;
}
/**
* Get The Registration Type
* @return The registration Type
*/
public String getRegistrationType() {
return registrationType;
}
/**
* Set registration Type
* @param type the registration Type
*/
public void setRegistrationType(String type) {
registrationType = type;
}
/**
* Set the Registration time
* @param sec the interval
*/
public void setRegistrationRemovalInterval(int sec) {
registrationRemovalInterval = sec;
}
/**
* Get the registration time interval
* @return The Registration time
*/
public int getRegistrationRemovalInterval() {
return registrationRemovalInterval;
}
} }