git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@3537 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1cefab7d2e
commit
3539ca8717
|
@ -23,6 +23,7 @@ import org.gcube.common.core.resources.GCUBERunningInstance;
|
||||||
import org.gcube.common.core.scope.GCUBEScope;
|
import org.gcube.common.core.scope.GCUBEScope;
|
||||||
import org.gcube.common.core.utils.handlers.GCUBEHandler;
|
import org.gcube.common.core.utils.handlers.GCUBEHandler;
|
||||||
import org.gcube.common.core.utils.handlers.GCUBEScheduledHandler;
|
import org.gcube.common.core.utils.handlers.GCUBEScheduledHandler;
|
||||||
|
import org.gcube.common.vremanagement.ghnmanager.impl.GHNManager;
|
||||||
import org.gcube.informationsystem.registry.impl.RegistryFactory;
|
import org.gcube.informationsystem.registry.impl.RegistryFactory;
|
||||||
import org.gcube.informationsystem.registry.impl.core.RegistryConfiguration.ROOT_SERVICES;
|
import org.gcube.informationsystem.registry.impl.core.RegistryConfiguration.ROOT_SERVICES;
|
||||||
import org.gcube.informationsystem.registry.impl.state.RegistryFactoryResource;
|
import org.gcube.informationsystem.registry.impl.state.RegistryFactoryResource;
|
||||||
|
@ -115,23 +116,35 @@ public class ServiceContext extends GCUBEServiceContext {
|
||||||
try {
|
try {
|
||||||
// register my profile
|
// register my profile
|
||||||
GCUBERunningInstance RegistryRIProfile = ServiceContext.getContext().getInstance();
|
GCUBERunningInstance RegistryRIProfile = ServiceContext.getContext().getInstance();
|
||||||
|
client = GHNContext.getImplementation(ISClient.class);
|
||||||
GCUBERIQuery query = ServiceContext.getContext().client.getQuery(GCUBERIQuery.class);
|
GCUBERIQuery query = ServiceContext.getContext().client.getQuery(GCUBERIQuery.class);
|
||||||
query.addAtomicConditions(new AtomicCondition("//ServiceClass", ServiceContext.this.getServiceClass()),new AtomicCondition("//ServiceName", this.getName()));
|
query.addAtomicConditions(new AtomicCondition("//ServiceClass", ServiceContext.this.getServiceClass()),new AtomicCondition("//ServiceName", ServiceContext.this.getInstance().getServiceName()));
|
||||||
if (ServiceContext.getContext().client.execute(query, ServiceContext.getContext().getScope()).size() == 0)
|
|
||||||
registerProfile(RegistryRIProfile, GCUBERunningInstance.TYPE);
|
for (GCUBEScope scope: ServiceContext.getContext().getInstance().getScopes().values())
|
||||||
|
{
|
||||||
|
ServiceContext.getContext().setScope(scope);
|
||||||
|
logger.trace("current scope: "+scope);
|
||||||
|
if (ServiceContext.getContext().client.execute(query,scope ).size() == 0)
|
||||||
|
registerProfile(RegistryRIProfile, GCUBERunningInstance.TYPE, scope);
|
||||||
|
|
||||||
|
RegistryFactoryResource resource = (RegistryFactoryResource) FactoryContext.getContext().getWSHome().create(FactoryContext.getContext().makeKey(RegistryFactory.NOTIFICATOR_RESOURCE_KEY));
|
||||||
|
resource.store();
|
||||||
|
}
|
||||||
|
|
||||||
ServiceContext.getContext().checkCodeployedServices();
|
ServiceContext.getContext().checkCodeployedServices();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Failed to register co-deployed services", 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 );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -158,17 +171,16 @@ public class ServiceContext extends GCUBEServiceContext {
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @throws ISPublisherException
|
* @throws ISPublisherException
|
||||||
*/
|
*/
|
||||||
private void registerProfile(GCUBEResource resource, String type)
|
private void registerProfile(GCUBEResource resource, String type, GCUBEScope scope)
|
||||||
throws ISPublisherException, Exception {
|
throws ISPublisherException, Exception {
|
||||||
if (GHNContext.getContext().getMode() == GHNContext.Mode.ROOT)
|
if (GHNContext.getContext().getMode() == GHNContext.Mode.ROOT)
|
||||||
GHNContext.getImplementation(ISPublisher.class).registerGCUBEResource(
|
GHNContext.getImplementation(ISPublisher.class).registerGCUBEResource(
|
||||||
resource, ServiceContext.getContext().getScope(),
|
resource, scope, ServiceContext.getContext());
|
||||||
ServiceContext.getContext());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkCodeployedServices () throws Exception {
|
private void checkCodeployedServices () throws Exception {
|
||||||
|
this.client = GHNContext.getImplementation(ISClient.class);
|
||||||
GCUBERunningInstance NotifierRIProfile = null;
|
GCUBERunningInstance NotifierRIProfile = null;
|
||||||
GCUBERunningInstance ISICRIProfile = null;
|
GCUBERunningInstance ISICRIProfile = null;
|
||||||
|
|
||||||
|
@ -197,21 +209,27 @@ public class ServiceContext extends GCUBEServiceContext {
|
||||||
// registers the local IS-Notifier profile
|
// registers the local IS-Notifier profile
|
||||||
if (isNotifierCodeployed) {
|
if (isNotifierCodeployed) {
|
||||||
GCUBERIQuery query = client.getQuery(GCUBERIQuery.class);
|
GCUBERIQuery query = client.getQuery(GCUBERIQuery.class);
|
||||||
query.addAtomicConditions(new AtomicCondition(
|
query.addGenericCondition("$result/Profile/AccessPoint/RunningInstanceInterfaces/Endpoint[string(@EntryName) eq 'gcube/informationsystem/notifier/Notifier'] ");
|
||||||
"//Endpoint@EntryName","gcube/informationsystem/notifier/Notifier"),new AtomicCondition("//ServiceName", ROOT_SERVICES.ISNOTIFIER.getName()));
|
query.addAtomicConditions(new AtomicCondition("//ServiceName", ROOT_SERVICES.ISNOTIFIER.getName()));
|
||||||
|
|
||||||
|
|
||||||
|
for (GCUBEScope scope: ServiceContext.getContext().getInstance().getScopes().values())
|
||||||
|
if (ServiceContext.getContext().client.execute(query,scope ).size() == 0)
|
||||||
|
registerProfile(NotifierRIProfile, GCUBERunningInstance.TYPE, scope);
|
||||||
|
|
||||||
|
|
||||||
if (client.execute(query, ServiceContext.getContext().getScope()).size() == 0)
|
|
||||||
registerProfile(NotifierRIProfile, GCUBERunningInstance.TYPE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// registers the local IS-IC profile
|
// registers the local IS-IC profile
|
||||||
if (isICCodeployed) {
|
if (isICCodeployed) {
|
||||||
GCUBERIQuery query = client.getQuery(GCUBERIQuery.class);
|
GCUBERIQuery query = client.getQuery(GCUBERIQuery.class);
|
||||||
query.addAtomicConditions(new AtomicCondition(
|
query.addGenericCondition("$result/Profile/AccessPoint/RunningInstanceInterfaces/Endpoint[string(@EntryName) eq 'gcube/informationsystem/isic/ISICFactoryService'] ");
|
||||||
"//Endpoint@EntryName","gcube/informationsystem/isic/ISICFactoryService"),new AtomicCondition("//ServiceName", ROOT_SERVICES.ISIC.getName()));
|
query.addAtomicConditions(new AtomicCondition("//ServiceName", ROOT_SERVICES.ISIC.getName()));
|
||||||
|
|
||||||
|
for (GCUBEScope scope: ServiceContext.getContext().getInstance().getScopes().values())
|
||||||
|
if (ServiceContext.getContext().client.execute(query,scope ).size() == 0)
|
||||||
|
registerProfile(ISICRIProfile, GCUBERunningInstance.TYPE, scope);
|
||||||
|
|
||||||
if (client.execute(query, ServiceContext.getContext().getScope()).size() == 0)
|
|
||||||
registerProfile(ISICRIProfile, GCUBERunningInstance.TYPE);
|
|
||||||
}
|
}
|
||||||
// registers the local GHNManager profile
|
// registers the local GHNManager profile
|
||||||
|
|
||||||
|
@ -221,8 +239,10 @@ public class ServiceContext extends GCUBEServiceContext {
|
||||||
GCUBEGHNQuery node = client.getQuery(GCUBEGHNQuery.class);
|
GCUBEGHNQuery node = client.getQuery(GCUBEGHNQuery.class);
|
||||||
node.addAtomicConditions(new AtomicCondition("/GHNDescription/Name", ghnProfile.getNodeDescription().getName()));
|
node.addAtomicConditions(new AtomicCondition("/GHNDescription/Name", ghnProfile.getNodeDescription().getName()));
|
||||||
|
|
||||||
if (client.execute(node, ServiceContext.getContext().getScope()).size() == 0)
|
for (GCUBEScope scope: ServiceContext.getContext().getInstance().getScopes().values())
|
||||||
registerProfile(ghnProfile, GCUBEHostingNode.TYPE);
|
if (ServiceContext.getContext().client.execute(node,scope ).size() == 0)
|
||||||
|
registerProfile(ghnProfile, GCUBEHostingNode.TYPE, scope);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,19 +99,8 @@ public class ProfileResource extends GCUBEWSResource {
|
||||||
if (!(RegistryFactory.notificationMap.contains(this.getID()))) {
|
if (!(RegistryFactory.notificationMap.contains(this.getID()))) {
|
||||||
try {
|
try {
|
||||||
notifier = GHNContext.getImplementation(ISNotifier.class);
|
notifier = GHNContext.getImplementation(ISNotifier.class);
|
||||||
System.out.println("i'm here ---------------");
|
|
||||||
for (SimpleTopic s : listQname)
|
|
||||||
System.out.println(s);
|
|
||||||
System.out.println(listQname);
|
|
||||||
System.out.println(listQname.getClass());
|
|
||||||
try {
|
|
||||||
notifier.registerISNotification(this.getEPR(), listQname, ServiceContext.getContext());
|
notifier.registerISNotification(this.getEPR(), listQname, ServiceContext.getContext());
|
||||||
} catch (ArrayStoreException e) {
|
|
||||||
System.out.println(e);
|
|
||||||
e.printStackTrace();
|
|
||||||
System.out.println("end stack trace");
|
|
||||||
}
|
|
||||||
System.out.println("i'm there xxx---------------");
|
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new ResourceException(e);
|
throw new ResourceException(e);
|
||||||
|
|
Loading…
Reference in New Issue