Search in sources :

Example 71 with FileInfo

use of org.alfresco.service.cmr.model.FileInfo in project alfresco-remote-api by Alfresco.

the class RemoteFileFolderLoaderTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    this.repositoryHelper = (Repository) getServer().getApplicationContext().getBean("repositoryHelper");
    this.nodeService = (NodeService) getServer().getApplicationContext().getBean("nodeService");
    this.transactionService = (TransactionService) getServer().getApplicationContext().getBean("TransactionService");
    this.fileFolderService = (FileFolderService) getServer().getApplicationContext().getBean("FileFolderService");
    // Get the path of the shared folder home
    final NodeRef companyHomeNodeRef = repositoryHelper.getCompanyHome();
    final NodeRef sharedHomeNodeRef = repositoryHelper.getSharedHome();
    RetryingTransactionCallback<NodeRef> createFolderWork = new RetryingTransactionCallback<NodeRef>() {

        @Override
        public NodeRef execute() throws Throwable {
            List<FileInfo> sharedHomeFileInfos = fileFolderService.getNamePath(companyHomeNodeRef, sharedHomeNodeRef);
            sharedHomePath = "/" + sharedHomeFileInfos.get(0).getName();
            String folderName = UUID.randomUUID().toString();
            // Create a folder
            FileInfo folderInfo = fileFolderService.create(sharedHomeNodeRef, folderName, ContentModel.TYPE_FOLDER);
            loadHomePath = sharedHomePath + "/" + folderName;
            // Done
            return folderInfo.getNodeRef();
        }
    };
    // Will be cleared later
    AuthenticationUtil.pushAuthentication();
    AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
    loadHomeNodeRef = transactionService.getRetryingTransactionHelper().doInTransaction(createFolderWork);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) FileInfo(org.alfresco.service.cmr.model.FileInfo) RetryingTransactionCallback(org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)

Example 72 with FileInfo

use of org.alfresco.service.cmr.model.FileInfo 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 73 with FileInfo

use of org.alfresco.service.cmr.model.FileInfo in project alfresco-remote-api by Alfresco.

the class WebDAVHelperIntegrationTest method canGetNodeForRootFolderPath.

@Test
public void canGetNodeForRootFolderPath() throws FileNotFoundException {
    FileInfo folderInfo = fileFolderService.create(rootFolder, "my_folder", ContentModel.TYPE_FOLDER);
    fileFolderService.create(folderInfo.getNodeRef(), "my_file.txt", ContentModel.TYPE_CONTENT);
    FileInfo found = webDAVHelper.getNodeForPath(rootFolder, "/");
    assertEquals(rootFolder, found.getNodeRef());
}
Also used : FileInfo(org.alfresco.service.cmr.model.FileInfo) Test(org.junit.Test)

Example 74 with FileInfo

use of org.alfresco.service.cmr.model.FileInfo in project alfresco-remote-api by Alfresco.

the class WebDAVHelperIntegrationTest method cannotGetNodeForPathWithIncorrectCase.

@Test
public void cannotGetNodeForPathWithIncorrectCase() throws FileNotFoundException {
    FileInfo folderInfo = fileFolderService.create(rootFolder, "my_folder", ContentModel.TYPE_FOLDER);
    fileFolderService.create(folderInfo.getNodeRef(), "my_file.txt", ContentModel.TYPE_CONTENT);
    try {
        webDAVHelper.getNodeForPath(rootFolder, "My_Folder/My_File.txt");
        fail("FileNotFoundException should have been thrown.");
    } catch (FileNotFoundException e) {
    // Got here, good.
    }
}
Also used : FileInfo(org.alfresco.service.cmr.model.FileInfo) FileNotFoundException(org.alfresco.service.cmr.model.FileNotFoundException) Test(org.junit.Test)

Example 75 with FileInfo

use of org.alfresco.service.cmr.model.FileInfo in project alfresco-remote-api by Alfresco.

the class WebDAVHelperIntegrationTest method cannotGetNodeForFolderPathWithIncorrectCase.

@Test
public void cannotGetNodeForFolderPathWithIncorrectCase() throws FileNotFoundException {
    FileInfo folderInfo = fileFolderService.create(rootFolder, "my_folder", ContentModel.TYPE_FOLDER);
    fileFolderService.create(folderInfo.getNodeRef(), "my_file.txt", ContentModel.TYPE_CONTENT);
    try {
        webDAVHelper.getNodeForPath(rootFolder, "My_Folder");
        fail("FileNotFoundException should have been thrown.");
    } catch (FileNotFoundException e) {
    // Got here, good.
    }
}
Also used : FileInfo(org.alfresco.service.cmr.model.FileInfo) FileNotFoundException(org.alfresco.service.cmr.model.FileNotFoundException) Test(org.junit.Test)

Aggregations

FileInfo (org.alfresco.service.cmr.model.FileInfo)101 NodeRef (org.alfresco.service.cmr.repository.NodeRef)82 WebApiDescription (org.alfresco.rest.framework.WebApiDescription)34 FileNotFoundException (org.alfresco.service.cmr.model.FileNotFoundException)26 HashMap (java.util.HashMap)20 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)20 QName (org.alfresco.service.namespace.QName)20 AbstractList (java.util.AbstractList)13 UserInfo (org.alfresco.rest.api.model.UserInfo)13 WebApiParam (org.alfresco.rest.framework.WebApiParam)11 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)10 AccessDeniedException (org.alfresco.repo.security.permissions.AccessDeniedException)10 FileFolderService (org.alfresco.service.cmr.model.FileFolderService)9 IOException (java.io.IOException)8 EntityNotFoundException (org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)8 Serializable (java.io.Serializable)7 List (java.util.List)7 ContentWriter (org.alfresco.service.cmr.repository.ContentWriter)7 FacesContext (javax.faces.context.FacesContext)6