Search in sources :

Example 66 with PropertyMap

use of org.alfresco.util.PropertyMap in project alfresco-remote-api by Alfresco.

the class LinksRestApiTest method createUser.

private void createUser(String userName, String role, String siteName) {
    // if user with given user name doesn't already exist then create user
    if (this.authenticationService.authenticationExists(userName) == false) {
        // create user
        this.authenticationService.createAuthentication(userName, "password".toCharArray());
        // create person properties
        PropertyMap personProps = new PropertyMap();
        personProps.put(ContentModel.PROP_USERNAME, userName);
        personProps.put(ContentModel.PROP_FIRSTNAME, USERDETAILS_FIRSTNAME);
        personProps.put(ContentModel.PROP_LASTNAME, USERDETAILS_LASTNAME);
        personProps.put(ContentModel.PROP_EMAIL, "FirstName123.LastName123@email.com");
        personProps.put(ContentModel.PROP_JOBTITLE, "JobTitle123");
        personProps.put(ContentModel.PROP_JOBTITLE, "Organisation123");
        // create person node for user
        this.personService.createPerson(personProps);
    }
    // add the user as a member with the given role
    this.siteService.setMembership(siteName, userName, role);
}
Also used : PropertyMap(org.alfresco.util.PropertyMap)

Example 67 with PropertyMap

use of org.alfresco.util.PropertyMap in project alfresco-remote-api by Alfresco.

the class FacetRestApiTest method createUser.

private void createUser(String userName) {
    if (!authenticationService.authenticationExists(userName)) {
        authenticationService.createAuthentication(userName, "PWD".toCharArray());
    }
    if (!personService.personExists(userName)) {
        PropertyMap ppOne = new PropertyMap(4);
        ppOne.put(ContentModel.PROP_USERNAME, userName);
        ppOne.put(ContentModel.PROP_FIRSTNAME, "firstName");
        ppOne.put(ContentModel.PROP_LASTNAME, "lastName");
        ppOne.put(ContentModel.PROP_EMAIL, "email@email.com");
        ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle");
        personService.createPerson(ppOne);
    }
}
Also used : PropertyMap(org.alfresco.util.PropertyMap)

Example 68 with PropertyMap

use of org.alfresco.util.PropertyMap in project alfresco-remote-api by Alfresco.

the class InviteServiceTest method createPerson.

private void createPerson(String firstName, String lastName, String userName, String emailAddress) {
    // if user with given user name doesn't already exist then create user
    if (this.authenticationService.authenticationExists(userName) == false) {
        // create user
        this.authenticationService.createAuthentication(userName, "password".toCharArray());
    }
    // person
    if (this.personService.personExists(userName) == false) {
        // create person properties
        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, emailAddress);
        personProps.put(ContentModel.PROP_JOBTITLE, PERSON_JOBTITLE);
        personProps.put(ContentModel.PROP_ORGANIZATION, PERSON_ORG);
        // create person node for user
        this.personService.createPerson(personProps);
    }
}
Also used : PropertyMap(org.alfresco.util.PropertyMap)

Example 69 with PropertyMap

use of org.alfresco.util.PropertyMap in project alfresco-remote-api by Alfresco.

the class PersonSearchTest method createUser.

private void createUser(String userName) {
    if (this.authenticationService.authenticationExists(userName) == false) {
        this.authenticationService.createAuthentication(userName, "PWD".toCharArray());
        PropertyMap ppOne = new PropertyMap(4);
        ppOne.put(ContentModel.PROP_USERNAME, userName);
        ppOne.put(ContentModel.PROP_FIRSTNAME, "firstName");
        ppOne.put(ContentModel.PROP_LASTNAME, "lastName");
        ppOne.put(ContentModel.PROP_EMAIL, "email@email.com");
        ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle");
        this.personService.createPerson(ppOne);
    }
}
Also used : PropertyMap(org.alfresco.util.PropertyMap)

Example 70 with PropertyMap

use of org.alfresco.util.PropertyMap in project records-management by Alfresco.

the class RecordableVersionServiceImpl method createNewRecordedVersion.

/**
 * Creates a new recorded version
 *
 * @param sourceTypeRef source type name
 * @param versionHistoryRef version history reference
 * @param standardVersionProperties standard version properties
 * @param versionProperties version properties
 * @param versionNumber version number
 * @param nodeDetails policy scope
 * @return {@link NodeRef} record version
 */
