cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to query WCM content through web-script

meetkenepps
Champ in-the-making
Champ in-the-making
I have been reading about the WCM capabilities of Alfresco and the web scripts framework. One thing, that is not very clear to me so far is whether it is possible to query the content created using WCM webforms through web-scripts. I think that it should be; but I am not 100% sure.

Similar question: how do I distinguish between different kinds of WCM content. For e.g. I have one form for product data-sheet and one form for product reference. How do I fetch all the instances of product references or all the instances of product data-sheet using web script calls?

-Ken
2 REPLIES 2

pmonks
Star Contributor
Star Contributor
Your hunch is spot on - it is indeed possible to query WCM content (including both Web Form backed and "static" files) via Web Scripts.  For Javascript-backed Web Scripts, you can use the AVM JS API (http://wiki.alfresco.com/wiki/JavaScript_API#AVM_API), while for Java-backed Web Scripts you'd use the AVMService Java API (http://dev.alfresco.com/resource/docs/java/repository/org/alfresco/service/cmr/avm/AVMService.html).

As for querying for specific types, I can think of two ways to do that (this is off the top of my head - there may be more approaches as well):
  1. The first is to query for the "parentformname" attribute (a property which is automatically populated by the WCM system).  For example the Lucene query
    TEXT:"Alfresco" AND @\{http\://www.alfresco.org/model/wcmappmodel/1.0\}parentformname:'Product Data-Sheet"
    would search for all product data-sheets containing the word "Alfresco" somewhere in the full text.

  2. Use XML Metadata Extraction (http://wiki.alfresco.com/wiki/Metadata_Extraction#XML_Meta-data_Extractor_Configuration_for_WCM) to index a custom property with the name of the type.
Although it's more work, the second approach supports more complex use cases, such as the case where you want to treat multiple different Web Form types as if they were a single type at querying time (of course you could also use approach #1 with a set of "ORs", but that likely won't perform as well a single query clause against a custom property).

Cheers,
Peter

meetkenepps
Champ in-the-making
Champ in-the-making
Thanks Peter, this is real good start for me.

-Ken
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.