use of com.hp.octane.integrations.services.rest.OctaneRestClient in project octane-ci-java-sdk by MicroFocus.
the class PipelineContextServiceImpl method getJobConfiguration.
@Override
public PipelineContextList getJobConfiguration(String serverIdentity, String jobName) throws IOException {
String url = getConfigurationUrl(serverIdentity, jobName);
OctaneRestClient octaneRestClient = restService.obtainOctaneRestClient();
Map<String, String> headers = new HashMap<>();
headers.put(ACCEPT_HEADER, ContentType.APPLICATION_JSON.getMimeType());
OctaneRequest request = dtoFactory.newDTO(OctaneRequest.class).setMethod(HttpMethod.GET).setUrl(url).setHeaders(headers);
OctaneResponse response = octaneRestClient.execute(request);
validateResponse(HttpStatus.SC_OK, response);
PipelineContextList result = dtoFactory.dtoFromJson(response.getBody(), PipelineContextList.class);
return result;
}
use of com.hp.octane.integrations.services.rest.OctaneRestClient in project octane-ci-java-sdk by MicroFocus.
the class BridgeServiceImpl method putAbridgedResult.
private int putAbridgedResult(String selfIdentity, String taskId, InputStream contentJSON) {
OctaneRestClient octaneRestClientImpl = restService.obtainOctaneRestClient();
Map<String, String> headers = new LinkedHashMap<>();
headers.put(RestService.CONTENT_TYPE_HEADER, ContentType.APPLICATION_JSON.getMimeType());
OctaneRequest octaneRequest = dtoFactory.newDTO(OctaneRequest.class).setMethod(HttpMethod.PUT).setUrl(configurer.octaneConfiguration.getUrl() + RestService.SHARED_SPACE_INTERNAL_API_PATH_PART + configurer.octaneConfiguration.getSharedSpace() + RestService.ANALYTICS_CI_PATH_PART + "servers/" + selfIdentity + "/tasks/" + taskId + "/result").setHeaders(headers).setBody(contentJSON);
try {
OctaneResponse octaneResponse = octaneRestClientImpl.execute(octaneRequest);
return octaneResponse.getStatus();
} catch (IOException ioe) {
logger.error(configurer.octaneConfiguration.getLocationForLog() + "failed to submit abridged task's result", ioe);
return 0;
}
}
use of com.hp.octane.integrations.services.rest.OctaneRestClient in project octane-ci-java-sdk by MicroFocus.
the class SCMDataServiceImpl method pushSCMDataByRestAPI.
private void pushSCMDataByRestAPI(String jobId, String buildId, InputStream scmData) throws IOException {
OctaneRestClient octaneRestClient = restService.obtainOctaneRestClient();
Map<String, String> headers = new HashMap<>();
headers.put(RestService.CONTENT_TYPE_HEADER, ContentType.APPLICATION_JSON.getMimeType());
boolean base64 = isEncodeBase64();
String encodedJobId = base64 ? CIPluginSDKUtils.urlEncodeBase64(jobId) : CIPluginSDKUtils.urlEncodeQueryParam(jobId);
String encodedBuildId = CIPluginSDKUtils.urlEncodeQueryParam(buildId);
String url = getSCMDataContextPath(configurer.octaneConfiguration.getUrl(), configurer.octaneConfiguration.getSharedSpace()) + "?instance-id=" + configurer.octaneConfiguration.getInstanceId() + "&job-ci-id=" + encodedJobId + "&build-ci-id=" + encodedBuildId;
if (base64) {
url = CIPluginSDKUtils.addParameterEncode64ToUrl(url);
}
OctaneRequest request = dtoFactory.newDTO(OctaneRequest.class).setMethod(HttpMethod.PUT).setUrl(url).setHeaders(headers).setBody(scmData);
OctaneResponse response = octaneRestClient.execute(request);
if (response.getStatus() == HttpStatus.SC_OK) {
logger.info(configurer.octaneConfiguration.getLocationForLog() + "scmData for " + jobId + " #" + buildId + ", push SUCCEED : " + response.getBody());
} else if (response.getStatus() == HttpStatus.SC_SERVICE_UNAVAILABLE) {
throw new TemporaryException("scmData push FAILED, service unavailable");
} else {
throw new PermanentException("scmData push FAILED, status " + response.getStatus() + "; dropping this item from the queue \n" + response.getBody());
}
}
Aggregations