protected NodeRef createNewRecordedVersion(QName sourceTypeRef, NodeRef versionHistoryRef, Map<QName, Serializable> standardVersionProperties, Map<String, Serializable> versionProperties, int versionNumber, PolicyScope nodeDetails) {
    NodeRef versionNodeRef = null;
    // Disable auto-version behaviour
    policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_VERSIONABLE);
    // disable other behaviours that we don't want to trigger during this process
    policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
    policyBehaviourFilter.disableBehaviour(ContentModel.TYPE_MULTILINGUAL_CONTAINER);
    // disable model security check
    modelSecurityService.disable();
    // disable property editable check
    recordService.disablePropertyEditableCheck();
    try {
        // get the destination file plan
        final NodeRef filePlan = (NodeRef) versionProperties.get(KEY_FILE_PLAN);
        if (filePlan == null) {
            throw new AlfrescoRuntimeException("Can't create a new recorded version, because no file plan has been specified in the version properties.");
        }
        // create a copy of the source node and place in the file plan
        final NodeRef nodeRef = (NodeRef) standardVersionProperties.get(Version2Model.PROP_QNAME_FROZEN_NODE_REF);
        cmObjectType.disableCopy();
        try {
            // create record
            final NodeRef record = recordService.createRecordFromCopy(filePlan, nodeRef);
            // apply version record aspect to record
            final PropertyMap versionRecordProps = new PropertyMap(3);
            versionRecordProps.put(PROP_VERSIONED_NODEREF, nodeRef);
            versionRecordProps.put(RecordableVersionModel.PROP_VERSION_LABEL, standardVersionProperties.get(QName.createQName(Version2Model.NAMESPACE_URI, Version2Model.PROP_VERSION_LABEL)));
            versionRecordProps.put(RecordableVersionModel.PROP_VERSION_DESCRIPTION, standardVersionProperties.get(QName.createQName(Version2Model.NAMESPACE_URI, Version2Model.PROP_VERSION_DESCRIPTION)));
            // run as system as we can't be sure if the user has add aspect rights
            authenticationUtil.runAsSystem(new RunAsWork<Void>() {

                @Override
                public Void doWork() throws Exception {
                    nodeService.addAspect(record, ASPECT_VERSION_RECORD, versionRecordProps);
                    return null;
                }
            });
            // wire record up to previous record
            linkToPreviousVersionRecord(nodeRef, record);
            // create version nodeRef
            ChildAssociationRef childAssocRef = dbNodeService.createNode(versionHistoryRef, Version2Model.CHILD_QNAME_VERSIONS, QName.createQName(Version2Model.NAMESPACE_URI, Version2Model.CHILD_VERSIONS + "-" + versionNumber), sourceTypeRef, null);
            versionNodeRef = childAssocRef.getChildRef();
            // add aspect with the standard version properties to the 'version' node
            nodeService.addAspect(versionNodeRef, Version2Model.ASPECT_VERSION, standardVersionProperties);
            // add the recordedVersion aspect with link to record
            nodeService.addAspect(versionNodeRef, ASPECT_RECORDED_VERSION, Collections.singletonMap(PROP_RECORD_NODE_REF, (Serializable) record));
            // freeze auditable aspect information
            freezeAuditableAspect(nodeRef, versionNodeRef);
        } finally {
            cmObjectType.enableCopy();
        }
    } finally {
        // enable model security check
        modelSecurityService.enable();
        // enable property editable check
        recordService.enablePropertyEditableCheck();
        // Enable behaviours
        this.policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_VERSIONABLE);
        this.policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
        this.policyBehaviourFilter.enableBehaviour(ContentModel.TYPE_MULTILINGUAL_CONTAINER);
    }
    // If the auditable aspect is not there then add it to the 'version' node (after original aspects have been frozen)
    if (!dbNodeService.hasAspect(versionNodeRef, ContentModel.ASPECT_AUDITABLE)) {
        dbNodeService.addAspect(versionNodeRef, ContentModel.ASPECT_AUDITABLE, null);
    }
    if (logger.isTraceEnabled()) {
        logger.trace("createNewRecordedVersion created (" + versionNumber + ") " + versionNodeRef);
    }
    return versionNodeRef;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Serializable(java.io.Serializable) PropertyMap(org.alfresco.util.PropertyMap) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) ReservedVersionNameException(org.alfresco.service.cmr.version.ReservedVersionNameException) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException)

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