use of org.sagebionetworks.bridge.models.accounts.UserSession in project BridgeServer2 by Sage-Bionetworks.
the class ParticipantController method getUploads.
@GetMapping("/v3/participants/{userId}/uploads")
public ForwardCursorPagedResourceList<UploadView> getUploads(@PathVariable String userId, @RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime, @RequestParam(required = false) Integer pageSize, @RequestParam(required = false) String offsetKey) {
UserSession session = getAdministrativeSession();
CAN_EDIT_PARTICIPANTS.checkAndThrow(USER_ID, userId);
App app = appService.getApp(session.getAppId());
DateTime startTimeDate = getDateTimeOrDefault(startTime, null);
DateTime endTimeDate = getDateTimeOrDefault(endTime, null);
return participantService.getUploads(app, userId, startTimeDate, endTimeDate, pageSize, offsetKey);
}
use of org.sagebionetworks.bridge.models.accounts.UserSession in project BridgeServer2 by Sage-Bionetworks.
the class ParticipantController method signOut.
@PostMapping("/v3/participants/{userId}/signOut")
public StatusMessage signOut(@PathVariable String userId, @RequestParam(required = false) boolean deleteReauthToken) {
UserSession session = getAdministrativeSession();
CAN_EDIT_PARTICIPANTS.checkAndThrow(USER_ID, userId);
App app = appService.getApp(session.getAppId());
participantService.signUserOut(app, userId, deleteReauthToken);
return new StatusMessage("User signed out.");
}
use of org.sagebionetworks.bridge.models.accounts.UserSession in project BridgeServer2 by Sage-Bionetworks.
the class ParticipantController method updateParticipant.
@PostMapping("/v3/participants/{userId}")
public StatusMessage updateParticipant(@PathVariable String userId) {
UserSession session = getAdministrativeSession();
CAN_EDIT_PARTICIPANTS.checkAndThrow(USER_ID, userId);
App app = appService.getApp(session.getAppId());
StudyParticipant participant = parseJson(StudyParticipant.class);
// Force userId of the URL
participant = new StudyParticipant.Builder().copyOf(participant).withId(userId).build();
participantService.updateParticipant(app, participant);
return new StatusMessage("Participant updated.");
}
use of org.sagebionetworks.bridge.models.accounts.UserSession in project BridgeServer2 by Sage-Bionetworks.
the class ParticipantController method getEnrollments.
@GetMapping("/v3/participants/{userId}/enrollments")
public PagedResourceList<EnrollmentDetail> getEnrollments(@PathVariable String userId) {
UserSession session = getAdministrativeSession();
CAN_EDIT_PARTICIPANTS.checkAndThrow(USER_ID, userId);
// A limitation of Swagger as we use it is that we don't want different collection
// containers for the same kind of entity. Since some APIs can page enrollments,
// this API returns a paged enrollment, despite the fact that there will probably
// never be more than one page of results returned from this API.
List<EnrollmentDetail> details = enrollmentService.getEnrollmentsForUser(session.getAppId(), null, userId);
return new PagedResourceList<>(details, details.size(), true);
}
use of org.sagebionetworks.bridge.models.accounts.UserSession in project BridgeServer2 by Sage-Bionetworks.
the class ParticipantController method createCustomActivityEvent.
@PostMapping(path = { "/v3/participants/{userId}/activityEvents", "/v3/participants/{userId}/activityevents" })
@ResponseStatus(HttpStatus.CREATED)
public StatusMessage createCustomActivityEvent(@PathVariable String userId) {
UserSession session = getAuthenticatedSession(DEVELOPER, RESEARCHER);
App app = appService.getApp(session.getAppId());
CustomActivityEventRequest activityEvent = parseJson(CustomActivityEventRequest.class);
participantService.createCustomActivityEvent(app, userId, activityEvent);
return new StatusMessage("Event recorded.");
}
Aggregations