aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
diff options
context:
space:
mode:
authorFrancis Toth <francis.toth@yoppworks.com>2020-04-24 10:29:03 -0400
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-04-28 09:19:04 +0000
commit33a4512b6eb6204e2209a788b06153a889629f4e (patch)
tree49e8d6a121ef5213a8419179d14570672b0a13b4 /catalog-be/src/main
parent76593bfbb1a233d76367abe903734c13b75f3a35 (diff)
Refactor CsarUtils::getEntryData
Change-Id: I1732ae05cfbe93c1bef8c249e16088a0cad34106 Issue-ID: SDC-2812 Signed-off-by: Francis Toth <francis.toth@yoppworks.com>
Diffstat (limited to 'catalog-be/src/main')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java38
1 files changed, 18 insertions, 20 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
index 39c0a09f9c..22b655ad40 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.be.tosca;
+import fj.F;
import fj.data.Either;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
@@ -609,26 +610,23 @@ public class CsarUtils {
return Either.left(zip);
}
- private Either<byte[], ActionStatus> getEntryData(String cassandraId, Component childComponent) {
- byte[] content;
- if (cassandraId == null || cassandraId.isEmpty()) {
- Either<ToscaRepresentation, ToscaError> exportRes = toscaExportUtils.exportComponent(childComponent);
- if (exportRes.isRight()) {
- log.debug("Failed to export tosca template for child component {} error {}",
- childComponent.getUniqueId(), exportRes.right().value());
- return Either.right(componentsUtils.convertFromToscaError(exportRes.right().value()));
- }
- content = exportRes.left().value().getMainYaml().getBytes();
- } else {
- Either<byte[], ActionStatus> fromCassandra = getFromCassandra(cassandraId);
- if (fromCassandra.isRight()) {
- return Either.right(fromCassandra.right().value());
- } else {
- content = fromCassandra.left().value();
- }
- }
- return Either.left(content);
- }
+ private Either<byte[], ActionStatus> getEntryData(String cassandraId, Component childComponent) {
+ if (cassandraId == null || cassandraId.isEmpty()) {
+ return toscaExportUtils.exportComponent(childComponent)
+ .right().map(toscaErrorToActionStatus(childComponent))
+ .left().map(toscaRepresentation -> toscaRepresentation.getMainYaml().getBytes());
+ } else {
+ return getFromCassandra(cassandraId);
+ }
+ }
+
+ private F<ToscaError, ActionStatus> toscaErrorToActionStatus(Component childComponent) {
+ return toscaError -> {
+ log.debug("Failed to export tosca template for child component {} error {}",
+ childComponent.getUniqueId(), toscaError);
+ return componentsUtils.convertFromToscaError(toscaError);
+ };
+ }
private Either<byte[], ResponseFormat> getLatestSchemaFilesFromCassandra() {
Either<List<SdcSchemaFilesData>, CassandraOperationStatus> specificSchemaFiles = sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(getVersionFirstThreeOctets(), CONFORMANCE_LEVEL);
ight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
#-------------------------------------------------------------------------------
# ============LICENSE_START=======================================================
#  Copyright (C) 2016-2018 Ericsson. All rights reserved.
#  Modifications Copyright (C) 2019-2020 Nordix Foundation.
# ================================================================================
# 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.
#
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=========================================================
#-------------------------------------------------------------------------------

Check out Draft Review

Build the source
mvn clean install

Build the docker image for the demo
cd packages/apex-pdp-docker/src/main/
cp ../../../apex-pdp-package-full/target/apex-pdp-package-full-2.0.0-SNAPSHOT-tarball.tar.gz docker/apex-pdp-package-full.tar.gz
docker build -t apex-onap-vcpe docker

Run the Docker container
docker run -it --rm -p 12561:12561 apex-onap-vcpe

Find the address of the host containter
ip route list

Update the configuration file REST URLs with the IP address of the source container
vi examples/config/ONAPvCPE/ApexConfig.json
examples/config/ONAPvCPE/ApexConfigStdin.json

Run simulator from command line on host machine using Maven, replacing xxx.xxx.xxx.xxx with the IP address of the local host
mvn exec:java  -Dexec.classpathScope="test" -Dexec.mainClass=org.onap.policy.apex.domains.onap.vcpe.OnapVCpeSim -Dexec.args="xxx.xxx.xxx.xxx 54321"

Run the engine in Docker, running the full example
/opt/app/policy/apex-pdp/bin/apexApps.sh engine -c examples/config/ONAPvCPE/ApexConfig.json

Run the engine in Docker, running with pasting into console using standard input
/opt/app/policy/apex-pdp/bin/apexApps.sh engine -c examples/config/ONAPvCPE/ApexConfigStdin.json

On an extraction of the Apex tarball, run the Apex client
bin/apexApps.sh full-client