git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@42 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e2374c479e
commit
dd67a18c20
|
@ -22,7 +22,7 @@ public class ProfileContext extends GCUBEStatefulPortTypeContext{
|
|||
}
|
||||
|
||||
public final String getNamespace() {
|
||||
return "http://gcube-system.org/namespaces/gcube/informationsystem/registry";
|
||||
return "http://gcube-system.org/namespaces/informationsystem/registry";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.gcube.common.core.resources.GCUBEResource;
|
|||
import org.gcube.common.core.resources.GCUBEService;
|
||||
import org.gcube.common.core.resources.GCUBETransformationProgram;
|
||||
import org.gcube.common.core.resources.GCUBEVRE;
|
||||
import org.gcube.common.core.resources.impl.kxml.KGCUBEResource;
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.gcube.common.is.publisher.impl.GCUBEPublisher;
|
||||
|
@ -49,7 +48,6 @@ import org.gcube.informationsystem.registry.stubs.UpdateStateMessage;
|
|||
import org.gcube.informationsystem.registry.stubs.service.RegistryServiceAddressingLocator;
|
||||
import org.globus.wsrf.ResourceContext;
|
||||
import org.globus.wsrf.ResourceKey;
|
||||
import org.globus.wsrf.impl.SimpleResourceKey;
|
||||
import org.oasis.wsrf.lifetime.Destroy;
|
||||
|
||||
|
||||
|
@ -490,7 +488,7 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
|||
case GHN: return GHNContext.getImplementation(GCUBEHostingNode.class);
|
||||
case VRE: return GHNContext.getImplementation(GCUBEVRE.class);
|
||||
case TransformationProgram: return GHNContext.getImplementation(GCUBETransformationProgram.class);
|
||||
case MetadataCollection: return GHNContext.getImplementation(GCUBECollection.class);
|
||||
case MetadataCollection: return GHNContext.getImplementation(GCUBEMCollection.class);
|
||||
case Generic: return GHNContext.getImplementation(GCUBEGenericResource.class);
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -1,7 +1,20 @@
|
|||
package org.gcube.informationsystem.registry.impl.core;
|
||||
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
import org.gcube.common.core.contexts.GCUBEServiceContext;
|
||||
import org.gcube.common.core.contexts.GHNContext;
|
||||
import org.gcube.common.core.is.client.ISClient;
|
||||
import org.gcube.common.core.is.client.queries.GCUBERIsFromClassAndName;
|
||||
import org.gcube.common.core.is.client.queries.GCUBEResourceXPathQuery;
|
||||
import org.gcube.common.core.is.publisher.ISPublisher;
|
||||
import org.gcube.common.core.is.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.informationsystem.registry.stubs.RegistryFactoryPortType;
|
||||
import org.gcube.informationsystem.registry.stubs.service.RegistryFactoryServiceAddressingLocator;
|
||||
|
||||
public class ServiceContext extends GCUBEServiceContext{
|
||||
|
||||
|
@ -18,10 +31,150 @@ public class ServiceContext extends GCUBEServiceContext{
|
|||
return JNDI_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onReady() throws Exception{
|
||||
|
||||
|
||||
GCUBERunningInstance RegistryRIProfile = null;
|
||||
|
||||
GCUBERunningInstance NotifierRIProfile = null;
|
||||
|
||||
GCUBERunningInstance ISICRIProfile = null;
|
||||
|
||||
|
||||
GCUBERunningInstance GHNManagerProfile = null;
|
||||
|
||||
GCUBEHostingNode ghnProfile = null;
|
||||
|
||||
String ghnName ="";
|
||||
|
||||
GCUBERIsFromClassAndName queryRI = null;
|
||||
|
||||
GCUBEResourceXPathQuery queryGHN = null;
|
||||
|
||||
boolean isNotifierCodeployed = false;
|
||||
|
||||
boolean isICCodeployed =false;
|
||||
|
||||
ISClient client = null;
|
||||
|
||||
|
||||
RegistryFactoryServiceAddressingLocator registryLocator = new RegistryFactoryServiceAddressingLocator();
|
||||
|
||||
RegistryFactoryPortType registryFactory = null;
|
||||
|
||||
// create GeneralQueryManager
|
||||
try {
|
||||
client = GHNContext.getImplementation(ISClient.class);
|
||||
queryRI = client.getQuery(GCUBERIsFromClassAndName.class);
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
registryFactory = registryLocator.getRegistryFactoryPortTypePort(FactoryContext.getContext().getEPR());
|
||||
|
||||
|
||||
|
||||
try {
|
||||
RegistryRIProfile= ServiceContext.getContext().getInstance();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
NotifierRIProfile= GHNContext.getContext().getServiceContext("InformationSystem", "IS-Notifier").getInstance();
|
||||
isNotifierCodeployed= true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
GHNManagerProfile= GHNContext.getContext().getServiceContext("VREManagement", "GHNManager").getInstance();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
ISICRIProfile=GHNContext.getContext().getServiceContext("InformationSystem", "IS-IC").getInstance();
|
||||
isICCodeployed = true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
ghnProfile=GHNContext.getContext().getGHN();
|
||||
|
||||
ghnName=ghnProfile.getNodeDescription().getName();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(20000);
|
||||
} catch (InterruptedException e1) {
|
||||
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
//Check if the Registry profile is alerady registered
|
||||
|
||||
try {
|
||||
|
||||
queryRI.setEntryName( "gcube/informationsystem/registry/RegistryFactory");
|
||||
queryRI.setResourceClass("InformationSystem");
|
||||
queryRI.setResourceName("IS-Registry");
|
||||
if (client.execute(queryRI, GHNContext.getContext().getDefaultScope()).size()==0) registerProfile(RegistryRIProfile,GCUBERunningInstance.TYPE);
|
||||
|
||||
if (isNotifierCodeployed) {
|
||||
queryRI.setEntryName( "gcube/informationsystem/notifier/Notifier");
|
||||
queryRI.setResourceClass("InformationSystem");
|
||||
queryRI.setResourceName("IS-Notifier");
|
||||
if (client.execute(queryRI, GHNContext.getContext().getDefaultScope()).size()==0) registerProfile(NotifierRIProfile,GCUBERunningInstance.TYPE);
|
||||
}
|
||||
|
||||
if (isICCodeployed) {
|
||||
queryRI.setEntryName( "diligentproject/informationservice/disic/DISICFactoryService");
|
||||
queryRI.setResourceClass("InformationSystem");
|
||||
queryRI.setResourceName("IS-IC");
|
||||
if (client.execute(queryRI, GHNContext.getContext().getDefaultScope()).size()==0) registerProfile(ISICRIProfile,GCUBERunningInstance.TYPE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
queryGHN.setResourceType(GCUBEHostingNode.TYPE);
|
||||
queryGHN.setXPath("/GHNDescription/Name/string() eq '" + ghnName + "'");
|
||||
if (client.execute(queryGHN, GHNContext.getContext().getDefaultScope()).size()==0) registerProfile(ghnProfile,GCUBEHostingNode.TYPE);
|
||||
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInitialisation() throws Exception {
|
||||
FactoryContext.getContext().getWSHome().create(FactoryContext.getContext().makeKey("RegistryResource"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register the Profile
|
||||
*
|
||||
* @param resource teh gCUBEResource
|
||||
* @param type The profile Type
|
||||
* @throws Exception
|
||||
* @throws ISPublisherException
|
||||
*/
|
||||
private void registerProfile(GCUBEResource resource,String type) throws ISPublisherException, Exception {
|
||||
GHNContext.getImplementation(ISPublisher.class).registerGCUBEResource(resource, GHNContext.getContext().getDefaultScope(), ServiceContext.getContext());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue