parent
afbc42eb8b
commit
3585ccc197
|
@ -81,7 +81,7 @@ public class ContextUtility {
|
||||||
return includeInstanceContexts;
|
return includeInstanceContexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCurrentContextFullName() {
|
private static String getCurrentContextFullName() {
|
||||||
String token = SecurityTokenProvider.instance.get();
|
String token = SecurityTokenProvider.instance.get();
|
||||||
AuthorizationEntry authorizationEntry = null;
|
AuthorizationEntry authorizationEntry = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -773,12 +773,12 @@ public abstract class ElementManagement<El extends OElement> {
|
||||||
|
|
||||||
SecurityContext targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
SecurityContext targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
||||||
|
|
||||||
Map<UUID,JsonNode> affectedInstances = internalAddToContext(targetSecurityContext);
|
Map<UUID,JsonNode> affecteElements = internalAddToContext(targetSecurityContext);
|
||||||
|
|
||||||
oDatabaseDocument.commit();
|
oDatabaseDocument.commit();
|
||||||
logger.info("{} with UUID {} successfully added to Context with UUID {}", elementType, uuid, contextUUID);
|
logger.info("{} with UUID {} successfully added to Context with UUID {}", elementType, uuid, contextUUID);
|
||||||
|
|
||||||
return affectedInstances;
|
return affecteElements;
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
logger.error("Unable to add {} with UUID {} to Context with UUID {}", elementType, uuid, contextUUID);
|
logger.error("Unable to add {} with UUID {} to Context with UUID {}", elementType, uuid, contextUUID);
|
||||||
if(oDatabaseDocument != null) {
|
if(oDatabaseDocument != null) {
|
||||||
|
@ -812,12 +812,12 @@ public abstract class ElementManagement<El extends OElement> {
|
||||||
|
|
||||||
SecurityContext targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
SecurityContext targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
||||||
|
|
||||||
Map<UUID,JsonNode> affectedInstances = internalRemoveFromContext(targetSecurityContext);
|
Map<UUID,JsonNode> affecteElements = internalRemoveFromContext(targetSecurityContext);
|
||||||
|
|
||||||
oDatabaseDocument.commit();
|
oDatabaseDocument.commit();
|
||||||
logger.info("{} with UUID {} successfully removed from Context with UUID {}", elementType, uuid, contextUUID);
|
logger.info("{} with UUID {} successfully removed from Context with UUID {}", elementType, uuid, contextUUID);
|
||||||
|
|
||||||
return affectedInstances;
|
return affecteElements;
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
logger.error("Unable to remove {} with UUID {} from Context with UUID {}", elementType, uuid, contextUUID);
|
logger.error("Unable to remove {} with UUID {} from Context with UUID {}", elementType, uuid, contextUUID);
|
||||||
if(oDatabaseDocument != null) {
|
if(oDatabaseDocument != null) {
|
||||||
|
|
|
@ -196,13 +196,10 @@ public abstract class EntityManagement<E extends EntityElement> extends EntityEl
|
||||||
|
|
||||||
Map<UUID,JsonNode> affectedInstances = new HashMap<>();
|
Map<UUID,JsonNode> affectedInstances = new HashMap<>();
|
||||||
|
|
||||||
if(!dryRunContextSharing) {
|
|
||||||
targetSecurityContext.addElement(getElement(), oDatabaseDocument);
|
targetSecurityContext.addElement(getElement(), oDatabaseDocument);
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DO NOT UNCOMMENT
|
* DO NOT UNCOMMENT
|
||||||
* the instance is added in internalAddToContext() function after
|
* the instance is added internalAddToContext() function after
|
||||||
* the update of Header metadata i.e. modifiedBy, lastUpdateTime
|
* the update of Header metadata i.e. modifiedBy, lastUpdateTime
|
||||||
* affectedInstances.put(uuid, serializeSelfOnly());
|
* affectedInstances.put(uuid, serializeSelfOnly());
|
||||||
*/
|
*/
|
||||||
|
@ -210,8 +207,8 @@ public abstract class EntityManagement<E extends EntityElement> extends EntityEl
|
||||||
Iterable<OEdge> edges = getElement().getEdges(ODirection.OUT);
|
Iterable<OEdge> edges = getElement().getEdges(ODirection.OUT);
|
||||||
|
|
||||||
for(OEdge edge : edges) {
|
for(OEdge edge : edges) {
|
||||||
RelationManagement<?> relationManagement = getRelationManagement(edge);
|
@SuppressWarnings("rawtypes")
|
||||||
relationManagement.setDryRunContextSharing(dryRunContextSharing);
|
RelationManagement relationManagement = getRelationManagement(edge);
|
||||||
affectedInstances.putAll(relationManagement.internalAddToContext(targetSecurityContext));
|
affectedInstances.putAll(relationManagement.internalAddToContext(targetSecurityContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,14 +224,12 @@ public abstract class EntityManagement<E extends EntityElement> extends EntityEl
|
||||||
Iterable<OEdge> edges = getElement().getEdges(ODirection.OUT);
|
Iterable<OEdge> edges = getElement().getEdges(ODirection.OUT);
|
||||||
|
|
||||||
for(OEdge edge : edges) {
|
for(OEdge edge : edges) {
|
||||||
RelationManagement<?> relationManagement = getRelationManagement(edge);
|
@SuppressWarnings("rawtypes")
|
||||||
relationManagement.setDryRunContextSharing(dryRunContextSharing);
|
RelationManagement relationManagement = getRelationManagement(edge);
|
||||||
affectedInstances.putAll(relationManagement.internalRemoveFromContext(targetSecurityContext));
|
affectedInstances.putAll(relationManagement.internalRemoveFromContext(targetSecurityContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!dryRunContextSharing) {
|
|
||||||
targetSecurityContext.removeElement(getElement(), oDatabaseDocument);
|
targetSecurityContext.removeElement(getElement(), oDatabaseDocument);
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* DO NOT UNCOMMENT
|
* DO NOT UNCOMMENT
|
||||||
* the instance is added internalAddToContext() function after
|
* the instance is added internalAddToContext() function after
|
||||||
|
|
|
@ -30,7 +30,6 @@ import org.gcube.informationsystem.resourceregistry.instances.base.relations.Rel
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.EntityManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.entities.EntityManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.utils.HeaderUtility;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.utils.PropagationConstraintOrient;
|
import org.gcube.informationsystem.resourceregistry.utils.PropagationConstraintOrient;
|
||||||
import org.gcube.informationsystem.resourceregistry.utils.Utility;
|
import org.gcube.informationsystem.resourceregistry.utils.Utility;
|
||||||
import org.gcube.informationsystem.utils.ElementMapper;
|
import org.gcube.informationsystem.utils.ElementMapper;
|
||||||
|
@ -72,8 +71,6 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
setWorkingContext(workingContext);
|
setWorkingContext(workingContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PropagationConstraint propagationConstraint;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Needed for ResourceManagement.serializeAsJson() function to check that
|
* Needed for ResourceManagement.serializeAsJson() function to check that
|
||||||
* sourceEntityManagement is the same of the instance is creating this
|
* sourceEntityManagement is the same of the instance is creating this
|
||||||
|
@ -272,27 +269,6 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<UUID,JsonNode> internalAddToContext(SecurityContext targetSecurityContext)
|
|
||||||
throws ContextException, ResourceRegistryException {
|
|
||||||
try {
|
|
||||||
Map<UUID,JsonNode> affectedInstances = reallyAddToContext(targetSecurityContext);
|
|
||||||
if(propagationConstraint.getAddConstraint()==PropagationConstraint.AddConstraint.propagate) {
|
|
||||||
if(!dryRunContextSharing) {
|
|
||||||
HeaderUtility.updateModifiedByAndLastUpdate(element);
|
|
||||||
element.save();
|
|
||||||
}
|
|
||||||
affectedInstances.put(uuid, serializeSelfOnly());
|
|
||||||
}
|
|
||||||
return affectedInstances;
|
|
||||||
} catch(ResourceRegistryException e) {
|
|
||||||
throw e;
|
|
||||||
} catch(Exception e) {
|
|
||||||
throw new ResourceRegistryException(
|
|
||||||
"Error Adding " + elementType + " to " + targetSecurityContext.toString(), e.getCause());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Map<UUID,JsonNode> reallyAddToContext(SecurityContext targetSecurityContext)
|
protected Map<UUID,JsonNode> reallyAddToContext(SecurityContext targetSecurityContext)
|
||||||
throws ContextException, ResourceRegistryException {
|
throws ContextException, ResourceRegistryException {
|
||||||
|
@ -303,7 +279,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
AddConstraint addConstraint = AddConstraint.unpropagate;
|
AddConstraint addConstraint = AddConstraint.unpropagate;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
propagationConstraint = Utility.getPropertyDocument(PropagationConstraint.class, element,
|
PropagationConstraint propagationConstraint = Utility.getPropertyDocument(PropagationConstraint.class, element,
|
||||||
Relation.PROPAGATION_CONSTRAINT_PROPERTY);
|
Relation.PROPAGATION_CONSTRAINT_PROPERTY);
|
||||||
if(propagationConstraint.getAddConstraint() != null) {
|
if(propagationConstraint.getAddConstraint() != null) {
|
||||||
addConstraint = propagationConstraint.getAddConstraint();
|
addConstraint = propagationConstraint.getAddConstraint();
|
||||||
|
@ -328,16 +304,12 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
* The relation must be added only in the case the target vertex must be added.
|
* The relation must be added only in the case the target vertex must be added.
|
||||||
* Otherwise we have a relation which point to an entity outside of the context.
|
* Otherwise we have a relation which point to an entity outside of the context.
|
||||||
*/
|
*/
|
||||||
T targetEntityManagement = getTargetEntityManagement();
|
affectedInstances.putAll(getTargetEntityManagement().internalAddToContext(targetSecurityContext));
|
||||||
targetEntityManagement.setDryRunContextSharing(dryRunContextSharing);
|
|
||||||
affectedInstances.putAll(targetEntityManagement.internalAddToContext(targetSecurityContext));
|
|
||||||
|
|
||||||
if(!dryRunContextSharing) {
|
|
||||||
targetSecurityContext.addElement(getElement(), oDatabaseDocument);
|
targetSecurityContext.addElement(getElement(), oDatabaseDocument);
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* DO NOT UNCOMMENT
|
* DO NOT UNCOMMENT
|
||||||
* the relation instance is added in internalAddToContext() function after
|
* the instance is added internalAddToContext() function after
|
||||||
* the update of Header metadata i.e. modifiedBy, lastUpdateTime
|
* the update of Header metadata i.e. modifiedBy, lastUpdateTime
|
||||||
* affectedInstances.put(uuid, serializeSelfOnly());
|
* affectedInstances.put(uuid, serializeSelfOnly());
|
||||||
*/
|
*/
|
||||||
|
@ -361,18 +333,12 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
Map<UUID,JsonNode> affectedInstances = new HashMap<>();
|
Map<UUID,JsonNode> affectedInstances = new HashMap<>();
|
||||||
|
|
||||||
/* Adding source to Context */
|
/* Adding source to Context */
|
||||||
ResourceManagement resourceManagement = getSourceEntityManagement();
|
affectedInstances.putAll(getSourceEntityManagement().internalAddToContext(targetSecurityContext));
|
||||||
resourceManagement.setDryRunContextSharing(dryRunContextSharing);
|
|
||||||
affectedInstances.putAll(resourceManagement.internalAddToContext(targetSecurityContext));
|
|
||||||
|
|
||||||
/* Adding target to Context */
|
/* Adding target to Context */
|
||||||
T targetEntityManagement = getTargetEntityManagement();
|
|
||||||
targetEntityManagement.setDryRunContextSharing(dryRunContextSharing);
|
|
||||||
affectedInstances.putAll(getTargetEntityManagement().internalAddToContext(targetSecurityContext));
|
affectedInstances.putAll(getTargetEntityManagement().internalAddToContext(targetSecurityContext));
|
||||||
|
|
||||||
if(!dryRunContextSharing) {
|
|
||||||
targetSecurityContext.addElement(getElement(), oDatabaseDocument);
|
targetSecurityContext.addElement(getElement(), oDatabaseDocument);
|
||||||
}
|
|
||||||
affectedInstances.put(uuid, serializeSelfOnly());
|
affectedInstances.put(uuid, serializeSelfOnly());
|
||||||
|
|
||||||
return affectedInstances;
|
return affectedInstances;
|
||||||
|
@ -388,7 +354,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
RemoveConstraint removeConstraint = RemoveConstraint.keep;
|
RemoveConstraint removeConstraint = RemoveConstraint.keep;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
propagationConstraint = Utility.getPropertyDocument(PropagationConstraint.class, element,
|
PropagationConstraint propagationConstraint = Utility.getPropertyDocument(PropagationConstraint.class, element,
|
||||||
Relation.PROPAGATION_CONSTRAINT_PROPERTY);
|
Relation.PROPAGATION_CONSTRAINT_PROPERTY);
|
||||||
if(propagationConstraint.getRemoveConstraint() != null) {
|
if(propagationConstraint.getRemoveConstraint() != null) {
|
||||||
removeConstraint = propagationConstraint.getRemoveConstraint();
|
removeConstraint = propagationConstraint.getRemoveConstraint();
|
||||||
|
@ -412,21 +378,16 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
* In any removeConstraint value the relation MUST be removed from context to
|
* In any removeConstraint value the relation MUST be removed from context to
|
||||||
* avoid to have edge having a source outside of the context.
|
* avoid to have edge having a source outside of the context.
|
||||||
*/
|
*/
|
||||||
if(!dryRunContextSharing) {
|
|
||||||
targetSecurityContext.removeElement(getElement(), oDatabaseDocument);
|
targetSecurityContext.removeElement(getElement(), oDatabaseDocument);
|
||||||
}
|
|
||||||
affectedInstances.put(uuid, serializeSelfOnly());
|
affectedInstances.put(uuid, serializeSelfOnly());
|
||||||
|
|
||||||
T targetEntityManagement = getTargetEntityManagement();
|
|
||||||
targetEntityManagement.setDryRunContextSharing(dryRunContextSharing);
|
|
||||||
|
|
||||||
switch(removeConstraint) {
|
switch(removeConstraint) {
|
||||||
case cascade:
|
case cascade:
|
||||||
affectedInstances.putAll(targetEntityManagement.internalRemoveFromContext(targetSecurityContext));
|
affectedInstances.putAll(getTargetEntityManagement().internalRemoveFromContext(targetSecurityContext));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case cascadeWhenOrphan:
|
case cascadeWhenOrphan:
|
||||||
OVertex target = (OVertex) targetEntityManagement.getElement();
|
OVertex target = (OVertex) getTargetEntityManagement().getElement();
|
||||||
|
|
||||||
Iterable<OEdge> iterable = target.getEdges(ODirection.IN);
|
Iterable<OEdge> iterable = target.getEdges(ODirection.IN);
|
||||||
Iterator<OEdge> iterator = iterable.iterator();
|
Iterator<OEdge> iterator = iterable.iterator();
|
||||||
|
@ -451,7 +412,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
"{} point to {} which is not orphan ({} exists). Giving {} directive, it will be not remove from {}.",
|
"{} point to {} which is not orphan ({} exists). Giving {} directive, it will be not remove from {}.",
|
||||||
element, target, edge, removeConstraint, targetSecurityContext);
|
element, target, edge, removeConstraint, targetSecurityContext);
|
||||||
} else {
|
} else {
|
||||||
affectedInstances.putAll(targetEntityManagement.internalRemoveFromContext(targetSecurityContext));
|
affectedInstances.putAll(getTargetEntityManagement().internalRemoveFromContext(targetSecurityContext));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -113,10 +113,12 @@ public class SharingManager {
|
||||||
String type = node.get(Element.CLASS_PROPERTY).asText();
|
String type = node.get(Element.CLASS_PROPERTY).asText();
|
||||||
String instanceId = node.get(IdentifiableElement.HEADER_PROPERTY).get(Header.UUID_PROPERTY).asText();
|
String instanceId = node.get(IdentifiableElement.HEADER_PROPERTY).get(Header.UUID_PROPERTY).asText();
|
||||||
|
|
||||||
ElementManagement<?> elementManagement = ElementManagementUtility.getERManagement(type);
|
@SuppressWarnings("rawtypes")
|
||||||
|
ElementManagement elementManagement = ElementManagementUtility.getERManagement(type);
|
||||||
elementManagement.setUUID(UUID.fromString(instanceId));
|
elementManagement.setUUID(UUID.fromString(instanceId));
|
||||||
elementManagement.setDryRunContextSharing(dryRun);
|
elementManagement.setDryRunContextSharing(dryRun);
|
||||||
|
|
||||||
|
ArrayNode ret = null;
|
||||||
if(operation == SharingOperation.ADD) {
|
if(operation == SharingOperation.ADD) {
|
||||||
affectedInstances.putAll(elementManagement.addToContext(UUID.fromString(contextId)));
|
affectedInstances.putAll(elementManagement.addToContext(UUID.fromString(contextId)));
|
||||||
}else {
|
}else {
|
||||||
|
@ -179,18 +181,17 @@ public class SharingManager {
|
||||||
|
|
||||||
CalledMethodProvider.instance.set(calledMethod.toString());
|
CalledMethodProvider.instance.set(calledMethod.toString());
|
||||||
|
|
||||||
ElementManagement<?> elementManagement = ElementManagementUtility.getERManagement(type);
|
@SuppressWarnings("rawtypes")
|
||||||
|
ElementManagement elementManagement = ElementManagementUtility.getERManagement(type);
|
||||||
elementManagement.setUUID(UUID.fromString(instanceId));
|
elementManagement.setUUID(UUID.fromString(instanceId));
|
||||||
elementManagement.setDryRunContextSharing(dryRun);
|
elementManagement.setDryRunContextSharing(dryRun);
|
||||||
|
|
||||||
UUID contextUUID = UUID.fromString(contextId);
|
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
Map<UUID,JsonNode> affectedInstances = null;
|
Map<UUID,JsonNode> affectedInstances = null;
|
||||||
if(operation == SharingOperation.ADD) {
|
if(operation == SharingOperation.ADD) {
|
||||||
affectedInstances = elementManagement.addToContext(contextUUID);
|
affectedInstances = elementManagement.addToContext(UUID.fromString(contextId));
|
||||||
}else {
|
}else {
|
||||||
affectedInstances = elementManagement.removeFromContext(contextUUID);
|
affectedInstances = elementManagement.removeFromContext(UUID.fromString(contextId));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -8,27 +8,21 @@ import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
||||||
import org.gcube.informationsystem.base.reference.Element;
|
|
||||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
|
||||||
import org.gcube.informationsystem.context.reference.entities.Context;
|
import org.gcube.informationsystem.context.reference.entities.Context;
|
||||||
import org.gcube.informationsystem.model.impl.properties.HeaderImpl;
|
|
||||||
import org.gcube.informationsystem.model.impl.properties.PropagationConstraintImpl;
|
import org.gcube.informationsystem.model.impl.properties.PropagationConstraintImpl;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
|
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
|
||||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.AddConstraint;
|
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.AddConstraint;
|
||||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.RemoveConstraint;
|
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.RemoveConstraint;
|
||||||
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.ContextTest;
|
import org.gcube.informationsystem.resourceregistry.ContextTest;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache;
|
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCacheRenewal;
|
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCacheRenewal;
|
||||||
|
@ -48,7 +42,6 @@ import org.gcube.informationsystem.resourceregistry.instances.base.ElementManage
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.relations.IsRelatedToManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.relations.IsRelatedToManagement;
|
||||||
import org.gcube.informationsystem.types.TypeMapper;
|
|
||||||
import org.gcube.informationsystem.utils.ElementMapper;
|
import org.gcube.informationsystem.utils.ElementMapper;
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.AccessPointFacetImpl;
|
import org.gcube.resourcemanagement.model.impl.entities.facets.AccessPointFacetImpl;
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.CPUFacetImpl;
|
import org.gcube.resourcemanagement.model.impl.entities.facets.CPUFacetImpl;
|
||||||
|
@ -186,231 +179,6 @@ public class BasicTest extends ContextTest {
|
||||||
Assert.assertTrue(deleted);
|
Assert.assertTrue(deleted);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO test add to context to a resource with only one facet and add propagation constraint to unpropagate.
|
|
||||||
// TODO test remove from context to a facet which is the only facet that characterise a Resource.
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void addRemoveDryRunTest() throws Exception {
|
|
||||||
EService eService = new EServiceImpl();
|
|
||||||
|
|
||||||
// I add only one facet to have the possibility to define the tests easier
|
|
||||||
SoftwareFacet softwareFacet = new SoftwareFacetImpl();
|
|
||||||
softwareFacet.setGroup("InformationSystem");
|
|
||||||
softwareFacet.setName("resource-registry");
|
|
||||||
softwareFacet.setVersion("1.1.0");
|
|
||||||
IsIdentifiedBy<EService, Facet> isIdentifiedBy = new IsIdentifiedByImpl<EService, Facet>(
|
|
||||||
eService, softwareFacet, null);
|
|
||||||
eService.addFacet(isIdentifiedBy);
|
|
||||||
|
|
||||||
ResourceManagement resourceManagement = new ResourceManagement();
|
|
||||||
resourceManagement.setElementType(EService.NAME);
|
|
||||||
resourceManagement.setJson(ElementMapper.marshal(eService));
|
|
||||||
|
|
||||||
String json = resourceManagement.create();
|
|
||||||
logger.debug("Created : {}", json);
|
|
||||||
eService = ElementMapper.unmarshal(EService.class, json);
|
|
||||||
logger.debug("Unmarshalled {} {}", EService.NAME, eService);
|
|
||||||
|
|
||||||
Map<UUID, IdentifiableElement> eServiceInstances = new HashMap<>();
|
|
||||||
eServiceInstances.put(eService.getHeader().getUUID(), eService);
|
|
||||||
for(ConsistsOf<?,?> consistsOf : eService.getConsistsOf()) {
|
|
||||||
eServiceInstances.put(consistsOf.getHeader().getUUID(), consistsOf);
|
|
||||||
eServiceInstances.put(consistsOf.getTarget().getHeader().getUUID(), consistsOf.getTarget());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HostingNode hostingNode = new HostingNodeImpl();
|
|
||||||
|
|
||||||
NetworkingFacet networkingFacet = new NetworkingFacetImpl();
|
|
||||||
networkingFacet.setIPAddress("146.48.87.183");
|
|
||||||
networkingFacet.setHostName("pc-frosini.isti.cnr.it");
|
|
||||||
networkingFacet.setDomainName("isti.cnr.it");
|
|
||||||
networkingFacet.setMask("255.255.248.0");
|
|
||||||
networkingFacet.setBroadcastAddress("146.48.87.255");
|
|
||||||
|
|
||||||
IsIdentifiedBy<HostingNode, NetworkingFacet> isIdentifiedByHNNF = new IsIdentifiedByImpl<HostingNode, NetworkingFacet>(
|
|
||||||
hostingNode, networkingFacet, null);
|
|
||||||
hostingNode.addFacet(isIdentifiedByHNNF);
|
|
||||||
|
|
||||||
CPUFacet cpuFacet = new CPUFacetImpl();
|
|
||||||
cpuFacet.setClockSpeed("1 GHz");
|
|
||||||
cpuFacet.setModel("Opteron");
|
|
||||||
cpuFacet.setVendor("AMD");
|
|
||||||
hostingNode.addFacet(cpuFacet);
|
|
||||||
|
|
||||||
MemoryFacet ram = new MemoryFacetImpl();
|
|
||||||
ram.setSize(8);
|
|
||||||
ram.setUnit(MemoryUnit.GB);
|
|
||||||
ram.setUsed(2);
|
|
||||||
|
|
||||||
HasVolatileMemory<HostingNode, MemoryFacet> hasVolatileMemory = new HasVolatileMemoryImpl<HostingNode, MemoryFacet>(
|
|
||||||
hostingNode, ram, null);
|
|
||||||
hostingNode.addFacet(hasVolatileMemory);
|
|
||||||
|
|
||||||
MemoryFacet disk = new MemoryFacetImpl();
|
|
||||||
disk.setSize(256);
|
|
||||||
disk.setUnit(MemoryUnit.GB);
|
|
||||||
disk.setUsed(120);
|
|
||||||
|
|
||||||
HasPersistentMemory<HostingNode, MemoryFacet> hasPersistentMemory = new HasPersistentMemoryImpl<HostingNode, MemoryFacet>(
|
|
||||||
hostingNode, disk, null);
|
|
||||||
hostingNode.addFacet(hasPersistentMemory);
|
|
||||||
|
|
||||||
Activates<HostingNode, EService> activates = new ActivatesImpl<HostingNode, EService>(
|
|
||||||
hostingNode, eService, null);
|
|
||||||
UUID activatedUUID = UUID.randomUUID();
|
|
||||||
activates.setHeader(new HeaderImpl(activatedUUID));
|
|
||||||
hostingNode.attachResource(activates);
|
|
||||||
|
|
||||||
resourceManagement = new ResourceManagement();
|
|
||||||
resourceManagement.setElementType(HostingNode.NAME);
|
|
||||||
resourceManagement.setJson(ElementMapper.marshal(hostingNode));
|
|
||||||
|
|
||||||
String hnJson = resourceManagement.create();
|
|
||||||
logger.debug("Created : {}", hnJson);
|
|
||||||
hostingNode = ElementMapper.unmarshal(HostingNode.class, hnJson);
|
|
||||||
logger.debug("Unmarshalled {} {}", HostingNode.NAME, hostingNode);
|
|
||||||
UUID hostingNodeUUID = hostingNode.getHeader().getUUID();
|
|
||||||
|
|
||||||
|
|
||||||
Map<UUID, IdentifiableElement> hostingNodeInstances = new HashMap<>();
|
|
||||||
hostingNodeInstances.put(hostingNodeUUID, hostingNode);
|
|
||||||
|
|
||||||
for(ConsistsOf<?,?> consistsOf : hostingNode.getConsistsOf()) {
|
|
||||||
hostingNodeInstances.put(consistsOf.getHeader().getUUID(), consistsOf);
|
|
||||||
hostingNodeInstances.put(consistsOf.getTarget().getHeader().getUUID(), consistsOf.getTarget());
|
|
||||||
}
|
|
||||||
|
|
||||||
IsRelatedToManagement isRelatedToManagement = new IsRelatedToManagement();
|
|
||||||
isRelatedToManagement.setElementType(Activates.NAME);
|
|
||||||
isRelatedToManagement.setUUID(activatedUUID);
|
|
||||||
String activatesString = isRelatedToManagement.read();
|
|
||||||
activates = ElementMapper.unmarshal(Activates.class, activatesString);
|
|
||||||
|
|
||||||
Map<UUID, IdentifiableElement> createdInstances = new HashMap<>();
|
|
||||||
createdInstances.putAll(hostingNodeInstances);
|
|
||||||
/* These should not be added due to default propagation constraint for IsRelatedTo relation
|
|
||||||
createdInstances.put(activatedUUID, activates);
|
|
||||||
createdInstances.putAll(eServiceInstances);
|
|
||||||
*/
|
|
||||||
Assert.assertTrue(createdInstances.size()==9);
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
logger.debug("Switching to another scope");
|
|
||||||
ContextTest.setContextByName(ALTERNATIVE_TEST_SCOPE);
|
|
||||||
|
|
||||||
resourceManagement = new ResourceManagement();
|
|
||||||
resourceManagement.setUUID(hostingNodeUUID);
|
|
||||||
|
|
||||||
resourceManagement.setDryRunContextSharing(true);
|
|
||||||
UUID contextUUID = ContextUtility.getCurrentSecurityContext().getUUID();
|
|
||||||
Map<UUID, JsonNode> testAffectedInstances = resourceManagement.addToContext(contextUUID);
|
|
||||||
|
|
||||||
resourceManagement = new ResourceManagement();
|
|
||||||
resourceManagement.setUUID(hostingNodeUUID);
|
|
||||||
|
|
||||||
try {
|
|
||||||
resourceManagement.read();
|
|
||||||
logger.debug("You should not be able to read {} with UUID {} in {} with UUID {} (i.e., {})",
|
|
||||||
HostingNode.NAME, hostingNodeUUID.toString(), Context.NAME, contextUUID, ContextUtility.getCurrentContextFullName());
|
|
||||||
}catch (AvailableInAnotherContextException e) {
|
|
||||||
// OK
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
resourceManagement.setDryRunContextSharing(false);
|
|
||||||
Map<UUID, JsonNode> affectedInstances = resourceManagement.addToContext(contextUUID);
|
|
||||||
logger.debug("Add to Context afffects the following instances {}", affectedInstances.values());
|
|
||||||
|
|
||||||
SortedSet<UUID> testAffectedInstancesUUID = new TreeSet<>(testAffectedInstances.keySet());
|
|
||||||
SortedSet<UUID> affectedInstancesUUID = new TreeSet<>(affectedInstances.keySet());
|
|
||||||
SortedSet<UUID> createdInstancesUUID = new TreeSet<>(createdInstances.keySet());
|
|
||||||
|
|
||||||
logger.debug("Created Instances where {}", createdInstancesUUID);
|
|
||||||
logger.debug("Test Affected Instances where {}", testAffectedInstancesUUID);
|
|
||||||
logger.debug("Affected Instances are {}", affectedInstancesUUID);
|
|
||||||
|
|
||||||
Assert.assertTrue(testAffectedInstancesUUID.size()==affectedInstancesUUID.size());
|
|
||||||
Assert.assertTrue(createdInstancesUUID.size()==affectedInstancesUUID.size());
|
|
||||||
|
|
||||||
Assert.assertTrue(createdInstancesUUID.containsAll(testAffectedInstancesUUID));
|
|
||||||
Assert.assertTrue(testAffectedInstancesUUID.containsAll(createdInstancesUUID));
|
|
||||||
|
|
||||||
Assert.assertTrue(createdInstancesUUID.containsAll(affectedInstancesUUID));
|
|
||||||
Assert.assertTrue(affectedInstancesUUID.containsAll(createdInstancesUUID));
|
|
||||||
|
|
||||||
Assert.assertTrue(testAffectedInstancesUUID.containsAll(affectedInstancesUUID));
|
|
||||||
Assert.assertTrue(affectedInstancesUUID.containsAll(testAffectedInstancesUUID));
|
|
||||||
|
|
||||||
|
|
||||||
for(UUID uuid : affectedInstances.keySet()) {
|
|
||||||
JsonNode testAffectedJsonNode = testAffectedInstances.get(uuid);
|
|
||||||
String testAffectedType = testAffectedJsonNode.get(Element.CLASS_PROPERTY).asText();
|
|
||||||
|
|
||||||
JsonNode affectedJsonNode = affectedInstances.get(uuid);
|
|
||||||
String affectedType = affectedJsonNode.get(Element.CLASS_PROPERTY).asText();
|
|
||||||
|
|
||||||
IdentifiableElement identifiableElement = createdInstances.get(uuid);
|
|
||||||
String createdType = TypeMapper.getType(identifiableElement.getClass());
|
|
||||||
|
|
||||||
Assert.assertTrue(affectedType.compareTo(testAffectedType)==0);
|
|
||||||
Assert.assertTrue(affectedType.compareTo(createdType)==0);
|
|
||||||
}
|
|
||||||
|
|
||||||
resourceManagement = new ResourceManagement();
|
|
||||||
resourceManagement.setUUID(hostingNodeUUID);
|
|
||||||
|
|
||||||
String hnString = resourceManagement.read();
|
|
||||||
HostingNode readHN = ElementMapper.unmarshal(HostingNode.class, hnString);
|
|
||||||
Assert.assertTrue(readHN.getHeader().getUUID().compareTo(hostingNodeUUID) == 0);
|
|
||||||
|
|
||||||
UUID eServiceUUID = eService.getHeader().getUUID();
|
|
||||||
try {
|
|
||||||
resourceManagement = new ResourceManagement();
|
|
||||||
resourceManagement.setUUID(eServiceUUID);
|
|
||||||
resourceManagement.read();
|
|
||||||
} catch (ResourceAvailableInAnotherContextException e) {
|
|
||||||
logger.debug("Resource with {} Not Found as Expected",
|
|
||||||
eServiceUUID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Commented because the behavior has been changed
|
|
||||||
try {
|
|
||||||
resourceManagement = new ResourceManagement();
|
|
||||||
resourceManagement.setUUID(eServiceUUID);
|
|
||||||
resourceManagement.delete();
|
|
||||||
logger.debug("You should not be able to delete EService with UUID {}",
|
|
||||||
uuid);
|
|
||||||
throw new Exception(
|
|
||||||
"You should not be able to delete EService with UUID " + uuid);
|
|
||||||
} catch (ResourceAvailableInAnotherContextException e) {
|
|
||||||
logger.debug("Resource with {} Not Deleted as Expected",
|
|
||||||
eServiceUUID);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
resourceManagement = new ResourceManagement();
|
|
||||||
resourceManagement.setUUID(hostingNodeUUID);
|
|
||||||
boolean deleted = resourceManagement.delete();
|
|
||||||
Assert.assertTrue(deleted);
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
logger.debug("Setting back default scope");
|
|
||||||
ContextTest.setContextByName(DEFAULT_TEST_SCOPE);
|
|
||||||
|
|
||||||
resourceManagement = new ResourceManagement();
|
|
||||||
resourceManagement.setUUID(eServiceUUID);
|
|
||||||
deleted = resourceManagement.delete();
|
|
||||||
Assert.assertTrue(deleted);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateEServiceHostingNode() throws Exception {
|
public void testCreateEServiceHostingNode() throws Exception {
|
||||||
EService eService = new EServiceImpl();
|
EService eService = new EServiceImpl();
|
||||||
|
@ -446,6 +214,7 @@ public class BasicTest extends ContextTest {
|
||||||
"https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11"));
|
"https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11"));
|
||||||
eService.addFacet(licenseFacet);
|
eService.addFacet(licenseFacet);
|
||||||
|
|
||||||
|
|
||||||
ResourceManagement resourceManagement = new ResourceManagement();
|
ResourceManagement resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setElementType(EService.NAME);
|
resourceManagement.setElementType(EService.NAME);
|
||||||
resourceManagement.setJson(ElementMapper.marshal(eService));
|
resourceManagement.setJson(ElementMapper.marshal(eService));
|
||||||
|
@ -455,14 +224,6 @@ public class BasicTest extends ContextTest {
|
||||||
eService = ElementMapper.unmarshal(EService.class, json);
|
eService = ElementMapper.unmarshal(EService.class, json);
|
||||||
logger.debug("Unmarshalled {} {}", EService.NAME, eService);
|
logger.debug("Unmarshalled {} {}", EService.NAME, eService);
|
||||||
|
|
||||||
Map<UUID, IdentifiableElement> eServiceInstances = new HashMap<>();
|
|
||||||
eServiceInstances.put(eService.getHeader().getUUID(), eService);
|
|
||||||
for(ConsistsOf<?,?> consistsOf : eService.getConsistsOf()) {
|
|
||||||
eServiceInstances.put(consistsOf.getHeader().getUUID(), consistsOf);
|
|
||||||
eServiceInstances.put(consistsOf.getTarget().getHeader().getUUID(), consistsOf.getTarget());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HostingNode hostingNode = new HostingNodeImpl();
|
HostingNode hostingNode = new HostingNodeImpl();
|
||||||
|
|
||||||
|
@ -503,8 +264,6 @@ public class BasicTest extends ContextTest {
|
||||||
|
|
||||||
Activates<HostingNode, EService> activates = new ActivatesImpl<HostingNode, EService>(
|
Activates<HostingNode, EService> activates = new ActivatesImpl<HostingNode, EService>(
|
||||||
hostingNode, eService, null);
|
hostingNode, eService, null);
|
||||||
UUID activatedUUID = UUID.randomUUID();
|
|
||||||
activates.setHeader(new HeaderImpl(activatedUUID));
|
|
||||||
hostingNode.attachResource(activates);
|
hostingNode.attachResource(activates);
|
||||||
|
|
||||||
resourceManagement = new ResourceManagement();
|
resourceManagement = new ResourceManagement();
|
||||||
|
@ -515,30 +274,7 @@ public class BasicTest extends ContextTest {
|
||||||
logger.debug("Created : {}", hnJson);
|
logger.debug("Created : {}", hnJson);
|
||||||
hostingNode = ElementMapper.unmarshal(HostingNode.class, hnJson);
|
hostingNode = ElementMapper.unmarshal(HostingNode.class, hnJson);
|
||||||
logger.debug("Unmarshalled {} {}", HostingNode.NAME, hostingNode);
|
logger.debug("Unmarshalled {} {}", HostingNode.NAME, hostingNode);
|
||||||
UUID hostingNodeUUID = hostingNode.getHeader().getUUID();
|
UUID uuid = hostingNode.getHeader().getUUID();
|
||||||
|
|
||||||
|
|
||||||
Map<UUID, IdentifiableElement> hostingNodeInstances = new HashMap<>();
|
|
||||||
hostingNodeInstances.put(hostingNodeUUID, hostingNode);
|
|
||||||
|
|
||||||
for(ConsistsOf<?,?> consistsOf : hostingNode.getConsistsOf()) {
|
|
||||||
hostingNodeInstances.put(consistsOf.getHeader().getUUID(), consistsOf);
|
|
||||||
hostingNodeInstances.put(consistsOf.getTarget().getHeader().getUUID(), consistsOf.getTarget());
|
|
||||||
}
|
|
||||||
|
|
||||||
IsRelatedToManagement isRelatedToManagement = new IsRelatedToManagement();
|
|
||||||
isRelatedToManagement.setElementType(Activates.NAME);
|
|
||||||
isRelatedToManagement.setUUID(activatedUUID);
|
|
||||||
String activatesString = isRelatedToManagement.read();
|
|
||||||
activates = ElementMapper.unmarshal(Activates.class, activatesString);
|
|
||||||
|
|
||||||
Map<UUID, IdentifiableElement> createdInstances = new HashMap<>();
|
|
||||||
createdInstances.putAll(hostingNodeInstances);
|
|
||||||
/* These should not be added due to default propagation constraint for IsRelatedTo relation
|
|
||||||
createdInstances.put(activatedUUID, activates);
|
|
||||||
createdInstances.putAll(eServiceInstances);
|
|
||||||
*/
|
|
||||||
Assert.assertTrue(createdInstances.size()==9);
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
@ -546,69 +282,18 @@ public class BasicTest extends ContextTest {
|
||||||
ContextTest.setContextByName(ALTERNATIVE_TEST_SCOPE);
|
ContextTest.setContextByName(ALTERNATIVE_TEST_SCOPE);
|
||||||
|
|
||||||
resourceManagement = new ResourceManagement();
|
resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setUUID(hostingNodeUUID);
|
resourceManagement.setUUID(uuid);
|
||||||
|
|
||||||
resourceManagement.setDryRunContextSharing(true);
|
Map<UUID, JsonNode> affectedInstaces = resourceManagement.addToContext(ContextUtility.getCurrentSecurityContext().getUUID());
|
||||||
UUID contextUUID = ContextUtility.getCurrentSecurityContext().getUUID();
|
|
||||||
Map<UUID, JsonNode> testAffectedInstances = resourceManagement.addToContext(contextUUID);
|
Assert.assertTrue(affectedInstaces);
|
||||||
|
|
||||||
resourceManagement = new ResourceManagement();
|
resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setUUID(hostingNodeUUID);
|
resourceManagement.setUUID(uuid);
|
||||||
|
|
||||||
try {
|
|
||||||
resourceManagement.read();
|
|
||||||
logger.debug("You should not be able to read {} with UUID {} in {} with UUID {} (i.e., {})",
|
|
||||||
HostingNode.NAME, hostingNodeUUID.toString(), Context.NAME, contextUUID, ContextUtility.getCurrentContextFullName());
|
|
||||||
}catch (AvailableInAnotherContextException e) {
|
|
||||||
// OK
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
resourceManagement.setDryRunContextSharing(false);
|
|
||||||
Map<UUID, JsonNode> affectedInstances = resourceManagement.addToContext(contextUUID);
|
|
||||||
logger.debug("Add to Context afffects the following instances {}", affectedInstances.values());
|
|
||||||
|
|
||||||
SortedSet<UUID> testAffectedInstancesUUID = new TreeSet<>(testAffectedInstances.keySet());
|
|
||||||
SortedSet<UUID> affectedInstancesUUID = new TreeSet<>(affectedInstances.keySet());
|
|
||||||
SortedSet<UUID> createdInstancesUUID = new TreeSet<>(createdInstances.keySet());
|
|
||||||
|
|
||||||
logger.debug("Created Instances where {}", createdInstancesUUID);
|
|
||||||
logger.debug("Test Affected Instances where {}", testAffectedInstancesUUID);
|
|
||||||
logger.debug("Affected Instances are {}", affectedInstancesUUID);
|
|
||||||
|
|
||||||
Assert.assertTrue(testAffectedInstancesUUID.size()==affectedInstancesUUID.size());
|
|
||||||
Assert.assertTrue(createdInstancesUUID.size()==affectedInstancesUUID.size());
|
|
||||||
|
|
||||||
Assert.assertTrue(createdInstancesUUID.containsAll(testAffectedInstancesUUID));
|
|
||||||
Assert.assertTrue(testAffectedInstancesUUID.containsAll(createdInstancesUUID));
|
|
||||||
|
|
||||||
Assert.assertTrue(createdInstancesUUID.containsAll(affectedInstancesUUID));
|
|
||||||
Assert.assertTrue(affectedInstancesUUID.containsAll(createdInstancesUUID));
|
|
||||||
|
|
||||||
Assert.assertTrue(testAffectedInstancesUUID.containsAll(affectedInstancesUUID));
|
|
||||||
Assert.assertTrue(affectedInstancesUUID.containsAll(testAffectedInstancesUUID));
|
|
||||||
|
|
||||||
|
|
||||||
for(UUID uuid : affectedInstances.keySet()) {
|
|
||||||
JsonNode testAffectedJsonNode = testAffectedInstances.get(uuid);
|
|
||||||
String testAffectedType = testAffectedJsonNode.get(Element.CLASS_PROPERTY).asText();
|
|
||||||
|
|
||||||
JsonNode affectedJsonNode = affectedInstances.get(uuid);
|
|
||||||
String affectedType = affectedJsonNode.get(Element.CLASS_PROPERTY).asText();
|
|
||||||
|
|
||||||
IdentifiableElement identifiableElement = createdInstances.get(uuid);
|
|
||||||
String createdType = TypeMapper.getType(identifiableElement.getClass());
|
|
||||||
|
|
||||||
Assert.assertTrue(affectedType.compareTo(testAffectedType)==0);
|
|
||||||
Assert.assertTrue(affectedType.compareTo(createdType)==0);
|
|
||||||
}
|
|
||||||
|
|
||||||
resourceManagement = new ResourceManagement();
|
|
||||||
resourceManagement.setUUID(hostingNodeUUID);
|
|
||||||
|
|
||||||
String hnString = resourceManagement.read();
|
String hnString = resourceManagement.read();
|
||||||
HostingNode readHN = ElementMapper.unmarshal(HostingNode.class, hnString);
|
HostingNode readHN = ElementMapper.unmarshal(HostingNode.class, hnString);
|
||||||
Assert.assertTrue(readHN.getHeader().getUUID().compareTo(hostingNodeUUID) == 0);
|
Assert.assertTrue(readHN.getHeader().getUUID().compareTo(uuid) == 0);
|
||||||
|
|
||||||
UUID eServiceUUID = eService.getHeader().getUUID();
|
UUID eServiceUUID = eService.getHeader().getUUID();
|
||||||
try {
|
try {
|
||||||
|
@ -636,7 +321,7 @@ public class BasicTest extends ContextTest {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
resourceManagement = new ResourceManagement();
|
resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setUUID(hostingNodeUUID);
|
resourceManagement.setUUID(uuid);
|
||||||
boolean deleted = resourceManagement.delete();
|
boolean deleted = resourceManagement.delete();
|
||||||
Assert.assertTrue(deleted);
|
Assert.assertTrue(deleted);
|
||||||
|
|
||||||
|
@ -758,10 +443,8 @@ public class BasicTest extends ContextTest {
|
||||||
|
|
||||||
resourceManagement = new ResourceManagement();
|
resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setUUID(hnUUID);
|
resourceManagement.setUUID(hnUUID);
|
||||||
Map<UUID,JsonNode> affectedInstances = resourceManagement.removeFromContext(ContextUtility.getCurrentSecurityContext().getUUID());
|
Map<String,JsonNode> affectedInstaces = resourceManagement.removeFromContext(ContextUtility.getCurrentSecurityContext().getUUID());
|
||||||
logger.debug("Remove from Context afffects the following instances {}", affectedInstances.values());
|
Assert.assertTrue(affectedInstaces);
|
||||||
|
|
||||||
// Assert.assertTrue(affectedInstaces);
|
|
||||||
|
|
||||||
/* The cascading MUST remove the relation and the target so that
|
/* The cascading MUST remove the relation and the target so that
|
||||||
* I MUST not be able to read Activates relation and EService
|
* I MUST not be able to read Activates relation and EService
|
||||||
|
|
Loading…
Reference in New Issue