use of org.sagebionetworks.bridge.models.accounts.UserSession in project BridgeServer2 by Sage-Bionetworks.
the class CompoundActivityDefinitionController method updateCompoundActivityDefinition.
/**
* Update a compound activity definition.
*/
@PostMapping(path = "/v3/compoundactivitydefinitions/{taskId}", produces = { APPLICATION_JSON_UTF8_VALUE })
public String updateCompoundActivityDefinition(@PathVariable String taskId) throws JsonProcessingException, IOException {
UserSession session = getAuthenticatedSession(DEVELOPER);
CompoundActivityDefinition requestDef = parseJson(CompoundActivityDefinition.class);
CompoundActivityDefinition updatedDef = compoundActivityDefService.updateCompoundActivityDefinition(session.getAppId(), taskId, requestDef);
return PUBLIC_DEFINITION_WRITER.writeValueAsString(updatedDef);
}
use of org.sagebionetworks.bridge.models.accounts.UserSession in project BridgeServer2 by Sage-Bionetworks.
the class CompoundActivityDefinitionController method createCompoundActivityDefinition.
/**
* Creates a compound activity definition.
*/
@PostMapping(path = "/v3/compoundactivitydefinitions", produces = { APPLICATION_JSON_UTF8_VALUE })
@ResponseStatus(HttpStatus.CREATED)
public String createCompoundActivityDefinition() throws JsonProcessingException, IOException {
UserSession session = getAuthenticatedSession(DEVELOPER);
CompoundActivityDefinition requestDef = parseJson(CompoundActivityDefinition.class);
CompoundActivityDefinition createdDef = compoundActivityDefService.createCompoundActivityDefinition(session.getAppId(), requestDef);
return PUBLIC_DEFINITION_WRITER.writeValueAsString(createdDef);
}
use of org.sagebionetworks.bridge.models.accounts.UserSession in project BridgeServer2 by Sage-Bionetworks.
the class ConsentController method getConsentSignatureV2.
// V2: consent to a specific subpopulation
@GetMapping(path = "/v3/subpopulations/{guid}/consents/signature", produces = { APPLICATION_JSON_UTF8_VALUE })
public String getConsentSignatureV2(@PathVariable String guid) throws Exception {
UserSession session = getAuthenticatedAndConsentedSession();
App app = appService.getApp(session.getAppId());
ConsentSignature sig = consentService.getConsentSignature(app, SubpopulationGuid.create(guid), session.getId());
return ConsentSignature.SIGNATURE_WRITER.writeValueAsString(sig);
}
use of org.sagebionetworks.bridge.models.accounts.UserSession in project BridgeServer2 by Sage-Bionetworks.
the class ConsentController method withdrawConsent.
@Deprecated
@PostMapping("/v3/consents/signature/withdraw")
public JsonNode withdrawConsent() {
UserSession session = getAuthenticatedSession();
App app = appService.getApp(session.getAppId());
return withdrawConsentV2(app.getIdentifier());
}
use of org.sagebionetworks.bridge.models.accounts.UserSession in project BridgeServer2 by Sage-Bionetworks.
the class ActivityEventController method getActivityEventHistoryForSelf.
@GetMapping("/v5/studies/{studyId}/participants/self/activityevents/{eventId}")
public ResourceList<StudyActivityEvent> getActivityEventHistoryForSelf(@PathVariable String studyId, @PathVariable String eventId, @RequestParam(required = false) String offsetBy, @RequestParam(required = false) String pageSize) throws JsonProcessingException {
UserSession session = getAuthenticatedAndConsentedSession();
if (!session.getParticipant().getStudyIds().contains(studyId)) {
throw new EntityNotFoundException(Account.class);
}
int offsetByInt = BridgeUtils.getIntOrDefault(offsetBy, 0);
int pageSizeInt = BridgeUtils.getIntOrDefault(pageSize, API_DEFAULT_PAGE_SIZE);
AccountId accountId = AccountId.forId(session.getAppId(), session.getId());
return studyActivityEventService.getStudyActivityEventHistory(accountId, studyId, eventId, offsetByInt, pageSizeInt);
}
Aggregations