AnsweredAssumed Answered

CMIS query throws an exception

Question asked by vinitp on Oct 23, 2012
Latest reply on Aug 14, 2017 by aowian
Hello,
I am trying to use CMIS query to retrieve list of documents in the repository (Alfresco enterprise 4.0.1) using the following code:

                         ItemIterable<QueryResult> results = util.getSession().query("select cmis:name from cmis:document", false);
              for(QueryResult hit: results) { 
                  for(PropertyData<?> property: hit.getProperties()) {

                      String queryName = property.getQueryName();
                      Object value = property.getFirstValue();

                      System.out.println(queryName + ": " + value);
                  }
              }

However, it throws this exception:

Exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException: Internal Server Error
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:452)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.post(AbstractAtomPubService.java:570)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.DiscoveryServiceImpl.query(DiscoveryServiceImpl.java:142)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl$3.fetchPage(SessionImpl.java:557)
   at org.apache.chemistry.opencmis.client.runtime.util.AbstractIterator.getCurrentPage(AbstractIterator.java:132)
   at org.apache.chemistry.opencmis.client.runtime.util.CollectionIterator.hasNext(CollectionIterator.java:48)
   at eeoc.gov.ecm.util.cmis.CmisUtil.main(CmisUtil.java:155)


Am I missing something?
Thanks,

UPDATE: While browsing this forum, I came across a posting where someone recommended to use "http://localhost:8080/alfresco/cmisatom" instead of "http://localhost:8080/alfresco/service/cmis" for ATOMPUB. This how I get a session:
                Map<String, String> parameter = new HashMap<String, String>();
      parameter.put(SessionParameter.USER, userId);
      parameter.put(SessionParameter.PASSWORD, password);
      parameter.put(SessionParameter.ATOMPUB_URL, ALFRSCO_ATOMPUB_URL);
      parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
      //parameter.put(SessionParameter.REPOSITORY_ID, REPOSITORY_ID);
      List<Repository> repositories = sessionFactory.getRepositories(parameter);
      session = repositories.get(0).createSession();

After changing the URL to "http://localhost:8080/alfresco/cmisatom" gives a different exception which  is:

Exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException: 092316733
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:452)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.post(AbstractAtomPubService.java:570)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.DiscoveryServiceImpl.query(DiscoveryServiceImpl.java:142)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl$3.fetchPage(SessionImpl.java:557)
   at org.apache.chemistry.opencmis.client.runtime.util.AbstractIterator.getCurrentPage(AbstractIterator.java:132)
   at org.apache.chemistry.opencmis.client.runtime.util.AbstractIterator.getTotalNumItems(AbstractIterator.java:70)
   at org.apache.chemistry.opencmis.client.runtime.util.AbstractIterable.getTotalNumItems(AbstractIterable.java:94)
   at eeoc.gov.ecm.util.cmis.CmisUtil.main(CmisUtil.java:156)

Outcomes