05-29-2018 09:59 AM
I am using Alfresco Entreprise 5.2.3.
I created a service with org.apache.chemistry.opencmis (client) 1.1.0 with atompub connection, which creates folders and saves documents to a repository /Sites/bdes/documentLibrary/extraitconforme/ that I can view with alfresco webpage :
http://localhost:9080/share/page/site/bdes/document-details?nodeRef=workspace://SpacesStore/7d1cbc32...
I also want to make a document publicly downloadable with no authentication.
Meaning after saving of the document I want to make it immediatly publicly shareble for download only.
Because there is nothing in chemistry doing this I start using Alfresco's following webscript.
/api/internal/shared/share/{store_protocol}/{store_id}/{node_id}
http://localhost:9080/alfresco/service/index/uri/api/internal/shared/share/%7Bstore_protocol%7D/%7Bs...
Because this is a httppost request to the server, I cannot do this without authentication.
So I got an authtenication ticket first by the webscript : /alfresco/service/api/login
Than I call the "quickshare" webscript : /alfresco/service/api/internal/shared/share/workspace/SpacesStore/{node_id}.
to make the document publicly shareble and get a share_id.
Because I don't know yet how to get the nodeId (unless its the same as the docId from Document
I get de the id from sharelink in alfresco webpage in the share field and add it to the httppost
So My httppost to make the file shareable will be :
http://localhost:9080/alfresco/service/api/internal/shared/share/workspace/SpacesStore/7d1cbc32-747d...?ticket=TICKET_d3e8854a4f253a1608615b294c5ed8520fd94f1f
or
http://localhost:9080/alfresco/service/api/internal/shared/share/workspace/SpacesStore/7d1cbc32-747d...?alf_ticket=TICKET_d3e8854a4f253a1608615b294c5ed8520fd94f1f
when putting this in my browser (firefox) , I get :
status
code 500
name "Internal Error"
description "An error inside the HTTP server which prevented it from fulfilling the request."
message "04290072 Wrapped Exception (with status template): 04290094 Unable to find: workspace/SpacesStore/7d1cbc32-747d-44ba-9d1a-6a0709be4b77"
exception ""
callstack []
server "Enterprise v5.2.3 (r852994b1-b12) schema 10.065"
time "29-mei-2018 18:22:04"
What am I doing wrong here?..
Can I even use ticket to get a document publicaly downloadable?
Can anyone please help me out.
I've read a lot of article about this, still I dont see whats wrong here.
06-01-2018 10:25 AM
The fact that the doc ID and the CMIS Object ID appear to be related is something you should DEFINITELY NOT depend on. The CMIS object ID is intended to be opaque. You should not try to reverse engineer it and you should not try to create it by appending the document ID to the version label. Doing so will create very brittle code that could break without notice.
Most CMIS calls in Alfresco will accept either a CMIS Object ID or the Alfresco Node Reference.
If you need to get the Alfresco Node Reference from a CMIS object, look at its properties. The NodeReference is available in the alfcmis:nodeRef property.
06-02-2018 06:20 AM
Jeff,
Thanks for the important tip.
I tested docId and nodeRef and the call does not support neither.
alfcmis:nodeRef returns value: "workspace://SpacesStore/7f5772df-a840-498b-bae1-5fcf70efb485"
In the properties there is no property nodeId ... see link :
What I need is that part after the last "/" namingly : 7f5772df-a840-498b-bae1-5fcf70efb485
Can I substring the nodeRef to have the nodeId, or shouldn't I depend on it either?
06-02-2018 01:15 PM
Yes, you can substring the Alfresco nodeRef to remove "workspace://SpacesStore" assuming you only care about nodes in the spaces store and do not care about nodes in the archive store.
06-02-2018 01:43 PM
Great !
All works like a sharm now.
Jeff, thank you for your help and guidance.
Very much appreciated.
Samir
12-02-2021 11:06 PM
how to get the username and password in above code?
Explore our Alfresco products with the links below. Use labels to filter content by product module.