public ToolAnalysis(Configuration configuration) throws CatalogException, AnalysisToolException { this.catalogManager = new CatalogManager(configuration); this.toolManager = new ToolManager(Paths.get(configuration.getToolDir())); this.jobManager = catalogManager.getJobManager(); this.fileManager = catalogManager.getFileManager(); }
@Before public void setUp() throws IOException, CatalogException { super.setUp(); fileManager = catalogManager.getFileManager(); }
@Test public void createNonSharedFile() throws CatalogException { thrown.expect(CatalogAuthorizationException.class); catalogManager.getFileManager().createFolder(studyFqn, Paths.get("folder/").toString(), null, false, null, QueryOptions.empty(), externalSessionId); }
@Test public void createExplicitlyForbiddenFile() throws CatalogException { thrown.expect(CatalogAuthorizationException.class); catalogManager.getFileManager().createFolder(studyFqn, Paths.get("data/d1/d2/d3/folder/").toString(), null, false, null, QueryOptions.empty(), externalSessionId); }
@Test public void readInheritedForbiddenFile() throws CatalogException { thrown.expect(CatalogAuthorizationException.class); catalogManager.getFileManager().get(studyFqn, data_d1_d2_d3_d4, null, externalSessionId); }
@Test public void readNonSharedFile() throws CatalogException { thrown.expect(CatalogAuthorizationException.class); catalogManager.getFileManager().get(studyFqn, data, null, externalSessionId); }
@Test public void readExplicitlyForbiddenFile() throws CatalogException { thrown.expect(CatalogAuthorizationException.class); catalogManager.getFileManager().get(studyFqn, data_d1_d2_d3, null, externalSessionId); }
@Test public void testCreateFileInLinkedFolder() throws Exception { // Create an empty folder Path dir = catalogManagerResource.getOpencgaHome().resolve("folder_to_link"); Files.createDirectory(dir); URI uri = dir.toUri(); // Link the folder in the root link(uri, "", studyFqn, new ObjectMap(), sessionIdUser); File file = catalogManager.getFileManager().create(studyFqn, File.Type.FILE, File.Format.PLAIN, File.Bioformat .NONE, "folder_to_link/file.txt", null, "", null, 0, -1, null, (long) -1, null, null, false, null, null, sessionIdUser).first(); assertEquals(uri.resolve("file.txt"), file.getUri()); }
@Test public void renameFileAlreadyExists() throws CatalogException { catalogManager.getFileManager().createFolder(studyFqn, "analysis/", new File.FileStatus(), false, "", new QueryOptions(), sessionIdUser); thrown.expect(CatalogException.class); thrown.expectMessage("already exists"); catalogManager.getFileManager().rename(studyFqn, "data/", "analysis", sessionIdUser); }
public static File createFile(String path, boolean indexed) throws CatalogException { File file = catalog.getFileManager().create("s1", File.Type.FILE, File.Format.VCF, File.Bioformat.VARIANT, path, null, null, null, 10, -1, null, -1, null, null, true, "", null, sessionId).first(); if (indexed) { int release = catalog.getProjectManager().get("p1", null, sessionId).first().getCurrentRelease(); catalog.getFileManager().updateFileIndexStatus(file, Status.READY, "", release, sessionId); } return file; }
@Test public void unlinkNonExternalFile() throws CatalogException, IOException { File file = catalogManager.getFileManager().create(studyFqn, File.Type.FILE, File.Format.PLAIN, File.Bioformat.NONE, "item." + TimeUtils.getTimeMillis() + ".txt", null, "file at root", null, 0, -1, null, (long) -1, null, null, true, null, null, userSessionId).first(); // Now we try to unlink it thrown.expect(CatalogException.class); thrown.expectMessage("use delete instead"); catalogManager.getFileManager().unlink(studyFqn, file.getPath(), userSessionId); }
@Test public void readInheritedSharedFile() throws CatalogException { QueryResult<File> file = catalogManager.getFileManager().get(studyFqn, data_d1_d2, null, externalSessionId); assertEquals(1, file.getNumResults()); }
@Test public void readExplicitlySharedFile() throws CatalogException { QueryResult<File> file = catalogManager.getFileManager().get(studyFqn, data_d1_d2_d3_d4_txt, null, externalSessionId); assertEquals(1, file.getNumResults()); }
@Test public void createFileNoStudyMember() throws CatalogException, IOException { String newUser = "newUser"; catalogManager.getUserManager().create(newUser, newUser, "asda@mail.com", password, "org", 1000L, Account.FULL, null, null); String sessionId = catalogManager.getUserManager().login(newUser, password); thrown.expect(CatalogAuthorizationException.class); catalogManager.getFileManager().createFolder(studyFqn, Paths.get("data/my_folder/").toString(), null, false, null, QueryOptions.empty(), sessionId); }
@Test public void testSearchFileFail1() throws CatalogException { thrown.expect(CatalogDBException.class); catalogManager.getFileManager().get(studyFqn, new Query(FileDBAdaptor.QueryParams.NATTRIBUTES.key() + ".numValue", "==NotANumber"), null, sessionIdUser); }
@Test public void testDeleteLeafFolder() throws CatalogException, IOException { File deletable = catalogManager.getFileManager().get(studyFqn2, "/data/test/folder/", QueryOptions.empty(), sessionIdUser).first(); deleteFolderAndCheck(deletable); }
@Test public void readFileForbiddenForUser() throws CatalogException { // Remove all permissions to the admin group in that folder catalogManager.getStudyManager().createGroup(studyFqn, groupMember, externalUser, ownerSessionId); catalogManager.getStudyManager().updateAcl(Arrays.asList(studyFqn), groupMember, new Study.StudyAclParams("", AclParams.Action.SET, "admin"), ownerSessionId); fileManager.updateAcl(studyFqn, Arrays.asList(data_d1_d2), externalUser, new File.FileAclParams(DENY_FILE_PERMISSIONS, AclParams.Action.SET, null), ownerSessionId); thrown.expect(CatalogAuthorizationException.class); catalogManager.getFileManager().get(studyFqn, data_d1_d2, null, externalSessionId); }
protected File create(String studyId, URI uri, String path) throws IOException, CatalogException { File file; file = fileMetadataReader.create(studyId, uri, path, "", true, null, sessionId).first(); // File.Format format = FormatDetector.detect(uri); // File.Bioformat bioformat = BioformatDetector.detect(uri); // file = catalogManager.createFile(studyId, format, bioformat, "data/vcfs/", "", true, -1, sessionId).first(); catalogFileUtils.upload(uri, file, null, sessionId, false, false, true, false, Long.MAX_VALUE); return catalogManager.getFileManager().get(studyId, file.getId(), null, sessionId).first(); }
@Test public void readFileNoStudyMember() throws CatalogException, IOException { String newUser = "newUser"; catalogManager.getUserManager().create(newUser, newUser, "asda@mail.com", password, "org", 1000L, Account.FULL, null, null); String sessionId = catalogManager.getUserManager().login(newUser, password); thrown.expect(CatalogAuthorizationException.class); catalogManager.getFileManager().get(studyFqn, data, null, sessionId); }
@Test public void testIndex1() throws Exception { indexFile(inputFile1, new QueryOptions(), outputId); Assert.assertEquals(FileIndex.IndexStatus.READY, catalogManager.getFileManager().get(studyId, inputFile1.getPath(), null, sessionId).first().getIndex().getStatus().getName()); Assert.assertNull(catalogManager.getFileManager().get(studyId, inputFile2.getPath(), null, sessionId).first().getIndex().getStatus()); }