chemistry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pascal O. (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CMIS-849) Rendition.GetContentstream always returns null for QueryResults
Date Tue, 30 Sep 2014 10:58:33 GMT

    [ https://issues.apache.org/jira/browse/CMIS-849?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14153056#comment-14153056
] 

Pascal O. edited comment on CMIS-849 at 9/30/14 10:57 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.FirstOrDefault(r => r.Kind == "cmis:thumbnail");
            if (rendition == null) 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:
{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}

> 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 O.
>            Assignee: Florian Müller
>            Priority: Minor
>         Attachments: client-objects.diff
>
>
> How to reproduce:
> {code}
> 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()
> {code}
> 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:title=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:title=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)

Mime
View raw message