From: Mathieu Baudier Date: Mon, 13 Feb 2012 16:52:25 +0000 (+0000) Subject: Additional checks in URL proxy X-Git-Tag: argeo-commons-2.1.30~1018 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=6cba7cec70660dfd80e823cc548239810751e112;p=lgpl%2Fargeo-commons.git Additional checks in URL proxy git-svn-id: https://svn.argeo.org/commons/trunk@5073 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- 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 357ec1f37..7f1788427 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 @@ -1,5 +1,6 @@ package org.argeo.jcr.proxy; +import java.io.IOException; import java.io.InputStream; import java.net.URL; @@ -89,15 +90,19 @@ public abstract class AbstractUrlProxy implements ResourceProxy { } /** Session is not saved */ - protected Node proxyUrl(Session session, String baseUrl, String path) { + protected Node proxyUrl(Session session, String baseUrl, String path) + throws RepositoryException { + String nodePath = getNodePath(path); + if (jcrAdminSession.itemExists(nodePath)) + throw new ArgeoException("Node " + nodePath + " already exists"); Node node = null; String remoteUrl = baseUrl + path; InputStream in = null; try { URL u = new URL(remoteUrl); in = u.openStream(); - node = importFile(session, getNodePath(path), in); - } catch (Exception e) { + node = importFile(session, nodePath, in); + } catch (IOException e) { if (log.isTraceEnabled()) { log.trace("Cannot read " + remoteUrl + ", skipping... " + e.getMessage());