11-09-2012 01:29 PM
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.MutableAuthenticationServiceImpl;
import org.alfresco.repo.security.person.PersonServiceImpl;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.MutableAuthenticationService;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.PropertyMap;
public class CreateUserToRepository {
public CreateUserToRepository() {
}
private PersonService personService;
private MutableAuthenticationService authenticationService;
public void createUser(String userName, String password, String firstName,
String lastName) {
authenticationService = new MutableAuthenticationServiceImpl();
if (this.authenticationService.authenticationExists(userName) == false) {
this.authenticationService.createAuthentication(userName,
password.toCharArray());
PropertyMap personProps = new PropertyMap();
personProps.put(ContentModel.PROP_USERNAME, userName);
personProps.put(ContentModel.PROP_FIRSTNAME, firstName);
personProps.put(ContentModel.PROP_LASTNAME, lastName);
personProps.put(ContentModel.PROP_EMAIL, userName
+ "@localhost.com");
personProps.put(ContentModel.PROP_JOBTITLE, "myJobTitle");
personProps.put(ContentModel.PROP_JOBTITLE, "myOrganisation");
personService = new PersonServiceImpl();
this.personService.createPerson(personProps);
}
}
}
11-09-2012 05:09 PM
11-09-2012 10:07 PM
Would be helpful if you gave the line number or stack trace but your init of the person and autentication service is nonsense. You should be injecting your dependencies.
11-12-2012 01:53 AM
11-12-2012 05:13 AM
11-12-2012 06:24 AM
11-28-2012 01:24 AM
11-28-2012 01:28 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.