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