Author: dkatayev
Date: 2010-02-09 11:27:22 -0500 (Tue, 09 Feb 2010)
New Revision: 1744
Modified:
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/MkColCommand.java
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestMkCol.java
Log:
EXOJCR-471 MKCOL bug fixed
Modified:
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java 2010-02-09
15:36:28 UTC (rev 1743)
+++
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java 2010-02-09
16:27:22 UTC (rev 1744)
@@ -393,12 +393,12 @@
else
{
Session session = session(repoName, workspaceName(repoPath), null);
- String uri = serverURI + "/" + srcWorkspace;
- Response prpfind = new PropFindCommand().propfind(session, destNodePath,
body, depth.getIntValue(), uri);
- if (prpfind.getStatus() != HTTPStatus.NOT_FOUND)
+
+ if (session.getRootNode().hasNode(TextUtil.relativizePath(repoPath)))
{
return Response.status(HTTPStatus.PRECON_FAILED).entity("Not
Found").build();
}
+
}
if (depth.getStringValue().equalsIgnoreCase("infinity"))
@@ -524,7 +524,8 @@
int dash = token.indexOf("-");
if (dash == -1)
{
- return
Response.status(HTTPStatus.REQUESTED_RANGE_NOT_SATISFIABLE).entity("Requested Range
Not Satisfiable").build();
+ return
Response.status(HTTPStatus.REQUESTED_RANGE_NOT_SATISFIABLE).entity(
+ "Requested Range Not Satisfiable").build();
}
else if (dash == 0)
{
Modified:
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/MkColCommand.java
===================================================================
---
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/MkColCommand.java 2010-02-09
15:36:28 UTC (rev 1743)
+++
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/MkColCommand.java 2010-02-09
16:27:22 UTC (rev 1744)
@@ -81,14 +81,24 @@
try
{
nullResourceLocks.checkLock(session, path, tokens);
- node = session.getRootNode().addNode(TextUtil.relativizePath(path), nodeType);
- if (mixinTypes != null)
+ try
{
- addMixins(node, mixinTypes);
+ node = session.getRootNode().getNode(TextUtil.relativizePath(path));
+ return Response.status(HTTPStatus.METHOD_NOT_ALLOWED).entity(
+ "MKCOL can only be executed on a deleted/non-existent
resource").build();
}
- session.save();
+ catch (PathNotFoundException e)
+ {
+ node = session.getRootNode().addNode(TextUtil.relativizePath(path),
nodeType);
+ if (mixinTypes != null)
+ {
+ addMixins(node, mixinTypes);
+ }
+ session.save();
+ }
+
}
catch (ItemExistsException exc)
{
Modified:
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestMkCol.java
===================================================================
---
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestMkCol.java 2010-02-09
15:36:28 UTC (rev 1743)
+++
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestMkCol.java 2010-02-09
16:27:22 UTC (rev 1744)
@@ -57,6 +57,17 @@
Node folderNode = session.getRootNode().getNode(TextUtil.relativizePath(folder));
assertTrue(folderNode.hasNode(TextUtil.relativizePath(file)));
}
+
+
+ public void testExistentMkCol() throws Exception
+ {
+ String folder = TestUtils.getFolderName();
+ ContainerResponse response = service(WebDAVMethods.MKCOL, getPathWS() + folder,
"", null, null);
+ assertEquals(HTTPStatus.CREATED, response.getStatus());
+
+ response = service(WebDAVMethods.MKCOL, getPathWS() + folder, "", null,
null);
+ assertEquals(HTTPStatus.METHOD_NOT_ALLOWED, response.getStatus());
+ }
@Override
protected String getRepositoryName()
Show replies by date