Return-Path: X-Original-To: apmail-chemistry-dev-archive@www.apache.org Delivered-To: apmail-chemistry-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 44BDB17FBB for ; Tue, 30 Sep 2014 10:48:34 +0000 (UTC) Received: (qmail 92081 invoked by uid 500); 30 Sep 2014 10:48:34 -0000 Delivered-To: apmail-chemistry-dev-archive@chemistry.apache.org Received: (qmail 92026 invoked by uid 500); 30 Sep 2014 10:48:34 -0000 Mailing-List: contact dev-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list dev@chemistry.apache.org Received: (qmail 91770 invoked by uid 99); 30 Sep 2014 10:48:34 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Sep 2014 10:48:33 +0000 Date: Tue, 30 Sep 2014 10:48:33 +0000 (UTC) From: "Pascal Oblonczek (JIRA)" To: dev@chemistry.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (CMIS-849) Rendition.GetContentstream always returns null for QueryResults MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CMIS-849?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14153056#comment-14153056 ] Pascal Oblonczek edited comment on CMIS-849 at 9/30/14 10:48 AM: ----------------------------------------------------------------- A small helper for those, who try to work around with current DotCMIS-0.6 Version: {code} public Image GetThumbnail(ISession session, IQueryResult result) { if (result.Renditions.Count == 0) return null; var rendition = result.Renditions[0]; if (rendition == null) return null; if (rendition.Kind != "cmis:thumbnail") return null; var objectId = session.CreateObjectId(result.GetPropertyById("cmis:objectId").FirstValue as string); var contentStream = session.GetContentStream(objectId, rendition.StreamId, null, null); if (contentStream == null) return null; using (var stream = contentStream.Stream) return Image.FromStream(stream); } {code} was (Author: pco): A small helper for those, who try to work around with current DotCMIS-0.6 Version: public Image GetThumbnail(ISession session, IQueryResult result) { if (result.Renditions.Count == 0) return null; var rendition = result.Renditions[0]; if (rendition == null) return null; if (rendition.Kind != "cmis:thumbnail") return null; var objectId = session.CreateObjectId(result.GetPropertyById("cmis:objectId").FirstValue as string); var contentStream = session.GetContentStream(objectId, rendition.StreamId, null, null); if (contentStream == null) return null; using (var stream = contentStream.Stream) return Image.FromStream(stream); } > Rendition.GetContentstream always returns null for QueryResults > --------------------------------------------------------------- > > Key: CMIS-849 > URL: https://issues.apache.org/jira/browse/CMIS-849 > Project: Chemistry > Issue Type: Improvement > Components: dotcmis > Affects Versions: DotCMIS 0.6 > Environment: DotCMIS 0.6 on .NET 3.5 / Windows 7 x64 > Alfresco 5.0.a on Ubuntu 12.0.4 LTS > Reporter: Pascal Oblonczek > Priority: Minor > Attachments: client-objects.diff > > > How to reproduce: > var ctx = session.CreateOperationContext(); > ctx.RenditionFilterString = "cmis:thumbnail"; > // Assumption: the returned document has a thumbnail rendition, edit query to match situation > var result = session.Query("select * from cmis:document", false, ctx).getPage(1).FirstOrDefault(); > var contentStream = result.Renditions[0].GetContentStream() > Expected: contentStream is an instance of a class that implements IContentStream > Found: null > ---- > Details: > The implementation of DotCMIS.Client.Impl.QueryResult.QueryResult constructor creates all renditions with an id set to "null". This has probably been done because cmis:objectId might not have been selected by the query: > [code file=client-object.cs:1581] > Renditions.Add(of.ConvertRendition(null, rd)); > [/code] > Looking at the implementation of DotCMIS.Client.Impl.Rendition.GetContentStream() we can see, that a null ID always leads to a null content stream. Thus, a query result will never by able to get the content stream of the rendition: > [code file=client-object.cs:1513] > public IContentStream GetContentStream() > { > if (objectId == null || StreamId == null) > { > return null; > } > [/code] > Instead you will have to call session.getContentStream and select and input values appropriately by hand, which I find is not very comfortable. > I attached a patch that makes this work. Anyway this means, that the "query author" needs to remember, that cmis:objectId must be selected by the query, otherwise he still gets null - maybe this is the main reason why you chose to always go with null. -- This message was sent by Atlassian JIRA (v6.3.4#6332)