You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by re...@apache.org on 2016/12/16 11:22:25 UTC
svn commit: r1774573 - in /jackrabbit/branches/2.8: ./
jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Author: reschke
Date: Fri Dec 16 11:22:25 2016
New Revision: 1774573
URL: http://svn.apache.org/viewvc?rev=1774573&view=rev
Log:
JCR-4086: spi2dav: code reformat to reduce scope of changes for JCR-4066 (ported to 2.8)
Modified:
jackrabbit/branches/2.8/ (props changed)
jackrabbit/branches/2.8/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Propchange: jackrabbit/branches/2.8/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Dec 16 11:22:25 2016
@@ -1,3 +1,3 @@
/jackrabbit/branches/JCR-2272:1173165-1176545
/jackrabbit/sandbox/JCR-2415-lucene-3.0:1060860-1064038
-/jackrabbit/trunk:1592881,1597717,1597799,1597806,1598035,1598058,1603769,1603934,1609712,1625561,1634584,1653275,1667787,1674859,1680757,1709811,1729382,1732436,1740814-1740815,1751279,1752165,1758600,1759607,1759782,1759865,1761679,1761909,1762422,1763558,1766398,1771078,1771741,1771939,1771999,1772049,1772444,1772457,1772530,1772544,1773591,1773745
+/jackrabbit/trunk:1592881,1597717,1597799,1597806,1598035,1598058,1603769,1603934,1609712,1625561,1634584,1653275,1667787,1674859,1680757,1709811,1729382,1732436,1740814-1740815,1751279,1752165,1758600,1759607,1759782,1759865,1761679,1761909,1762422,1763558,1766398,1771078,1771741,1771939,1771999,1772049,1772444,1772457,1772530,1772544,1773591,1773745,1774443
Modified: jackrabbit/branches/2.8/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.8/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?rev=1774573&r1=1774572&r2=1774573&view=diff
==============================================================================
--- jackrabbit/branches/2.8/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java (original)
+++ jackrabbit/branches/2.8/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java Fri Dec 16 11:22:25 2016
@@ -363,8 +363,7 @@ public class RepositoryServiceImpl imple
java.net.URI base = new java.net.URI(baseUri);
java.net.URI rel = new java.net.URI(relUri);
return base.resolve(rel).toString();
- }
- catch (URISyntaxException ex) {
+ } catch (URISyntaxException ex) {
throw new RepositoryException(ex);
}
}
@@ -617,10 +616,6 @@ public class RepositoryServiceImpl imple
//--------------------------------------------------------------------------
/**
* Execute a 'Workspace' operation.
- *
- * @param method
- * @param sessionInfo
- * @throws RepositoryException
*/
private void execute(DavMethod method, SessionInfo sessionInfo) throws RepositoryException {
try {
@@ -735,7 +730,7 @@ public class RepositoryServiceImpl imple
public SessionInfo obtain(SessionInfo sessionInfo, String workspaceName)
throws RepositoryException {
checkSessionInfo(sessionInfo);
- return obtain(((SessionInfoImpl)sessionInfo).getCredentials(), workspaceName);
+ return obtain(((SessionInfoImpl) sessionInfo).getCredentials(), workspaceName);
}
@Override
@@ -760,7 +755,7 @@ public class RepositoryServiceImpl imple
MultiStatusResponse[] responses = method.getResponseBodyAsMultiStatus().getResponses();
if (responses.length != 1) {
- throw new LoginException("Login failed: Unknown workspace '" + workspaceName+ "'.");
+ throw new LoginException("Login failed: Unknown workspace '" + workspaceName + "'.");
}
DavPropertySet props = responses[0].getProperties(DavServletResponse.SC_OK);
@@ -781,7 +776,7 @@ public class RepositoryServiceImpl imple
throw new LoginException("Login failed: Invalid workspace name " + workspaceName);
}
} else {
- throw new LoginException("Login failed: Unknown workspace '" + workspaceName+ "'.");
+ throw new LoginException("Login failed: Unknown workspace '" + workspaceName + "'.");
}
} catch (IOException e) {
throw new RepositoryException(e.getMessage());
@@ -1056,8 +1051,7 @@ public class RepositoryServiceImpl imple
// nodeInfo.
l.addAll(buildPropertyInfos(nInfo));
return l.iterator();
- }
- else {
+ } else {
PropertyInfo pInfo = getPropertyInfo(sessionInfo, (PropertyId) itemId);
return Iterators.singleton(pInfo);
}
@@ -1087,14 +1081,14 @@ public class RepositoryServiceImpl imple
if (nid.getPath() == null) {
PropertyId id = getIdFactory().createPropertyId(nid, NameConstants.JCR_UUID);
- QValue[] vs = new QValue[] {getQValueFactory().create(nid.getUniqueID(), PropertyType.STRING)};
+ QValue[] vs = new QValue[] { getQValueFactory().create(nid.getUniqueID(), PropertyType.STRING) };
Path p = getPathFactory().create(nPath, NameConstants.JCR_UUID, true);
PropertyInfo pi = new PropertyInfoImpl(id, p, PropertyType.STRING, false, vs);
l.add(pi);
}
Name pName = NameConstants.JCR_PRIMARYTYPE;
- QValue[] vs = new QValue[] {getQValueFactory().create(nInfo.getNodetype())};
+ QValue[] vs = new QValue[] { getQValueFactory().create(nInfo.getNodetype()) };
PropertyInfo pi = new PropertyInfoImpl(getIdFactory().createPropertyId(nid, pName),
getPathFactory().create(nPath, pName, true), PropertyType.NAME, false, vs);
l.add(pi);
@@ -1267,7 +1261,7 @@ public class RepositoryServiceImpl imple
v = ValueFormat.getQValue(jcrValue, resolver, getQValueFactory());
}
}
- values = new QValue[] {v};
+ values = new QValue[] { v };
isMultiValued = false;
} else if (ct.startsWith("text/xml")) {
// jcr:values property spooled
@@ -1446,7 +1440,7 @@ public class RepositoryServiceImpl imple
String uri = getItemUri(nodeId, sessionInfo);
String workspUri = uriResolver.getWorkspaceUri(srcWorkspaceName);
- update(uri, null, new String[] {workspUri}, UpdateInfo.UPDATE_BY_WORKSPACE, false, sessionInfo);
+ update(uri, null, new String[] { workspUri }, UpdateInfo.UPDATE_BY_WORKSPACE, false, sessionInfo);
}
@Override
@@ -1482,7 +1476,7 @@ public class RepositoryServiceImpl imple
LockDiscovery ld = LockDiscovery.createFromXml(p.toXml(DomUtil.createDocument()));
NodeId parentId = getParentId(uri, ps, sessionInfo);
return retrieveLockInfo(ld, sessionInfo, nodeId, parentId);
- } else {
+ } else {
// no lock present
log.debug("No Lock present on node with id " + saveGetIdString(nodeId, sessionInfo));
return null;
@@ -1510,7 +1504,7 @@ public class RepositoryServiceImpl imple
public LockInfo lock(SessionInfo sessionInfo, NodeId nodeId, boolean deep, boolean sessionScoped, long timeoutHint, String ownerHint) throws RepositoryException {
try {
checkSessionInfo(sessionInfo);
- long davTimeout = (timeoutHint == Long.MAX_VALUE) ? INFINITE_TIMEOUT : timeoutHint*1000;
+ long davTimeout = (timeoutHint == Long.MAX_VALUE) ? INFINITE_TIMEOUT : timeoutHint * 1000;
String ownerInfo = (ownerHint == null) ? sessionInfo.getUserID() : ownerHint;
String uri = getItemUri(nodeId, sessionInfo);
@@ -1600,7 +1594,7 @@ public class RepositoryServiceImpl imple
return pLockInfo;
}
}
- return new LockInfoImpl(activeLock, holder == null ? nodeId : holder, ((SessionInfoImpl)sessionInfo).getAllLockTokens());
+ return new LockInfoImpl(activeLock, holder == null ? nodeId : holder, ((SessionInfoImpl) sessionInfo).getAllLockTokens());
}
@Override
@@ -1681,7 +1675,7 @@ public class RepositoryServiceImpl imple
}
}
- update(uri, relPath, new String[] {vUri}, UpdateInfo.UPDATE_BY_VERSION, removeExisting, sessionInfo);
+ update(uri, relPath, new String[] { vUri }, UpdateInfo.UPDATE_BY_VERSION, removeExisting, sessionInfo);
}
private boolean exists(SessionInfo sInfo, String uri) {
@@ -1701,7 +1695,6 @@ public class RepositoryServiceImpl imple
return false;
}
-
@Override
public void restore(SessionInfo sessionInfo, NodeId[] versionIds, boolean removeExisting) throws RepositoryException {
String uri = uriResolver.getWorkspaceUri(sessionInfo.getWorkspaceName());
@@ -2029,8 +2022,7 @@ public class RepositoryServiceImpl imple
try {
checkEventFilterSupport(filters);
- }
- catch (UnsupportedRepositoryOperationException ex) {
+ } catch (UnsupportedRepositoryOperationException ex) {
unsubscribe(rootUri, subscriptionId, sessionInfo);
throw (ex);
}
@@ -2106,7 +2098,7 @@ public class RepositoryServiceImpl imple
throw new RepositoryException(e);
} catch (DavException e) {
throw ExceptionConverter.generate(e);
- } finally {
+ } finally {
if (method != null) {
method.releaseConnection();
}
@@ -2124,7 +2116,7 @@ public class RepositoryServiceImpl imple
throw new RepositoryException(e);
} catch (DavException e) {
throw ExceptionConverter.generate(e);
- } finally {
+ } finally {
if (method != null) {
method.releaseConnection();
}
@@ -2181,7 +2173,7 @@ public class RepositoryServiceImpl imple
throw new RepositoryException(e);
} catch (DavException e) {
throw ExceptionConverter.generate(e);
- } finally {
+ } finally {
if (method != null) {
method.releaseConnection();
}
@@ -2446,44 +2438,44 @@ public class RepositoryServiceImpl imple
public void registerNodeTypes(SessionInfo sessionInfo, QNodeTypeDefinition[] nodeTypeDefinitions, boolean allowUpdate) throws RepositoryException {
PropPatchMethod method = null;
try {
- DavPropertySet setProperties = new DavPropertySet();
- setProperties.add(createRegisterNodeTypesProperty(sessionInfo, nodeTypeDefinitions, allowUpdate));
- String uri = uriResolver.getWorkspaceUri(sessionInfo.getWorkspaceName());
- method = new PropPatchMethod(uri, setProperties, new DavPropertyNameSet());
- initMethod(method, sessionInfo, true);
- getClient(sessionInfo).executeMethod(method);
- method.checkSuccess();
- } catch (IOException e) {
- throw new RepositoryException(e);
- } catch (DavException e) {
- throw ExceptionConverter.generate(e);
- } finally {
- if (method != null) {
+ DavPropertySet setProperties = new DavPropertySet();
+ setProperties.add(createRegisterNodeTypesProperty(sessionInfo, nodeTypeDefinitions, allowUpdate));
+ String uri = uriResolver.getWorkspaceUri(sessionInfo.getWorkspaceName());
+ method = new PropPatchMethod(uri, setProperties, new DavPropertyNameSet());
+ initMethod(method, sessionInfo, true);
+ getClient(sessionInfo).executeMethod(method);
+ method.checkSuccess();
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ } catch (DavException e) {
+ throw ExceptionConverter.generate(e);
+ } finally {
+ if (method != null) {
method.releaseConnection();
- }
- }
+ }
+ }
}
@Override
public void unregisterNodeTypes(SessionInfo sessionInfo, Name[] nodeTypeNames) throws RepositoryException {
PropPatchMethod method = null;
try {
- DavPropertySet setProperties = new DavPropertySet();
- setProperties.add(createUnRegisterNodeTypesProperty(sessionInfo, nodeTypeNames));
- String uri = uriResolver.getWorkspaceUri(sessionInfo.getWorkspaceName());
- method = new PropPatchMethod(uri, setProperties, new DavPropertyNameSet());
- initMethod(method, sessionInfo, true);
- getClient(sessionInfo).executeMethod(method);
- method.checkSuccess();
- } catch (IOException e) {
- throw new RepositoryException(e);
- } catch (DavException e) {
- throw ExceptionConverter.generate(e);
- } finally {
- if (method != null) {
- method.releaseConnection();
- }
- }
+ DavPropertySet setProperties = new DavPropertySet();
+ setProperties.add(createUnRegisterNodeTypesProperty(sessionInfo, nodeTypeNames));
+ String uri = uriResolver.getWorkspaceUri(sessionInfo.getWorkspaceName());
+ method = new PropPatchMethod(uri, setProperties, new DavPropertyNameSet());
+ initMethod(method, sessionInfo, true);
+ getClient(sessionInfo).executeMethod(method);
+ method.checkSuccess();
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ } catch (DavException e) {
+ throw ExceptionConverter.generate(e);
+ } finally {
+ if (method != null) {
+ method.releaseConnection();
+ }
+ }
}
@Override
@@ -2494,38 +2486,38 @@ public class RepositoryServiceImpl imple
MkWorkspaceMethod method = null;
try {
- method = new MkWorkspaceMethod(uriResolver.getWorkspaceUri(name));
- initMethod(method, sessionInfo, true);
- getClient(sessionInfo).executeMethod(method);
- method.checkSuccess();
- } catch (IOException e) {
- throw new RepositoryException(e);
- } catch (DavException e) {
- throw ExceptionConverter.generate(e);
- } finally {
- if (method != null) {
- method.releaseConnection();
- }
- }
+ method = new MkWorkspaceMethod(uriResolver.getWorkspaceUri(name));
+ initMethod(method, sessionInfo, true);
+ getClient(sessionInfo).executeMethod(method);
+ method.checkSuccess();
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ } catch (DavException e) {
+ throw ExceptionConverter.generate(e);
+ } finally {
+ if (method != null) {
+ method.releaseConnection();
+ }
+ }
}
@Override
public void deleteWorkspace(SessionInfo sessionInfo, String name) throws RepositoryException {
DeleteMethod method = null;
try {
- method = new DeleteMethod(uriResolver.getWorkspaceUri(name));
- initMethod(method, sessionInfo, true);
- getClient(sessionInfo).executeMethod(method);
- method.checkSuccess();
- } catch (IOException e) {
- throw new RepositoryException(e);
- } catch (DavException e) {
- throw ExceptionConverter.generate(e);
- } finally {
- if (method != null) {
- method.releaseConnection();
- }
- }
+ method = new DeleteMethod(uriResolver.getWorkspaceUri(name));
+ initMethod(method, sessionInfo, true);
+ getClient(sessionInfo).executeMethod(method);
+ method.checkSuccess();
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ } catch (DavException e) {
+ throw ExceptionConverter.generate(e);
+ } finally {
+ if (method != null) {
+ method.releaseConnection();
+ }
+ }
}
/**
@@ -2652,7 +2644,6 @@ public class RepositoryServiceImpl imple
org.w3c.dom.Text txt2 = document.createTextNode(uri);
uriElem.appendChild(txt2);
-
nsElem.appendChild(prefixElem);
nsElem.appendChild(uriElem);
@@ -2663,7 +2654,6 @@ public class RepositoryServiceImpl imple
return new DefaultDavProperty<List<XmlSerializable>>(JcrRemotingConstants.JCR_NAMESPACES_LN, val, ItemResourceConstants.NAMESPACE, false);
}
-
private static DavProperty<List<XmlSerializable>> createNodeTypeProperty(String localName, String[] ntNames) {
// convert the specified node type names to a xml-serializable value
List<XmlSerializable> val = new ArrayList<XmlSerializable>();
@@ -2706,8 +2696,7 @@ public class RepositoryServiceImpl imple
private boolean isDavClass3(SessionInfo sessionInfo) {
try {
return getDavComplianceClasses(sessionInfo).contains("3");
- }
- catch (RepositoryException ex) {
+ } catch (RepositoryException ex) {
log.warn("failure to obtain OPTIONS response", ex);
return false;
}
@@ -2722,8 +2711,7 @@ public class RepositoryServiceImpl imple
sb.append("?").append(u.getRawQuery());
}
return sb.toString();
- }
- catch (java.net.URISyntaxException ex) {
+ } catch (java.net.URISyntaxException ex) {
log.warn("parsing " + uri, ex);
return uri;
}