Skip to Content

SCP Document Service query using CMIS Browser bindings?

Hello SCP Document Service experts,

we want to use the SCP Document Service from HANA XSJS (XS Classic, XSC). For that I've implemented a Proxy Bridge in Java to be able to call the Document Service via HTTPS and OAuth / Basic authentication. Using this Proxy I can already create a new document and read it from HANA XS.

But before uploading a document I want to check if for this business object already a document exists. Based on the example I've found in the document CMIS Browser Binding Proposal - Oasis I've added the following

<form id="queryForm" action="" method="GET">
<input name="cmisaction" type="hidden" value="query" />
<table>
<tr><td>Query:</td><td><input name="statement" type="text" size="100" maxlength="1000" 
value="SELECT * FROM cmis:document 
WHERE cmis:name = '00b83148-5d86-aebe-84e0-332ef729a0c3'"></td></tr>
<tr><td>Max Items:</td><td><input name="maxItems" type="text" size="4" maxlength="8" value="100"></td></tr>
<tr><td>Skip Count:</td><td><input name="skipCount" type="text" size="4" maxlength="8" value="0"></td></tr>
<tr><td></td><td><input type="submit" value="Go" /></td></tr>
</table>
</form>

to the sample that is provided in the Documenation Accessing the Document Service from an HTML5 Application. Unfortunately the result that I've got returned isn't filtered by the cmis:name that I'm looking for. All objects in the folder are returned.

Hope someone can guide me in the right direction.

Best regards
Gregor

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 11, 2017 at 02:13 PM

    There is another issue in your form. Queries must be executed as a POST not a GET request. As you do a GET on the /root collection this is interpreted as an getObjectByPath() call on the root folder. The query parameters are ignored in this case. So you get all children of the root folder. To do a query, try this:

        <form id="queryForm" action="https://cmisproxy<account>.hana.ondemand.com/<servletpath>/json/<repo-ID>" 
          method="POST"> <!-- omit the /root at the end of the URL!!!! -->
          <input name="cmisaction" type="hidden" value="query" />
          ...
      </form>

    And one remark: For performance reasons do not a SELECT *, do a SELECT on only those properties you are interested in. Some properties are expensive to get and it will cause a lot of data to be transmitted.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Jens,

      thank you for the great guidance. I finally made it work using this form:

      	<form id="queryForm" action="/cmis/json/45e890711d092fc031656795" method="POST">
      		<input name="cmisaction" type="hidden" value="query" />
      		<table>
      		<tr><td>Query:</td><td><input name="statement" type="text" size="100" maxlength="1000" 
      		value="SELECT cmis:contentStreamMimeType, cmis:name 
      			FROM cmis:document 
      			WHERE cmis:name = '7ee9bab7-9b9f-0c1c-c2c5-c45ee6d9857c' 
      			  AND IN_FOLDER('LJz3ItlxLloqQCVDaAwK0a9ZRUXFwKT7Dcl7R_HKA1k')"></td></tr>
      		<tr><td>Max Items:</td><td><input name="maxItems" type="text" size="4" maxlength="8" value="100"></td></tr>
      		<tr><td>Skip Count:</td><td><input name="skipCount" type="text" size="4" maxlength="8" value="0"></td></tr>
      		<tr><td></td><td>
      		<input type="submit" value="Go" /></td></tr>
      		</table>
      	</form>	

      Best regards
      Gregor

  • Aug 10, 2017 at 01:44 PM

    For the moment I found a workaround using the Atom endpoint. I send a POST with the following payload:

    <?xml version='1.0' encoding='utf-8'?>
    <cmis:query xmlns='http://www.w3.org/2005/Atom' xmlns:cmis='http://docs.oasis-open.org/ns/cmis/core/200908/'>
    	<cmis:statement>SELECT cmis:contentStreamMimeType, cmis:name FROM cmis:document WHERE cmis:name = '00b83148-5d86-aebe-84e0-332ef729a0c3'</cmis:statement>
    	<cmis:searchAllVersions>false</cmis:searchAllVersions>
    	<cmis:includeAllowableActions>false</cmis:includeAllowableActions>
    </cmis:query>
    
    Add comment
    10|10000 characters needed characters exceeded

    • Hi Gregor,

      We are trying to do the same thing and have the same problem. Why did you give up with your first try and used the Atom version? Didn't POST work for you? We are getting following error while trying to use a form with POST:

      { "exception": "notSupported", "message": "Unknown operation" }

      It seems like cmisaction=query is not supported. Do you have any tips for us?

      Thanks and Regards,

      Koray

  • avatar image
    Former Member
    Aug 11, 2017 at 12:06 PM

    You can use the browser binding as well. I do not fully understand what you are trying to achieve. I guess your main problem is that you do not define an action parameter. You have to send your form to your CMIS proxy app. Please try:

    <form id="queryForm" action="https://cmisproxy<account>.hana.ondemand.com/<servletpath>/json/<repo-ID>/root" method="GET">
    <input name="cmisaction" type="hidden" value="query" />
    <table>
    <tr><td>Query:</td><td><input name="statement" type="text" size="100" maxlength="1000"
    value="SELECT * FROM cmis:document WHERE cmis:name = 'Sprint7.pdf'"></td></tr>
    <tr><td>Max Items:</td><td><input name="maxItems" type="text" size="4" maxlength="8" value="100"></td></tr>
    <tr><td>Skip Count:</td><td><input name="skipCount" type="text" size="4" maxlength="8" value="0"></td></tr>
    <tr><td></td><td>
    <input type="submit" value="Go" onclick="doQuery();" /></td></tr>
    </table>
    </form>

    The details of the URL depend on how you configure your proxy app and the landscape/region. To test the URL you can put it in a browser and check if you get a response, like:

    https://cmisproxyd053421trial.hanatrial.ondemand.com/cmisproxy/cmis/json/65ac5d94148a6dc5cf5d895/root?cmisselector=children

    Please note that in your example your browser receives the JSON response and displays the result. Usually you would do this in an XMLHttpRequest and process the response in code.

    You can look in the CP Document Service documentation in getChildren() for an example.

    Add comment
    10|10000 characters needed characters exceeded