cancel
Showing results for 
Search instead for 
Did you mean: 

Opencmis extension paging problem

mirko79
Champ in-the-making
Champ in-the-making
Hi,
i'm having problems using pagination with opencmis extension : if the last page contains only one results the "currentPage.getHasMoreItems()" on second-last page returns false and i lose one result.
For example if i set MaxItemPerPage to 10 and there are 21 results, the last is not retrieved.

I have installed Alfresco community 4.0.d (alfresco-community-4.0.d-installer-win-x64.exe)

Creation of session in client:

                        SessionFactory factory = SessionFactoryImpl.newInstance();
         Map<String, String> parameter = new HashMap<String, String>();
   
         // user credentials
         parameter.put(SessionParameter.USER, configurationUtils.getCmisUserLogin());
         parameter.put(SessionParameter.PASSWORD, configurationUtils.getCmisUserPassword());
              // ATOMPUB binding
         parameter.put(SessionParameter.ATOMPUB_URL, configurationUtils.getCmisBindingUrl());
         parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
         parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");

                       List<Repository> repositories = factory.getRepositories(parameter);
                       this.session = repositories.get(0).createSession();
         

Query with pagination to cmis:


                Session session = cmisClient.getSession();
      OperationContext operationContext = new OperationContextImpl();
      operationContext.setMaxItemsPerPage(10);

      String queryString = "select d.*,w.* "
            + "from cmis:document as d join adp:my_aspect as w on d.cmis:objectId = w.cmis:objectId "
            + "where w.adp:stato = 'DA INVIARE'";
      
      ItemIterable<QueryResult> results = session.query(queryString, false,operationContext);

      int pageNumber = 0;
      boolean finished = false;
      int count = 0;
      while (!finished) {
         ItemIterable<QueryResult> currentPage = results.skipTo(count).getPage();

         for (QueryResult qResult : currentPage) {
            String objectId = "";
            PropertyData<?> propData = qResult.getPropertyById("cmis:objectId"); // Atom Pub binding
            if (propData != null) {
               objectId = (String) propData.getFirstValue();
            } else {
               //TODO: decidere se fare o meno
               objectId = qResult.getPropertyValueByQueryName("d.cmis:objectId"); // Web Services binding
            }
            CmisObject obj = session.getObject(session.createObjectId(objectId));
            count++;
            _log.info("CMIS obj id: [" + obj.getId() + "], name:["+ obj.getName() + "], adp:status: ["+obj.getPropertyValue("adp:stato")+"]");
         }
         pageNumber++;
           if (!currentPage.getHasMoreItems())
               finished = true;
      }

thanks
3 REPLIES 3

steves
Champ in-the-making
Champ in-the-making
Hi Mirko79,

have you solved this problem?
I've tried the same on a fresh 4.2.c community edition, same result, the last item is missing.
Then I tried using lucene and with it it works.

goebel
Champ on-the-rise
Champ on-the-rise
Have the same issue here that the last item is missing


Georges Goebel

mohcinew
Champ in-the-making
Champ in-the-making
Hi, I'm having the same issue! there is no news ?