diff --git a/source/java/org/alfresco/repo/webdav/GetMethod.java b/source/java/org/alfresco/repo/webdav/GetMethod.java
index 08fef39382..1b970781a3 100644
--- a/source/java/org/alfresco/repo/webdav/GetMethod.java
+++ b/source/java/org/alfresco/repo/webdav/GetMethod.java
@@ -141,6 +141,15 @@ public class GetMethod extends WebDAVMethod
// Nothing to do in this method
}
+ /**
+ * @return Returns true always
+ */
+ @Override
+ protected boolean isReadOnly()
+ {
+ return true;
+ }
+
/**
* Exceute the WebDAV request
*
diff --git a/source/java/org/alfresco/repo/webdav/OptionsMethod.java b/source/java/org/alfresco/repo/webdav/OptionsMethod.java
index cac9e47f6a..70dc431301 100644
--- a/source/java/org/alfresco/repo/webdav/OptionsMethod.java
+++ b/source/java/org/alfresco/repo/webdav/OptionsMethod.java
@@ -69,6 +69,15 @@ public class OptionsMethod extends WebDAVMethod
// Nothing to do in this method
}
+ /**
+ * @return Returns true always
+ */
+ @Override
+ protected boolean isReadOnly()
+ {
+ return true;
+ }
+
/**
* Perform the main request processing
*
diff --git a/source/java/org/alfresco/repo/webdav/PutMethod.java b/source/java/org/alfresco/repo/webdav/PutMethod.java
index 3e212bf7e4..21ab9914ca 100644
--- a/source/java/org/alfresco/repo/webdav/PutMethod.java
+++ b/source/java/org/alfresco/repo/webdav/PutMethod.java
@@ -24,14 +24,17 @@
*/
package org.alfresco.repo.webdav;
+import java.io.BufferedInputStream;
import java.io.InputStream;
import java.io.Serializable;
+import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.alfresco.model.ContentModel;
+import org.alfresco.repo.content.encoding.ContentCharsetFinder;
import org.alfresco.service.cmr.model.FileExistsException;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo;
@@ -142,23 +145,28 @@ public class PutMethod extends WebDAVMethod
// Access the content
ContentWriter writer = fileFolderService.getWriter(contentNodeInfo.getNodeRef());
// set content properties
+ String mimetype = null;
if (m_strContentType != null)
{
- writer.setMimetype(m_strContentType);
+ mimetype = m_strContentType;
}
else
{
- String guessedMimetype = getServiceRegistry().getMimetypeService().guessMimetype(contentNodeInfo.getName());
- writer.setMimetype(guessedMimetype);
+ String guessedMimetype = getMimetypeService().guessMimetype(contentNodeInfo.getName());
+ mimetype = guessedMimetype;
}
- // use default encoding
- writer.setEncoding("UTF-8");
+ writer.setMimetype(mimetype);
// Get the input stream from the request data
- InputStream input = m_request.getInputStream();
+ InputStream is = m_request.getInputStream();
+ is = is.markSupported() ? is : new BufferedInputStream(is);
+
+ ContentCharsetFinder charsetFinder = getMimetypeService().getContentCharsetFinder();
+ Charset encoding = charsetFinder.getCharset(is, mimetype);
+ writer.setEncoding(encoding.name());
// Write the new data to the content node
- writer.putContent(input);
+ writer.putContent(is);
// Set the response status, depending if the node existed or not
m_response.setStatus(created ? HttpServletResponse.SC_CREATED : HttpServletResponse.SC_NO_CONTENT);
diff --git a/source/java/org/alfresco/repo/webdav/WebDAVHelper.java b/source/java/org/alfresco/repo/webdav/WebDAVHelper.java
index e9b36bcdd5..ac2ea685f8 100644
--- a/source/java/org/alfresco/repo/webdav/WebDAVHelper.java
+++ b/source/java/org/alfresco/repo/webdav/WebDAVHelper.java
@@ -88,9 +88,6 @@ public class WebDAVHelper
/**
* Class constructor
- *
- * @param serviceRegistry ServiceRegistry
- * @param authService AuthenticationService
*/
protected WebDAVHelper(ServiceRegistry serviceRegistry, AuthenticationService authService)
{
@@ -108,9 +105,7 @@ public class WebDAVHelper
}
/**
- * Return the authentication service
- *
- * @return AuthenticationService
+ * @return Return the authentication service
*/
public final AuthenticationService getAuthenticationService()
{
@@ -118,9 +113,7 @@ public class WebDAVHelper
}
/**
- * Return the service registry
- *
- * @return ServiceRegistry
+ * @return Return the service registry
*/
public final ServiceRegistry getServiceRegistry()
{
@@ -128,9 +121,7 @@ public class WebDAVHelper
}
/**
- * Return the node service
- *
- * @return NodeService
+ * @return Return the node service
*/
public final NodeService getNodeService()
{
@@ -143,9 +134,7 @@ public class WebDAVHelper
}
/**
- * Return the search service
- *
- * @return SearchService
+ * @return Return the search service
*/
public final SearchService getSearchService()
{
@@ -153,9 +142,7 @@ public class WebDAVHelper
}
/**
- * Return the namespace service
- *
- * @return NamespaceService
+ * @return Return the namespace service
*/
public final NamespaceService getNamespaceService()
{
@@ -163,9 +150,7 @@ public class WebDAVHelper
}
/**
- * Return the dictionary service
- *
- * @return DictionaryService
+ * @return Return the dictionary service
*/
public final DictionaryService getDictionaryService()
{
@@ -173,9 +158,7 @@ public class WebDAVHelper
}
/**
- * Return the mimetype service
- *
- * @return MimetypeService
+ * @return Return the mimetype service
*/
public final MimetypeService getMimetypeService()
{
@@ -183,9 +166,7 @@ public class WebDAVHelper
}
/**
- * Return the lock service
- *
- * @return LockService
+ * @return Return the lock service
*/
public final LockService getLockService()
{
@@ -193,9 +174,7 @@ public class WebDAVHelper
}
/**
- * Return the copy service
- *
- * @return CopyService
+ * @return Return the copy service
*/
public final CopyService getCopyService()
{
@@ -237,8 +216,8 @@ public class WebDAVHelper
/**
* Split the path into all the component directories and filename
*
- * @param path String
- * @return String[]
+ * @param path the string to split
+ * @return an array of all the path components
*/
public final List splitAllPaths(String path)
{
@@ -260,11 +239,12 @@ public class WebDAVHelper
/**
* Get the file info for the given paths
*
- * @param rootNodeRef the acting webdav root
- * @param path the path to search for
- * @param servletPath the base servlet path, which may be null or empty
- * @return Return the file info for the path
- * @throws FileNotFoundException if the path doesn't refer to a valid node
+ * @param rootNodeRef the acting webdav root
+ * @param path the path to search for
+ * @param servletPath the base servlet path, which may be null or empty
+ * @return Return the file info for the path
+ * @throws FileNotFoundException
+ * if the path doesn't refer to a valid node
*/
public final FileInfo getNodeForPath(NodeRef rootNodeRef, String path, String servletPath) throws FileNotFoundException
{
@@ -366,9 +346,6 @@ public class WebDAVHelper
/**
* Make an ETag value for a node using the GUID and modify date/time
- *
- * @param node NodeRef
- * @return String
*/
public final String makeETag(NodeRef node)
{
@@ -381,9 +358,6 @@ public class WebDAVHelper
/**
* Make an ETag value for a node using the GUID and modify date/time
- *
- * @param node NodeRef
- * @return String
*/
public final String makeQuotedETag(NodeRef node)
{
@@ -397,9 +371,6 @@ public class WebDAVHelper
/**
* Make an ETag value for a node using the GUID and modify date/time
- *
- * @param node NodeRef
- * @param str StringBuilder
*/
protected final void makeETagString(NodeRef node, StringBuilder etag)
{
@@ -417,9 +388,7 @@ public class WebDAVHelper
}
/**
- * Return the null XML attribute list
- *
- * @return AttributesImpl
+ * @return Return the null XML attribute list
*/
public final AttributesImpl getNullAttributes()
{
@@ -429,7 +398,7 @@ public class WebDAVHelper
/**
* Encodes the given string to valid URL format
*
- * @param s the String to convert
+ * @param s the String to convert
*/
public final static String encodeURL(String s)
{
@@ -446,11 +415,7 @@ public class WebDAVHelper
/**
* Replace one string instance with another within the specified string
*
- * @param str
- * @param repl
- * @param with
- *
- * @return replaced string
+ * @return Returns the replaced string
*/
public static String replace(String str, String repl, String with)
{
@@ -478,7 +443,7 @@ public class WebDAVHelper
/**
* Encodes the given string to valid HTML format
*
- * @param string the String to convert
+ * @param string the String to convert
*/
public final static String encodeHTML(String string)
{
diff --git a/source/java/org/alfresco/repo/webdav/WebDAVMethod.java b/source/java/org/alfresco/repo/webdav/WebDAVMethod.java
index 82eaf5936f..d2c83721c6 100644
--- a/source/java/org/alfresco/repo/webdav/WebDAVMethod.java
+++ b/source/java/org/alfresco/repo/webdav/WebDAVMethod.java
@@ -37,8 +37,7 @@ import javax.xml.parsers.ParserConfigurationException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.permissions.AccessDeniedException;
-import org.alfresco.repo.transaction.TransactionUtil;
-import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
+import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.lock.LockService;
import org.alfresco.service.cmr.model.FileFolderService;
@@ -114,11 +113,23 @@ public abstract class WebDAVMethod
m_strPath = WebDAV.getRepositoryPath(req);
}
+
+ /**
+ * Override and return true if the method is a query method only. The default implementation
+ * returns false.
+ *
+ * @return Returns true if the method transaction may be read-only
+ */
+ protected boolean isReadOnly()
+ {
+ return false;
+ }
/**
- * Executes the method
+ * Executes the method, wrapping the call to {@link #executeImpl()} in an appropriate transaction
+ * and handling the error conditions.
*/
- public void execute() throws WebDAVServerException
+ public final void execute() throws WebDAVServerException
{
// Parse the HTTP headers
parseRequestHeaders();
@@ -126,9 +137,9 @@ public abstract class WebDAVMethod
// Parse the HTTP body
parseRequestBody();
- TransactionWork executeWork = new TransactionWork()
+ RetryingTransactionCallback