Refs #10238: Refactor Context Port Type
Task-Url: https://support.d4science.org/issues/10238 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@158789 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d9fe526386
commit
6899669ccf
|
@ -190,30 +190,39 @@ public class ContextManagement extends EntityManagement<Context> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Vertex reallyCreate() throws ERAlreadyPresentException, ResourceRegistryException {
|
protected Vertex reallyCreate() throws ERAlreadyPresentException, ResourceRegistryException {
|
||||||
JsonNode isParentOfJsonNode = jsonNode.get(Context.PARENT_PROPERTY);
|
try {
|
||||||
|
JsonNode isParentOfJsonNode = jsonNode.get(Context.PARENT_PROPERTY);
|
||||||
if (isParentOfJsonNode!=null && !(isParentOfJsonNode instanceof NullNode)) {
|
|
||||||
|
|
||||||
JsonNode parentJsonNode = isParentOfJsonNode.get(Relation.SOURCE_PROPERTY);
|
if (isParentOfJsonNode!=null && !(isParentOfJsonNode instanceof NullNode)) {
|
||||||
ContextManagement parentContext = new ContextManagement(orientGraph);
|
|
||||||
parentContext.setJSON(parentJsonNode);
|
JsonNode parentJsonNode = isParentOfJsonNode.get(Relation.SOURCE_PROPERTY);
|
||||||
|
ContextManagement parentContext = new ContextManagement(orientGraph);
|
||||||
|
parentContext.setJSON(parentJsonNode);
|
||||||
|
|
||||||
|
checkContext(parentContext);
|
||||||
|
createVertex();
|
||||||
|
|
||||||
|
SecurityContext.createSecurityContext(orientGraph, uuid);
|
||||||
|
|
||||||
|
IsParentOfManagement isParentOfManagement = new IsParentOfManagement(orientGraph);
|
||||||
|
isParentOfManagement.setJSON(isParentOfJsonNode);
|
||||||
|
isParentOfManagement.setSourceEntityManagement(parentContext);
|
||||||
|
isParentOfManagement.setTargetEntityManagement(this);
|
||||||
|
|
||||||
|
isParentOfManagement.internalCreate();
|
||||||
|
|
||||||
|
}else {
|
||||||
|
checkContext(null);
|
||||||
|
createVertex();
|
||||||
|
}
|
||||||
|
|
||||||
checkContext(parentContext);
|
return getElement();
|
||||||
createVertex();
|
}catch (Exception e) {
|
||||||
|
if(uuid!=null) {
|
||||||
IsParentOfManagement isParentOfManagement = new IsParentOfManagement(orientGraph);
|
SecurityContext.deleteSecurityContext(orientGraph, uuid);
|
||||||
isParentOfManagement.setJSON(isParentOfJsonNode);
|
}
|
||||||
isParentOfManagement.setSourceEntityManagement(parentContext);
|
throw e;
|
||||||
isParentOfManagement.setTargetEntityManagement(this);
|
|
||||||
|
|
||||||
isParentOfManagement.internalCreate();
|
|
||||||
|
|
||||||
}else {
|
|
||||||
checkContext(null);
|
|
||||||
createVertex();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return getElement();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -291,6 +300,8 @@ public class ContextManagement extends EntityManagement<Context> {
|
||||||
|
|
||||||
element = (Vertex) ERManagement.updateProperties(oClass, getElement(), jsonNode, ignoreKeys, ignoreStartWithKeys);
|
element = (Vertex) ERManagement.updateProperties(oClass, getElement(), jsonNode, ignoreKeys, ignoreStartWithKeys);
|
||||||
|
|
||||||
|
ContextUtility.invalidContextUUIDCache(uuid);
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,6 +348,9 @@ public class ContextManagement extends EntityManagement<Context> {
|
||||||
|
|
||||||
element.remove();
|
element.remove();
|
||||||
|
|
||||||
|
ContextUtility.invalidContextUUIDCache(uuid);
|
||||||
|
SecurityContext.deleteSecurityContext(orientGraph, uuid);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,6 @@ public class SecurityContext {
|
||||||
readerUser.save();
|
readerUser.save();
|
||||||
logger.trace("{} created", readerUser);
|
logger.trace("{} created", readerUser);
|
||||||
|
|
||||||
oDatabaseDocumentTx.commit();
|
|
||||||
|
|
||||||
logger.trace(
|
logger.trace(
|
||||||
"Security Context (roles and users) with UUID {} successfully created",
|
"Security Context (roles and users) with UUID {} successfully created",
|
||||||
|
@ -158,7 +157,7 @@ public class SecurityContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteSecurityContext(OrientGraph orientGraph,
|
public static void deleteSecurityContext(OrientGraph orientGraph,
|
||||||
UUID context, boolean commit) {
|
UUID context) {
|
||||||
|
|
||||||
logger.trace(
|
logger.trace(
|
||||||
"Going to remove Security Context (roles and users) with UUID {}",
|
"Going to remove Security Context (roles and users) with UUID {}",
|
||||||
|
@ -206,10 +205,6 @@ public class SecurityContext {
|
||||||
logger.error("{} was not dropped successfully", role);
|
logger.error("{} was not dropped successfully", role);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(commit){
|
|
||||||
oDatabaseDocumentTx.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.trace(
|
logger.trace(
|
||||||
"Security Context (roles and users) with UUID {} successfully removed",
|
"Security Context (roles and users) with UUID {} successfully removed",
|
||||||
context.toString());
|
context.toString());
|
||||||
|
|
Loading…
Reference in New Issue