jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1157175 - /jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Date Fri, 12 Aug 2011 16:23:42 GMT
Author: angela
Date: Fri Aug 12 16:23:42 2011
New Revision: 1157175

URL: http://svn.apache.org/viewvc?rev=1157175&view=rev
Log:
JCR-3052 - spi2dav: avoid reusing the same document in repositoryserviceimpl

Modified:
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?rev=1157175&r1=1157174&r2=1157175&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Fri Aug 12 16:23:42 2011
@@ -229,7 +229,6 @@ public class RepositoryServiceImpl imple
 
     private final int itemInfoCacheSize;
 
-    private final Document domFactory;
     private final NamespaceCache nsCache;
     private final URIResolverImpl uriResolver;
 
@@ -311,23 +310,19 @@ public class RepositoryServiceImpl imple
         this.itemInfoCacheSize = itemInfoCacheSize;
 
         try {
-            domFactory = DomUtil.createDocument();
-        } catch (ParserConfigurationException e) {
-            throw new RepositoryException(e);
-        }
-
-        try {
             URI repositoryUri = new URI((uri.endsWith("/")) ? uri : uri+"/", true);
             hostConfig = new HostConfiguration();
             hostConfig.setHost(repositoryUri);
 
             nsCache = new NamespaceCache();
-            uriResolver = new URIResolverImpl(repositoryUri, this, domFactory);
+            uriResolver = new URIResolverImpl(repositoryUri, this, DomUtil.createDocument());
             NamePathResolver resolver = new NamePathResolverImpl(nsCache);
             valueFactory = new ValueFactoryQImpl(qValueFactory, resolver);
 
         } catch (URIException e) {
             throw new RepositoryException(e);
+        } catch (ParserConfigurationException e) {
+            throw new RepositoryException(e);
         }
 
         connectionManager = new MultiThreadedHttpConnectionManager();
