Search in sources :

Example 16 with ContentService

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;
    }
}
Also used : ContentReader(org.alfresco.service.cmr.repository.ContentReader) ContentService(org.alfresco.service.cmr.repository.ContentService)

Example 17 with ContentService

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();
}
Also used : TransactionService(org.alfresco.service.transaction.TransactionService) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) NodeService(org.alfresco.service.cmr.repository.NodeService) FileFolderService(org.alfresco.service.cmr.model.FileFolderService) ContentService(org.alfresco.service.cmr.repository.ContentService) NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) SearchService(org.alfresco.service.cmr.search.SearchService) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Before(org.junit.Before)

Example 18 with ContentService

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");
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Repository(org.alfresco.repo.model.Repository) PropertyMap(org.alfresco.util.PropertyMap) AuthenticationComponent(org.alfresco.repo.security.authentication.AuthenticationComponent) NodeService(org.alfresco.service.cmr.repository.NodeService) PersonService(org.alfresco.service.cmr.security.PersonService) ContentService(org.alfresco.service.cmr.repository.ContentService) MutableAuthenticationService(org.alfresco.service.cmr.security.MutableAuthenticationService)

Aggregations

ContentService (org.alfresco.service.cmr.repository.ContentService)18 NodeRef (org.alfresco.service.cmr.repository.NodeRef)12 ContentReader (org.alfresco.service.cmr.repository.ContentReader)9 ContentWriter (org.alfresco.service.cmr.repository.ContentWriter)6 QName (org.alfresco.service.namespace.QName)6 ServiceRegistry (org.alfresco.service.ServiceRegistry)5 NodeService (org.alfresco.service.cmr.repository.NodeService)5 Serializable (java.io.Serializable)4 StringTokenizer (java.util.StringTokenizer)3 FacesContext (javax.faces.context.FacesContext)3 FileInfo (org.alfresco.service.cmr.model.FileInfo)3 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)3 InputStream (java.io.InputStream)2 SocketException (java.net.SocketException)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Locale (java.util.Locale)2 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)2 DictionaryService (org.alfresco.service.cmr.dictionary.DictionaryService)2 FileFolderService (org.alfresco.service.cmr.model.FileFolderService)2