use of com.checkmarx.flow.dto.servicenow.Result in project cx-flow by checkmarx-ltd.
the class ServiceNowTracker method getIssues.
/**
* Get Incidents/Issues from Service Now.
* @param request
* @return issues collection of data.
* @throws MachinaException
*/
@Override
public List<Issue> getIssues(ScanRequest request) throws MachinaException {
log.debug("Executing getIssues Service Now API call");
try {
String apiRequest = createServiceNowRequest(request);
URI apiRequestUri = URI.create(apiRequest);
Optional<Result> res = Optional.ofNullable(restOperations.getForObject(apiRequestUri, Result.class));
if (res.isPresent()) {
List results = res.get().getIncidents().stream().map(i -> mapToIssue(i)).collect(Collectors.toList());
log.debug("Found {} issues in ServiceNow for this project.", results != null ? results.size() : 0);
return results;
}
} catch (RestClientException e) {
log.error("Error occurred while fetching ServiceNow Issues");
log.error(ExceptionUtils.getStackTrace(e));
throw new MachinaRuntimeException();
}
return Lists.newArrayList();
}
use of com.checkmarx.flow.dto.servicenow.Result in project cx-flow by checkmarx-ltd.
the class ServiceNowTracker method getIncidentByIDConvertToIssue.
/**
* Find Incident By Sys ID and convert into Issue
* @return Issue object.
*/
private Optional<Issue> getIncidentByIDConvertToIssue(String sysId) {
log.debug("Executing getIncidentByIDConvertToIssue");
try {
String apiRequest = String.format("%s%s?sys_id=%s", properties.getApiUrl(), INCIDENTS, sysId);
Optional<Result> res = Optional.ofNullable(restOperations.getForObject(apiRequest, Result.class));
if (res.isPresent()) {
return res.get().getIncidents().stream().map(i -> this.mapToIssue(i)).findFirst();
}
} catch (RestClientException e) {
log.error("Error occurred while fetching ServiceNow Issue");
log.error(ExceptionUtils.getStackTrace(e));
throw new MachinaRuntimeException();
}
return Optional.empty();
}
Aggregations