Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Alfresco CMIS
Alfresco CMIS

Alfresco CMIS: Learn how to build applications that talk to content management servers in a standardized way using this superb course on getting the best from Alfresco CMIS. This is a highly practical, step-by-step guide.

eBook
€14.99 €21.99
Paperback
€26.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Alfresco CMIS

Chapter 2. Basic CMIS Operations

In this chapter, we will dig into the CMIS API and test it by calling a CMIS server directly via HTTP, and it will respond in XML or JSON depending on whether we are using the AtomPub binding or the Browser binding. We will try out most of the common operations that would be normal to perform against a CMS system such as follows:

  • Authenticating and connecting to the server

  • Fetching repository information including repository ID and root-folder URL

  • Listing the content of a folder

  • Listing the content types that are available

  • Reading content metadata and downloading content

  • Creating, updating, and deleting folders and files

This chapter is particularly useful for those who cannot, for some reason, use a third-party library that abstracts the inner workings of the CMIS interface. So if you cannot use any of the libraries from the Apache Chemistry project, this chapter will be helpful as it will tell you how to interact with any CMIS-compliant server using only HTTP...

Setting up a CMIS server


Before we start, we are going to need a CMIS server to talk to. There are a number of ways to get access to a CMIS server. You can, for example, install your own or use one that is available on the Internet. Actually, it is best to install your own so that you can have some control over it and you have the confidence that there are not loads of other users doing stuff at the same time as you.

We will focus on the Alfresco content management server in this book, but all the exercises should work with any other CMIS-compliant server too. However, if you use another CMIS server, remember that it will have a different entry point URL than Alfresco's (different from, for example, http://localhost:8080/alfresco/cmisatom).

Installing your own CMIS server

This book is about Alfresco and CMIS, so we will use the Alfresco CMS server when working with CMIS. The quickest way to get going with your own Alfresco installation is to download the full installation file of the Community...

Setting up a tool to make HTTP requests


So we now have an Alfresco CMIS server that we can talk to. Next, we need a tool that can be used to make HTTP requests to the server. We are going to test the AtomPub and Browser CMIS bindings, which are based on the HTTP protocol and the back and forth sending of XML and JSON.

One really good tool that can be used for this is cURL; it is available for most platforms. On my Ubuntu laptop, I can just use the #sudo apt-get install curl command to install it. On Windows, you can download cURL from http://curl.haxx.se/download.html. If you are on a Mac, then Apple has a different version of cURL as part of the developer tools; it's also available through Homebrew using brew install curl.

Later on, in this chapter, we will also look at using the Chrome browser to view XML and JSON responses and some other command-line tools to parse and display XML and JSON.

Authenticating with the repository


When using the AtomPub binding or the Browser binding, authentication is delegated to the transport protocol, which is HTTP. All CMIS-compliant servers must, at the very least, support client authentication using the HTTP Basic authentication schema. We will use this in the following examples. If the server is Alfresco, the alternative is to use the Alfresco login service. As this is not supported by other servers, we will stick to the HTTP Basic authentication, which is portable.

The curl tool can handle Basic Auth for us automatically; we just have to pass the username and password, as follows, with the -u switch when we use curl:

$ curl -u admin:admin

If you are going to work only with Alfresco, you can log in and get a ticket that you can use in subsequent calls as follows:

$ curl "http://localhost:8080/alfresco/service/api/login?u=admin&pw=admin"
<?xml version="1.0" encoding="UTF-8"?>
<ticket>TICKET_39ea5e46e83a6d6e43845182f4254f9de50402fb...

Getting repository information


To execute any other operation against a CMIS repository, we first need to find out its identifier, access points, and capabilities. The identifier is used when we want to connect and get a session to work within. It is also important to know the capabilities of a CMIS server, as not all requirements in the CMIS specification are mandatory, and the capabilities tell us what the repository supports and what it doesn't. The access points tell us how to, for example, get access to the top-level folders in the repository. All this information is accessible via the getRepositoryInfo service call.

Before we look at how to get repository information when using the AtomPub or the Browser binding, we will walk through the different properties that we will encounter and explain them. They are the same for all bindings, so it makes sense to describe them before looking at protocol-specific stuff.

The repository ID, identified by the repositoryId property, is usually needed...

Listing the children of the root folder


After we have the information about the repository via the getRepositoryInfos service, we would typically want to access some folders and files in it. First, you would usually access the children of the top-level folder (also called root folder) in the repository, and this can be done via the getChildren service. This folder is called /Company Home in the Alfresco world.

The getChildren request returns a list of all the folders and files contained in a particular folder. This call has to be supported by the repository, but there are other navigation-related service calls too that might or might not be supported. The getDescendants call will return all the children of a folder to a specified depth. The getFolderTree call will return a complete folder tree to a specified depth (note that only folder objects are returned).

