136 WhitelistedSite whitelist = null;
138 json =
parser.parse(jsonString).getAsJsonObject();
139 whitelist =
gson.fromJson(json, WhitelistedSite.class);
141 }
catch (JsonParseException e) {
142 logger.error(
"updateWhitelistedSite failed due to JsonParseException", e);
143 m.put(HttpCodeView.CODE, HttpStatus.BAD_REQUEST);
144 m.put(JsonErrorView.ERROR_MESSAGE,
"Could not update whitelisted site. The server encountered a JSON syntax exception. Contact a system administrator for assistance.");
145 return JsonErrorView.VIEWNAME;
146 }
catch (IllegalStateException e) {
147 logger.error(
"updateWhitelistedSite failed due to IllegalStateException", e);
148 m.put(HttpCodeView.CODE, HttpStatus.BAD_REQUEST);
149 m.put(JsonErrorView.ERROR_MESSAGE,
"Could not update whitelisted site. The server encountered an IllegalStateException. Refresh and try again - if the problem persists, contact a system administrator for assistance.");
150 return JsonErrorView.VIEWNAME;
155 if (oldWhitelist == null) {
156 logger.error(
"updateWhitelistedSite failed; whitelist with id " +
id +
" could not be found.");
157 m.put(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
158 m.put(JsonErrorView.ERROR_MESSAGE,
"Could not update whitelisted site. The requested whitelisted site with id " +
id +
"could not be found.");
159 return JsonErrorView.VIEWNAME;
164 m.put(JsonEntityView.ENTITY, newWhitelist);
166 return JsonEntityView.VIEWNAME;
static final Logger logger
Definition: WhitelistAPI.java:66
JsonParser parser
Definition: WhitelistAPI.java:69
WhitelistedSiteService whitelistService
Definition: WhitelistAPI.java:61
WhitelistedSite getById(Long id)
WhitelistedSite update(WhitelistedSite oldWhitelistedSite, WhitelistedSite whitelistedSite)
Gson gson
Definition: WhitelistAPI.java:68