Merged RETURN-OF-THE-API (5.2.0) to 5.2.N (5.2.1)

128442 jvonka: V1 REST API: Update binary content - add optional name param (to allow rename on upload of a new version)
   - api implementation + api sanity tests (+ve/-ve)
   REPO-518


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@129159 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Martin Muller
2016-08-05 13:46:13 +00:00
parent c6a7632a25
commit 93aa43babc
4 changed files with 71 additions and 13 deletions

View File

@@ -2254,7 +2254,17 @@ public class NodesImpl implements Nodes
}
String versionComment = parameters.getParameter(PARAM_VERSION_COMMENT);
final String fileName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
String fileName = parameters.getParameter(PARAM_NAME);
if (fileName != null)
{
// optionally rename, before updating the content
nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, fileName);
}
else
{
fileName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
}
return updateExistingFile(null, nodeRef, fileName, contentInfo, stream, parameters, versionMajor, versionComment);
}

View File

@@ -87,6 +87,14 @@ public class NodesEntityResource implements
return nodes.getFolderOrDocument(nodeId, parameters);
}
/**
* Download content
*
* @param fileNodeId
* @param parameters {@link Parameters}
* @return
* @throws EntityNotFoundException
*/
@Override
@WebApiDescription(title = "Download content", description = "Download content")
@BinaryProperties({"content"})
@@ -95,6 +103,19 @@ public class NodesEntityResource implements
return nodes.getContent(fileNodeId, parameters, true);
}
/**
* Upload new version of content
*
* This allow binary content update of an existing file/content node.
*
* Note: alternatively, can upload via POST (multipart/form-data) with existing file name and form "overwrite=true".
*
* @param fileNodeId
* @param contentInfo Basic information about the content stream
* @param stream An inputstream
* @param parameters
* @return
*/
@Override
@WebApiDescription(title = "Upload content", description = "Upload content")
@BinaryProperties({"content"})