AnsweredAssumed Answered

Alfresco Remote API, obtener carpeta Company Home

Question asked by witho on Nov 18, 2008
Latest reply on Sep 11, 2009 by witho
Hola,

Estoy creando usuarios de Alfresco desde una clase Java, usando un proyecto open source llamado RAAR (CMA). El caso es que al crear el nuevo usuario quiero configurar su carpeta personal como la carpeta "Company Home" y no consigo obtener la referencia al nodo de esta carpeta. Dejo aquí mi codigo, espero que alguien pueda echarme una mano para hacer esto bien, he probado con metodos como getChildByName y getRootNode pero no consigo nada. Gracias.


                String userName;
      userName = user.getLogin();      
      String passwd = user.getPassword();
      String firstName = user.getFirstName();
      String lastName = user.getLastName();
      String email = user.getEmailAddress();      
                  
      QName firstNameQName = QName.createQName("{http://www.alfresco.org/model/content/1.0}firstName");
      QName lastNameQName = QName.createQName("{http://www.alfresco.org/model/content/1.0}lastName");
      QName passwordQName = QName.createQName("{http://www.alfresco.org/model/content/1.0}password");
      QName emailQName = QName.createQName("{http://www.alfresco.org/model/content/1.0}email");
      QName homeFolderQName = QName.createQName("{http://www.alfresco.org/model/content/1.0}homeFolder");
      
      Map<QName, Serializable> props = null;
      props = new HashMap<QName, Serializable>(5);
      // homeFolder value must be a nodeRef
      props.put(firstNameQName, firstName);
      props.put(lastNameQName, lastName);
      props.put(passwordQName, passwd);
      props.put(emailQName, email);
            
      try{
      
         configurationApplicationContext=WebApplicationContextUtils.getWebApplicationContext(this.getServlet().getServletContext());
         
         authenticationService = (AuthenticationServiceImpl) configurationApplicationContext.getBean("authenticationService");
         peopleService = (PeopleServiceImpl) configurationApplicationContext.getBean("peopleService");
         nodeService = (NodeServiceImpl) configurationApplicationContext.getBean("nodeService");         
         
         ticket = authenticationService.authenticate(repositoryUri, userid, password.toCharArray());   
         
         NodeRef rootNode = nodeService.getRootNode(ticket, new StoreRef("workspace://SpacesStore"));
         
         //NodeRef homeFolder = nodeService.getChildByName(ticket, rootNode, QName.createQName(
                        "{http://www.alfresco.org/model/content/1.0}folder" ), "app:company_home");
         
         props.put(homeFolderQName, rootNode );
         
                  System.out.println("Creating the user called pruebaLray");
                   NodeRef userRef = peopleService.createPerson(ticket, userName, passwd.toCharArray(), props);

Outcomes