Add To Context adds only the ERElement in the source context #12218
This commit is contained in:
parent
a1fbd07378
commit
78d1f71aa6
|
@ -239,6 +239,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
|||
return sourceResource;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected OVertex createVertex() throws EntityAlreadyPresentException, ResourceRegistryException {
|
||||
|
||||
logger.trace("Going to create {} for {} ({}) using {}", OVertex.class.getSimpleName(), accessType.getName(),
|
||||
|
@ -301,6 +302,12 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
|||
|
||||
protected void reallyAddToContext()
|
||||
throws ContextException, ResourceRegistryException {
|
||||
if(!sourceSecurityContext.isElementInContext(getElement())) {
|
||||
// The element in not in the source security context. It will be skipped
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
targetSecurityContext.addElement(getElement(), oDatabaseDocument);
|
||||
|
||||
/*
|
||||
|
@ -316,6 +323,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
|||
RelationManagement<?,?> relationManagement = getRelationManagement(edge);
|
||||
relationManagement.setDryRun(dryRun);
|
||||
relationManagement.setHonourPropagationConstraintsInContextSharing(honourPropagationConstraintsInContextSharing);
|
||||
relationManagement.setSourceSecurityContext(sourceSecurityContext);
|
||||
relationManagement.setTargetSecurityContext(targetSecurityContext);
|
||||
relationManagement.internalAddToContext();
|
||||
affectedInstances.putAll(relationManagement.getAffectedInstances());
|
||||
|
@ -341,6 +349,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||
|
@ -405,6 +414,11 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
|||
protected void reallyRemoveFromContext()
|
||||
throws ContextException, ResourceRegistryException {
|
||||
|
||||
if(!targetSecurityContext.isElementInContext(getElement())) {
|
||||
// The element in not in the source security context. It will be skipped
|
||||
return;
|
||||
}
|
||||
|
||||
if(honourPropagationConstraintsInContextSharing) {
|
||||
Iterable<OEdge> edges = getElement().getEdges(ODirection.OUT);
|
||||
|
||||
|
@ -412,6 +426,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
|||
RelationManagement<?,?> relationManagement = getRelationManagement(edge);
|
||||
relationManagement.setDryRun(dryRun);
|
||||
relationManagement.setHonourPropagationConstraintsInContextSharing(honourPropagationConstraintsInContextSharing);
|
||||
// Not needed relationManagement.setSourceSecurityContext(sourceSecurityContext);
|
||||
relationManagement.setTargetSecurityContext(targetSecurityContext);
|
||||
relationManagement.internalRemoveFromContext();
|
||||
addToRelationManagements(relationManagement);
|
||||
|
@ -429,6 +444,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
|||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFromContext(UUID contextUUID)
|
||||
throws SchemaViolationException, NotFoundException, ContextException, ResourceRegistryException {
|
||||
|
||||
|
@ -440,6 +456,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
|||
oDatabaseDocument.begin();
|
||||
setAsEntryPoint();
|
||||
|
||||
// Not needed sourceSecurityContext = ContextUtility.getCurrentSecurityContext();
|
||||
targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
||||
|
||||
internalRemoveFromContext();
|
||||
|
|
|
@ -74,11 +74,17 @@ public class FacetManagement extends EntityManagement<Facet, FacetType> {
|
|||
consistsOfManagement = new ConsistsOfManagement();
|
||||
consistsOfManagement.setElement(oEdge);
|
||||
consistsOfManagement.setTargetEntityManagement(this);
|
||||
// Not needed consistsOfManagement.setSourceSecurityContext(sourceSecurityContext);
|
||||
consistsOfManagement.setTargetSecurityContext(targetSecurityContext);
|
||||
|
||||
|
||||
affectedInstances.put(uuid, consistsOfManagement.serializeAsAffectedInstance());
|
||||
|
||||
OVertex oVertex = getElement().getVertices(ODirection.IN).iterator().next();
|
||||
resourceManagement = new ResourceManagement();
|
||||
resourceManagement.setElement(oVertex);
|
||||
// Not needed resourceManagement.setSourceSecurityContext(sourceSecurityContext);
|
||||
resourceManagement.setTargetSecurityContext(targetSecurityContext);
|
||||
resourceManagement.addToRelationManagements(consistsOfManagement);
|
||||
}
|
||||
super.reallyRemoveFromContext();
|
||||
|
@ -134,12 +140,16 @@ public class FacetManagement extends EntityManagement<Facet, FacetType> {
|
|||
break;
|
||||
|
||||
case ADD_TO_CONTEXT:
|
||||
resourceManagement.setSourceSecurityContext(sourceSecurityContext);
|
||||
resourceManagement.setTargetSecurityContext(targetSecurityContext);
|
||||
resourceManagement.setWorkingContext(targetSecurityContext);
|
||||
targetSecurityContextODatabaseDocument = targetSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
||||
resourceManagement.setODatabaseDocument(targetSecurityContextODatabaseDocument);
|
||||
break;
|
||||
|
||||
case REMOVE_FROM_CONTEXT:
|
||||
// Not needed resourceManagement.setSourceSecurityContext(sourceSecurityContext);
|
||||
resourceManagement.setTargetSecurityContext(targetSecurityContext);
|
||||
resourceManagement.setWorkingContext(targetSecurityContext);
|
||||
targetSecurityContextODatabaseDocument = targetSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
||||
resourceManagement.setODatabaseDocument(targetSecurityContextODatabaseDocument);
|
||||
|
|
|
@ -278,6 +278,7 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
|
|||
RelationManagement<?,?> relationManagement = getRelationManagement(edge);
|
||||
relationManagement.setDryRun(dryRun);
|
||||
relationManagement.setHonourPropagationConstraintsInContextSharing(honourPropagationConstraintsInContextSharing);
|
||||
relationManagement.setSourceSecurityContext(sourceSecurityContext);
|
||||
relationManagement.setTargetSecurityContext(targetSecurityContext);
|
||||
relationManagement.internalAddToContext();
|
||||
affectedInstances.putAll(relationManagement.getAffectedInstances());
|
||||
|
@ -432,6 +433,7 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
|
|||
if(relationManagement == null) {
|
||||
try {
|
||||
relationManagement = ElementManagementUtility.getRelationManagement(targetSecurityContext, oDatabaseDocument, edge);
|
||||
relationManagement.setSourceSecurityContext(sourceSecurityContext);
|
||||
relationManagements.put(id, relationManagement);
|
||||
}catch (AvailableInAnotherContextException e) {
|
||||
continue;
|
||||
|
|
|
@ -119,6 +119,10 @@ public class ConsistsOfManagement extends RelationManagement<FacetManagement, Fa
|
|||
resourceManagement = new ResourceManagement();
|
||||
resourceManagement.setElementType(sourceEntityManagement.getTypeName());
|
||||
resourceManagement.setUUID(sourceEntityManagement.getUUID());
|
||||
if(operation == Operation.ADD_TO_CONTEXT) {
|
||||
resourceManagement.setSourceSecurityContext(sourceSecurityContext);
|
||||
}
|
||||
resourceManagement.setTargetSecurityContext(targetSecurityContext);
|
||||
resourceManagement.setWorkingContext(targetSecurityContext);
|
||||
targetSecurityContextODatabaseDocument = targetSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
||||
resourceManagement.setODatabaseDocument(targetSecurityContextODatabaseDocument);
|
||||
|
|
|
@ -369,7 +369,10 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
|||
|
||||
protected void reallyAddToContext()
|
||||
throws ContextException, ResourceRegistryException {
|
||||
getElement();
|
||||
if(!sourceSecurityContext.isElementInContext(getElement())) {
|
||||
// The element in not in the source security context. It will be skipped
|
||||
return;
|
||||
}
|
||||
|
||||
if(honourPropagationConstraintsInContextSharing) {
|
||||
AddConstraint addConstraint = AddConstraint.unpropagate;
|
||||
|
@ -402,6 +405,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
|||
*/
|
||||
getTargetEntityManagement().setDryRun(dryRun);
|
||||
targetEntityManagement.setHonourPropagationConstraintsInContextSharing(honourPropagationConstraintsInContextSharing);
|
||||
targetEntityManagement.setSourceSecurityContext(sourceSecurityContext);
|
||||
targetEntityManagement.setTargetSecurityContext(targetSecurityContext);
|
||||
targetEntityManagement.internalAddToContext();
|
||||
affectedInstances.putAll(targetEntityManagement.getAffectedInstances());
|
||||
|
@ -485,6 +489,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
|||
oDatabaseDocument = workingContext.getDatabaseDocument(PermissionMode.WRITER);
|
||||
setAsEntryPoint();
|
||||
|
||||
sourceSecurityContext = ContextUtility.getCurrentSecurityContext();
|
||||
targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
||||
|
||||
forcedAddToContext();
|
||||
|
@ -518,7 +523,10 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
|||
|
||||
protected Map<UUID,JsonNode> reallyRemoveFromContext()
|
||||
throws ContextException, ResourceRegistryException {
|
||||
getElement();
|
||||
if(!targetSecurityContext.isElementInContext(getElement())) {
|
||||
// The element in not in the source security context. It will be skipped
|
||||
return affectedInstances;
|
||||
}
|
||||
|
||||
getSourceEntityManagement().getElement();
|
||||
|
||||
|
@ -556,6 +564,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
|||
T targetEntityManagement = getTargetEntityManagement();
|
||||
targetEntityManagement.setDryRun(dryRun);
|
||||
targetEntityManagement.setHonourPropagationConstraintsInContextSharing(honourPropagationConstraintsInContextSharing);
|
||||
// Not needed targetEntityManagement.setSourceSecurityContext(sourceSecurityContext);
|
||||
targetEntityManagement.setTargetSecurityContext(targetSecurityContext);
|
||||
if(targetEntityManagement instanceof ResourceManagement) {
|
||||
((ResourceManagement) targetEntityManagement).setSanityCheckNotRequired();
|
||||
|
@ -635,6 +644,8 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
|||
oDatabaseDocument.begin();
|
||||
setAsEntryPoint();
|
||||
|
||||
|
||||
// Not needed sourceSecurityContext = ContextUtility.getCurrentSecurityContext();
|
||||
targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
||||
|
||||
internalRemoveFromContext();
|
||||
|
|
|
@ -143,6 +143,8 @@ public class BasicTest extends MultiContextTest {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreateEServiceHostingNode() throws Exception {
|
||||
EService eService = ERManagementTest.createEService();
|
||||
|
|
Loading…
Reference in New Issue