138 SystemScope scope =
gson.fromJson(json, SystemScope.class);
141 if (alreadyExists != null) {
143 logger.error(
"Error: attempting to save a scope with a value that already exists: " + scope.getValue());
144 m.put(HttpCodeView.CODE, HttpStatus.CONFLICT);
145 m.put(JsonErrorView.ERROR_MESSAGE,
"A scope with value " + scope.getValue() +
" already exists, please choose a different value.");
146 return JsonErrorView.VIEWNAME;
151 if (scope != null && scope.getId() != null) {
153 m.put(JsonEntityView.ENTITY, scope);
155 return JsonEntityView.VIEWNAME;
158 logger.error(
"createScope failed; JSON was invalid: " + json);
159 m.put(HttpCodeView.CODE, HttpStatus.BAD_REQUEST);
160 m.put(JsonErrorView.ERROR_MESSAGE,
"Could not save new scope " + scope +
". The scope service failed to return a saved entity.");
161 return JsonErrorView.VIEWNAME;
SystemScope save(SystemScope scope)
static final Logger logger
Definition: ScopeAPI.java:63
SystemScope getByValue(String value)
Gson gson
Definition: ScopeAPI.java:65
SystemScopeService scopeService
Definition: ScopeAPI.java:58