Search in sources :

Example 11 with PropertyMap

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

the class AbstractSiteServiceTest method createPerson.

protected void createPerson(String 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");
    this.personService.createPerson(ppOne);
}
Also used : PropertyMap(org.alfresco.util.PropertyMap)

Example 12 with PropertyMap

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

the class CommentsApiTest method createUser.

private void createUser(String userName) {
    // if user with given user name doesn't already exist then create user
    if (!authenticationService.authenticationExists(userName)) {
        // create user
        authenticationService.createAuthentication(userName, "password".toCharArray());
    }
    if (!personService.personExists(userName)) {
        // create person properties
        PropertyMap personProps = new PropertyMap();
        personProps.put(ContentModel.PROP_USERNAME, userName);
        personProps.put(ContentModel.PROP_FIRSTNAME, "FirstNameTest");
        personProps.put(ContentModel.PROP_LASTNAME, "LastNameTest");
        personProps.put(ContentModel.PROP_EMAIL, "FirstNameTest.LastNameTest@test.com");
        personProps.put(ContentModel.PROP_JOBTITLE, "JobTitleTest");
        // create person node for user
        personService.createPerson(personProps);
    }
}
Also used : PropertyMap(org.alfresco.util.PropertyMap)

Example 13 with PropertyMap

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

the class ContentGetTest method createUser.

private void createUser(String userName) {
    if (!this.authenticationService.authenticationExists(userName)) {
        this.authenticationService.createAuthentication(userName, "PWD".toCharArray());
        PropertyMap ppOne = new PropertyMap(5);
        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 14 with PropertyMap

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

the class DiscussionRestApiTest 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)) {
        // create user
        this.authenticationService.createAuthentication(userName, "password".toCharArray());
    }
    if (!this.personService.personExists(userName)) {
        // create person properties
        PropertyMap personProps = new PropertyMap();
        personProps.put(ContentModel.PROP_USERNAME, userName);
        personProps.put(ContentModel.PROP_FIRSTNAME, "FirstName123");
        personProps.put(ContentModel.PROP_LASTNAME, "LastName123");
        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);
    // Give the test user access to the test node
    // They need to be able to read it, and create children of it
    permissionService.setPermission(FORUM_NODE, userName, PermissionService.READ, true);
    permissionService.setPermission(FORUM_NODE, userName, PermissionService.CREATE_CHILDREN, true);
}
Also used : PropertyMap(org.alfresco.util.PropertyMap)

Example 15 with PropertyMap

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

the class RecordServiceImpl method createRecord.

/**
 * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#createRecord(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, boolean)
 */
