use of com.hp.octane.integrations.exceptions.TemporaryException in project octane-ci-java-sdk by MicroFocus.
the class FODServiceImpl method scanIsCompleted.
private boolean scanIsCompleted(Long releaseId, Long scanId) {
try {
Scan completeScan = FODReleaseService.getCompleteScan(releaseId, scanId);
if (completeScan == null) {
return false;
}
logger.debug(configurer.octaneConfiguration.getLocationForLog() + "scan:" + scanId + " is:" + completeScan.status);
if (completeScan.status == null) {
return false;
}
// Scan that has not started, and not in progress is completed.
return (!Scan.IN_PROGRESS.equals(completeScan.status) && !Scan.NOT_STARTED.equals(completeScan.status) && !Scan.QUEUED.equals(completeScan.status));
} catch (PermanentException e) {
throw e;
} catch (TemporaryException e) {
throw e;
} catch (Exception e) {
return false;
}
}
use of com.hp.octane.integrations.exceptions.TemporaryException in project octane-ci-java-sdk by MicroFocus.
the class FODConnector method getRawResponseFromFOD.
private String getRawResponseFromFOD(String url) {
// URL encode
HttpGet httpGet = new HttpGet(url);
httpGet.setHeader("Authorization", "Bearer " + getUpdatedAccessToken());
httpGet.setHeader("Accept", "application/json");
httpGet.setHeader("Cookie", "__zlcmid=hTgaa94NtAdw5T; FoD=1725197834.36895.0000");
httpGet.setHeader("Accept-Encoding", "gzip, deflate, br");
CloseableHttpResponse response = null;
try {
logger.debug("sending the request : " + url);
response = httpClient.execute(httpGet);
if (response.getStatusLine().getStatusCode() > 300) {
if (response.getStatusLine().getStatusCode() == 401) {
throw new PermanentException("Cannot authenticate , the user is Unauthorized , make sure you are using the correct role for the user (): " + response.getStatusLine().getReasonPhrase());
}
if (response.getStatusLine().getStatusCode() == 503) {
throw new TemporaryException("Service Unavailable , retry");
}
throw new PermanentException("unexpected return response : " + response.getStatusLine().getReasonPhrase());
}
return isToString(response.getEntity().getContent());
} catch (IOException e) {
throw new PermanentException(e);
} finally {
if (response != null) {
EntityUtils.consumeQuietly(response.getEntity());
HttpClientUtils.closeQuietly(response);
}
}
}
Aggregations