This commit is contained in:
Manuele Simi 2008-04-22 20:18:06 +00:00
parent 1484ce8f50
commit 988510b4c3
3 changed files with 97 additions and 25 deletions

View File

@ -169,8 +169,7 @@ public class RegistryFactory extends GCUBEStartupPortType{
//check ID
if (resource.getID()== null || resource.getID().compareTo("")==0) {resource.setID(uuidgen.nextUUID()); }
}
catch (Exception ex)
{
catch (Exception ex) {
logger.error("Error trying to load profile", ex);
throw new SchemaValidationFault();
}
@ -364,10 +363,9 @@ public class RegistryFactory extends GCUBEStartupPortType{
* @return the resource ( null if the resource has not been created yet
*/
protected synchronized ProfileResource getProfileResource(String id ){
ProfileResource resource = null;
ResourceKey key = ProfileContext.getContext().makeKey( id);
ProfileResource resource = null;
try {
resource = (ProfileResource) ProfileContext.getContext().getWSHome().find(key);
resource = (ProfileResource) ProfileContext.getContext().getWSHome().find(ProfileContext.getContext().makeKey(id));
}
catch (Exception e ){
logger.debug("A profile with the given id has not been created yet");

View File

@ -1,5 +1,7 @@
package org.gcube.informationsystem.registry.impl.core;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import javax.xml.namespace.QName;
@ -92,11 +94,13 @@ public class RegistryFactoryResource extends GCUBEWSResource {
* @throws Exception Exception
*/
protected void initialise(Object... o) throws ResourceException {
logger.debug("Starting RegistryFactoryService");
logger.debug("Initialising the RegistryFactoryresource...");
/* Initialize the RP's */
this.initialiseRPs();
logger.debug("RegistryFactoryResource RPs initialised");
try {
//Topic List creation for registrationto is-Notifier
//Topic List creation for registration to IS-Notifier
listQname = new ArrayList<QName>();
for (String rpName : RPNames)
listQname.add(new QName(this.getPorttypeContext().getNamespace(),rpName));
@ -108,8 +112,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
e.printStackTrace();
logger.error("Error on Registration Thread",e);
}
//GHNContext.getImplementation(ISPublisher.class).registerWSResource(this,GHNContext.getContext().getDefaultScope());
//GHNContext.getImplementation(ISPublisher.class).registerWSResource(this,GHNContext.getContext().getDefaultScope());
} catch (Exception e) {
logger.error("Error on Initialization of Resource",e);
throw new ResourceException("Failed to initialise the RPs and related topics");
@ -129,7 +132,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
public void setRunningInstance (RegistryProperty property) {
this.getResourcePropertySet().get(RunningInstanceRP).clear();
this.getResourcePropertySet().get(RunningInstanceRP).add(property);
this.getPersistenceDelegate().store(this);
//this.getPersistenceDelegate().store(this);
}
@ -154,7 +157,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
public void setExternalRunningInstance (RegistryProperty property) {
this.getResourcePropertySet().get(ExternalRunningInstanceRP).clear();
this.getResourcePropertySet().get(ExternalRunningInstanceRP).add(property);
this.getPersistenceDelegate().store(this);
//this.getPersistenceDelegate().store(this);
}
@ -181,7 +184,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
public void setService (RegistryProperty property) {
this.getResourcePropertySet().get(ServiceRP).clear();
this.getResourcePropertySet().get(ServiceRP).add(property);
this.getPersistenceDelegate().store(this);
//this.getPersistenceDelegate().store(this);
}
@ -207,7 +210,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
public void setCollection (RegistryProperty property) {
this.getResourcePropertySet().get(CollectionRP).clear();
this.getResourcePropertySet().get(CollectionRP).add(property);
this.getPersistenceDelegate().store(this);
//this.getPersistenceDelegate().store(this);
}
@ -232,7 +235,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
public void setCS (RegistryProperty property) {
this.getResourcePropertySet().get(CSRP).clear();
this.getResourcePropertySet().get(CSRP).add(property);
this.getPersistenceDelegate().store(this);
//this.getPersistenceDelegate().store(this);
}
@ -257,7 +260,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
public void setCSInstance (RegistryProperty property) {
this.getResourcePropertySet().get(CSInstanceRP).clear();
this.getResourcePropertySet().get(CSInstanceRP).add(property);
this.getPersistenceDelegate().store(this);
//this.getPersistenceDelegate().store(this);
}
@ -283,7 +286,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
public void setGHN (RegistryProperty property) {
this.getResourcePropertySet().get(GHNRP).clear();
this.getResourcePropertySet().get(GHNRP).add(property);
this.getPersistenceDelegate().store(this);
//this.getPersistenceDelegate().store(this);
}
@ -307,7 +310,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
public void setGLiteSE (RegistryProperty property) {
this.getResourcePropertySet().get(gLiteSERP).clear();
this.getResourcePropertySet().get(gLiteSERP).add(property);
this.getPersistenceDelegate().store(this);
//this.getPersistenceDelegate().store(this);
}
/**
@ -331,7 +334,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
public void setGLiteCE (RegistryProperty property) {
this.getResourcePropertySet().get(gLiteCERP).clear();
this.getResourcePropertySet().get(gLiteCERP).add(property);
this.getPersistenceDelegate().store(this);
//this.getPersistenceDelegate().store(this);
}
@ -357,7 +360,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
public void setGLiteSite (RegistryProperty property) {
this.getResourcePropertySet().get(gLiteSiteRP).clear();
this.getResourcePropertySet().get(gLiteSiteRP).add(property);
this.getPersistenceDelegate().store(this);
//this.getPersistenceDelegate().store(this);
}
@ -382,7 +385,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
public void setGLiteService (RegistryProperty property) {
this.getResourcePropertySet().get(gLiteServiceRP).clear();
this.getResourcePropertySet().get(gLiteServiceRP).add(property);
this.getPersistenceDelegate().store(this);
//this.getPersistenceDelegate().store(this);
}
@ -406,7 +409,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
public void setVRE (RegistryProperty property) {
this.getResourcePropertySet().get(VRERP).clear();
this.getResourcePropertySet().get(VRERP).add(property);
this.getPersistenceDelegate().store(this);
//this.getPersistenceDelegate().store(this);
}
@ -431,7 +434,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
public void setMetaColl (RegistryProperty property) {
this.getResourcePropertySet().get(MetadataCollectionRP).clear();
this.getResourcePropertySet().get(MetadataCollectionRP).add(property);
this.getPersistenceDelegate().store(this);
//this.getPersistenceDelegate().store(this);
}
@ -456,7 +459,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
public void setTransProgram (RegistryProperty property) {
this.getResourcePropertySet().get(TransformationProgramRP).clear();
this.getResourcePropertySet().get(TransformationProgramRP).add(property);
this.getPersistenceDelegate().store(this);
//this.getPersistenceDelegate().store(this);
}
@ -481,7 +484,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
public void setGenericResource (RegistryProperty property) {
this.getResourcePropertySet().get(GenericRP).clear();
this.getResourcePropertySet().get(GenericRP).add(property);
this.getPersistenceDelegate().store(this);
//this.getPersistenceDelegate().store(this);
}
/**
@ -495,5 +498,71 @@ public class RegistryFactoryResource extends GCUBEWSResource {
}
private void initialiseRPs() {
RegistryProperty property = new RegistryProperty();
/*for (Method method :this.getClass().getDeclaredMethods()) {
if (method.getName().contains("set")) {
try {
method.invoke(this,property);
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
}
break;
}
}*/
this.getResourcePropertySet().get(RunningInstanceRP).clear();
this.getResourcePropertySet().get(RunningInstanceRP).add(property);
this.getResourcePropertySet().get(ExternalRunningInstanceRP).clear();
this.getResourcePropertySet().get(ExternalRunningInstanceRP).add(property);
this.getResourcePropertySet().get(ServiceRP).clear();
this.getResourcePropertySet().get(ServiceRP).add(property);
this.getResourcePropertySet().get(CollectionRP).clear();
this.getResourcePropertySet().get(CollectionRP).add(property);
this.getResourcePropertySet().get(CSRP).clear();
this.getResourcePropertySet().get(CSRP).add(property);
this.getResourcePropertySet().get(CSInstanceRP).clear();
this.getResourcePropertySet().get(CSInstanceRP).add(property);
this.getResourcePropertySet().get(GHNRP).clear();
this.getResourcePropertySet().get(GHNRP).add(property);
this.getResourcePropertySet().get(gLiteCERP).clear();
this.getResourcePropertySet().get(gLiteCERP).add(property);
this.getResourcePropertySet().get(gLiteSERP).clear();
this.getResourcePropertySet().get(gLiteSERP).add(property);
this.getResourcePropertySet().get(gLiteServiceRP).clear();
this.getResourcePropertySet().get(gLiteServiceRP).add(property);
this.getResourcePropertySet().get(gLiteSiteRP).clear();
this.getResourcePropertySet().get(gLiteSiteRP).add(property);
this.getResourcePropertySet().get(VRERP).clear();
this.getResourcePropertySet().get(VRERP).add(property);
this.getResourcePropertySet().get(MetadataCollectionRP).clear();
this.getResourcePropertySet().get(MetadataCollectionRP).add(property);
this.getResourcePropertySet().get(GenericRP).clear();
this.getResourcePropertySet().get(GenericRP).add(property);
this.getResourcePropertySet().get(TransformationProgramRP).clear();
this.getResourcePropertySet().get(TransformationProgramRP).add(property);
}
}

View File

@ -10,6 +10,7 @@ import org.gcube.common.core.informationsystem.publisher.ISPublisherException;
import org.gcube.common.core.resources.GCUBEHostingNode;
import org.gcube.common.core.resources.GCUBEResource;
import org.gcube.common.core.resources.GCUBERunningInstance;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.informationsystem.registry.impl.core.RegistryConfiguration.ROOT_SERVICES;
/**
@ -49,14 +50,18 @@ public class ServiceContext extends GCUBEServiceContext {
protected void onReady() throws Exception {
//GCUBERunningInstance GHNManagerProfile = null;
//creates the single RegistryResource used to raise notifications about profiles' changes
logger.info("Creating IS-Registry notification resource...");
new Thread() {
public void run() {
try {
Thread.sleep(5000);
FactoryContext.getContext().getWSHome().create(
ServiceContext.getContext().setScope(ServiceContext.getContext().getInstance().getScopes().values().toArray(new GCUBEScope[0])[0]);
RegistryFactoryResource resource = (RegistryFactoryResource) FactoryContext.getContext().getWSHome().create(
FactoryContext.getContext().makeKey(RegistryFactory.NOTIFICATOR_RESOURCE_KEY));
resource.getPersistenceDelegate().store(resource );
} catch (Exception e) {
ServiceContext.this.logger.error("Failed to create the notification resource", e);
}