Compare commits

...

3 Commits

Author SHA1 Message Date
Luca Frosini c6049a122b Fixed context test base class 2024-04-16 15:11:33 +02:00
Luca Frosini 1e31a71fce starting to create the skeleton for changes 2024-01-25 17:18:39 +01:00
Luca Frosini 0917263f27 added test JSON query 2024-01-25 15:59:48 +01:00
4 changed files with 47 additions and 2 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
protected JsonNode createCompleteJsonNode() throws ResourceRegistryException {
JsonNode context = serializeSelfAsJsonNode();
context = filterFieldsByRole(context);
int count = 0;
Iterable<OEdge> parents = getElement().getEdges(ODirection.IN);
for (OEdge edge : parents) {
@ -235,6 +242,8 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
return context;
}
@Override
protected OVertex reallyCreate() throws AlreadyPresentException, ResourceRegistryException {
SecurityContext securityContext = null;
@ -256,6 +265,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
uuid = UUIDManager.getInstance().generateValidUUID();
}
logFullPath();
createVertex();
IsParentOfManagement isParentOfManagement = new IsParentOfManagement(oDatabaseDocument);
@ -267,6 +277,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
} else {
checkContext(null);
logFullPath();
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
protected OVertex reallyUpdate() throws NotFoundException, ResourceRegistryException {
@ -361,6 +389,8 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
move(newParentContextManagement, false);
}
logFullPath();
element = (OVertex) updateProperties(oClass, getElement(), jsonNode, ignoreKeys, ignoreStartWithKeys);
ServerContextCache.getInstance().cleanCache();
@ -406,6 +436,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
thisSecurityContext.changeParentSecurityContext(newParentSecurityContext, oDatabaseDocument);
}
@Override
protected void reallyDelete() throws NotFoundException, ResourceRegistryException {
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");
}
// TODO Move the vertex to the ShadowContextSecurityContext (i.e the cemetery)
element.delete();
ContextUtility contextUtility = ContextUtility.getInstance();

View File

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

View File

@ -47,6 +47,8 @@ public class ContextTest {
public static final String PASSWORD_PROPERTY_KEY = "password";
public static final String CLIENT_ID_PROPERTY_KEY = "clientId";
public static final String RESOURCE_REGISTRY_URL_PROPERTY = "RESOURCE_REGISTRY_URL";
static {
GCUBE = "/gcube";
DEVNEXT = GCUBE + "/devNext";
@ -54,7 +56,7 @@ public class ContextTest {
DEVSEC = GCUBE + "/devsec";
DEVVRE = DEVSEC + "/devVRE";
PARENT_DEFAULT_TEST_SCOPE = "/gcube";
PARENT_DEFAULT_TEST_SCOPE = GCUBE;
DEFAULT_TEST_SCOPE = DEVNEXT;
ALTERNATIVE_TEST_SCOPE = NEXTNEXT;

View File

@ -0,0 +1,10 @@
{
"type": "ConsistsOf",
"source": {
"type": "HostingNode",
"id": "34498fb5-e184-473b-ad2f-08f7ab1afd35"
},
"target": {
"type" : "CPUFacet"
}
}