cancel
Showing results for 
Search instead for 
Did you mean: 

Read Content

ant_batt
Champ in-the-making
Champ in-the-making
Hi,

I want to read a content. My code works fine for one space but for another space don't work. Space that can't I read contains is

/app:company_home/cm:portal/cm:Game/cm:Content/cm:The_x0020_Example/*/cm:050109.html
or
/app:company_home/cm:portal/cm:Game/cm:Content/cm:The_x0020_Example/cm:2009/cm:050109.html

My code, that work fine with another space, is:


WebServiceFactory.setEndpointAddress(Alfresco.ENDPOINT);
AuthenticationUtils.startSession(AlfrescoConstants.USERNAME, AlfrescoConstants.PASSWORD);
Reference ref = new Reference(AlfrescoConstants.STORE, null, "/app:company_home/cm:portal/cm:Game/cm:Content/cm:The_x0020_Example/*/cm:050109.html");
ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
Content[] readResult = contentService.read(
        new Predicate(new Reference[]{ref}, AlfrescoConstants.STORE, null),
   Constants.PROP_CONTENT);

Thanks
1 REPLY 1

openpj
Elite Collaborator
Elite Collaborator
You have to encode all the space name using the helper class ISO9075.
For each space (and only for all the subspaces!) you have to append a string to create the related child name for the space as the following:
cm:spaceName
The spaceName value must be encoded using the encode method of the ISO9075 helper class:
org.alfresco.webservice.util.ISO9075
Try to use it in this way:

WebServiceFactory.setEndpointAddress(Alfresco.ENDPOINT);
AuthenticationUtils.startSession(AlfrescoConstants.USERNAME, AlfrescoConstants.PASSWORD);
Reference ref = new Reference(AlfrescoConstants.STORE, null, "/app:company_home/cm:"+ISO9075.encode(portal)+"/cm:"+ISO9075.encode(Game)+"/cm:"+ISO9075.encode(Content)+"/cm:"+ISO9075.encode(The_x0020_Example)+"/*/cm:050109.html");
ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
Content[] readResult = contentService.read(
        new Predicate(new Reference[]{ref}, AlfrescoConstants.STORE, null),
   Constants.PROP_CONTENT);
Hope this helps.