Search in sources :

Example 96 with PropertyMap

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
    }
}
Also used : PropertyMap(org.alfresco.util.PropertyMap) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException)

Example 97 with PropertyMap

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");
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) PropertyMap(org.alfresco.util.PropertyMap) RetryingTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper)

Example 98 with PropertyMap

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;
    }
}
Also used : UserTransaction(javax.transaction.UserTransaction) PropertyMap(org.alfresco.util.PropertyMap) DuplicateChildNodeNameException(org.alfresco.service.cmr.repository.DuplicateChildNodeNameException) SystemException(javax.transaction.SystemException)

Example 99 with PropertyMap

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;
}
Also used : PropertyMap(org.alfresco.util.PropertyMap)

Example 100 with PropertyMap

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;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) PropertyMap(org.alfresco.util.PropertyMap)

Aggregations

PropertyMap (org.alfresco.util.PropertyMap)111 NodeRef (org.alfresco.service.cmr.repository.NodeRef)43 ContentWriter (org.alfresco.service.cmr.repository.ContentWriter)15 Test (org.junit.Test)14 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)13 QName (org.alfresco.service.namespace.QName)11 Serializable (java.io.Serializable)9 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)8 ContentReader (org.alfresco.service.cmr.repository.ContentReader)8 BaseSpringTest (org.alfresco.util.BaseSpringTest)8 FileContentReader (org.alfresco.repo.content.filestore.FileContentReader)7 DictionaryException (org.alfresco.service.cmr.dictionary.DictionaryException)7 ExpectedException (org.junit.rules.ExpectedException)7 ApplicationContext (org.springframework.context.ApplicationContext)7 StoreRef (org.alfresco.service.cmr.repository.StoreRef)6 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)5 NodeService (org.alfresco.service.cmr.repository.NodeService)5 Date (java.util.Date)4 HashMap (java.util.HashMap)4 ServiceRegistry (org.alfresco.service.ServiceRegistry)4