@Override
public void createRecord(final NodeRef filePlan, final NodeRef nodeRef, final boolean isLinked) {
    // filePlan can be null. In this case the default RM site will be used.
    ParameterCheck.mandatory("nodeRef", nodeRef);
    ParameterCheck.mandatory("isLinked", isLinked);
    recordCreationSanityCheckOnNode(nodeRef);
    final NodeRef checkedFilePlan = recordCreationSanityCheckOnFilePlan(filePlan);
    invokeBeforeRecordDeclaration(nodeRef);
    // do the work of creating the record as the system user
    AuthenticationUtil.runAsSystem(new RunAsWork<Void>() {

        @Override
        public Void doWork() {
            if (!nodeService.hasAspect(nodeRef, ASPECT_RECORD)) {
                // disable delete rules
                ruleService.disableRuleType("outbound");
                try {
                    // get the new record container for the file plan
                    NodeRef newRecordContainer = filePlanService.getUnfiledContainer(checkedFilePlan);
                    if (newRecordContainer == null) {
                        throw new AlfrescoRuntimeException("Unable to create record, because new record container could not be found.");
                    }
                    // get the documents readers and writers
                    Pair<Set<String>, Set<String>> readersAndWriters = extendedPermissionService.getReadersAndWriters(nodeRef);
                    // get the current owner
                    String owner = ownableService.getOwner(nodeRef);
                    // get the documents primary parent assoc
                    ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(nodeRef);
                    // get the latest version record, if there is one
                    NodeRef latestVersionRecord = getLatestVersionRecord(nodeRef);
                    behaviourFilter.disableBehaviour();
                    try {
                        // move the document into the file plan
                        nodeService.moveNode(nodeRef, newRecordContainer, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName());
                    } finally {
                        behaviourFilter.enableBehaviour();
                    }
                    // save the information about the originating details
                    Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>(3);
                    aspectProperties.put(PROP_RECORD_ORIGINATING_LOCATION, parentAssoc.getParentRef());
                    aspectProperties.put(PROP_RECORD_ORIGINATING_USER_ID, owner);
                    aspectProperties.put(PROP_RECORD_ORIGINATING_CREATION_DATE, new Date());
                    nodeService.addAspect(nodeRef, ASPECT_RECORD_ORIGINATING_DETAILS, aspectProperties);
                    // make the document a record
                    makeRecord(nodeRef);
                    generateRecordIdentifier(nodeService, identifierService, nodeRef);
                    if (latestVersionRecord != null) {
                        // indicate that this is the 'final' record version
                        PropertyMap versionRecordProps = new PropertyMap(2);
                        versionRecordProps.put(RecordableVersionModel.PROP_VERSION_LABEL, I18NUtil.getMessage(FINAL_VERSION));
                        versionRecordProps.put(RecordableVersionModel.PROP_VERSION_DESCRIPTION, I18NUtil.getMessage(FINAL_DESCRIPTION));
                        nodeService.addAspect(nodeRef, RecordableVersionModel.ASPECT_VERSION_RECORD, versionRecordProps);
                        // link to previous version
                        relationshipService.addRelationship(CUSTOM_REF_VERSIONS.getLocalName(), nodeRef, latestVersionRecord);
                    }
                    if (isLinked) {
                        // turn off rules
                        ruleService.disableRules();
                        try {
                            // maintain the original primary location
                            nodeService.addChild(parentAssoc.getParentRef(), nodeRef, parentAssoc.getTypeQName(), parentAssoc.getQName());
                            // set the extended security
                            extendedSecurityService.set(nodeRef, readersAndWriters);
                        } finally {
                            ruleService.enableRules();
                        }
                    }
                } finally {
                    ruleService.enableRuleType("outbound");
                }
            }
            return null;
        }
    });
    invokeOnRecordDeclaration(nodeRef);
}
Also used : Serializable(java.io.Serializable) QName(org.alfresco.service.namespace.QName) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) Date(java.util.Date) NodeRef(org.alfresco.service.cmr.repository.NodeRef) PropertyMap(org.alfresco.util.PropertyMap) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) Map(java.util.Map) PropertyMap(org.alfresco.util.PropertyMap) HashMap(java.util.HashMap) Pair(org.alfresco.util.Pair)

Aggregations

PropertyMap (org.alfresco.util.PropertyMap)38 NodeRef (org.alfresco.service.cmr.repository.NodeRef)6 Serializable (java.io.Serializable)3 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)3 HashMap (java.util.HashMap)2 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)2 ContentWriter (org.alfresco.service.cmr.repository.ContentWriter)2 Version (org.alfresco.service.cmr.version.Version)2 QName (org.alfresco.service.namespace.QName)2 Date (java.util.Date)1 Map (java.util.Map)1 Set (java.util.Set)1 Relationship (org.alfresco.module.org_alfresco_module_rm.relationship.Relationship)1 Role (org.alfresco.module.org_alfresco_module_rm.role.Role)1 Repository (org.alfresco.repo.model.Repository)1 AuthenticationComponent (org.alfresco.repo.security.authentication.AuthenticationComponent)1 RunAsWork (org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork)1 ContentService (org.alfresco.service.cmr.repository.ContentService)1 NodeService (org.alfresco.service.cmr.repository.NodeService)1 MutableAuthenticationService (org.alfresco.service.cmr.security.MutableAuthenticationService)1