Search in sources :

Example 1 with UnsupportedMediaTypeException

use of org.alfresco.rest.framework.core.exceptions.UnsupportedMediaTypeException in project alfresco-remote-api by Alfresco.

the class NodesImpl method updateContent.

@Override
public Node updateContent(String fileNodeId, BasicContentInfo contentInfo, InputStream stream, Parameters parameters) {
    if (contentInfo.getMimeType().toLowerCase().startsWith("multipart")) {
        throw new UnsupportedMediaTypeException("Cannot update using " + contentInfo.getMimeType());
    }
    final NodeRef nodeRef = validateNode(fileNodeId);
    if (!nodeMatches(nodeRef, Collections.singleton(ContentModel.TYPE_CONTENT), null, false)) {
        throw new InvalidArgumentException("NodeId of content is expected: " + nodeRef.getId());
    }
    Boolean versionMajor = null;
    String str = parameters.getParameter(PARAM_VERSION_MAJOR);
    if (str != null) {
        versionMajor = Boolean.valueOf(str);
    }
    String versionComment = parameters.getParameter(PARAM_VERSION_COMMENT);
    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);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) InvalidArgumentException(org.alfresco.rest.framework.core.exceptions.InvalidArgumentException) UnsupportedMediaTypeException(org.alfresco.rest.framework.core.exceptions.UnsupportedMediaTypeException) FilterPropBoolean(org.alfresco.repo.node.getchildren.FilterPropBoolean)

Aggregations

FilterPropBoolean (org.alfresco.repo.node.getchildren.FilterPropBoolean)1 InvalidArgumentException (org.alfresco.rest.framework.core.exceptions.InvalidArgumentException)1 UnsupportedMediaTypeException (org.alfresco.rest.framework.core.exceptions.UnsupportedMediaTypeException)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1