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