AnsweredAssumed Answered

Error using CMIS againts alfresco

Question asked by laudio.info@gmail.com on Apr 11, 2014
Latest reply on Apr 11, 2014 by laudio.info@gmail.com
Hello

i am using chemistry 0.10.0
i have this:

Session
private static Session connect() {
         
         if (cmisSession == null) {
               SessionFactory factory = SessionFactoryImpl.newInstance();
               Map<String, String> parameter = new HashMap<String, String>();
                System.out.println(">>>Alfresco en local");
                // datos de conexion   
                   parameter.put(SessionParameter.ATOMPUB_URL, "Myurl");
                   parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
                   //FIXME mirar si esta parametro es necesario o no
                   //parameter.put(SessionParameter.AUTH_HTTP_BASIC, "true");
                   parameter.put(SessionParameter.USER, "mylogin");
                   parameter.put(SessionParameter.PASSWORD, "mypass");
                   parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");

             List<Repository> repositories = factory.getRepositories(parameter);
               System.out.println("conectamos a alfresco con usuario: " + parameter.get(SessionParameter.USER));
               System.out.println("conectamos a alfresco con passwd: " + parameter.get(SessionParameter.PASSWORD));
               System.out.println("conectamos a alfresco con url: " + parameter.get(SessionParameter.ATOMPUB_URL));
               System.out.println("conectamos a alfresco con un binding de tipo: " + parameter.get(SessionParameter.BINDING_TYPE));
               System.out.println("conectamos a alfresco con una autorizacion: " + parameter.get(SessionParameter.AUTH_HTTP_BASIC));
             System.out.println(">>>Alfresco antes de crear sesion");
               if (repositories != null && !repositories.isEmpty()) {
                  System.out.println(">>>Alfresco repositorios es != null");
                  cmisSession = repositories.get(0).createSession();
                  System.out.println(">>>Alfresco despues de crear sesion");
                  System.out.println(">>> "+repositories.get(0).getId());
                  System.out.println(">>> "+repositories.get(0).getName());
                  System.out.println(">>> "+repositories.get(0).getRootFolderId());
               }else{
                  System.out.println(">>>Alfresco NO hay repositorios");
               }
            
          }      
         
          return cmisSession;
          }
this returns well the session
but when i made:
cmisSession = connect();
         if(cmisSession == null) {
            System.out.println("ERROR sesion nula————————————-");            
         }
         Map<String, String> props = new HashMap<String, String>();
         props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
         props.put(PropertyIds.NAME, "el titulo");
         System.out.println("Alfresco tomamos el contenido del fichero");
         String data = "hdfhdfhdfhd";
         ByteArrayInputStream input = new ByteArrayInputStream(data.getBytes());
         //ByteArrayInputStream input = new ByteArrayInputStream(documentoET.getContenido());
         //Folder root = cmisSession.getRootFolder();
         System.out.println("Alfresco tomamos el directorio en base al string recibido que es: "+ alfrescoFolder);
         if(cmisSession == null){
            System.out.println("CXONEXION NULA");
         }else{
            System.out.println("CXONEXION NO NULA");
            //System.out.println("Nombre del root folder: " + root.getName());
         }
         if(cmisSession.getObject(alfrescoFolder) == null){
         
appears into the last line one error:
Exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException: Not Found
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:467)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.read(AbstractAtomPubService.java:613)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.getObjectInternal(AbstractAtomPubService.java:836)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImpl.getObject(ObjectServiceImpl.java:619)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl.getObject(SessionImpl.java:410)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl.getObject(SessionImpl.java:388)
   at ejemplo.main(ejemplo.java:56)–>this line is if(cmisSession.getObject(alfrescoFolder) == null){


Can you help me?
thanks   

Outcomes