merge with master
This commit is contained in:
parent
eb40fd0eeb
commit
1d01f50e29
|
@ -0,0 +1 @@
|
|||
/target/
|
2
pom.xml
2
pom.xml
|
@ -21,7 +21,7 @@
|
|||
|
||||
<groupId>org.gcube.resources</groupId>
|
||||
<artifactId>registry-publisher</artifactId>
|
||||
<version>1.3.1-SNAPSHOT</version>
|
||||
<version>1.3.3-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
|
||||
|
|
|
@ -88,7 +88,6 @@ public class RegistryPublisherImpl implements RegistryPublisher {
|
|||
log.debug("id generated: "+id);
|
||||
ResourceMediator.setId(resource, id);
|
||||
}
|
||||
HashSet<String> vosScopes = updateResourceScopes(resource);
|
||||
// add the new scopes
|
||||
for(String scope: scopes){
|
||||
log.debug("[VOCREATE] new scope added {}",scope);
|
||||
|
@ -101,6 +100,7 @@ public class RegistryPublisherImpl implements RegistryPublisher {
|
|||
log.error("the resource is not valid", e);
|
||||
throw new IllegalArgumentException("the resource is not valid ", e.getCause());
|
||||
}
|
||||
HashSet<String> vosScopes = updateResourceScopes(resource);
|
||||
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
|
||||
|
@ -446,6 +446,9 @@ public class RegistryPublisherImpl implements RegistryPublisher {
|
|||
|
||||
private <T extends Resource> HashSet<String> updateResourceScopes(T resource) {
|
||||
HashSet<String> vosScopes = Utils.getInternalVOScopes(resource);
|
||||
// if the resource type is a RunningInstance or a HostingNode the check on the most recent resource is bypassed
|
||||
if((resource.type().toString().equalsIgnoreCase("RunningInstance")) || (resource.type().toString().equalsIgnoreCase("GHN")) || (resource.type().toString().equalsIgnoreCase("GCoreEndpoint")) || (resource.type().toString().equalsIgnoreCase("HostingNode")))
|
||||
return vosScopes;
|
||||
//extract the scopes from the more recent resource found at vo level
|
||||
List <String> latestScopesFound= Utils.setLatestInternalScopes(resource, vosScopes);
|
||||
log.debug("latest scope found are "+latestScopesFound);
|
||||
|
|
|
@ -65,6 +65,7 @@ public class Utils {
|
|||
ScopeBean scopeBean = new ScopeBean(scope);
|
||||
if(scopeBean.is(Type.VRE))
|
||||
vosScopes.add(scopeBean.enclosingScope().toString());
|
||||
else
|
||||
// if the scope is a root-vo scope, it will be added to the vosScope array
|
||||
vosScopes.add(scope);
|
||||
}
|
||||
|
@ -154,6 +155,7 @@ public class Utils {
|
|||
|
||||
private static <T extends Resource> List<String> extractInternalScopes(T resource, String latestVO) {
|
||||
T extractedResource=null;
|
||||
log.debug("checking resource "+resource.id()+" type: "+resource.type());
|
||||
if(resource.type().toString().equalsIgnoreCase("RuntimeResource")){
|
||||
extractedResource= (T)getServiceEndpointByID(resource.id(), latestVO);
|
||||
}else if(resource.type().toString().equalsIgnoreCase("GenericResource")){
|
||||
|
|
|
@ -86,11 +86,11 @@ public class ValidationUtils {
|
|||
}else if(new ScopeBean(scope).is(Type.VO)){
|
||||
log.debug(" "+scope+" is a VO scope");
|
||||
if(anotherSonVREOnResource(resource, scope)){
|
||||
throw new IllegalArgumentException("the resource "+resource.id()+" have another scope defined in the same VO. The VO is "+scope);
|
||||
return false; //throw new IllegalArgumentException("the resource "+resource.id()+" have another scope defined in the same VO. The VO is "+scope);
|
||||
}else return true;
|
||||
}else{ // is a INFRA scope
|
||||
if(anotherInfraScopeOnResource(resource, scope)){
|
||||
throw new IllegalArgumentException("the resource "+resource.id()+" have another scope defined in the same INFRA. The INFRA is "+scope);
|
||||
return false; //throw new IllegalArgumentException("the resource "+resource.id()+" have another scope defined in the same INFRA. The INFRA is "+scope);
|
||||
}else return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue