mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (4.3/Cloud)
73685: Merged V4.2-BUG-FIX (4.2.3) to HEAD-BUG-FIX (4.3/Cloud) 73523: Merged DEV 4.2.N to V4.2-BUG-FIX (4.2.3) 67086: MNT-10820: In WebDav browser interface, the folder listing action triggers READ audit activity - WebDAV 'GET' method handler implementation has been modified to use content property instead of content reader for retrieving metadata during generating folder listing. Using content reader for getting document size and mime type is overkill. Regression test has been added for this test case git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@74800 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
package org.alfresco.repo.webdav;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.io.Writer;
|
||||
import java.net.SocketException;
|
||||
import java.text.ParseException;
|
||||
@@ -36,12 +37,15 @@ import org.alfresco.repo.web.util.HttpRangeProcessor;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.model.FileNotFoundException;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.service.cmr.repository.datatype.TypeConverter;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
@@ -431,9 +435,9 @@ public class GetMethod extends WebDAVMethod
|
||||
*/
|
||||
private void generateDirectoryListing(FileInfo fileInfo)
|
||||
{
|
||||
FileFolderService fileFolderService = getFileFolderService();
|
||||
MimetypeService mimeTypeService = getMimetypeService();
|
||||
|
||||
NodeService nodeService = getNodeService();
|
||||
|
||||
Writer writer = null;
|
||||
|
||||
try
|
||||
@@ -498,15 +502,16 @@ public class GetMethod extends WebDAVMethod
|
||||
{
|
||||
rootURL = rootURL + WebDAVHelper.PathSeperator;
|
||||
}
|
||||
|
||||
if (wasLink)
|
||||
{
|
||||
Path pathToNode = getNodeService().getPath(fileInfo.getNodeRef());
|
||||
Path pathToNode = nodeService.getPath(fileInfo.getNodeRef());
|
||||
if (pathToNode.size() > 2)
|
||||
{
|
||||
pathToNode = pathToNode.subPath(2, pathToNode.size() - 1);
|
||||
}
|
||||
|
||||
rootURL = getURLForPath(m_request, pathToNode.toDisplayPath(getNodeService(), getPermissionService()), true);
|
||||
rootURL = getURLForPath(m_request, pathToNode.toDisplayPath(nodeService, getPermissionService()), true);
|
||||
if (rootURL.endsWith(WebDAVHelper.PathSeperator) == false)
|
||||
{
|
||||
rootURL = rootURL + WebDAVHelper.PathSeperator;
|
||||
@@ -560,19 +565,41 @@ public class GetMethod extends WebDAVMethod
|
||||
|
||||
// size field
|
||||
writer.write("</td><td class='textData'>");
|
||||
|
||||
ContentData contentData = null;
|
||||
if (!childNodeInfo.isFolder())
|
||||
{
|
||||
Serializable contentPropertyName = nodeService.getProperty(childNodeInfo.getNodeRef(), ContentModel.PROP_CONTENT_PROPERTY_NAME);
|
||||
QName contentPropertyQName = DefaultTypeConverter.INSTANCE.convert(QName.class, contentPropertyName);
|
||||
|
||||
if (null == contentPropertyQName)
|
||||
{
|
||||
contentPropertyQName = ContentModel.PROP_CONTENT;
|
||||
}
|
||||
|
||||
Serializable contentProperty = nodeService.getProperty(childNodeInfo.getNodeRef(), contentPropertyQName);
|
||||
|
||||
if (contentProperty instanceof ContentData)
|
||||
{
|
||||
contentData = (ContentData) contentProperty;
|
||||
}
|
||||
}
|
||||
|
||||
if (childNodeInfo.isFolder())
|
||||
{
|
||||
writer.write(" ");
|
||||
}
|
||||
else
|
||||
{
|
||||
ContentReader reader = fileFolderService.getReader(childNodeInfo.getNodeRef());
|
||||
long fsize = 0L;
|
||||
if (reader != null)
|
||||
if (null != contentData)
|
||||
{
|
||||
fsize = reader.getSize();
|
||||
writer.write(formatSize(Long.toString(contentData.getSize())));
|
||||
}
|
||||
writer.write(formatSize(Long.toString(fsize)));
|
||||
else
|
||||
{
|
||||
writer.write(" ");
|
||||
}
|
||||
|
||||
}
|
||||
writer.write("</td><td class='textData'>");
|
||||
|
||||
@@ -583,21 +610,16 @@ public class GetMethod extends WebDAVMethod
|
||||
}
|
||||
else
|
||||
{
|
||||
ContentReader reader = fileFolderService.getReader(childNodeInfo.getNodeRef());
|
||||
String mimetype = " ";
|
||||
if (reader != null)
|
||||
if (null != contentData)
|
||||
{
|
||||
mimetype = reader.getMimetype();
|
||||
String displayType = mimeTypeService.getDisplaysByMimetype().get(reader.getMimetype());
|
||||
mimetype = contentData.getMimetype();
|
||||
String displayType = mimeTypeService.getDisplaysByMimetype().get(mimetype);
|
||||
|
||||
if (displayType != null)
|
||||
{
|
||||
mimetype = displayType;
|
||||
}
|
||||
if (mimetype == null)
|
||||
{
|
||||
mimetype = reader.getMimetype();
|
||||
}
|
||||
}
|
||||
writer.write(mimetype);
|
||||
}
|
||||
|
Reference in New Issue
Block a user