mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD (5.2) to 5.2.N (5.2.1)
126546 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 124063 jvonka: RA-885: Nodes (FileFolder) API - upload (create node with file content) improvements - guess mimetype if (multi-)part Content-Type field is missing or is default binary mime type (application/octet-stream) - ignore filename override if null or empty git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126892 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -49,6 +49,7 @@ import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.action.executer.ContentMetadataExtracter;
|
||||
import org.alfresco.repo.content.ContentLimitViolationException;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.model.Repository;
|
||||
import org.alfresco.repo.model.filefolder.FileFolderServiceImpl;
|
||||
import org.alfresco.repo.node.getchildren.GetChildrenCannedQuery;
|
||||
@@ -153,12 +154,14 @@ public class NodesImpl implements Nodes
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(NodesImpl.class);
|
||||
|
||||
private static enum Type
|
||||
private enum Type
|
||||
{
|
||||
// Note: ordered
|
||||
DOCUMENT, FOLDER
|
||||
}
|
||||
|
||||
private static final String DEFAULT_MIMETYPE = MimetypeMap.MIMETYPE_BINARY;
|
||||
|
||||
private NodeService nodeService;
|
||||
private DictionaryService dictionaryService;
|
||||
private FileFolderService fileFolderService;
|
||||
@@ -171,7 +174,6 @@ public class NodesImpl implements Nodes
|
||||
private PersonService personService;
|
||||
private OwnableService ownableService;
|
||||
private AuthorityService authorityService;
|
||||
private SiteServiceInternal siteServiceInternal;
|
||||
|
||||
private BehaviourFilter behaviourFilter;
|
||||
|
||||
@@ -1817,9 +1819,9 @@ public class NodesImpl implements Nodes
|
||||
{
|
||||
String mimeType = contentInfo.mimeType;
|
||||
// Manage MimeType
|
||||
if (mimeType == null)
|
||||
if ((mimeType == null) || mimeType.equals(DEFAULT_MIMETYPE))
|
||||
{
|
||||
// the mimeType was not provided via the contentInfo, so try to guess
|
||||
// the mimeType was not provided (or was the default binary mimeType) via the contentInfo, so try to guess
|
||||
final String fileName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||
mimeType = mimetypeService.guessMimetype(fileName);
|
||||
}
|
||||
@@ -1871,13 +1873,17 @@ public class NodesImpl implements Nodes
|
||||
switch (field.getName().toLowerCase())
|
||||
{
|
||||
case "filename":
|
||||
fileName = getStringOrNull(field.getValue());
|
||||
String str = getStringOrNull(field.getValue());
|
||||
if ((str != null) && (! str.isEmpty()))
|
||||
{
|
||||
fileName = str;
|
||||
}
|
||||
break;
|
||||
|
||||
case "filedata":
|
||||
if (field.getIsFile())
|
||||
{
|
||||
fileName = fileName != null ? fileName : field.getFilename();
|
||||
fileName = (fileName != null ? fileName : field.getFilename());
|
||||
content = field.getContent();
|
||||
}
|
||||
break;
|
||||
@@ -1929,7 +1935,7 @@ public class NodesImpl implements Nodes
|
||||
}
|
||||
// Ensure mandatory file attributes have been located. Need either
|
||||
// destination, or site + container or updateNodeRef
|
||||
if ((fileName == null || content == null))
|
||||
if ((fileName == null) || fileName.isEmpty() || (content == null))
|
||||
{
|
||||
throw new InvalidArgumentException("Required parameters are missing");
|
||||
}
|
||||
@@ -2051,8 +2057,8 @@ public class NodesImpl implements Nodes
|
||||
protected void write(NodeRef nodeRef, Content content)
|
||||
{
|
||||
ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
|
||||
// Per RA-637 requirement the mimeType provided by the client takes precedence, however,
|
||||
// if the mimeType is null, then it will be guessed.
|
||||
// Per RA-637 & RA-885 requirement the mimeType provided by the client takes precedence, however,
|
||||
// if the mimeType is null (or default binary mimeType) then it will be guessed.
|
||||
setWriterContentType(writer, new ContentInfoWrapper(content), nodeRef, true);
|
||||
writer.putContent(content.getInputStream());
|
||||
}
|
||||
|
Reference in New Issue
Block a user