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);
}
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();
}
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());
}
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.
}
}
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.
}
}
Aggregations