1

I need to share and unshare the content in alfresco using OpenCMIS, i read the documentation here for Apache Chemistry but i don't find this API functionality to share and unshare Documents.

So how can i do it programmatically?

user2758757
  • 109
  • 7
  • 1
    what do you mean in detail? Do you like to leverage Alfresco Share's public share feature or do you like to change permissions of a node? – alfrescian Sep 11 '13 at 08:03
  • look, when i share the content and view the shared content in a public share feature, any one can see this content without any permissions, so i need to manage the share in my web application with share and unshare and get the generated shared content id then display it in `http://localhost:8080/share/s/"theSharedContentIdAutoGenerated"` – user2758757 Sep 11 '13 at 09:17
  • Huh, still quite vague. The actual need of public sharing is that everyone can access it!. You can just use OpenCMIS ACL methods to set the permissions you need. And then users can access content they have authorization to. – Tahir Malik Sep 11 '13 at 14:48

1 Answers1

1

I'm going to interpret your requirement as following: You'd like to use Alfresco Share's "Quick Share"-Feature that is available in Alfresco Community 4.2 & Alfresco Cloud.


Alfresco Share uses the following internal API (REST/Webscript) to trigger a Quick Share:

POST /api/internal/shared/share/{store_protocol}/{store_id}/{node_id}

which return the generated quick share id as json:

{
   "sharedId": "IHR65hlGT9yOTKwqPYMbRw"
}

The WebScript is implemented as Java-backed WebScript. Controller is

org.alfresco.repo.web.scripts.quickshare.ShareContentPost

that uses the following Service:

org.alfresco.repo.quickshare.QuickShareServiceImpl

As you can see here this Service generates a UUID (the link id) & sets the value as property qshare:sharedId (Aspect qshare:shared):

 UUID uuid = UUIDGenerator.getInstance().generateRandomBasedUUID();
 sharedId = Base64.encodeBase64URLSafeString(uuid.toByteArray()); // => 22 chars (eg. q3bEKPeDQvmJYgt4hJxOjw)
  Map<QName,Serializable> props = new HashMap<QName,Serializable>(2);
  props.put(QuickShareModel.PROP_QSHARE_SHAREDID, sharedId);
  props.put(QuickShareModel.PROP_QSHARE_SHAREDBY, AuthenticationUtil.getRunAsUser());
  nodeService.addAspect(nodeRef, QuickShareModel.ASPECT_QSHARE, props);

You should be able to do this via CMIS, but this Service also sets an Attribute via AttributeService (stores all shared-IDs per tenant):

attributeService.setAttribute(tenantNodeRef, ATTR_KEY_SHAREDIDS_ROOT, sharedId)

I'm not sure for which purpose this is used & if it is a MUST have for your requirement.

alfrescian
  • 4,079
  • 1
  • 18
  • 20