This commit is contained in:
Lucio Lelii 2009-10-14 09:57:31 +00:00
parent 5db93e0d91
commit d98a2c02b5
4 changed files with 12 additions and 10 deletions

View File

@ -34,26 +34,26 @@ private GCUBELog logger= new GCUBELog(GHNConsumer.class);
public void onNotificationReceived(NotificationEvent event){
try{
logger.trace("notificetion received");
ServiceContext.getContext().setScope(this.scope);
String id= event.getPayload().getMessage()[0].getChildNodes().item(0).getChildNodes().item(0).getNodeValue();
String operation=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue();
if (id.compareTo(this.resourceId)==0 && operation.compareTo("modify")==0){
logger.info("notification received for genericResource "+id+" and operation "+operation);
if (id.compareTo(this.resourceId)==0 && (operation.compareTo("update")==0 || operation.compareTo("create")==0)){
logger.trace("notification received for functionalityResource with id "+id+" in scope "+scope.toString());
KGCUBEGenericFunctionalityResource resource= new KGCUBEGenericFunctionalityResource();
ISClient client=GHNContext.getImplementation(ISClient.class);
GCUBEGenericResourceQuery query= client.getQuery(GCUBEGenericResourceQuery.class);
query.addAtomicConditions(new AtomicCondition("/Profile/Name","FuctionalitiesResource"), new AtomicCondition("/Profile/SecondaryType","VREModelerResource"));
GCUBEGenericQuery genericQuery= client.getQuery(GCUBEGenericQuery.class);
genericQuery.setExpression(query.getExpression());
Thread.sleep(60000);
resource.load(new StringReader(client.execute(genericQuery, ServiceContext.getContext().getScope()).get(0).toString()));
Thread.sleep(60000);
//FunctionalityHandler
//FunctionalityHandler
FunctionalityHandler functionalityHandler= new FunctionalityHandler();
functionalityHandler.add(resource);
}
}catch(Exception e){logger.error("error in notification received",e);}
}catch(Exception e){logger.error("error in functionality notification",e);}
}
}

View File

@ -29,7 +29,7 @@ public class MCollectionConsumer extends BaseNotificationConsumer{
public void onNotificationReceived(NotificationEvent event){
try{
logger.trace("notificetion received");
//logger.trace("notification received");
ServiceContext.getContext().setScope(this.scope);
String id= event.getPayload().getMessage()[0].getChildNodes().item(0).getChildNodes().item(0).getNodeValue();
String operation=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue();

View File

@ -29,7 +29,7 @@ public class RunningInstanceConsumer extends BaseNotificationConsumer{
public void onNotificationReceived(NotificationEvent event){
try{
logger.trace("notificetion received");
logger.trace("notification received for RI");
ServiceContext.getContext().setScope(this.scope);
String id= event.getPayload().getMessage()[0].getChildNodes().item(0).getChildNodes().item(0).getNodeValue();
String operation=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue();

View File

@ -45,9 +45,10 @@ public class FunctionalityHandler implements ResourceHandler<KGCUBEGenericFuncti
public void add(KGCUBEGenericFunctionalityResource resource)
throws Exception {
DBInterface.deleteAll(functionalityTableName);
DBInterface.deleteAll(portletTableName);
DBInterface.deleteAll(serviceTableName);
DBInterface.deleteAll(portletTableName);
DBInterface.deleteAll(functionalityTableName);
logger.debug("functionality clean");
this.insert(resource);
logger.debug("functionality changed");
}
@ -65,6 +66,7 @@ public class FunctionalityHandler implements ResourceHandler<KGCUBEGenericFuncti
genericQuery.setExpression(query.getExpression());
resource.load(new StringReader(queryClient.execute(genericQuery, ServiceContext.getContext().getScope()).get(0).toString()));
this.functionalityResourceId= resource.getID();
logger.debug("the functionality resource ID is "+this.functionalityResourceId);
this.insert(resource);
logger.debug("functionality initialized");
}catch(Exception e ){logger.error("Functionality resource not found",e); logger.warn("the service will be initialized without functionalities"); }