You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@chemistry.apache.org by Christopher Cheng <ch...@gmail.com> on 2011/07/31 12:12:43 UTC

getting title and description from document

Instead of using Alfresco API, using Chemistry seems to be a bit more
difficult to get "title" and "description" of the document

for (org.apache.chemistry.opencmis.commons.data.CmisExtensionElement e :
document.getExtensions(org.apache.chemistry.opencmis.commons.enums.ExtensionLevel.PROPERTIES))
{
            for
(org.apache.chemistry.opencmis.commons.data.CmisExtensionElement o :
e.getChildren()) {
                for
(org.apache.chemistry.opencmis.commons.data.CmisExtensionElement e2 :
o.getChildren()) {
                  if ("propertyString".equals(e2.getName())) {
                      if
(e2.getAttributes().get("propertyDefinitionId").equals("cm:title")) {
                            for
(org.apache.chemistry.opencmis.commons.data.CmisExtensionElement e3 :
e2.getChildren()) {
                                if ("value".equals(e3.getName())) {
                                    title = e3.getValue();
                                }
                            }
                        }
                  }
                }
            }
        }

Using Alfresco API, it seems that it's simpler

Node entry1 =
rootNode.getNode("app:company_home/wiki:encyclopedia/wiki:entry1");
String title = entry1.getProperty("cm:title").getString();

Can anybody suggest a less painful way to do this?

Re: getting title and description from document

Posted by Florian Müller <fl...@alfresco.com>.
Hi Christopher,

Use the Alfresco OpenCMIS Extension [1].


Florian


[1] http://apache-extras.org/p/alfresco-opencmis-extension


On 31/07/2011 11:12, Christopher Cheng wrote:
> Instead of using Alfresco API, using Chemistry seems to be a bit more
> difficult to get "title" and "description" of the document
> 
> for (org.apache.chemistry.opencmis.commons.data.CmisExtensionElement e :
> document.getExtensions(org.apache.chemistry.opencmis.commons.enums.ExtensionLevel.PROPERTIES))
> {
>             for
> (org.apache.chemistry.opencmis.commons.data.CmisExtensionElement o :
> e.getChildren()) {
>                 for
> (org.apache.chemistry.opencmis.commons.data.CmisExtensionElement e2 :
> o.getChildren()) {
>                   if ("propertyString".equals(e2.getName())) {
>                       if
> (e2.getAttributes().get("propertyDefinitionId").equals("cm:title")) {
>                             for
> (org.apache.chemistry.opencmis.commons.data.CmisExtensionElement e3 :
> e2.getChildren()) {
>                                 if ("value".equals(e3.getName())) {
>                                     title = e3.getValue();
>                                 }
>                             }
>                         }
>                   }
>                 }
>             }
>         }
> 
> Using Alfresco API, it seems that it's simpler
> 
> Node entry1 =
> rootNode.getNode("app:company_home/wiki:encyclopedia/wiki:entry1");
> String title = entry1.getProperty("cm:title").getString();
> 
> Can anybody suggest a less painful way to do this?
>