public URI createDirectory(URI uri) throws CatalogIOException { return createDirectory(uri, false); }
public URI createUser(String userId) throws CatalogIOException { checkParam(userId); URI usersUri = getUsersUri(); checkDirectoryUri(usersUri, true); URI userPath = getUserUri(userId); try { if (!exists(userPath)) { createDirectory(userPath); createDirectory(userPath.resolve(CatalogIOManager.USER_PROJECTS_FOLDER)); createDirectory(userPath.resolve(CatalogIOManager.USER_BIN_FOLDER)); return userPath; } } catch (CatalogIOException e) { throw e; } return null; }
/** * This method creates the folders and workspace structure for storing the OpenCGA data. I * * @throws CatalogIOException CatalogIOException */ public void setup() throws CatalogIOException { setConfiguration(configuration); if (!exists(rootDir)) { logger.info("Initializing CatalogIOManager. Creating main folder '" + rootDir + "'"); createDirectory(rootDir, true); } checkDirectoryUri(rootDir, true); if (!exists(jobsDir)) { logger.info("Initializing CatalogIOManager. Creating jobs folder '" + jobsDir + "'"); createDirectory(jobsDir); } checkDirectoryUri(jobsDir, true); if (!exists(rootDir.resolve(OPENCGA_USERS_FOLDER))) { createDirectory(rootDir.resolve(OPENCGA_USERS_FOLDER)); } if (!exists(rootDir.resolve(OPENCGA_ANONYMOUS_USERS_FOLDER))) { createDirectory(rootDir.resolve(OPENCGA_ANONYMOUS_USERS_FOLDER)); } if (!exists(rootDir.resolve(OPENCGA_BIN_FOLDER))) { createDirectory(rootDir.resolve(OPENCGA_BIN_FOLDER)); } }
void checkQueuedJob(Job job, Path tempJobFolder, CatalogIOManager catalogIOManager) { Path tmpOutdirPath = getJobTemporaryFolder(job.getUid(), tempJobFolder); if (!tmpOutdirPath.toFile().exists()) { logger.warn("Attempting to create the temporal output directory again"); try { catalogIOManager.createDirectory(tmpOutdirPath.toUri()); } catch (CatalogIOException e) { logger.error("Could not create the temporal output directory to run the job"); } } else { String status = executorManager.status(tmpOutdirPath, job); if (!status.equalsIgnoreCase(Job.JobStatus.UNKNOWN) && !status.equalsIgnoreCase(Job.JobStatus.QUEUED)) { try { logger.info("Updating job {} from {} to {}", job.getUid(), Job.JobStatus.QUEUED, Job.JobStatus.RUNNING); setNewStatus(job.getUid(), Job.JobStatus.RUNNING, "The job is running"); } catch (CatalogException e) { logger.warn("Could not update job {} to status running", job.getUid()); } } } }
public URI createFolder(URI studyUri, String folderName, boolean parent) throws CatalogIOException { checkParam(folderName); if (!folderName.endsWith("/")) { folderName += "/"; } checkDirectoryUri(studyUri, true); URI folderUri = null; try { folderUri = studyUri.resolve(new URI(null, folderName, null)); } catch (URISyntaxException e) { throw CatalogIOException.uriSyntaxException(folderName, e); } try { if (!exists(folderUri)) { if (parent) { createDirectory(folderUri, true); } else { checkDirectoryUri(folderUri.resolve(".."), true); createDirectory(folderUri); } } } catch (CatalogIOException e) { throw new CatalogIOException("createFolder(): could not create the directory", e); } return folderUri; }
public URI createProject(String userId, String projectId) throws CatalogIOException { checkParam(projectId); URI projectUri = getProjectUri(userId, projectId); try { if (!exists(projectUri)) { projectUri = createDirectory(projectUri, true); } } catch (CatalogIOException e) { throw new CatalogIOException("createProject(): could not create the project folder", e); } return projectUri; }
public URI createStudy(URI studyUri) throws CatalogIOException { checkUriScheme(studyUri); try { if (!exists(studyUri)) { studyUri = createDirectory(studyUri); } } catch (CatalogIOException e) { throw new CatalogIOException("createStudy method: could not create the study folder: " + e.toString(), e); } return studyUri; }
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; }
public URI createJobOutDir(String userId, String folderName) throws CatalogIOException { checkParam(folderName); URI jobsFolderUri = getJobsUri(userId); checkDirectoryUri(jobsFolderUri, true); URI jobUri; try { jobUri = jobsFolderUri.resolve(new URI(null, folderName, null)); } catch (URISyntaxException e) { throw CatalogIOException.uriSyntaxException(folderName, e); } if (!exists(jobUri)) { try { jobUri = createDirectory(jobUri, true); } catch (CatalogIOException e) { throw new CatalogIOException("createStudy method: could not create the study folder: " + e.toString(), e); } } else { throw new CatalogIOException("createJobOutDir method: Job folder " + folderName + "already exists."); } return jobUri; }
catalogIOManager.createDirectory(path.toUri()); } catch (CatalogIOException e) { logger.warn("Could not create the temporal output directory " + path + " to run the job", e);
catalogIOManager.createDirectory(path.toUri()); } catch (CatalogIOException e) { logger.warn("Could not create the temporal output directory " + path + " to run the job", e);
if (!Files.exists(tempFilePath.getParent())) { logger.debug("Creating temporal folder: {}", tempFilePath.getParent()); ioManager.createDirectory(tempDirectory, true); ioManager.createDirectory(Paths.get(fileQueryResult.first().getUri()).getParent().toUri(), true);
catalogManager.getCatalogIOManagerFactory().getDefault().createDirectory(studyUri.resolve("data/test/folder/"), true); Path filePath = CatalogManagerTest.createDebugFile(studyUri.resolve("data/test/folder/").resolve("file_scanner_test_file.txt") .getPath()).toPath();