diff --git a/src/main/java/org/gcube/informationsystem/publisher/RegistryPublisherImpl.java b/src/main/java/org/gcube/informationsystem/publisher/RegistryPublisherImpl.java index 3ae7fa7..2d0be4e 100644 --- a/src/main/java/org/gcube/informationsystem/publisher/RegistryPublisherImpl.java +++ b/src/main/java/org/gcube/informationsystem/publisher/RegistryPublisherImpl.java @@ -94,7 +94,6 @@ public class RegistryPublisherImpl implements RegistryPublisher { log.debug("[VOCREATE] new scope added {}",scope); ResourceMediator.setScope(resource, scope); } - // validating the resource try { Resources.validate(resource); @@ -103,18 +102,19 @@ public class RegistryPublisherImpl implements RegistryPublisher { throw new IllegalArgumentException("the resource is not valid ", e.getCause()); } try{ - - // checking the current scope: if the operation fails in the current VO it will give an exception, if it fails in another VO no exception will be given - String currentVO = Utils.getCurrentVO(currentScope); - if (currentVO != null){ - RegistryStub stub = getRegistryStub(); - createResource(resource, currentVO, stub); - vosScopes.remove(currentVO); - //in this case it is a root-vo scope so we need to create the resource only at root-vo level - }else{ - RegistryStub stub = getRegistryStub(); - createResource(resource, currentVO, stub); - return resource; + if(currentScope != null){ + // checking the current scope: if the operation fails in the current VO it will give an exception, if it fails in another VO no exception will be given + String currentVO = Utils.getCurrentVO(currentScope); + if (currentVO != null){ + RegistryStub stub = getRegistryStub(); + createResource(resource, currentVO, stub); + vosScopes.remove(currentVO); + //in this case it is a root-vo scope so we need to create the resource only at root-vo level + }else{ + RegistryStub stub = getRegistryStub(); + createResource(resource, currentVO, stub); + return resource; + } } // update the resource for each VO for (String voScope: vosScopes){ @@ -231,17 +231,19 @@ public class RegistryPublisherImpl implements RegistryPublisher { } HashSet vosScopes = Utils.getInternalVOScopes(resource); try{ - // checking the current scope: if the operation fail in the current VO it will give an exception, if it fails in another VO no exception will be given - String currentVO = Utils.getCurrentVO(currentScope); - if (currentVO != null){ - ScopeProvider.instance.set(currentVO); - registryUpdate(resource, 0); - vosScopes.remove(currentVO); - // in this case it is a root-vo scope so we need to update the resource only at root-vo level - }else{ - ScopeProvider.instance.set(currentScope); - registryUpdate(resource, 0); - return resource; + if(currentScope != null){ + // checking the current scope: if the operation fail in the current VO it will give an exception, if it fails in another VO no exception will be given + String currentVO = Utils.getCurrentVO(currentScope); + if (currentVO != null){ + ScopeProvider.instance.set(currentVO); + registryUpdate(resource, 0); + vosScopes.remove(currentVO); + // in this case it is a root-vo scope so we need to update the resource only at root-vo level + }else{ + ScopeProvider.instance.set(currentScope); + registryUpdate(resource, 0); + return resource; + } } int tries=0; diff --git a/src/main/java/org/gcube/informationsystem/publisher/utils/Utils.java b/src/main/java/org/gcube/informationsystem/publisher/utils/Utils.java index ea63116..a3128b1 100644 --- a/src/main/java/org/gcube/informationsystem/publisher/utils/Utils.java +++ b/src/main/java/org/gcube/informationsystem/publisher/utils/Utils.java @@ -65,7 +65,7 @@ public class Utils { ScopeBean scopeBean = new ScopeBean(scope); if(scopeBean.is(Type.VRE)) vosScopes.add(scopeBean.enclosingScope().toString()); -// else if(scopeBean.is(Type.VO)) +// if the scope is a root-vo scope, it will be added to the vosScope array vosScopes.add(scope); } return vosScopes;