aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/CambriaHandler.java46
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java46
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/ComponentValidations.java18
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/distribution/servlet/DistributionServlet.java11
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/BeMonitoringServlet.java3
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/InputsServlet.java5
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ProductServlet.java2
-rw-r--r--catalog-be/src/main/resources/config/distribution-engine-configuration.yaml4
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java109
11 files changed, 178 insertions, 70 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/CambriaHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/CambriaHandler.java
index 6738b87853..e6d15b8d5e 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/CambriaHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/CambriaHandler.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.be.components.distribution.engine;
import java.io.IOException;
+import java.net.MalformedURLException;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.Collection;
@@ -31,8 +32,10 @@ import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import com.att.nsa.cambria.client.*;
import org.apache.http.HttpStatus;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
+import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.distribution.api.client.CambriaOperationStatus;
import org.openecomp.sdc.common.config.EcompErrorName;
import org.slf4j.Logger;
@@ -40,16 +43,12 @@ import org.slf4j.LoggerFactory;
import com.att.nsa.apiClient.http.HttpException;
import com.att.nsa.apiClient.http.HttpObjectNotFoundException;
-import com.att.nsa.cambria.client.CambriaBatchingPublisher;
import com.att.nsa.cambria.client.CambriaClient.CambriaApiException;
import com.att.nsa.cambria.client.CambriaClientBuilders.TopicManagerBuilder;
import com.att.nsa.cambria.client.CambriaClientBuilders.PublisherBuilder;
import com.att.nsa.cambria.client.CambriaClientBuilders.ConsumerBuilder;
import com.att.nsa.cambria.client.CambriaClientBuilders.IdentityManagerBuilder;
-import com.att.nsa.cambria.client.CambriaConsumer;
-import com.att.nsa.cambria.client.CambriaIdentityManager;
import com.att.nsa.cambria.client.CambriaPublisher.message;
-import com.att.nsa.cambria.client.CambriaTopicManager;
import com.google.gson.Gson;
import fj.data.Either;
@@ -63,6 +62,8 @@ public class CambriaHandler {
private Gson gson = new Gson();
+ public static boolean useHttpsWithDmaap = ConfigurationManager.getConfigurationManager().getDistributionEngineConfiguration().isUseHttpsWithDmaap();
+
public static void main(String[] args) {
// String userBodyJson ="{\"artifactName\":\"myartifact\",
@@ -86,18 +87,18 @@ public class CambriaHandler {
String key = "sSJc5qiBnKy2qrlc";
String secret = "4ZRPzNJfEUK0sSNBvccd2m7X";
- createTopicManager = new TopicManagerBuilder().usingHttps().usingHosts(servers).authenticatedBy(key, secret).build();
+ createTopicManager = buildCambriaClient(new TopicManagerBuilder().usingHosts(servers).authenticatedBy(key, secret));
String topicName = "ASDC-DISTR-NOTIF-TOPIC-PRODesofer";
String clientKey1 = "CGGoorrGPXPx2B1C";
String clientSecret1 = "OTHk2mcCSbskEtHhDw8h5oUa";
- CambriaTopicManager createStatusTopicManager = new TopicManagerBuilder().usingHttps().usingHosts(servers).authenticatedBy(key, secret).build();
+ CambriaTopicManager createStatusTopicManager = buildCambriaClient(new TopicManagerBuilder().usingHosts(servers).authenticatedBy(key, secret));
String reportTopic = "ASDC-DISTR-STATUS-TOPIC-PRODESOFER";
createStatusTopicManager.allowProducer(reportTopic, clientKey1);
- CambriaBatchingPublisher createSimplePublisher = new PublisherBuilder().onTopic(reportTopic).usingHttps().usingHosts(servers).build();
+ CambriaBatchingPublisher createSimplePublisher = new PublisherBuilder().onTopic(reportTopic).usingHttps(useHttpsWithDmaap).usingHosts(servers).build();
createSimplePublisher.setApiCredentials(clientKey1, clientSecret1);
DistributionStatusNotification distributionStatusNotification = new DistributionStatusNotification();
@@ -126,20 +127,20 @@ public class CambriaHandler {
String clientKey2 = "TAIEPO0aDU4VzM0G";
- CambriaConsumer createConsumer1 = new ConsumerBuilder().authenticatedBy("asdc1", "consumerId1").onTopic(topicName).usingHttps().usingHosts(servers).build();
+ CambriaConsumer createConsumer1 = new ConsumerBuilder().authenticatedBy("asdc1", "consumerId1").onTopic(topicName).usingHttps(useHttpsWithDmaap).usingHosts(servers).build();
createConsumer1.setApiCredentials(clientKey1, "OTHk2mcCSbskEtHhDw8h5oUa");
createTopicManager.allowConsumer(topicName, clientKey1);
CambriaConsumer createConsumer2 = null;
if (true) {
- createConsumer2 = new ConsumerBuilder().authenticatedBy("asdc2", "consumerId3").onTopic(topicName).usingHttps().usingHosts(servers).build();
+ createConsumer2 = new ConsumerBuilder().authenticatedBy("asdc2", "consumerId3").onTopic(topicName).usingHttps(useHttpsWithDmaap).usingHosts(servers).build();
createConsumer2.setApiCredentials(clientKey2, "FSlNJbmGWWBvBLJetQMYxPP6");
createTopicManager.allowConsumer(topicName, clientKey2);
}
- createSimplePublisher = new PublisherBuilder().onTopic(topicName).usingHttps().usingHosts(servers).build();
+ createSimplePublisher = new PublisherBuilder().onTopic(topicName).usingHttps(useHttpsWithDmaap).usingHosts(servers).build();
createSimplePublisher.setApiCredentials(key, secret);
createTopicManager.allowProducer(topicName, key);
@@ -284,7 +285,7 @@ public class CambriaHandler {
CambriaTopicManager createTopicManager = null;
try {
- createTopicManager = new TopicManagerBuilder().usingHttps().usingHosts(hostSet).build();
+ createTopicManager = buildCambriaClient(new TopicManagerBuilder().usingHosts(hostSet));
Set<String> topics = createTopicManager.getTopics();
@@ -318,7 +319,6 @@ public class CambriaHandler {
*
* set Cambria status and http code in case we succeed to fetch it
*
- * @param errorMessage
* @return
*/
private CambriaErrorResponse processError(Exception e) {
@@ -415,8 +415,6 @@ public class CambriaHandler {
* - list of U-EB servers
* @param apiKey
* @param secretKey
- * @param topicsList
- * - list of exists topics
* @param topicName
* - topic to create
* @param partitionCount
@@ -428,7 +426,7 @@ public class CambriaHandler {
CambriaTopicManager createTopicManager = null;
try {
- createTopicManager = new TopicManagerBuilder().usingHttps().usingHosts(hostSet).authenticatedBy(apiKey, secretKey).build();
+ createTopicManager = buildCambriaClient(new TopicManagerBuilder().usingHosts(hostSet).authenticatedBy(apiKey, secretKey));
createTopicManager.createTopic(topicName, "ASDC distribution notification topic", partitionCount, replicationCount);
@@ -458,7 +456,7 @@ public class CambriaHandler {
public CambriaErrorResponse unRegisterFromTopic(Collection<String> hostSet, String topicName, String managerApiKey, String managerSecretKey, String subscriberApiKey, SubscriberTypeEnum subscriberTypeEnum) {
CambriaTopicManager createTopicManager = null;
try {
- createTopicManager = new TopicManagerBuilder().usingHttps().usingHosts(hostSet).authenticatedBy(managerApiKey, managerSecretKey).build();
+ createTopicManager = buildCambriaClient(new TopicManagerBuilder().usingHosts(hostSet).authenticatedBy(managerApiKey, managerSecretKey));
if (subscriberTypeEnum == SubscriberTypeEnum.PRODUCER) {
createTopicManager.revokeProducer(topicName, subscriberApiKey);
@@ -513,7 +511,7 @@ public class CambriaHandler {
CambriaTopicManager createTopicManager = null;
try {
- createTopicManager = new TopicManagerBuilder().usingHttps().usingHosts(hostSet).authenticatedBy(managerApiKey, managerSecretKey).build();
+ createTopicManager = buildCambriaClient(new TopicManagerBuilder().usingHosts(hostSet).authenticatedBy(managerApiKey, managerSecretKey));
if (subscriberTypeEnum == SubscriberTypeEnum.PRODUCER) {
createTopicManager.allowProducer(topicName, subscriberApiKey);
@@ -567,7 +565,7 @@ public class CambriaHandler {
*/
public CambriaConsumer createConsumer(Collection<String> hostSet, String topicName, String apiKey, String secretKey, String consumerId, String consumerGroup, int timeoutMS) throws Exception {
- CambriaConsumer consumer = new ConsumerBuilder().authenticatedBy(apiKey, secretKey).knownAs(consumerGroup, consumerId).onTopic(topicName).usingHttps().usingHosts(hostSet).withSocketTimeout(timeoutMS).build();
+ CambriaConsumer consumer = new ConsumerBuilder().authenticatedBy(apiKey, secretKey).knownAs(consumerGroup, consumerId).onTopic(topicName).usingHttps(useHttpsWithDmaap).usingHosts(hostSet).withSocketTimeout(timeoutMS).build();
consumer.setApiCredentials(apiKey, secretKey);
return consumer;
}
@@ -638,7 +636,7 @@ public class CambriaHandler {
String json = gson.toJson(data);
logger.trace("Before sending notification data {} to topic {}", json, topicName);
- createSimplePublisher = new PublisherBuilder().onTopic(topicName).usingHttps().usingHosts(uebServers).build();
+ createSimplePublisher = new PublisherBuilder().onTopic(topicName).usingHttps(useHttpsWithDmaap).usingHosts(uebServers).build();
createSimplePublisher.setApiCredentials(uebPublicKey, uebSecretKey);
int result = createSimplePublisher.send(PARTITION_KEY, json);
@@ -700,7 +698,7 @@ public class CambriaHandler {
String json = gson.toJson(data);
logger.debug("Before sending notification data {} to topic {}", json, topicName);
- createSimplePublisher = new PublisherBuilder().onTopic(topicName).usingHttps().usingHosts(uebServers).build();
+ createSimplePublisher = new PublisherBuilder().onTopic(topicName).usingHttps(useHttpsWithDmaap).usingHosts(uebServers).build();
createSimplePublisher.setApiCredentials(uebPublicKey, uebSecretKey);
int result = createSimplePublisher.send(PARTITION_KEY, json);
@@ -761,7 +759,7 @@ public class CambriaHandler {
hostSet.add(server);
CambriaIdentityManager createIdentityManager = null;
try {
- createIdentityManager = new IdentityManagerBuilder().usingHttps().usingHosts(hostSet).build();
+ createIdentityManager = buildCambriaClient(new IdentityManagerBuilder().usingHosts(hostSet));
createIdentityManager.getApiKey(apiKey);
response = new CambriaErrorResponse(CambriaOperationStatus.OK, 200);
@@ -775,4 +773,10 @@ public class CambriaHandler {
return response;
}
+ private static <T extends CambriaClient> T buildCambriaClient(CambriaClientBuilders.AbstractAuthenticatedManagerBuilder<? extends CambriaClient> client) throws MalformedURLException, GeneralSecurityException {
+ if (useHttpsWithDmaap) {
+ client.usingHttps();
+ }
+ return (T)client.build();
+ }
}
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 887ce12c3c..003fe66d9d 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
@@ -2660,7 +2660,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
if (!artifactUniqueId.equals(artifactId)) {
// need to update the generated id in heat env
Map<String, ArtifactDefinition> deploymentArtifacts = parent.getDeploymentArtifacts();
- Optional<Entry<String, ArtifactDefinition>> findFirst = deploymentArtifacts.entrySet().stream().filter(a -> a.getValue().getGeneratedFromId().equals(artifactId)).findFirst();
+ Optional<Entry<String, ArtifactDefinition>> findFirst = deploymentArtifacts.entrySet().stream().filter(a -> a.getValue().getGeneratedFromId()!=null && a.getValue().getGeneratedFromId().equals(artifactId)).findFirst();
if (findFirst.isPresent()) {
ArtifactDefinition artifactEnvInfo = findFirst.get().getValue();
artifactEnvInfo.setArtifactChecksum(null);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
index a2809b44cf..c3471e46e1 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
@@ -21,38 +21,26 @@
package org.openecomp.sdc.be.components.impl;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.UUID;
import java.util.Map.Entry;
import java.util.function.BiConsumer;
-import java.util.function.Predicate;
import java.util.stream.Collectors;
-import java.util.stream.Stream;
import org.json.simple.JSONObject;
+import org.openecomp.sdc.be.components.validation.ComponentValidations;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
-import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
-import org.openecomp.sdc.be.dao.neo4j.GraphEdgePropertiesDictionary;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
-import org.openecomp.sdc.be.impl.ComponentsUtils;
-import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.ComponentInstInputsMap;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.ComponentInstanceInput;
@@ -66,27 +54,17 @@ import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
-import org.openecomp.sdc.be.model.operations.impl.InputsOperation;
-import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.be.model.tosca.converters.PropertyValueConverter;
-import org.openecomp.sdc.be.resources.data.InputValueData;
-import org.openecomp.sdc.be.resources.data.InputsData;
-import org.openecomp.sdc.be.resources.data.PropertyValueData;
-import org.openecomp.sdc.be.resources.data.UniqueIdData;
import org.openecomp.sdc.exception.ResponseFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor;
import org.springframework.stereotype.Component;
import org.yaml.snakeyaml.Yaml;
import com.google.gson.Gson;
-import com.thinkaurelius.titan.core.TitanVertex;
-import fj.Function;
import fj.data.Either;
@Component("inputsBusinessLogic")
@@ -97,15 +75,6 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
private static Logger log = LoggerFactory.getLogger(InputsBusinessLogic.class.getName());
-
-
- @javax.annotation.Resource
- private PropertyOperation propertyOperation = null;
-
-
- @Autowired
- private ComponentsUtils componentsUtils;
-
private static final String GET_INPUT = "get_input";
private static String ASSOCIATING_INPUT_TO_PROP = "AssociatingInputToComponentInstanceProperty";
@@ -148,7 +117,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
}
- public Either<List<ComponentInstanceInput>, ResponseFormat> getComponentInstanceInputs(String userId, String componentId, String componentInstanceId,String fromName, int amount) {
+ public Either<List<ComponentInstanceInput>, ResponseFormat> getComponentInstanceInputs(String userId, String componentId, String componentInstanceId) {
Either<User, ResponseFormat> resp = validateUserExists(userId, "get Inputs", false);
@@ -171,15 +140,14 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
}
org.openecomp.sdc.be.model.Component component = getComponentEither.left().value();
- Map<String, List<ComponentInstanceInput>> ciInputs = component.getComponentInstancesInputs();
- if(!ciInputs.containsKey(componentInstanceId)){
+
+ if(!ComponentValidations.validateComponentInstanceExist(component, componentInstanceId)){
ActionStatus actionStatus = ActionStatus.COMPONENT_INSTANCE_NOT_FOUND;
log.debug("Failed to found component instance inputs {}, error: {}", componentInstanceId, actionStatus.name());
return Either.right(componentsUtils.getResponseFormat(actionStatus));
}
-
- return Either.left(ciInputs.get(componentInstanceId));
-
+ Map<String, List<ComponentInstanceInput>> ciInputs = Optional.ofNullable(component.getComponentInstancesInputs()).orElse(Collections.emptyMap());
+ return Either.left(ciInputs.getOrDefault(componentInstanceId, Collections.emptyList()));
}
/**
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
new file mode 100644
index 0000000000..b50c8ef9d1
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/ComponentValidations.java
@@ -0,0 +1,18 @@
+package org.openecomp.sdc.be.components.validation;
+
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+public class ComponentValidations {
+
+ public static boolean validateComponentInstanceExist(Component component, String instanceId) {
+ return Optional.ofNullable(component.getComponentInstances())
+ .map(componentInstances -> componentInstances.stream().map(ComponentInstance::getUniqueId).collect(Collectors.toList()))
+ .filter(instancesIds -> instancesIds.contains(instanceId))
+ .isPresent();
+ }
+
+}
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 67f0e74b50..05f4b15621 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
@@ -56,6 +56,9 @@ import org.springframework.web.context.WebApplicationContext;
import com.jcabi.aspects.Loggable;
import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiResponse;
+import com.wordnik.swagger.annotations.ApiResponses;
import fj.data.Either;
@@ -80,6 +83,8 @@ public class DistributionServlet extends BeGenericServlet {
@Path("/distributionUebCluster")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "UEB Server List", httpMethod = "GET", notes = "return the available UEB Server List", response = String.class)
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "UEB server list fetched successfully"), @ApiResponse(code = 500, message = "One or more BE components (Titan, ES, BE) are down") })
public Response getUebServerList(@Context final HttpServletRequest request, @HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) String instanceId, @HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization, @HeaderParam(value = Constants.ACCEPT_HEADER) String accept) {
init(request);
@@ -134,6 +139,8 @@ public class DistributionServlet extends BeGenericServlet {
@Path("/artifactTypes")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Artifact types list", httpMethod = "GET", notes = "Fetches available artifact types list", response = String.class)
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "Artifact types list fetched successfully"), @ApiResponse(code = 500, message = "One or more BE components (Titan, ES, BE) are down") })
public Response getValidArtifactTypes(@Context final HttpServletRequest request, @HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) String instanceId, @HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization, @HeaderParam(value = Constants.ACCEPT_HEADER) String accept) {
init(request);
@@ -156,6 +163,8 @@ public class DistributionServlet extends BeGenericServlet {
@Path("/registerForDistribution")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Subscription status", httpMethod = "POST", notes = "Subscribes for distribution notifications", response = String.class)
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "Subscribed for distribution notifications successfull"), @ApiResponse(code = 500, message = "One or more BE components (Titan, ES, BE) are down") })
public Response registerForDistribution(@Context final HttpServletRequest request, String requestJson) {
String url = request.getMethod() + " " + request.getRequestURI();
log.debug("Start handle request of {}", url);
@@ -187,6 +196,8 @@ public class DistributionServlet extends BeGenericServlet {
@Path("/unRegisterForDistribution")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Subscription status", httpMethod = "POST", notes = "Removes from subscription for distribution notifications", response = String.class)
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "Successfully removed from subscription for distribution notifications"), @ApiResponse(code = 500, message = "One or more BE components (Titan, ES, BE) are down") })
public Response unRegisterForDistribution(@Context final HttpServletRequest request, String requestJson) {
String url = request.getMethod() + " " + request.getRequestURI();
log.debug("Start handle request of {}", url);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/BeMonitoringServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/BeMonitoringServlet.java
index 51b0a1dff7..7a83726cc3 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/BeMonitoringServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/BeMonitoringServlet.java
@@ -34,7 +34,6 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.openecomp.sdc.be.components.impl.DistributionMonitoringBusinessLogic;
import org.openecomp.sdc.be.components.impl.HealthCheckBusinessLogic;
import org.openecomp.sdc.be.components.impl.MonitoringBusinessLogic;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
@@ -42,9 +41,9 @@ import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.api.HealthCheckInfo;
-import org.openecomp.sdc.common.api.HealthCheckWrapper;
import org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckComponent;
import org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckStatus;
+import org.openecomp.sdc.common.api.HealthCheckWrapper;
import org.openecomp.sdc.common.config.EcompErrorName;
import org.openecomp.sdc.common.monitoring.MonitoringEvent;
import org.openecomp.sdc.exception.ResponseFormat;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/InputsServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/InputsServlet.java
index 580b2bdb8b..8bef822f26 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/InputsServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/InputsServlet.java
@@ -179,8 +179,7 @@ public class InputsServlet extends AbstractValidationsServlet {
@ApiOperation(value = "Get Inputs only", httpMethod = "GET", notes = "Returns Inputs list", response = Resource.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Component found"), @ApiResponse(code = 403, message = "Restricted operation"), @ApiResponse(code = 404, message = "Component not found") })
public Response getComponentInstanceInputs(@PathParam("componentType") final String componentType, @PathParam("componentId") final String componentId, @PathParam("instanceId") final String instanceId,
- @PathParam("originComponentUid") final String originComonentUid, @Context final HttpServletRequest request, @QueryParam("fromName") String fromName, @QueryParam("amount") int amount,
- @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
+ @PathParam("originComponentUid") final String originComonentUid, @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
ServletContext context = request.getSession().getServletContext();
String url = request.getMethod() + " " + request.getRequestURI();
@@ -190,7 +189,7 @@ public class InputsServlet extends AbstractValidationsServlet {
try {
InputsBusinessLogic businessLogic = getInputBL(context);
- Either<List<ComponentInstanceInput>, ResponseFormat> inputsResponse = businessLogic.getComponentInstanceInputs(userId, componentId, instanceId, fromName, amount);
+ Either<List<ComponentInstanceInput>, ResponseFormat> inputsResponse = businessLogic.getComponentInstanceInputs(userId, componentId, instanceId);
if (inputsResponse.isRight()) {
log.debug("failed to get component instance inputs {}", componentType);
return buildErrorResponse(inputsResponse.right().value());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ProductServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ProductServlet.java
index f4ac921cb7..4b450cbe7b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ProductServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ProductServlet.java
@@ -72,7 +72,7 @@ public class ProductServlet extends BeGenericServlet {
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Create product", httpMethod = "POST", notes = "Returns created product", response = Product.class)
@ApiResponses(value = { @ApiResponse(code = 201, message = "Product created"), @ApiResponse(code = 403, message = "Restricted operation / Empty USER_ID header"), @ApiResponse(code = 400, message = "Invalid/missing content"),
- @ApiResponse(code = 409, message = "Product already exists / User not found / Wrong user role") })
+ @ApiResponse(code = 409, message = "Product already exists / User not found / Wrong user role") })
public Response createProduct(@ApiParam(value = "Product object to be created", required = true) String data, @Context final HttpServletRequest request,
@HeaderParam(value = Constants.USER_ID_HEADER) @ApiParam(value = "USER_ID of product strategist user", required = true) String userId) {
diff --git a/catalog-be/src/main/resources/config/distribution-engine-configuration.yaml b/catalog-be/src/main/resources/config/distribution-engine-configuration.yaml
index 5d93601ea0..60886cf40f 100644
--- a/catalog-be/src/main/resources/config/distribution-engine-configuration.yaml
+++ b/catalog-be/src/main/resources/config/distribution-engine-configuration.yaml
@@ -43,4 +43,6 @@ createTopic:
partitionCount: 1
replicationCount: 1
-startDistributionEngine: true \ No newline at end of file
+startDistributionEngine: true
+
+useHttpsWithDmaap: true \ No newline at end of file
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 fd7717a769..1ff6f853d9 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
@@ -8,14 +8,12 @@ import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
-
import java.util.Collections;
import java.util.Map;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-
public class ArtifactResolverTest {
private ArtifactResolverImpl testInstance = new ArtifactResolverImpl();
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
new file mode 100644
index 0000000000..97b425db05
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java
@@ -0,0 +1,109 @@
+package org.openecomp.sdc.be.components.impl;
+
+import fj.data.Either;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceInput;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
+import org.openecomp.sdc.be.user.IUserBusinessLogic;
+import org.openecomp.sdc.exception.ResponseFormat;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class InputsBusinessLogicTest {
+
+ private static final String COMPONENT_INSTANCE_ID = "instanceId";
+ private static final String COMPONENT_ID = "componentId";
+ private static final String USER_ID = "userId";
+ public static final String INSTANCE_INPUT_ID = "inputId";
+ @Mock
+ private ComponentsUtils componentsUtilsMock;
+
+ @Mock
+ private IUserBusinessLogic userAdminMock;
+
+ @Mock
+ private ToscaOperationFacade toscaOperationFacadeMock;
+
+ @InjectMocks
+ private InputsBusinessLogic testInstance;
+
+ private Service service;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ service = new Service();
+ service.setUniqueId(COMPONENT_INSTANCE_ID);
+ ComponentInstance componentInstance = new ComponentInstance();
+ componentInstance.setUniqueId(COMPONENT_INSTANCE_ID);
+ service.setComponentInstances(Collections.singletonList(componentInstance));
+
+ Map<String, List<ComponentInstanceInput>> instanceInputMap = new HashMap<>();
+ ComponentInstanceInput componentInstanceInput = new ComponentInstanceInput();
+ componentInstanceInput.setInputId(INSTANCE_INPUT_ID);
+ instanceInputMap.put(COMPONENT_INSTANCE_ID, Collections.singletonList(componentInstanceInput));
+ instanceInputMap.put("someInputId", Collections.singletonList(new ComponentInstanceInput()));
+ service.setComponentInstancesInputs(instanceInputMap);
+
+ Mockito.when(userAdminMock.getUser(USER_ID, false)).thenReturn(Either.left(new User()));
+ }
+
+ @Test
+ public void getComponentInstanceInputs_ComponentInstanceNotExist() throws Exception {
+ Mockito.when(toscaOperationFacadeMock.getToscaElement(Mockito.eq(COMPONENT_ID), Mockito.any(ComponentParametersView.class))).thenReturn(Either.left(service));
+ Either<List<ComponentInstanceInput>, ResponseFormat> componentInstanceInputs = testInstance.getComponentInstanceInputs(USER_ID, COMPONENT_ID, "nonExisting");
+ assertTrue(componentInstanceInputs.isRight());
+ Mockito.verify(componentsUtilsMock).getResponseFormat(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND);
+ }
+
+ @Test
+ public void getComponentInstanceInputs_emptyInputsMap() throws Exception {
+ service.setComponentInstancesInputs(Collections.emptyMap());
+ getComponents_emptyInputs(service);
+ }
+
+ @Test
+ public void getComponentInstanceInputs_nullInputsMap() throws Exception {
+ service.setComponentInstancesInputs(null);
+ getComponents_emptyInputs(service);
+ }
+
+ @Test
+ public void getComponentInstanceInputs_instanceHasNoInputs() throws Exception {
+ service.setComponentInstancesInputs(Collections.singletonMap("someInputId", new ArrayList<>()));
+ getComponents_emptyInputs(service);
+ }
+
+ @Test
+ public void getComponentInstanceInputs() throws Exception {
+ Mockito.when(toscaOperationFacadeMock.getToscaElement(Mockito.eq(COMPONENT_ID), Mockito.any(ComponentParametersView.class))).thenReturn(Either.left(service));
+ Either<List<ComponentInstanceInput>, ResponseFormat> componentInstanceInputs = testInstance.getComponentInstanceInputs(USER_ID, COMPONENT_ID, COMPONENT_INSTANCE_ID);
+ assertEquals("inputId", componentInstanceInputs.left().value().get(0).getInputId());
+ }
+
+ private void getComponents_emptyInputs(Service service) {
+ Mockito.when(toscaOperationFacadeMock.getToscaElement(Mockito.eq(COMPONENT_ID), Mockito.any(ComponentParametersView.class))).thenReturn(Either.left(service));
+ Either<List<ComponentInstanceInput>, ResponseFormat> componentInstanceInputs = testInstance.getComponentInstanceInputs(USER_ID, COMPONENT_ID, COMPONENT_INSTANCE_ID);
+ assertEquals(Collections.emptyList(), componentInstanceInputs.left().value());
+ }
+
+}