Search in sources :

Example 21 with UserSession

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

the class AppConfigController method getAppConfigs.

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

Example 22 with UserSession

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

the class AppConfigController method updateAppConfig.

@PostMapping("/v3/appconfigs/{guid}")
public GuidVersionHolder updateAppConfig(@PathVariable String guid) {
    UserSession session = getAuthenticatedSession(DEVELOPER);
    AppConfig appConfig = parseJson(AppConfig.class);
    appConfig.setGuid(guid);
    AppConfig updated = appConfigService.updateAppConfig(session.getAppId(), appConfig);
    cacheProvider.removeSetOfCacheKeys(CacheKey.appConfigList(session.getAppId()));
    return new GuidVersionHolder(updated.getGuid(), updated.getVersion());
}
Also used : AppConfig(org.sagebionetworks.bridge.models.appconfig.AppConfig) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) GuidVersionHolder(org.sagebionetworks.bridge.models.GuidVersionHolder) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 23 with UserSession

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

the class AppConfigController method createAppConfig.

@PostMapping("/v3/appconfigs")
@ResponseStatus(HttpStatus.CREATED)
public GuidVersionHolder createAppConfig() {
    UserSession session = getAuthenticatedSession(DEVELOPER);
    AppConfig appConfig = parseJson(AppConfig.class);
    AppConfig created = appConfigService.createAppConfig(session.getAppId(), appConfig);
    cacheProvider.removeSetOfCacheKeys(CacheKey.appConfigList(session.getAppId()));
    return new GuidVersionHolder(created.getGuid(), created.getVersion());
}
Also used : AppConfig(org.sagebionetworks.bridge.models.appconfig.AppConfig) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) GuidVersionHolder(org.sagebionetworks.bridge.models.GuidVersionHolder) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 24 with UserSession

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

the class AppConfigElementsController method deleteElementRevision.

@DeleteMapping("/v3/appconfigs/elements/{id}/revisions/{revision}")
public StatusMessage deleteElementRevision(@PathVariable String id, @PathVariable String revision, @RequestParam(required = false) String physical) {
    UserSession session = getAuthenticatedSession(DEVELOPER);
    Long revisionLong = BridgeUtils.getLongOrDefault(revision, null);
    if (revisionLong == null) {
        throw new BadRequestException("Revision is not a valid revision number");
    }
    if ("true".equals(physical) && session.isInRole(ADMIN)) {
        service.deleteElementRevisionPermanently(session.getAppId(), id, revisionLong);
    } else {
        service.deleteElementRevision(session.getAppId(), id, revisionLong);
    }
    // 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 revision deleted.");
}
Also used : UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) BadRequestException(org.sagebionetworks.bridge.exceptions.BadRequestException) StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping)

Example 25 with UserSession

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

the class AppConfigElementsController method getMostRecentElements.

@GetMapping("/v3/appconfigs/elements")
public ResourceList<AppConfigElement> getMostRecentElements(@RequestParam(required = false) String includeDeleted) {
    UserSession session = getAuthenticatedSession(DEVELOPER);
    boolean includeDeletedFlag = Boolean.valueOf(includeDeleted);
    List<AppConfigElement> elements = service.getMostRecentElements(session.getAppId(), 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)

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