diff --git a/pom.xml b/pom.xml index d28d78b..a3ab99e 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.gcube.resourcemanagement resource-manager - 2.2.0-SNAPSHOT + 2.2.1-SNAPSHOT pom Resource Manager Reactor diff --git a/resource-manager-service/pom.xml b/resource-manager-service/pom.xml index 4c6dbb1..ec807ec 100644 --- a/resource-manager-service/pom.xml +++ b/resource-manager-service/pom.xml @@ -4,7 +4,7 @@ org.gcube.resourcemanagement resource-manager - 2.2.0-SNAPSHOT + 2.2.1-SNAPSHOT .. diff --git a/resource-manager-service/src/main/java/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedAnyResource.java b/resource-manager-service/src/main/java/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedAnyResource.java index e74781f..e3acd9f 100644 --- a/resource-manager-service/src/main/java/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedAnyResource.java +++ b/resource-manager-service/src/main/java/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedAnyResource.java @@ -90,22 +90,6 @@ public final class ScopedAnyResource extends ScopedResource { getLogger().error("bad query. Caused by: "+e.getCause()); throw new Exception("unable to find the target resource (ID=" + id + "). Possible cause: " + e.getMessage(), e); } -// try{ -// if ((profiles != null) && (profiles.size() > 0)){ -// logger.info("profile found "); -// this.profile = profiles.get(0); -// }else{ -// GCUBEScope enclosingScope=GCUBEScope.getScope(this.scope).getEnclosingScope(); -// logger.info("profile not found. Try on enclosing scope: "+enclosingScope); -// // obviously, in the case of adding, the resource is not in the current scope, therefore we look upstairs (the enclosing scope) -// this.profile = (GCUBEResource) client.execute(realquery, enclosingScope).get(0); -// } -// }catch(Throwable e){ -// getLogger().error("bad query. Caused by: "+e.getCause()); -// throw new Exception("unable to find the target resource (ID=" + id + "). Possible cause: " + e.getMessage(), e); -// -// } - } @Override @@ -114,7 +98,10 @@ public final class ScopedAnyResource extends ScopedResource { getLogger().debug("Adding scope to resource profile"); try { profile.addScope(this.getScope()); - getLogger().debug("republish the resource "+profile.getID()+" with scope added "+this.getScope()); + + getLogger().debug("republish the resource "+profile.getID()+" with scope added "+this.getScope()+"with GCubeScope: "+ ServiceContext.getContext().getScope()+" in context "+ServiceContext.getContext()); + //patch: serviceContext altered by is-publisher + GCUBEScope currentServiceContext=ServiceContext.getContext().getScope(); //republish the resource ISPublisher publisher = GHNContext.getImplementation(ISPublisher.class); publisher.updateGCUBEResource(this.profile, ServiceContext.getContext().getScope(), ServiceContext.getContext()); @@ -126,6 +113,10 @@ public final class ScopedAnyResource extends ScopedResource { publisher.updateGCUBEResource(this.profile, ServiceContext.getContext().getScope().getEnclosingScope(), ServiceContext.getContext()); } } + getLogger().debug(": "+profile.getID()+"\n\t the ServiceContext is "+ServiceContext.getContext().getScope()); + //patch: serviceContext altered by is-publisher + ServiceContext.getContext().setScope(currentServiceContext); + getLogger().debug("ServiceContext scope restored to: "+currentServiceContext); } catch (Exception e) { this.noHopeForMe("Failed to add the scope ("+ this.getScope()+") to resource " + this.getId(), e); } @@ -134,8 +125,10 @@ public final class ScopedAnyResource extends ScopedResource { @Override protected void removeFromScope() throws ResourceNotFound, Exception { this.findResource(); - getLogger().debug("Removing scope from resource profile"); + getLogger().debug("Removing scope from resource profile"); try { + //patch: serviceContext altered by is-publisher + GCUBEScope currentServiceContext=ServiceContext.getContext().getScope(); profile.removeScope(this.getScope()); //republish the resource ISPublisher publisher = GHNContext.getImplementation(ISPublisher.class); @@ -146,6 +139,8 @@ public final class ScopedAnyResource extends ScopedResource { publisher.updateGCUBEResource(this.profile, ServiceContext.getContext().getScope().getEnclosingScope(), ServiceContext.getContext()); } } + //patch: serviceContext altered by is-publisher + ServiceContext.getContext().setScope(currentServiceContext); } catch (Exception e) { this.noHopeForMe("Failed to remove the scope ("+ this.getScope()+") from resource " + this.getId(), e); } diff --git a/resource-manager-stubs/pom.xml b/resource-manager-stubs/pom.xml index ce675c1..f851873 100644 --- a/resource-manager-stubs/pom.xml +++ b/resource-manager-stubs/pom.xml @@ -7,7 +7,7 @@ org.gcube.resourcemanagement resource-manager - 2.2.0-SNAPSHOT + 2.2.1-SNAPSHOT resource-manager-stubs Resource Manager Stubs diff --git a/resource-manager-test-suite/pom.xml b/resource-manager-test-suite/pom.xml index 40a6293..0a8657e 100644 --- a/resource-manager-test-suite/pom.xml +++ b/resource-manager-test-suite/pom.xml @@ -7,7 +7,7 @@ org.gcube.resourcemanagement resource-manager - 2.2.0-SNAPSHOT + 2.2.1-SNAPSHOT resource-manager-test-suite