mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-4568: extended upload method to support relativePath creation and
minor change in specification
This commit is contained in:
@@ -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)
|
||||||
{
|
{
|
||||||
|
@@ -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",
|
||||||
|
Reference in New Issue
Block a user