PArent context must be get with the same current DB
This commit is contained in:
parent
fb7ca52744
commit
99980cc20c
|
@ -153,16 +153,41 @@ public class ContextUtility {
|
|||
}
|
||||
}
|
||||
|
||||
// private OVertex getParentOfContextVertexByUUID(UUID uuid) throws ResourceRegistryException {
|
||||
// ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||
// ODatabaseDocument oDatabaseDocument = null;
|
||||
// try {
|
||||
// oDatabaseDocument = getAdminSecurityContext().getDatabaseDocument(PermissionMode.READER);
|
||||
// OVertex oVertex = OrientDBUtility.getElementByUUID(oDatabaseDocument, Context.NAME, uuid,
|
||||
// OVertex.class);
|
||||
// return oVertex;
|
||||
// } finally {
|
||||
// if(oDatabaseDocument!=null) {
|
||||
// oDatabaseDocument.close();
|
||||
// }
|
||||
//
|
||||
// if(current!=null) {
|
||||
// current.activateOnCurrentThread();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
private SecurityContext getSecurityContextByUUID(UUID uuid, OVertex contextVertex) throws ResourceRegistryException {
|
||||
SecurityContext securityContext = contexts.get(uuid);
|
||||
if(securityContext == null) {
|
||||
|
||||
securityContext = new SecurityContext(uuid);
|
||||
|
||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||
ODatabaseDocument oDatabaseDocument = null;
|
||||
|
||||
try {
|
||||
if(contextVertex == null) {
|
||||
contextVertex = getContextVertexByUUID(uuid);
|
||||
oDatabaseDocument = getAdminSecurityContext().getDatabaseDocument(PermissionMode.READER);
|
||||
contextVertex = OrientDBUtility.getElementByUUID(oDatabaseDocument, Context.NAME, uuid, OVertex.class);
|
||||
}
|
||||
|
||||
OVertex parentVertex = contextVertex.getVertices(ODirection.IN, IsParentOf.NAME).iterator().next();
|
||||
|
||||
if(parentVertex != null) {
|
||||
|
@ -172,6 +197,14 @@ public class ContextUtility {
|
|||
|
||||
} catch(NoSuchElementException e) {
|
||||
// No parent
|
||||
} finally {
|
||||
if(oDatabaseDocument!=null) {
|
||||
oDatabaseDocument.close();
|
||||
}
|
||||
|
||||
if(current!=null) {
|
||||
current.activateOnCurrentThread();
|
||||
}
|
||||
}
|
||||
|
||||
contexts.put(uuid, securityContext);
|
||||
|
|
Loading…
Reference in New Issue