import org.springframework.http.HttpStatus;
public class GetMetricsService {
- private static Logger LOGGER = FlexLogger
- .getLogger(GetDictionaryService.class.getName());
+ private static final Logger LOGGER = FlexLogger
+ .getLogger(GetMetricsService.class.getName());
private MetricsResponse response = null;
private HttpStatus status = HttpStatus.BAD_REQUEST;
- private String message = null;
private MetricsRequestParameters metricsParameters = null;
public GetMetricsService(String requestID) {
requestUUID = UUID.fromString(requestID);
} catch (IllegalArgumentException e) {
requestUUID = UUID.randomUUID();
- LOGGER.info("Generated Random UUID: " + requestUUID.toString());
+ LOGGER.info("Generated Random UUID: " + requestUUID.toString(), e);
}
} else {
requestUUID = UUID.randomUUID();
}
private void specialCheck() {
- if (response != null) {
- if (response.getResponseMessage() != null
- && response.getResponseMessage().contains("PE300")) {
+ if (response != null && (response.getResponseMessage() != null
+ && response.getResponseMessage().contains("PE300"))) {
status = HttpStatus.BAD_REQUEST;
- }
}
}
metricsParameters.getRequestID(), "metrics");
JSONObject json = null;
+ String message = null;
if (result != null) {
if (result.length() > 81 && result.contains("{")) {
try {
String responseMessage = result.substring(0, 82);
- String jsonString = result.substring(result.indexOf("{"),
+ String jsonString = result.substring(result.indexOf('{'),
result.length());
json = new JSONObject(jsonString);
metricsResponse.setPdpMetrics(pdpCount);
} catch (JsonException | IllegalStateException e) {
+ String jsonString = null;
+ if(json != null){
+ jsonString = json.toString();
+ }
message = XACMLErrorConstants.ERROR_DATA_ISSUE
- + " improper JSON object : " + json != null ? json.toString() : "JSON is null";
- LOGGER.error(message);
+ + " improper JSON object : " + jsonString;
+ LOGGER.error(message + e);
metricsResponse.setResponseMessage(message);
metricsResponse.setResponseCode(400);
return metricsResponse;