Search in sources :

Example 1 with CreateResultAction

use of com.checkmarx.flow.dto.rally.CreateResultAction in project cx-flow by checkmarx-ltd.

the class RallyIssueTracker method createRallyTag.

/**
 * Creates or locates existing Rally tag and return it's reference.
 *
 * @param name The name of the Rally Tag to create or locate
 * @return String containing the reference, this should never be null!
 */
private JSONObject createRallyTag(String name) {
    log.info("Creating Rally Tag: ".concat(name));
    HttpEntity httpEntity = new HttpEntity(getJSONCreateTag(name), createAuthHeaders());
    CreateResultAction cra;
    ResponseEntity<CreateResultAction> response;
    response = restTemplate.exchange(properties.getApiUrl().concat(CREATE_TAG), HttpMethod.POST, httpEntity, CreateResultAction.class);
    cra = response.getBody();
    Map<String, Object> m = (Map<String, Object>) cra.getAdditionalProperties().get("CreateResult");
    m = (Map<String, Object>) m.get("Object");
    JSONObject cxFlowTag = new JSONObject();
    cxFlowTag.put("_ref", (String) m.get("_ref"));
    return cxFlowTag;
}
Also used : CreateResultAction(com.checkmarx.flow.dto.rally.CreateResultAction) JSONObject(org.json.JSONObject) JSONObject(org.json.JSONObject) Map(java.util.Map)

Example 2 with CreateResultAction

use of com.checkmarx.flow.dto.rally.CreateResultAction in project cx-flow by checkmarx-ltd.

the class RallyIssueTracker method createIssue.

/**
 * Creates new Rally defect.
 *
 * @param resultIssue
 * @param request
 * @return
 * @throws MachinaException
 */
@Override
public Issue createIssue(ScanResults.XIssue resultIssue, ScanRequest request) throws MachinaException {
    log.debug("Executing createIssue Rally API call");
    try {
        String json = getJSONCreateIssue(resultIssue, request);
        HttpEntity httpEntity = new HttpEntity(json, createAuthHeaders());
        CreateResultAction cra;
        ResponseEntity<CreateResultAction> response;
        response = restTemplate.exchange(properties.getApiUrl().concat(CREATE_ISSUE), HttpMethod.POST, httpEntity, CreateResultAction.class);
        cra = response.getBody();
        Map<String, Object> m = (Map<String, Object>) cra.getAdditionalProperties().get("CreateResult");
        m = (Map<String, Object>) m.get("Object");
        return mapHashManToIssue(m);
    } catch (HttpClientErrorException e) {
        log.error("Error occurred while creating Rally Issue");
        log.error(ExceptionUtils.getStackTrace(e));
        throw new MachinaRuntimeException();
    }
}
Also used : CreateResultAction(com.checkmarx.flow.dto.rally.CreateResultAction) HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) MachinaRuntimeException(com.checkmarx.flow.exception.MachinaRuntimeException) JSONObject(org.json.JSONObject) Map(java.util.Map)

Aggregations

CreateResultAction (com.checkmarx.flow.dto.rally.CreateResultAction)2 Map (java.util.Map)2 JSONObject (org.json.JSONObject)2 MachinaRuntimeException (com.checkmarx.flow.exception.MachinaRuntimeException)1 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)1