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);
}
Aggregations