aboutsummaryrefslogtreecommitdiffstats
path: root/mso-catalog-db
diff options
context:
space:
mode:
authorSmokowski, Steven <steve.smokowski@att.com>2020-02-12 11:13:08 -0500
committerBenjamin, Max (mb388a) <mb388a@att.com>2020-02-12 11:13:09 -0500
commit5ba5518f6b9dffbf0fed7f3655b1635cd818bc1e (patch)
tree417a3b906a03726a760ffbfc3c543f20022ff707 /mso-catalog-db
parent1980195d94d2208c8f5c8951885cfe345fbc8dd1 (diff)
mso to add support for creating the cloud region
Initial check in to support cloud region create Add additional junit tests Add additional integration tests Updated junit to use spy and removed setter method Issue-ID: SO-2657 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: I6a93f3b4caf7d640ffa5842981247d284b9013ad
Diffstat (limited to 'mso-catalog-db')
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java57
1 files changed, 55 insertions, 2 deletions
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
index 7f5907e9bf..161ca2a2fb 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
@@ -764,8 +764,61 @@ public class CatalogDbClient {
return this.getSingleResource(cloudSiteClient, getUri(uri + id));
}
- public void postCloudSite(CloudSite cloudSite) {
- this.postSingleResource(cloudSiteClient, cloudSite);
+ public CloudSite postCloudSite(CloudSite cloudSite) {
+ if (cloudSite == null) {
+ throw new EntityNotFoundException("CloudSite passed as null");
+ }
+ try {
+ HttpHeaders headers = getHttpHeaders();
+ HttpEntity<CloudSite> entity = new HttpEntity<>(cloudSite, headers);
+ CloudSite updatedCloudSite = restTemplate
+ .exchange(UriComponentsBuilder.fromUriString(endpoint + "/cloudSite").build().encode().toString(),
+ HttpMethod.POST, entity, CloudSite.class)
+ .getBody();
+ return updatedCloudSite;
+ } catch (HttpClientErrorException e) {
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ throw new EntityNotFoundException("Unable to find CloudSite with Cloud Site Id: " + cloudSite.getId());
+ }
+ throw e;
+ }
+ }
+
+ public CloudSite updateCloudSite(CloudSite cloudSite) {
+ if (cloudSite == null) {
+ throw new EntityNotFoundException("CloudSite passed as null");
+ }
+ try {
+ HttpHeaders headers = getHttpHeaders();
+ HttpEntity<CloudSite> entity = new HttpEntity<>(cloudSite, headers);
+ CloudSite updatedCloudSite = restTemplate
+ .exchange(UriComponentsBuilder.fromUriString(endpoint + "/cloudSite/" + cloudSite.getId()).build()
+ .encode().toString(), HttpMethod.PUT, entity, CloudSite.class)
+ .getBody();
+ return updatedCloudSite;
+ } catch (HttpClientErrorException e) {
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ throw new EntityNotFoundException("Unable to find CloudSite with Cloud Site Id: " + cloudSite.getId());
+ }
+ throw e;
+ }
+ }
+
+ public void deleteCloudSite(String cloudSiteId) {
+ if (cloudSiteId == null) {
+ throw new EntityNotFoundException("CloudSiteId passed as null");
+ }
+ try {
+ HttpHeaders headers = getHttpHeaders();
+ HttpEntity<String> entity = new HttpEntity<>(null, headers);
+ restTemplate.exchange(UriComponentsBuilder.fromUriString(endpoint + "/cloudSite/" + cloudSiteId).build()
+ .encode().toString(), HttpMethod.DELETE, entity, CloudSite.class).getBody();
+ } catch (HttpClientErrorException e) {
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ throw new EntityNotFoundException("Unable to find CloudSite with Cloud Site Id: " + cloudSiteId);
+ }
+ throw e;
+ }
}
public List<CloudSite> getCloudSites() {