Ayoub Idelhoussain
Ayoub Idelhoussain

Reputation: 655

CMIS how to fetch a document by it's objectId


i'm trying to fetch document from alfresco using CMIS queries and all i have is there object id i tried the following but it returned 'bad request'

SELECT * FROM cmis:document where cmis:objectId = workspace://SpacesStore/89332e83-1a43-41fe-ba8d-2facdf317d05   


I apologize i forgot to mention that i'm using CMIS with javascript Thank you .

Upvotes: 0

Views: 3544

Answers (2)

Yagami Light
Yagami Light

Reputation: 1796

Simplly with CMIS there is two ways to get an object (File or Folder) :

Before getting the object you need to get your alfresco session, read this post : How to get Session in Alfresco using CMIS.

Getting an object by path

CmisObject object = session.getObjectByPath(pathObject);

Getting an object by ID

CmisObject object = session.getObject(idObject);

After getting the object you can cast it to File or Folder

You can also read this post to understand how to get document with query using a Folder ID How to get a document using Folder ID.

Hope that Helped you.

Upvotes: 0

sgirardin
sgirardin

Reputation: 448

When you have the ID you don't need to use a query you can get it directly from the session object.

Typically for Java you can do something like this :

CmisObject cmisObject = session.getObject(id);

if (cmisObject instanceof Document) {
    Document document = (Document) cmisObject;
} else if (cmisObject instanceof Folder) {
    Folder folder = (Folder) cmisDocument;
} 

Upvotes: 1

Related Questions