Fixing corner case

This commit is contained in:
Luca Frosini 2021-03-05 18:14:07 +01:00
parent 6afde17b0f
commit d7ed728c81
5 changed files with 26 additions and 3 deletions

View File

@ -414,6 +414,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
relationManagement.setHonourPropagationConstraintsInContextSharing(honourPropagationConstraintsInContextSharing);
relationManagement.setTargetSecurityContext(targetSecurityContext);
relationManagement.internalRemoveFromContext();
addToRelationManagements(relationManagement);
affectedInstances.putAll(relationManagement.getAffectedInstances());
}
}

View File

@ -70,9 +70,16 @@ public class FacetManagement extends EntityManagement<Facet, FacetType> {
protected void reallyRemoveFromContext()
throws ContextException, ResourceRegistryException {
if(entryPoint) {
OEdge oEdge = getElement().getEdges(ODirection.IN).iterator().next();
consistsOfManagement = new ConsistsOfManagement();
consistsOfManagement.setElement(oEdge);
consistsOfManagement.setTargetEntityManagement(this);
affectedInstances.put(uuid, consistsOfManagement.serializeSelfAsJsonNode());
OVertex oVertex = getElement().getVertices(ODirection.IN).iterator().next();
resourceManagement = new ResourceManagement();
resourceManagement.setElement(oVertex);
resourceManagement.addToRelationManagements(consistsOfManagement);
}
super.reallyRemoveFromContext();
}
@ -89,7 +96,7 @@ public class FacetManagement extends EntityManagement<Facet, FacetType> {
OVertex oVertex = getElement().getVertices(ODirection.IN).iterator().next();
resourceManagement = new ResourceManagement();
resourceManagement.setElement(oVertex);
// TODO
resourceManagement.addToRelationManagements(consistsOfManagement);
}
affectedInstances.put(uuid, serializeSelfAsJsonNode());
@ -126,7 +133,13 @@ public class FacetManagement extends EntityManagement<Facet, FacetType> {
resourceManagement.setODatabaseDocument(oDatabaseDocument);
break;
case ADD_TO_CONTEXT: case REMOVE_FROM_CONTEXT:
case ADD_TO_CONTEXT:
resourceManagement.setWorkingContext(targetSecurityContext);
targetSecurityContextODatabaseDocument = targetSecurityContext.getDatabaseDocument(PermissionMode.READER);
resourceManagement.setODatabaseDocument(targetSecurityContextODatabaseDocument);
break;
case REMOVE_FROM_CONTEXT:
resourceManagement.setWorkingContext(targetSecurityContext);
targetSecurityContextODatabaseDocument = targetSecurityContext.getDatabaseDocument(PermissionMode.READER);
resourceManagement.setODatabaseDocument(targetSecurityContextODatabaseDocument);

View File

@ -477,8 +477,17 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
break;
}
}else {
if(operation == Operation.REMOVE_FROM_CONTEXT && relationManagement!=null) {
/*
* The relation has been removed from the targetContext but it has not been committed.
* We must consider as not available in targetSecurityContext
*/
continue;
}
if(relationManagement==null) {
relationManagement = getRelationManagement(edge);
relationManagements.put(id, relationManagement);
}
}

View File

@ -129,6 +129,7 @@ public class ConsistsOfManagement extends RelationManagement<FacetManagement, Fa
return;
}
resourceManagement.setOperation(operation);
resourceManagement.addToRelationManagements(this);
resourceManagement.sanityCheck();
}catch (ResourceRegistryException e) {
throw e;

View File

@ -277,7 +277,6 @@ public class ERManagementTest extends ContextTest {
}
@Test
public void testCreateEServiceAndRemoveFromContextRequiredFacet() throws Exception {
EService eService = instantiateValidEService();