@@ -791,7 +786,7 @@ public class RepositoryServiceImpl imple
         try {
             String uri = getItemUri(itemId, sessionInfo);
             ReportInfo reportInfo = new ReportInfo(JcrRemotingConstants.REPORT_PRIVILEGES,
ItemResourceConstants.NAMESPACE);
-            reportInfo.setContentElement(DomUtil.hrefToXml(uri, domFactory));
+            reportInfo.setContentElement(DomUtil.hrefToXml(uri, DomUtil.createDocument()));
 
             method = new ReportMethod(uriResolver.getWorkspaceUri(sessionInfo.getWorkspaceName()),
reportInfo);
             getClient(sessionInfo).executeMethod(method);
@@ -820,6 +815,8 @@ public class RepositoryServiceImpl imple
             return privileges.containsAll(requiredPrivileges);
         } catch (IOException e) {
             throw new RepositoryException(e);
+        } catch (ParserConfigurationException e) {
+            throw new RepositoryException(e);
         } catch (DavException e) {
             throw ExceptionConverter.generate(e);
         } finally {
@@ -1446,7 +1443,7 @@ public class RepositoryServiceImpl imple
             DavPropertySet ps = responses[0].getProperties(DavServletResponse.SC_OK);
             if (ps.contains(DavPropertyName.LOCKDISCOVERY)) {
                 DavProperty<?> p = ps.get(DavPropertyName.LOCKDISCOVERY);
-                LockDiscovery ld = LockDiscovery.createFromXml(p.toXml(domFactory));
+                LockDiscovery ld = LockDiscovery.createFromXml(p.toXml(DomUtil.createDocument()));
                 NodeId parentId = getParentId(ps, sessionInfo);
                 return retrieveLockInfo(ld, sessionInfo, nodeId, parentId);
             }  else {
@@ -1456,6 +1453,8 @@ public class RepositoryServiceImpl imple
             }
         } catch (IOException e) {
             throw new RepositoryException(e);
+        } catch (ParserConfigurationException e) {
+            throw new RepositoryException(e);
         } catch (DavException e) {
             throw ExceptionConverter.generate(e);
         } finally {
@@ -1694,7 +1693,7 @@ public class RepositoryServiceImpl imple
         try {
             UpdateInfo uInfo;
             if (removeExisting || relPath != null) {
-                Element uElem = UpdateInfo.createUpdateElement(updateSource, updateType,
domFactory);
+                Element uElem = UpdateInfo.createUpdateElement(updateSource, updateType,
DomUtil.createDocument());
                 if (removeExisting) {
                     DomUtil.addChildElement(uElem, JcrRemotingConstants.XML_REMOVEEXISTING,
ItemResourceConstants.NAMESPACE);
                 }
@@ -1711,6 +1710,8 @@ public class RepositoryServiceImpl imple
             execute(method, sessionInfo);
         } catch (IOException e) {
             throw new RepositoryException(e);
+        } catch (ParserConfigurationException e) {
+            throw new RepositoryException(e);
         } catch (DavException e) {
             throw ExceptionConverter.generate(e);
         }
@@ -1728,10 +1729,11 @@ public class RepositoryServiceImpl imple
      */
     public Iterator<NodeId> merge(SessionInfo sessionInfo, NodeId nodeId, String srcWorkspaceName,
boolean bestEffort, boolean isShallow) throws NoSuchWorkspaceException, AccessDeniedException,
MergeException, LockException, InvalidItemStateException, RepositoryException {
         try {
+            Document doc = DomUtil.createDocument();
             String wspHref = uriResolver.getWorkspaceUri(srcWorkspaceName);
-            Element mElem = MergeInfo.createMergeElement(new String[] {wspHref}, !bestEffort,
false, domFactory);
+            Element mElem = MergeInfo.createMergeElement(new String[] {wspHref}, !bestEffort,
false, doc);
             if (isShallow) {
-                mElem.appendChild(DomUtil.depthToXml(false, domFactory));
+                mElem.appendChild(DomUtil.depthToXml(false, doc));
             }
             MergeInfo mInfo = new MergeInfo(mElem);
 
@@ -1747,6 +1749,8 @@ public class RepositoryServiceImpl imple
             return failedIds.iterator();
         } catch (IOException e) {
             throw new RepositoryException(e);
+        } catch (ParserConfigurationException e) {
+            throw new RepositoryException(e);
         } catch (DavException e) {
             throw ExceptionConverter.generate(e);
         }
@@ -2065,7 +2069,7 @@ public class RepositoryServiceImpl imple
             if (disc.isEmpty()) {
                 events = new EventBundle[0];
             } else {
-                Element discEl = disc.toXml(domFactory);
+                Element discEl = disc.toXml(DomUtil.createDocument());
                 ElementIterator it = DomUtil.getChildren(discEl,
                         ObservationConstants.XML_EVENTBUNDLE,
                         ObservationConstants.NAMESPACE);
@@ -2089,6 +2093,8 @@ public class RepositoryServiceImpl imple
             return events;
         } catch (IOException e) {
             throw new RepositoryException(e);
+        } catch (ParserConfigurationException e) {
+            throw new RepositoryException(e);
         } catch (DavException e) {
             throw ExceptionConverter.generate(e);
         }  finally {
@@ -2292,12 +2298,12 @@ public class RepositoryServiceImpl imple
     /**
      * @see RepositoryService#getQNodeTypeDefinitions(SessionInfo)
      */
-    public Iterator<QNodeTypeDefinition> getQNodeTypeDefinitions(SessionInfo sessionInfo)
throws RepositoryException {
-        ReportInfo info = new ReportInfo(JcrRemotingConstants.REPORT_NODETYPES, ItemResourceConstants.NAMESPACE);
-        info.setContentElement(DomUtil.createElement(domFactory, NodeTypeConstants.XML_REPORT_ALLNODETYPES,
ItemResourceConstants.NAMESPACE));
-
+    public Iterator<QNodeTypeDefinition> getQNodeTypeDefinitions(SessionInfo sessionInfo)
throws RepositoryException {       
         ReportMethod method = null;
         try {
+            ReportInfo info = new ReportInfo(JcrRemotingConstants.REPORT_NODETYPES, ItemResourceConstants.NAMESPACE);
+            info.setContentElement(DomUtil.createElement(DomUtil.createDocument(), NodeTypeConstants.XML_REPORT_ALLNODETYPES,
ItemResourceConstants.NAMESPACE));
+
             String workspaceUri = uriResolver.getWorkspaceUri(sessionInfo.getWorkspaceName());
             method = new ReportMethod(workspaceUri, info);
             getClient(sessionInfo).executeMethod(method);
@@ -2307,6 +2313,8 @@ public class RepositoryServiceImpl imple
             return retrieveQNodeTypeDefinitions(sessionInfo, reportDoc);
         } catch (IOException e) {
             throw new RepositoryException(e);
+        } catch (ParserConfigurationException e) {
+            throw new RepositoryException(e);
         } catch (DavException e) {
             throw ExceptionConverter.generate(e);
         } finally {



Mime
View raw message