From 38eedcea373b88f66069408cc893bb5ba2049d77 Mon Sep 17 00:00:00 2001 From: "luca.frosini" Date: Fri, 11 Nov 2016 11:01:12 +0000 Subject: [PATCH] Reverted some changes git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@134084 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../resources/utils/ContextUtility.java | 33 +++++-------------- .../resources/utils/HeaderUtility.java | 2 +- .../resources/utils/Utility.java | 2 +- 3 files changed, 10 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/resources/utils/ContextUtility.java b/src/main/java/org/gcube/informationsystem/resourceregistry/resources/utils/ContextUtility.java index fce6855..224ddf9 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/resources/utils/ContextUtility.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/resources/utils/ContextUtility.java @@ -36,7 +36,7 @@ import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx; * @author Luca Frosini (ISTI - CNR) * */ -public abstract class ContextUtility { +public class ContextUtility { private static final Logger logger = LoggerFactory .getLogger(ContextUtility.class); @@ -86,9 +86,8 @@ public abstract class ContextUtility { } return authorizationEntry.getContext(); } - - public static Vertex getActualContextVertex() throws ContextNotFoundException, ContextException{ - OrientGraphNoTx orientGraphNoTx = null; + + public static UUID getActualContextUUID() throws ContextException { try { String scope = getCurrentScope(); if(scope==null){ @@ -99,30 +98,14 @@ public abstract class ContextUtility { .getSecurityContextFactory( SecurityContextMapper.ADMIN_SECURITY_CONTEXT_UUID, PermissionMode.READER); - - orientGraphNoTx = factory.getNoTx(); - return ContextUtility.getContextVertexByFullName(orientGraphNoTx, scope); - } catch (ContextNotFoundException e) { - throw e; - } catch (Exception e) { - throw new ContextException( - "Unable to restrive Context Vertex for current Context", e); - } finally{ - if(orientGraphNoTx!=null){ - orientGraphNoTx.shutdown(); - } - } - } - - public static UUID getActualContextUUID() throws ContextException { - try { - Vertex context = getActualContextVertex(); + Vertex context = ContextUtility.getContextVertexByFullName( + factory.getTx(), scope); return getContextUUIDFromContextVertex(context); } catch (ContextException e) { throw e; } catch (Exception e) { throw new ContextException( - "Unable to restrive Context UUID for current Context", e); + "Unable to restrive Context UUID from current Context", e); } } @@ -183,7 +166,7 @@ public abstract class ContextUtility { } } - public static Vertex getContextVertexByFullName(OrientGraphNoTx orientGraphNoTx, + public static Vertex getContextVertexByFullName(OrientGraph orientGraph, String fullName) throws ContextNotFoundException { logger.trace("Going to get {} {} from full name '{}'", Context.NAME, Vertex.class.getSimpleName(), fullName); @@ -199,7 +182,7 @@ public abstract class ContextUtility { ; OSQLSynchQuery osqlSynchQuery = new OSQLSynchQuery( select); - Iterable vertexes = orientGraphNoTx.command(osqlSynchQuery) + Iterable vertexes = orientGraph.command(osqlSynchQuery) .execute(); if (vertexes == null || !vertexes.iterator().hasNext()) { diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/resources/utils/HeaderUtility.java b/src/main/java/org/gcube/informationsystem/resourceregistry/resources/utils/HeaderUtility.java index e5aed42..5cc0780 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/resources/utils/HeaderUtility.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/resources/utils/HeaderUtility.java @@ -23,7 +23,7 @@ import com.tinkerpop.blueprints.Vertex; * @author Luca Frosini (ISTI - CNR) * */ -public abstract class HeaderUtility { +public class HeaderUtility { private static final Logger logger = LoggerFactory .getLogger(HeaderUtility.class); diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/resources/utils/Utility.java b/src/main/java/org/gcube/informationsystem/resourceregistry/resources/utils/Utility.java index b97f980..f6c3eb9 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/resources/utils/Utility.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/resources/utils/Utility.java @@ -33,7 +33,7 @@ import com.tinkerpop.blueprints.util.io.graphson.GraphSONUtility; * @author Luca Frosini (ISTI - CNR) * */ -public abstract class Utility { +public class Utility { private static final Logger logger = LoggerFactory.getLogger(Utility.class);