use of org.alfresco.service.cmr.security.PersonService in project alfresco-remote-api by Alfresco.
the class ArchivedNodeState method create.
public static ArchivedNodeState create(NodeRef archivedNode, ServiceRegistry serviceRegistry) {
ArchivedNodeState result = new ArchivedNodeState();
NodeService nodeService = serviceRegistry.getNodeService();
Map<QName, Serializable> properties = nodeService.getProperties(archivedNode);
result.archivedNodeRef = archivedNode;
result.archivedBy = (String) properties.get(ContentModel.PROP_ARCHIVED_BY);
result.archivedDate = (Date) properties.get(ContentModel.PROP_ARCHIVED_DATE);
result.name = (String) properties.get(ContentModel.PROP_NAME);
result.title = (String) properties.get(ContentModel.PROP_TITLE);
result.description = (String) properties.get(ContentModel.PROP_DESCRIPTION);
QName type = nodeService.getType(archivedNode);
result.isContentType = (type.equals(ContentModel.TYPE_CONTENT) || serviceRegistry.getDictionaryService().isSubClass(type, ContentModel.TYPE_CONTENT));
result.nodeType = type.toPrefixString(serviceRegistry.getNamespaceService());
PersonService personService = serviceRegistry.getPersonService();
if (result.archivedBy != null && personService.personExists(result.archivedBy)) {
NodeRef personNodeRef = personService.getPerson(result.archivedBy, false);
Map<QName, Serializable> personProps = nodeService.getProperties(personNodeRef);
result.firstName = (String) personProps.get(ContentModel.PROP_FIRSTNAME);
result.lastName = (String) personProps.get(ContentModel.PROP_LASTNAME);
}
ChildAssociationRef originalParentAssoc = (ChildAssociationRef) properties.get(ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC);
if (serviceRegistry.getPermissionService().hasPermission(originalParentAssoc.getParentRef(), PermissionService.READ).equals(AccessStatus.ALLOWED) && nodeService.exists(originalParentAssoc.getParentRef())) {
result.displayPath = PathUtil.getDisplayPath(nodeService.getPath(originalParentAssoc.getParentRef()), true);
} else {
result.displayPath = "";
}
return result;
}
use of org.alfresco.service.cmr.security.PersonService in project alfresco-remote-api by Alfresco.
the class RunningActionRestApiTest method setUp.
@SuppressWarnings("unchecked")
@Override
protected void setUp() throws Exception {
super.setUp();
ApplicationContext appContext = getServer().getApplicationContext();
nodeService = (NodeService) appContext.getBean("NodeService");
replicationService = (ReplicationService) appContext.getBean("ReplicationService");
actionTrackingService = (ActionTrackingService) appContext.getBean("actionTrackingService");
repositoryHelper = (Repository) appContext.getBean("repositoryHelper");
transactionService = (TransactionService) appContext.getBean("transactionService");
executingActionsCache = (SimpleCache<String, ExecutionDetails>) appContext.getBean("executingActionsCache");
MutableAuthenticationService authenticationService = (MutableAuthenticationService) appContext.getBean("AuthenticationService");
PersonService personService = (PersonService) appContext.getBean("PersonService");
personManager = new TestPersonManager(authenticationService, personService, nodeService);
UserTransaction txn = transactionService.getUserTransaction();
txn.begin();
personManager.createPerson(USER_NORMAL);
// Ensure we start with no replication definitions
// (eg another test left them behind)
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
for (ReplicationDefinition rd : replicationService.loadReplicationDefinitions()) {
replicationService.deleteReplicationDefinition(rd);
}
txn.commit();
// Grab a reference to the data dictionary
dataDictionary = nodeService.getChildByName(repositoryHelper.getCompanyHome(), ContentModel.ASSOC_CONTAINS, "Data Dictionary");
AuthenticationUtil.clearCurrentSecurityContext();
}
use of org.alfresco.service.cmr.security.PersonService in project alfresco-remote-api by Alfresco.
the class WorkflowModelBuilderTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
namespaceService = new NamespaceServiceMemoryImpl();
namespaceService.registerNamespace("test", URI);
namespaceService.registerNamespace(NamespaceService.CONTENT_MODEL_PREFIX, NamespaceService.CONTENT_MODEL_1_0_URI);
namespaceService.registerNamespace(NamespaceService.BPM_MODEL_PREFIX, NamespaceService.BPM_MODEL_1_0_URI);
personService = mock(PersonService.class);
when(personService.getPerson(userName)).thenReturn(person);
when(personService.personExists(userName)).thenReturn(true);
nodeService = mock(NodeService.class);
Map<QName, Serializable> personProps = new HashMap<QName, Serializable>();
personProps.put(ContentModel.PROP_USERNAME, userName);
personProps.put(ContentModel.PROP_FIRSTNAME, firstName);
personProps.put(ContentModel.PROP_LASTNAME, lastName);
when(nodeService.getProperties(person)).thenReturn(personProps);
when(nodeService.getProperty(person, ContentModel.PROP_USERNAME)).thenReturn(userName);
when(nodeService.getProperty(person, ContentModel.PROP_FIRSTNAME)).thenReturn(firstName);
when(nodeService.getProperty(person, ContentModel.PROP_LASTNAME)).thenReturn(lastName);
workflowService = mock(WorkflowService.class);
dictionaryService = mock(DictionaryService.class);
authenticationService = mock(AuthenticationService.class);
builder = new WorkflowModelBuilder(namespaceService, nodeService, authenticationService, personService, workflowService, dictionaryService);
}
use of org.alfresco.service.cmr.security.PersonService in project alfresco-remote-api by Alfresco.
the class DownloadRestApiTest method setUp.
public void setUp() {
// Resolve required services
authenticationService = getServer().getApplicationContext().getBean("AuthenticationService", MutableAuthenticationService.class);
authenticationComponent = getServer().getApplicationContext().getBean("authenticationComponent", AuthenticationComponent.class);
contentService = getServer().getApplicationContext().getBean("ContentService", ContentService.class);
nodeService = getServer().getApplicationContext().getBean("NodeService", NodeService.class);
personService = getServer().getApplicationContext().getBean("PersonService", PersonService.class);
// Authenticate as user
this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
// if user with given user name doesn't already exist then create user
if (this.authenticationService.authenticationExists(TEST_USERNAME) == false) {
// create user
this.authenticationService.createAuthentication(TEST_USERNAME, "password".toCharArray());
// create person properties
PropertyMap personProps = new PropertyMap();
personProps.put(ContentModel.PROP_USERNAME, TEST_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);
}
Repository repositoryHelper = (Repository) getServer().getApplicationContext().getBean("repositoryHelper");
NodeRef companyHome = repositoryHelper.getCompanyHome();
// Create some static test content
rootFolder = createNode(companyHome, "rootFolder", ContentModel.TYPE_FOLDER, AuthenticationUtil.getAdminUserName());
rootFile = createNodeWithTextContent(companyHome, "rootFile", ContentModel.TYPE_CONTENT, AuthenticationUtil.getAdminUserName(), "Root file content");
level1File = createNodeWithTextContent(rootFolder, "level1File", ContentModel.TYPE_CONTENT, AuthenticationUtil.getAdminUserName(), "Level 1 file content");
level1Folder = createNode(rootFolder, "level1Folder", ContentModel.TYPE_FOLDER, AuthenticationUtil.getAdminUserName());
level2File = createNodeWithTextContent(level1Folder, "level2File", ContentModel.TYPE_CONTENT, AuthenticationUtil.getAdminUserName(), "Level 2 file content");
}
use of org.alfresco.service.cmr.security.PersonService in project alfresco-remote-api by Alfresco.
the class BaseCustomModelApiTest method setup.
@Before
public void setup() throws Exception {
authenticationService = applicationContext.getBean("authenticationService", MutableAuthenticationService.class);
personService = applicationContext.getBean("personService", PersonService.class);
customModelService = applicationContext.getBean("customModelService", CustomModelService.class);
final AuthorityService authorityService = applicationContext.getBean("authorityService", AuthorityService.class);
this.nonAdminUserName = createUser("nonAdminUser" + System.currentTimeMillis(), "password", null);
this.customModelAdmin = createUser("customModelAdmin" + System.currentTimeMillis(), "password", null);
users.add(nonAdminUserName);
users.add(customModelAdmin);
// Add 'customModelAdmin' user into 'ALFRESCO_MODEL_ADMINISTRATORS' group
transactionHelper.doInTransaction(new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable {
authorityService.addAuthority(CustomModelServiceImpl.GROUP_ALFRESCO_MODEL_ADMINISTRATORS_AUTHORITY, customModelAdmin);
return null;
}
});
}
Aggregations