This commit is contained in:
Roberto Cirillo 2019-10-23 10:10:40 +02:00
parent 565312cbb0
commit 108c194bf2
2 changed files with 27 additions and 25 deletions

View File

@ -94,7 +94,6 @@ public class RegistryPublisherImpl implements RegistryPublisher {
log.debug("[VOCREATE] new scope added {}",scope); log.debug("[VOCREATE] new scope added {}",scope);
ResourceMediator.setScope(resource, scope); ResourceMediator.setScope(resource, scope);
} }
// validating the resource // validating the resource
try { try {
Resources.validate(resource); Resources.validate(resource);
@ -103,18 +102,19 @@ public class RegistryPublisherImpl implements RegistryPublisher {
throw new IllegalArgumentException("the resource is not valid ", e.getCause()); throw new IllegalArgumentException("the resource is not valid ", e.getCause());
} }
try{ try{
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 // 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); String currentVO = Utils.getCurrentVO(currentScope);
if (currentVO != null){ if (currentVO != null){
RegistryStub stub = getRegistryStub(); RegistryStub stub = getRegistryStub();
createResource(resource, currentVO, stub); createResource(resource, currentVO, stub);
vosScopes.remove(currentVO); vosScopes.remove(currentVO);
//in this case it is a root-vo scope so we need to create the resource only at root-vo level //in this case it is a root-vo scope so we need to create the resource only at root-vo level
}else{ }else{
RegistryStub stub = getRegistryStub(); RegistryStub stub = getRegistryStub();
createResource(resource, currentVO, stub); createResource(resource, currentVO, stub);
return resource; return resource;
}
} }
// update the resource for each VO // update the resource for each VO
for (String voScope: vosScopes){ for (String voScope: vosScopes){
@ -231,17 +231,19 @@ public class RegistryPublisherImpl implements RegistryPublisher {
} }
HashSet<String> vosScopes = Utils.getInternalVOScopes(resource); HashSet<String> vosScopes = Utils.getInternalVOScopes(resource);
try{ 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 if(currentScope != null){
String currentVO = Utils.getCurrentVO(currentScope); // 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
if (currentVO != null){ String currentVO = Utils.getCurrentVO(currentScope);
ScopeProvider.instance.set(currentVO); if (currentVO != null){
registryUpdate(resource, 0); ScopeProvider.instance.set(currentVO);
vosScopes.remove(currentVO); registryUpdate(resource, 0);
// in this case it is a root-vo scope so we need to update the resource only at root-vo level vosScopes.remove(currentVO);
}else{ // in this case it is a root-vo scope so we need to update the resource only at root-vo level
ScopeProvider.instance.set(currentScope); }else{
registryUpdate(resource, 0); ScopeProvider.instance.set(currentScope);
return resource; registryUpdate(resource, 0);
return resource;
}
} }
int tries=0; int tries=0;

View File

@ -65,7 +65,7 @@ public class Utils {
ScopeBean scopeBean = new ScopeBean(scope); ScopeBean scopeBean = new ScopeBean(scope);
if(scopeBean.is(Type.VRE)) if(scopeBean.is(Type.VRE))
vosScopes.add(scopeBean.enclosingScope().toString()); 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); vosScopes.add(scope);
} }
return vosScopes; return vosScopes;