diff --git a/src/org/gcube/vremanagement/vremodeler/consumers/GenericResourceConsumer.java b/src/org/gcube/vremanagement/vremodeler/consumers/GenericResourceConsumer.java index 157349e..10665f1 100644 --- a/src/org/gcube/vremanagement/vremodeler/consumers/GenericResourceConsumer.java +++ b/src/org/gcube/vremanagement/vremodeler/consumers/GenericResourceConsumer.java @@ -1,6 +1,7 @@ package org.gcube.vremanagement.vremodeler.consumers; import java.io.StringReader; +import java.io.StringWriter; import javax.xml.namespace.QName; @@ -41,7 +42,7 @@ private GCUBELog logger= new GCUBELog(GHNConsumer.class); String operation=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue(); logger.info("notification received for genericResource "+id+" and operation "+operation); - if (id.compareTo(this.functionalityResourceId)==0 && (operation.compareTo("update")==0 || operation.compareTo("create")==0)){ + if (id.compareTo(this.functionalityResourceId)==0 && (operation.compareTo("update")==0)){ logger.trace("notification received for functionalityResource with id "+id+" in scope "+scope.toString()); KGCUBEGenericFunctionalityResource resource= new KGCUBEGenericFunctionalityResource(); ISClient client=GHNContext.getImplementation(ISClient.class); @@ -58,10 +59,19 @@ private GCUBELog logger= new GCUBELog(GHNConsumer.class); logger.trace("notification received for generic resource with operation create"); ISClient client=GHNContext.getImplementation(ISClient.class); GCUBEGenericResourceQuery query= client.getQuery(GCUBEGenericResourceQuery.class); - query.addAtomicConditions(new AtomicCondition("/ID",this.functionalityResourceId)); + query.addAtomicConditions(new AtomicCondition("/ID",id)); GCUBEGenericResource resource =client.execute(query, ServiceContext.getContext().getScope()).get(0); - if (ServiceContext.getContext().getSecondaryTypeGenericResourceRequired().contains(resource.getSecondaryType())) - new GenericResourceHandler().add(resource); + + if (resource.getName().compareTo("FuctionalitiesResource")==0){ + FunctionalityHandler functionalityHandler= new FunctionalityHandler(); + KGCUBEGenericFunctionalityResource functResource=new KGCUBEGenericFunctionalityResource(); + StringWriter sw= new StringWriter(); + resource.store(sw); + functResource.load(new StringReader(sw.toString())); + functionalityHandler.add(functResource); + } else + if (ServiceContext.getContext().getSecondaryTypeGenericResourceRequired().contains(resource.getSecondaryType())) + new GenericResourceHandler().add(resource); }else if (operation.compareTo("destroy")==0){ logger.trace("notification received for generic resource with operation destroy"); new GenericResourceHandler().drop(id); diff --git a/src/org/gcube/vremanagement/vremodeler/impl/ServiceContext.java b/src/org/gcube/vremanagement/vremodeler/impl/ServiceContext.java index 4553d43..4a284ee 100644 --- a/src/org/gcube/vremanagement/vremodeler/impl/ServiceContext.java +++ b/src/org/gcube/vremanagement/vremodeler/impl/ServiceContext.java @@ -56,8 +56,12 @@ public class ServiceContext extends GCUBEServiceContext{ for (GCUBEScope scope : ServiceContext.getContext().getInstance().getScopes().values()){ ServiceContext.getContext().setScope(scope); - this.setSecondaryTypeGenericResourceRequired(((String)this.getProperty("GenericResourceToAdd", true)).split(",")); + ArrayList genResList= new ArrayList(); + for (String gen:((String)this.getProperty("GenericResourceToAdd", true)).split(",")) + genResList.add(gen.trim()); + this.setSecondaryTypeGenericResourceRequired(genResList.toArray(new String[0])); + GCUBESecurityManager secMan= new GCUBESecurityManagerImpl(){ @Override public boolean isSecurityEnabled() {