AnsweredAssumed Answered

Alfresco & LDAP + create folder

Question asked by b12jose on Feb 15, 2008
Latest reply on May 20, 2010 by clock1988
i!,

I've syncronized LDAP and Alfresco so that if the user does not exist in
Alfresco but it does in LDAP it makes login in the system, but appart from
making logging, I need it to create a series of folders and copy some
contents in such folder.
I know that PersonServiceImpl is the class able to do so and that
createPerson is the method to be invoked in order to create such user, for
this reason, I've tried to modify  the code so as to create the folders and
copy the contents, but it gives the following error:
net.sf.acegisecurity.BadCredentialsException: Bad credentials presented

I join the code, Please, could you help me?


public FileFolderService createFileFolderService(){
       System.out.println("Creando FileFolderService");
       System.out.println("Registry"+registry);
       fileFolderService = this.getServiceRegistry().getFileFolderService();
       return fileFolderService;
   }

   public NodeRef createPerson(Map<QName, Serializable> properties) throws FileExistsException
   {

       try {
           System.out.println("User"+AuthenticationUtil.getCurrentUserName());
           AuthenticationUtils.startSession("admin", "admin");
           AuthenticationUtil.setCurrentUser("admin");
           AuthenticationUtil.setSystemUserAsCurrentUser();
           System.out.println("User"+AuthenticationUtil.getCurrentUserName());
           String userName = DefaultTypeConverter.INSTANCE.convert(String.class, properties.get(ContentModel.PROP_USERNAME));
           properties.put(ContentModel.PROP_USERNAME, userName);
           NodeRef nodo = null;
           this.setFileFolderService(createFileFolderService());
           nodo = nodeService.createNode(getPeopleContainer(), ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_PERSON, ContentModel.TYPE_PERSON, properties).getChildRef();
           NodeRef padre=null;
           try{
            padre = new NodeRef(APP+"company_home/"+CM+"config/"+CM+"usuarios");
           }catch(Exception ex){
               System.err.println("MIKI ERROR:"+ex.getMessage());
               ex.printStackTrace(System.err);
           }
           fileFolderService.create(padre, userName, ContentModel.TYPE_FOLDER);
           NodeRef archivoACopiar = new NodeRef(APP+"company_home/"+CM+"template");
           NodeRef destinoCopia = new NodeRef(APP+"company_home/"+CM+"config/"+CM+"usuarios/"+CM+userName);

           fileFolderService.copy(archivoACopiar, destinoCopia, SPLIT);          
           NodeRef segundoAC = new NodeRef(APP+"company_home/"+CM+"template/"+CM+"conf");
           NodeRef segundoDC = new NodeRef(APP+"company_home/"+CM+"config/"+CM+"user/"+CM+userName);
           fileFolderService.copy(segundoAC, segundoDC, SPLIT);
           NodeRef tercerAC = new NodeRef(APP+"company_home/"+CM+"template/"+CM+"files");
           fileFolderService.copy(tercerAC, segundoDC, SPLIT);
           NodeRef cuartoAC = new NodeRef(APP+"company_home/"+CM+"template/"+CM+"trash");
           fileFolderService.copy(cuartoAC, segundoDC, SPLIT);
           return nodo;
       }catch (Exception ex) {
           Logger.getLogger(PersonServiceImplFidesol.class.getName()).log(Level.SEVERE, null, ex);

       }
       return null;
   }


Thank you very much
Regards

Outcomes