RM-4568: extended upload method to support relativePath creation and

minor change in specification
This commit is contained in:
Silviu Dinuta
2017-01-19 16:53:19 +02:00
parent a7b698750b
commit 397730876b
2 changed files with 49 additions and 17 deletions

View File

@@ -64,6 +64,8 @@ import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair; import org.alfresco.util.Pair;
import org.alfresco.util.ParameterCheck; import org.alfresco.util.ParameterCheck;
import org.apache.commons.lang.StringUtils;
import org.springframework.extensions.webscripts.servlet.FormData;
import net.sf.acegisecurity.vote.AccessDecisionVoter; import net.sf.acegisecurity.vote.AccessDecisionVoter;
@@ -355,6 +357,36 @@ public class RMNodesImpl extends NodesImpl implements RMNodes
return super.createNode(parentNodeRef.getId(), nodeInfo, parameters); return super.createNode(parentNodeRef.getId(), nodeInfo, parameters);
} }
@Override
public Node upload(String parentFolderNodeId, FormData formData, Parameters parameters)
{
if (formData == null || !formData.getIsMultiPart())
{
throw new InvalidArgumentException("The request content-type is not multipart: "+parentFolderNodeId);
}
for (FormData.FormField field : formData.getFields())
{
if(field.getName().equalsIgnoreCase("relativepath"))
{
// Create the path if it does not exist
getOrCreatePath(parentFolderNodeId, getStringOrNull(field.getValue()), ContentModel.TYPE_CONTENT);
break;
}
}
return super.upload(parentFolderNodeId, formData, parameters);
}
private String getStringOrNull(String value)
{
if (StringUtils.isNotEmpty(value))
{
return value.equalsIgnoreCase("null") ? null : value;
}
return null;
}
@Override @Override
public NodeRef getOrCreatePath(String parentFolderNodeId, String relativePath, QName nodeTypeQName) public NodeRef getOrCreatePath(String parentFolderNodeId, String relativePath, QName nodeTypeQName)
{ {

View File

@@ -289,7 +289,7 @@ paths:
} }
``` ```
You can create an empty electronic record and use the record endpoint to create content: You can create an empty electronic record:
```JSON ```JSON
{ {
"name":"My Electronic Record", "name":"My Electronic Record",