starting to create the skeleton for changes

This commit is contained in:
Luca Frosini 2024-01-25 17:18:39 +01:00
parent 0917263f27
commit 1e31a71fce
2 changed files with 34 additions and 1 deletions

View File

@ -189,11 +189,18 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
} }
private JsonNode filterFieldsByRole(JsonNode context) {
// TODO return extra info only to authorized users
return context;
}
@Override @Override
protected JsonNode createCompleteJsonNode() throws ResourceRegistryException { protected JsonNode createCompleteJsonNode() throws ResourceRegistryException {
JsonNode context = serializeSelfAsJsonNode(); JsonNode context = serializeSelfAsJsonNode();
context = filterFieldsByRole(context);
int count = 0; int count = 0;
Iterable<OEdge> parents = getElement().getEdges(ODirection.IN); Iterable<OEdge> parents = getElement().getEdges(ODirection.IN);
for (OEdge edge : parents) { for (OEdge edge : parents) {
@ -235,6 +242,8 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
return context; return context;
} }
@Override @Override
protected OVertex reallyCreate() throws AlreadyPresentException, ResourceRegistryException { protected OVertex reallyCreate() throws AlreadyPresentException, ResourceRegistryException {
SecurityContext securityContext = null; SecurityContext securityContext = null;
@ -256,6 +265,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
uuid = UUIDManager.getInstance().generateValidUUID(); uuid = UUIDManager.getInstance().generateValidUUID();
} }
logFullPath();
createVertex(); createVertex();
IsParentOfManagement isParentOfManagement = new IsParentOfManagement(oDatabaseDocument); IsParentOfManagement isParentOfManagement = new IsParentOfManagement(oDatabaseDocument);
@ -267,6 +277,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
} else { } else {
checkContext(null); checkContext(null);
logFullPath();
createVertex(); createVertex();
} }
@ -290,6 +301,23 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
} }
} }
/**
* TODO
* The full path of the context is added for every non safe action
* - At creation time
* - At rename time (see #25139)
* - At parent change time (see #26544)
*
* In this way we are sure to track context fullpath changes.
* Furthermore when a context is delete and is mode to the cemetery
* i.e. ShadowContextSecurityContext (see #19428) we do not have to do nothing with
* the fullpath just move the vertex in the new SecurityContext
* and add the instance of context deletion
*/
protected void logFullPath() {
}
@Override @Override
protected OVertex reallyUpdate() throws NotFoundException, ResourceRegistryException { protected OVertex reallyUpdate() throws NotFoundException, ResourceRegistryException {
@ -361,6 +389,8 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
move(newParentContextManagement, false); move(newParentContextManagement, false);
} }
logFullPath();
element = (OVertex) updateProperties(oClass, getElement(), jsonNode, ignoreKeys, ignoreStartWithKeys); element = (OVertex) updateProperties(oClass, getElement(), jsonNode, ignoreKeys, ignoreStartWithKeys);
ServerContextCache.getInstance().cleanCache(); ServerContextCache.getInstance().cleanCache();
@ -406,6 +436,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
thisSecurityContext.changeParentSecurityContext(newParentSecurityContext, oDatabaseDocument); thisSecurityContext.changeParentSecurityContext(newParentSecurityContext, oDatabaseDocument);
} }
@Override @Override
protected void reallyDelete() throws NotFoundException, ResourceRegistryException { protected void reallyDelete() throws NotFoundException, ResourceRegistryException {
Iterable<OEdge> iterable = getElement().getEdges(ODirection.OUT); Iterable<OEdge> iterable = getElement().getEdges(ODirection.OUT);
@ -414,6 +445,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
throw new ContextException("Cannot remove a " + Context.NAME + " having children"); throw new ContextException("Cannot remove a " + Context.NAME + " having children");
} }
// TODO Move the vertex to the ShadowContextSecurityContext (i.e the cemetery)
element.delete(); element.delete();
ContextUtility contextUtility = ContextUtility.getInstance(); ContextUtility contextUtility = ContextUtility.getInstance();

View File

@ -12,6 +12,7 @@ import com.orientechnologies.orient.core.metadata.security.ORule;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
* Added for feature #19428
*/ */
public class ShadowContextSecurityContext extends SecurityContext { public class ShadowContextSecurityContext extends SecurityContext {