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;
}
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);
}
Aggregations