creacion de usuarios alfresco

cancel
Showing results for 
Search instead for 
Did you mean: 
fjump
Member II

creacion de usuarios alfresco

Hola a todos soy nuevo en el desarrollo de algresco y estoy tratando de hacer una pequeña aplicacion la cual pueda crear usuarios y grupos de ellos.
estoy trabajando con las siguientes herramientas:
-authenticationService.authenticationExists
-Alfresco-Community-3.2r2-Full-Setup
-eclipse galileo
-jdj 1.6
he intentado de varias formas llamando web services pero me arroja un error en la auntetificacion y tambien he intentado crear el codigo yo para la creacion de usuarios peor me arroaj un java.lang.NullPointerException  me gutaria que si alguien sabe de como hacerlo puediera ayudar.


miren este es el codigo de mi clase con la cual estoy tratando de crear usuarios me gustaria saber si me falta algo en la estructura de la aplicacion algun archivo de configuracion o le falta algo al codigo.(esta es una clase de ejemplo que estaba en el foro ).
solo tngo esta clase en mi proyeto y las referencias a los .jar que se necesitan
espero alguna ayuda gracias


public class BootstrapAuthorityCreator {
   
       private AuthorityService authorityService;
       private PersonService personService;
       private TransactionService transactionService;
       private AuthenticationService authenticationService;
       private UserTransaction tx;
       private static Logger logger = Logger.getLogger(BootstrapAuthorityCreator.class);

       public void init() throws Exception {

          String salesGroup;
          String marketingGroup;
        
          tx = transactionService.getUserTransaction();
          tx.begin();
         
          // create tuser1, tuser2, tuser3, tuser4
           if(!authenticationService.authenticationExists("admin")) {
             authenticationService.createAuthentication("tuser1", "password".toCharArray());
             if (logger.isDebugEnabled()) logger.debug("Created tuser1 auth");
           }

           if (!personService.personExists("tuser1")) {
             personService.createPerson(createDefaultProperties("tuser1", "Test", "User1", "tuser1@localhost", "password"));
             if (logger.isDebugEnabled()) logger.debug("Created tuser1 person");
          }

           if(!authenticationService.authenticationExists("tuser2")) {
             authenticationService.createAuthentication("tuser2", "password".toCharArray());
             if (logger.isDebugEnabled()) logger.debug("Created tuser2 auth");
           }

          if (!personService.personExists("tuser2")) {
             personService.createPerson(createDefaultProperties("tuser2", "Test", "User2", "tuser2@localhost", "password"));
             if (logger.isDebugEnabled()) logger.debug("Created tuser2 person");
          }

           if(!authenticationService.authenticationExists("tuser3")) {
             authenticationService.createAuthentication("tuser3", "password".toCharArray());
             if (logger.isDebugEnabled()) logger.debug("Created tuser3 auth");
           }

          if (!personService.personExists("tuser3")) {
             personService.createPerson(createDefaultProperties("tuser3", "Test", "User3", "tuser3@localhost", "password"));
             if (logger.isDebugEnabled()) logger.debug("Created tuser3 person");
          }

           if(!authenticationService.authenticationExists("tuser4")) {
             authenticationService.createAuthentication("tuser4", "password".toCharArray());
             if (logger.isDebugEnabled()) logger.debug("Created tuser4 auth");
           }

          if (!personService.personExists("tuser4")) {
             personService.createPerson(createDefaultProperties("tuser4", "Test", "User4", "tuser4@localhost", "password"));
             if (logger.isDebugEnabled()) logger.debug("Created tuser4 person");
          }
         
          if (authorityService.authorityExists(authorityService.getName(AuthorityType.GROUP, "sales"))) {
             salesGroup = authorityService.getName(AuthorityType.GROUP, "sales");
          } else {
             // create the sales group
             salesGroup = authorityService.createAuthority(AuthorityType.GROUP, "sales");
          }

          //add tuser1 and tuser2 to the sales group
          authorityService.addAuthority(salesGroup, "tuser1");
          authorityService.addAuthority(salesGroup, "tuser2");
         
          if (authorityService.authorityExists(authorityService.getName(AuthorityType.GROUP, "marketing"))) {
             marketingGroup = authorityService.getName(AuthorityType.GROUP, "marketing");
          } else {
             // create the marketing group
             marketingGroup = authorityService.createAuthority(AuthorityType.GROUP, "marketing");
          }

          //add tuser3 and tuser4 to the marketing group
          authorityService.addAuthority(marketingGroup, "tuser3");
          authorityService.addAuthority(marketingGroup, "tuser4");
         
          tx.commit();
       }
     
       private Map<QName, Serializable> createDefaultProperties(String userName, String firstName, String lastName,
               String email, String password) {
           HashMap<QName, Serializable> properties = new HashMap<QName, Serializable>();
           properties.put(ContentModel.PROP_USERNAME, userName);
           properties.put(ContentModel.PROP_FIRSTNAME, firstName);
           properties.put(ContentModel.PROP_LASTNAME, lastName);
           properties.put(ContentModel.PROP_EMAIL, email);
           properties.put(ContentModel.PROP_PASSWORD, password);
           return properties;
       }

      public void setAuthorityService(AuthorityService authorityService) {
         this.authorityService = authorityService;
      }

      public void setPersonService(PersonService personService) {
         this.personService = personService;
      }

      public void setTransactionService(TransactionService transactionService) {
         this.transactionService = transactionService;
      }

      public void setAuthenticationService(AuthenticationService authenticationService) {
         this.authenticationService = authenticationService;
      }

}
1 Reply
jobispo
Member II

Re: creacion de usuarios alfresco

Creo que tu problema es que no injectas los servicios cuando declaras el Bean en el archivo faces, eso es lo que provoca que te genere Nullpointer Exception.

Si los has injectado, el error sería otro. Comentanos. Por cierto, si los injectas necesitas los getters ademas de los setters que si tienes creados.