From cdd0f73f70d8400ae1b7fd879032cd988abb9ea3 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Tue, 4 Jun 2013 14:27:37 +0000 Subject: [PATCH] Make proxy more generic https://www.argeo.org/bugzilla/show_bug.cgi?id=162 git-svn-id: https://svn.argeo.org/commons/branches/1.x@6327 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../org/argeo/jcr/proxy/AbstractUrlProxy.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/proxy/AbstractUrlProxy.java b/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/proxy/AbstractUrlProxy.java index 7692163e3..8a66f3102 100644 --- a/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/proxy/AbstractUrlProxy.java +++ b/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/proxy/AbstractUrlProxy.java @@ -78,18 +78,24 @@ public abstract class AbstractUrlProxy implements ResourceProxy { public Node proxy(String path) { // we open a JCR session with client credentials in order not to use the // admin session in multiple thread or make it a bottleneck. + Node nodeAdmin = null; + Node nodeClient = null; Session clientSession = null; try { clientSession = jcrRepository.login(proxyWorkspace); if (!clientSession.itemExists(path) || shouldUpdate(clientSession, path)) { - Node nodeT = retrieveAndSave(path); - if (nodeT == null) - return null; - } - return clientSession.getNode(path); + nodeAdmin = retrieveAndSave(path); + if (nodeAdmin != null) + nodeClient = clientSession.getNode(path); + } else + nodeClient = clientSession.getNode(path); + return nodeClient; } catch (RepositoryException e) { throw new ArgeoException("Cannot proxy " + path, e); + } finally { + if (nodeClient == null) + JcrUtils.logoutQuietly(clientSession); } } -- 2.30.2