0

I want to execute a simple query using the PHP CMIS client I got from the Apache Chemistry page. As a proof of concept I figured that the following code should have worked as expected:

    <?php
    require_once 'cmis_repository_wrapper.php';

    $repo_url     = 'http://localhost:8080/alfresco/s/cmis';
    $repo_username= 'admin';
    $repo_password= 'admin';
    $query        = 'SELECT * FROM cm:document';

    $client = new CMISService($repo_url, $repo_username, $repo_password);        
    $objs   = $client->query($query);

    foreach($objs->objectList as $obj)
    {
       print_r($obj);
    }
    ?>

However when I try to run this I get the following error:

Warning: DOMDocument::loadXML(): Entity 'nbsp' not defined in Entity, line: 22 in cmis_repository_wrapper.php on line 392

Am I missing something in my implementation? Or is something wrong with the wrapper provided by the Chemistry project page?

Kross
  • 305
  • 3
  • 21
  • You are using a deprecated CMIS endpoint. See https://stackoverflow.com/questions/22218781/alfresco-cmis-parents-query-returning-unexpected-empty-result/22219680#22219680 . – Florian Müller Jun 17 '14 at 15:20
  • I tried changing the endpoint to the one mentioned in the answer and also another one (alfresco/cmisatom). I don't get the error I was receiving before, but the array comes back empty. I know I have documents in the repository. And I have queried both with curl and the workbench and I'm able to see them, but when I query here I can't. – Kross Jun 18 '14 at 13:24

2 Answers2

1

If you are using Alfresco 4.2.f the URL should be:

http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.0/atom

Also, maybe you just mistyped it when you included your snippet, but there is no such thing as "cm:document". I think you meant "cmis:document".

Jeff Potts
  • 10,468
  • 17
  • 40
  • I am, but that one seems to give me a problem when I call it... I don't receive any data back in PHP, it works fine in workbench, though. Using this: `http://localhost:8080/alfresco/s/cmis`. It seems to be working for the moment, though it gives me tons of notices. – Kross Jun 18 '14 at 19:11
0

I've been having some issue myself. The following works for me:

$query = <<<CMIS
  SELECT *
  FROM cmis:document
  WHERE ( CONTAINS('cmis:name:\'$query*\'')
  OR CONTAINS('\'$query\''))
  CMIS;

In your case, you can try:

$query = <<<CMIS
  SELECT *
  FROM cmis:document
  CMIS;

Im still looking for different ways to get the query across but haven't had much success. Let me know if this works for you and if you have another way of doing it.

Emir Memic
  • 270
  • 1
  • 3
  • 14