132 BlacklistedSite blacklist = null;
136 json =
parser.parse(jsonString).getAsJsonObject();
137 blacklist =
gson.fromJson(json, BlacklistedSite.class);
140 catch (JsonSyntaxException e) {
141 logger.error(
"updateBlacklistedSite failed due to JsonSyntaxException", e);
142 m.put(HttpCodeView.CODE, HttpStatus.BAD_REQUEST);
143 m.put(JsonErrorView.ERROR_MESSAGE,
"Could not update blacklisted site. The server encountered a JSON syntax exception. Contact a system administrator for assistance.");
144 return JsonErrorView.VIEWNAME;
145 }
catch (IllegalStateException e) {
146 logger.error(
"updateBlacklistedSite failed due to IllegalStateException", e);
147 m.put(HttpCodeView.CODE, HttpStatus.BAD_REQUEST);
148 m.put(JsonErrorView.ERROR_MESSAGE,
"Could not update blacklisted site. The server encountered an IllegalStateException. Refresh and try again - if the problem persists, contact a system administrator for assistance.");
149 return JsonErrorView.VIEWNAME;
155 if (oldBlacklist == null) {
156 logger.error(
"updateBlacklistedSite failed; blacklist with id " +
id +
" could not be found");
157 m.put(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
158 m.put(JsonErrorView.ERROR_MESSAGE,
"Could not update blacklisted site. The requested blacklist with id " +
id +
"could not be found.");
159 return JsonErrorView.VIEWNAME;
164 m.put(JsonEntityView.ENTITY, newBlacklist);
166 return JsonEntityView.VIEWNAME;
BlacklistedSite getById(Long id)
static final Logger logger
Definition: BlacklistAPI.java:66
Gson gson
Definition: BlacklistAPI.java:68
BlacklistedSite update(BlacklistedSite oldBlacklistedSite, BlacklistedSite blacklistedSite)
BlacklistedSiteService blacklistService
Definition: BlacklistAPI.java:61
JsonParser parser
Definition: BlacklistAPI.java:69