mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Fixed AR-1321: Allow '&' in filename
The following filename is valid now: "x ¬ £ % & + ; x.txt" This was a restriction imposed by WebDAV, but the encoding of the repsonses is working well and these restrictions be removed as a result. Fixed AR-1281: WebDAV upload was assigning incorrect encoding I added a bean 'charset.finder', which can be fetched from the MimetypeService. Various pluggins now exist to decode a stream and figure out what the encoding is. WebDAV and CIFS/FTP are now hooked into this so that they guess a little better. Fixed others: Added retrying transactions to WebDAV. Read/write transactions for WebDAV. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6073 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -68,6 +68,7 @@ import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.service.cmr.lock.NodeLockedException;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
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.StoreRef;
|
||||
@@ -111,6 +112,7 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
|
||||
private NodeService nodeService;
|
||||
private SearchService searchService;
|
||||
private ContentService contentService;
|
||||
private MimetypeService mimetypeService;
|
||||
private PermissionService permissionService;
|
||||
private FileFolderService fileFolderService;
|
||||
|
||||
@@ -280,6 +282,14 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
|
||||
fileFolderService = fileService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mimetypeService service for helping with mimetypes and encoding
|
||||
*/
|
||||
public void setMimetypeService(MimetypeService mimetypeService)
|
||||
{
|
||||
this.mimetypeService = mimetypeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse and validate the parameter string and create a device context object for this instance
|
||||
* of the shared device. The same DeviceInterface implementation may be used for multiple
|
||||
@@ -1240,7 +1250,7 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
|
||||
{
|
||||
// Create the network file
|
||||
|
||||
netFile = ContentNetworkFile.createFile(transactionService, nodeService, contentService, cifsHelper, nodeRef, params);
|
||||
netFile = ContentNetworkFile.createFile(nodeService, contentService, mimetypeService, cifsHelper, nodeRef, params);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1406,7 +1416,7 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
|
||||
|
||||
// Create the network file
|
||||
|
||||
NetworkFile netFile = ContentNetworkFile.createFile(transactionService, nodeService, contentService, cifsHelper, nodeRef, params);
|
||||
NetworkFile netFile = ContentNetworkFile.createFile(nodeService, contentService, mimetypeService, cifsHelper, nodeRef, params);
|
||||
|
||||
// Truncate the file so that the content stream is created
|
||||
|
||||
|
@@ -24,10 +24,14 @@
|
||||
*/
|
||||
package org.alfresco.filesys.smb.server.repo;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.filesys.server.filesys.AccessDeniedException;
|
||||
@@ -38,15 +42,16 @@ import org.alfresco.filesys.server.filesys.NetworkFile;
|
||||
import org.alfresco.filesys.smb.SeekType;
|
||||
import org.alfresco.i18n.I18NUtil;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.content.encoding.ContentCharsetFinder;
|
||||
import org.alfresco.repo.content.filestore.FileContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentAccessor;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
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.transaction.TransactionService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -62,9 +67,9 @@ public class ContentNetworkFile extends NodeRefNetworkFile
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(ContentNetworkFile.class);
|
||||
|
||||
private TransactionService transactionService;
|
||||
private NodeService nodeService;
|
||||
private ContentService contentService;
|
||||
private MimetypeService mimetypeService;
|
||||
|
||||
// File channel to file content
|
||||
|
||||
@@ -86,9 +91,9 @@ public class ContentNetworkFile extends NodeRefNetworkFile
|
||||
* Helper method to create a {@link NetworkFile network file} given a node reference.
|
||||
*/
|
||||
public static ContentNetworkFile createFile(
|
||||
TransactionService transactionService,
|
||||
NodeService nodeService,
|
||||
ContentService contentService,
|
||||
MimetypeService mimetypeService,
|
||||
CifsHelper cifsHelper,
|
||||
NodeRef nodeRef,
|
||||
FileOpenParams params)
|
||||
@@ -100,7 +105,7 @@ public class ContentNetworkFile extends NodeRefNetworkFile
|
||||
|
||||
// Create the file
|
||||
|
||||
ContentNetworkFile netFile = new ContentNetworkFile(transactionService, nodeService, contentService, nodeRef, path);
|
||||
ContentNetworkFile netFile = new ContentNetworkFile(nodeService, contentService, mimetypeService, nodeRef, path);
|
||||
|
||||
// Set relevant parameters
|
||||
|
||||
@@ -176,17 +181,17 @@ public class ContentNetworkFile extends NodeRefNetworkFile
|
||||
* @param name String
|
||||
*/
|
||||
private ContentNetworkFile(
|
||||
TransactionService transactionService,
|
||||
NodeService nodeService,
|
||||
ContentService contentService,
|
||||
MimetypeService mimetypeService,
|
||||
NodeRef nodeRef,
|
||||
String name)
|
||||
{
|
||||
super(name, nodeRef);
|
||||
setFullName(name);
|
||||
this.transactionService = transactionService;
|
||||
this.nodeService = nodeService;
|
||||
this.contentService = contentService;
|
||||
this.mimetypeService = mimetypeService;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -362,6 +367,13 @@ public class ContentNetworkFile extends NodeRefNetworkFile
|
||||
|
||||
if (modified)
|
||||
{
|
||||
// Take a guess at the mimetype
|
||||
channel.position(0);
|
||||
InputStream is = new BufferedInputStream(Channels.newInputStream(channel));
|
||||
ContentCharsetFinder charsetFinder = mimetypeService.getContentCharsetFinder();
|
||||
Charset charset = charsetFinder.getCharset(is, content.getMimetype());
|
||||
content.setEncoding(charset.name());
|
||||
|
||||
// Close the channel
|
||||
|
||||
channel.close();
|
||||
|
Reference in New Issue
Block a user