Automating useful tasks within a CMIS repository

I started a project a while back to curb some of the less-efficient tasks for my Alfresco-based CMS.  My main target: eliminate the painfully slow file check-in process.  My goal: create a per-user bulk check-in method.

If you’re curious about how far you can get with some fairly basic scripting gusto, a good place to start is with the Apache Chemistry project.  Their mission is to provide a more general-purpose API to any CMIS-compliant repository (Alfresco, Nuxeo, KnowledgeTree, MS SharePoint, and EMC Documentum to name a few).  They have already developed fairly robust APIs for Java, PHP, Python, .NET, but I’m sure they’d appreciate further contributions from the community (or maybe even repo testing, hint hint).  Thanks to Jeff Potts for that.

I think Python is a good language for newbie experimentation, so I suggest the cmislib API to get warmed up.  I like this library for several reasons.  First, it’s Python so it’s a simple install.  If you’ve ever used easy_install, then you’re most of the way there.  Second, the API allows you to both access (search and check-out) and manipulate (edit and check-in) your content.  And third, you can make database queries, so searching the repo returns immediate results.

Installation:

1)      Install Python.  I’ve tested it with Python 2.7.
2)      Install setuptools.
3)      Install the cmislib library.

Check out more complete installation directions here.  Otherwise, that’s it.

Here’s a quick script I wrote to perform a bulk check-in (based on the user) to my Alfresco repository.   You’ll need to substitute your CMIS client address, but you will be prompted for your logon credentials.

from cmislib.model import CmisClient
import sys

usr = raw_input("Enter username: ")
pwd = raw_input("Enter password: ")

comment = raw_input("\nEnter comment for bulk check-in: ")

try:
    client = CmisClient('[***SUB YOUR CLIENT ADDRESS HERE]', usr, pwd)

except:
    print "Problem connecting to repository"
    raw_input('\n\nPress Enter to exit...')
    sys.exit()

repo = client.defaultRepository

for doc in repo.getCheckedOutDocs().getResults():
    owner = doc.getCheckedOutBy()
    if owner == usr:
        try:
            doc.checkin(checkinComment=comment)
            print "[CHECKED-IN]", doc.getTitle()
        except:
            print "Failed to check-in",doc.getTitle()
            continue

raw_input('\n\nPress Enter to exit...')

6 thoughts on “Automating useful tasks within a CMIS repository

    • Don,

      The PHP API sub-project of Apache Chemistry has been around a while. It is maintained by Richard McKnight, an Alfresco employee. The Drupal CMIS module wraps the Apache Chemistry PHP API. I know a lot of people are using the Drupal CMIS module.

      Although the PHP API has been part of Chemistry for a while, it has yet to go through a formal release. That’s a reflection of Richard’s bandwidth and not necessarily on the stability of the API.

      With all of that said, I’m not a PHP guy and don’t have detailed first-hand knowledge of that API so I can’t give you a very specific answer beyond what I’ve provided.

      If you do try out the PHP API and you find issues or you’d like to make enhancements, I’m sure Richard would appreciate any contribution you can provide.

      Jeff

      • Thanks for the background, Jeff. I’m also looking into the PDO database abstraction layer, but I’m not anywhere near making a technical choice yet. I hadn’t known about this CMIS option before–it’s good to have choices!

        I’m also keen on the potential uses of NoSQL libraries like CouchDB, MongoDB, and eXist-db as they pertain to DITA content. CouchDB in particular seems to have a ready-to-integrate RESTful API, although its Erlang environment becomes one more install dependency to manage.

        • well written. I agree that extnseions or modules are a big benefit but they could be a big problem as well. You have mentioned security. apart from that issues related to quality of modules and upgrades are also a big pain.best,

    • I greatly enyeojd your presentation on integrating Drupal and Alfresco with the CMIS module. It helped me set up my test server so I can see the Alfresco repository through Drupal but I cannot seem to make the sync work. Would you mind a few questions about that? Thanks.Bill Brantley

Leave a Reply to Don Day Cancel reply

Your email address will not be published. Required fields are marked *


*