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
|
||||
protected Vertex reallyCreate() throws ERAlreadyPresentException, ResourceRegistryException {
|
||||
JsonNode isParentOfJsonNode = jsonNode.get(Context.PARENT_PROPERTY);
|
||||
|
||||
if (isParentOfJsonNode!=null && !(isParentOfJsonNode instanceof NullNode)) {
|
||||
try {
|
||||
JsonNode isParentOfJsonNode = jsonNode.get(Context.PARENT_PROPERTY);
|
||||
|
||||
JsonNode parentJsonNode = isParentOfJsonNode.get(Relation.SOURCE_PROPERTY);
|
||||
ContextManagement parentContext = new ContextManagement(orientGraph);
|
||||
parentContext.setJSON(parentJsonNode);
|
||||
if (isParentOfJsonNode!=null && !(isParentOfJsonNode instanceof NullNode)) {
|
||||
|
||||
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);
|
||||
createVertex();
|
||||
|
||||
IsParentOfManagement isParentOfManagement = new IsParentOfManagement(orientGraph);
|
||||
isParentOfManagement.setJSON(isParentOfJsonNode);
|
||||
isParentOfManagement.setSourceEntityManagement(parentContext);
|
||||
isParentOfManagement.setTargetEntityManagement(this);
|
||||
|
||||
isParentOfManagement.internalCreate();
|
||||
|
||||
}else {
|
||||
checkContext(null);
|
||||
createVertex();
|
||||
return getElement();
|
||||
}catch (Exception e) {
|
||||
if(uuid!=null) {
|
||||
SecurityContext.deleteSecurityContext(orientGraph, uuid);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
return getElement();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -291,6 +300,8 @@ public class ContextManagement extends EntityManagement<Context> {
|
|||
|
||||
element = (Vertex) ERManagement.updateProperties(oClass, getElement(), jsonNode, ignoreKeys, ignoreStartWithKeys);
|
||||
|
||||
ContextUtility.invalidContextUUIDCache(uuid);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
|
@ -337,6 +348,9 @@ public class ContextManagement extends EntityManagement<Context> {
|
|||
|
||||
element.remove();
|
||||
|
||||
ContextUtility.invalidContextUUIDCache(uuid);
|
||||
SecurityContext.deleteSecurityContext(orientGraph, uuid);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
|
|
@ -150,7 +150,6 @@ public class SecurityContext {
|
|||
readerUser.save();
|
||||
logger.trace("{} created", readerUser);
|
||||
|
||||
oDatabaseDocumentTx.commit();
|
||||
|
||||
logger.trace(
|
||||
"Security Context (roles and users) with UUID {} successfully created",
|
||||
|
@ -158,7 +157,7 @@ public class SecurityContext {
|
|||
}
|
||||
|
||||
public static void deleteSecurityContext(OrientGraph orientGraph,
|
||||
UUID context, boolean commit) {
|
||||
UUID context) {
|
||||
|
||||
logger.trace(
|
||||
"Going to remove Security Context (roles and users) with UUID {}",
|
||||
|
@ -206,10 +205,6 @@ public class SecurityContext {
|
|||
logger.error("{} was not dropped successfully", role);
|
||||
}
|
||||
|
||||
if(commit){
|
||||
oDatabaseDocumentTx.commit();
|
||||
}
|
||||
|
||||
logger.trace(
|
||||
"Security Context (roles and users) with UUID {} successfully removed",
|
||||
context.toString());
|
||||
|
|
Loading…
Reference in New Issue