/** * Obtains the resource java bean containing the requested entries. * * @param entryStr Entry id in string format. * @param studyStr Study id in string format. Could be one of [id|user@aliasProject:aliasStudy|aliasProject:aliasStudy|aliasStudy]. * @param sessionId Session id of the user logged. * @return the resource java bean containing the requested entries. * @throws CatalogException when more than one entry is found. */ public AbstractManager.MyResource<R> getUid(String entryStr, @Nullable String studyStr, String sessionId) throws CatalogException { ParamUtils.checkObj(entryStr, "id"); String userId = catalogManager.getUserManager().getUserId(sessionId); Study study = catalogManager.getStudyManager().resolveId(studyStr, userId); if (entryStr.contains(",")) { throw new CatalogException("More than one entry found"); } R entry = smartResolutor(study.getUid(), entryStr, userId); return new MyResource<>(userId, study, entry); }
MyResource<Cohort> resource = new MyResource<>(user, study, cohort);
QueryResult<Individual> unsafeUpdate(Study study, Individual individual, ObjectMap parameters, QueryOptions options, String userId) throws CatalogException { try { ParamUtils.checkAllParametersExist(parameters.keySet().iterator(), (a) -> IndividualDBAdaptor.UpdateParams.getParam(a) != null); } catch (CatalogParameterException e) { throw new CatalogException("Could not update: " + e.getMessage(), e); } MyResource<Individual> resource = new MyResource<>(userId, study, individual); List<VariableSet> variableSetList = checkUpdateAnnotationsAndExtractVariableSets(resource, parameters, options, individualDBAdaptor); if (options.getBoolean(Constants.INCREMENT_VERSION)) { // We do need to get the current release to properly create a new version options.put(Constants.CURRENT_RELEASE, studyManager.getCurrentRelease(study, userId)); } QueryResult<Individual> queryResult = individualDBAdaptor.update(individual.getUid(), parameters, variableSetList, options); auditManager.recordUpdate(AuditRecord.Resource.individual, individual.getUid(), userId, parameters, null, null); return queryResult; }
QueryResult<File> unsafeUpdate(Study study, File file, ObjectMap parameters, QueryOptions options, String userId) throws CatalogException { if (isRootFolder(file)) { throw new CatalogException("Cannot modify root folder"); } try { ParamUtils.checkAllParametersExist(parameters.keySet().iterator(), (a) -> FileDBAdaptor.UpdateParams.getParam(a) != null); } catch (CatalogParameterException e) { throw new CatalogException("Could not update: " + e.getMessage(), e); } MyResource<File> resource = new MyResource<>(userId, study, file); List<VariableSet> variableSetList = checkUpdateAnnotationsAndExtractVariableSets(resource, parameters, options, fileDBAdaptor); String ownerId = studyDBAdaptor.getOwnerId(study.getUid()); fileDBAdaptor.update(file.getUid(), parameters, variableSetList, options); QueryResult<File> queryResult = fileDBAdaptor.get(file.getUid(), options); auditManager.recordUpdate(AuditRecord.Resource.file, file.getUid(), userId, parameters, null, null); userDBAdaptor.updateUserLastModified(ownerId); return queryResult; }