use of org.alfresco.service.cmr.repository.ContentService in project acs-community-packaging by Alfresco.
the class UsersBeanProperties method getPersonDescription.
public String getPersonDescription() {
ContentService cs = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getContentService();
ContentReader reader = cs.getReader(this.person.getNodeRef(), ContentModel.PROP_PERSONDESC);
if (reader != null && reader.exists()) {
return Utils.stripUnsafeHTMLTags(reader.getContentString()).replace("\r\n", "<p>");
} else {
return null;
}
}
use of org.alfresco.service.cmr.repository.ContentService in project alfresco-remote-api by Alfresco.
the class MoveMethodTest method setUp.
@Before
public void setUp() throws Exception {
req = new MockHttpServletRequest();
resp = new MockHttpServletResponse();
rootNode = new NodeRef("workspace://SpacesStore/node1");
moveMethod = new MoveMethod() {
@Override
protected LockInfo checkNode(FileInfo fileInfo, boolean ignoreShared, boolean lockMethod) throws WebDAVServerException {
return new LockInfoImpl();
}
@Override
protected LockInfo checkNode(FileInfo fileInfo) throws WebDAVServerException {
return new LockInfoImpl();
}
};
moveMethod.setDetails(req, resp, davHelper, rootNode);
sourceFileInfo = Mockito.mock(FileInfo.class);
when(sourceFileInfo.isFolder()).thenReturn(true);
destPath = "/path/to/dest.doc";
moveMethod.m_strDestinationPath = destPath;
sourcePath = "/path/to/source.doc";
moveMethod.m_strPath = sourcePath;
when(davHelper.getFileFolderService()).thenReturn(mockFileFolderService);
List<String> sourcePathSplit = Arrays.asList("path", "to", "source.doc");
when(davHelper.splitAllPaths(sourcePath)).thenReturn(sourcePathSplit);
List<String> destPathSplit = Arrays.asList("path", "to", "dest.doc");
when(davHelper.splitAllPaths(destPath)).thenReturn(destPathSplit);
when(mockFileFolderService.resolveNamePath(rootNode, sourcePathSplit)).thenReturn(sourceFileInfo);
FileInfo destFileInfo = Mockito.mock(FileInfo.class);
when(mockFileFolderService.resolveNamePath(rootNode, destPathSplit)).thenReturn(destFileInfo);
sourceParentNodeRef = new NodeRef("workspace://SpacesStore/parent");
destParentNodeRef = new NodeRef("workspace://SpacesStore/parent");
sourceNodeRef = new NodeRef("workspace://SpacesStore/sourcefile");
when(davHelper.getLockService()).thenReturn(davLockService);
searchService = ctx.getBean("SearchService", SearchService.class);
fileFolderService = ctx.getBean("FileFolderService", FileFolderService.class);
nodeService = ctx.getBean("NodeService", NodeService.class);
transactionService = ctx.getBean("transactionService", TransactionService.class);
contentService = ctx.getBean("contentService", ContentService.class);
webDAVHelper = ctx.getBean("webDAVHelper", WebDAVHelper.class);
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
repositoryHelper = (Repository) ctx.getBean("repositoryHelper");
companyHomeNodeRef = repositoryHelper.getCompanyHome();
}
use of org.alfresco.service.cmr.repository.ContentService 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");
}
Aggregations