use of com.checkmarx.flow.dto.servicenow.Incident in project cx-flow by checkmarx-ltd.
the class ServiceNowTracker method updateIncidentFromIssue.
/**
* Update Incident from Issue.
*
* @param issue
* @param resultIssue
* @return Incident object.
*/
private Incident updateIncidentFromIssue(Issue issue, ScanResults.XIssue resultIssue) {
Incident incident = new Incident();
incident.setSysId(issue.getId());
incident.setSeverity(getSeverityId(resultIssue.getSeverity()));
incident.setState(TRANSITION_OPEN);
incident.setIncidentState(TRANSITION_OPEN);
return incident;
}
use of com.checkmarx.flow.dto.servicenow.Incident in project cx-flow by checkmarx-ltd.
the class ServiceNowTracker method getCloseIncident.
/**
* Create Service Now object out of the Issue/ScanRequest for close issue.
* @return Incident object
*/
private Incident getCloseIncident() {
Incident incident = new Incident();
incident.setState(TRANSITION_CLOSE);
incident.setIncidentState(TRANSITION_CLOSE);
incident.setCloseNotes(String.format("Closing reason: %s", CLOSING_NOTE));
incident.setCloseCode(CLOSE_CODE);
return incident;
}
use of com.checkmarx.flow.dto.servicenow.Incident in project cx-flow by checkmarx-ltd.
the class ServiceNowTracker method updateIssue.
@Override
public Issue updateIssue(Issue issue, ScanResults.XIssue resultIssue, ScanRequest request) throws MachinaException {
log.info("Executing updateIssue Service Now API call");
Incident incident = updateIncidentFromIssue(issue, resultIssue);
try {
String query = String.format("%s%s/%s", properties.getApiUrl(), INCIDENTS, issue.getId());
this.addComment(incident, resultIssue.getLink(), "Issue still exists.");
restOperations.put(query, incident);
return getIssues(request).stream().findFirst().orElseThrow(() -> new MachinaException("Incident record hasn't been found."));
} catch (HttpClientErrorException e) {
log.error("Error updating issue.");
throw new MachinaRuntimeException();
}
}
use of com.checkmarx.flow.dto.servicenow.Incident in project cx-flow by checkmarx-ltd.
the class ServiceNowTracker method getCreateIncident.
/**
* Create Service Now object out of the Issue/ScanRequest for a new/update issue.
* @param resultIssue
* @param request
* @return Incident object
*/
private Incident getCreateIncident(ScanResults.XIssue resultIssue, ScanRequest request) {
String tag = createServiceNowTag(request);
String title = HTMLHelper.getScanRequestIssueKeyWithDefaultProductValue(request, this, resultIssue);
String body = HTMLHelper.getTextBody(resultIssue, request, flowProperties);
Incident incident = new Incident();
incident.setShortDescription(title);
incident.setDescription(convertToText(body));
incident.setSeverity(getSeverityId(resultIssue.getSeverity()));
incident.setComments(tag);
incident.setWorkNotes(request.getAdditionalMetadata("tagsList"));
incident.setState(TRANSITION_OPEN);
incident.setIncidentState(TRANSITION_OPEN);
return incident;
}
use of com.checkmarx.flow.dto.servicenow.Incident in project cx-flow by checkmarx-ltd.
the class ServiceNowTracker method closeIssue.
@Override
public void closeIssue(Issue issue, ScanRequest request) throws MachinaException {
log.info("Executing closeIssue Service Now API call");
Incident incident = getCloseIncident();
try {
String query = String.format("%s%s/%s", properties.getApiUrl(), INCIDENTS, issue.getId());
log.debug("ServiceNow Close Issues URL: {}", query);
restOperations.put(query, incident);
} catch (HttpClientErrorException e) {
log.error("Error closing issue.Details are:" + e.getMessage());
throw new MachinaRuntimeException(e);
}
}
Aggregations