diff options
Diffstat (limited to 'vid-app-common/src')
14 files changed, 563 insertions, 497 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java index 6a8439fee..1710d984f 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java @@ -195,6 +195,7 @@ public class AaiClient implements AaiClientInterface { return new AaiResponse(e.getCause(), "AAI response parsing Error" , HttpStatus.SC_INTERNAL_SERVER_ERROR); } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger,"Exception in aai response parsing", e); return new AaiResponse(e.getCause(), "Got " + aaiResponse.getHttpCode() + " from a&ai" , aaiResponse.getHttpCode()); } } @@ -335,8 +336,8 @@ public class AaiClient implements AaiClientInterface { encodedParam= URLEncoder.encode(param, "UTF-8"); } catch (UnsupportedEncodingException e) { String methodName = "getUrlFromList"; - logger.error(EELFLoggerDelegate.errorLogger, methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, methodName + e.toString()); + logger.error(EELFLoggerDelegate.errorLogger, methodName, e); + logger.debug(EELFLoggerDelegate.debugLogger, methodName, e); } url = url.concat(encodedParam); if(i != params.size()){ diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/OperationalEnvironment.java b/vid-app-common/src/main/java/org/onap/vid/aai/OperationalEnvironment.java index fd4f6c7f5..be6c6e51f 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/OperationalEnvironment.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/OperationalEnvironment.java @@ -20,9 +20,9 @@ package org.onap.vid.aai; +import org.onap.vid.aai.model.RelationshipList; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import org.onap.vid.aai.model.RelationshipList; @JsonIgnoreProperties(ignoreUnknown = true) public class OperationalEnvironment { @@ -39,15 +39,75 @@ public class OperationalEnvironment { public OperationalEnvironment() { } - public OperationalEnvironment(String operationalEnvironmentId, String operationalEnvironmentName, String operationalEnvironmentType, String operationalEnvironmentStatus, String tenantContext, String workloadContext, String resourceVersion, RelationshipList relationshipList) { - this.operationalEnvironmentId = operationalEnvironmentId; - this.operationalEnvironmentName = operationalEnvironmentName; - this.operationalEnvironmentType = operationalEnvironmentType; - this.operationalEnvironmentStatus = operationalEnvironmentStatus; - this.tenantContext = tenantContext; - this.workloadContext = workloadContext; - this.resourceVersion = resourceVersion; - this.relationshipList = relationshipList; + public OperationalEnvironment(OperationalEnvironmentBuilder builder) { + this.operationalEnvironmentId = builder.operationalEnvironmentId; + this.operationalEnvironmentName = builder.operationalEnvironmentName; + this.operationalEnvironmentType = builder.operationalEnvironmentType; + this.operationalEnvironmentStatus = builder.operationalEnvironmentStatus; + this.tenantContext = builder.tenantContext; + this.workloadContext = builder.workloadContext; + this.resourceVersion = builder.resourceVersion; + this.relationshipList = builder.relationshipList; + } + + public static class OperationalEnvironmentBuilder { + private String operationalEnvironmentId; + private String operationalEnvironmentName; + private String operationalEnvironmentType; + private String operationalEnvironmentStatus; + private String tenantContext; + private String workloadContext; + private String resourceVersion; + private RelationshipList relationshipList; + + public OperationalEnvironmentBuilder setOperationalEnvironmentId( + String operationalEnvironmentId) { + this.operationalEnvironmentId = operationalEnvironmentId; + return this; + } + + public OperationalEnvironmentBuilder setOperationalEnvironmentName( + String operationalEnvironmentName) { + this.operationalEnvironmentName = operationalEnvironmentName; + return this; + } + + public OperationalEnvironmentBuilder setOperationalEnvironmentType( + String operationalEnvironmentType) { + this.operationalEnvironmentType = operationalEnvironmentType; + return this; + } + + public OperationalEnvironmentBuilder setOperationalEnvironmentStatus( + String operationalEnvironmentStatus) { + this.operationalEnvironmentStatus = operationalEnvironmentStatus; + return this; + } + + public OperationalEnvironmentBuilder setTenantContext(String tenantContext) { + this.tenantContext = tenantContext; + return this; + } + + public OperationalEnvironmentBuilder setWorkloadContext(String workloadContext) { + this.workloadContext = workloadContext; + return this; + } + + public OperationalEnvironmentBuilder setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; + return this; + } + + public OperationalEnvironmentBuilder setRelationshipList( + RelationshipList relationshipList) { + this.relationshipList = relationshipList; + return this; + } + + public OperationalEnvironment createOperationalEnvironment() { + return new OperationalEnvironment(this); + } } public String getOperationalEnvironmentId() { diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java b/vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java index 1ee4da0b4..5641bc502 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java @@ -51,8 +51,8 @@ public class PombaClientImpl implements PombaClientInterface { try { pombaRestInterface.RestPost(fromAppId, uri, new ObjectMapper().writeValueAsString(request)); } catch (Exception e) { - logger.info(EELFLoggerDelegate.errorLogger, methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, methodName + e.toString()); + logger.info(EELFLoggerDelegate.errorLogger, methodName, e); + logger.debug(EELFLoggerDelegate.debugLogger, methodName, e); } } } diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java index 129a61041..b118901a4 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java @@ -50,8 +50,8 @@ public class PombaRestInterface extends AAIRestInterface { client = httpsAuthClientFactory.getClient(HttpClientMode.WITH_KEYSTORE); } catch (Exception e) { - logger.info(EELFLoggerDelegate.errorLogger, "Exception in REST call to DB in initRestClient" + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, "Exception in REST call to DB : " + e.toString()); + logger.info(EELFLoggerDelegate.errorLogger, "Exception in REST call to DB in initRestClient", e); + logger.debug(EELFLoggerDelegate.debugLogger, "Exception in REST call to DB : ", e); } } } diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Service.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Service.java index c3d571825..ca151a731 100644 --- a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Service.java +++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Service.java @@ -22,347 +22,425 @@ package org.onap.vid.asdc.beans; import java.util.Collection; import java.util.UUID; + /** * The Class Service. */ public class Service { - /** - * The Enum DistributionStatus. - */ - public enum DistributionStatus { + /** + * The Enum DistributionStatus. + */ + public enum DistributionStatus { + + /** The distribution not approved. */ + DISTRIBUTION_NOT_APPROVED, + + /** The distribution approved. */ + DISTRIBUTION_APPROVED, + + /** The distributed. */ + DISTRIBUTED, + + /** The distribution rejected. */ + DISTRIBUTION_REJECTED, + + /** The destributed for tenant isolation. */ + DISTRIBUTION_COMPLETE_OK + } + + /** + * The Enum LifecycleState. + */ + public enum LifecycleState { - /** The distribution not approved. */ - DISTRIBUTION_NOT_APPROVED, + /** The not certified checkout. */ + NOT_CERTIFIED_CHECKOUT, - /** The distribution approved. */ - DISTRIBUTION_APPROVED, + /** The not certified checkin. */ + NOT_CERTIFIED_CHECKIN, - /** The distributed. */ - DISTRIBUTED, + /** The ready for certification. */ + READY_FOR_CERTIFICATION, + + /** The certification in progress. */ + CERTIFICATION_IN_PROGRESS, - /** The distribution rejected. */ - DISTRIBUTION_REJECTED, + /** The certified. */ + CERTIFIED + } - /** The destributed for tenant isolation. */ - DISTRIBUTION_COMPLETE_OK - } - - /** - * The Enum LifecycleState. - */ - public enum LifecycleState { - - /** The not certified checkout. */ - NOT_CERTIFIED_CHECKOUT, - - /** The not certified checkin. */ - NOT_CERTIFIED_CHECKIN, - - /** The ready for certification. */ - READY_FOR_CERTIFICATION, - - /** The certification in progress. */ - CERTIFICATION_IN_PROGRESS, - - /** The certified. */ - CERTIFIED - } - - /** The uuid. */ - private String uuid; - - /** The invariant UUID. */ - private String invariantUUID; - - /** The name. */ - private String name; - - /** The version. */ - private String version; - - /** The tosca model URL. */ - private String toscaModelURL; - - /** The category. */ - private String category; - - /** The lifecycle state. */ - private Service.LifecycleState lifecycleState; - - /** The last updater user uid. */ - private String lastUpdaterUserId; - - /** The last updater full name. */ - private String lastUpdaterFullName; - - /** The distribution status. */ - private String distributionStatus; - - /** The artifacts. */ - private Collection<Artifact> artifacts; - - /** The resources. */ - private Collection<SubResource> resources; - - /** - * Gets the uuid. - * - * @return the uuid - */ - public String getUuid() { - return uuid; - } - - /** - * Gets the invariant UUID. - * - * @return the invariant UUID - */ - public String getInvariantUUID() { - return invariantUUID; - } - - /** - * Gets the name. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the version. - * - * @return the version - */ - public String getVersion() { - return version; - } - - /** - * Gets the tosca model URL. - * - * @return the tosca model URL - */ - public String getToscaModelURL() { - return toscaModelURL; - } - - /** - * Gets the category. - * - * @return the category - */ - public String getCategory() { - return category; - } - - /** - * Gets the lifecycle state. - * - * @return the lifecycle state - */ - public Service.LifecycleState getLifecycleState() { - return lifecycleState; - } - - /** - * Gets the last updater user uid. - * - * @return the last updater user uid - */ - public String getLastUpdaterUserId() { - return lastUpdaterUserId; - } - - /** - * Gets the last updater full name. - * - * @return the last updater full name - */ - public String getLastUpdaterFullName() { - return lastUpdaterFullName; - } - - /** - * Gets the distribution status. - * - * @return the distribution status - */ - public String getDistributionStatus() { - return distributionStatus; - } - - /** - * Gets the artifacts. - * - * @return the artifacts - */ - public Collection<Artifact> getArtifacts() { - return artifacts; - } - - /** - * Gets the resources. - * - * @return the resources - */ - public Collection<SubResource> getResources() { - return resources; - } - - /** - * Sets the uuid. - * - * @param uuid the new uuid - */ - public void setUuid(String uuid) { - this.uuid = uuid; - } - - /** - * Sets the invariant UUID. - * - * @param invariantUUID the new invariant UUID - */ - public void setInvariantUUID(String invariantUUID) { - this.invariantUUID = invariantUUID; - } - - /** - * Sets the name. - * - * @param name the new name - */ - public void setName(String name) { - this.name = name; - } - - /** - * Sets the version. - * - * @param version the new version - */ - public void setVersion(String version) { - this.version = version; - } - - /** - * Sets the tosca model URL. - * - * @param toscaModelURL the new tosca model URL - */ - public void setToscaModelURL(String toscaModelURL) { - this.toscaModelURL = toscaModelURL; - } - - /** - * Sets the category. - * - * @param category the new category - */ - public void setCategory(String category) { - this.category = category; - } - - /** - * Sets the lifecycle state. - * - * @param lifecycleState the new lifecycle state - */ - public void setLifecycleState(Service.LifecycleState lifecycleState) { - this.lifecycleState = lifecycleState; - } - - /** - * Sets the last updater user uid. - * - * @param lastUpdaterUserId the new last updater user uid - */ - public void set(String lastUpdaterUserId) { - this.lastUpdaterUserId = lastUpdaterUserId; - } - - /** - * Sets the last updater full name. - * - * @param lastUpdaterFullName the new last updater full name - */ - public void setLastUpdaterFullName(String lastUpdaterFullName) { - this.lastUpdaterFullName = lastUpdaterFullName; - } - - /** - * Sets the distribution status. - * - * @param distributionStatus the new distribution status - */ - public void setDistributionStatus(String distributionStatus) { - this.distributionStatus = distributionStatus; - } - - /** - * Sets the artifacts. - * - * @param artifacts the new artifacts - */ - public void setArtifacts(Collection<Artifact> artifacts) { - this.artifacts = artifacts; - } - - /** - * Sets the resources. - * - * @param resources the new resources - */ - public void setResources(Collection<SubResource> resources) { - this.resources = resources; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return uuid; - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - return UUID.fromString(getUuid()).hashCode(); - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object o) { - if (o == this) return true; - if (!(o instanceof Service)) return false; - - final Service service = (Service) o; - - return (service.getUuid().equals(getUuid())); - } - - public Service(String uuid, String invariantUUID, String category, String version, String name, String distributionStatus, String toscaModelURL, LifecycleState lifecycleState, Collection<Artifact> artifacts, Collection<SubResource> resources) { - this.uuid = uuid; - this.invariantUUID = invariantUUID; - this.name = name; - this.version = version; - this.toscaModelURL = toscaModelURL; - this.category = category; - this.lifecycleState = lifecycleState; - this.distributionStatus = distributionStatus; - this.artifacts = artifacts; - this.resources = resources; - } - - public Service() { - } + /** The uuid. */ + private String uuid; + + /** The invariant UUID. */ + private String invariantUUID; + + /** The name. */ + private String name; + + /** The version. */ + private String version; + + /** The tosca model URL. */ + private String toscaModelURL; + + /** The category. */ + private String category; + + /** The lifecycle state. */ + private Service.LifecycleState lifecycleState; + + /** The last updater user uid. */ + private String lastUpdaterUserId; + + /** The last updater full name. */ + private String lastUpdaterFullName; + + /** The distribution status. */ + private String distributionStatus; + + /** The artifacts. */ + private Collection<Artifact> artifacts; + + /** The resources. */ + private Collection<SubResource> resources; + + + public static class ServiceBuilder { + private String uuid; + private String invariantUUID; + private String name; + private String version; + private String toscaModelURL; + private String category; + private Service.LifecycleState lifecycleState; + private String distributionStatus; + private Collection<Artifact> artifacts; + private Collection<SubResource> resources; + + public ServiceBuilder setUuid(String uuid) { + this.uuid = uuid; + return this; + } + + public ServiceBuilder setInvariantUUID(String invariantUUID) { + this.invariantUUID = invariantUUID; + return this; + } + + public ServiceBuilder setName(String name) { + this.name = name; + return this; + } + + public ServiceBuilder setVersion(String version) { + this.version = version; + return this; + } + + public ServiceBuilder setToscaModelURL(String toscaModelURL) { + this.toscaModelURL = toscaModelURL; + return this; + } + + public ServiceBuilder setCategory(String category) { + this.category = category; + return this; + } + + public ServiceBuilder setLifecycleState(Service.LifecycleState lifecycleState) { + this.lifecycleState = lifecycleState; + return this; + } + + public ServiceBuilder setDistributionStatus(String distributionStatus) { + this.distributionStatus = distributionStatus; + return this; + } + + public ServiceBuilder setArtifacts(Collection<Artifact> artifacts) { + this.artifacts = artifacts; + return this; + } + + public ServiceBuilder setResources(Collection<SubResource> resources) { + this.resources = resources; + return this; + } + + public Service build() { + return new Service(this); + } + } + + + /** + * Gets the uuid. + * + * @return the uuid + */ + public String getUuid() { + return uuid; + } + + /** + * Gets the invariant UUID. + * + * @return the invariant UUID + */ + public String getInvariantUUID() { + return invariantUUID; + } + + /** + * Gets the name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the version. + * + * @return the version + */ + public String getVersion() { + return version; + } + + /** + * Gets the tosca model URL. + * + * @return the tosca model URL + */ + public String getToscaModelURL() { + return toscaModelURL; + } + + /** + * Gets the category. + * + * @return the category + */ + public String getCategory() { + return category; + } + + /** + * Gets the lifecycle state. + * + * @return the lifecycle state + */ + public Service.LifecycleState getLifecycleState() { + return lifecycleState; + } + + /** + * Gets the last updater user uid. + * + * @return the last updater user uid + */ + public String getLastUpdaterUserId() { + return lastUpdaterUserId; + } + + /** + * Gets the last updater full name. + * + * @return the last updater full name + */ + public String getLastUpdaterFullName() { + return lastUpdaterFullName; + } + + /** + * Gets the distribution status. + * + * @return the distribution status + */ + public String getDistributionStatus() { + return distributionStatus; + } + + /** + * Gets the artifacts. + * + * @return the artifacts + */ + public Collection<Artifact> getArtifacts() { + return artifacts; + } + + /** + * Gets the resources. + * + * @return the resources + */ + public Collection<SubResource> getResources() { + return resources; + } + + /** + * Sets the uuid. + * + * @param uuid the new uuid + */ + public void setUuid(String uuid) { + this.uuid = uuid; + } + + /** + * Sets the invariant UUID. + * + * @param invariantUUID the new invariant UUID + */ + public void setInvariantUUID(String invariantUUID) { + this.invariantUUID = invariantUUID; + } + + /** + * Sets the name. + * + * @param name the new name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Sets the version. + * + * @param version the new version + */ + public void setVersion(String version) { + this.version = version; + } + + /** + * Sets the tosca model URL. + * + * @param toscaModelURL the new tosca model URL + */ + public void setToscaModelURL(String toscaModelURL) { + this.toscaModelURL = toscaModelURL; + } + + /** + * Sets the category. + * + * @param category the new category + */ + public void setCategory(String category) { + this.category = category; + } + + /** + * Sets the lifecycle state. + * + * @param lifecycleState the new lifecycle state + */ + public void setLifecycleState(Service.LifecycleState lifecycleState) { + this.lifecycleState = lifecycleState; + } + + /** + * Sets the last updater user uid. + * + * @param lastUpdaterUserId the new last updater user uid + */ + public void set(String lastUpdaterUserId) { + this.lastUpdaterUserId = lastUpdaterUserId; + } + + /** + * Sets the last updater full name. + * + * @param lastUpdaterFullName the new last updater full name + */ + public void setLastUpdaterFullName(String lastUpdaterFullName) { + this.lastUpdaterFullName = lastUpdaterFullName; + } + + /** + * Sets the distribution status. + * + * @param distributionStatus the new distribution status + */ + public void setDistributionStatus(String distributionStatus) { + this.distributionStatus = distributionStatus; + } + + /** + * Sets the artifacts. + * + * @param artifacts the new artifacts + */ + public void setArtifacts(Collection<Artifact> artifacts) { + this.artifacts = artifacts; + } + + /** + * Sets the resources. + * + * @param resources the new resources + */ + public void setResources(Collection<SubResource> resources) { + this.resources = resources; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return uuid; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return UUID.fromString(getUuid()).hashCode(); + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object o) { + if (o == this) + return true; + if (!(o instanceof Service)) + return false; + + final Service service = (Service) o; + + return (service.getUuid().equals(getUuid())); + } + + public Service() {} + + public Service(ServiceBuilder serviceBuilder) { + + this.uuid = serviceBuilder.uuid; + this.invariantUUID = serviceBuilder.invariantUUID; + this.name = serviceBuilder.name; + this.version = serviceBuilder.version; + this.toscaModelURL = serviceBuilder.toscaModelURL; + this.category = serviceBuilder.category; + this.lifecycleState = serviceBuilder.lifecycleState; + this.distributionStatus = serviceBuilder.distributionStatus; + this.artifacts = serviceBuilder.artifacts; + this.resources = serviceBuilder.resources; + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/ServiceBuilder.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/ServiceBuilder.java deleted file mode 100644 index d2b7ffb84..000000000 --- a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/ServiceBuilder.java +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * VID - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.vid.asdc.beans; - -import java.util.Collection; - -public class ServiceBuilder { - private String uuid; - private String invariantUUID; - private String name; - private String version; - private String toscaModelURL; - private String category; - private Service.LifecycleState lifecycleState; - private String distributionStatus; - private Collection<Artifact> artifacts; - private Collection<SubResource> resources; - - public ServiceBuilder setUuid(String uuid) { - this.uuid = uuid; - return this; - } - - public ServiceBuilder setInvariantUUID(String invariantUUID) { - this.invariantUUID = invariantUUID; - return this; - } - - public ServiceBuilder setName(String name) { - this.name = name; - return this; - } - - public ServiceBuilder setVersion(String version) { - this.version = version; - return this; - } - - public ServiceBuilder setToscaModelURL(String toscaModelURL) { - this.toscaModelURL = toscaModelURL; - return this; - } - - public ServiceBuilder setCategory(String category) { - this.category = category; - return this; - } - - public ServiceBuilder setLifecycleState(Service.LifecycleState lifecycleState) { - this.lifecycleState = lifecycleState; - return this; - } - - public ServiceBuilder setDistributionStatus(String distributionStatus) { - this.distributionStatus = distributionStatus; - return this; - } - - public ServiceBuilder setArtifacts(Collection<Artifact> artifacts) { - this.artifacts = artifacts; - return this; - } - - public ServiceBuilder setResources(Collection<SubResource> resources) { - this.resources = resources; - return this; - } - - public Service build() { - return new Service(uuid, invariantUUID, category, version, name, distributionStatus, toscaModelURL, lifecycleState, artifacts, resources); - } -} - - diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java index 83757f2fb..83832bfd0 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java @@ -96,13 +96,18 @@ public class AaiServiceImpl implements AaiService { } for (ModelVer modelVer: model.getModelVers().getModelVer()) { - Service service = new Service( - modelVer.getModelVersionId(), - model.getModelInvariantId(), - category, modelVer.getModelVersion(), modelVer.getModelName(), - modelVer.getDistributionStatus(), - null, null, null, null - ); + Service service = new Service.ServiceBuilder().setUuid(modelVer.getModelVersionId()) + .setInvariantUUID(model.getModelInvariantId()) + .setCategory(category) + .setVersion(modelVer.getModelVersion()) + .setName( modelVer.getModelName()) + .setDistributionStatus(modelVer.getDistributionStatus()) + .setToscaModelURL(null) + .setLifecycleState(null) + .setArtifacts(null) + .setResources(null).build(); + + services.add(service); } diff --git a/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java index fc5a85c04..814959020 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java @@ -149,8 +149,6 @@ public class ChangeManagementServiceImpl implements ChangeManagementService { } } - - // AH:TODO: return ChangeManagementResponse return null; } @@ -162,15 +160,15 @@ public class ChangeManagementServiceImpl implements ChangeManagementService { return currentRequestDetails.getVnfInstanceId(); } - protected String extractServiceInstanceId(RequestDetails currentRequestDetails, String requestType) { - try { - String serviceInstanceId = currentRequestDetails.getRelatedInstList().get(0).getRelatedInstance().getInstanceId(); - serviceInstanceId.toString(); //throw exception in case that serviceInstanceId is null... - return serviceInstanceId; - } catch (Exception e) { + protected String extractServiceInstanceId(RequestDetails currentRequestDetails, + String requestType) { + String serviceInstanceId = currentRequestDetails.getRelatedInstList().get(0) + .getRelatedInstance().getInstanceId(); + if (serviceInstanceId == null) { logger.error("Failed to extract serviceInstanceId"); throw new BadRequestException("No instanceId in request " + requestType); } + return serviceInstanceId; } @Override @@ -227,6 +225,7 @@ public class ChangeManagementServiceImpl implements ChangeManagementService { dataAccessService.saveDomainObject(vnfList.get(0), null); } catch (NonUniqueObjectException e) { //In case the relation already exists, we continue running on the list + logger.debug("NonUniqueObjectException in addVnfWorkflowRelation", e); } } return vnfWorkflowRelationResponse; @@ -340,8 +339,11 @@ public class ChangeManagementServiceImpl implements ChangeManagementService { } private boolean validateJsonOutput(org.json.JSONObject json) { - if (!json.has(PRIMARY_KEY) || !json.getJSONObject(PRIMARY_KEY).keySet().containsAll(REQUIRED_KEYS)) - return false; - return true; + boolean isValid = true; + if (!json.has(PRIMARY_KEY) + || !json.getJSONObject(PRIMARY_KEY).keySet().containsAll(REQUIRED_KEYS)) { + isValid = false; + } + return isValid; } } diff --git a/vid-app-common/src/main/java/org/onap/vid/services/CloudOwnerServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/CloudOwnerServiceImpl.java index 8dc19cfa9..d885f205e 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/CloudOwnerServiceImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/CloudOwnerServiceImpl.java @@ -79,7 +79,7 @@ public class CloudOwnerServiceImpl implements CloudOwnerService { lcpCloudRegionId = msoRequest.extractValueByPathUsingAdditionalProperties(LCP_CLOUD_REGION_ID_PATH, String.class); } catch (NotFoundException exception) { - LOGGER.debug("Can't find lcp region in RequestDetails. Assume no cloudOwner enrichment is needed. Reason: "+exception.getMessage()); + LOGGER.debug("Can't find lcp region in RequestDetails. Assume no cloudOwner enrichment is needed. Reason: ", exception); return; } String cloudOwner = aaiClient.getCloudOwnerByCloudRegionId(lcpCloudRegionId); diff --git a/vid-app-common/src/main/java/org/onap/vid/services/CsvServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/CsvServiceImpl.java index 4a5564e9c..4aabdae21 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/CsvServiceImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/CsvServiceImpl.java @@ -197,7 +197,9 @@ public class CsvServiceImpl implements CsvService{ currentJson.put(new JSONObject().put(key, values)); } else { JSONObject lastItem = lastItemInArray(currentJson); - lastItem.put(key, values); + if(lastItem != null) { + lastItem.put(key, values); + } } } } diff --git a/vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java index db40ce23c..790dbfa55 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java @@ -61,7 +61,7 @@ public class RoleGenaratorServiceImpl implements RoleGeneratorService { } catch (Exception e) { - Log.error("There was an error in updating roles "+e.getMessage()); + Log.error("There was an error in updating roles ", e); } return query; } diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java index c331b3252..076c46284 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java @@ -56,10 +56,15 @@ public class OperationalEnvironmentTest { RelationshipList relationshipList = new RelationshipList(); relationshipList.relationship = new ArrayList<>(); - OperationalEnvironment operationalEnvironment = new OperationalEnvironment("testId", - "testEnvName", "testEnvType", - "testEnvStatus", "testTenant", "testWorkload", - "testResource", relationshipList); + OperationalEnvironment operationalEnvironment = + new OperationalEnvironment.OperationalEnvironmentBuilder() + .setOperationalEnvironmentId("testId") + .setOperationalEnvironmentName("testEnvName") + .setOperationalEnvironmentType("testEnvType") + .setOperationalEnvironmentStatus("testEnvStatus") + .setTenantContext("testTenant").setWorkloadContext("testWorkload") + .setResourceVersion("testResource").setRelationshipList(relationshipList) + .createOperationalEnvironment(); assertThat(operationalEnvironment.getOperationalEnvironmentId()).isEqualTo("testId"); assertThat(operationalEnvironment.getWorkloadContext()).isEqualTo("testWorkload"); diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientITTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientITTest.java index 12a327af8..126f30067 100644 --- a/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientITTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientITTest.java @@ -20,8 +20,25 @@ package org.onap.vid.asdc.rest; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.xebialabs.restito.semantics.Call; +import static com.xebialabs.restito.semantics.Action.ok; +import static com.xebialabs.restito.semantics.Action.stringContent; +import static org.apache.http.client.config.RequestConfig.custom; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; +import static org.hamcrest.collection.IsIterableContainingInOrder.contains; +import static org.junit.Assert.assertTrue; +import static org.onap.vid.client.SyncRestClientInterface.HEADERS.X_ECOMP_INSTANCE_ID; +import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.security.GeneralSecurityException; +import java.util.Collections; +import java.util.Optional; +import java.util.UUID; +import javax.net.ssl.SSLContext; import org.apache.http.config.Registry; import org.apache.http.config.RegistryBuilder; import org.apache.http.conn.socket.ConnectionSocketFactory; @@ -38,27 +55,8 @@ import org.onap.vid.asdc.AsdcCatalogException; import org.onap.vid.asdc.beans.Service; import org.onap.vid.client.SyncRestClient; import org.onap.vid.testUtils.StubServerUtil; - -import javax.net.ssl.SSLContext; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.security.GeneralSecurityException; -import java.util.Collections; -import java.util.Optional; -import java.util.UUID; - -import static com.xebialabs.restito.semantics.Action.ok; -import static com.xebialabs.restito.semantics.Action.stringContent; -import static org.apache.http.client.config.RequestConfig.custom; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasItems; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.matchesPattern; -import static org.hamcrest.collection.IsIterableContainingInOrder.contains; -import static org.junit.Assert.assertTrue; -import static org.onap.vid.client.SyncRestClientInterface.HEADERS.X_ECOMP_INSTANCE_ID; -import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.xebialabs.restito.semantics.Call; public class SdcRestClientITTest { @@ -124,15 +122,23 @@ public class SdcRestClientITTest { assertTrue(first.isPresent()); - assertThat(first.get().getHeaders().keySet(), hasItems(X_ECOMP_INSTANCE_ID.toLowerCase(), REQUEST_ID_HEADER_KEY.toLowerCase())); - assertThat(first.get().getHeaders().get(REQUEST_ID_HEADER_KEY.toLowerCase()).get(0), matchesPattern(UUID_REGEX)); + assertThat(first.get().getHeaders().keySet(), + hasItems(X_ECOMP_INSTANCE_ID.toLowerCase(), REQUEST_ID_HEADER_KEY.toLowerCase())); + assertThat(first.get().getHeaders().get(REQUEST_ID_HEADER_KEY.toLowerCase()).get(0), + matchesPattern(UUID_REGEX)); } private Service getExpectedService(String stringId) { - return new Service(stringId, stringId, - "sampleCategory", "sampleVersion", - "sampleName", "sampleDistStatus", - "sampleToscaUrl", Service.LifecycleState.CERTIFIED, Collections.emptyList(), Collections.emptyList()); + return new Service.ServiceBuilder().setUuid(stringId) + .setInvariantUUID(stringId) + .setCategory("sampleCategory") + .setVersion("sampleVersion") + .setName( "sampleName") + .setDistributionStatus("sampleDistStatus") + .setToscaModelURL("sampleToscaUrl") + .setLifecycleState(Service.LifecycleState.CERTIFIED) + .setArtifacts(Collections.emptyList()) + .setResources(Collections.emptyList()).build(); } diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/VidControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/VidControllerTest.java index 2c6963147..39d3cddc7 100644 --- a/vid-app-common/src/test/java/org/onap/vid/controller/VidControllerTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/controller/VidControllerTest.java @@ -35,7 +35,6 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.vid.asdc.AsdcCatalogException; import org.onap.vid.asdc.beans.SecureServices; import org.onap.vid.asdc.beans.Service; -import org.onap.vid.asdc.beans.ServiceBuilder; import org.onap.vid.model.*; import org.onap.vid.model.PombaInstance.PombaRequest; import org.onap.vid.model.PombaInstance.ServiceInstance; @@ -171,7 +170,7 @@ public class VidControllerTest { } private Service createService(String uuid, int i) { - return new ServiceBuilder().setUuid(uuid).setInvariantUUID("invariantUUID" + i) + return new Service.ServiceBuilder().setUuid(uuid).setInvariantUUID("invariantUUID" + i) .setCategory("category" + i).setVersion("version" + i).setName("name" + i) .setDistributionStatus("distStatus" + i).setToscaModelURL("toscaModelUrl" + i).build(); } |