The repository information's call will return information on the navigation service calls that are supported besides the getChildren...

Optional parameters when listing the children of a folder


The getChildren service call allows us to specify a number of optional parameters at request time. To control the number of content items that are being returned, one can use the following parameters in the request URL:

  • maxItems: This is the maximum number of items to return in a response. The default is repository-specific and Alfresco will, for example, return all content items if you do not specify this parameter.

  • skipCount: This is the number of potential results that the repository will skip/page over before returning any results. This defaults to zero.

These paging input parameters work in parallel with the following output parameters in the response:

  • hasMoreItems: This parameter will be true if the repository contains additional items after those contained in the response, otherwise it will be false. If true, a request with a larger skipCount or larger maxItems will return additional results (unless the contents of the repository...

Listing available types and subtypes


When we are working with a repository, it is important to be able to find out what types are available so that we can classify documents and folders properly. One of the first things to do in a CMS project is to design a domain-specific content model so that content can be classified appropriately. A proper content model improves the search capabilities and enables specific behavior to be implemented based on the type of content.

The getTypeChildren service is used for listing types. This service call can also use the paging parameters that the getChildren service call uses, such as maxItems. The type listing will contain a type definition with information about each type. From the type definition, we can determine whether new objects can be created from this type (cmis:creatable), objects of this type are fileable (cmis:fileable) in a folder, you can search for the objects of this type by including the type in the FROM clause (cmis:queryable), and whether...

Getting metadata and content


We now know how to list the contents of a folder. What we would want to do next is to probably download content files and list metadata (that is, properties) for individual content items.

Getting metadata and content with the AtomPub binding

If we take a closer look at the end of the AtomPub service document (that is, the response from http://localhost:8080/alfresco/cmisatom), we will find sections with URI templates; one for getting metadata by ID, which is listed as follows:

<cmisra:uritemplate>
<cmisra:template>
http://localhost:8080/alfresco/cmisatom/f0ebcfb4-ca9f-4991-bda8-9465f4f11527/id?id={id}&filter={filter}&includeAllowableActions={includeAllowableActions}&includeACL={includeACL}&includePolicyIds={includePolicyIds}&includeRelationships={includeRelationships}&renditionFilter={renditionFilter}
</cmisra:template>
<cmisra:type>objectbyid</cmisra:type>
<cmisra:mediatype>application/atom+xml;type=entry...

Creating, updating, and deleting content


After you have listed content (that is, CMIS objects) in the repository, you would probably want to be able to create, update, and delete content. This is handled via the CMIS object services.

The following table gives you an overview of the available object service calls that are related to creating the content of different types:

Service call name

Short description

Long description

createDocument

Creates a document

Creates a document object of the specified type (given by the cmis:objectTypeId property) in the (optionally) specified location.

createDocumentFromSource

Copies a document

Creates a document object as a copy of the given source document in the (optionally) specified location.

createFolder

Creates a folder

Creates a folder object of the specified type in the specified location.

createRelationship

Creates a relationship

Creates a relationship object of the specified type.

createPolicy

Creates a policy

Creates...

Summary


In this chapter, we have gone through most of the basic functionalities that are likely to be used on a day-to-day basis and learned how to use them with both the AtomPub protocol and the Browser binding protocol. We have seen how we can list the contents of a folder and navigate to the subfolders. The Browser binding has shown us that it is quite easy to work with CMIS via this binding as you can use HTML forms for almost all operations and it is easy to integrate with the UI this way.

In this chapter, we also looked into how to download the content types that the repository supports, which is important as you are likely to set custom types when uploading new content. We also covered how to create, read, update, and delete documents and folders for a specific domain. And finally, we went through how to download a document.

In the next chapter, we will look into more features supported by CMIS such as version management, access control, and searching for content.

Left arrow icon Right arrow icon

What you will learn

  • Add, update, delete, and search for content with increasing efficiency using HTTP and XML/JSON, OpenCMIS , JavaScript, and Groovy
  • Feed content directly into a JavaScript widget from a CMIS call JSON response, so you can see how content management servers can be accessed directly via AJAX calls from a web application
  • Integrate Drupal with a content management server via CMIS, so Drupal does not have to store documents and images
  • Integrate multiple content management systems in a standard way via an enterprise service bus and a CMIS connector
  • Handle advanced concepts such as versioning, permissions, and relationships between content items
  • Talk to the Alfresco Cloud service via CMIS, so you can make content available outside the company firewall

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Mar 25, 2014
Length: 272 pages
Edition :
Language : English
ISBN-13 : 9781782163527
Vendor :
Alfresco
Languages :
Concepts :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Mar 25, 2014
Length: 272 pages
Edition :
Language : English
ISBN-13 : 9781782163527
Vendor :
Alfresco
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 101.97
Alfresco CMIS
€26.99
Alfresco 4 Enterprise Content Management Implementation
€49.99
Learning Alfresco Web Scripts
€24.99
Total 101.97 Stars icon

Table of Contents

7 Chapters
Getting Started with CMIS Chevron down icon Chevron up icon
Basic CMIS Operations Chevron down icon Chevron up icon
Advanced CMIS Operations Chevron down icon Chevron up icon
Alfresco and CMIS Chevron down icon Chevron up icon
Accessing a CMIS Server with a Java Client Chevron down icon Chevron up icon
Accessing a CMIS Server Using Scripting Languages Chevron down icon Chevron up icon
System Integration with CMIS Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.8
(6 Ratings)
5 star 83.3%
4 star 16.7%
3 star 0%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Johnny Gee Jun 06, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I have read and reviewed many Alfresco books over the years, but I must say that Martin Bergljung has done a terrific job of making a technical book easy to read. "Alfresco CMIS" is simple and easy to understand. He minimize the amount of technical jargon and if there were some concepts he felt that the reader may not know, he explained them clearly and effortlessly.He does a great job giving the history of CMIS and he does even a better job of describing the various CMIS operations in detail and in plain English. He even talks about how to install CMIS server so that the reader has opportunity to play with CMIS sample code he provides. My only wish is that the author would have talked about the CMIS operations in the context of business problem. The best technical books I have read are the ones that relate technical information to business case.I would recommend this book to anyone who is looking to write a custom app using CMIS against Alfresco repository.
Amazon Verified review Amazon
AHASH Jul 19, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is an excellent resource for anyone wanting to know more about CMIS (Content Management Interoperability Services). It starts out with a good introduction to the CMIS standard including the service, basic and advanced CMIS operations, and the object model. Examples include version management, security, search, and relationship management. The book illustrates various integration patterns via different uses cases. It then goes on to discuss the CMIS implementation in Alfresco (open source content management system).The book discusses various methods for accessing a CMIS server including use of a Java client as well as using using scripting languages such as Groovy. The examples and code snippets provided are very valuable for someone who wants to try out the various examples on their own. A thorough explanation of the code included in the book is also provided.The book concludes with an explanation of how to integrate other systems/applications using CMIS. The examples include integration with Drupal.CMIS is an open standard for integrating content management systems and is gaining popularity. This book provides excellent coverage on the topic with a focus on Alfresco.
Amazon Verified review Amazon
Sam Jun 01, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
As an Enterprise Architect, I work with ECM systems, Documentum, Alfresco, Sharepoint etc. Alfresco is incredibly powerful and has such a low cost comparing to other options, it has enabled me to build full fledged application suite with very short periods of time. Many organizations still have Documentum, but Alfresco can take to many other ECM systems using CMIS protocol. The resulting federated ECM system is a comprehensive solution to document management, collaboration and integration.If you are using Alfresco and need CMIS integration, stop reading the review and just buy it !I have bought >10 Alfresco books that this is among the two books that I would recommend.Enterprise ArchitectSam Wu, SAMSSOFT
Amazon Verified review Amazon
Jorge Jun 03, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is a great book if you need to code an integration with a CMIS server such as Alfresco. Specifically, if you don't want to use a third-party API wrapper, this book will give you the details on how to implement it yourself. Or, if you want to understand what's going on under the hood of your third-party API wrapper.One area where this book could be improved is explaining error cases. For example, if I upload a file to CMIS, what errors should I expect? What if the file already exists? What if my filename is invalid? What other things can go wrong? Without this information, I am left to try all the cases myself to see what happens.
Amazon Verified review Amazon
Romin K. Irani May 14, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The number of solutions being built on top of Content Management Systems is plenty and across implementations, you wish that there was a common API that you could access all the CMS. CMIS is the common API via which you can access any Content Management System that supports this standard.The book starts off with an overview of CMIS and how it came about. The next set of chapters goes into the CMIS Standard, especially the different operations via which you can do create, update, delete and query for documents. These two chapters setup a solid foundation since they allowed you to understand what is happening behind the scenes in terms of the REST Calls and the data formats being exchanged in the request / response.I preferred this approach rather than jumping into a high level API that does not allow the developer to understand some of the details behind the calls. The next chapter jumps into specific support for CMIS via Alfresco.Once this is covered, you get to pick the languages via which you want to access the CMIS API. One chapter covers the Java API in case you are talking to the CMS via a Server side infrastructure or are planning to create your own service layer on top of it. In case you are looking for accessing CMIS via the Web interface, a chapter on invoking the CMIS Interface via JavaScript is also covered.The final couple of chapters delve deeper into integration scenarios with the Drupal Web Content Management (WCM) and Mule ESB Integration.Overall the book is a solid guide to the CMIS Standard via Alfresco. In case you are planning on integrating with any CMIS capable repository, keep this book handy.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.