cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve content model of a document?

harikakosaraju
Champ in-the-making
Champ in-the-making
Hello,
I am using java. I need to retrieve the content model of a document. Alfresco version is 5.0.2. Any suggestions?
5 REPLIES 5

steven_okennedy
Star Contributor
Star Contributor
Hi

When you say you need to retrieve the content model, do you mean that you need to find out what the content type is?  Or is it a list of the properties that have been set?

Also, where are you running your code, is it an external Java application that is connecting the Alfresco platform or is it custom code that is running within Alfresco e.g. an action or behaviour?  The APIs & options that you would use are different in each case

Regards

Steven

I need to find out the name of the content model that was applied to the document.
This is the custom code that will be running within alfresco application. I am writing this code in an action.

I did not quite understand the usecase here. Could you please elaborate more on the usecase you are trying to address. Why do you require to know the name of the content model? How it will help. If you just need to find the content type of the node, you can easily do it through NodeService API. Take a look at ScriptNode which has getType() and getShortType() implementations available.

steven_okennedy
Star Contributor
Star Contributor
Hi

In that case, just use nodeService.getType(NodeRef nodeRef) (http://dev.alfresco.com/resource/docs/java/org/alfresco/service/cmr/repository/NodeService.html#getT...)

This returns a QName representing the type of the document.

Regards

Steven

harikakosaraju
Champ in-the-making
Champ in-the-making
Used nodeService. Thanks both of you.