use of org.apache.chemistry.opencmis.commons.exceptions.CmisVersioningException in project alfresco-repository by Alfresco.
the class AlfrescoCmisServiceImpl method cancelCheckOut.
@Override
public void cancelCheckOut(String repositoryId, String objectId, ExtensionsData extension) {
checkRepositoryId(repositoryId);
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
// only accept a PWC
if (!info.isVariant(CMISObjectVariant.PWC)) {
NodeRef nodeRef = info.getNodeRef();
NodeRef workingCopyNodeRef = connector.getCheckOutCheckInService().getWorkingCopy(nodeRef);
info = getOrCreateNodeInfo(workingCopyNodeRef.getId());
if (!info.isVariant(CMISObjectVariant.PWC)) {
throw new CmisVersioningException("Object is not a PWC!");
}
}
// get object
final NodeRef nodeRef = info.getNodeRef();
// cancel check out
connector.getCheckOutCheckInService().cancelCheckout(nodeRef);
}
use of org.apache.chemistry.opencmis.commons.exceptions.CmisVersioningException in project alfresco-repository by Alfresco.
the class AlfrescoCmisServiceImpl method checkIn.
@Override
public void checkIn(String repositoryId, final Holder<String> objectId, final Boolean major, final Properties properties, final ContentStream contentStream, final String checkinComment, final List<String> policies, final Acl addAces, final Acl removeAces, ExtensionsData extension) {
checkRepositoryId(repositoryId);
CMISNodeInfo info = getOrCreateNodeInfo(objectId.getValue(), "Object");
// only accept a PWC
if (!info.isVariant(CMISObjectVariant.PWC)) {
throw new CmisVersioningException("Object is not a PWC!");
}
// get object
final NodeRef nodeRef = info.getNodeRef();
final TypeDefinitionWrapper type = info.getType();
// check in
// update PWC
connector.setProperties(nodeRef, type, properties, new String[] { PropertyIds.OBJECT_TYPE_ID });
connector.applyPolicies(nodeRef, type, policies);
connector.applyACL(nodeRef, type, addAces, removeAces);
// handle content
if (contentStream != null) {
String mimeType = parseMimeType(contentStream);
String encoding = getEncoding(contentStream.getStream(), mimeType);
// write content
ContentWriter writer = connector.getFileFolderService().getWriter(nodeRef);
writer.setMimetype(mimeType);
writer.setEncoding(encoding);
writer.putContent(contentStream.getStream());
}
// create version properties
Map<String, Serializable> versionProperties = new HashMap<String, Serializable>(5);
versionProperties.put(VersionModel.PROP_VERSION_TYPE, major ? VersionType.MAJOR : VersionType.MINOR);
if (checkinComment != null) {
versionProperties.put(VersionModel.PROP_DESCRIPTION, checkinComment);
}
// check in
NodeRef newNodeRef = connector.getCheckOutCheckInService().checkin(nodeRef, versionProperties);
connector.getActivityPoster().postFileFolderUpdated(info.isFolder(), newNodeRef);
objectId.setValue(connector.createObjectId(newNodeRef));
}
Aggregations