문제

Can someone post the code necessary to get the private working copy ID or object from an object that has been checked out previously? I tried to use Alfresco web Scripts to get the working copy, like this: /alfresco/service/cmis/pwc/i/d1f91b65-1165-4db5-8521-8fc3abb1074b but it gave me a 404

any help please

도움이 되었습니까?

해결책

Using OpenCMIS, the getAllVersions() call returns all versions of the object, including the Private Working Copy (PWC) if the object is checked out. The PWC will be on the top of the list followed by the latest version.

So, in your case, if you want to do a query for the object, or navigate through the folder tree, or whatever, you can do that. Then ask the object for its versions and you can get the PWC from that list if it is checked out.

Here's a Groovy example:

document = session.getObjectByPath('/versionableExample.txt')
println("Checked out?" + document.versionSeriesCheckedOut)
versions = document.getAllVersions()
for (version in versions) {
    println ("Version:" + version.versionLabel + " PWC?:" + version.privateWorkingCopy)
}

This outputs the following assuming a document called versionableExample.txt exists in the root of the Apache Chemistry In-Memory repo that has three versions and is currently checked out:

Checked out?true
Version:V 4.0 PWC?:true
Version:V 3.0 PWC?:false
Version:V 2.0 PWC?:false
Version:V 1.0 PWC?:false

Hope that helps,

Jeff

다른 팁

The property cmis:versionSeriesCheckedOutId should contain the PWC id if the document is checked out. Here is an OpenCMIS snippet:

String pwcId = doc.getVersionSeriesCheckedOutId();
Document pwc = (Document) session.getObject(pwcId);

I guess your answer is in this forum post.

I'll recap shortly:

RepositoryInfo repositoryInfo = session.getRepositoryInfo();
AclCapabilities aclCapabilities = repositoryInfo.getAclCapabilities();
Map<String, PermissionMapping> permissionMappings = aclCapabilities.getPermissionMapping();
PermissionMapping permissionMapping = permissionMappings.get(PermissionMapping.CAN_CHECKOUT_DOCUMENT);

List<String> permissions = permissionMapping.getPermissions();

Ace addAce = session.getObjectFactory().createAce(principal, permissions);
List<Ace> addAces = new LinkedList<Ace>();
addAces.add(addAce);

document.addAcl(addAces, AclPropagation.REPOSITORYDETERMINED);
ObjectId checkedOutDocumentObjectId = document.checkOut();

Document checkedOutDocument = (Document) session.getObject(checkedOutDocumentObjectId);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top