New developerWorks article on cmislib

If you would like to learn more about cmislib, an open source CMIS client API for Python that works with any CMIS-compliant repository such as Alfresco, FileNet, Nuxeo, OpenText, and others, check out my new developerWorks article.

This is part one in a two-part series. In the second part, which will be published soon, Jay Brown from IBM talks about how he used cmislib to create an xcopy-like utility that copies images from a file system into any CMIS repository. As it does the copy, it inspects the image’s EXIF tags and if the target document type has corresponding properties, it populates those properties with the image metadata.

3 comments

  1. Nate says:

    Jeff, I know that this is not the forum for this but with Alfresco, there isnt enough examples no matter how many hours spent. I have two question 1) How do you use REST to authenticate? I can use the URI such as
    http://localhost:8080/alfresco/service/api/login?u=admin&pw=admin
    to get a ticket back via the url but that is all I can do because I cannot get authenticated. What would the code look like.
    2) How would I use the following to retrieve a document? Do yo have any example? There is just so much that is not answered about this product. Could you please point me in the right direction? Thanks

    http://:8080/alfresco/service/api/node/content/workspace/spacesstore/?a=false

  2. jpotts says:

    Nate,

    If you get a ticket back, you are authenticated. Once you get the ticket, you pass it in the alf_ticket argument on every request. When you pass it as an argument, it looks like this:

    http://localhost:8080/alfresco/s/somewebscript?alf_ticket=TICKET_44740de7943f7bab5be61f787c62660ff3008299

    An alternative is to use basic authentication. If you want to use basic authentication, exactly how you do that depends on the tool/language you’re using. For example, in Python, the code looks something like this:
    # create a password manager
    passwordManager = HTTPPasswordMgrWithDefaultRealm()
    passwordManager.add_password(None, url, username, password)

    opener = build_opener(SmartRedirectHandler(),
    DefaultErrorHandler(),
    HTTPBasicAuthHandler(passwordManager))

    Regarding your second question, I don’t know what that “a” argument is, but let’s assume you’ve got a node reference to an object. You could construct a URL that looks like this:

    /alfresco/s/api/node/content/workspace/spacesstore/a410c988-6b21-4875-83db-d03ce03661d7

    And that would retrieve the object. If the object is plain text, you’ll get the plain text back. If it is a binary, you’ll get the binary object. In the case of cmislib, you can look at getContentStream to see an example of how it retrieves objects via CMIS and writes them out to the file system.

    Jeff

Comments are closed.