Frage

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?

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top