replaced magic number with constant

This commit is contained in:
skubiak 2015-01-26 08:15:18 +01:00
parent 551b591802
commit bff292bdf4

View File

@ -26,6 +26,7 @@ import de.svenkubiak.jpushover.enums.Sound;
*/ */
public class JPushover { public class JPushover {
private static final Logger LOG = LoggerFactory.getLogger(JPushover.class); private static final Logger LOG = LoggerFactory.getLogger(JPushover.class);
private static final int HTTP_OK = 200;
private String pushoverToken; private String pushoverToken;
private String pushoverUser; private String pushoverUser;
@ -231,7 +232,7 @@ public class JPushover {
try { try {
httpResponse = Request.Post(Constants.VALIDATION_URL.get()).bodyForm(params, Consts.UTF_8).execute().returnResponse(); httpResponse = Request.Post(Constants.VALIDATION_URL.get()).bodyForm(params, Consts.UTF_8).execute().returnResponse();
if (httpResponse != null && httpResponse.getStatusLine().getStatusCode() == 200) { if (httpResponse != null && httpResponse.getStatusLine().getStatusCode() == HTTP_OK) {
String response = IOUtils.toString(httpResponse.getEntity().getContent()); String response = IOUtils.toString(httpResponse.getEntity().getContent());
if (StringUtils.isNotBlank(response) && response.contains("\"status\":1")) { if (StringUtils.isNotBlank(response) && response.contains("\"status\":1")) {
valid = true; valid = true;
@ -286,7 +287,7 @@ public class JPushover {
jPushoverResponse = new JPushoverResponse() jPushoverResponse = new JPushoverResponse()
.httpStatus(status) .httpStatus(status)
.response(IOUtils.toString(httpResponse.getEntity().getContent(), Consts.UTF_8)) .response(IOUtils.toString(httpResponse.getEntity().getContent(), Consts.UTF_8))
.isSuccessful((status == 200) ? true : false); .isSuccessful((status == HTTP_OK) ? true : false);
} }
} catch (IOException e) { } catch (IOException e) {
LOG.error("Failed to send message to pushover", e); LOG.error("Failed to send message to pushover", e);