Search in sources :

Example 26 with UserSession

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

the class AppConfigElementsController method getElementRevisions.

@GetMapping("/v3/appconfigs/elements/{id}")
public ResourceList<AppConfigElement> getElementRevisions(@PathVariable String id, @RequestParam(required = false) String includeDeleted) {
    UserSession session = getAuthenticatedSession(DEVELOPER);
    boolean includeDeletedFlag = Boolean.valueOf(includeDeleted);
    List<AppConfigElement> elements = service.getElementRevisions(session.getAppId(), id, includeDeletedFlag);
    return new ResourceList<AppConfigElement>(elements).withRequestParam(INCLUDE_DELETED_PARAM, includeDeletedFlag);
}
Also used : AppConfigElement(org.sagebionetworks.bridge.models.appconfig.AppConfigElement) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 27 with UserSession

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

the class AppConfigElementsController method deleteElementAllRevisions.

@DeleteMapping("/v3/appconfigs/elements/{id}")
public StatusMessage deleteElementAllRevisions(@PathVariable String id, @RequestParam(required = false) String physical) {
    UserSession session = getAuthenticatedSession(DEVELOPER);
    if ("true".equals(physical) && session.isInRole(ADMIN)) {
        service.deleteElementAllRevisionsPermanently(session.getAppId(), id);
    } else {
        service.deleteElementAllRevisions(session.getAppId(), id);
    }
    // App config elements are included in the app configs, so allow cache to update
    cacheProvider.removeSetOfCacheKeys(CacheKey.appConfigList(session.getAppId()));
    return new StatusMessage("App config element deleted.");
}
Also used : UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping)

Example 28 with UserSession

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

the class AppController method verifySenderEmail.

@PostMapping(path = { "/v1/apps/self/verifyEmail", "/v3/studies/self/verifyEmail" })
public EmailVerificationStatusHolder verifySenderEmail() {
    UserSession session = getAuthenticatedSession(DEVELOPER);
    App app = appService.getApp(session.getAppId());
    EmailVerificationStatus status = emailVerificationService.verifyEmailAddress(app.getSupportEmail());
    return new EmailVerificationStatusHolder(status);
}
Also used : App(org.sagebionetworks.bridge.models.apps.App) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) EmailVerificationStatus(org.sagebionetworks.bridge.services.EmailVerificationStatus) EmailVerificationStatusHolder(org.sagebionetworks.bridge.models.apps.EmailVerificationStatusHolder) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 29 with UserSession

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

the class AppController method resendVerifyEmail.

/**
 * Resends the verification email for the current app's email.
 */
@PostMapping(path = { "/v1/apps/self/emails/resendVerify", "/v3/studies/self/emails/resendVerify" })
public StatusMessage resendVerifyEmail(@RequestParam(required = false) String type) {
    UserSession session = getAuthenticatedSession(DEVELOPER);
    AppEmailType parsedType = parseEmailType(type);
    appService.sendVerifyEmail(session.getAppId(), parsedType);
    return RESEND_EMAIL_MSG;
}
Also used : UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) AppEmailType(org.sagebionetworks.bridge.services.AppEmailType) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 30 with UserSession

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

the class AppController method getEmailStatus.

@GetMapping(path = { "/v1/apps/self/emailStatus", "/v3/studies/self/emailStatus" })
public EmailVerificationStatusHolder getEmailStatus() {
    UserSession session = getAuthenticatedSession(DEVELOPER);
    App app = appService.getApp(session.getAppId());
    EmailVerificationStatus status = emailVerificationService.getEmailStatus(app.getSupportEmail());
    return new EmailVerificationStatusHolder(status);
}
Also used : App(org.sagebionetworks.bridge.models.apps.App) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) EmailVerificationStatus(org.sagebionetworks.bridge.services.EmailVerificationStatus) EmailVerificationStatusHolder(org.sagebionetworks.bridge.models.apps.EmailVerificationStatusHolder) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

UserSession (org.sagebionetworks.bridge.models.accounts.UserSession)483 PostMapping (org.springframework.web.bind.annotation.PostMapping)149 GetMapping (org.springframework.web.bind.annotation.GetMapping)114 App (org.sagebionetworks.bridge.models.apps.App)104 Test (org.testng.annotations.Test)102 StudyParticipant (org.sagebionetworks.bridge.models.accounts.StudyParticipant)89 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)65 StatusMessage (org.sagebionetworks.bridge.models.StatusMessage)60 Account (org.sagebionetworks.bridge.models.accounts.Account)56 BeforeMethod (org.testng.annotations.BeforeMethod)47 EntityNotFoundException (org.sagebionetworks.bridge.exceptions.EntityNotFoundException)45 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)43 UnauthorizedException (org.sagebionetworks.bridge.exceptions.UnauthorizedException)38 CriteriaContext (org.sagebionetworks.bridge.models.CriteriaContext)31 DateTime (org.joda.time.DateTime)27 AccountId (org.sagebionetworks.bridge.models.accounts.AccountId)27 JsonNode (com.fasterxml.jackson.databind.JsonNode)21 ResourceList (org.sagebionetworks.bridge.models.ResourceList)21 SubpopulationGuid (org.sagebionetworks.bridge.models.subpopulations.SubpopulationGuid)21 BadRequestException (org.sagebionetworks.bridge.exceptions.BadRequestException)18