public List<QueryResult<JobAclEntry>> getAcls(String studyStr, List<String> jobList, String member, boolean silent, String sessionId) throws CatalogException { List<QueryResult<JobAclEntry>> jobAclList = new ArrayList<>(jobList.size()); for (String job : jobList) { try { MyResource<Job> resource = getUid(job, studyStr, sessionId); QueryResult<JobAclEntry> allJobAcls; if (StringUtils.isNotEmpty(member)) { allJobAcls = authorizationManager.getJobAcl(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), member); } else { allJobAcls = authorizationManager.getAllJobAcls(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser()); } allJobAcls.setId(job); jobAclList.add(allJobAcls); } catch (CatalogException e) { if (silent) { jobAclList.add(new QueryResult<>(job, 0, 0, 0, "", e.toString(), new ArrayList<>(0))); } else { throw e; } } } return jobAclList; }
public List<QueryResult<FileAclEntry>> getAcls(String studyStr, List<String> fileList, String member, boolean silent, String sessionId) throws CatalogException { List<QueryResult<FileAclEntry>> fileAclList = new ArrayList<>(fileList.size()); for (String file : fileList) { try { MyResource<File> resource = getUid(file, studyStr, sessionId); QueryResult<FileAclEntry> allFileAcls; if (StringUtils.isNotEmpty(member)) { allFileAcls = authorizationManager.getFileAcl(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), member); } else { allFileAcls = authorizationManager.getAllFileAcls(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), true); } allFileAcls.setId(file); fileAclList.add(allFileAcls); } catch (CatalogException e) { if (silent) { fileAclList.add(new QueryResult<>(file, 0, 0, 0, "", e.toString(), new ArrayList<>(0))); } else { throw e; } } } return fileAclList; }
public List<QueryResult<IndividualAclEntry>> getAcls(String studyStr, List<String> individualList, String member, boolean silent, String sessionId) throws CatalogException { List<QueryResult<IndividualAclEntry>> individualAclList = new ArrayList<>(individualList.size()); for (String individual : individualList) { try { MyResource<Individual> resource = getUid(individual, studyStr, sessionId); QueryResult<IndividualAclEntry> allIndividualAcls; if (StringUtils.isNotEmpty(member)) { allIndividualAcls = authorizationManager.getIndividualAcl(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), member); } else { allIndividualAcls = authorizationManager.getAllIndividualAcls(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser()); } allIndividualAcls.setId(individual); individualAclList.add(allIndividualAcls); } catch (CatalogException e) { if (silent) { individualAclList.add(new QueryResult<>(individual, 0, 0, 0, "", e.toString(), new ArrayList<>(0))); } else { throw e; } } } return individualAclList; }
public QueryResult<Interpretation> create(String studyStr, String clinicalAnalysisStr, Interpretation interpretation, QueryOptions options, String sessionId) throws CatalogException { // We check if the user can create interpretations in the clinical analysis MyResource<ClinicalAnalysis> resource = catalogManager.getClinicalAnalysisManager() .getUid(clinicalAnalysisStr, studyStr, sessionId); authorizationManager.checkClinicalAnalysisPermission(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), ClinicalAnalysisAclEntry.ClinicalAnalysisPermissions.UPDATE); options = ParamUtils.defaultObject(options, QueryOptions::new); ParamUtils.checkObj(interpretation, "clinicalAnalysis"); ParamUtils.checkAlias(interpretation.getInterpretation().getId(), "id"); interpretation.getInterpretation().setCreationDate(TimeUtils.getTime()); interpretation.getInterpretation().setDescription( ParamUtils.defaultString(interpretation.getInterpretation().getDescription(), "")); interpretation.getInterpretation().setStatus(Status.READY); interpretation.getInterpretation().setAttributes( ParamUtils.defaultObject(interpretation.getInterpretation().getAttributes(), Collections.emptyMap())); interpretation.setUuid(UUIDUtils.generateOpenCGAUUID(UUIDUtils.Entity.INTERPRETATION)); QueryResult<Interpretation> queryResult = interpretationDBAdaptor.insert(resource.getStudy().getUid(), interpretation, options); // Now, we add the interpretation to the clinical analysis ObjectMap parameters = new ObjectMap(); parameters.put(ClinicalAnalysisDBAdaptor.QueryParams.INTERPRETATIONS.key(), Arrays.asList(interpretation)); Map<String, Object> actionMap = new HashMap<>(); actionMap.put(ClinicalAnalysisDBAdaptor.QueryParams.INTERPRETATIONS.key(), ParamUtils.UpdateAction.ADD.name()); parameters.put(Constants.ACTIONS, actionMap); catalogManager.getClinicalAnalysisManager().update(resource.getStudy().getFqn(), clinicalAnalysisStr, parameters, null, sessionId); return queryResult; }
public List<QueryResult<CohortAclEntry>> getAcls(String studyStr, List<String> cohortList, String member, boolean silent, String sessionId) throws CatalogException { List<QueryResult<CohortAclEntry>> cohortAclList = new ArrayList<>(cohortList.size()); for (String cohort : cohortList) { try { MyResource<Cohort> resource = getUid(cohort, studyStr, sessionId); QueryResult<CohortAclEntry> allCohortAcls; if (StringUtils.isNotEmpty(member)) { allCohortAcls = authorizationManager.getCohortAcl(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), member); } else { allCohortAcls = authorizationManager.getAllCohortAcls(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser()); } allCohortAcls.setId(cohort); cohortAclList.add(allCohortAcls); } catch (CatalogException e) { if (silent) { cohortAclList.add(new QueryResult<>(cohort, 0, 0, 0, "", e.toString(), new ArrayList<>(0))); } else { throw e; } } } return cohortAclList; }
public List<QueryResult<ClinicalAnalysisAclEntry>> getAcls(String studyStr, List<String> clinicalList, String member, boolean silent, String sessionId) throws CatalogException { List<QueryResult<ClinicalAnalysisAclEntry>> clinicalAclList = new ArrayList<>(clinicalList.size()); for (String clinicalAnalysis : clinicalList) { try { MyResource<ClinicalAnalysis> resource = getUid(clinicalAnalysis, studyStr, sessionId); QueryResult<ClinicalAnalysisAclEntry> allClinicalAcls; if (StringUtils.isNotEmpty(member)) { allClinicalAcls = authorizationManager.getClinicalAnalysisAcl(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), member); } else { allClinicalAcls = authorizationManager.getAllClinicalAnalysisAcls(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser()); } allClinicalAcls.setId(clinicalAnalysis); clinicalAclList.add(allClinicalAcls); } catch (CatalogException e) { if (silent) { clinicalAclList.add(new QueryResult<>(clinicalAnalysis, 0, 0, 0, "", e.toString(), new ArrayList<>(0))); } else { throw e; } } } return clinicalAclList; }
public List<QueryResult<FamilyAclEntry>> getAcls(String studyStr, List<String> familyList, String member, boolean silent, String sessionId) throws CatalogException { List<QueryResult<FamilyAclEntry>> familyAclList = new ArrayList<>(familyList.size()); for (String family : familyList) { try { MyResource<Family> resource = getUid(family, studyStr, sessionId); QueryResult<FamilyAclEntry> allFamilyAcls; if (StringUtils.isNotEmpty(member)) { allFamilyAcls = authorizationManager.getFamilyAcl(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), member); } else { allFamilyAcls = authorizationManager.getAllFamilyAcls(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser()); } allFamilyAcls.setId(family); familyAclList.add(allFamilyAcls); } catch (CatalogException e) { if (silent) { familyAclList.add(new QueryResult<>(family, 0, 0, 0, "", e.toString(), new ArrayList<>(0))); } else { throw e; } } } return familyAclList; }
public List<QueryResult<SampleAclEntry>> getAcls(String studyStr, List<String> sampleList, String member, boolean silent, String sessionId) throws CatalogException { List<QueryResult<SampleAclEntry>> sampleAclList = new ArrayList<>(sampleList.size()); for (String sample : sampleList) { try { MyResource<Sample> resource = getUid(sample, studyStr, sessionId); QueryResult<SampleAclEntry> allSampleAcls; if (StringUtils.isNotEmpty(member)) { allSampleAcls = authorizationManager.getSampleAcl(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), member); } else { allSampleAcls = authorizationManager.getAllSampleAcls(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser()); } allSampleAcls.setId(sample); sampleAclList.add(allSampleAcls); } catch (CatalogException e) { if (silent) { sampleAclList.add(new QueryResult<>(sample, 0, 0, 0, "", e.toString(), new ArrayList<>(0))); } else { throw e; } } } return sampleAclList; }
public QueryResult<Cohort> update(String studyStr, String entryStr, ObjectMap parameters, boolean allowModifyCohortAll, QueryOptions options, String sessionId) throws CatalogException { ParamUtils.checkObj(parameters, "Update parameters"); options = ParamUtils.defaultObject(options, QueryOptions::new); parameters = new ObjectMap(parameters); MyResource<Cohort> resource = getUid(entryStr, studyStr, sessionId); // Check permissions... // Only check write annotation permissions if the user wants to update the annotation sets if (parameters.containsKey(CohortDBAdaptor.QueryParams.ANNOTATION_SETS.key())) { authorizationManager.checkCohortPermission(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), CohortAclEntry.CohortPermissions.WRITE_ANNOTATIONS); } // Only check update permissions if the user wants to update anything apart from the annotation sets if ((parameters.size() == 1 && !parameters.containsKey(CohortDBAdaptor.QueryParams.ANNOTATION_SETS.key())) || parameters.size() > 1) { authorizationManager.checkCohortPermission(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), CohortAclEntry.CohortPermissions.UPDATE); } Cohort cohort = cohortDBAdaptor.get(resource.getResource().getUid(), QueryOptions.empty()).first(); return unsafeUpdate(resource.getStudy(), cohort, parameters, allowModifyCohortAll, options, resource.getUser()); }
public void setStatus(String studyStr, String fileId, String status, String message, String sessionId) throws CatalogException { MyResource<File> resource = getUid(fileId, studyStr, sessionId); String userId = resource.getUser(); long fileUid = resource.getResource().getUid(); authorizationManager.checkFilePermission(resource.getStudy().getUid(), fileUid, userId, FileAclEntry.FilePermissions.WRITE); if (status != null && !File.FileStatus.isValid(status)) { throw new CatalogException("The status " + status + " is not valid file status."); } ObjectMap parameters = new ObjectMap(); parameters.putIfNotNull(FileDBAdaptor.QueryParams.STATUS_NAME.key(), status); parameters.putIfNotNull(FileDBAdaptor.QueryParams.STATUS_MSG.key(), message); fileDBAdaptor.update(fileUid, parameters, QueryOptions.empty()); auditManager.recordUpdate(AuditRecord.Resource.file, fileUid, userId, parameters, null, null); }
public void setStatus(String studyStr, String id, String status, String message, String sessionId) throws CatalogException { ParamUtils.checkParameter(sessionId, "sessionId"); MyResource resource = getUid(id, studyStr, sessionId); authorizationManager.checkJobPermission(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), JobAclEntry.JobPermissions.UPDATE); if (status != null && !Job.JobStatus.isValid(status)) { throw new CatalogException("The status " + status + " is not valid job status."); } ObjectMap parameters = new ObjectMap(); parameters.putIfNotNull(JobDBAdaptor.QueryParams.STATUS_NAME.key(), status); parameters.putIfNotNull(JobDBAdaptor.QueryParams.STATUS_MSG.key(), message); jobDBAdaptor.update(resource.getResource().getUid(), parameters, QueryOptions.empty()); auditManager.recordUpdate(AuditRecord.Resource.job, resource.getResource().getUid(), resource.getUser(), parameters, null, null); }
public void setStatus(String studyStr, String id, String status, String message, String sessionId) throws CatalogException { MyResource resource = getUid(id, studyStr, sessionId); authorizationManager.checkCohortPermission(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), CohortAclEntry.CohortPermissions.UPDATE); if (status != null && !Cohort.CohortStatus.isValid(status)) { throw new CatalogException("The status " + status + " is not valid cohort status."); } ObjectMap parameters = new ObjectMap(); parameters.putIfNotNull(CohortDBAdaptor.QueryParams.STATUS_NAME.key(), status); parameters.putIfNotNull(CohortDBAdaptor.QueryParams.STATUS_MSG.key(), message); cohortDBAdaptor.update(resource.getResource().getUid(), parameters, new QueryOptions()); auditManager.recordUpdate(AuditRecord.Resource.cohort, resource.getResource().getUid(), resource.getUser(), parameters, null, null); }
public void setDiskUsage(String studyStr, String fileId, long size, String sessionId) throws CatalogException { MyResource<File> resource = getUid(fileId, studyStr, sessionId); authorizationManager.checkFilePermission(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), FileAclEntry.FilePermissions.WRITE); ObjectMap parameters = new ObjectMap(FileDBAdaptor.QueryParams.SIZE.key(), size); fileDBAdaptor.update(resource.getResource().getUid(), parameters, QueryOptions.empty()); auditManager.recordUpdate(AuditRecord.Resource.file, resource.getResource().getUid(), resource.getUser(), parameters, null, null); }
@Override public QueryResult<Job> update(String studyStr, String entryStr, ObjectMap parameters, QueryOptions options, String sessionId) throws CatalogException { ParamUtils.checkObj(parameters, "parameters"); options = ParamUtils.defaultObject(options, QueryOptions::new); MyResource resource = getUid(entryStr, studyStr, sessionId); authorizationManager.checkJobPermission(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), JobAclEntry.JobPermissions.UPDATE); QueryResult<Job> queryResult = jobDBAdaptor.update(resource.getResource().getUid(), parameters, QueryOptions.empty()); auditManager.recordUpdate(AuditRecord.Resource.job, resource.getResource().getUid(), resource.getUser(), parameters, null, null); return queryResult; }
public void setUri(String studyStr, String fileId, String uri, String sessionId) throws CatalogException { MyResource<File> resource = getUid(fileId, studyStr, sessionId); String userId = resource.getUser(); long studyId = resource.getStudy().getUid(); authorizationManager.checkFilePermission(studyId, resource.getResource().getUid(), userId, FileAclEntry.FilePermissions.WRITE); ObjectMap parameters = new ObjectMap(FileDBAdaptor.QueryParams.URI.key(), uri); fileDBAdaptor.update(resource.getResource().getUid(), parameters, QueryOptions.empty()); auditManager.recordUpdate(AuditRecord.Resource.file, resource.getResource().getUid(), userId, parameters, null, null); }
public DataInputStream download(String studyStr, String fileStr, int start, int limit, QueryOptions options, String sessionId) throws CatalogException { MyResource<File> resource = getUid(fileStr, studyStr, sessionId); authorizationManager.checkFilePermission(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), FileAclEntry.FilePermissions.DOWNLOAD); URI fileUri = getUri(resource.getResource()); return catalogIOManagerFactory.get(fileUri).getFileObject(fileUri, start, limit); }
public QueryResult<Job> visit(String studyStr, String jobId, String sessionId) throws CatalogException { MyResource resource = getUid(jobId, studyStr, sessionId); authorizationManager.checkJobPermission(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), JobAclEntry.JobPermissions.VIEW); ObjectMap params = new ObjectMap(JobDBAdaptor.QueryParams.VISITED.key(), true); return jobDBAdaptor.update(resource.getResource().getUid(), params, QueryOptions.empty()); }
public void setFileIndex(String studyStr, String fileId, FileIndex index, String sessionId) throws CatalogException { MyResource<File> resource = getUid(fileId, studyStr, sessionId); authorizationManager.checkFilePermission(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), FileAclEntry.FilePermissions.WRITE); ObjectMap parameters = new ObjectMap(FileDBAdaptor.QueryParams.INDEX.key(), index); fileDBAdaptor.update(resource.getResource().getUid(), parameters, QueryOptions.empty()); auditManager.recordUpdate(AuditRecord.Resource.file, resource.getResource().getUid(), resource.getUser(), parameters, null, null); }
@Deprecated public void setModificationDate(String studyStr, String fileId, String date, String sessionId) throws CatalogException { MyResource<File> resource = getUid(fileId, studyStr, sessionId); String userId = resource.getUser(); long studyId = resource.getStudy().getUid(); authorizationManager.checkFilePermission(studyId, resource.getResource().getUid(), userId, FileAclEntry.FilePermissions.WRITE); ObjectMap parameters = new ObjectMap(FileDBAdaptor.QueryParams.MODIFICATION_DATE.key(), date); fileDBAdaptor.update(resource.getResource().getUid(), parameters, QueryOptions.empty()); auditManager.recordUpdate(AuditRecord.Resource.file, resource.getResource().getUid(), userId, parameters, null, null); }
public DataInputStream grep(String studyStr, String fileStr, String pattern, QueryOptions options, String sessionId) throws CatalogException { MyResource<File> resource = getUid(fileStr, studyStr, sessionId); authorizationManager.checkFilePermission(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), FileAclEntry.FilePermissions.VIEW); URI fileUri = getUri(resource.getResource()); boolean ignoreCase = options.getBoolean("ignoreCase"); boolean multi = options.getBoolean("multi"); return catalogIOManagerFactory.get(fileUri).getGrepFileObject(fileUri, pattern, ignoreCase, multi); }