use of org.onap.so.rest.exceptions.HttpResouceNotFoundException in project so by onap.
the class VnfmAdapterServiceProviderImpl method invokeCreateInstantiationRequest.
@Override
public Optional<CreateVnfResponse> invokeCreateInstantiationRequest(final String vnfId, final CreateVnfRequest request) {
try {
final String url = urlProvider.getCreateInstantiateUrl(vnfId);
final ResponseEntity<CreateVnfResponse> response = httpServiceProvider.postHttpRequest(request, url, CreateVnfResponse.class);
final HttpStatus httpStatus = response.getStatusCode();
if (!(httpStatus.equals(HttpStatus.ACCEPTED)) && !(httpStatus.equals(HttpStatus.OK))) {
LOGGER.error("Unable to invoke HTTP POST using URL: {}, Response Code: {}", url, httpStatus.value());
return Optional.absent();
}
if (!response.hasBody()) {
LOGGER.error(RECEIVED_RESPONSE_WITHOUT_BODY, response);
return Optional.absent();
}
final CreateVnfResponse createVnfResponse = response.getBody();
if (createVnfResponse.getJobId() == null || createVnfResponse.getJobId().isEmpty()) {
LOGGER.error("Received invalid instantiation response: {}", response);
return Optional.absent();
}
return Optional.of(createVnfResponse);
} catch (final RestProcessingException | InvalidRestRequestException | HttpResouceNotFoundException httpInvocationException) {
LOGGER.error("Unexpected error while processing create and instantiation request", httpInvocationException);
return Optional.absent();
}
}
use of org.onap.so.rest.exceptions.HttpResouceNotFoundException in project so by onap.
the class VnfmAdapterServiceProviderImpl method getInstantiateOperationJobStatus.
@Override
public Optional<QueryJobResponse> getInstantiateOperationJobStatus(final String jobId) {
try {
final String url = urlProvider.getJobStatusUrl(jobId);
final ResponseEntity<QueryJobResponse> response = httpServiceProvider.getHttpResponse(url, QueryJobResponse.class);
final HttpStatus httpStatus = response.getStatusCode();
if (!(httpStatus.equals(HttpStatus.ACCEPTED)) && !(httpStatus.equals(HttpStatus.OK))) {
LOGGER.error("Unable to invoke HTTP GET using URL: {}, Response Code: ", url, httpStatus.value());
return Optional.absent();
}
if (!response.hasBody()) {
LOGGER.error(RECEIVED_RESPONSE_WITHOUT_BODY, response);
return Optional.absent();
}
return Optional.of(response.getBody());
} catch (final RestProcessingException | InvalidRestRequestException | HttpResouceNotFoundException httpInvocationException) {
LOGGER.error("Unexpected error while processing job request", httpInvocationException);
throw httpInvocationException;
}
}
Aggregations