AnsweredAssumed Answered

CMIS - Get categories with java

Question asked by fabiogomes.ti on Jul 7, 2013
Latest reply on Jul 22, 2013 by fabiogomes.ti
Hi all,

I need to create a module that read a folder structure and import to Alfresco, i am using CMIS for this.

I need to list the categories and tags from repository to apply to the doc uploaded, but i don't know how i can make it.

I am using the CMIS query but it is not working yet.

See my code:


String queryString = "SELECT * FROM cmis:folder where contains('PATH:\"/cm:generalclassifiable//*\"')";
List<CmisObject> objList = new ArrayList<CmisObject>(); 
       // execute query
       ItemIterable<QueryResult> results = session.query(queryString, false);
       System.out.println("TOTAL DE RESULTADOS => "+results.getTotalNumItems());
       for (QueryResult qResult : results) {
          String objectId = "";
          PropertyData<?> propData = qResult.getPropertyById("cmis:objectId"); // Atom Pub binding
          if (propData != null) {
             objectId = (String) propData.getFirstValue();
          } else {
             objectId = qResult.getPropertyValueByQueryName("d.cmis:objectId"); // Web Services binding
          }
         CmisObject obj = session.getObject(session.createObjectId(objectId));
         objList.add(obj);
       }
      
      DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
        int iCount = 1;
        for (CmisObject result : objList) {
            System.out.println("———————-\r\nResult " + iCount + ":");
            System.out.println("id:" + result.getId());
            System.out.println("name:" + result.getName());
            System.out.println("created:" + dateFormat.format(result.getCreationDate().getTime()));
            iCount ++;
        }

Outcomes