cancel
Showing results for 
Search instead for 
Did you mean: 

Custom metadata for WCM Content

himanshu
Champ in-the-making
Champ in-the-making
Hi,

How to add custom metadata fields to the content stored in WCM repository?

I have articles in my web project stored as xml files. In a use case, I want to pick the most emailed article. So I want to add the emailCount as a metadata field for article which can be read and edited without editing the xml file.
How can i do this??

I have already read a few articles on Metadata extraction but was not able to get it working.

Thanks in advance.

Regards

Himanshu
4 REPLIES 4

jbarmash
Champ in-the-making
Champ in-the-making
You'd probably have to add an aspect to the content you want to tag this, and expose it through web-client-config.xml. 

Unfortunately, there is no way to add the aspect from the UI, so you'd have to add it programatically - through javascript script or webscript.

himanshu
Champ in-the-making
Champ in-the-making
Hi jbarmash,

Unfortunately, there is no way to add the aspect from the UI, so you'd have to add it programatically - through javascript script or webscript.

So I can add the aspect programmatically. I am already using Java-backed Web-Scripts to read and write content to the alfresco WCM repository.
How can I tag the aspect to the content by using Java backed Web-Script??
Any specific service i can get from the ServiceRegistry bean??

Thanks for the help.

Regards

Himanshu

pmonks
Star Contributor
Star Contributor
AVMService.addAspect (http://dev.alfresco.com/resource/docs/java/repository/org/alfresco/service/cmr/avm/AVMService.html#a...) or NodeService.addAspect (http://dev.alfresco.com/resource/docs/java/repository/org/alfresco/service/cmr/repository/NodeServic...) will do the job.

Be aware that aspects don't get deployed to the filesystem (many filesystems don't support arbitrary metadata for files), so if you need this metadata in your delivery application and are using FSR deployment I'd suggest using XML content modelling rather than aspects.  This is a large part of the reason that Alfresco WCM doesn't provide UI support for aspects - in practice they can't be used for much beyond authoring-side metadata.

Cheers,
Peter

kmehta31
Champ in-the-making
Champ in-the-making
Hi all,

I have one question/issue related to this which I am trying to figure out since a long time. We have content model define through xsd schemas and all our content is getting created through web forms. For each web form we have corresponding entries in wcm-xml-metadata-extracter-context.xml.
Now when we update and modify the content the values are getting indexed (extracted) properly and we are able to verify through Node Browser.
Even the Lucene Queries are working fine only issue we are facing is in sorting the data.

The issue we are facing are in the webscripts while sorting the data.
e.g.
                                SearchParameters sp = new SearchParameters();
      sp.addStore(getStoreReference());
      sp.setLanguage(SearchService.LANGUAGE_LUCENE);
      StringBuffer strBfrQuery = new StringBuffer();
      strBfrQuery.append(WebscriptConstants.divisionQuery); //Query is working fine no issue. getting proper result set
      String strQname = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "title").toString();
      sp.setQuery(strBfrQuery.toString());
                                sp.addSort(strQname, false);

The sorting is not working for any fields in webforms. We tried many options but couldnt get the right results. Do we have to do any extra step other than setting up wcm-xml-metadata-extracter-context.xml for sorting.
Peter: It would be great help if you can help us out here and provide more guidence.

Looking forward for your reply.

Thanks

Kalpesh Mehta