Search in sources :

Example 1 with SharingOption

use of org.sagebionetworks.bridge.models.accounts.SharingOption in project BridgeServer2 by Sage-Bionetworks.

the class IntentController method submitIntentToParticipate.

@PostMapping("/v3/itp")
@ResponseStatus(HttpStatus.ACCEPTED)
public StatusMessage submitIntentToParticipate() {
    // An early hack in the system was that sharing scope was added to the consent signature
    // JSON even though it is not part of the signature. We need to move that value because
    // the client API continues to treat sharing as part of the consent signature.
    JsonNode requestNode = parseJson(JsonNode.class);
    IntentToParticipate intent = parseJson(requestNode, IntentToParticipate.class);
    if (requestNode != null && requestNode.has("consentSignature")) {
        SharingOption sharing = SharingOption.fromJson(requestNode.get("consentSignature"), 2);
        intent = new IntentToParticipate.Builder().copyOf(intent).withScope(sharing.getSharingScope()).build();
    }
    intentService.submitIntentToParticipate(intent);
    return SUBMITTED_MSG;
}
Also used : SharingOption(org.sagebionetworks.bridge.models.accounts.SharingOption) JsonNode(com.fasterxml.jackson.databind.JsonNode) IntentToParticipate(org.sagebionetworks.bridge.models.itp.IntentToParticipate) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 2 with SharingOption

use of org.sagebionetworks.bridge.models.accounts.SharingOption in project BridgeServer2 by Sage-Bionetworks.

the class ConsentController method giveConsentForVersion.

private JsonNode giveConsentForVersion(int version, SubpopulationGuid subpopGuid) {
    UserSession session = getAuthenticatedSession();
    App app = appService.getApp(session.getAppId());
    JsonNode node = parseJson(JsonNode.class);
    ConsentSignature consentSignature = ConsentSignature.fromJSON(node);
    SharingOption sharing = SharingOption.fromJson(node, version);
    // On client update, clients have sent consent signatures even before the session reflects the need
    // for the new consent. Update the criteria context before consent, using the latest User-Agent
    // header, so the server is synchronized with the client's state.
    CriteriaContext context = getCriteriaContext(session);
    Map<SubpopulationGuid, ConsentStatus> consentStatuses = consentService.getConsentStatuses(context);
    // If provided subpopulation is not in the statuses, it either doesn't exist or doesn't apply to
    // this user, and we return a 404
    ConsentStatus status = consentStatuses.get(subpopGuid);
    if (status == null) {
        throw new EntityNotFoundException(Subpopulation.class);
    }
    consentService.consentToResearch(app, subpopGuid, session.getParticipant(), consentSignature, sharing.getSharingScope(), true);
    // We must do a full refresh of the session because consents can set data groups and studies.
    CriteriaContext updatedContext = getCriteriaContext(session);
    UserSession updatedSession = authenticationService.getSession(app, updatedContext);
    sessionUpdateService.updateSession(session, updatedSession);
    return UserSessionInfo.toJSON(updatedSession);
}
Also used : App(org.sagebionetworks.bridge.models.apps.App) ConsentSignature(org.sagebionetworks.bridge.models.subpopulations.ConsentSignature) ConsentStatus(org.sagebionetworks.bridge.models.accounts.ConsentStatus) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) SharingOption(org.sagebionetworks.bridge.models.accounts.SharingOption) JsonNode(com.fasterxml.jackson.databind.JsonNode) SubpopulationGuid(org.sagebionetworks.bridge.models.subpopulations.SubpopulationGuid) EntityNotFoundException(org.sagebionetworks.bridge.exceptions.EntityNotFoundException) CriteriaContext(org.sagebionetworks.bridge.models.CriteriaContext)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)2 SharingOption (org.sagebionetworks.bridge.models.accounts.SharingOption)2 EntityNotFoundException (org.sagebionetworks.bridge.exceptions.EntityNotFoundException)1 CriteriaContext (org.sagebionetworks.bridge.models.CriteriaContext)1 ConsentStatus (org.sagebionetworks.bridge.models.accounts.ConsentStatus)1 UserSession (org.sagebionetworks.bridge.models.accounts.UserSession)1 App (org.sagebionetworks.bridge.models.apps.App)1 IntentToParticipate (org.sagebionetworks.bridge.models.itp.IntentToParticipate)1 ConsentSignature (org.sagebionetworks.bridge.models.subpopulations.ConsentSignature)1 SubpopulationGuid (org.sagebionetworks.bridge.models.subpopulations.SubpopulationGuid)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1