@Deprecated private void checkCanLinkFile(File file, boolean relink) throws CatalogException { String fileStatusEnum = file.getStatus().getName(); if (relink) { if (!fileStatusEnum.equals(File.FileStatus.READY)) { throw new CatalogIOException("Unable to relink a file with status : " + fileStatusEnum); } if (!file.isExternal()) { throw new CatalogIOException("Unable to relink a non linked file"); } } else { if (!fileStatusEnum.equals(File.FileStatus.STAGE) && !fileStatusEnum.equals(File.FileStatus.MISSING)) { throw new CatalogIOException("Unable to link a file with status : " + fileStatusEnum); } } }
@Deprecated public URI getUri(long studyId, String filePath) throws CatalogException { ParamUtils.checkObj(filePath, "filePath"); List<File> parents = getParents(false, INCLUDE_FILE_URI_PATH, filePath, studyId).getResult(); for (File parent : parents) { if (parent.getUri() != null) { if (parent.isExternal()) { throw new CatalogException("Cannot upload files to an external folder"); } String relativePath = filePath.replaceFirst(parent.getPath(), ""); return Paths.get(parent.getUri()).resolve(relativePath).toUri(); } } URI studyUri = getStudyUri(studyId); return filePath.isEmpty() ? studyUri : catalogIOManagerFactory.get(studyUri).getFileUri(studyUri, filePath); }
URI newUri = Paths.get(oldUri).getParent().resolve(newName).toUri(); boolean isExternal = file.isExternal(); //If the file URI is not null, the file is external located. QueryResult<File> result; switch (file.getType()) {
if (!file.isExternal()) { //Do not delete file if is external URI fileUri = catalogManager.getFileManager().getUri(file); CatalogIOManager ioManager = catalogManager.getCatalogIOManagerFactory().get(fileUri);
QueryResult<File> recursiveFileQueryResult = fileDBAdaptor.get(newQuery, options); if (file.isExternal()) { if (!nestedFile.isExternal()) { wrongFiles.add(nestedFile.getPath()); if (nestedFile.isExternal()) { wrongFiles.add(nestedFile.getPath());
fileSolrModel.setExternal(file.isExternal()); fileSolrModel.setSize(file.getSize()); if (file.getSoftware() != null) {
if (!file.isExternal()) { dbAdaptorFactory.getCatalogStudyDBAdaptor().updateDiskUsage(studyId, file.getSize());
assert (fileSolrModel.isExternal() == file.isExternal()); assert (fileSolrModel.getSize() == file.getSize()); assert (fileSolrModel.getSoftware().equals(file.getSoftware().getName()));
if (!file.isExternal()) { throw new CatalogException("Only previously linked files can be unlinked. Please, use delete instead.");
if (file.isExternal()) {
null, sessionIdUser); assertEquals(1, folderQueryResult.getNumResults()); assertTrue(!folderQueryResult.first().isExternal()); assertTrue(folderQueryResult.first().isExternal()); assertTrue(folderQueryResult.first().isExternal()); folderQueryResult = catalogManager.getFileManager().get(studyFqn, new Query(FileDBAdaptor.QueryParams.PATH.key(), "myDirectory/data/test/folder/"), null, sessionIdUser); assertEquals(1, folderQueryResult.getNumResults()); assertTrue(folderQueryResult.first().isExternal());