git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@3118 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
578b34406f
commit
b64c8a8a59
|
@ -1,5 +1,12 @@
|
||||||
package org.gcube.informationsystem.registry.impl;
|
package org.gcube.informationsystem.registry.impl;
|
||||||
|
|
||||||
|
import java.io.StringWriter;
|
||||||
|
|
||||||
|
import javax.xml.transform.Transformer;
|
||||||
|
import javax.xml.transform.TransformerFactory;
|
||||||
|
import javax.xml.transform.dom.DOMSource;
|
||||||
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
|
||||||
import org.apache.axis.utils.XMLUtils;
|
import org.apache.axis.utils.XMLUtils;
|
||||||
import org.gcube.common.core.faults.GCUBEFault;
|
import org.gcube.common.core.faults.GCUBEFault;
|
||||||
import org.gcube.informationsystem.registry.impl.contexts.ProfileContext;
|
import org.gcube.informationsystem.registry.impl.contexts.ProfileContext;
|
||||||
|
@ -26,7 +33,7 @@ public class Registry {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return XMLUtils.DocumentToString(((ProfileResource)ProfileContext.getContext().getWSHome().find()).getProfile());
|
return XMLUtils.DocumentToString(((ProfileResource)ProfileContext.getContext().getWSHome().find()).getProfile());
|
||||||
} catch (ResourceException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new GCUBEFault();
|
throw new GCUBEFault();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.axis.components.uuid.UUIDGen;
|
import org.apache.axis.components.uuid.UUIDGen;
|
||||||
import org.apache.axis.components.uuid.UUIDGenFactory;
|
import org.apache.axis.components.uuid.UUIDGenFactory;
|
||||||
|
import org.apache.axis.utils.XMLUtils;
|
||||||
import org.gcube.common.core.contexts.GCUBEServiceContext;
|
import org.gcube.common.core.contexts.GCUBEServiceContext;
|
||||||
import org.gcube.common.core.contexts.GHNContext;
|
import org.gcube.common.core.contexts.GHNContext;
|
||||||
import org.gcube.common.core.faults.GCUBEFault;
|
import org.gcube.common.core.faults.GCUBEFault;
|
||||||
|
@ -138,6 +139,8 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
||||||
logger.info("CreateResource operation invoked");
|
logger.info("CreateResource operation invoked");
|
||||||
logSecurityInfo("createResource");
|
logSecurityInfo("createResource");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String profile = mess.getProfile();
|
String profile = mess.getProfile();
|
||||||
if (profile == null || profile.compareTo("") == 0) {
|
if (profile == null || profile.compareTo("") == 0) {
|
||||||
String msg = "Profile file empty";
|
String msg = "Profile file empty";
|
||||||
|
@ -156,6 +159,7 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
||||||
logger.debug("Adding Scopes to Profile "+ scope);
|
logger.debug("Adding Scopes to Profile "+ scope);
|
||||||
resource.addScope(GCUBEScope.getScope(scope));
|
resource.addScope(GCUBEScope.getScope(scope));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//check ID
|
//check ID
|
||||||
if (resource.getID()== null || resource.getID().compareTo("")==0) {resource.setID(uuidgen.nextUUID()); }
|
if (resource.getID()== null || resource.getID().compareTo("")==0) {resource.setID(uuidgen.nextUUID()); }
|
||||||
|
@ -305,12 +309,9 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
||||||
if (this.isResourceCreated(ID)){
|
if (this.isResourceCreated(ID)){
|
||||||
//destroy the resource
|
//destroy the resource
|
||||||
try{
|
try{
|
||||||
ProfileResource resource = getProfileResource(ID );
|
|
||||||
resource.removeProfile();
|
ProfileContext.getContext().getWSHome().remove(ProfileContext.getContext().makeKey(ID));
|
||||||
RegistryServiceAddressingLocator locator = new RegistryServiceAddressingLocator();
|
logger.info(" Resource Destroyed");
|
||||||
RegistryPortType portType = locator.getRegistryPortTypePort(resource.getEPR());
|
|
||||||
portType.destroy(new Destroy());
|
|
||||||
logger.info(" profile resource destroyed");
|
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
logger.error("Error removing resource for ID ", e);
|
logger.error("Error removing resource for ID ", e);
|
||||||
|
|
|
@ -77,52 +77,10 @@ public class ServiceContext extends GCUBEServiceContext {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Tries to create the resource */
|
|
||||||
protected class NotificationResource extends GCUBEHandler<Object> {
|
|
||||||
|
|
||||||
public NotificationResource() {
|
|
||||||
//register the aggregator content mapping in the current thread. This is because of the container
|
|
||||||
//behavior: it seems that
|
|
||||||
//this mapping is available only in the Main thread of the container, but not in the others
|
|
||||||
TypeMappingRegistry registry = ContainerConfig.getContext().getTypeMappingRegistry();
|
|
||||||
javax.xml.rpc.encoding.TypeMapping mapping = registry.createTypeMapping();
|
|
||||||
QName qname = new QName("http://mds.globus.org/aggregator/types","AggregatorContent");
|
|
||||||
mapping.register(AggregatorContent.class, qname,
|
|
||||||
new BeanSerializerFactory(AggregatorContent.class, qname),
|
|
||||||
new BeanDeserializerFactory(AggregatorContent.class,qname));
|
|
||||||
registry.register("", mapping);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void run() throws Exception {
|
|
||||||
|
|
||||||
List<String> pt = GHNContext.getContext().getActivePortTypes();
|
|
||||||
if ( (pt == null) || (pt.size() < 1))
|
|
||||||
throw new Exception();
|
|
||||||
|
|
||||||
try {
|
|
||||||
// register my profile
|
|
||||||
GCUBERunningInstance RegistryRIProfile = ServiceContext.getContext().getInstance();
|
|
||||||
GCUBERIQuery query = client.getQuery(GCUBERIQuery.class);
|
|
||||||
query.addAtomicConditions(new AtomicCondition("//ServiceClass", ServiceContext.this.getServiceClass()),new AtomicCondition("//ServiceName", this.getName()));
|
|
||||||
if (ServiceContext.this.client.execute(query, GHNContext.getContext().getDefaultScope()).size() == 0)
|
|
||||||
registerProfile(RegistryRIProfile, GCUBERunningInstance.TYPE);
|
|
||||||
|
|
||||||
ServiceContext. this.checkCodeployedServices();
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Failed to register co-deployed services", e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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 );
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ServiceContext() {}
|
private ServiceContext() {}
|
||||||
|
|
||||||
|
@ -144,9 +102,54 @@ public class ServiceContext extends GCUBEServiceContext {
|
||||||
//creates the single RegistryResource used to raise notifications about profiles' changes
|
//creates the single RegistryResource used to raise notifications about profiles' changes
|
||||||
logger.info("Scheduling IS-Registry notification resource...");
|
logger.info("Scheduling IS-Registry notification resource...");
|
||||||
|
|
||||||
NotificationResourceScheduler scheduler = new NotificationResourceScheduler(10, GCUBEScheduledHandler.Mode.LAZY);
|
NotificationResourceScheduler scheduler = new NotificationResourceScheduler(20, GCUBEScheduledHandler.Mode.LAZY);
|
||||||
scheduler.setHandled(new NotificationResource());
|
scheduler.setHandled(new GCUBEHandler(){
|
||||||
|
public void run() throws Exception {
|
||||||
|
|
||||||
|
//TODO: to remove for gcore 0.4.0
|
||||||
|
TypeMappingRegistry registry = ContainerConfig.getContext().getTypeMappingRegistry();
|
||||||
|
javax.xml.rpc.encoding.TypeMapping mapping = registry.createTypeMapping();
|
||||||
|
QName qname = new QName("http://mds.globus.org/aggregator/types","AggregatorContent");
|
||||||
|
mapping.register(AggregatorContent.class, qname,
|
||||||
|
new BeanSerializerFactory(AggregatorContent.class, qname),
|
||||||
|
new BeanDeserializerFactory(AggregatorContent.class,qname));
|
||||||
|
registry.register("", mapping);
|
||||||
|
//-- to remove --
|
||||||
|
|
||||||
|
|
||||||
|
List<String> pt = GHNContext.getContext().getActivePortTypes();
|
||||||
|
if ( (pt == null) || (pt.size() < 1))
|
||||||
|
throw new Exception();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
// register my profile
|
||||||
|
GCUBERunningInstance RegistryRIProfile = ServiceContext.getContext().getInstance();
|
||||||
|
GCUBERIQuery query = ServiceContext.getContext().client.getQuery(GCUBERIQuery.class);
|
||||||
|
query.addAtomicConditions(new AtomicCondition("//ServiceClass", ServiceContext.this.getServiceClass()),new AtomicCondition("//ServiceName", this.getName()));
|
||||||
|
if (ServiceContext.getContext().client.execute(query, GHNContext.getContext().getDefaultScope()).size() == 0)
|
||||||
|
registerProfile(RegistryRIProfile, GCUBERunningInstance.TYPE);
|
||||||
|
|
||||||
|
ServiceContext.getContext().checkCodeployedServices();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Failed to register co-deployed services", e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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 );
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
scheduler.run();
|
scheduler.run();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -26,7 +26,6 @@ public class RegistryFactoryPersistenceDelegate extends GCUBEWSFilePersistenceDe
|
||||||
resource.setMetadataCollection((RegistryProperty)ois.readObject());
|
resource.setMetadataCollection((RegistryProperty)ois.readObject());
|
||||||
resource.setRunningInstance((RegistryProperty)ois.readObject());
|
resource.setRunningInstance((RegistryProperty)ois.readObject());
|
||||||
resource.setService((RegistryProperty)ois.readObject());
|
resource.setService((RegistryProperty)ois.readObject());
|
||||||
resource.setTransformationProgram((RegistryProperty)ois.readObject());
|
|
||||||
resource.setVRE((RegistryProperty)ois.readObject());
|
resource.setVRE((RegistryProperty)ois.readObject());
|
||||||
resource.setGenericResource((RegistryProperty)ois.readObject());
|
resource.setGenericResource((RegistryProperty)ois.readObject());
|
||||||
SubscriptionPersistenceUtils.loadSubscriptionListeners(
|
SubscriptionPersistenceUtils.loadSubscriptionListeners(
|
||||||
|
@ -49,7 +48,6 @@ public class RegistryFactoryPersistenceDelegate extends GCUBEWSFilePersistenceDe
|
||||||
oos.writeObject(resource.getMetadataCollection());
|
oos.writeObject(resource.getMetadataCollection());
|
||||||
oos.writeObject(resource.getRunningInstance());
|
oos.writeObject(resource.getRunningInstance());
|
||||||
oos.writeObject(resource.getService());
|
oos.writeObject(resource.getService());
|
||||||
oos.writeObject(resource.getTransformationProgram());
|
|
||||||
oos.writeObject(resource.getVRE());
|
oos.writeObject(resource.getVRE());
|
||||||
oos.writeObject(resource.getGenericResource());
|
oos.writeObject(resource.getGenericResource());
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
|
||||||
|
|
||||||
|
import org.apache.axis.utils.XMLUtils;
|
||||||
import org.gcube.common.core.informationsystem.publisher.ISPublisher;
|
import org.gcube.common.core.informationsystem.publisher.ISPublisher;
|
||||||
import org.gcube.common.core.informationsystem.publisher.ISPublisherException;
|
import org.gcube.common.core.informationsystem.publisher.ISPublisherException;
|
||||||
import org.gcube.common.core.contexts.GHNContext;
|
import org.gcube.common.core.contexts.GHNContext;
|
||||||
|
@ -62,12 +63,14 @@ public class ProfileResource extends GCUBEWSResource {
|
||||||
@Override
|
@Override
|
||||||
public void initialise(Object... params) throws ResourceException {
|
public void initialise(Object... params) throws ResourceException {
|
||||||
GCUBEResource resource = (GCUBEResource) params[0];
|
GCUBEResource resource = (GCUBEResource) params[0];
|
||||||
|
|
||||||
Document dom = null;
|
Document dom = null;
|
||||||
StringWriter writer =new StringWriter();
|
StringWriter writer =new StringWriter();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
resource.store(writer);
|
resource.store(writer);
|
||||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
|
factory.setNamespaceAware(true);
|
||||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||||
StringReader reader = new StringReader(writer.toString().substring(writer.toString().indexOf("?>")+2, writer.toString().length()));
|
StringReader reader = new StringReader(writer.toString().substring(writer.toString().indexOf("?>")+2, writer.toString().length()));
|
||||||
InputSource source = new InputSource(reader);
|
InputSource source = new InputSource(reader);
|
||||||
|
@ -76,6 +79,15 @@ public class ProfileResource extends GCUBEWSResource {
|
||||||
throw new ResourceException(e1);
|
throw new ResourceException(e1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
StringWriter sw= new StringWriter();
|
||||||
|
try {
|
||||||
|
resource.store(sw);
|
||||||
|
} catch (Exception e1) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
*/
|
||||||
this.setProfile(dom);
|
this.setProfile(dom);
|
||||||
this.setNotificationProfile(dom);
|
this.setNotificationProfile(dom);
|
||||||
this.setGCubeResource(resource);
|
this.setGCubeResource(resource);
|
||||||
|
@ -90,7 +102,7 @@ public class ProfileResource extends GCUBEWSResource {
|
||||||
if (!(RegistryFactory.notificationMap.contains(this.getID()))) {
|
if (!(RegistryFactory.notificationMap.contains(this.getID()))) {
|
||||||
try {
|
try {
|
||||||
publisher = GHNContext.getImplementation(ISPublisher.class);
|
publisher = GHNContext.getImplementation(ISPublisher.class);
|
||||||
publisher.registerToISNotification(this.getEPR(), listQname, GHNContext.getContext().getDefaultScope(), ServiceContext.getContext());
|
//publisher.registerToISNotification(this.getEPR(), listQname, GHNContext.getContext().getDefaultScope(), ServiceContext.getContext());
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new ResourceException(e);
|
throw new ResourceException(e);
|
||||||
|
@ -191,14 +203,11 @@ public class ProfileResource extends GCUBEWSResource {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeProfile() throws ResourceException {
|
|
||||||
this.getPersistenceDelegate().remove(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void updateResource(GCUBEResource resource) throws Exception{
|
public void updateResource(GCUBEResource resource) throws Exception{
|
||||||
|
|
||||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
|
factory.setNamespaceAware(true);
|
||||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
resource.store(writer);
|
resource.store(writer);
|
||||||
|
|
|
@ -43,9 +43,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
|
|
||||||
protected static final String VRERP="VRE";
|
protected static final String VRERP="VRE";
|
||||||
|
|
||||||
protected static final String GenericRP="Generic";
|
protected static final String GenericResourceRP="GenericResource";
|
||||||
|
|
||||||
protected static final String TransformationProgramRP="TransformationProgram";
|
|
||||||
|
|
||||||
protected static final String MetadataCollectionRP="MetadataCollection";
|
protected static final String MetadataCollectionRP="MetadataCollection";
|
||||||
|
|
||||||
|
@ -65,9 +63,8 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
gLiteSiteRP,
|
gLiteSiteRP,
|
||||||
gLiteServiceRP,
|
gLiteServiceRP,
|
||||||
VRERP,
|
VRERP,
|
||||||
GenericRP,
|
MetadataCollectionRP,
|
||||||
TransformationProgramRP,
|
GenericResourceRP
|
||||||
MetadataCollectionRP
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -448,30 +445,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Default Setter for the RP TransRule
|
|
||||||
*
|
|
||||||
* @param property The RegistryProperty
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void setTransformationProgram(RegistryProperty property) {
|
|
||||||
this.getResourcePropertySet().get(TransformationProgramRP).clear();
|
|
||||||
this.getResourcePropertySet().get(TransformationProgramRP).add(property);
|
|
||||||
//this.getPersistenceDelegate().store(this);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default getter for the RP TransRule
|
|
||||||
*
|
|
||||||
* @return The RegistryProperty
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public RegistryProperty getTransformationProgram() {
|
|
||||||
return (RegistryProperty) this.getResourcePropertySet().get(TransformationProgramRP).get(0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Setter for the RP Generic
|
* Default Setter for the RP Generic
|
||||||
|
@ -481,8 +455,8 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void setGenericResource (RegistryProperty property) {
|
public void setGenericResource (RegistryProperty property) {
|
||||||
this.getResourcePropertySet().get(GenericRP).clear();
|
this.getResourcePropertySet().get(GenericResourceRP).clear();
|
||||||
this.getResourcePropertySet().get(GenericRP).add(property);
|
this.getResourcePropertySet().get(GenericResourceRP).add(property);
|
||||||
//this.getPersistenceDelegate().store(this);
|
//this.getPersistenceDelegate().store(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,7 +467,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public RegistryProperty getGenericResource () {
|
public RegistryProperty getGenericResource () {
|
||||||
return (RegistryProperty) this.getResourcePropertySet().get(GenericRP).get(0);
|
return (RegistryProperty) this.getResourcePropertySet().get(GenericResourceRP).get(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,11 +530,9 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
this.getResourcePropertySet().get(MetadataCollectionRP).clear();
|
this.getResourcePropertySet().get(MetadataCollectionRP).clear();
|
||||||
this.getResourcePropertySet().get(MetadataCollectionRP).add(property);
|
this.getResourcePropertySet().get(MetadataCollectionRP).add(property);
|
||||||
|
|
||||||
this.getResourcePropertySet().get(GenericRP).clear();
|
this.getResourcePropertySet().get(GenericResourceRP).clear();
|
||||||
this.getResourcePropertySet().get(GenericRP).add(property);
|
this.getResourcePropertySet().get(GenericResourceRP).add(property);
|
||||||
|
|
||||||
this.getResourcePropertySet().get(TransformationProgramRP).clear();
|
|
||||||
this.getResourcePropertySet().get(TransformationProgramRP).add(property);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue