You are here

Using CMIS query in Content Query navigation model

One of the new features in WebCenter PS3 is the new navigation model. It allows you build dynamic models . You can add all kinds of resources in the navigation model like external links, pages from your portal, taskflows, portals, content from a content server and so on.

When your portal is content driven, you definitly want the ability to add links to different items based upon some criteria instead of adding all the content manually. This can be achieved by adding a content query to your navigation model. A content query is based upon the CMIS standard. CMIS stands for Content Management Interoperability Services which is a standard for improving the interoperability between different content management servers. For example Alfresco, IBM, Microsoft, SAP,... support this standard.

CMIS has its own query language which looks a lot like the SQL language used in databases. At first sight a CMIS query can look somewhat difficult.

Before you can add a content query, you first need to create a connection to the content query. In JDeveloper right click the connections and select Content Repository from the New context menu.

Select Oracle content Server for the repository type and fill in the correct parameters for your server:

Before explaining the content query in detail we will first add it to a navigation model. Make sure you have created a WebCenter Portal application. Open the default-navigation-model.xml from the oracle/webcenter/portalapp/navigations folder.

Select the default-navigation-model node and press the add button.

Select the Content Query.

In the Repository field you need to select the content repository. Press the browse button so you can easily select the correct connection:

Specify a title which will be the root node for your query. The results in the query will be shown as children of this node.

Now we can start explaining the query...

I will give a few examples of queries and explain them in detail:

Show all content in a specific folder

If you want to add all the items from a specific folder you need to use following query:

SELECT * FROM cmis:document WHERE IN_TREE('/ucm/IDC:Folder/988901828852000401')

This query will return all the items from the folder with the specified ID. I still don't know if there is a query so we can use the path instead of the folder id. This query is not that good because when you migrate from a development environment to test or production environment, you have to make sure the ID's of the folders don0t change or the query will not work. A disadvantage of the CMIS query field is that you cannot use expression language to build dynamic queries...

Show all content with a specific term in the name

If you for example want to create a Jobs node in your portal and you want to include all the documents that has Job in its name than you would use following query:

SELECT * FROM cmis:document WHERE cmis:name LIKE 'Job%'

Using any metadata field in the query

You can use any metadata field in your query. Suppose you have create a custom metadata field that contains a productID and you want to show all the documents for that product:

SELECT * FROM ora:t:IDC:GlobalProfile WHERE ora:p:xProuctID = 15

Again... Because you can't use expression language the ProductID needs to be hardcoded and is not dynamic...

Also notice that that the query is case sensitive so if you have defined the ProductID field in your UCM as productId than you need to use xproductId instead of xProductID.

List of common properties of the cmis:document object

  • cmis:createdBy is the name of the author which maps to dDocAuthor
  • cmis:lastModifiedBy is the name of the user who made the last modification to the document. This field is mapped to dDocCreator.
  • cmis:creationDate is the creation date which maps to the dCreateDate field
  • cmis:lastModificationdate maps to dLastModifiedDate
  • cmis:name maps to the name. dOriginalName when used in cmis:document ad dCollectionName when used in cmis:folder
  • cmis:contentStreamMimeType contains the mime type which maps to dFormat
  • cmis:objectId contains the id of the document which maps to dDocName
  • cmis:objectTypeId contains the name of the UCM profile.
Category: 

Comments

Another informative post....Thanks...

1) I have the following structure in UCM. Basically i want to get all the content or files present in a Latest News directory.

Contribution Folders > LatestNews. The collection id of LatestNews (540502833803000401).

When i use the cmis query : SELECT * FROM cmis:document WHERE IN_TREE('/Contribution Folders/IDC:Folder/540502833803000401'), i get the following error.

Caused by: oracle.webcenter.content.integration.cmis.query.ParseException: 10-May-2011 17:57:33 oracle.webcenter.content.integration.cmis.query.VcrExpressionSearchDelegate getFolder
SEVERE: Argument is not a Folder: /Contribution Folders/IDC:Folder/540502833803000401.
[10-May-2011 17:57:33 oracle.webcenter.content.integration.federated.internal.delegate.RepositoryHelper checkCapability
SEVERE: Error finding repository: LatestNews.
]
at oracle.webcenter.content.integration.cmis.query.VcrExpressionSearchDelegate.getFolder(VcrExpressionSearchDelegate.java:940)
at oracle.webcenter.content.integration.cmis.query.VcrExpressionSearchDelegate.inTree(VcrExpressionSearchDelegate.java:969)
at oracle.webcenter.content.integration.cmis.query.VcrExpressionSearchDelegate.inTree(VcrExpressionSearchDelegate.java:58)

I have played around with that query by replacing Contribution Folders with different names and different path. But same error persists. As a temporary fix, i have added the tags to all the files present in LatestNews directory and querying with the following pattern.

SELECT cmis:objectId FROM ora:t:IDC:GlobalProfile WHERE ora:p:xWCTags LIKE 'LatestNews%'

2) Is there any way to execute CMIS query from a java bean ? If so can you please share the snippet, i am thinking of executing that cmis query dynamically by passing the folder collectionid or document collectionid through taskflow parameter. In that way, i can avoid navigation model.

Thanks for your time in responding to the queries.

Regards
Prasath.C

The first part in the WHERE_IN_TREE is the name of the connection so if your connection ucm is called connectionToUcm the query should be:
SELECT * FROM cmis:document WHERE IN_TREE('/connectionToUcm/IDC:Folder/540502833803000401');

Thanks Yannick. At some stage i tried with the connection name too 'ucm/IDC:Folder:/' (UCM- ucm connection name in my case), but didnot realize it that would be a case sensitive one.

Any way to execute the CMIS query programmatically ?

That would not be easy... I discussed this issue during the training with Peter. It would be great if the CMIS query from the navigation model would accept expression language so we can dynamicly build the query but this is not possible...

Any solution to create a query that is portable between environments (i.e. not relying on IDs)?

The problem is that you can't use expression language in the CMIS query in a navigation model. You can use EL in a query in the content presenter but when it comes to the navigation model, it isn't as flexible as it should be...

You could use to try other metadata instead of the path. One way of doing it is by assigning an account for each folder representing the folder so you can write your query based upon the dAccount.

How can I get some of the custom metadata.

Custom metadata in the where clause or what exactly are you talking about? Can you be a little more specific about the usecase?

Hi,

Suppose I have a folder in UCM. I have some dummy contents inside that folder.
I want to use these content to build the navigation model.

In each content, there is a metadata called targetPath. This stores the path to which this points. Now can I get "xtargetPath" value using CMIS in the navigation model.

To be honest I don't exactly know.
The navigation model is an abstraction for the elements. It only has a few basic attributes like title and so on but I don't see any way of accessing custom attributes specific to the type of node.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer