cancel
Showing results for 
Search instead for 
Did you mean: 

how do i get target prop_content by using queryAssociated?

tomcheng76
Champ in-the-making
Champ in-the-making
Suppose i have the parent Reference, and the associate type, then i can find the "target".
But i can only get a NamedValue which is a string, i am not sure if there is a problem if the content is not plain text.
Can i get the image content by casting it to byte? Or should i get the uuid and use contentService to read the content again (is this slow since it needs two queries ??)?

       Association association = new Association(assocType, "target") ;
       ResultSetRow[] imageRows = repositoryService.queryAssociated(parent, association).getResultSet().getRows();
        // by using getColumns() and search for Constants.PROP_CONTENT, i can get the content in NamedValue format

Hopefully my question is understandable..Smiley Happy
1 REPLY 1

tomcheng76
Champ in-the-making
Champ in-the-making
okay, end up with this, not sure the performance though

QueryResult queryResult = MyCollection.getAssociatedChild(currentRef, ICMConstants.ASSOC_IMAGES);
ResultSetRow[] imageRows = queryResult.getResultSet().getRows();
for (ResultSetRow imageRow : imageRows) {
ResultSetRowNode imageNode = imageRow.getNode();
String imageNodeId = imageNode.getId();
              
Reference imageRef = new Reference(dsICM.getStore(), imageNodeId, null);
Predicate imagePredicate = new Predicate(new Reference[]{imageRef}, dsICM.getStore(), null);
Content[] readResult = dsICM.getContentService().read(imagePredicate, ICMConstants.PROP_CONTENT);
Content imageContent = readResult[0];
InputStream imageIn = ContentUtils.getContentAsInputStream(imageContent);
byte[] content = IOUtils.toByteArray(imageIn);
}

reference: https://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/web-service-client/s...

reading testcase is much better than sdk example, they are more solid 🙂
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.