You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@chemistry.apache.org by "Pascal Oblonczek (JIRA)" <ji...@apache.org> on 2014/09/30 12:47:35 UTC
[jira] [Commented] (CMIS-849) Rendition.GetContentstream always
returns null for QueryResults
[ https://issues.apache.org/jira/browse/CMIS-849?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14153056#comment-14153056 ]
Pascal Oblonczek commented on CMIS-849:
---------------------------------------
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)