import javax.ws.rs.InternalServerErrorException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriBuilder;
-
import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse;
import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest;
@Component
public class VnfVolumeAdapterClientImpl implements VnfVolumeAdapterClient {
- private final VnfVolumeAdapterRestProperties props;
+ private final VnfVolumeAdapterRestProperties props;
- public VnfVolumeAdapterClientImpl() {
- this.props = new VnfVolumeAdapterRestProperties();
- }
+ public VnfVolumeAdapterClientImpl() {
+ this.props = new VnfVolumeAdapterRestProperties();
+ }
- @Override
- public CreateVolumeGroupResponse createVNFVolumes(CreateVolumeGroupRequest req) throws VnfAdapterClientException {
- try {
- return this.getAdapterRestClient("").post(req, CreateVolumeGroupResponse.class);
- } catch (InternalServerErrorException e) {
- throw new VnfAdapterClientException(e.getMessage());
- }
- }
+ @Override
+ public CreateVolumeGroupResponse createVNFVolumes(CreateVolumeGroupRequest req) throws VnfAdapterClientException {
+ try {
+ return this.getAdapterRestClient("").post(req, CreateVolumeGroupResponse.class);
+ } catch (InternalServerErrorException e) {
+ throw new VnfAdapterClientException(e.getMessage());
+ }
+ }
- @Override
- public DeleteVolumeGroupResponse deleteVNFVolumes(String aaiVolumeGroupId, DeleteVolumeGroupRequest req)
- throws VnfAdapterClientException {
- try {
- return this.getAdapterRestClient("/" + aaiVolumeGroupId).delete(req, DeleteVolumeGroupResponse.class);
- } catch (InternalServerErrorException e) {
- throw new VnfAdapterClientException(e.getMessage());
- }
- }
+ @Override
+ public DeleteVolumeGroupResponse deleteVNFVolumes(String aaiVolumeGroupId, DeleteVolumeGroupRequest req)
+ throws VnfAdapterClientException {
+ try {
+ return this.getAdapterRestClient("/" + aaiVolumeGroupId).delete(req, DeleteVolumeGroupResponse.class);
+ } catch (InternalServerErrorException e) {
+ throw new VnfAdapterClientException(e.getMessage());
+ }
+ }
- @Override
- public RollbackVolumeGroupResponse rollbackVNFVolumes(String aaiVolumeGroupId, RollbackVolumeGroupRequest req)
- throws VnfAdapterClientException {
- try {
- return this.getAdapterRestClient("/" + aaiVolumeGroupId + "/rollback").delete(req,
- RollbackVolumeGroupResponse.class);
- } catch (InternalServerErrorException e) {
- throw new VnfAdapterClientException(e.getMessage());
- }
- }
+ @Override
+ public RollbackVolumeGroupResponse rollbackVNFVolumes(String aaiVolumeGroupId, RollbackVolumeGroupRequest req)
+ throws VnfAdapterClientException {
+ try {
+ return this.getAdapterRestClient("/" + aaiVolumeGroupId + "/rollback").delete(req,
+ RollbackVolumeGroupResponse.class);
+ } catch (InternalServerErrorException e) {
+ throw new VnfAdapterClientException(e.getMessage());
+ }
+ }
- @Override
- public UpdateVolumeGroupResponse updateVNFVolumes(String aaiVolumeGroupId, UpdateVolumeGroupRequest req)
- throws VnfAdapterClientException {
- try {
- return this.getAdapterRestClient("/" + aaiVolumeGroupId).put(req, UpdateVolumeGroupResponse.class);
- } catch (InternalServerErrorException e) {
- throw new VnfAdapterClientException(e.getMessage());
- }
- }
+ @Override
+ public UpdateVolumeGroupResponse updateVNFVolumes(String aaiVolumeGroupId, UpdateVolumeGroupRequest req)
+ throws VnfAdapterClientException {
+ try {
+ return this.getAdapterRestClient("/" + aaiVolumeGroupId).put(req, UpdateVolumeGroupResponse.class);
+ } catch (InternalServerErrorException e) {
+ throw new VnfAdapterClientException(e.getMessage());
+ }
+ }
- @Override
- public QueryVolumeGroupResponse queryVNFVolumes(String aaiVolumeGroupId, String cloudSiteId, String tenantId,
- String volumeGroupStackId, Boolean skipAAI, String requestId, String serviceInstanceId)
- throws VnfAdapterClientException {
- try {
- String path = buildQueryPath(aaiVolumeGroupId, cloudSiteId, tenantId, volumeGroupStackId, skipAAI,
- requestId, serviceInstanceId);
- return this.getAdapterRestClient(path).get(QueryVolumeGroupResponse.class).get();
- } catch (InternalServerErrorException e) {
- throw new VnfAdapterClientException(e.getMessage());
- }
- }
+ @Override
+ public QueryVolumeGroupResponse queryVNFVolumes(String aaiVolumeGroupId, String cloudSiteId, String tenantId,
+ String volumeGroupStackId, Boolean skipAAI, String requestId, String serviceInstanceId)
+ throws VnfAdapterClientException {
+ try {
+ String path = buildQueryPath(aaiVolumeGroupId, cloudSiteId, tenantId, volumeGroupStackId, skipAAI,
+ requestId, serviceInstanceId);
+ return this.getAdapterRestClient(path).get(QueryVolumeGroupResponse.class).get();
+ } catch (InternalServerErrorException e) {
+ throw new VnfAdapterClientException(e.getMessage());
+ }
+ }
- protected String buildQueryPath(String aaiVolumeGroupId, String cloudSiteId, String tenantId,
- String volumeGroupStackId, Boolean skipAAI, String requestId, String serviceInstanceId) {
- javax.ws.rs.core.UriBuilder builder = this.getUri("/" + aaiVolumeGroupId);
- builder.queryParam("cloudSiteId", cloudSiteId).queryParam("tenantId", tenantId)
- .queryParam("volumeGroupStackId", volumeGroupStackId).queryParam("skipAAI", skipAAI)
- .queryParam("msoRequest.requestId", requestId)
- .queryParam("msoRequest.serviceInstanceId", serviceInstanceId);
- return builder.build().toString();
- }
+ protected String buildQueryPath(String aaiVolumeGroupId, String cloudSiteId, String tenantId,
+ String volumeGroupStackId, Boolean skipAAI, String requestId, String serviceInstanceId) {
+ javax.ws.rs.core.UriBuilder builder = this.getUri("/" + aaiVolumeGroupId);
+ builder.queryParam("cloudSiteId", cloudSiteId).queryParam("tenantId", tenantId)
+ .queryParam("volumeGroupStackId", volumeGroupStackId).queryParam("skipAAI", skipAAI)
+ .queryParam("msoRequest.requestId", requestId)
+ .queryParam("msoRequest.serviceInstanceId", serviceInstanceId);
+ return builder.build().toString();
+ }
- protected UriBuilder getUri(String path) {
- return UriBuilder.fromPath(path);
- }
+ protected UriBuilder getUri(String path) {
+ return UriBuilder.fromPath(path);
+ }
- protected RestClient getAdapterRestClient(String path) {
- return new AdapterRestClient(props, this.getUri(path).build(), MediaType.APPLICATION_JSON,
- MediaType.APPLICATION_JSON);
- }
+ protected RestClient getAdapterRestClient(String path) {
+ return new AdapterRestClient(props, this.getUri(path).build(), MediaType.APPLICATION_JSON,
+ MediaType.APPLICATION_JSON);
+ }
}