Reorganizing code
This commit is contained in:
parent
93f5999553
commit
05a8825635
|
@ -27,10 +27,10 @@ public interface ERManagement {
|
||||||
|
|
||||||
public SecurityContext getSourceSecurityContext();
|
public SecurityContext getSourceSecurityContext();
|
||||||
|
|
||||||
public Map<UUID, JsonNode> internalAddToContext()
|
public void internalAddToContext()
|
||||||
throws ContextException, ResourceRegistryException;
|
throws ContextException, ResourceRegistryException;
|
||||||
|
|
||||||
public Map<UUID, JsonNode> addToContext(UUID contextUUID)
|
public void addToContext(UUID contextUUID)
|
||||||
throws SchemaViolationException, NotFoundException, ContextException, ResourceRegistryException;
|
throws SchemaViolationException, NotFoundException, ContextException, ResourceRegistryException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,10 +41,10 @@ public interface ERManagement {
|
||||||
|
|
||||||
public SecurityContext getTargetSecurityContext();
|
public SecurityContext getTargetSecurityContext();
|
||||||
|
|
||||||
public Map<UUID, JsonNode> internalRemoveFromContext()
|
public void internalRemoveFromContext()
|
||||||
throws ContextException, ResourceRegistryException;
|
throws ContextException, ResourceRegistryException;
|
||||||
|
|
||||||
public Map<UUID, JsonNode> removeFromContext(UUID contextUUID)
|
public void removeFromContext(UUID contextUUID)
|
||||||
throws SchemaViolationException, NotFoundException, ContextException, ResourceRegistryException;
|
throws SchemaViolationException, NotFoundException, ContextException, ResourceRegistryException;
|
||||||
|
|
||||||
// public void sanityCheck() throws SchemaViolationException, ResourceRegistryException;
|
// public void sanityCheck() throws SchemaViolationException, ResourceRegistryException;
|
||||||
|
|
|
@ -299,9 +299,8 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<UUID,JsonNode> reallyAddToContext()
|
protected void reallyAddToContext()
|
||||||
throws ContextException, ResourceRegistryException {
|
throws ContextException, ResourceRegistryException {
|
||||||
|
|
||||||
if(!dryRun) {
|
if(!dryRun) {
|
||||||
targetSecurityContext.addElement(getElement(), oDatabaseDocument);
|
targetSecurityContext.addElement(getElement(), oDatabaseDocument);
|
||||||
}
|
}
|
||||||
|
@ -320,15 +319,14 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
||||||
relationManagement.setDryRun(dryRun);
|
relationManagement.setDryRun(dryRun);
|
||||||
relationManagement.setHonourPropagationConstraintsInContextSharing(honourPropagationConstraintsInContextSharing);
|
relationManagement.setHonourPropagationConstraintsInContextSharing(honourPropagationConstraintsInContextSharing);
|
||||||
relationManagement.setTargetSecurityContext(targetSecurityContext);
|
relationManagement.setTargetSecurityContext(targetSecurityContext);
|
||||||
affectedInstances.putAll(relationManagement.internalAddToContext());
|
relationManagement.internalAddToContext();
|
||||||
|
affectedInstances.putAll(relationManagement.getAffectedInstances());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return affectedInstances;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<UUID,JsonNode> internalAddToContext()
|
public void internalAddToContext()
|
||||||
throws ContextException, ResourceRegistryException {
|
throws ContextException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
setOperation(Operation.ADD_TO_CONTEXT);
|
setOperation(Operation.ADD_TO_CONTEXT);
|
||||||
|
@ -339,7 +337,6 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
||||||
}
|
}
|
||||||
affectedInstances.put(uuid, serializeSelfAsJsonNode());
|
affectedInstances.put(uuid, serializeSelfAsJsonNode());
|
||||||
sanityCheck();
|
sanityCheck();
|
||||||
return affectedInstances;
|
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
@ -348,7 +345,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<UUID,JsonNode> addToContext(UUID contextUUID) throws SchemaViolationException, NotFoundException, ContextException, ResourceRegistryException {
|
public void addToContext(UUID contextUUID) throws SchemaViolationException, NotFoundException, ContextException, ResourceRegistryException {
|
||||||
logger.info("Going to add {} with UUID {} to Context with UUID {}", accessType.getName(), uuid, contextUUID);
|
logger.info("Going to add {} with UUID {} to Context with UUID {}", accessType.getName(), uuid, contextUUID);
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
try {
|
try {
|
||||||
|
@ -360,12 +357,10 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
||||||
sourceSecurityContext = ContextUtility.getCurrentSecurityContext();
|
sourceSecurityContext = ContextUtility.getCurrentSecurityContext();
|
||||||
targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
||||||
|
|
||||||
Map<UUID,JsonNode> affectedInstances = internalAddToContext();
|
internalAddToContext();
|
||||||
|
|
||||||
oDatabaseDocument.commit();
|
oDatabaseDocument.commit();
|
||||||
logger.info("{} with UUID {} successfully added to Context with UUID {}", typeName, uuid, contextUUID);
|
logger.info("{} with UUID {} successfully added to Context with UUID {}", typeName, uuid, contextUUID);
|
||||||
|
|
||||||
return affectedInstances;
|
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
logger.error("Unable to add {} with UUID {} to Context with UUID {} - Reason is {}", typeName, uuid, contextUUID, e.getMessage());
|
logger.error("Unable to add {} with UUID {} to Context with UUID {} - Reason is {}", typeName, uuid, contextUUID, e.getMessage());
|
||||||
if(oDatabaseDocument != null) {
|
if(oDatabaseDocument != null) {
|
||||||
|
@ -390,18 +385,17 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<UUID,JsonNode> internalRemoveFromContext()
|
public void internalRemoveFromContext()
|
||||||
throws ContextException, ResourceRegistryException {
|
throws ContextException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
setOperation(Operation.REMOVE_FROM_CONTEXT);
|
setOperation(Operation.REMOVE_FROM_CONTEXT);
|
||||||
Map<UUID,JsonNode> affectedInstances = reallyRemoveFromContext();
|
reallyRemoveFromContext();
|
||||||
if(!dryRun) {
|
if(!dryRun) {
|
||||||
HeaderUtility.updateModifiedByAndLastUpdate(element);
|
HeaderUtility.updateModifiedByAndLastUpdate(element);
|
||||||
element.save();
|
element.save();
|
||||||
}
|
}
|
||||||
affectedInstances.put(uuid, serializeSelfAsJsonNode());
|
affectedInstances.put(uuid, serializeSelfAsJsonNode());
|
||||||
sanityCheck();
|
sanityCheck();
|
||||||
return affectedInstances;
|
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
@ -421,7 +415,8 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
||||||
relationManagement.setDryRun(dryRun);
|
relationManagement.setDryRun(dryRun);
|
||||||
relationManagement.setHonourPropagationConstraintsInContextSharing(honourPropagationConstraintsInContextSharing);
|
relationManagement.setHonourPropagationConstraintsInContextSharing(honourPropagationConstraintsInContextSharing);
|
||||||
relationManagement.setTargetSecurityContext(targetSecurityContext);
|
relationManagement.setTargetSecurityContext(targetSecurityContext);
|
||||||
affectedInstances.putAll(relationManagement.internalRemoveFromContext());
|
relationManagement.internalRemoveFromContext();
|
||||||
|
affectedInstances.putAll(relationManagement.getAffectedInstances());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,7 +433,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
||||||
return affectedInstances;
|
return affectedInstances;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<UUID,JsonNode> removeFromContext(UUID contextUUID)
|
public void removeFromContext(UUID contextUUID)
|
||||||
throws SchemaViolationException, NotFoundException, ContextException, ResourceRegistryException {
|
throws SchemaViolationException, NotFoundException, ContextException, ResourceRegistryException {
|
||||||
|
|
||||||
logger.debug("Going to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
|
logger.debug("Going to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
|
||||||
|
@ -455,8 +450,6 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
||||||
|
|
||||||
oDatabaseDocument.commit();
|
oDatabaseDocument.commit();
|
||||||
logger.info("{} with UUID {} successfully removed from Context with UUID {}", typeName, uuid, contextUUID);
|
logger.info("{} with UUID {} successfully removed from Context with UUID {}", typeName, uuid, contextUUID);
|
||||||
|
|
||||||
return affectedInstances;
|
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
logger.error("Unable to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
|
logger.error("Unable to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
|
||||||
if(oDatabaseDocument != null) {
|
if(oDatabaseDocument != null) {
|
||||||
|
|
|
@ -6,7 +6,6 @@ import java.util.Iterator;
|
||||||
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.UUID;
|
|
||||||
|
|
||||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||||
import org.gcube.informationsystem.base.reference.AccessType;
|
import org.gcube.informationsystem.base.reference.AccessType;
|
||||||
|
@ -240,7 +239,7 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Map<UUID,JsonNode> reallyAddToContext()
|
protected void reallyAddToContext()
|
||||||
throws ContextException, ResourceRegistryException {
|
throws ContextException, ResourceRegistryException {
|
||||||
|
|
||||||
if(!dryRun) {
|
if(!dryRun) {
|
||||||
|
@ -264,10 +263,10 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
|
||||||
relationManagement.setDryRun(dryRun);
|
relationManagement.setDryRun(dryRun);
|
||||||
relationManagement.setHonourPropagationConstraintsInContextSharing(honourPropagationConstraintsInContextSharing);
|
relationManagement.setHonourPropagationConstraintsInContextSharing(honourPropagationConstraintsInContextSharing);
|
||||||
relationManagement.setTargetSecurityContext(targetSecurityContext);
|
relationManagement.setTargetSecurityContext(targetSecurityContext);
|
||||||
Map<UUID,JsonNode> resourceCharacterisationInstances = relationManagement.internalAddToContext();
|
relationManagement.internalAddToContext();
|
||||||
affectedInstances.putAll(resourceCharacterisationInstances);
|
affectedInstances.putAll(relationManagement.getAffectedInstances());
|
||||||
if(relationManagement instanceof ConsistsOfManagement) {
|
if(relationManagement instanceof ConsistsOfManagement) {
|
||||||
facetCounter = facetCounter + resourceCharacterisationInstances.size();
|
facetCounter = facetCounter + relationManagement.getAffectedInstances().size();
|
||||||
}
|
}
|
||||||
relationManagement.sanityCheck();
|
relationManagement.sanityCheck();
|
||||||
}
|
}
|
||||||
|
@ -285,8 +284,7 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
|
||||||
throw new ResourceRegistryException(stringBuffer.toString());
|
throw new ResourceRegistryException(stringBuffer.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return affectedInstances;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String all(boolean polymorphic) throws ResourceRegistryException {
|
public String all(boolean polymorphic) throws ResourceRegistryException {
|
||||||
|
|
|
@ -415,11 +415,11 @@ 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();
|
getTargetEntityManagement().setDryRun(dryRun);
|
||||||
targetEntityManagement.setDryRun(dryRun);
|
|
||||||
targetEntityManagement.setHonourPropagationConstraintsInContextSharing(honourPropagationConstraintsInContextSharing);
|
targetEntityManagement.setHonourPropagationConstraintsInContextSharing(honourPropagationConstraintsInContextSharing);
|
||||||
targetEntityManagement.setTargetSecurityContext(targetSecurityContext);
|
targetEntityManagement.setTargetSecurityContext(targetSecurityContext);
|
||||||
affectedInstances.putAll(targetEntityManagement.internalAddToContext());
|
targetEntityManagement.internalAddToContext();
|
||||||
|
affectedInstances.putAll(targetEntityManagement.getAffectedInstances());
|
||||||
|
|
||||||
if(!dryRun) {
|
if(!dryRun) {
|
||||||
targetSecurityContext.addElement(getElement(), oDatabaseDocument);
|
targetSecurityContext.addElement(getElement(), oDatabaseDocument);
|
||||||
|
@ -455,7 +455,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<UUID,JsonNode> internalAddToContext()
|
public void internalAddToContext()
|
||||||
throws ContextException, ResourceRegistryException {
|
throws ContextException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
operation = Operation.ADD_TO_CONTEXT;
|
operation = Operation.ADD_TO_CONTEXT;
|
||||||
|
@ -467,7 +467,6 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
}
|
}
|
||||||
affectedInstances.put(uuid, serializeSelfAsJsonNode());
|
affectedInstances.put(uuid, serializeSelfAsJsonNode());
|
||||||
}
|
}
|
||||||
return affectedInstances;
|
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
@ -478,23 +477,21 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
|
|
||||||
public Map<UUID,JsonNode> forcedAddToContext()
|
public Map<UUID,JsonNode> forcedAddToContext()
|
||||||
throws ContextException, ResourceRegistryException {
|
throws ContextException, ResourceRegistryException {
|
||||||
getElement();
|
|
||||||
|
|
||||||
setOperation(Operation.ADD_TO_CONTEXT);
|
setOperation(Operation.ADD_TO_CONTEXT);
|
||||||
|
|
||||||
/* Adding source to Context */
|
/* Adding source to Context */
|
||||||
ResourceManagement resourceManagement = getSourceEntityManagement();
|
getSourceEntityManagement().setDryRun(dryRun);
|
||||||
resourceManagement.setDryRun(dryRun);
|
sourceEntityManagement.setHonourPropagationConstraintsInContextSharing(honourPropagationConstraintsInContextSharing);
|
||||||
resourceManagement.setHonourPropagationConstraintsInContextSharing(honourPropagationConstraintsInContextSharing);
|
sourceEntityManagement.setTargetSecurityContext(targetSecurityContext);
|
||||||
resourceManagement.setTargetSecurityContext(targetSecurityContext);
|
sourceEntityManagement.internalAddToContext();
|
||||||
affectedInstances.putAll(resourceManagement.internalAddToContext());
|
affectedInstances.putAll(sourceEntityManagement.getAffectedInstances());
|
||||||
|
|
||||||
/* Adding target to Context */
|
/* Adding target to Context */
|
||||||
T targetEntityManagement = getTargetEntityManagement();
|
getTargetEntityManagement().setDryRun(dryRun);
|
||||||
targetEntityManagement.setDryRun(dryRun);
|
|
||||||
targetEntityManagement.setHonourPropagationConstraintsInContextSharing(honourPropagationConstraintsInContextSharing);
|
targetEntityManagement.setHonourPropagationConstraintsInContextSharing(honourPropagationConstraintsInContextSharing);
|
||||||
targetEntityManagement.setTargetSecurityContext(targetSecurityContext);
|
targetEntityManagement.setTargetSecurityContext(targetSecurityContext);
|
||||||
affectedInstances.putAll(getTargetEntityManagement().internalAddToContext());
|
targetEntityManagement.internalAddToContext();
|
||||||
|
affectedInstances.putAll(targetEntityManagement.getAffectedInstances());
|
||||||
|
|
||||||
if(!dryRun) {
|
if(!dryRun) {
|
||||||
targetSecurityContext.addElement(getElement(), oDatabaseDocument);
|
targetSecurityContext.addElement(getElement(), oDatabaseDocument);
|
||||||
|
@ -505,7 +502,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<UUID,JsonNode> addToContext(UUID contextUUID) throws NotFoundException, ContextException {
|
public void addToContext(UUID contextUUID) throws NotFoundException, ContextException {
|
||||||
logger.debug("Going to add {} with UUID {} to Context with UUID {}", accessType.getName(), uuid, contextUUID);
|
logger.debug("Going to add {} with UUID {} to Context with UUID {}", accessType.getName(), uuid, contextUUID);
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
try {
|
try {
|
||||||
|
@ -522,8 +519,6 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
oDatabaseDocument.commit();
|
oDatabaseDocument.commit();
|
||||||
logger.info("{} with UUID {} successfully added to Context with UUID {}", accessType.getName(), uuid,
|
logger.info("{} with UUID {} successfully added to Context with UUID {}", accessType.getName(), uuid,
|
||||||
contextUUID);
|
contextUUID);
|
||||||
|
|
||||||
return affectedInstances;
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
logger.error("Unable to add {} with UUID {} to Context with UUID {}", accessType.getName(), uuid,
|
logger.error("Unable to add {} with UUID {} to Context with UUID {}", accessType.getName(), uuid,
|
||||||
contextUUID, e);
|
contextUUID, e);
|
||||||
|
@ -586,7 +581,8 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
targetEntityManagement.setTargetSecurityContext(targetSecurityContext);
|
targetEntityManagement.setTargetSecurityContext(targetSecurityContext);
|
||||||
switch(removeConstraint) {
|
switch(removeConstraint) {
|
||||||
case cascade:
|
case cascade:
|
||||||
affectedInstances.putAll(targetEntityManagement.internalRemoveFromContext());
|
targetEntityManagement.internalRemoveFromContext();
|
||||||
|
affectedInstances.putAll(targetEntityManagement.getAffectedInstances());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case cascadeWhenOrphan:
|
case cascadeWhenOrphan:
|
||||||
|
@ -615,7 +611,8 @@ 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());
|
targetEntityManagement.internalRemoveFromContext();
|
||||||
|
affectedInstances.putAll(targetEntityManagement.getAffectedInstances());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -630,7 +627,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<UUID,JsonNode> internalRemoveFromContext()
|
public void internalRemoveFromContext()
|
||||||
throws ContextException, ResourceRegistryException {
|
throws ContextException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
setOperation(Operation.REMOVE_FROM_CONTEXT);
|
setOperation(Operation.REMOVE_FROM_CONTEXT);
|
||||||
|
@ -640,7 +637,6 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
element.save();
|
element.save();
|
||||||
}
|
}
|
||||||
affectedInstances.put(uuid, serializeSelfAsJsonNode());
|
affectedInstances.put(uuid, serializeSelfAsJsonNode());
|
||||||
return affectedInstances;
|
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
@ -650,7 +646,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<UUID,JsonNode> removeFromContext(UUID contextUUID)
|
public void removeFromContext(UUID contextUUID)
|
||||||
throws NotFoundException, ContextException, ResourceRegistryException {
|
throws NotFoundException, ContextException, ResourceRegistryException {
|
||||||
logger.debug("Going to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
|
logger.debug("Going to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
|
@ -668,8 +664,6 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
|
|
||||||
oDatabaseDocument.commit();
|
oDatabaseDocument.commit();
|
||||||
logger.info("{} with UUID {} successfully removed from Context with UUID {}", typeName, uuid, contextUUID);
|
logger.info("{} with UUID {} successfully removed from Context with UUID {}", typeName, uuid, contextUUID);
|
||||||
|
|
||||||
return affectedInstances;
|
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
logger.error("Unable to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
|
logger.error("Unable to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
|
||||||
if(oDatabaseDocument != null) {
|
if(oDatabaseDocument != null) {
|
||||||
|
|
|
@ -190,16 +190,16 @@ public class SharingManager {
|
||||||
|
|
||||||
UUID contextUUID = UUID.fromString(contextId);
|
UUID contextUUID = UUID.fromString(contextId);
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
|
||||||
Map<UUID,JsonNode> affectedInstances = null;
|
|
||||||
if(operation == SharingOperation.ADD) {
|
if(operation == SharingOperation.ADD) {
|
||||||
affectedInstances = ((ERManagement) elementManagement).addToContext(contextUUID);
|
((ERManagement) elementManagement).addToContext(contextUUID);
|
||||||
}else {
|
}else {
|
||||||
affectedInstances = ((ERManagement) elementManagement).removeFromContext(contextUUID);
|
((ERManagement) elementManagement).removeFromContext(contextUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return serializeAffectedInstaces(objectMapper, affectedInstances);
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
return serializeAffectedInstaces(objectMapper, elementManagement.getAffectedInstances());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ResourceRegistryException(e);
|
throw new ResourceRegistryException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,7 +153,8 @@ public class FacetManagementTest extends ContextTest {
|
||||||
facetManagement.setElementType(facetType);
|
facetManagement.setElementType(facetType);
|
||||||
facetManagement.setUUID(facet.getHeader().getUUID());
|
facetManagement.setUUID(facet.getHeader().getUUID());
|
||||||
|
|
||||||
Map<UUID,JsonNode> affectedInstances = facetManagement.addToContext(ContextUtility.getCurrentSecurityContext().getUUID());
|
facetManagement.addToContext(ContextUtility.getCurrentSecurityContext().getUUID());
|
||||||
|
Map<UUID,JsonNode> affectedInstances = facetManagement.getAffectedInstances();
|
||||||
Assert.assertTrue(affectedInstances.containsKey(facet.getHeader().getUUID()));
|
Assert.assertTrue(affectedInstances.containsKey(facet.getHeader().getUUID()));
|
||||||
Assert.assertTrue(affectedInstances.size()==1);
|
Assert.assertTrue(affectedInstances.size()==1);
|
||||||
|
|
||||||
|
@ -166,7 +167,8 @@ public class FacetManagementTest extends ContextTest {
|
||||||
facetManagement.setElementType(facetType);
|
facetManagement.setElementType(facetType);
|
||||||
facetManagement.setUUID(facet.getHeader().getUUID());
|
facetManagement.setUUID(facet.getHeader().getUUID());
|
||||||
|
|
||||||
Map<UUID,JsonNode> affectedInstances = facetManagement.removeFromContext(ContextUtility.getCurrentSecurityContext().getUUID());
|
facetManagement.removeFromContext(ContextUtility.getCurrentSecurityContext().getUUID());
|
||||||
|
Map<UUID,JsonNode> affectedInstances = facetManagement.getAffectedInstances();
|
||||||
Assert.assertTrue(affectedInstances.containsKey(facet.getHeader().getUUID()));
|
Assert.assertTrue(affectedInstances.containsKey(facet.getHeader().getUUID()));
|
||||||
Assert.assertTrue(affectedInstances.size()==1);
|
Assert.assertTrue(affectedInstances.size()==1);
|
||||||
|
|
||||||
|
|
|
@ -396,7 +396,8 @@ public class BasicTest extends MultiContextTest {
|
||||||
|
|
||||||
resourceManagement = new ResourceManagement();
|
resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setUUID(hnUUID);
|
resourceManagement.setUUID(hnUUID);
|
||||||
Map<UUID,JsonNode> affectedInstances = resourceManagement.removeFromContext(ContextUtility.getCurrentSecurityContext().getUUID());
|
resourceManagement.removeFromContext(ContextUtility.getCurrentSecurityContext().getUUID());
|
||||||
|
Map<UUID,JsonNode> affectedInstances = resourceManagement.getAffectedInstances();
|
||||||
logger.debug("Remove from Context affects the following instances {}", affectedInstances.values());
|
logger.debug("Remove from Context affects the following instances {}", affectedInstances.values());
|
||||||
|
|
||||||
// Assert.assertTrue(affectedInstaces);
|
// Assert.assertTrue(affectedInstaces);
|
||||||
|
|
|
@ -82,8 +82,9 @@ public class MultiContextTest extends ContextTest {
|
||||||
resourceManagement.setUUID(r.getHeader().getUUID());
|
resourceManagement.setUUID(r.getHeader().getUUID());
|
||||||
resourceManagement.setDryRun(dryRun);
|
resourceManagement.setDryRun(dryRun);
|
||||||
UUID contextUUID = ContextUtility.getCurrentSecurityContext().getUUID();
|
UUID contextUUID = ContextUtility.getCurrentSecurityContext().getUUID();
|
||||||
Map<UUID, JsonNode> affectedInstances = resourceManagement.removeFromContext(contextUUID);
|
resourceManagement.removeFromContext(contextUUID);
|
||||||
|
Map<UUID, JsonNode> affectedInstances = resourceManagement.getAffectedInstances();
|
||||||
|
|
||||||
SortedSet<UUID> expectedInstancesUUID = new TreeSet<>(expectedInstances.keySet());
|
SortedSet<UUID> expectedInstancesUUID = new TreeSet<>(expectedInstances.keySet());
|
||||||
SortedSet<UUID> affectedInstancesUUID = new TreeSet<>(affectedInstances.keySet());
|
SortedSet<UUID> affectedInstancesUUID = new TreeSet<>(affectedInstances.keySet());
|
||||||
|
|
||||||
|
@ -189,7 +190,8 @@ public class MultiContextTest extends ContextTest {
|
||||||
resourceManagement.setUUID(r.getHeader().getUUID());
|
resourceManagement.setUUID(r.getHeader().getUUID());
|
||||||
resourceManagement.setDryRun(dryRun);
|
resourceManagement.setDryRun(dryRun);
|
||||||
UUID contextUUID = ContextUtility.getInstance().getSecurityContextByFullName(targetContextFullName).getUUID();
|
UUID contextUUID = ContextUtility.getInstance().getSecurityContextByFullName(targetContextFullName).getUUID();
|
||||||
Map<UUID, JsonNode> affectedInstances = resourceManagement.addToContext(contextUUID);
|
resourceManagement.addToContext(contextUUID);
|
||||||
|
Map<UUID, JsonNode> affectedInstances = resourceManagement.getAffectedInstances();
|
||||||
|
|
||||||
SortedSet<UUID> expectedInstancesUUID = new TreeSet<>(expectedInstances.keySet());
|
SortedSet<UUID> expectedInstancesUUID = new TreeSet<>(expectedInstances.keySet());
|
||||||
SortedSet<UUID> affectedInstancesUUID = new TreeSet<>(affectedInstances.keySet());
|
SortedSet<UUID> affectedInstancesUUID = new TreeSet<>(affectedInstances.keySet());
|
||||||
|
|
Loading…
Reference in New Issue