@Deprecated /** * Link an external file into Catalog. Adds an URI to the field File::uri * A file with a uri is an "external" file. Files inside external folders are not external. * * @param file Already existing file. Should be "STAGE" or "MISSING", or have relink == true * @param calculateChecksum Calculate checksum from the new linked file * @param externalUri External file to link * @param createFoundFiles Create a simple catalog file entry for found files. Used only for link folders * @param relink Change the existing link of a file. * @param sessionId User's sessionId * @return Modified file * @throws CatalogException CatalogException */ public File link(File file, boolean calculateChecksum, URI externalUri, boolean createFoundFiles, boolean relink, String sessionId) throws CatalogException { ParamUtils.checkObj(file, "file"); ParamUtils.checkObj(externalUri, "externalUri"); checkCanLinkFile(file, relink); if (file.getType() == File.Type.DIRECTORY) { return linkFolder(file, calculateChecksum, externalUri, createFoundFiles, relink, sessionId); } else { return linkFile(file, calculateChecksum, externalUri, sessionId); } }
private QueryResult<File> create(Study study, File file, boolean parents, String content, QueryOptions options, String sessionId) throws CatalogException { QueryResult<File> queryResult = register(study, file, parents, options, sessionId); if (file.getType() == File.Type.FILE && StringUtils.isNotEmpty(content)) { CatalogIOManager ioManager = catalogIOManagerFactory.getDefault(); // We set parents to true because the file has been successfully registered, which means the directories are already registered // in catalog ioManager.createDirectory(Paths.get(file.getUri()).getParent().toUri(), true); InputStream inputStream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)); ioManager.createFile(file.getUri(), inputStream); // Update file parameters ObjectMap params = new ObjectMap() .append(FileDBAdaptor.QueryParams.STATUS_NAME.key(), File.FileStatus.READY) .append(FileDBAdaptor.QueryParams.SIZE.key(), ioManager.getFileSize(file.getUri())); queryResult = fileDBAdaptor.update(file.getUid(), params, QueryOptions.empty()); } return queryResult; }
if (file.getType().equals(File.Type.DIRECTORY)) { pathList.add("~^" + file.getPath());
directoryToScan = URI.create(directoryToScan.toString() + "/"); if (!directory.getType().equals(File.Type.DIRECTORY)) { throw new CatalogException("Expected folder where place the found files."); if (file.getType() == File.Type.FILE) { if (file.getStatus().getName().equals(File.FileStatus.MISSING)) { logger.info("File { id:" + file.getUid() + ", path:\"" + file.getPath() + "\" } recover tracking from file " + uri);
File file = fileConverter.convertToDataModelType(fileDoc, options); if (file.getType().equals(File.Type.DIRECTORY)) { filePath += filePath.endsWith("/") ? "" : "/"; if (file.getType().equals(File.Type.DIRECTORY)) { // recursive over the files inside folder QueryResult<File> allFilesInFolder = getAllFilesInFolder(studyId, file.getPath(), null); String oldPath = file.getPath();
if (file.getType().equals(File.Type.DIRECTORY)) { Query query = new Query(FileDBAdaptor.QueryParams.PATH.key(), "~" + file.getPath() + "..*") .append(FileDBAdaptor.QueryParams.STATUS_NAME.key(), "!=" + File.FileStatus.DELETED); if (f.getType() == File.Type.FILE && !f.getStatus().getName().equals(File.FileStatus.TRASHED)) { delete(f, sessionId); .filter(f -> f.getType() == File.Type.DIRECTORY && !f.getStatus().getName().equals(File.FileStatus.TRASHED)) .sorted((f1, f2) -> f2.getPath().length() - f1.getPath().length()) .collect(Collectors.toList());
if (!fileQueryResult.first().getType().equals(File.Type.DIRECTORY)) { throw new CatalogException("The file introduced is not a directory.");
if (fileAux.getType().equals(File.Type.DIRECTORY)) { FileTree subTree = getTree(fileAux, query, queryOptions, maxDepth - 1, studyId, userId); if (subTree != null) {
private void updateIndexStatusAfterDeletionOfTransformedFile(long studyId, File file) throws CatalogDBException { if (file.getType() == File.Type.FILE && (file.getRelatedFiles() == null || file.getRelatedFiles().isEmpty())) { return;
public QueryResult<File> getFilesFromFolder(String folderStr, String studyStr, QueryOptions options, String sessionId) throws CatalogException { ParamUtils.checkObj(folderStr, "folder"); MyResource<File> resource = getUid(folderStr, studyStr, sessionId); options = ParamUtils.defaultObject(options, QueryOptions::new); if (!resource.getResource().getType().equals(File.Type.DIRECTORY)) { throw new CatalogDBException("File {path:'" + resource.getResource().getPath() + "'} is not a folder."); } Query query = new Query(FileDBAdaptor.QueryParams.DIRECTORY.key(), resource.getResource().getPath()); return get(studyStr, query, options, sessionId); }
long numModified = 0; if (file.getType() == File.Type.FILE) { numMatched += 1;
fileSolrModel.setName(file.getName()); fileSolrModel.setStudyId(study.getFqn().replace(":", "__")); fileSolrModel.setType(file.getType().name()); if (file.getFormat() != null) { fileSolrModel.setFormat(file.getFormat().name());
if (file.getType() == File.Type.FILE) { filesToAnalyse.add(file); } else {
assert (fileSolrModel.getType().equals(file.getType().name())); assert (fileSolrModel.getFormat().equals(file.getFormat().name())); assert (fileSolrModel.getBioformat().equals(file.getBioformat().name()));
if (!file.getType().equals(File.Type.FILE)) { return file;
file.setType(ParamUtils.defaultObject(file.getType(), File.Type.FILE)); file.setFormat(ParamUtils.defaultObject(file.getFormat(), File.Format.PLAIN)); file.setBioformat(ParamUtils.defaultObject(file.getBioformat(), File.Bioformat.NONE)); file.setCreationDate(TimeUtils.getTime()); file.setModificationDate(file.getCreationDate()); if (file.getType() == File.Type.FILE) { file.setStatus(ParamUtils.defaultObject(file.getStatus(), new File.FileStatus(File.FileStatus.STAGE))); } else { file.setAttributes(ParamUtils.defaultObject(file.getAttributes(), HashMap::new)); if (file.getType() == File.Type.DIRECTORY && !file.getPath().endsWith("/")) { file.setPath(file.getPath() + "/"); if (file.getType() == File.Type.FILE && file.getPath().endsWith("/")) { file.setPath(file.getPath().substring(0, file.getPath().length() - 1)); if (file.getType() == File.Type.DIRECTORY) { uri = getFileUri(studyId, file.getPath(), true); } else {
authorizationManager.checkFilePermission(study.getUid(), file.getUid(), userId, FileAclEntry.FilePermissions.WRITE); if (!file.getType().equals(File.Type.DIRECTORY)) { throw new CatalogException("Bad outDir type. Required type : " + File.Type.DIRECTORY);
if (file.getType() == File.Type.DIRECTORY) { return file;