use of org.alfresco.util.PropertyMap in project records-management by Alfresco.
the class RecordableVersionsBaseTest method prepareContent.
protected void prepareContent(NodeRef content) {
// add titled aspect
PropertyMap titledProperties = new PropertyMap(2);
titledProperties.put(ContentModel.PROP_TITLE, "document title");
titledProperties.put(ContentModel.PROP_DESCRIPTION, "document description");
nodeService.addAspect(content, ContentModel.ASPECT_TITLED, titledProperties);
// add ownable aspect
PropertyMap ownableProperties = new PropertyMap(1);
ownableProperties.put(ContentModel.PROP_OWNER, OWNER);
nodeService.addAspect(content, ContentModel.ASPECT_OWNABLE, ownableProperties);
// add Dublin core aspect
PropertyMap dublinCoreProperties = new PropertyMap(2);
dublinCoreProperties.put(QNAME_PUBLISHER, PUBLISHER);
dublinCoreProperties.put(QNAME_SUBJECT, SUBJECT);
nodeService.addAspect(content, ContentModel.ASPECT_DUBLINCORE, dublinCoreProperties);
// add content
ContentWriter writer = contentService.getWriter(content, ContentModel.PROP_CONTENT, true);
writer.setEncoding("UTF-8");
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
writer.putContent(CONTENT);
}
use of org.alfresco.util.PropertyMap in project records-management by Alfresco.
the class AutoRecordableVersionsTest method testVersionRecordsRelated.
/**
* Given that all revisions will be automatically recorded,
* When I update a document 3 times,
* Then all 3 created records will be related together using the "VersionedBy" relationship
*/
public void testVersionRecordsRelated() {
doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator, false) {
/**
* given *
*/
public void given() throws Exception {
doTestInTransaction(new VoidTest() {
@Override
public void runImpl() throws Exception {
// set the recordable version policy
PropertyMap recordableVersionProperties = new PropertyMap(1);
recordableVersionProperties.put(PROP_RECORDABLE_VERSION_POLICY, RecordableVersionPolicy.ALL);
recordableVersionProperties.put(PROP_FILE_PLAN, filePlan);
nodeService.addAspect(dmDocument, RecordableVersionModel.ASPECT_VERSIONABLE, recordableVersionProperties);
// make the node versionable
PropertyMap versionableProperties = new PropertyMap(1);
versionableProperties.put(ContentModel.PROP_INITIAL_VERSION, false);
nodeService.addAspect(dmDocument, ContentModel.ASPECT_VERSIONABLE, versionableProperties);
}
});
}
/**
* when *
*/
public void when() {
// update the content 3 times
updateContent();
updateContent();
updateContent();
}
/**
* then
*/
public void then() {
doTestInTransaction(new VoidTest() {
@Override
public void runImpl() throws Exception {
// check that the record has been recorded
checkRecordedVersion(dmDocument, null, "0.3");
Version version = versionService.getCurrentVersion(dmDocument);
NodeRef record = recordableVersionService.getVersionRecord(version);
boolean foundPrevious = false;
Set<Relationship> relationships = relationshipService.getRelationshipsFrom(record);
assertNotNull(relationships);
assertEquals(1, relationships.size());
for (Relationship relationship : relationships) {
if (relationship.getUniqueName().equals(CUSTOM_REF_VERSIONS.getLocalName())) {
NodeRef previousVersionRecord = relationship.getTarget();
assertNotNull(previousVersionRecord);
foundPrevious = true;
}
}
assertTrue(foundPrevious);
}
});
}
/**
* Helper method to update content of dmDocument
*/
private void updateContent() {
doTestInTransaction(new VoidTest() {
@Override
public void runImpl() throws Exception {
ContentWriter writer = contentService.getWriter(dmDocument, ContentModel.PROP_CONTENT, true);
writer.putContent(MY_NEW_CONTENT);
}
});
}
});
}
use of org.alfresco.util.PropertyMap in project alfresco-repository by Alfresco.
the class People method createPerson.
/**
* Create a Person with the given user name
*
* @param userName the user name of the person to create
* @return the person node (type cm:person) created or null if the user name already exists
*/
public ScriptNode createPerson(String userName) {
ParameterCheck.mandatoryString("userName", userName);
ScriptNode person = null;
PropertyMap properties = new PropertyMap();
properties.put(ContentModel.PROP_USERNAME, userName);
if (!personService.personExists(userName)) {
NodeRef personRef = personService.createPerson(properties);
person = new ScriptNode(personRef, services, getScope());
}
return person;
}
use of org.alfresco.util.PropertyMap in project alfresco-repository by Alfresco.
the class CopyServiceImplTest method testRecursiveCopy.
/**
* Test a potentially recursive copy
*/
public void testRecursiveCopy() {
PropertyMap props = new PropertyMap();
// Need to create a potentially recursive node structure
props.put(ContentModel.PROP_NODE_UUID, "nodeOne");
NodeRef nodeOne = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_CONTAINER, props).getChildRef();
props.put(ContentModel.PROP_NODE_UUID, "nodeTwo");
NodeRef nodeTwo = nodeService.createNode(nodeOne, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_CONTAINER, props).getChildRef();
props.put(ContentModel.PROP_NODE_UUID, "nodeThree");
NodeRef nodeThree = nodeService.createNode(nodeTwo, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_CONTAINER, props).getChildRef();
// Issue a potentialy recursive copy
copyService.copy(nodeOne, nodeThree, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, true);
// System.out.println(
// NodeStoreInspector.dumpNodeStore(nodeService, storeRef));
}
use of org.alfresco.util.PropertyMap in project alfresco-repository by Alfresco.
the class CopyServiceImplTest method setUp.
@Override
protected void setUp() throws Exception {
ctx = ApplicationContextHelper.getApplicationContext();
if (AlfrescoTransactionSupport.isActualTransactionActive()) {
fail("Test started with transaction in progress");
}
ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
// Set the services
transactionService = serviceRegistry.getTransactionService();
nodeService = (NodeService) ctx.getBean("dbNodeService");
publicNodeService = serviceRegistry.getNodeService();
copyService = (CopyService) ctx.getBean("copyService");
contentService = (ContentService) ctx.getBean("contentService");
ruleService = (RuleService) ctx.getBean("ruleService");
actionService = (ActionService) ctx.getBean("actionService");
permissionService = (PermissionService) ctx.getBean("PermissionService");
personService = serviceRegistry.getPersonService();
authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
authenticationService = (MutableAuthenticationService) ctx.getBean("authenticationService");
cociService = (CheckOutCheckInService) ctx.getBean("checkOutCheckInService");
dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO");
authenticationComponent.setSystemUserAsCurrentUser();
// Ensure that a transaction is present
txn = transactionService.getUserTransaction();
txn.begin();
// Create the test model
createTestModel();
// Create the store and get the root node reference
storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
rootNodeRef = nodeService.getRootNode(storeRef);
// Create the node used for copying
ChildAssociationRef childAssocRef = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}test"), TEST_TYPE_QNAME, createTypePropertyBag());
sourceNodeRef = childAssocRef.getChildRef();
// Create another bag of properties
Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>();
aspectProperties.put(PROP3_QNAME_MANDATORY, TEST_VALUE_1);
aspectProperties.put(PROP4_QNAME_OPTIONAL, TEST_VALUE_2);
// Apply the test aspect
nodeService.addAspect(sourceNodeRef, TEST_ASPECT_QNAME, aspectProperties);
nodeService.addAspect(sourceNodeRef, ContentModel.ASPECT_TITLED, null);
// Add a child
ChildAssociationRef temp3 = nodeService.createNode(sourceNodeRef, TEST_CHILD_ASSOC_TYPE_QNAME, TEST_CHILD_ASSOC_QNAME, TEST_TYPE_QNAME, createTypePropertyBag());
childNodeRef = temp3.getChildRef();
// Add a child that is primary
ChildAssociationRef temp2 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}testNonPrimaryChild"), TEST_TYPE_QNAME, createTypePropertyBag());
nonPrimaryChildNodeRef = temp2.getChildRef();
nodeService.addChild(sourceNodeRef, nonPrimaryChildNodeRef, TEST_CHILD_ASSOC_TYPE_QNAME, TEST_CHILD_ASSOC_QNAME2);
// Add a target assoc
ChildAssociationRef temp = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}testAssoc"), TEST_TYPE_QNAME, createTypePropertyBag());
targetNodeRef = temp.getChildRef();
nodeService.createAssociation(sourceNodeRef, targetNodeRef, TEST_ASSOC_TYPE_QNAME);
// Create a node we can use as the destination in a copy
Map<QName, Serializable> destinationProps = new HashMap<QName, Serializable>();
destinationProps.put(PROP1_QNAME_MANDATORY, TEST_VALUE_1);
destinationProps.put(PROP5_QNAME_MANDATORY, TEST_VALUE_3);
destinationProps.put(ContentModel.PROP_CONTENT, CONTENT_DATA_TEXT);
ChildAssociationRef temp5 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}testDestinationNode"), TEST_TYPE_QNAME, destinationProps);
destinationNodeRef = temp5.getChildRef();
// Create two users, for use as part of
// the permission related tests
authenticationService.createAuthentication(USER_1, "PWD".toCharArray());
authenticationService.createAuthentication(USER_2, "PWD".toCharArray());
PropertyMap personProperties = new PropertyMap();
personProperties.put(ContentModel.PROP_USERNAME, USER_1);
personProperties.put(ContentModel.PROP_AUTHORITY_DISPLAY_NAME, "title" + USER_1);
personProperties.put(ContentModel.PROP_FIRSTNAME, "firstName");
personProperties.put(ContentModel.PROP_LASTNAME, "lastName");
personProperties.put(ContentModel.PROP_EMAIL, USER_1 + "@example.com");
personProperties.put(ContentModel.PROP_JOBTITLE, "jobTitle");
personService.createPerson(personProperties);
personProperties = new PropertyMap();
personProperties.put(ContentModel.PROP_USERNAME, USER_2);
personProperties.put(ContentModel.PROP_AUTHORITY_DISPLAY_NAME, "title" + USER_2);
personProperties.put(ContentModel.PROP_FIRSTNAME, "firstName");
personProperties.put(ContentModel.PROP_LASTNAME, "lastName");
personProperties.put(ContentModel.PROP_EMAIL, USER_2 + "@example.com");
personProperties.put(ContentModel.PROP_JOBTITLE, "jobTitle");
personService.createPerson(personProperties);
}
Aggregations