From 6be9d57be122f4cfd72ec62748e8afe3e7478d28 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Tue, 27 Mar 2012 13:36:41 +0000 Subject: [PATCH] Merged BRANCHES/DEV/THOR1_WEBDAV to HEAD: 34815: WebDAV: PUT method updates mime-type if repo determines different mimetype from original request. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@34816 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../org/alfresco/repo/webdav/PutMethod.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/source/java/org/alfresco/repo/webdav/PutMethod.java b/source/java/org/alfresco/repo/webdav/PutMethod.java index e4a75d371d..7ec1dbef4b 100644 --- a/source/java/org/alfresco/repo/webdav/PutMethod.java +++ b/source/java/org/alfresco/repo/webdav/PutMethod.java @@ -237,7 +237,18 @@ public class PutMethod extends WebDAVMethod implements ActivityPostProducer getActionService().executeAction(extract, contentNodeInfo.getNodeRef()); } - + // If the mime-type determined by the repository is different + // from the original specified in the request, update it. + if (!m_strContentType.equals(writer.getMimetype())) + { + String oldMimeType = m_strContentType; + m_strContentType = writer.getMimetype(); + if (logger.isDebugEnabled()) + { + logger.debug("Mimetype originally specified as " + oldMimeType + + ", now guessed to be " + m_strContentType); + } + } // Set the response status, depending if the node existed or not m_response.setStatus(created ? HttpServletResponse.SC_CREATED : HttpServletResponse.SC_NO_CONTENT); @@ -282,6 +293,18 @@ public class PutMethod extends WebDAVMethod implements ActivityPostProducer return created; } + /** + * Retrieve the mimetype of the content sent for the PUT request. The initial + * value specified in the request may be updated after the file contents have + * been uploaded if the repository has determined a different mimetype for the content. + * + * @return content-type + */ + public String getContentType() + { + return this.m_strContentType; + } + /** * Create an activity post. *