AnsweredAssumed Answered

How to access to document 'Categories' via CMIS

Question asked by vodok on Mar 8, 2013
Latest reply on Mar 11, 2013 by vodok
Hi,

I am tottaly new as Alfresco applications developer in Java.

I am creating a maven plugin which creates new versions of all documents under a determined folder depending on the category of those documents. I've been able to create new versions of all documents but I don't know how to get all the different document categories defined in Alfresco nor how to get the different categories a document might be associated to. After reading a lot I think it has something to do with "Aspects" but I am using CMIS and I think such aspect is not accessible via CMIS.

1. Am I in the right direction?
2. Do you know how to get categories associated to a document via CMIS?
3. Do you know how to access to Alfresco defined categories via CMIS?

Thank you very much.

I show you a little brief of the code in case I didn't explain myself :P

<java>
….
if (tree.getChildren().isEmpty()) {
   Document doc = (Document) tree.getItem();
   //HERE I WOULD NEED TO CHECK DOCUMENT CATEGORY AND DEPENDING ON CATEGORY I WOULD CREATE NEW VERSION OR NOT
//EXAMPLE PSEUDO CODE
//If (doc.getCategory == Alfresco.getCategoriesByTag(/Languages/spanish){

      

// Versioning…
   getLog().info("\nVersionando documento: "+doc.getName());
   getLog().info("————-");
         
// check whether is versionable or not
      if (((DocumentType) (doc.getType())).isVersionable()) {
   getLog().info("Tipo del archivo: "+doc.getName()+":"+doc.getType().getDisplayName());
   getLog().info(doc.getName() + " es versionable y su BaseType es: "+doc.getBaseType().getDisplayName());
            docsVersionados.add(doc.getName());
            
// realizamos el check out de la última versión del documento,
// modificamos la PWC y realizamos el check in de la nueva versión
      Document pwc = (Document) session.getObject(doc.checkOut());
// Check in the pwc
        try {
     pwc.checkIn(false, null, pwc.getContentStream(),comentarioNuevaVersion);
   } catch (Exception e) {
       e.printStackTrace();
           System.out.println("checkin failed, trying to cancel the checkout");
           pwc.cancelCheckOut();
   }
…..

..
<java>

Outcomes