summaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-07-12 00:54:52 +0300
committerMichael Lando <ml636r@att.com>2017-07-12 01:55:12 +0300
commitdd60339b06d252fcb1382aa97ab3d65b37dad021 (patch)
treec1551ce67cd77ca810ad5f579eb3617af86be85f /catalog-be/src
parentab146a193c43e9be0e9efeac7bab2690a7ba2d33 (diff)
[sdc] rebase update
Change-Id: I8f1fc7150975122dd9f3f4e653b9983064b399a6 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/ArtifactsResolver.java20
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactResolverImpl.java20
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java5
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/ComponentValidations.java20
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java20
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/distribution/servlet/DistributionCatalogServlet.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/distribution/servlet/DistributionServlet.java20
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java16
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServlet.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java24
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertor.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java46
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java4
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java20
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java20
16 files changed, 219 insertions, 38 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/ArtifactsResolver.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/ArtifactsResolver.java
index 95f1edd61f..0762872797 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/ArtifactsResolver.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/ArtifactsResolver.java
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.sdc.be.components;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactResolverImpl.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactResolverImpl.java
index 7ef3a1961f..141ed95575 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactResolverImpl.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactResolverImpl.java
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.sdc.be.components.impl;
import org.openecomp.sdc.be.components.ArtifactsResolver;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
index e5d380a836..cb04cfcdc9 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
@@ -3599,10 +3599,11 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
protected Either<ArtifactDefinition, ResponseFormat> generateArtifactPayload(ArtifactDefinition artifactDefinition, ComponentTypeEnum componentType, org.openecomp.sdc.be.model.Component component, String resourceInstanceName, User modifier,
boolean shouldLock, Supplier<Long> payloadUpdateDateGen, Supplier<Either<ESArtifactData, ResponseFormat>> esDataCreator, String instanceId) {
+
+ log.trace("Start generating payload for {} artifact {}", artifactDefinition.getArtifactType(), artifactDefinition.getEsId());
+ if (artifactDefinition.getPayloadUpdateDate() == null || artifactDefinition.getPayloadUpdateDate() == 0 || artifactDefinition.getPayloadUpdateDate() <= payloadUpdateDateGen.get()) {
- if (artifactDefinition.getPayloadUpdateDate() == null || artifactDefinition.getPayloadUpdateDate() == 0 || artifactDefinition.getPayloadUpdateDate() < payloadUpdateDateGen.get()) {
-
- log.trace("Generaing payload for {} artifact {}", artifactDefinition.getArtifactType(), artifactDefinition.getEsId());
+ log.trace("Generating payload for {} artifact {}", artifactDefinition.getArtifactType(), artifactDefinition.getEsId());
Either<ESArtifactData, ResponseFormat> artifactDataRes = esDataCreator.get();
ESArtifactData artifactData = null;
@@ -3664,6 +3665,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
artifactDefinition.setArtifactChecksum(newCheckSum);
// artifactToscaOperation.updateUUID(artifactDefinition, oldCheckSum, artifactDefinition.getArtifactVersion());
artifactDefinition.setEsId(artifactDefinition.getUniqueId());
+ log.trace("No real update done in payload for {} artifact, updating payloadUpdateDate {}", artifactDefinition.getArtifactType(), artifactDefinition.getEsId());
updateArifactDefinitionStatus = artifactToscaOperation.updateArifactOnResource(artifactDefinition, component.getUniqueId(), artifactDefinition.getUniqueId(), componentType.getNodeType(), instanceId);
log.trace("Update Payload ", artifactDefinition.getEsId());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
index 8d8aa72c8f..643b35d17b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
@@ -41,6 +41,7 @@ import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
+import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
@@ -557,7 +558,8 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
ComponentInstance origInst = iterator.next();
Optional<ComponentInstance> op = componentInstanceList.stream().filter(ci -> ci.getUniqueId().equals(origInst.getUniqueId())).findAny();
if(op.isPresent()){
- ComponentInstance updatedCi = op.get();
+ ComponentInstance updatedCi = op.get();
+ updatedCi.setCustomizationUUID(origInst.getCustomizationUUID());
Boolean isUniqueName = validateInstanceNameUniquenessUponUpdate(containerComponent, origInst, updatedCi.getName());
if(!isUniqueName){
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to update the name of the component instance {} to {}. A component instance with the same name already exists. ",
@@ -1636,6 +1638,7 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
newComponentInstance.setPosX(resResourceInfo.getPosX());
newComponentInstance.setPosY(resResourceInfo.getPosY());
newComponentInstance.setDescription(resResourceInfo.getDescription());
+ newComponentInstance.setToscaComponentName(((ResourceMetadataDataDefinition)origComponent.getComponentMetadataDefinition().getMetadataDataDefinition()).getToscaResourceName());
resultOp = createComponentInstanceOnGraph(containerComponent, origComponent, newComponentInstance, user);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/ComponentValidations.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/ComponentValidations.java
index b50c8ef9d1..7964b4406c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/ComponentValidations.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/ComponentValidations.java
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.sdc.be.components.validation;
import org.openecomp.sdc.be.model.Component;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java
index 6edfe81fee..f2a5b35562 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.sdc.be.datamodel.utils;
import java.util.ArrayList;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/distribution/servlet/DistributionCatalogServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/distribution/servlet/DistributionCatalogServlet.java
index 5ed0719f90..7001740a18 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/distribution/servlet/DistributionCatalogServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/distribution/servlet/DistributionCatalogServlet.java
@@ -98,7 +98,7 @@ public class DistributionCatalogServlet extends BeGenericServlet {
@ApiOperation(value = "Download service artifact", httpMethod = "GET", notes = "Returns downloaded artifact", response = String.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "The artifact is found and streamed.", response = String.class),
- @ApiResponse(code = 400, message = "Missing “X-ECOMP-InstanceID” HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 404, message = "Specified Service is not found - SVC4503"),
@@ -177,7 +177,7 @@ public class DistributionCatalogServlet extends BeGenericServlet {
@ApiOperation(value = "Download resource artifact", httpMethod = "GET", notes = "Returns downloaded artifact", response = String.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "The artifact is found and streamed.", response = String.class),
- @ApiResponse(code = 400, message = "Missing “X-ECOMP-InstanceID” HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 404, message = "Specified Service is not found - SVC4503"),
@@ -258,7 +258,7 @@ public class DistributionCatalogServlet extends BeGenericServlet {
@ApiOperation(value = "Download resource instance artifact", httpMethod = "GET", notes = "Returns downloaded artifact", response = String.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "The artifact is found and streamed.", response = String.class),
- @ApiResponse(code = 400, message = "Missing “X-ECOMP-InstanceID” HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 404, message = "Specified Service is not found - SVC4503"),
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/distribution/servlet/DistributionServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/distribution/servlet/DistributionServlet.java
index ab760218a7..71e97f79bd 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/distribution/servlet/DistributionServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/distribution/servlet/DistributionServlet.java
@@ -106,7 +106,7 @@ public class DistributionServlet extends BeGenericServlet {
@ResponseHeader(name = "Content-Length", description = "Length of the response body", response = String.class)})
@ApiResponses(value = {
@ApiResponse(code = 200, message = "ECOMP component is authenticated and list of Cambria API server’s FQDNs is returned", response = ServerListResponse.class),
- @ApiResponse(code = 400, message = "Missing “X-ECOMP-InstanceID” HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its credentials for Basic Authentication - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 405, message = "Method Not Allowed: Invalid HTTP method type used ( PUT,DELETE,POST will be rejected) - POL4050"),
@@ -174,11 +174,11 @@ public class DistributionServlet extends BeGenericServlet {
@ApiOperation(value = "Subscription status", httpMethod = "POST", notes = "Subscribes for distribution notifications")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "ECOMP component is successfully registered for distribution", response = TopicRegistrationResponse.class),
- @ApiResponse(code = 400, message = "Missing “X-ECOMP-InstanceID” HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
@ApiResponse(code = 400, message = "Missing Body - POL4500"),
- @ApiResponse(code = 400, message = "Invalid Body : missing mandatory parameter “apiPublicKey” - POL4501"),
- @ApiResponse(code = 400, message = "Invalid Body : missing mandatory parameter “distrEnvName” - POL4502"),
- @ApiResponse(code = 400, message = "Invalid Body : Specified “distrEnvName” doesn’t exist - POL4137"),
+ @ApiResponse(code = 400, message = "Invalid Body : missing mandatory parameter 'apiPublicKey' - POL4501"),
+ @ApiResponse(code = 400, message = "Invalid Body : missing mandatory parameter 'distrEnvName' - POL4502"),
+ @ApiResponse(code = 400, message = "Invalid Body : Specified 'distrEnvName' doesn’t exist - POL4137"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 405, message = "Method Not Allowed : Invalid HTTP method type used to register for distribution ( PUT,DELETE,GET will be rejected) - POL4050"),
@@ -236,7 +236,7 @@ public class DistributionServlet extends BeGenericServlet {
@ApiOperation(value = "Artifact types list", httpMethod = "GET", notes = "Fetches available artifact types list")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Artifact types list fetched successfully", response = String.class),
- @ApiResponse(code = 400, message = "Missing “X-ECOMP-InstanceID” HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 405, message = "Method Not Allowed : Invalid HTTP method type used to register for distribution ( POST,PUT,DELETE will be rejected) - POL4050"),
@@ -282,11 +282,11 @@ public class DistributionServlet extends BeGenericServlet {
//TODO Edit the responses
@ApiResponses(value = {
@ApiResponse(code = 204, message = "ECOMP component is successfully unregistered", response = TopicUnregistrationResponse.class),
- @ApiResponse(code = 400, message = "Missing “X-ECOMP-InstanceID” HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
@ApiResponse(code = 400, message = "Missing Body - POL4500"),
- @ApiResponse(code = 400, message = "Invalid Body : missing mandatory parameter “apiPublicKey” - POL4501"),
- @ApiResponse(code = 400, message = "Invalid Body : missing mandatory parameter “distrEnvName” - SVC4506"),
- @ApiResponse(code = 400, message = "Invalid Body : Specified “distrEnvName” doesn’t exist - POL4137"),
+ @ApiResponse(code = 400, message = "Invalid Body : missing mandatory parameter 'apiPublicKey' - POL4501"),
+ @ApiResponse(code = 400, message = "Invalid Body : missing mandatory parameter 'distrEnvName' - SVC4506"),
+ @ApiResponse(code = 400, message = "Invalid Body : Specified 'distrEnvName' doesn’t exist - POL4137"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 405, message = "Method Not Allowed : Invalid HTTP method type used to register for distribution ( PUT,DELETE,GET will be rejected) - POL4050"),
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java
index 74eea8b3ec..32293ca9b7 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java
@@ -107,7 +107,7 @@ public class ArtifactExternalServlet extends AbstractValidationsServlet {
@ApiOperation(value = "uploads of artifact to a resource or service", httpMethod = "POST", notes = "uploads of artifact to a resource or service")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Artifact uploaded", response = ArtifactDefinition.class),
- @ApiResponse(code = 400, message = "Missing “X-ECOMP-InstanceID” HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
@@ -199,7 +199,7 @@ public class ArtifactExternalServlet extends AbstractValidationsServlet {
@ApiOperation(value = "uploads an artifact to a resource instance", httpMethod = "POST", notes = "uploads an artifact to a resource instance")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Artifact uploaded", response = ArtifactDefinition.class),
- @ApiResponse(code = 400, message = "Missing “X-ECOMP-InstanceID” HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
@@ -300,7 +300,7 @@ public class ArtifactExternalServlet extends AbstractValidationsServlet {
@ApiOperation(value = "updates an artifact on a resource or service", httpMethod = "POST", notes = "uploads of artifact to a resource or service")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Artifact updated", response = ArtifactDefinition.class),
- @ApiResponse(code = 400, message = "Missing “X-ECOMP-InstanceID” HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
@@ -394,7 +394,7 @@ public class ArtifactExternalServlet extends AbstractValidationsServlet {
@ApiOperation(value = "updates an artifact on a resource instance", httpMethod = "POST", notes = "uploads of artifact to a resource or service")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Artifact updated", response = ArtifactDefinition.class),
- @ApiResponse(code = 400, message = "Missing “X-ECOMP-InstanceID” HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
@@ -491,7 +491,7 @@ public class ArtifactExternalServlet extends AbstractValidationsServlet {
@ApiResponse(code = 404, message = "Asset not found") })*/
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Artifact deleted", response = ArtifactDefinition.class),
- @ApiResponse(code = 400, message = "Missing “X-ECOMP-InstanceID” HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
@@ -580,7 +580,7 @@ public class ArtifactExternalServlet extends AbstractValidationsServlet {
@ApiOperation(value = "deletes an artifact of a resource insatnce", httpMethod = "DELETE", notes = "deletes an artifact of a resource insatnce", response = Response.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Artifact deleted", response = ArtifactDefinition.class),
- @ApiResponse(code = 400, message = "Missing “X-ECOMP-InstanceID” HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
@@ -671,7 +671,7 @@ public class ArtifactExternalServlet extends AbstractValidationsServlet {
@ApiOperation(value = "Download component artifact", httpMethod = "GET", notes = "Returns downloaded artifact")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Artifact downloaded", response = String.class),
- @ApiResponse(code = 400, message = "Missing “X-ECOMP-InstanceID” HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
@@ -750,7 +750,7 @@ public class ArtifactExternalServlet extends AbstractValidationsServlet {
@ApiOperation(value = "Download resource instance artifact", httpMethod = "GET", notes = "Returns downloaded artifact", response = Response.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Artifact downloaded", response = String.class),
- @ApiResponse(code = 400, message = "Missing “X-ECOMP-InstanceID” HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServlet.java
index ce8b967786..c3708d4017 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServlet.java
@@ -107,7 +107,7 @@ public class AssetsDataServlet extends AbstractValidationsServlet {
@ApiOperation(value = "Fetch list of assets", httpMethod = "GET", notes = "Returns list of assets")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "ECOMP component is authenticated and list of Catalog Assets Metadata is returned", response = AssetMetadata.class, responseContainer="List"),
- @ApiResponse(code = 400, message = "Missing “X-ECOMP-InstanceID” HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 405, message = "Method Not Allowed : Invalid HTTP method type used ( PUT,DELETE,POST will be rejected) - POL4050"),
@@ -217,7 +217,7 @@ public class AssetsDataServlet extends AbstractValidationsServlet {
@ApiOperation(value = "Detailed metadata of asset by uuid", httpMethod = "GET", notes = "Returns detailed metadata of an asset by uuid")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "ECOMP component is authenticated and list of Catalog Assets Metadata is returned", response = AssetMetadata.class, responseContainer="List"),
- @ApiResponse(code = 400, message = "Missing “X-ECOMP-InstanceID” HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 404, message = "Error: Requested '%1' (uuid) resource was not found - SVC4063"),
@@ -306,7 +306,7 @@ public class AssetsDataServlet extends AbstractValidationsServlet {
@ApiOperation(value = "Fetch assets CSAR", httpMethod = "GET", notes = "Returns asset csar", response = String.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "ECOMP component is authenticated and list of Catalog Assets Metadata is returned", response = String.class),
- @ApiResponse(code = 400, message = "Missing “X-ECOMP-InstanceID” HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 404, message = "Error: Requested '%1' (uuid) resource was not found - SVC4063"),
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java
index b88fa903b1..529d2aba4d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.sdc.be.externalapi.servlet;
import java.io.IOException;
@@ -100,7 +120,7 @@ public class CrudExternalServlet extends AbstractValidationsServlet {
@ApiOperation(value = "creates a resource", httpMethod = "POST", notes = "Creates a resource")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "ECOMP component is authenticated and Asset created", response = Resource.class),
- @ApiResponse(code = 400, message = "Missing “X-ECOMP-InstanceID” HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing X-ECOMP-InstanceID HTTP header - POL5001"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 404, message = "Error: Requested '%1' (uuid) resource was not found - SVC4063"),
@@ -249,7 +269,7 @@ public class CrudExternalServlet extends AbstractValidationsServlet {
@ApiOperation(value = "Change Resource lifecycle State", httpMethod = "POST")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Resource state changed", response = AssetMetadata.class),
- @ApiResponse(code = 400, message = "Missing “X-ECOMP-InstanceID” HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing X-ECOMP-InstanceID HTTP header - POL5001"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 404, message = "Error: Requested '%1' (uuid) resource was not found - SVC4063"),
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertor.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertor.java
index b21e064a82..3fd5297439 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertor.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertor.java
@@ -122,7 +122,7 @@ public class CapabiltyRequirementConvertor {
if (prop.getSchema() != null && prop.getSchema().getProperty() != null) {
innerType = prop.getSchema().getProperty().getType();
}
- Object convertedValue = PropertyConvertor.getInstance().convertToToscaObject(propertyType, prop.getValue(), innerType, dataTypes);
+ Object convertedValue = PropertyConvertor.getInstance().convertToToscaObject(propertyType, prop.getName(), prop.getValue(), innerType, dataTypes);
return convertedValue;
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
index af3b73dc97..0804ef1ed4 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
@@ -24,7 +24,9 @@ import java.io.StringReader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
+import org.apache.commons.lang3.StringUtils;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.DataTypeDefinition;
@@ -39,7 +41,9 @@ import org.openecomp.sdc.be.tosca.model.ToscaProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.gson.Gson;
import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import com.google.gson.stream.JsonReader;
@@ -50,7 +54,7 @@ public class PropertyConvertor {
private static PropertyConvertor instance;
private JsonParser jsonParser = new JsonParser();
private static Logger log = LoggerFactory.getLogger(PropertyConvertor.class.getName());
-
+ Gson gson = new Gson();
protected PropertyConvertor() {
}
@@ -97,7 +101,7 @@ public class PropertyConvertor {
prop.setEntry_schema(eschema);
}
log.debug("try to convert property {} from type {} with default value {}", property.getName(), property.getType(), property.getDefaultValue());
- prop.setDefaultp(convertToToscaObject(property.getType(), property.getDefaultValue(), innerType, dataTypes));
+ prop.setDefaultp(convertToToscaObject(property.getType(), property.getName(), property.getDefaultValue(), innerType, dataTypes));
prop.setType(property.getType());
prop.setDescription(property.getDescription());
if (isCapabiltyProperty) {
@@ -107,10 +111,13 @@ public class PropertyConvertor {
return prop;
}
- public Object convertToToscaObject(String propertyType, String value, String innerType, Map<String, DataTypeDefinition> dataTypes) {
+ public Object convertToToscaObject(String propertyType, String propertyName, String value, String innerType, Map<String, DataTypeDefinition> dataTypes) {
log.debug("try to convert propertyType {} , value {}, innerType {}", propertyType, value, innerType);
if (value == null) {
- return value;
+ value = getDataTypeDefaultValue(propertyName, dataTypes.get(propertyType));
+ if(StringUtils.isEmpty(value)){
+ return null;
+ }
}
ToscaMapValueConverter mapConverterInst = ToscaMapValueConverter.getInstance();
@@ -185,4 +192,35 @@ public class PropertyConvertor {
}
+ private String getDataTypeDefaultValue(String propertyName, DataTypeDefinition dataTypeDefinition) {
+
+ String delaultValue = null;
+ JsonObject asJsonObjectIn = new JsonObject();
+ Map<String, PropertyDefinition> allParentsProps = new HashMap<>();
+ while (dataTypeDefinition != null) {
+
+ List<PropertyDefinition> currentParentsProps = dataTypeDefinition.getProperties();
+ if (currentParentsProps != null) {
+ currentParentsProps.stream().forEach(p -> allParentsProps.put(p.getName(), p));
+ }
+
+ dataTypeDefinition = dataTypeDefinition.getDerivedFrom();
+ }
+ for (Entry<String, PropertyDefinition> entry : allParentsProps.entrySet()) {
+ String propName = entry.getKey();
+ PropertyDefinition propertyDefinition = entry.getValue();
+ JsonElement elementValue = asJsonObjectIn.get(propName);
+ if(elementValue == null && propertyDefinition.getDefaultValue() != null){
+ JsonReader jsonReader = new JsonReader(new StringReader(propertyDefinition.getDefaultValue()));
+ jsonReader.setLenient(true);
+ elementValue = jsonParser.parse(jsonReader);
+ asJsonObjectIn.add(propName, elementValue);
+ }
+ }
+ if(!asJsonObjectIn.isJsonNull()){
+ delaultValue = gson.toJson(asJsonObjectIn);
+ }
+ return delaultValue;
+ }
+
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index 65e4266d6d..d6f87967ca 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -644,8 +644,6 @@ public class ToscaExportHandler {
if (!MapUtils.isEmpty(componentInstancesProperties)) {
componentInstancesProperties.get(instanceUniqueId).stream()
- // Filters out properties with empty ValueUniqueUid
- .filter(e -> e.getValue() != null && !e.getValue().isEmpty() )
// Collects filtered properties to List
.collect(Collectors.toList()).stream()
// Converts and adds each value to property map
@@ -694,7 +692,7 @@ public class ToscaExportHandler {
if (input.getSchema() != null && input.getSchema().getProperty() != null) {
innerType = input.getSchema().getProperty().getType();
}
- return propertyConvertor.convertToToscaObject(propertyType, supplier.get(), innerType, dataTypes);
+ return propertyConvertor.convertToToscaObject(propertyType, input.getName(), supplier.get(), innerType, dataTypes);
}
private ToscaGroupTemplate convertGroup(GroupDefinition group) {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java
index 1ff6f853d9..a325817316 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.sdc.be.components.impl;
import org.junit.Before;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java
index 97b425db05..db5531debf 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.sdc.be.components.impl;
import fj.data.Either;