You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@chemistry.apache.org by "Stefan Kopf (JIRA)" <ji...@apache.org> on 2013/03/18 14:10:16 UTC

[jira] [Updated] (CMIS-639) AtomPub: Query result entries are missing the element

     [ https://issues.apache.org/jira/browse/CMIS-639?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Kopf updated CMIS-639:
-----------------------------

    Description: 
Acording to CMIS spec, the <atom:content> element is required in every <atom:entry> element. See Sections 3.5.2 and 3.4.1.3.6.

The <atom:content> element is present in every <atom:entry> returned for getChildren in the NavigationService or for getObject in the ObjectService.

For some reason, the method writeQueryResultEntry in the ...atompub.DiscoveryService does not make use of AtomPubUtils.writeObjectEntry but assembles the result itself. But in this process, the <atom:content> element is missing.

This problem can be fixed as follows in org.apache.chemistry.opencmis.server.impl.atompub.DiscoveryService:
{code:java}
    private static void writeQueryResultEntry(AtomEntry entry, ObjectData result, String id, GregorianCalendar now, UrlBuilder baseUrl)
            throws Exception {
        CmisObjectType resultJaxb = convert(result);
        if (resultJaxb == null) {
            return;
        }

        // start
        entry.startEntry(false);

        // write Atom base tags
        entry.writeAuthor("");
        entry.writeId(entry.generateAtomId(id));
        entry.writePublished(now);
        entry.writeTitle("Query Result " + id);
        entry.writeUpdated(now);
        
        // BUGFIX start
        String fileName = getStringProperty(result, PropertyIds.CONTENT_STREAM_FILE_NAME);
        String mimeType = getStringProperty(result, PropertyIds.CONTENT_STREAM_MIME_TYPE);
        String streamId = getIdProperty(result, PropertyIds.CONTENT_STREAM_ID);
        BigInteger length = getIntegerProperty(result, PropertyIds.CONTENT_STREAM_LENGTH);
        boolean hasContent = fileName != null || mimeType != null || streamId != null || length != null;
        String contentSrc = null;
        if (hasContent) {
            UrlBuilder contentSrcBuilder = compileUrlBuilder(baseUrl, AtomPubUtils.RESOURCE_CONTENT, result.getId());
            if (fileName != null) {
                contentSrcBuilder.addPathSegment(fileName);
            }
            contentSrc = contentSrcBuilder.toString();
        }
        entry.writeContent(contentSrc, mimeType);
        // BUGFIX end

        // write query result object
        JaxBHelper.marshal(JaxBHelper.CMIS_EXTRA_OBJECT_FACTORY.createObject(resultJaxb), entry.getWriter(), true);

        // we are done
        entry.endEntry();
    }
{code}

  was:
Acording to CMIS spec, the <atom:content> element is required in every <atom:entry> element. See Sections 3.5.2 and 3.4.1.3.6.

The <atom:content> element is present in every <atom:entry> returned for getChildren in the NavigationService or for getObject in the ObjectService.

For some reason, the method writeQueryResultEntry in the ...atompub.DiscoveryService does not make use of AtomPubUtils.writeObjectEntry but assembles the result itself. But in this process, the <atom:content> element is missing.

This problem can be fixed as follows:
{code:java}
    private static void writeQueryResultEntry(AtomEntry entry, ObjectData result, String id, GregorianCalendar now, UrlBuilder baseUrl)
            throws Exception {
        CmisObjectType resultJaxb = convert(result);
        if (resultJaxb == null) {
            return;
        }

        // start
        entry.startEntry(false);

        // write Atom base tags
        entry.writeAuthor("");
        entry.writeId(entry.generateAtomId(id));
        entry.writePublished(now);
        entry.writeTitle("Query Result " + id);
        entry.writeUpdated(now);
        
        // BUGFIX start
        String fileName = getStringProperty(result, PropertyIds.CONTENT_STREAM_FILE_NAME);
        String mimeType = getStringProperty(result, PropertyIds.CONTENT_STREAM_MIME_TYPE);
        String streamId = getIdProperty(result, PropertyIds.CONTENT_STREAM_ID);
        BigInteger length = getIntegerProperty(result, PropertyIds.CONTENT_STREAM_LENGTH);
        boolean hasContent = fileName != null || mimeType != null || streamId != null || length != null;
        String contentSrc = null;
        if (hasContent) {
            UrlBuilder contentSrcBuilder = compileUrlBuilder(baseUrl, AtomPubUtils.RESOURCE_CONTENT, result.getId());
            if (fileName != null) {
                contentSrcBuilder.addPathSegment(fileName);
            }
            contentSrc = contentSrcBuilder.toString();
        }
        entry.writeContent(contentSrc, mimeType);
        // BUGFIX end

        // write query result object
        JaxBHelper.marshal(JaxBHelper.CMIS_EXTRA_OBJECT_FACTORY.createObject(resultJaxb), entry.getWriter(), true);

        // we are done
        entry.endEntry();
    }
{code}

    
> AtomPub: Query result entries are missing the <atom:content> element
> --------------------------------------------------------------------
>
>                 Key: CMIS-639
>                 URL: https://issues.apache.org/jira/browse/CMIS-639
>             Project: Chemistry
>          Issue Type: Bug
>          Components: opencmis-server
>    Affects Versions: OpenCMIS 0.8.0
>            Reporter: Stefan Kopf
>
> Acording to CMIS spec, the <atom:content> element is required in every <atom:entry> element. See Sections 3.5.2 and 3.4.1.3.6.
> The <atom:content> element is present in every <atom:entry> returned for getChildren in the NavigationService or for getObject in the ObjectService.
> For some reason, the method writeQueryResultEntry in the ...atompub.DiscoveryService does not make use of AtomPubUtils.writeObjectEntry but assembles the result itself. But in this process, the <atom:content> element is missing.
> This problem can be fixed as follows in org.apache.chemistry.opencmis.server.impl.atompub.DiscoveryService:
> {code:java}
>     private static void writeQueryResultEntry(AtomEntry entry, ObjectData result, String id, GregorianCalendar now, UrlBuilder baseUrl)
>             throws Exception {
>         CmisObjectType resultJaxb = convert(result);
>         if (resultJaxb == null) {
>             return;
>         }
>         // start
>         entry.startEntry(false);
>         // write Atom base tags
>         entry.writeAuthor("");
>         entry.writeId(entry.generateAtomId(id));
>         entry.writePublished(now);
>         entry.writeTitle("Query Result " + id);
>         entry.writeUpdated(now);
>         
>         // BUGFIX start
>         String fileName = getStringProperty(result, PropertyIds.CONTENT_STREAM_FILE_NAME);
>         String mimeType = getStringProperty(result, PropertyIds.CONTENT_STREAM_MIME_TYPE);
>         String streamId = getIdProperty(result, PropertyIds.CONTENT_STREAM_ID);
>         BigInteger length = getIntegerProperty(result, PropertyIds.CONTENT_STREAM_LENGTH);
>         boolean hasContent = fileName != null || mimeType != null || streamId != null || length != null;
>         String contentSrc = null;
>         if (hasContent) {
>             UrlBuilder contentSrcBuilder = compileUrlBuilder(baseUrl, AtomPubUtils.RESOURCE_CONTENT, result.getId());
>             if (fileName != null) {
>                 contentSrcBuilder.addPathSegment(fileName);
>             }
>             contentSrc = contentSrcBuilder.toString();
>         }
>         entry.writeContent(contentSrc, mimeType);
>         // BUGFIX end
>         // write query result object
>         JaxBHelper.marshal(JaxBHelper.CMIS_EXTRA_OBJECT_FACTORY.createObject(resultJaxb), entry.getWriter(), true);
>         // we are done
>         entry.endEntry();
>     }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira