use of org.alfresco.util.PropertyMap in project alfresco-repository by Alfresco.
the class PersonTest method testPreventCreationOfBuiltInAuthorities.
public void testPreventCreationOfBuiltInAuthorities() {
try {
PropertyMap systemProps = new PropertyMap();
systemProps.put(ContentModel.PROP_USERNAME, AuthenticationUtil.getSystemUserName());
systemProps.put(ContentModel.PROP_FIRSTNAME, "myFirstName");
systemProps.put(ContentModel.PROP_LASTNAME, "myLastName");
systemProps.put(ContentModel.PROP_EMAIL, "myFirstName.myLastName@email.com");
systemProps.put(ContentModel.PROP_JOBTITLE, "myJobTitle");
systemProps.put(ContentModel.PROP_ORGANIZATION, "myOrganisation");
personService.createPerson(systemProps);
fail("case fail creating SystemUserName: " + AuthenticationUtil.getSystemUserName());
} catch (AlfrescoRuntimeException e) {
// expect to go here
}
try {
PropertyMap guestProps = new PropertyMap();
guestProps.put(ContentModel.PROP_USERNAME, AuthenticationUtil.getGuestUserName());
guestProps.put(ContentModel.PROP_FIRSTNAME, "myFirstName");
guestProps.put(ContentModel.PROP_LASTNAME, "myLastName");
guestProps.put(ContentModel.PROP_EMAIL, "myFirstName.myLastName@email.com");
guestProps.put(ContentModel.PROP_JOBTITLE, "myJobTitle");
guestProps.put(ContentModel.PROP_ORGANIZATION, "myOrganisation");
personService.createPerson(guestProps);
fail("case fail creating GuestUserName: " + AuthenticationUtil.getGuestUserName());
} catch (AlfrescoRuntimeException e) {
// expect to go here
}
}
use of org.alfresco.util.PropertyMap in project alfresco-repository by Alfresco.
the class PersonTest method xtestLazyHomeFolderCreation.
public void xtestLazyHomeFolderCreation() throws Exception {
String firstName = "" + System.currentTimeMillis();
String lastName = String.format("%05d", -1);
final String username = GUID.generate();
String emailAddress = String.format("%s.%s@xyz.com", firstName, lastName);
PropertyMap properties = new PropertyMap(7);
properties.put(ContentModel.PROP_USERNAME, username);
properties.put(ContentModel.PROP_FIRSTNAME, firstName);
properties.put(ContentModel.PROP_LASTNAME, lastName);
properties.put(ContentModel.PROP_EMAIL, emailAddress);
final NodeRef madePerson = personService.createPerson(properties);
NodeRef homeFolder = DefaultTypeConverter.INSTANCE.convert(NodeRef.class, nodeService.getProperty(madePerson, ContentModel.PROP_HOMEFOLDER));
if (homeFolder != null) {
throw new IllegalStateException("Home folder created eagerly");
}
testTX.commit();
testTX = transactionService.getUserTransaction();
testTX.begin();
RetryingTransactionHelper helper = transactionService.getRetryingTransactionHelper();
helper.doInTransaction(new RetryingTransactionCallback<Void>() {
public Void execute() throws Throwable {
assertTrue(personService.personExists(username));
NodeRef person = personService.getPerson(username);
assertEquals(madePerson, person);
NodeRef homeFolder = DefaultTypeConverter.INSTANCE.convert(NodeRef.class, nodeService.getProperty(madePerson, ContentModel.PROP_HOMEFOLDER));
if (homeFolder == null) {
throw new IllegalStateException("Home folder not created lazily");
}
return null;
}
}, true, false);
homeFolder = DefaultTypeConverter.INSTANCE.convert(NodeRef.class, nodeService.getProperty(madePerson, ContentModel.PROP_HOMEFOLDER));
if (homeFolder == null) {
throw new IllegalStateException("Home folder not created lazily");
}
}
use of org.alfresco.util.PropertyMap in project alfresco-repository by Alfresco.
the class SiteServiceTestHuge method createUser.
// ------------------ create 1 --------------------
private void createUser(String userName) throws Exception {
UserTransaction txn = transactionService.getUserTransaction();
try {
txn.begin();
authenticationService.createAuthentication(userName, userName.toCharArray());
PropertyMap ppOne = new PropertyMap(4);
ppOne.put(ContentModel.PROP_USERNAME, userName);
ppOne.put(ContentModel.PROP_FIRSTNAME, userName.substring(0, userName.length() - 4));
ppOne.put(ContentModel.PROP_LASTNAME, "user");
ppOne.put(ContentModel.PROP_EMAIL, userName + "@email.com");
ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle");
personService.createPerson(ppOne);
txn.commit();
} catch (Exception e) {
txn.rollback();
throw e;
}
}
use of org.alfresco.util.PropertyMap in project alfresco-repository by Alfresco.
the class ChainingUserRegistrySynchronizerTest method newPerson.
/**
* Constructs a description of a test person with a given email.
*
* @param userName
* the user name
* @param email
* the email
* @return the node description
*/
private NodeDescription newPerson(String userName, String email) {
NodeDescription person = new NodeDescription(userName);
PropertyMap properties = person.getProperties();
properties.put(ContentModel.PROP_USERNAME, userName);
properties.put(ContentModel.PROP_FIRSTNAME, userName + "F");
properties.put(ContentModel.PROP_LASTNAME, userName + "L");
properties.put(ContentModel.PROP_EMAIL, email);
person.setLastModified(new Date());
return person;
}
use of org.alfresco.util.PropertyMap in project alfresco-repository by Alfresco.
the class TestPersonManager method makePersonNode.
private NodeRef makePersonNode(String userName) {
PropertyMap personProps = makePersonProperties(userName);
NodeRef person = personService.createPerson(personProps);
people.put(userName, person);
return person;
}
Aggregations