summaryrefslogtreecommitdiffstats
path: root/common-app-api
diff options
context:
space:
mode:
Diffstat (limited to 'common-app-api')
-rw-r--r--common-app-api/.gitignore2
-rw-r--r--common-app-api/pom.xml209
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/be/config/BeEcompErrorManager.java431
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/be/config/CleanComponentsConfiguration.java46
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java1233
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java154
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/be/config/DistributionEngineConfiguration.java430
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorConfiguration.java54
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorInfo.java102
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/be/config/Neo4jErrorsConfiguration.java47
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/be/config/validation/DeploymentArtifactHeatConfiguration.java57
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/be/monitoring/BeMonitoringService.java140
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/api/ApplicationErrorCodesEnum.java37
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactGroupTypeEnum.java66
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactTypeEnum.java81
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/api/BasicConfiguration.java25
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/api/ConfigurationListener.java50
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/api/ConfigurationSource.java28
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/api/Constants.java126
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/api/FileChangeCallback.java27
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckInfo.java76
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckWrapper.java62
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/api/ResourceType.java25
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/api/ResponseInfo.java84
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/api/ToscaNodeTypeInfo.java79
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/api/ToscaNodeTypeInterface.java37
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/api/UploadArtifactInfo.java147
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/api/UserRoleEnum.java41
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/api/YamlConstants.java29
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/api/YamlSuffixEnum.java60
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/config/AbsEcompErrorManager.java121
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompClassification.java41
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorCode.java155
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorConfiguration.java161
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorEnum.java484
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorInfo.java78
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorLogUtil.java199
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorName.java41
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/config/IEcompConfigurationManager.java25
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/config/IEcompErrorManager.java27
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java242
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKeysEnum.java103
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/CapList.java324
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java125
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/FunctionalInterfaces.java282
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/MonitoringFieldsKeysEnum.java57
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/Wrapper.java52
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java148
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/impl/ExternalConfiguration.java106
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/impl/FSConfigurationSource.java121
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/impl/MutableHttpServletRequest.java73
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/kpi/api/ASDCKpiApi.java67
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java129
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/monitoring/MonitoringEvent.java126
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/monitoring/MonitoringMetricsFetcher.java212
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/rest/api/IRestClient.java103
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/rest/api/RestClientServiceExeption.java78
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/rest/api/RestConfigurationInfo.java107
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/rest/api/RestResponse.java108
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/rest/api/RestResponseAsByteArray.java133
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/HttpRestClientServiceImpl.java436
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/RestClientServiceFactory.java48
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/validator/RequestHeadersValidator.java95
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/validator/RestRequestValidationException.java34
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/servlets/BasicServlet.java30
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/util/CapabilityTypeNameEnum.java46
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/util/GeneralUtility.java150
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/util/GsonFactory.java40
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/util/HtmlCleaner.java112
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/util/HttpUtil.java81
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/util/JsonUtils.java45
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/util/MethodActivationStatusEnum.java25
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/util/SerializationUtils.java87
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/util/StreamUtils.java136
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/util/ThreadLocalsHolder.java63
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java498
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java275
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/util/ZipUtil.java178
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/AbstractSdncException.java116
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/AlreadyExistException.java41
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/DeleteLastApplicationEnvironmentException.java34
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/DeleteReferencedObjectException.java35
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/FunctionalException.java41
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/IndexingServiceException.java39
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/InvalidArgumentException.java33
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/NotFoundException.java35
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/OkResponseInfo.java28
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/PolicyException.java31
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/ResponseFormat.java191
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/ServiceException.java32
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/TechnicalException.java40
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/VersionConflictException.java33
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/fe/config/Configuration.java304
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java117
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/fe/config/Connection.java48
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/fe/config/FeEcompErrorManager.java77
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/fe/monitoring/FeMonitoringService.java140
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/data_structure/CapListTest.java126
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java549
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/test/TestExternalConfiguration.java258
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/test/YamlTest.java61
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/test/config/TestConfiguration.java149
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/test/config/TestConnection.java48
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/test/config/TestNotExistConfiguration.java47
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/util/StreamUtilsTests.java143
-rw-r--r--common-app-api/src/test/resources/config/common/distribution-engine-configuration.yaml35
-rw-r--r--common-app-api/src/test/resources/config/common/test-configuration.yaml35
-rw-r--r--common-app-api/src/test/resources/logback-test.xml13
108 files changed, 13271 insertions, 0 deletions
diff --git a/common-app-api/.gitignore b/common-app-api/.gitignore
new file mode 100644
index 0000000000..19f2e002ce
--- /dev/null
+++ b/common-app-api/.gitignore
@@ -0,0 +1,2 @@
+/target
+/target
diff --git a/common-app-api/pom.xml b/common-app-api/pom.xml
new file mode 100644
index 0000000000..955e721a94
--- /dev/null
+++ b/common-app-api/pom.xml
@@ -0,0 +1,209 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>common-app-api</artifactId>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>sdc-main</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>security-utils</artifactId>
+ <version>${security-utils.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <!-- functional java -->
+
+ <dependency>
+ <groupId>org.functionaljava</groupId>
+ <artifactId>functionaljava</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.glassfish.jersey.containers</groupId>
+ <artifactId>jersey-container-servlet</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- yaml to object converter -->
+ <dependency>
+ <groupId>org.yaml</groupId>
+ <artifactId>snakeyaml</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- listen to file changes -->
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-jci-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Gson -->
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- http client -->
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.glassfish.jersey.media</groupId>
+ <artifactId>jersey-media-json-jackson</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Aspects -->
+ <dependency>
+ <groupId>com.jcabi</groupId>
+ <artifactId>jcabi-aspects</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <!-- logging -->
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <!-- logging end -->
+ <!-- -->
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>${guava.version}</version><!--$NO-MVN-MAN-VER$-->
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.fusesource</groupId>
+ <artifactId>sigar</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- jsoup HTML parser library @ http://jsoup.org/ -->
+ <dependency>
+ <groupId>org.jsoup</groupId>
+ <artifactId>jsoup</artifactId>
+ <version>1.8.3</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-validator</groupId>
+ <artifactId>commons-validator</artifactId>
+ <version>1.5.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.jettison</groupId>
+ <artifactId>jettison</artifactId>
+ <version>1.3.8</version>
+ </dependency>
+
+ <dependency>
+ <groupId>de.ruedigermoeller</groupId>
+ <artifactId>fst</artifactId>
+ <version>2.47</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+<build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <version>2.7</version>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+</build>
+
+</project>
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/BeEcompErrorManager.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/BeEcompErrorManager.java
new file mode 100644
index 0000000000..d2675ac0c0
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/BeEcompErrorManager.java
@@ -0,0 +1,431 @@
+/*-
+ * ============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.config;
+
+import org.openecomp.sdc.common.config.AbsEcompErrorManager;
+import org.openecomp.sdc.common.config.EcompErrorEnum;
+import org.openecomp.sdc.common.config.IEcompConfigurationManager;
+
+public class BeEcompErrorManager extends AbsEcompErrorManager {
+
+ public enum ComponentName {
+ SERVICE, PRODUCT, VF
+ }
+
+ public enum ErrorSeverity {
+ INFO, WARNING, ERROR, FATAL
+ }
+
+ private static volatile BeEcompErrorManager instance;
+ private static ConfigurationManager configurationManager;
+
+ private BeEcompErrorManager() {
+ };
+
+ public static BeEcompErrorManager getInstance() {
+ if (instance == null) {
+
+ instance = init();
+ }
+ return instance;
+ }
+
+ private static synchronized BeEcompErrorManager init() {
+ if (instance == null) {
+ instance = new BeEcompErrorManager();
+ configurationManager = ConfigurationManager.getConfigurationManager();
+ }
+ return instance;
+ }
+
+ @Override
+ public IEcompConfigurationManager getConfigurationManager() {
+ return configurationManager;
+ }
+
+ public void logBeUebAuthenticationError(String context, String reason) {
+ processEcompError(context, EcompErrorEnum.BeUebAuthenticationError, reason);
+ }
+
+ public void logBeHealthCheckRecovery(String context) {
+ processEcompError(context, EcompErrorEnum.BeHealthCheckRecovery);
+ }
+
+ public void logBeHealthCheckTitanRecovery(String context) {
+ processEcompError(context, EcompErrorEnum.BeHealthCheckTitanRecovery);
+ }
+
+ public void logBeHealthCheckElasticSearchRecovery(String context) {
+ processEcompError(context, EcompErrorEnum.BeHealthCheckElasticSearchRecovery);
+ }
+
+ public void logBeHealthCheckUebClusterRecovery(String context) {
+ processEcompError(context, EcompErrorEnum.BeHealthCheckUebClusterRecovery);
+ }
+
+ public void logFeHealthCheckRecovery(String context) {
+ processEcompError(context, EcompErrorEnum.FeHealthCheckRecovery);
+ }
+
+ public void logBeHealthCheckError(String context) {
+ processEcompError(context, EcompErrorEnum.BeHealthCheckError);
+ }
+
+ public void logBeHealthCheckTitanError(String context) {
+ processEcompError(context, EcompErrorEnum.BeHealthCheckTitanError);
+ }
+
+ public void logBeHealthCheckElasticSearchError(String context) {
+ processEcompError(context, EcompErrorEnum.BeHealthCheckElasticSearchError);
+ }
+
+ public void logBeHealthCheckUebClusterError(String context) {
+ processEcompError(context, EcompErrorEnum.BeHealthCheckUebClusterError);
+ }
+
+ public void logFeHealthCheckError(String context) {
+ processEcompError(context, EcompErrorEnum.FeHealthCheckError);
+ }
+
+ /**
+ * @param context
+ * @param reason
+ */
+ public void logBeUebConnectionError(String context, String reason) {
+ processEcompError(context, EcompErrorEnum.BeUebConnectionError, reason);
+ }
+
+ public void logBeUebUnkownHostError(String context, String host) {
+ processEcompError(context, EcompErrorEnum.BeUebUnkownHostError, host);
+ }
+
+ public void logBeComponentMissingError(String context, String componentType, String name) {
+ processEcompError(context, EcompErrorEnum.BeComponentMissingError, componentType, name);
+ }
+
+ public void logBeIncorrectComponentError(String context, String componentType, String name) {
+ processEcompError(context, EcompErrorEnum.BeIncorrectComponentError, componentType, name);
+ }
+
+ public void logBeInvalidConfigurationError(String context, String parameterName, String parameterValue) {
+ processEcompError(context, EcompErrorEnum.BeInvalidConfigurationError, parameterName, parameterValue);
+ }
+
+ public void logBeUebObjectNotFoundError(String context, String notFoundObjectName) {
+ processEcompError(context, EcompErrorEnum.BeUebObjectNotFoundError, notFoundObjectName);
+ }
+
+ public void logBeDistributionEngineInvalidArtifactType(String context, String artifactType,
+ String validArtifactTypes) {
+ processEcompError(context, EcompErrorEnum.BeDistributionEngineInvalidArtifactType, artifactType,
+ validArtifactTypes);
+ }
+
+ public void logBeMissingConfigurationError(String context, String parameterName) {
+ processEcompError(context, EcompErrorEnum.BeMissingConfigurationError, parameterName);
+ }
+
+ public void logBeConfigurationInvalidListSizeError(String context, String parameterName, int listMinimumSize) {
+ processEcompError(context, EcompErrorEnum.BeConfigurationInvalidListSizeError, parameterName,
+ String.valueOf(listMinimumSize));
+ }
+
+ public void logErrorConfigFileFormat(String context, String description) {
+ processEcompError(context, EcompErrorEnum.ErrorConfigFileFormat, description);
+ }
+
+ public void logBeMissingArtifactInformationError(String context, String missingInfo) {
+ processEcompError(context, EcompErrorEnum.BeMissingArtifactInformationError, missingInfo);
+ }
+
+ public void logBeArtifactMissingError(String context, String artifactName) {
+ processEcompError(context, EcompErrorEnum.BeArtifactMissingError, artifactName);
+ }
+
+ public void logBeUserMissingError(String context, String userId) {
+ processEcompError(context, EcompErrorEnum.BeUserMissingError, userId);
+ }
+
+ public void logBeInvalidTypeError(String context, String type, String name) {
+ processEcompError(context, EcompErrorEnum.BeInvalidTypeError, type, name);
+ }
+
+ public void logBeInvalidValueError(String context, String value, String name, String type) {
+ processEcompError(context, EcompErrorEnum.BeInvalidValueError, value, name, type);
+ }
+
+ public void logBeArtifactPayloadInvalid(String context) {
+ processEcompError(context, EcompErrorEnum.BeArtifactPayloadInvalid);
+ }
+
+ public void logBeArtifactInformationInvalidError(String context) {
+ processEcompError(context, EcompErrorEnum.BeArtifactInformationInvalidError);
+ }
+
+ public void logBeDistributionMissingError(String context, String distributionName) {
+ processEcompError(context, EcompErrorEnum.BeDistributionMissingError, "Distribution", distributionName);
+ }
+
+ public void logBeGraphObjectMissingError(String context, String objectType, String objectName) {
+ processEcompError(context, EcompErrorEnum.BeGraphObjectMissingError, objectType, objectName);
+ }
+
+ public void logBeInvalidJsonInput(String context) {
+ processEcompError(context, EcompErrorEnum.BeInvalidJsonInput);
+ }
+
+ public void logBeInitializationError(String context) {
+ processEcompError(context, EcompErrorEnum.BeInitializationError);
+ }
+
+ public void logBeFailedAddingResourceInstanceError(String context, String resourceName, String serviceId) {
+ processEcompError(context, EcompErrorEnum.BeFailedAddingResourceInstanceError, resourceName, serviceId);
+ }
+
+ public void logBeUebSystemError(String context, String operation) {
+ processEcompError(context, EcompErrorEnum.BeUebSystemError, operation);
+ }
+
+ public void logBeDistributionEngineSystemError(String context, String operation) {
+ processEcompError(context, EcompErrorEnum.BeDistributionEngineSystemError, operation);
+ }
+
+ public void logBeFailedAddingNodeTypeError(String context, String nodeType) {
+ processEcompError(context, EcompErrorEnum.BeFailedAddingNodeTypeError, nodeType);
+ }
+
+ public void logBeDaoSystemError(String context) {
+ processEcompError(context, EcompErrorEnum.BeDaoSystemError);
+ }
+
+ public void logBeSystemError(String context) {
+ processEcompError(context, EcompErrorEnum.BeSystemError);
+ }
+
+ public void logBeExecuteRollbackError(String context) {
+ processEcompError(context, EcompErrorEnum.BeExecuteRollbackError);
+ }
+
+ public void logBeFailedLockObjectError(String context, String type, String id) {
+ processEcompError(context, EcompErrorEnum.BeFailedLockObjectError, type, id);
+ }
+
+ public void logBeFailedCreateNodeError(String context, String nodeName, String status) {
+ processEcompError(context, EcompErrorEnum.BeFailedCreateNodeError, nodeName, status);
+ }
+
+ public void logBeFailedUpdateNodeError(String context, String nodeName, String status) {
+ processEcompError(context, EcompErrorEnum.BeFailedUpdateNodeError, nodeName, status);
+ }
+
+ public void logBeFailedDeleteNodeError(String context, String nodeName, String status) {
+ processEcompError(context, EcompErrorEnum.BeFailedDeleteNodeError, nodeName, status);
+ }
+
+ public void logBeFailedRetrieveNodeError(String context, String nodeName, String status) {
+ processEcompError(context, EcompErrorEnum.BeFailedRetrieveNodeError, nodeName, status);
+ }
+
+ public void logBeFailedFindParentError(String context, String node, String status) {
+ processEcompError(context, EcompErrorEnum.BeFailedFindParentError, node, status);
+ }
+
+ public void logBeFailedFindAllNodesError(String context, String nodeType, String parentNode, String status) {
+ processEcompError(context, EcompErrorEnum.BeFailedFindAllNodesError, nodeType, parentNode, status);
+ }
+
+ public void logBeFailedFindAssociationError(String context, String nodeType, String fromNode, String status) {
+ processEcompError(context, EcompErrorEnum.BeFailedFindAssociationError, nodeType, fromNode, status);
+ }
+
+ public void logBeComponentCleanerSystemError(String context, String operation) {
+ processEcompError(context, EcompErrorEnum.BeComponentCleanerSystemError, operation);
+ }
+
+ public void logBeRestApiGeneralError(String context) {
+ processEcompError(context, EcompErrorEnum.BeRestApiGeneralError);
+ }
+
+ public void logFqdnResolveError(String context, String description) {
+ processEcompError(context, EcompErrorEnum.FqdnResolveError, description);
+ }
+
+ public void logSiteSwitchoverInfo(String context, String description) {
+ processEcompError(context, EcompErrorEnum.SiteSwitchoverInfo, description);
+ }
+
+ public void logInternalAuthenticationError(String context, String description, ErrorSeverity severity) {
+
+ if (severity == null) {
+ processEcompError(context, EcompErrorEnum.InternalAuthenticationError, description);
+ } else {
+ switch (severity) {
+ case INFO:
+ processEcompError(context, EcompErrorEnum.InternalAuthenticationInfo, description);
+ break;
+ case WARNING:
+ processEcompError(context, EcompErrorEnum.InternalAuthenticationWarning, description);
+ break;
+ case ERROR:
+ processEcompError(context, EcompErrorEnum.InternalAuthenticationError, description);
+ break;
+ case FATAL:
+ processEcompError(context, EcompErrorEnum.InternalAuthenticationFatal, description);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ }
+
+ public void logInternalConnectionError(String context, String description, ErrorSeverity severity) {
+
+ if (severity == null) {
+ processEcompError(context, EcompErrorEnum.InternalConnectionError, description);
+ } else {
+ switch (severity) {
+ case INFO:
+ processEcompError(context, EcompErrorEnum.InternalConnectionInfo, description);
+ break;
+ case WARNING:
+ processEcompError(context, EcompErrorEnum.InternalConnectionWarning, description);
+ break;
+ case ERROR:
+ processEcompError(context, EcompErrorEnum.InternalConnectionError, description);
+ break;
+ case FATAL:
+ processEcompError(context, EcompErrorEnum.InternalConnectionFatal, description);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ }
+
+ public void logInternalDataError(String context, String description, ErrorSeverity severity) {
+
+ if (severity == null) {
+ processEcompError(context, EcompErrorEnum.InternalDataError, description);
+ } else {
+ switch (severity) {
+ case INFO:
+ processEcompError(context, EcompErrorEnum.InternalDataInfo, description);
+ break;
+ case WARNING:
+ processEcompError(context, EcompErrorEnum.InternalDataWarning, description);
+ break;
+ case ERROR:
+ processEcompError(context, EcompErrorEnum.InternalDataError, description);
+ break;
+ case FATAL:
+ processEcompError(context, EcompErrorEnum.InternalDataFatal, description);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ }
+
+ public void logInvalidInputError(String context, String description, ErrorSeverity severity) {
+
+ if (severity == null) {
+ processEcompError(context, EcompErrorEnum.InvalidInputError, description);
+ } else {
+ switch (severity) {
+ case INFO:
+ processEcompError(context, EcompErrorEnum.InvalidInputWarning, description);
+ break;
+ case WARNING:
+ processEcompError(context, EcompErrorEnum.InvalidInputInfo, description);
+ break;
+ case ERROR:
+ processEcompError(context, EcompErrorEnum.InvalidInputError, description);
+ break;
+ case FATAL:
+ processEcompError(context, EcompErrorEnum.InvalidInputFatal, description);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ }
+
+ public void logInternalFlowError(String context, String description, ErrorSeverity severity) {
+
+ if (severity == null) {
+ processEcompError(context, EcompErrorEnum.InternalFlowError, description);
+ } else {
+ switch (severity) {
+ case INFO:
+ processEcompError(context, EcompErrorEnum.InternalFlowInfo, description);
+ break;
+ case WARNING:
+ processEcompError(context, EcompErrorEnum.InternalFlowWarning, description);
+ break;
+ case ERROR:
+ processEcompError(context, EcompErrorEnum.InternalFlowError, description);
+ break;
+ case FATAL:
+ processEcompError(context, EcompErrorEnum.InternalFlowFatal, description);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ }
+
+ public void logInternalUnexpectedError(String context, String description, ErrorSeverity severity) {
+
+ if (severity == null) {
+ processEcompError(context, EcompErrorEnum.InternalUnexpectedError, description);
+ } else {
+ switch (severity) {
+ case INFO:
+ processEcompError(context, EcompErrorEnum.InternalUnexpectedInfo, description);
+ break;
+ case WARNING:
+ processEcompError(context, EcompErrorEnum.InternalUnexpectedWarning, description);
+ break;
+ case ERROR:
+ processEcompError(context, EcompErrorEnum.InternalUnexpectedError, description);
+ break;
+ case FATAL:
+ processEcompError(context, EcompErrorEnum.InternalUnexpectedFatal, description);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/CleanComponentsConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/CleanComponentsConfiguration.java
new file mode 100644
index 0000000000..6411005449
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/CleanComponentsConfiguration.java
@@ -0,0 +1,46 @@
+/*-
+ * ============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.config;
+
+import java.util.List;
+
+public class CleanComponentsConfiguration {
+
+ private long cleanIntervalInMinutes;
+ private List<String> componentsToClean;
+
+ public long getCleanIntervalInMinutes() {
+ return cleanIntervalInMinutes;
+ }
+
+ public void setCleanIntervalInMinutes(long cleanIntervalInMinutes) {
+ this.cleanIntervalInMinutes = cleanIntervalInMinutes;
+ }
+
+ public List<String> getComponentsToClean() {
+ return componentsToClean;
+ }
+
+ public void setComponentsToClean(List<String> componentsToClean) {
+ this.componentsToClean = componentsToClean;
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java
new file mode 100644
index 0000000000..96505f4e5d
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java
@@ -0,0 +1,1233 @@
+/*-
+ * ============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.config;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.openecomp.sdc.common.api.BasicConfiguration;
+
+import static java.lang.String.format;
+
+public class Configuration extends BasicConfiguration {
+
+ private List<String> identificationHeaderFields;
+ /**
+ * Requests from these Urls will not be logged by
+ * org.openecomp.sdc.be.filters.BeServletFilter.<br>
+ **/
+ private List<String> unLoggedUrls;
+
+ /**
+ * backend host
+ */
+ private String beFqdn;
+ /**
+ * backend http port
+ */
+ private Integer beHttpPort;
+ /**
+ * backend http secured port
+ */
+ private Integer beSslPort;
+ /**
+ * be http context
+ */
+ private String beContext;
+ /**
+ * backend protocol. http | https
+ */
+ private String beProtocol = "http";
+
+ private Date released;
+ private String version = "1111";
+ private List<String> protocols;
+ private Map<String, String> users;
+ private Map<String, Object> neo4j;
+ private ElasticSearchConfig elasticSearch;
+ private String titanCfgFile;
+ private Boolean titanInMemoryGraph;
+ private Long titanLockTimeout;
+ private Long titanReconnectIntervalInSeconds;
+ private Long titanHealthCheckReadTimeout;
+ private Long esReconnectIntervalInSeconds;
+ private Long uebHealthCheckReconnectIntervalInSeconds;
+ private Long uebHealthCheckReadTimeout;
+
+ private List<String> resourceTypes;
+ private List<String> excludeResourceCategory;
+ private Map<String, Object> deploymentResourceArtifacts;
+ private Map<String, Object> deploymentResourceInstanceArtifacts;
+ private Map<String, Object> toscaArtifacts;
+ private Map<String, Object> informationalResourceArtifacts;
+ private Map<String, Object> informationalServiceArtifacts;
+ private Map<String, DeploymentArtifactTypeConfig> resourceDeploymentArtifacts;
+ private Map<String, DeploymentArtifactTypeConfig> serviceDeploymentArtifacts;
+ private Map<String, DeploymentArtifactTypeConfig> resourceInstanceDeploymentArtifacts;
+ private Map<String, DeploymentArtifactTypeConfig> resourceInformationalDeployedArtifacts;
+ private Map<String, Object> serviceApiArtifacts;
+ private List<String> excludeServiceCategory;
+ private Map<String, Set<String>> requirementsToFulfillBeforeCert;
+ private Map<String, Set<String>> capabilitiesToConsumeBeforeCert;
+
+ private List<String> artifactTypes;
+ private List<String> licenseTypes;
+
+ private Integer additionalInformationMaxNumberOfKeys;
+ private Integer defaultHeatArtifactTimeoutMinutes;
+
+ private BeMonitoringConfig systemMonitoring;
+ private CleanComponentsConfiguration cleanComponentsConfiguration;
+
+ private String artifactsIndex;
+
+ private String heatEnvArtifactHeader;
+ private String heatEnvArtifactFooter;
+
+ private String toscaFilesDir;
+ private String heatTranslatorPath;
+
+ private OnboardingConfig onboarding;
+
+ private CassandrConfig cassandraConfig;
+
+ private SwitchoverDetectorConfig switchoverDetector;
+
+ private ApplicationL1CacheConfig applicationL1Cache;
+
+ private ApplicationL2CacheConfig applicationL2Cache;
+
+ private ToscaValidatorsConfig toscaValidators;
+
+ private boolean disableAudit;
+
+ public SwitchoverDetectorConfig getSwitchoverDetector() {
+ return switchoverDetector;
+ }
+
+ public void setSwitchoverDetector(SwitchoverDetectorConfig switchoverDetector) {
+ this.switchoverDetector = switchoverDetector;
+ }
+
+ public ApplicationL1CacheConfig getApplicationL1Cache() {
+ return applicationL1Cache;
+ }
+
+ public void setApplicationL1Cache(ApplicationL1CacheConfig applicationL1Cache) {
+ this.applicationL1Cache = applicationL1Cache;
+ }
+
+ public ApplicationL2CacheConfig getApplicationL2Cache() {
+ return applicationL2Cache;
+ }
+
+ public void setApplicationL2Cache(ApplicationL2CacheConfig applicationL2Cache) {
+ this.applicationL2Cache = applicationL2Cache;
+ }
+
+ private EcompPortalConfig ecompPortal;
+
+ public CassandrConfig getCassandraConfig() {
+ return cassandraConfig;
+ }
+
+ public void setCassandraConfig(CassandrConfig cassandraKeySpace) {
+ this.cassandraConfig = cassandraKeySpace;
+ }
+
+ public List<String> getIdentificationHeaderFields() {
+ return identificationHeaderFields;
+ }
+
+ public void setIdentificationHeaderFields(List<String> identificationHeaderFields) {
+ this.identificationHeaderFields = identificationHeaderFields;
+ }
+
+ public Date getReleased() {
+ return released;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setReleased(Date released) {
+ this.released = released;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public List<String> getProtocols() {
+ return protocols;
+ }
+
+ public void setProtocols(List<String> protocols) {
+ this.protocols = protocols;
+ }
+
+ public Map<String, String> getUsers() {
+ return users;
+ }
+
+ public void setUsers(Map<String, String> users) {
+ this.users = users;
+ }
+
+ public String getBeFqdn() {
+ return beFqdn;
+ }
+
+ public void setBeFqdn(String beHost) {
+ this.beFqdn = beHost;
+ }
+
+ public Integer getBeHttpPort() {
+ return beHttpPort;
+ }
+
+ public void setBeHttpPort(Integer beHttpPort) {
+ this.beHttpPort = beHttpPort;
+ }
+
+ public Integer getBeSslPort() {
+ return beSslPort;
+ }
+
+ public void setBeSslPort(Integer beSslPort) {
+ this.beSslPort = beSslPort;
+ }
+
+ public String getBeContext() {
+ return beContext;
+ }
+
+ public void setBeContext(String beContext) {
+ this.beContext = beContext;
+ }
+
+ public String getBeProtocol() {
+ return beProtocol;
+ }
+
+ public void setBeProtocol(String beProtocol) {
+ this.beProtocol = beProtocol;
+ }
+
+ public Map<String, Object> getNeo4j() {
+ return neo4j;
+ }
+
+ public void setNeo4j(Map<String, Object> neo4j) {
+ this.neo4j = neo4j;
+ }
+
+ public ElasticSearchConfig getElasticSearch() {
+ return elasticSearch;
+ }
+
+ public void setElasticSearch(ElasticSearchConfig elasticSearch) {
+ this.elasticSearch = elasticSearch;
+ }
+
+ public String getTitanCfgFile() {
+ return titanCfgFile;
+ }
+
+ public void setTitanCfgFile(String titanCfgFile) {
+ this.titanCfgFile = titanCfgFile;
+ }
+
+ public Boolean getTitanInMemoryGraph() {
+ return titanInMemoryGraph;
+ }
+
+ public void setTitanInMemoryGraph(Boolean titanInMemoryGraph) {
+ this.titanInMemoryGraph = titanInMemoryGraph;
+ }
+
+ public Long getTitanLockTimeout() {
+ return titanLockTimeout;
+ }
+
+ public void setTitanLockTimeout(Long titanLockTimeout) {
+ this.titanLockTimeout = titanLockTimeout;
+ }
+
+ public Long getTitanHealthCheckReadTimeout() {
+ return titanHealthCheckReadTimeout;
+ }
+
+ public Long getTitanHealthCheckReadTimeout(long defaultVal) {
+ return titanHealthCheckReadTimeout == null ? defaultVal : titanHealthCheckReadTimeout;
+ }
+
+ public void setTitanHealthCheckReadTimeout(Long titanHealthCheckReadTimeout) {
+ this.titanHealthCheckReadTimeout = titanHealthCheckReadTimeout;
+ }
+
+ public Long getTitanReconnectIntervalInSeconds() {
+ return titanReconnectIntervalInSeconds;
+ }
+
+ public Long getTitanReconnectIntervalInSeconds(long defaultVal) {
+ return titanReconnectIntervalInSeconds == null ? defaultVal : titanReconnectIntervalInSeconds;
+ }
+
+ public void setTitanReconnectIntervalInSeconds(Long titanReconnectIntervalInSeconds) {
+ this.titanReconnectIntervalInSeconds = titanReconnectIntervalInSeconds;
+ }
+
+ public Long getEsReconnectIntervalInSeconds() {
+ return esReconnectIntervalInSeconds;
+ }
+
+ public Long getEsReconnectIntervalInSeconds(long defaultVal) {
+ return esReconnectIntervalInSeconds == null ? defaultVal : esReconnectIntervalInSeconds;
+ }
+
+ public void setEsReconnectIntervalInSeconds(Long esReconnectIntervalInSeconds) {
+ this.esReconnectIntervalInSeconds = esReconnectIntervalInSeconds;
+ }
+
+ public List<String> getArtifactTypes() {
+ return artifactTypes;
+ }
+
+ public void setArtifactTypes(List<String> artifactTypes) {
+ this.artifactTypes = artifactTypes;
+ }
+
+ public List<String> getExcludeResourceCategory() {
+ return excludeResourceCategory;
+ }
+
+ public void setExcludeResourceCategory(List<String> excludeResourceCategory) {
+ this.excludeResourceCategory = excludeResourceCategory;
+ }
+
+ public Map<String, Object> getToscaArtifacts() {
+ return toscaArtifacts;
+ }
+
+ public void setToscaArtifacts(Map<String, Object> toscaArtifacts) {
+ this.toscaArtifacts = toscaArtifacts;
+ }
+
+ public Map<String, Object> getInformationalResourceArtifacts() {
+ return informationalResourceArtifacts;
+ }
+
+ public void setInformationalResourceArtifacts(Map<String, Object> informationalResourceArtifacts) {
+ this.informationalResourceArtifacts = informationalResourceArtifacts;
+ }
+
+ public Map<String, Object> getInformationalServiceArtifacts() {
+ return informationalServiceArtifacts;
+ }
+
+ public void setInformationalServiceArtifacts(Map<String, Object> informationalServiceArtifacts) {
+ this.informationalServiceArtifacts = informationalServiceArtifacts;
+ }
+
+ public Map<String, Object> getServiceApiArtifacts() {
+ return serviceApiArtifacts;
+ }
+
+ public void setServiceApiArtifacts(Map<String, Object> serviceApiArtifacts) {
+ this.serviceApiArtifacts = serviceApiArtifacts;
+ }
+
+ public Map<String, DeploymentArtifactTypeConfig> getServiceDeploymentArtifacts() {
+ return serviceDeploymentArtifacts;
+ }
+
+ public void setServiceDeploymentArtifacts(Map<String, DeploymentArtifactTypeConfig> serviceDeploymentArtifacts) {
+ this.serviceDeploymentArtifacts = serviceDeploymentArtifacts;
+ }
+
+ public Map<String, DeploymentArtifactTypeConfig> getResourceDeploymentArtifacts() {
+ return resourceDeploymentArtifacts;
+ }
+
+ public void setResourceDeploymentArtifacts(Map<String, DeploymentArtifactTypeConfig> resourceDeploymentArtifacts) {
+ this.resourceDeploymentArtifacts = resourceDeploymentArtifacts;
+ }
+
+ public void setResourceInstanceDeploymentArtifacts(
+ Map<String, DeploymentArtifactTypeConfig> resourceInstanceDeploymentArtifacts) {
+ this.resourceInstanceDeploymentArtifacts = resourceInstanceDeploymentArtifacts;
+ }
+
+ public Map<String, DeploymentArtifactTypeConfig> getResourceInstanceDeploymentArtifacts() {
+ return resourceInstanceDeploymentArtifacts;
+ }
+
+ public List<String> getExcludeServiceCategory() {
+ return excludeServiceCategory;
+ }
+
+ public void setExcludeServiceCategory(List<String> excludeServiceCategory) {
+ this.excludeServiceCategory = excludeServiceCategory;
+ }
+
+ public List<String> getLicenseTypes() {
+ return licenseTypes;
+ }
+
+ public void setLicenseTypes(List<String> licenseTypes) {
+ this.licenseTypes = licenseTypes;
+ }
+
+ public Integer getAdditionalInformationMaxNumberOfKeys() {
+ return additionalInformationMaxNumberOfKeys;
+ }
+
+ public void setAdditionalInformationMaxNumberOfKeys(Integer additionalInformationMaxNumberOfKeys) {
+ this.additionalInformationMaxNumberOfKeys = additionalInformationMaxNumberOfKeys;
+ }
+
+ public BeMonitoringConfig getSystemMonitoring() {
+ return systemMonitoring;
+ }
+
+ public void setSystemMonitoring(BeMonitoringConfig systemMonitoring) {
+ this.systemMonitoring = systemMonitoring;
+ }
+
+ public Integer getDefaultHeatArtifactTimeoutMinutes() {
+ return defaultHeatArtifactTimeoutMinutes;
+ }
+
+ public void setDefaultHeatArtifactTimeoutMinutes(Integer defaultHeatArtifactTimeoutMinutes) {
+ this.defaultHeatArtifactTimeoutMinutes = defaultHeatArtifactTimeoutMinutes;
+ }
+
+ public Long getUebHealthCheckReconnectIntervalInSeconds() {
+ return uebHealthCheckReconnectIntervalInSeconds;
+ }
+
+ public void setUebHealthCheckReconnectIntervalInSeconds(Long uebHealthCheckReconnectIntervalInSeconds) {
+ this.uebHealthCheckReconnectIntervalInSeconds = uebHealthCheckReconnectIntervalInSeconds;
+ }
+
+ public Long getUebHealthCheckReadTimeout() {
+ return uebHealthCheckReadTimeout;
+ }
+
+ public void setUebHealthCheckReadTimeout(Long uebHealthCheckReadTimeout) {
+ this.uebHealthCheckReadTimeout = uebHealthCheckReadTimeout;
+ }
+
+ public static class ElasticSearchConfig {
+
+ List<IndicesTimeFrequencyEntry> indicesTimeFrequency;
+
+ public List<IndicesTimeFrequencyEntry> getIndicesTimeFrequency() {
+ return indicesTimeFrequency;
+ }
+
+ public void setIndicesTimeFrequency(List<IndicesTimeFrequencyEntry> indicesTimeFrequency) {
+ this.indicesTimeFrequency = indicesTimeFrequency;
+ }
+
+ public static class IndicesTimeFrequencyEntry {
+
+ String indexPrefix;
+ String creationPeriod;
+
+ public String getIndexPrefix() {
+ return indexPrefix;
+ }
+
+ public void setIndexPrefix(String indexPrefix) {
+ this.indexPrefix = indexPrefix;
+ }
+
+ public String getCreationPeriod() {
+ return creationPeriod;
+ }
+
+ public void setCreationPeriod(String creationPeriod) {
+ this.creationPeriod = creationPeriod;
+ }
+ }
+ }
+
+ public static class CassandrConfig {
+
+ List<String> cassandraHosts;
+ String localDataCenter;
+ Long reconnectTimeout;
+ List<KeyspaceConfig> keySpaces;
+ boolean authenticate;
+ String username;
+ String password;
+ boolean ssl;
+ String truststorePath;
+ String truststorePassword;
+
+ public String getLocalDataCenter() {
+ return localDataCenter;
+ }
+
+ public void setLocalDataCenter(String localDataCenter) {
+ this.localDataCenter = localDataCenter;
+ }
+
+ public boolean isAuthenticate() {
+ return authenticate;
+ }
+
+ public void setAuthenticate(boolean authenticate) {
+ this.authenticate = authenticate;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public boolean isSsl() {
+ return ssl;
+ }
+
+ public void setSsl(boolean ssl) {
+ this.ssl = ssl;
+ }
+
+ public String getTruststorePath() {
+ return truststorePath;
+ }
+
+ public void setTruststorePath(String truststorePath) {
+ this.truststorePath = truststorePath;
+ }
+
+ public String getTruststorePassword() {
+ return truststorePassword;
+ }
+
+ public void setTruststorePassword(String truststorePassword) {
+ this.truststorePassword = truststorePassword;
+ }
+
+ public Long getReconnectTimeout() {
+ return reconnectTimeout;
+ }
+
+ public void setReconnectTimeout(Long reconnectTimeout) {
+ this.reconnectTimeout = reconnectTimeout;
+ }
+
+ public List<String> getCassandraHosts() {
+ return cassandraHosts;
+ }
+
+ public void setCassandraHosts(List<String> cassandraHosts) {
+ this.cassandraHosts = cassandraHosts;
+ }
+
+ public List<KeyspaceConfig> getKeySpaces() {
+ return keySpaces;
+ }
+
+ public void setKeySpaces(List<KeyspaceConfig> cassandraConfig) {
+ this.keySpaces = cassandraConfig;
+ }
+
+ public static class KeyspaceConfig {
+
+ String name;
+ String replicationStrategy;
+ List<String> replicationInfo;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getReplicationStrategy() {
+ return replicationStrategy;
+ }
+
+ public void setReplicationStrategy(String replicationStrategy) {
+ this.replicationStrategy = replicationStrategy;
+ }
+
+ public List<String> getReplicationInfo() {
+ return replicationInfo;
+ }
+
+ public void setReplicationInfo(List<String> replicationInfo) {
+ this.replicationInfo = replicationInfo;
+ }
+ }
+ }
+
+ public static class SwitchoverDetectorConfig {
+
+ String gBeFqdn;
+ String gFeFqdn;
+ String beVip;
+ String feVip;
+ int beResolveAttempts;
+ int feResolveAttempts;
+ Boolean enabled;
+ long interval;
+ String changePriorityUser;
+ String changePriorityPassword;
+ String publishNetworkUrl;
+ String publishNetworkBody;
+ Map<String, GroupInfo> groups;
+
+ public String getgBeFqdn() {
+ return gBeFqdn;
+ }
+
+ public void setgBeFqdn(String gBeFqdn) {
+ this.gBeFqdn = gBeFqdn;
+ }
+
+ public String getgFeFqdn() {
+ return gFeFqdn;
+ }
+
+ public void setgFeFqdn(String gFeFqdn) {
+ this.gFeFqdn = gFeFqdn;
+ }
+
+ public String getBeVip() {
+ return beVip;
+ }
+
+ public void setBeVip(String beVip) {
+ this.beVip = beVip;
+ }
+
+ public String getFeVip() {
+ return feVip;
+ }
+
+ public void setFeVip(String feVip) {
+ this.feVip = feVip;
+ }
+
+ public int getBeResolveAttempts() {
+ return beResolveAttempts;
+ }
+
+ public void setBeResolveAttempts(int beResolveAttempts) {
+ this.beResolveAttempts = beResolveAttempts;
+ }
+
+ public int getFeResolveAttempts() {
+ return feResolveAttempts;
+ }
+
+ public void setFeResolveAttempts(int feResolveAttempts) {
+ this.feResolveAttempts = feResolveAttempts;
+ }
+
+ public Boolean getEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(Boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public long getInterval() {
+ return interval;
+ }
+
+ public void setInterval(long interval) {
+ this.interval = interval;
+ }
+
+ public String getChangePriorityUser() {
+ return changePriorityUser;
+ }
+
+ public void setChangePriorityUser(String changePriorityUser) {
+ this.changePriorityUser = changePriorityUser;
+ }
+
+ public String getChangePriorityPassword() {
+ return changePriorityPassword;
+ }
+
+ public void setChangePriorityPassword(String changePriorityPassword) {
+ this.changePriorityPassword = changePriorityPassword;
+ }
+
+ public String getPublishNetworkUrl() {
+ return publishNetworkUrl;
+ }
+
+ public void setPublishNetworkUrl(String publishNetworkUrl) {
+ this.publishNetworkUrl = publishNetworkUrl;
+ }
+
+ public String getPublishNetworkBody() {
+ return publishNetworkBody;
+ }
+
+ public void setPublishNetworkBody(String publishNetworkBody) {
+ this.publishNetworkBody = publishNetworkBody;
+ }
+
+ public Map<String, GroupInfo> getGroups() {
+ return groups;
+ }
+
+ public void setGroups(Map<String, GroupInfo> groups) {
+ this.groups = groups;
+ }
+
+ public static class GroupInfo {
+
+ String changePriorityUrl;
+ String changePriorityBody;
+
+ public String getChangePriorityUrl() {
+ return changePriorityUrl;
+ }
+
+ public void setChangePriorityUrl(String changePriorityUrl) {
+ this.changePriorityUrl = changePriorityUrl;
+ }
+
+ public String getChangePriorityBody() {
+ return changePriorityBody;
+ }
+
+ public void setChangePriorityBody(String changePriorityBody) {
+ this.changePriorityBody = changePriorityBody;
+ }
+ }
+
+ }
+
+ public static class BeMonitoringConfig {
+
+ Boolean enabled;
+ Boolean isProxy;
+ Integer probeIntervalInSeconds;
+
+ public Boolean getEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(Boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public Boolean getIsProxy() {
+ return isProxy;
+ }
+
+ public void setIsProxy(Boolean isProxy) {
+ this.isProxy = isProxy;
+ }
+
+ public Integer getProbeIntervalInSeconds() {
+ return probeIntervalInSeconds;
+ }
+
+ public Integer getProbeIntervalInSeconds(int defaultVal) {
+ return probeIntervalInSeconds == null ? defaultVal : probeIntervalInSeconds;
+ }
+
+ public void setProbeIntervalInSeconds(Integer probeIntervalInSeconds) {
+ this.probeIntervalInSeconds = probeIntervalInSeconds;
+ }
+ }
+
+ public static class DeploymentArtifactTypeConfig {
+
+ List<String> acceptedTypes;
+ List<String> validForResourceTypes;
+
+ public List<String> getValidForResourceTypes() {
+ return validForResourceTypes;
+ }
+
+ public void setValidForResourceTypes(List<String> validForResourceTypes) {
+ this.validForResourceTypes = validForResourceTypes;
+ }
+
+ public List<String> getAcceptedTypes() {
+ return acceptedTypes;
+ }
+
+ public void setAcceptedTypes(List<String> acceptedTypes) {
+ this.acceptedTypes = acceptedTypes;
+ }
+ }
+
+ public static class OnboardingConfig {
+
+ String protocol = "http";
+ String host;
+ Integer port;
+ String downloadCsarUri;
+
+ public String getProtocol() {
+ return protocol;
+ }
+
+ public void setProtocol(String protocol) {
+ this.protocol = protocol;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public Integer getPort() {
+ return port;
+ }
+
+ public void setPort(Integer port) {
+ this.port = port;
+ }
+
+ public String getDownloadCsarUri() {
+ return downloadCsarUri;
+ }
+
+ public void setDownloadCsarUri(String downloadCsarUri) {
+ this.downloadCsarUri = downloadCsarUri;
+ }
+
+ @Override
+ public String toString() {
+ return "OnboardingConfig [protocol=" + protocol + ", host=" + host + ", port=" + port + ", downloadCsarUri="
+ + downloadCsarUri + "]";
+ }
+
+ }
+
+ public static class EcompPortalConfig {
+
+ private String defaultFunctionalMenu;
+
+ public String getDefaultFunctionalMenu() {
+ return defaultFunctionalMenu;
+ }
+
+ public void setDefaultFunctionalMenu(String defaultFunctionalMenu) {
+ this.defaultFunctionalMenu = defaultFunctionalMenu;
+ }
+
+ @Override
+ public String toString() {
+ return "EcompPortalConfig [defaultFunctionalMenu=" + defaultFunctionalMenu + "]";
+ }
+
+ }
+
+ public static class ApplicationL1CacheConfig {
+
+ ApplicationL1CacheInfo datatypes;
+
+ public ApplicationL1CacheInfo getDatatypes() {
+ return datatypes;
+ }
+
+ public void setDatatypes(ApplicationL1CacheInfo datatypes) {
+ this.datatypes = datatypes;
+ }
+
+ @Override
+ public String toString() {
+ return "ApplicationL1CacheConfig [datatypes=" + datatypes + "]";
+ }
+
+ }
+
+ public static class ApplicationL2CacheConfig {
+
+ boolean enabled;
+ ApplicationL1CacheCatalogInfo catalogL1Cache;
+
+ QueueInfo queue;
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public ApplicationL1CacheCatalogInfo getCatalogL1Cache() {
+ return catalogL1Cache;
+ }
+
+ public void setCatalogL1Cache(ApplicationL1CacheCatalogInfo catalogL1Cache) {
+ this.catalogL1Cache = catalogL1Cache;
+ }
+
+ public QueueInfo getQueue() {
+ return queue;
+ }
+
+ public void setQueue(QueueInfo queue) {
+ this.queue = queue;
+ }
+
+ @Override
+ public String toString() {
+ return "ApplicationL2CacheConfig [enabled=" + enabled + ", catalogL1Cache=" + catalogL1Cache + "]";
+ }
+
+ }
+
+ public static class ToscaValidatorsConfig {
+
+ private Integer stringMaxLength;
+
+ public Integer getStringMaxLength() {
+ return stringMaxLength;
+ }
+
+ public void setStringMaxLength(Integer stringMaxLength) {
+ this.stringMaxLength = stringMaxLength;
+ }
+
+ @Override
+ public String toString() {
+ return "ToscaValidatorsConfig [stringMaxLength=" + stringMaxLength + "]";
+ }
+
+ }
+
+ public static class ApplicationL1CacheInfo {
+
+ Boolean enabled;
+ Integer firstRunDelay;
+ Integer pollIntervalInSec;
+
+ public Boolean getEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(Boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public Integer getFirstRunDelay() {
+ return firstRunDelay;
+ }
+
+ public void setFirstRunDelay(Integer firstRunDelay) {
+ this.firstRunDelay = firstRunDelay;
+ }
+
+ public Integer getPollIntervalInSec() {
+ return pollIntervalInSec;
+ }
+
+ public void setPollIntervalInSec(Integer pollIntervalInSec) {
+ this.pollIntervalInSec = pollIntervalInSec;
+ }
+
+ @Override
+ public String toString() {
+ return "ApplicationL1CacheInfo [enabled=" + enabled + ", firstRunDelay=" + firstRunDelay
+ + ", pollIntervalInSec=" + pollIntervalInSec + "]";
+ }
+ }
+
+ public static class ApplicationL1CacheCatalogInfo {
+
+ Boolean enabled;
+ Integer resourcesSizeInCache;
+ Integer servicesSizeInCache;
+ Integer productsSizeInCache;
+
+ public Boolean getEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(Boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public Integer getResourcesSizeInCache() {
+ return resourcesSizeInCache;
+ }
+
+ public void setResourcesSizeInCache(Integer resourcesSizeInCache) {
+ this.resourcesSizeInCache = resourcesSizeInCache;
+ }
+
+ public Integer getServicesSizeInCache() {
+ return servicesSizeInCache;
+ }
+
+ public void setServicesSizeInCache(Integer servicesSizeInCache) {
+ this.servicesSizeInCache = servicesSizeInCache;
+ }
+
+ public Integer getProductsSizeInCache() {
+ return productsSizeInCache;
+ }
+
+ public void setProductsSizeInCache(Integer productsSizeInCache) {
+ this.productsSizeInCache = productsSizeInCache;
+ }
+
+ @Override
+ public String toString() {
+ return "ApplicationL1CacheCatalogInfo [enabled=" + enabled + ", resourcesSizeInCache="
+ + resourcesSizeInCache + ", servicesSizeInCache=" + servicesSizeInCache + ", productsSizeInCache="
+ + productsSizeInCache + "]";
+ }
+
+ }
+
+ public static class QueueInfo {
+ Integer numberOfCacheWorkers;
+ Integer waitOnShutDownInMinutes;
+ Integer syncIntervalInSecondes;
+
+ public Integer getWaitOnShutDownInMinutes() {
+ return waitOnShutDownInMinutes;
+ }
+
+ public void setWaitOnShutDownInMinutes(Integer waitOnShutDownInMinutes) {
+ this.waitOnShutDownInMinutes = waitOnShutDownInMinutes;
+ }
+
+ public Integer getSyncIntervalInSecondes() {
+ return syncIntervalInSecondes;
+ }
+
+ public void setSyncIntervalInSecondes(Integer syncIntervalInSecondes) {
+ this.syncIntervalInSecondes = syncIntervalInSecondes;
+ }
+
+ public Integer getNumberOfCacheWorkers() {
+ return numberOfCacheWorkers;
+ }
+
+ public void setNumberOfCacheWorkers(Integer numberOfCacheWorkers) {
+ this.numberOfCacheWorkers = numberOfCacheWorkers;
+ }
+
+ @Override
+ public String toString() {
+ return "QueueInfo[" + "waitOnShutDownInMinutes=" + waitOnShutDownInMinutes + ", syncIntervalInSecondes="
+ + syncIntervalInSecondes + ", numberOfCacheWorkers=" + this.numberOfCacheWorkers + ']';
+ }
+ }
+
+ public CleanComponentsConfiguration getCleanComponentsConfiguration() {
+ return cleanComponentsConfiguration;
+ }
+
+ public void setCleanComponentsConfiguration(CleanComponentsConfiguration cleanComponentsConfiguration) {
+ this.cleanComponentsConfiguration = cleanComponentsConfiguration;
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder().append(format("backend host: %s\n", beFqdn))
+ .append(format("backend http port: %s\n", beHttpPort))
+ .append(format("backend ssl port: %s\n", beSslPort)).append(format("backend context: %s\n", beContext))
+ .append(format("backend protocol: %s\n", beProtocol)).append(format("Version: %s\n", version))
+ .append(format("Released: %s\n", released)).append(format("Supported protocols: %s\n", protocols))
+ .append(format("Users: %s\n", users)).append(format("Neo4j: %s\n", neo4j))
+ .append(format("ElasticSearch: %s\n", elasticSearch))
+ .append(format("Titan Cfg File: %s\n", titanCfgFile))
+ .append(format("Titan In memory: %s\n", titanInMemoryGraph))
+ .append(format("Titan lock timeout: %s\n", titanLockTimeout))
+ .append(format("Titan reconnect interval seconds: %s\n", titanReconnectIntervalInSeconds))
+ .append(format("excludeResourceCategory: %s\n", excludeResourceCategory))
+ .append(format("informationalResourceArtifacts: %s\n", informationalResourceArtifacts))
+ .append(format("deploymentResourceArtifacts: %s\n", deploymentResourceArtifacts))
+ .append(format("informationalServiceArtifacts: %s\n", informationalServiceArtifacts))
+ .append(format("Supported artifacts types: %s\n", artifactTypes))
+ .append(format("Supported license types: %s\n", licenseTypes))
+ .append(format("Additional information Maximum number of preoperties: %s\n",
+ additionalInformationMaxNumberOfKeys))
+ .append(format("Default Heat Artifact Timeout in Minutes: %s\n", defaultHeatArtifactTimeoutMinutes))
+ .append(format("URLs For HTTP Requests that will not be automatically logged : %s\n", unLoggedUrls))
+ .append(format("Service Api Artifacts: %s\n", serviceApiArtifacts))
+ .append(format("heat env artifact header: %s\n", heatEnvArtifactHeader))
+ .append(format("heat env artifact footer: %s\n", heatEnvArtifactFooter))
+ .append(format("onboarding: %s\n", onboarding)).toString();
+ }
+
+ public List<String> getUnLoggedUrls() {
+ return unLoggedUrls;
+ }
+
+ public void setUnLoggedUrls(List<String> unLoggedUrls) {
+ this.unLoggedUrls = unLoggedUrls;
+ }
+
+ public Map<String, Object> getDeploymentResourceArtifacts() {
+ return deploymentResourceArtifacts;
+ }
+
+ public void setDeploymentResourceArtifacts(Map<String, Object> deploymentResourceArtifacts) {
+ this.deploymentResourceArtifacts = deploymentResourceArtifacts;
+ }
+
+ public String getHeatEnvArtifactHeader() {
+ return heatEnvArtifactHeader;
+ }
+
+ public void setHeatEnvArtifactHeader(String heatEnvArtifactHeader) {
+ this.heatEnvArtifactHeader = heatEnvArtifactHeader;
+ }
+
+ public String getHeatEnvArtifactFooter() {
+ return heatEnvArtifactFooter;
+ }
+
+ public void setHeatEnvArtifactFooter(String heatEnvArtifactFooter) {
+ this.heatEnvArtifactFooter = heatEnvArtifactFooter;
+ }
+
+ public Map<String, Object> getDeploymentResourceInstanceArtifacts() {
+ return deploymentResourceInstanceArtifacts;
+ }
+
+ public void setDeploymentResourceInstanceArtifacts(Map<String, Object> deploymentResourceInstanceArtifacts) {
+ this.deploymentResourceInstanceArtifacts = deploymentResourceInstanceArtifacts;
+ }
+
+ public String getArtifactsIndex() {
+ return artifactsIndex;
+ }
+
+ public void setArtifactsIndex(String artifactsIndex) {
+ this.artifactsIndex = artifactsIndex;
+ }
+
+ public Map<String, DeploymentArtifactTypeConfig> getResourceInformationalDeployedArtifacts() {
+ return resourceInformationalDeployedArtifacts;
+ }
+
+ public void setResourceInformationalDeployedArtifacts(
+ Map<String, DeploymentArtifactTypeConfig> resourceInformationalDeployedArtifacts) {
+ this.resourceInformationalDeployedArtifacts = resourceInformationalDeployedArtifacts;
+ }
+
+ public List<String> getResourceTypes() {
+ return resourceTypes;
+ }
+
+ public void setResourceTypes(List<String> resourceTypes) {
+ this.resourceTypes = resourceTypes;
+ }
+
+ public String getToscaFilesDir() {
+ return toscaFilesDir;
+ }
+
+ public void setToscaFilesDir(String toscaFilesDir) {
+ this.toscaFilesDir = toscaFilesDir;
+ }
+
+ public String getHeatTranslatorPath() {
+ return heatTranslatorPath;
+ }
+
+ public void setHeatTranslatorPath(String heatTranslatorPath) {
+ this.heatTranslatorPath = heatTranslatorPath;
+ }
+
+ public Map<String, Set<String>> getRequirementsToFulfillBeforeCert() {
+ return requirementsToFulfillBeforeCert;
+ }
+
+ public void setRequirementsToFulfillBeforeCert(Map<String, Set<String>> requirementsToFulfillBeforeCert) {
+ this.requirementsToFulfillBeforeCert = requirementsToFulfillBeforeCert;
+ }
+
+ public Map<String, Set<String>> getCapabilitiesToConsumeBeforeCert() {
+ return capabilitiesToConsumeBeforeCert;
+ }
+
+ public void setCapabilitiesToConsumeBeforeCert(Map<String, Set<String>> capabilitiesToConsumeBeforeCert) {
+ this.capabilitiesToConsumeBeforeCert = capabilitiesToConsumeBeforeCert;
+ }
+
+ public OnboardingConfig getOnboarding() {
+ return onboarding;
+ }
+
+ public void setOnboarding(OnboardingConfig onboarding) {
+ this.onboarding = onboarding;
+ }
+
+ public EcompPortalConfig getEcompPortal() {
+ return ecompPortal;
+ }
+
+ public void setEcompPortal(EcompPortalConfig ecompPortal) {
+ this.ecompPortal = ecompPortal;
+ }
+
+ public ToscaValidatorsConfig getToscaValidators() {
+ return toscaValidators;
+ }
+
+ public void setToscaValidators(ToscaValidatorsConfig toscaValidators) {
+ this.toscaValidators = toscaValidators;
+ }
+
+ public boolean isDisableAudit() {
+ return disableAudit;
+ }
+
+ public void setDisableAudit(boolean enableAudit) {
+ this.disableAudit = enableAudit;
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java
new file mode 100644
index 0000000000..0015729be0
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java
@@ -0,0 +1,154 @@
+/*-
+ * ============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.config;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.openecomp.sdc.common.api.BasicConfiguration;
+import org.openecomp.sdc.common.api.ConfigurationListener;
+import org.openecomp.sdc.common.api.ConfigurationSource;
+import org.openecomp.sdc.common.api.FileChangeCallback;
+import org.openecomp.sdc.common.config.EcompErrorConfiguration;
+import org.openecomp.sdc.common.config.IEcompConfigurationManager;
+
+public class ConfigurationManager implements FileChangeCallback, IEcompConfigurationManager {
+
+ ConfigurationSource configurationSource = null;
+ private static ConfigurationManager instance;
+
+ public ConfigurationManager(ConfigurationSource configurationSource) {
+ super();
+ this.configurationSource = configurationSource;
+ loadConfigurationFiles();
+ instance = this;
+ }
+
+ Map<String, Object> configurations = new HashMap<String, Object>();
+
+ private void loadConfigurationFiles() {
+
+ loadConfigurationClass(Configuration.class);
+ loadConfigurationClass(ErrorConfiguration.class);
+ loadConfigurationClass(Neo4jErrorsConfiguration.class);
+ loadConfigurationClass(EcompErrorConfiguration.class);
+ loadConfigurationClass(DistributionEngineConfiguration.class);
+ }
+
+ private <T extends BasicConfiguration> void loadConfigurationClass(Class<T> clazz) {
+ ConfigurationListener configurationListener = new ConfigurationListener(clazz, this);
+
+ T object = configurationSource.getAndWatchConfiguration(clazz, configurationListener);
+
+ configurations.put(getKey(clazz), object);
+ }
+
+ private <T> String getKey(Class<T> class1) {
+
+ return class1.getSimpleName();
+
+ }
+
+ public Configuration getConfiguration() {
+
+ return (Configuration) configurations.get(getKey(Configuration.class));
+
+ }
+
+ public void setConfiguration(Configuration configuration) {
+
+ configurations.put(getKey(Configuration.class), configuration);
+
+ }
+
+ public void setErrorConfiguration(ErrorConfiguration configuration) {
+
+ configurations.put(getKey(ErrorConfiguration.class), configuration);
+
+ }
+
+ public ErrorConfiguration getErrorConfiguration() {
+
+ return (ErrorConfiguration) configurations.get(getKey(ErrorConfiguration.class));
+
+ }
+
+ public Neo4jErrorsConfiguration getNeo4jErrorsConfiguration() {
+ return (Neo4jErrorsConfiguration) configurations.get(getKey(Neo4jErrorsConfiguration.class));
+ }
+
+ @Override
+ public EcompErrorConfiguration getEcompErrorConfiguration() {
+
+ return (EcompErrorConfiguration) configurations.get(getKey(EcompErrorConfiguration.class));
+
+ }
+
+ public Configuration getConfigurationAndWatch(ConfigurationListener configurationListener) {
+
+ if (configurationListener != null) {
+
+ configurationSource.addWatchConfiguration(Configuration.class, configurationListener);
+
+ }
+ return (Configuration) configurations.get(getKey(Configuration.class));
+
+ }
+
+ public static ConfigurationManager getConfigurationManager() {
+ return instance;
+ }
+
+ public void reconfigure(BasicConfiguration obj) {
+
+ // if (obj != null) {
+
+ // if (obj instanceof Configuration) {
+ // configurations.put(getKey(Configuration.class), obj);
+ // }
+ // if (obj instanceof ErrorConfiguration) {
+ // configurations.put(getKey(ErrorConfiguration.class), obj);
+ // }
+ //
+ // if (obj instanceof EcompErrorConfiguration) {
+ // configurations.put(getKey(EcompErrorConfiguration.class), obj);
+ // }
+ // }
+
+ }
+
+ /**
+ * FOR TEST ONLY
+ *
+ * @param ecompErrorConfiguration
+ */
+ public void setEcompErrorConfiguration(EcompErrorConfiguration ecompErrorConfiguration) {
+
+ configurations.put(getKey(EcompErrorConfiguration.class), ecompErrorConfiguration);
+
+ }
+
+ public DistributionEngineConfiguration getDistributionEngineConfiguration() {
+
+ return (DistributionEngineConfiguration) configurations.get(getKey(DistributionEngineConfiguration.class));
+
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/DistributionEngineConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/DistributionEngineConfiguration.java
new file mode 100644
index 0000000000..e4a2092e2f
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/DistributionEngineConfiguration.java
@@ -0,0 +1,430 @@
+/*-
+ * ============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.config;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.openecomp.sdc.common.api.BasicConfiguration;
+
+public class DistributionEngineConfiguration extends BasicConfiguration {
+
+ private List<String> uebServers;
+
+ private String distributionNotifTopicName;
+
+ private String distributionStatusTopicName;
+
+ private Integer initRetryIntervalSec;
+
+ private Integer initMaxIntervalSec;
+
+ private ComponentArtifactTypesConfig distribNotifServiceArtifactTypes;
+
+ private ComponentArtifactTypesConfig distribNotifResourceArtifactTypes;
+
+ // private List<String> distribNotifServiceInfoArtifactTypes;
+
+ // private List<String> distribNotifResourceLifecycleArtifactTypes;
+
+ private String uebPublicKey;
+
+ private String uebSecretKey;
+
+ private List<String> environments;
+
+ private DistributionStatusTopicConfig distributionStatusTopic;
+
+ private CreateTopicConfig createTopic;
+
+ private boolean startDistributionEngine;
+
+ private DistributionNotificationTopicConfig distributionNotificationTopic;
+
+ private Integer defaultArtifactInstallationTimeout = 60;
+
+ public static class DistribNotifServiceArtifacts {
+
+ Map<String, Object> service;
+ Map<String, Object> resource;
+
+ public Map<String, Object> getService() {
+ return service;
+ }
+
+ public void setService(Map<String, Object> service) {
+ this.service = service;
+ }
+
+ public Map<String, Object> getResource() {
+ return resource;
+ }
+
+ public void setResource(Map<String, Object> resource) {
+ this.resource = resource;
+ }
+
+ }
+
+ public static class NotifArtifactTypes {
+
+ List<String> info;
+ List<String> lifecycle;
+
+ public List<String> getInfo() {
+ return info;
+ }
+
+ public void setInfo(List<String> info) {
+ this.info = info;
+ }
+
+ public List<String> getLifecycle() {
+ return lifecycle;
+ }
+
+ public void setLifecycle(List<String> lifecycle) {
+ this.lifecycle = lifecycle;
+ }
+
+ }
+
+ public static class NotifArtifactTypesResource {
+
+ List<ArtifcatTypeEnum> lifecycle;
+
+ }
+
+ public static enum ArtifcatTypeEnum {
+
+ MURANO_PKG("MURANO-PKG"), HEAT("HEAT"), DG_XML("DG_XML");
+
+ String value;
+
+ private ArtifcatTypeEnum(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+
+ return value;
+ }
+ }
+
+ public List<String> getUebServers() {
+ return uebServers;
+ }
+
+ public void setUebServers(List<String> uebServers) {
+ this.uebServers = uebServers;
+ }
+
+ public String getDistributionNotifTopicName() {
+ return distributionNotifTopicName;
+ }
+
+ public void setDistributionNotifTopicName(String distributionNotifTopicName) {
+ this.distributionNotifTopicName = distributionNotifTopicName;
+ }
+
+ public String getDistributionStatusTopicName() {
+ return distributionStatusTopicName;
+ }
+
+ public void setDistributionStatusTopicName(String distributionStatusTopicName) {
+ this.distributionStatusTopicName = distributionStatusTopicName;
+ }
+
+ public Integer getInitRetryIntervalSec() {
+ return initRetryIntervalSec;
+ }
+
+ public void setInitRetryIntervalSec(Integer initRetryIntervalSec) {
+ this.initRetryIntervalSec = initRetryIntervalSec;
+ }
+
+ public ComponentArtifactTypesConfig getDistribNotifServiceArtifactTypes() {
+ return distribNotifServiceArtifactTypes;
+ }
+
+ public void setDistribNotifServiceArtifactTypes(ComponentArtifactTypesConfig distribNotifServiceArtifactTypes) {
+ this.distribNotifServiceArtifactTypes = distribNotifServiceArtifactTypes;
+ }
+
+ public ComponentArtifactTypesConfig getDistribNotifResourceArtifactTypes() {
+ return distribNotifResourceArtifactTypes;
+ }
+
+ public void setDistribNotifResourceArtifactTypes(ComponentArtifactTypesConfig distribNotifResourceArtifactTypes) {
+ this.distribNotifResourceArtifactTypes = distribNotifResourceArtifactTypes;
+ }
+
+ public String getUebPublicKey() {
+ return uebPublicKey;
+ }
+
+ public void setUebPublicKey(String uebPublicKey) {
+ this.uebPublicKey = uebPublicKey;
+ }
+
+ public String getUebSecretKey() {
+ return uebSecretKey;
+ }
+
+ public void setUebSecretKey(String uebSecretKey) {
+ this.uebSecretKey = uebSecretKey;
+ }
+
+ public List<String> getEnvironments() {
+ return environments;
+ }
+
+ public void setEnvironments(List<String> environments) {
+
+ Set<String> set = new HashSet<String>();
+ if (environments != null) {
+ set.addAll(environments);
+ this.environments = new ArrayList<String>(set);
+ } else {
+ this.environments = null;
+ }
+
+ }
+
+ public DistributionStatusTopicConfig getDistributionStatusTopic() {
+ return distributionStatusTopic;
+ }
+
+ public void setDistributionStatusTopic(DistributionStatusTopicConfig distributionStatusTopic) {
+ this.distributionStatusTopic = distributionStatusTopic;
+ }
+
+ public Integer getInitMaxIntervalSec() {
+ return initMaxIntervalSec;
+ }
+
+ public void setInitMaxIntervalSec(Integer initMaxIntervalSec) {
+ this.initMaxIntervalSec = initMaxIntervalSec;
+ }
+
+ public CreateTopicConfig getCreateTopic() {
+ return createTopic;
+ }
+
+ public void setCreateTopic(CreateTopicConfig createTopic) {
+ this.createTopic = createTopic;
+ }
+
+ public boolean isStartDistributionEngine() {
+ return startDistributionEngine;
+ }
+
+ public void setStartDistributionEngine(boolean startDistributionEngine) {
+ this.startDistributionEngine = startDistributionEngine;
+ }
+
+ public DistributionNotificationTopicConfig getDistributionNotificationTopic() {
+ return distributionNotificationTopic;
+ }
+
+ public void setDistributionNotificationTopic(DistributionNotificationTopicConfig distributionNotificationTopic) {
+ this.distributionNotificationTopic = distributionNotificationTopic;
+ }
+
+ public int getDefaultArtifactInstallationTimeout() {
+ return defaultArtifactInstallationTimeout;
+ }
+
+ public void setDefaultArtifactInstallationTimeout(int defaultArtifactInstallationTimeout) {
+ this.defaultArtifactInstallationTimeout = defaultArtifactInstallationTimeout;
+ }
+
+ public static class CreateTopicConfig {
+
+ private Integer partitionCount;
+ private Integer replicationCount;
+
+ public Integer getPartitionCount() {
+ return partitionCount;
+ }
+
+ public void setPartitionCount(Integer partitionCount) {
+ this.partitionCount = partitionCount;
+ }
+
+ public Integer getReplicationCount() {
+ return replicationCount;
+ }
+
+ public void setReplicationCount(Integer replicationCount) {
+ this.replicationCount = replicationCount;
+ }
+
+ @Override
+ public String toString() {
+ return "CreateTopicConfig [partitionCount=" + partitionCount + ", replicationCount=" + replicationCount + "]";
+ }
+
+ }
+
+ public static class EnvironmentConfig {
+
+ private String name;
+ private List<String> uebServers;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<String> getUebServers() {
+ return uebServers;
+ }
+
+ public void setUebServers(List<String> uebServers) {
+ this.uebServers = uebServers;
+ }
+
+ @Override
+ public String toString() {
+ return "EnvironmentConfig [name=" + name + ", uebServers=" + uebServers + "]";
+ }
+
+ }
+
+ public static class DistributionStatusTopicConfig {
+
+ private Integer pollingIntervalSec;
+ private Integer fetchTimeSec;
+ private String consumerGroup;
+ private String consumerId;
+
+ public Integer getPollingIntervalSec() {
+ return pollingIntervalSec;
+ }
+
+ public void setPollingIntervalSec(Integer pollingIntervalSec) {
+ this.pollingIntervalSec = pollingIntervalSec;
+ }
+
+ public Integer getFetchTimeSec() {
+ return fetchTimeSec;
+ }
+
+ public void setFetchTimeSec(Integer fetchTimeSec) {
+ this.fetchTimeSec = fetchTimeSec;
+ }
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+ public String getConsumerId() {
+ return consumerId;
+ }
+
+ public void setConsumerId(String consumerId) {
+ this.consumerId = consumerId;
+ }
+
+ @Override
+ public String toString() {
+ return "DistributionStatusTopicConfig [pollingIntervalSec=" + pollingIntervalSec + ", fetchTimeSec=" + fetchTimeSec + ", consumerGroup=" + consumerGroup + ", consumerId=" + consumerId + "]";
+ }
+
+ }
+
+ public static class DistributionNotificationTopicConfig {
+
+ private Integer maxWaitingAfterSendingSeconds;
+ private Integer maxThreadPoolSize;
+ private Integer minThreadPoolSize;
+
+ public Integer getMaxWaitingAfterSendingSeconds() {
+ return maxWaitingAfterSendingSeconds;
+ }
+
+ public void setMaxWaitingAfterSendingSeconds(Integer maxWaitingAfterSendingSeconds) {
+ this.maxWaitingAfterSendingSeconds = maxWaitingAfterSendingSeconds;
+ }
+
+ public Integer getMaxThreadPoolSize() {
+ return maxThreadPoolSize;
+ }
+
+ public void setMaxThreadPoolSize(Integer maxThreadPoolSize) {
+ this.maxThreadPoolSize = maxThreadPoolSize;
+ }
+
+ public Integer getMinThreadPoolSize() {
+ return minThreadPoolSize;
+ }
+
+ public void setMinThreadPoolSize(Integer minThreadPoolSize) {
+ this.minThreadPoolSize = minThreadPoolSize;
+ }
+
+ @Override
+ public String toString() {
+ return "DistributionNotificationTopicConfig [maxWaitingAfterSendingSeconds=" + maxWaitingAfterSendingSeconds + ", maxThreadPoolSize=" + maxThreadPoolSize + ", minThreadPoolSize=" + minThreadPoolSize + "]";
+ }
+
+ }
+
+ public static class ComponentArtifactTypesConfig {
+
+ private List<String> info;
+ private List<String> lifecycle;
+
+ public List<String> getInfo() {
+ return info;
+ }
+
+ public void setInfo(List<String> info) {
+ this.info = info;
+ }
+
+ public List<String> getLifecycle() {
+ return lifecycle;
+ }
+
+ public void setLifecycle(List<String> lifecycle) {
+ this.lifecycle = lifecycle;
+ }
+
+ @Override
+ public String toString() {
+ return "ArtifactTypesConfig [info=" + info + ", lifecycle=" + lifecycle + "]";
+ }
+
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorConfiguration.java
new file mode 100644
index 0000000000..8250df6c04
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorConfiguration.java
@@ -0,0 +1,54 @@
+/*-
+ * ============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.config;
+
+import java.util.Map;
+
+import org.openecomp.sdc.common.api.BasicConfiguration;
+
+public class ErrorConfiguration extends BasicConfiguration {
+
+ private Map<String, ErrorInfo> errors;
+
+ public Map<String, ErrorInfo> getErrors() {
+ return errors;
+ }
+
+ public void setErrors(Map<String, ErrorInfo> errors) {
+ this.errors = errors;
+ }
+
+ public ErrorInfo getErrorInfo(String key) {
+ ErrorInfo clone = null;
+ ErrorInfo other = errors.get(key);
+ if (other != null) {
+ clone = new ErrorInfo();
+ clone.cloneData(other);
+ }
+ return clone;
+ }
+
+ @Override
+ public String toString() {
+ return "ErrorConfiguration [errors=" + errors + "]";
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorInfo.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorInfo.java
new file mode 100644
index 0000000000..40daf96d36
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorInfo.java
@@ -0,0 +1,102 @@
+/*-
+ * ============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.config;
+
+import org.openecomp.sdc.common.config.EcompErrorName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ErrorInfo {
+
+ private Integer code;
+ private String message;
+ private String messageId;
+ private ErrorInfoType errorInfoType;
+
+ private static final String SVC_PREFIX = "SVC";
+ private static final String POL_PREFIX = "POL";
+
+ private static Logger log = LoggerFactory.getLogger(ErrorInfo.class.getName());
+
+ public ErrorInfo() {
+ this.errorInfoType = ErrorInfoType.OK;
+ }
+
+ public Integer getCode() {
+ return code;
+ }
+
+ public void setCode(Integer code) {
+ this.code = code;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getMessageId() {
+ return messageId;
+ }
+
+ public void setMessageId(String messageId) {
+ // Determining the type of error
+ if (messageId == null) {
+ this.errorInfoType = ErrorInfoType.OK;
+ } else if (messageId.startsWith(SVC_PREFIX)) {
+ this.errorInfoType = ErrorInfoType.SERVICE_EXCEPTION;
+ } else if (messageId.startsWith(POL_PREFIX)) {
+ this.errorInfoType = ErrorInfoType.POLICY_EXCEPTION;
+ } else {
+ // unexpected - should it fail the startup?
+ BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.ErrorConfigFileFormat, "Error Info");
+ BeEcompErrorManager.getInstance().logErrorConfigFileFormat("Error Info",
+ "Could not set error info type for message id " + messageId);
+ log.debug("Error: unexpected error message ID {}, should start with {} or {}", messageId, SVC_PREFIX,
+ POL_PREFIX);
+ }
+ this.messageId = messageId;
+ }
+
+ public ErrorInfoType getErrorInfoType() {
+ return this.errorInfoType;
+ }
+
+ public void cloneData(ErrorInfo other) {
+ this.code = other.getCode();
+ this.message = other.getMessage();
+ this.messageId = other.getMessageId();
+ this.errorInfoType = other.errorInfoType;
+ }
+
+ @Override
+ public String toString() {
+ return "ErrorInfo [code=" + code + ", messageId=" + messageId + ", message=" + message + "]";
+ }
+
+ public enum ErrorInfoType {
+ OK, POLICY_EXCEPTION, SERVICE_EXCEPTION
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/Neo4jErrorsConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/Neo4jErrorsConfiguration.java
new file mode 100644
index 0000000000..24a85dc627
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/Neo4jErrorsConfiguration.java
@@ -0,0 +1,47 @@
+/*-
+ * ============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.config;
+
+import java.util.Map;
+
+import org.openecomp.sdc.common.api.BasicConfiguration;
+
+public class Neo4jErrorsConfiguration extends BasicConfiguration {
+ private Map<String, String> errors;
+
+ public Map<String, String> getErrors() {
+ return errors;
+ }
+
+ public void setErrors(Map<String, String> errors) {
+ this.errors = errors;
+ }
+
+ public String getErrorMessage(String key) {
+ return errors.get(key);
+ }
+
+ @Override
+ public String toString() {
+ return "Neo4jErrorsConfiguration [errors=" + errors + "]";
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/validation/DeploymentArtifactHeatConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/validation/DeploymentArtifactHeatConfiguration.java
new file mode 100644
index 0000000000..72b53bac75
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/validation/DeploymentArtifactHeatConfiguration.java
@@ -0,0 +1,57 @@
+/*-
+ * ============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.config.validation;
+
+import java.util.Map;
+
+/**
+ * Currently for deployment artifacts HEAT validation only.
+ *
+ * Other artifacts might require different fields validation Be sure to check it
+ * before you re-use this class
+ *
+ * @author paharoni
+ *
+ */
+public class DeploymentArtifactHeatConfiguration {
+
+ // All the rest of heat file is not needed for now...
+ String heat_template_version;
+
+ Map<String, Object> resources;
+
+ public String getHeat_template_version() {
+ return heat_template_version;
+ }
+
+ public void setHeat_template_version(String heat_template_version) {
+ this.heat_template_version = heat_template_version;
+ }
+
+ public Map<String, Object> getResources() {
+ return resources;
+ }
+
+ public void setResources(Map<String, Object> resources) {
+ this.resources = resources;
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/monitoring/BeMonitoringService.java b/common-app-api/src/main/java/org/openecomp/sdc/be/monitoring/BeMonitoringService.java
new file mode 100644
index 0000000000..ac7391d8cc
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/be/monitoring/BeMonitoringService.java
@@ -0,0 +1,140 @@
+/*-
+ * ============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.monitoring;
+
+import java.io.IOException;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.openecomp.sdc.be.config.Configuration;
+import org.openecomp.sdc.be.config.ConfigurationManager;
+import org.openecomp.sdc.common.api.Constants;
+import org.openecomp.sdc.common.monitoring.MonitoringEvent;
+import org.openecomp.sdc.common.monitoring.MonitoringMetricsFetcher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+public class BeMonitoringService {
+
+ private static final String URL = "%s://%s:%s/sdc2/rest/monitoring";
+ private static Logger monitoringLogger = LoggerFactory.getLogger("asdc.be.monitoring.service");
+ private static Logger log = LoggerFactory.getLogger(BeMonitoringService.class.getName());
+ private static Gson gson = new GsonBuilder().setPrettyPrinting().create();
+
+ private class MonitoringScheduledTask implements Runnable {
+ @Override
+ public void run() {
+ monitoringLogger.trace("Executing BE Monitoring Task - Start");
+ MonitoringEvent monitoringMetrics = MonitoringMetricsFetcher.getInstance().getMonitoringMetrics();
+ processMonitoringEvent(monitoringMetrics);
+ monitoringLogger.trace("Executing BE Monitoring Task - Status = {}", monitoringMetrics.toString());
+ }
+ }
+
+ /**
+ * This executor will execute the Monitoring task.
+ */
+ ScheduledExecutorService monitoringExecutor = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
+ @Override
+ public Thread newThread(Runnable r) {
+ return new Thread(r, "BE-Monitoring-Thread");
+ }
+ });
+ private ServletContext context;
+
+ public BeMonitoringService(ServletContext context) {
+ this.context = context;
+ }
+
+ public void start(int interval) {
+ Configuration config = ((ConfigurationManager) context.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR))
+ .getConfiguration();
+ if (config.getSystemMonitoring().getEnabled()) {
+ log.info("BE monitoring service is enabled, interval is {} seconds", interval);
+ this.monitoringExecutor.scheduleAtFixedRate(new MonitoringScheduledTask(), 0, interval, TimeUnit.SECONDS);
+ } else {
+ log.info("BE monitoring service is disabled");
+ }
+ }
+
+ private void processMonitoringEvent(MonitoringEvent monitoringMetrics) {
+ CloseableHttpClient httpClient = null;
+ try {
+ Configuration config = ((ConfigurationManager) context.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR))
+ .getConfiguration();
+ String redirectedUrl = String.format(URL, config.getBeProtocol(), config.getBeFqdn(),
+ config.getBeHttpPort());
+ httpClient = getHttpClient(config);
+ HttpPost httpPost = new HttpPost(redirectedUrl);
+ String monitoringMetricsJson = gson.toJson(monitoringMetrics);
+ HttpEntity myEntity = new StringEntity(monitoringMetricsJson);
+ httpPost.setEntity(myEntity);
+ httpPost.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+ int beResponseStatus;
+ CloseableHttpResponse beResponse;
+ try {
+ beResponse = httpClient.execute(httpPost);
+ beResponseStatus = beResponse.getStatusLine().getStatusCode();
+ if (beResponseStatus != HttpStatus.SC_OK) {
+ monitoringLogger.error("Unexpected HTTP response from BE : {}", beResponseStatus);
+ }
+ } catch (Exception e) {
+ monitoringLogger.error("Monitoring error when trying to connect to BE", e);
+ }
+ } catch (Exception e) {
+ monitoringLogger.error("Unexpected monitoring error", e);
+ } finally {
+ if (httpClient != null) {
+ try {
+ httpClient.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ }
+
+ private CloseableHttpClient getHttpClient(Configuration config) {
+ int timeout = 3000;
+ RequestConfig.Builder requestBuilder = RequestConfig.custom();
+ requestBuilder.setConnectTimeout(timeout).setConnectionRequestTimeout(timeout).setSocketTimeout(timeout);
+
+ HttpClientBuilder builder = HttpClientBuilder.create();
+ builder.setDefaultRequestConfig(requestBuilder.build());
+ return builder.build();
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ApplicationErrorCodesEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ApplicationErrorCodesEnum.java
new file mode 100644
index 0000000000..fa0f30842b
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ApplicationErrorCodesEnum.java
@@ -0,0 +1,37 @@
+/*-
+ * ============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.common.api;
+
+public enum ApplicationErrorCodesEnum {
+
+ POL5000, // INTERNAL_ERROR
+
+ SVC4000, // INVALID_INPUT
+
+ SVC4002, // MISSING_INFORMATION
+ SVC4003, // RESOURCE_NAME_ALREADY_EXIST
+ SVC4004, // MISSING_CATEGORY
+ SVC4005, // MISSING_TAGS
+ SVC4006, // MISSING_DESCRIPTION
+ SVC4007, // BAD_CATEGORY
+
+ SVC4030; // RESTRICTED_ACTION
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactGroupTypeEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactGroupTypeEnum.java
new file mode 100644
index 0000000000..b7968dc53f
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactGroupTypeEnum.java
@@ -0,0 +1,66 @@
+/*-
+ * ============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.common.api;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public enum ArtifactGroupTypeEnum {
+
+ INFORMATIONAL("INFORMATIONAL"),
+ DEPLOYMENT("DEPLOYMENT"),
+ LIFE_CYCLE("LIFE_CYCLE"),
+ SERVICE_API("SERVICE_API"),
+ TOSCA("TOSCA"),
+ OTHER("OTHER");
+
+ private String type;
+
+ ArtifactGroupTypeEnum(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public static ArtifactGroupTypeEnum findType(final String type) {
+ for (ArtifactGroupTypeEnum ate : ArtifactGroupTypeEnum.values()) {
+ if (ate.getType().equals(type)) {
+ return ate;
+ }
+ }
+ return null;
+ }
+
+ public static List<String> getAllTypes() {
+ List<String> types = new ArrayList<String>();
+ for (ArtifactGroupTypeEnum ate : ArtifactGroupTypeEnum.values()) {
+ types.add(ate.getType());
+ }
+ return types;
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactTypeEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactTypeEnum.java
new file mode 100644
index 0000000000..c0fbad006a
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactTypeEnum.java
@@ -0,0 +1,81 @@
+/*-
+ * ============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.common.api;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Enum That Represents possible Artifacts Types.
+ *
+ */
+public enum ArtifactTypeEnum {
+ CHEF("CHEF"), PUPPET("PUPPET"), YANG("YANG"), SHELL_SCRIPT("SHELL_SCRIPT"), ICON( "ICON"),
+ UNKNOWN("UNKNOWN"), HEAT("HEAT"), DG_XML("DG_XML"), MURANO_PKG( "MURANO_PKG"), HEAT_ENV("HEAT_ENV"),
+ YANG_XML("YANG_XML"), HEAT_VOL("HEAT_VOL"), HEAT_NET("HEAT_NET"), OTHER("OTHER"), WORKFLOW("WORKFLOW"),
+ NETWORK_CALL_FLOW("NETWORK_CALL_FLOW"), TOSCA_TEMPLATE("TOSCA_TEMPLATE"), TOSCA_CSAR("TOSCA_CSAR"),
+ VNF_CATALOG("VNF_CATALOG"), VF_LICENSE("VF_LICENSE"),VENDOR_LICENSE("VENDOR_LICENSE"),
+ MODEL_INVENTORY_PROFILE("MODEL_INVENTORY_PROFILE"), MODEL_QUERY_SPEC("MODEL_QUERY_SPEC"),
+ APPC_CONFIG("APPC_CONFIG"), HEAT_NESTED("HEAT_NESTED"), HEAT_ARTIFACT("HEAT_ARTIFACT"),
+ VF_MODULES_METADATA("VF_MODULES_METADATA"),
+ //DCAE Artifacts
+ DCAE_TOSCA("DCAE_TOSCA"), DCAE_JSON("DCAE_JSON"), DCAE_POLICY("DCAE_POLICY"), DCAE_DOC("DCAE_DOC"),
+ DCAE_EVENT("DCAE_EVENT"), DCAE_INVENTORY_TOSCA("DCAE_INVENTORY_TOSCA"), DCAE_INVENTORY_JSON("DCAE_INVENTORY_JSON"),
+ DCAE_INVENTORY_POLICY("DCAE_INVENTORY_POLICY"), DCAE_INVENTORY_DOC("DCAE_INVENTORY_DOC"),
+ DCAE_INVENTORY_BLUEPRINT("DCAE_INVENTORY_BLUEPRINT"), DCAE_INVENTORY_EVENT("DCAE_INVENTORY_EVENT"),
+ //AAI Artifacts
+ AAI_SERVICE_MODEL("AAI_SERVICE_MODEL"), AAI_VF_MODEL("AAI_VF_MODEL"), AAI_VF_MODULE_MODEL("AAI_VF_MODULE_MODEL"),
+ AAI_VF_INSTANCE_MODEL("AAI_VF_INSTANCE_MODEL")
+
+ ;
+
+ ArtifactTypeEnum(String type) {
+ this.type = type;
+ }
+
+ private String type;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public static ArtifactTypeEnum findType(final String type) {
+ for (ArtifactTypeEnum ate : ArtifactTypeEnum.values()) {
+ //According to Pavel/Ella
+ if (ate.getType().equalsIgnoreCase(type)) {
+ return ate;
+ }
+ }
+ return null;
+ }
+
+ public static List<String> getAllTypes() {
+ List<String> types = new ArrayList<String>();
+ for (ArtifactTypeEnum ate : ArtifactTypeEnum.values()) {
+ types.add(ate.getType());
+ }
+ return types;
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/BasicConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/BasicConfiguration.java
new file mode 100644
index 0000000000..5152b2af26
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/BasicConfiguration.java
@@ -0,0 +1,25 @@
+/*-
+ * ============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.common.api;
+
+public class BasicConfiguration {
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ConfigurationListener.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ConfigurationListener.java
new file mode 100644
index 0000000000..d60ed6dabc
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ConfigurationListener.java
@@ -0,0 +1,50 @@
+/*-
+ * ============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.common.api;
+
+public class ConfigurationListener {
+
+ private Class<? extends BasicConfiguration> type;
+ private FileChangeCallback callBack;
+
+ public ConfigurationListener(Class<? extends BasicConfiguration> type, FileChangeCallback callBack) {
+ super();
+ this.type = type;
+ this.callBack = callBack;
+ }
+
+ public Class<? extends BasicConfiguration> getType() {
+ return type;
+ }
+
+ public void setType(Class<? extends BasicConfiguration> type) {
+ this.type = type;
+ }
+
+ public FileChangeCallback getCallBack() {
+ return callBack;
+ }
+
+ public void setCallBack(FileChangeCallback callBack) {
+ this.callBack = callBack;
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ConfigurationSource.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ConfigurationSource.java
new file mode 100644
index 0000000000..5901d1e267
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ConfigurationSource.java
@@ -0,0 +1,28 @@
+/*-
+ * ============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.common.api;
+
+public interface ConfigurationSource {
+
+ public <T> T getAndWatchConfiguration(Class<T> className, ConfigurationListener configurationListener);
+
+ public <T> void addWatchConfiguration(Class<T> className, ConfigurationListener configurationListener);
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/Constants.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/Constants.java
new file mode 100644
index 0000000000..673060cb0d
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/Constants.java
@@ -0,0 +1,126 @@
+/*-
+ * ============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.common.api;
+
+public interface Constants {
+
+ public static final String APPLICATION_NAME = "application-name";
+ public static final String APPLICATION_VERSION = "application-version";
+ public static final String CONFIG_HOME = "config.home";
+ public static final String LOG_HOME = "log.home";
+ public static final String YAML_SUFFIX = ".yaml";
+ public static final String CONFIGURATION_SOURCE_ATTR = "configuration-source";
+ public static final String MDC_APP_NAME = "APP_NAME";
+ public static final String CONFIGURATION_MANAGER_ATTR = "configuration-manager";
+ public static final String HEALTH_CHECK_SERVICE_ATTR = "healthCheckService";
+ public static final String REST_CLIENT_ATTR = "rest-client";
+ public static final String ARTIFACT_DAO_ATTR = "artifact-dao";
+ public static final String UPLOAD_VALIDATORR_ATTR = "upload-validator";
+ public static final String THREAD_EXECUTOR_ATTR = "thread-executor";
+ public static final String ERROR_LOG_FORMAT = "EVENT = ARTIFACT_UPLOAD USER_ID=%s USER_NAME=%s ACCESS_IP=%s ACCESS_TYPE=%s RURL=%s SC=%d";
+ public static final String FIRST_NAME_HEADER = "HTTP_CSP_FIRSTNAME";
+ public static final String LAST_NAME_HEADER = "HTTP_CSP_LASTNAME";
+ public static final String USER_ID_HEADER = "USER_ID";
+ public static final String MD5_HEADER = "Content-MD5";
+ public static final String CONTENT_DISPOSITION_HEADER = "Content-Disposition";
+ public static final String CONTENT_TYPE_HEADER = "Content-Type";
+ public static final String ORIGIN_HEADER = "HTTP_IV_REMOTE_ADDRESS";
+ public static final String ACCESS_HEADER = "HTTP_CSP_WSTYPE";
+ public static final String X_ECOMP_REQUEST_ID_HEADER = "X-ECOMP-RequestID";
+ public static final String X_ECOMP_INSTANCE_ID_HEADER = "X-ECOMP-InstanceID";
+ public static final String X_ECOMP_SERVICE_ID_HEADER = "X-ECOMP-ServiceID";
+ public static final String HTTP = "http";
+ public static final String HTTPS = "https";
+ public static final String HTTP_IV_USER = "HTTP_IV_USER";
+ public static final String A4C_CSAR_CONTEXT = "/rest/csars/";
+ public static final String WEB_APPLICATION_CONTEXT_WRAPPER_ATTR = "web-application-context-wrapper";
+ public static final String CATALOG_BE = "catalog-be";
+ public static final String HTTP_CSP_FIRSTNAME = "HTTP_CSP_FIRSTNAME";
+ public static final String HTTP_CSP_LASTNAME = "HTTP_CSP_LASTNAME";
+ public static final String HTTP_IV_REMOTE_ADDRESS = "HTTP_IV_REMOTE_ADDRESS";
+ public static final String HTTP_CSP_TYPE = "HTTP_CSP_WSTYPE";
+ public static final String RESOURCE_SUPPORTED_VERSION = "0.0.1";
+ public static final String ARTIFACT_ID_FORMAT = "%s:%s:%s"; // resourceName:resourceVersion:artifactName
+ public static final String SERVICE_ARTIFACT_ID_FORMAT = "%s:%s:%s:%s"; // serviceName:serviceVersion:nodeTemplateName:artifactName
+ public static final String CONTENT_DISPOSITION = "content-disposition";
+ public static final String DOWNLOAD_ARTIFACT_LOGIC_ATTR = "downloadArtifactLogic";
+ public static final String SDC_RELEASE_VERSION_ATTR = "SDC-Version";
+ // public static final String AUDITING_MANAGER = "auditingManager";
+ // public static final String USER_ADMIN_MANAGER = "userAdminManager";
+ public static final String YEAR = "year";
+ public static final String MONTH = "month";
+ public static final String DAY = "day";
+ public static final String HOUR = "hour";
+ public static final String MINUTE = "minute";
+ public static final String NONE = "none";
+ public static final String RESOURCE_OPERATION_MANAGER = "resourceOperationManager";
+ public static final String PROPERTY_OPERATION_MANAGER = "propertyOperationManager";
+ public static final String SERVICE_OPERATION_MANAGER = "serviceOperationManager";
+ public static final String EMPTY_STRING = "";
+ public static final String NULL_STRING = "null";
+ public static final String DOUBLE_NULL_STRING = "null null";
+ public static final String ECOMP_ERROR_MNGR_ATTR = "ecompErrorMngrAttr";
+ public static final String AUTHORIZATION_HEADER = "Authorization";
+ public static final String ACCEPT_HEADER = "Accept";
+ public static final String STANDARD_INTERFACE_TYPE = "standard";
+ public static final String MURANO_PKG_ARTIFACT_TYPE = "MURANO-PKG";
+ public static final String ARTIFACT_GROUP_TYPE_FIELD = "artifactGroupType";
+
+ // TOSCA
+ public static final String TOSCA_META_PATH = "TOSCA-Metadata/TOSCA.meta";
+ public static final String TOSCA_META_ENTRY_DEFINITIONS = "Entry-Definitions";
+ public static final String USER_DEFINED_RESOURCE_NAMESPACE_PREFIX = "org.openecomp.resource.";
+
+ public static final String IS_BASE = "isBase";
+ public static final String HEAT_FILE_PROPS = "heat_file";
+ public static final String MODULE_NAME_FORMAT = "%s..%s..module-%s";
+ public static final String MODULE_DESC_PATTERN = "[\\_\\-\\.a-zA-Z0-9]+";
+ public static final String MODULE_OLD_NAME_PATTERN = "([\\w\\_\\-\\.\\s]+)(::module-)(\\d+)";
+ public static final String MODULE_NEW_NAME_PATTERN = "([\\w\\_\\-\\.\\s]+\\.\\.)([\\_\\-\\.a-zA-Z0-9]+)(..module-)(\\d+)";
+ public static final String MODULE_NAME_DELIMITER = "module-";
+ public static final String IMPORT_STRUCTURE = "importStructure";
+ public static final String DEFAULT_GROUP_VF_MODULE = "org.openecomp.groups.VfModule";
+
+ public static final String ARTIFACT_GROUP_TYPE = "artifactGroupType";
+ public static final String ARTIFACT_LABEL = "artifactLabel";
+ public static final String ARTIFACT_PAYLOAD_DATA = "payloadData";
+ public static final String ARTIFACT_DISPLAY_NAME = "artifactDisplayName";
+ public static final String ARTIFACT_DESCRIPTION = "description";
+ public static final String ARTIFACT_TYPE = "artifactType";
+ public static final String ARTIFACT_NAME = "artifactName";
+ public static final String ARTIFACT_ID = "uniqueId";
+ public static final String REQUIRED_ARTIFACTS = "requiredArtifacts";
+
+ public static final String ABSTRACT = "abstract";
+ public static final String GLOBAL_SUBSTITUTION_TYPE_SERVICE_TEMPLATE = "Definitions/GlobalSubstitutionTypesServiceTemplate.yaml";
+
+ public static final String VENDOR_LICENSE_MODEL = "vendor-license-model.xml";
+ public static final String VENDOR_LICENSE_LABEL = "vendorlicense";
+ public static final String VENDOR_LICENSE_DISPLAY_NAME = "Vendor License";
+ public static final String VENDOR_LICENSE_DESCRIPTION = " Vendor license file";
+
+ public static final String VF_LICENSE_MODEL = "vf-license-model.xml";
+ public static final String VF_LICENSE_LABEL = "vflicense";
+ public static final String VF_LICENSE_DISPLAY_NAME = "VF License";
+ public static final String VF_LICENSE_DESCRIPTION = "VF license file";
+ public static final String ARTIFACTS = "Artifacts/";
+ public static final String GET_INPUT = "get_input";
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/FileChangeCallback.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/FileChangeCallback.java
new file mode 100644
index 0000000000..5c4d3d5926
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/FileChangeCallback.java
@@ -0,0 +1,27 @@
+/*-
+ * ============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.common.api;
+
+public interface FileChangeCallback {
+
+ public void reconfigure(BasicConfiguration obj);
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckInfo.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckInfo.java
new file mode 100644
index 0000000000..653b8b0866
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckInfo.java
@@ -0,0 +1,76 @@
+/*-
+ * ============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.common.api;
+
+public class HealthCheckInfo {
+
+ private HealthCheckComponent healthCheckComponent;
+ private HealthCheckStatus healthCheckStatus;
+ private String version;
+ private String description;
+
+ public HealthCheckInfo(HealthCheckComponent healthCheckComponent, HealthCheckStatus healthCheckStatus,
+ String version, String description) {
+ super();
+ this.healthCheckComponent = healthCheckComponent;
+ this.healthCheckStatus = healthCheckStatus;
+ this.version = version;
+ this.description = description;
+ }
+
+ public HealthCheckInfo() {
+ super();
+ }
+
+ public HealthCheckComponent getHealthCheckComponent() {
+ return healthCheckComponent;
+ }
+
+ public HealthCheckStatus getHealthCheckStatus() {
+ return healthCheckStatus;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public enum HealthCheckComponent {
+ FE, BE, TITAN, ES, DE;
+ }
+
+ public enum HealthCheckStatus {
+ UP, DOWN, UNKNOWN;
+ }
+
+ @Override
+ public String toString() {
+ return "HealthCheckInfo [healthCheckComponent=" + healthCheckComponent + ", healthCheckStatus="
+ + healthCheckStatus + ", version=" + version + ", description=" + description + "]";
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckWrapper.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckWrapper.java
new file mode 100644
index 0000000000..29c6350516
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckWrapper.java
@@ -0,0 +1,62 @@
+/*-
+ * ============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.common.api;
+
+import java.util.List;
+
+public class HealthCheckWrapper {
+
+ String sdcVersion;
+ String siteMode;
+ List<HealthCheckInfo> componentsInfo;
+
+ public HealthCheckWrapper(List<HealthCheckInfo> componentsInfo, String sdcVersion, String siteMode) {
+ super();
+ this.componentsInfo = componentsInfo;
+ this.sdcVersion = sdcVersion;
+ this.siteMode = siteMode;
+ }
+
+ public List<HealthCheckInfo> getComponentsInfo() {
+ return componentsInfo;
+ }
+
+ public void setComponentsInfo(List<HealthCheckInfo> componentsInfo) {
+ this.componentsInfo = componentsInfo;
+ }
+
+ public String getSdcVersion() {
+ return sdcVersion;
+ }
+
+ public void setSdcVersion(String sdcVersion) {
+ this.sdcVersion = sdcVersion;
+ }
+
+ public String getSiteMode() {
+ return siteMode;
+ }
+
+ public void setSiteMode(String siteMode) {
+ this.siteMode = siteMode;
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ResourceType.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ResourceType.java
new file mode 100644
index 0000000000..b93fed2e0c
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ResourceType.java
@@ -0,0 +1,25 @@
+/*-
+ * ============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.common.api;
+
+public enum ResourceType {
+ RESOURCE, SERVICE
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ResponseInfo.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ResponseInfo.java
new file mode 100644
index 0000000000..337d5d1b8a
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ResponseInfo.java
@@ -0,0 +1,84 @@
+/*-
+ * ============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.common.api;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class ResponseInfo {
+
+ public static enum ResponseStatusEnum {
+ SUCCESS("success"),
+ LOGIN_FAILED("loginFailed"),
+ INTERNAL_ERROR("internalError"),
+ MISSING_HEADERS("required headers are missing"),
+ TIMEOUT("timeout"),
+ PARSING_ERROR("parsingFailed");
+
+ ResponseStatusEnum(String status) {
+ this.statusDescription = status;
+ }
+
+ public String statusDescription;
+ }
+
+ private ResponseStatusEnum applicativeStatus;
+ private String description;
+
+ public ResponseInfo(ResponseStatusEnum applicativeStatus, String description) {
+ super();
+ this.applicativeStatus = applicativeStatus;
+ this.description = description;
+ }
+
+ public ResponseInfo(ResponseStatusEnum applicativeStatus) {
+ super();
+ this.applicativeStatus = applicativeStatus;
+ }
+
+ public ResponseStatusEnum getApplicativeStatus() {
+ return applicativeStatus;
+ }
+
+ public void setApplicativeStatus(ResponseStatusEnum applicativeStatus) {
+ this.applicativeStatus = applicativeStatus;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ @Override
+ public String toString() {
+ ObjectMapper mapper = new ObjectMapper();
+ String tostring = super.toString();
+ try {
+ tostring = mapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+
+ }
+ return tostring;
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ToscaNodeTypeInfo.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ToscaNodeTypeInfo.java
new file mode 100644
index 0000000000..f6608952d0
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ToscaNodeTypeInfo.java
@@ -0,0 +1,79 @@
+/*-
+ * ============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.common.api;
+
+import java.util.List;
+
+public class ToscaNodeTypeInfo {
+
+ private String nodeName;
+ private String templateVersion;
+ private List<ToscaNodeTypeInterface> interfaces;
+ private String iconPath;
+ private String templateName;
+
+ public String getTemplateName() {
+ return templateName;
+ }
+
+ public void setTemplateName(String templateName) {
+ this.templateName = templateName;
+ }
+
+ public String getNodeName() {
+ return nodeName;
+ }
+
+ public void setNodeName(String nodeName) {
+ this.nodeName = nodeName;
+ }
+
+ public String getTemplateVersion() {
+ return templateVersion;
+ }
+
+ public void setTemplateVersion(String templateVersion) {
+ this.templateVersion = templateVersion;
+ }
+
+ public List<ToscaNodeTypeInterface> getInterfaces() {
+ return interfaces;
+ }
+
+ public void setInterfaces(List<ToscaNodeTypeInterface> interfaces) {
+ this.interfaces = interfaces;
+ }
+
+ public String getIconPath() {
+ return iconPath;
+ }
+
+ public void setIconPath(String iconPath) {
+ this.iconPath = iconPath;
+ }
+
+ @Override
+ public String toString() {
+ return "ToscaNodeTypeInfo [nodeName=" + nodeName + ", templateVersion=" + templateVersion + ", templateName="
+ + templateName + ", interfaces=" + interfaces + ", iconPath=" + iconPath + "]";
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ToscaNodeTypeInterface.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ToscaNodeTypeInterface.java
new file mode 100644
index 0000000000..4095714f4b
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ToscaNodeTypeInterface.java
@@ -0,0 +1,37 @@
+/*-
+ * ============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.common.api;
+
+import java.util.List;
+
+public class ToscaNodeTypeInterface {
+
+ List<String> scripts;
+
+ public List<String> getScripts() {
+ return scripts;
+ }
+
+ public void setScripts(List<String> scripts) {
+ this.scripts = scripts;
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/UploadArtifactInfo.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/UploadArtifactInfo.java
new file mode 100644
index 0000000000..9e1734135c
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/UploadArtifactInfo.java
@@ -0,0 +1,147 @@
+/*-
+ * ============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.common.api;
+
+public class UploadArtifactInfo {
+
+ public UploadArtifactInfo() {
+
+ }
+
+ public UploadArtifactInfo(String artifactName, String artifactPath, ArtifactTypeEnum artifactType,
+ String artifactDescription) {
+ super();
+ this.artifactName = artifactName;
+ this.artifactPath = artifactPath;
+ this.artifactType = artifactType;
+ this.artifactDescription = artifactDescription;
+ }
+
+ public UploadArtifactInfo(String artifactName, String artifactPath, ArtifactTypeEnum artifactType,
+ String artifactDescription, String artifactData) {
+ super();
+ this.artifactName = artifactName;
+ this.artifactPath = artifactPath;
+ this.artifactType = artifactType;
+ this.artifactDescription = artifactDescription;
+ this.artifactData = artifactData;
+ }
+
+ private String artifactName;
+ private String artifactPath;
+ private ArtifactTypeEnum artifactType;
+ private String artifactDescription;
+ private String artifactData;
+
+ public String getArtifactName() {
+ return artifactName;
+ }
+
+ public void setArtifactName(String artifactName) {
+ this.artifactName = artifactName;
+ }
+
+ public String getArtifactPath() {
+ return artifactPath;
+ }
+
+ public void setArtifactPath(String artifactPath) {
+ this.artifactPath = artifactPath;
+ }
+
+ public ArtifactTypeEnum getArtifactType() {
+ return artifactType;
+ }
+
+ public void setArtifactType(ArtifactTypeEnum artifactType) {
+ this.artifactType = artifactType;
+ }
+
+ public String getArtifactDescription() {
+ return artifactDescription;
+ }
+
+ public void setArtifactDescription(String artifactDescription) {
+ this.artifactDescription = artifactDescription;
+ }
+
+ public String getArtifactData() {
+ return artifactData;
+ }
+
+ public void setArtifactData(String artifactData) {
+ this.artifactData = artifactData;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((artifactData == null) ? 0 : artifactData.hashCode());
+ result = prime * result + ((artifactDescription == null) ? 0 : artifactDescription.hashCode());
+ result = prime * result + ((artifactName == null) ? 0 : artifactName.hashCode());
+ result = prime * result + ((artifactPath == null) ? 0 : artifactPath.hashCode());
+ result = prime * result + ((artifactType == null) ? 0 : artifactType.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ UploadArtifactInfo other = (UploadArtifactInfo) obj;
+ if (artifactData == null) {
+ if (other.artifactData != null)
+ return false;
+ } else if (!artifactData.equals(other.artifactData))
+ return false;
+ if (artifactDescription == null) {
+ if (other.artifactDescription != null)
+ return false;
+ } else if (!artifactDescription.equals(other.artifactDescription))
+ return false;
+ if (artifactName == null) {
+ if (other.artifactName != null)
+ return false;
+ } else if (!artifactName.equals(other.artifactName))
+ return false;
+ if (artifactPath == null) {
+ if (other.artifactPath != null)
+ return false;
+ } else if (!artifactPath.equals(other.artifactPath))
+ return false;
+ if (artifactType != other.artifactType)
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "UploadArtifactInfo [artifactName=" + artifactName + ", artifactPath=" + artifactPath + ", artifactType="
+ + artifactType + ", artifactDescription=" + artifactDescription + ", artifactData=" + artifactData
+ + "]";
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/UserRoleEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/UserRoleEnum.java
new file mode 100644
index 0000000000..6d333bf457
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/UserRoleEnum.java
@@ -0,0 +1,41 @@
+/*-
+ * ============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.common.api;
+
+public enum UserRoleEnum {
+ ADMIN("ADMIN"),
+ DESIGNER("DESIGNER"),
+ TESTER("TESTER"),
+ GOVERNOR("GOVERNOR"),
+ OPS("OPS"),
+ PRODUCT_MANAGER("PRODUCT_MANAGER"),
+ PRODUCT_STRATEGIST("PRODUCT_STRATEGIST");
+
+ private String name;
+
+ UserRoleEnum(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/YamlConstants.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/YamlConstants.java
new file mode 100644
index 0000000000..0dadef9292
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/YamlConstants.java
@@ -0,0 +1,29 @@
+/*-
+ * ============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.common.api;
+
+public interface YamlConstants {
+
+ public static final String NODE_TYPES = "node_types";
+ public static final String INTERFACES = "interfaces";
+ public static final String TEMPLATE_VERSION = "template_version";
+ public static final String TEMPLATE_NAME = "template_name";
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/YamlSuffixEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/YamlSuffixEnum.java
new file mode 100644
index 0000000000..4ac6290940
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/YamlSuffixEnum.java
@@ -0,0 +1,60 @@
+/*-
+ * ============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.common.api;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public enum YamlSuffixEnum {
+
+ YAML("YAML"),
+
+ yaml("yaml"),
+
+ YML("YML"),
+
+ yml("yml");
+
+ YamlSuffixEnum(String suffix) {
+ this.suffix = suffix;
+ }
+
+ private String suffix;
+
+ public String getSuffix() {
+ return suffix;
+ }
+
+ public void setSuufix(String suffix) {
+ this.suffix = suffix;
+ }
+
+ public static List<String> getSuffixes() {
+
+ List<String> arrayList = new ArrayList<String>();
+
+ for (YamlSuffixEnum yamlSuffixEnum : YamlSuffixEnum.values()) {
+ arrayList.add(yamlSuffixEnum.getSuffix());
+ }
+
+ return arrayList;
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/AbsEcompErrorManager.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/AbsEcompErrorManager.java
new file mode 100644
index 0000000000..6a54071f42
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/AbsEcompErrorManager.java
@@ -0,0 +1,121 @@
+/*-
+ * ============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.common.config;
+
+import java.util.Formatter;
+import java.util.IllegalFormatException;
+import java.util.Locale;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.sdc.common.config.EcompErrorConfiguration.EcompAlarmSeverity;
+import org.openecomp.sdc.common.config.EcompErrorConfiguration.EcompErrorSeverity;
+import org.openecomp.sdc.common.config.EcompErrorConfiguration.EcompErrorType;
+
+import com.jcabi.aspects.Loggable;
+
+@Loggable(prepend = true, value = Loggable.TRACE, trim = false)
+public abstract class AbsEcompErrorManager implements IEcompErrorManager {
+
+ public static final String PARAM_STR = "%s";
+
+ public abstract IEcompConfigurationManager getConfigurationManager();
+
+ @Deprecated
+ @Override
+ public void processEcompError(EcompErrorName ecompErrorName, String ecompErrorContext,
+ String... descriptionParams) {
+
+ /*
+ * //Getting the relevant config manager IEcompConfigurationManager
+ * configurationManager = getConfigurationManager();
+ *
+ * //Getting the error by name EcompErrorInfo ecompErrorInfo =
+ * configurationManager.getEcompErrorConfiguration().getEcompErrorInfo(
+ * ecompErrorName.name());
+ *
+ * if (ecompErrorInfo != null){ ecompErrorInfo =
+ * setDescriptionParams(ecompErrorInfo, ecompErrorName.name(),
+ * descriptionParams); EcompErrorLogUtil.logEcompError(ecompErrorName,
+ * ecompErrorInfo, ecompErrorContext); } else {
+ * EcompErrorLogUtil.logEcompError(EcompErrorName.EcompErrorNotFound,
+ * getErrorInfoForUnknownErrorName(ecompErrorName.name()),
+ * ecompErrorContext); }
+ */
+
+ }
+
+ private EcompErrorInfo setDescriptionParams(EcompErrorInfo ecompErrorInfo, String ecompErrorName,
+ String... descriptionParams) {
+ String description = ecompErrorInfo.getDescription();
+ // Counting number of params in description
+ int countMatches = StringUtils.countMatches(description, PARAM_STR);
+ // Catching cases when there are more params passed than there are in
+ // the description (formatter will ignore extra params and won't throw
+ // exception)
+ if (countMatches != descriptionParams.length) {
+ return getErrorInfoForDescriptionParamsMismatch(ecompErrorName);
+ }
+ // Setting params of the description if any
+ StringBuilder sb = new StringBuilder();
+ Formatter formatter = new Formatter(sb, Locale.US);
+ try {
+ formatter.format(description, (Object[]) descriptionParams).toString();
+ ecompErrorInfo.setDescription(formatter.toString());
+ } catch (IllegalFormatException e) {
+ // Number of passed params doesn't match number of params in config
+ // file
+ return getErrorInfoForDescriptionParamsMismatch(ecompErrorName);
+ } finally {
+ formatter.close();
+ }
+ return ecompErrorInfo;
+ }
+
+ private EcompErrorInfo getErrorInfoForUnknownErrorName(String ecompErrorName) {
+ EcompErrorInfo ecompErrorInfo = new EcompErrorInfo();
+ ecompErrorInfo.setCode(EcompErrorConfiguration.ECODE_PREFIX + "3001");
+ ecompErrorInfo.setType(EcompErrorType.CONFIG_ERROR.name());
+ ecompErrorInfo.setSeverity(EcompErrorSeverity.ERROR.name());
+ ecompErrorInfo.setAlarmSeverity(EcompAlarmSeverity.MAJOR.name());
+ ecompErrorInfo.setDescription(new StringBuilder().append("Ecomp error element not found in YAML, name: ")
+ .append(ecompErrorName).toString());
+ return ecompErrorInfo;
+ }
+
+ private EcompErrorInfo getErrorInfoForDescriptionParamsMismatch(String ecompErrorName) {
+ EcompErrorInfo ecompErrorInfo = new EcompErrorInfo();
+ ecompErrorInfo.setCode(EcompErrorConfiguration.ECODE_PREFIX + "3002");
+ ecompErrorInfo.setType(EcompErrorType.CONFIG_ERROR.name());
+ ecompErrorInfo.setSeverity(EcompErrorSeverity.ERROR.name());
+ ecompErrorInfo.setAlarmSeverity(EcompAlarmSeverity.MAJOR.name());
+ ecompErrorInfo.setDescription(new StringBuilder()
+ .append("Ecomp error description params mismatch between code and YAML or wrong format, name: ")
+ .append(ecompErrorName).toString());
+ return ecompErrorInfo;
+ }
+
+ public void processEcompError(String context, EcompErrorEnum ecompErrorEnum, String... descriptionParams) {
+
+ EcompErrorLogUtil.logEcompError(context, ecompErrorEnum, descriptionParams);
+
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompClassification.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompClassification.java
new file mode 100644
index 0000000000..31499486de
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompClassification.java
@@ -0,0 +1,41 @@
+/*-
+ * ============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.common.config;
+
+public enum EcompClassification {
+
+ INFORMATION("I"), WARNING("W"), ERROR("E"), FATAL("F");
+
+ String classification;
+
+ EcompClassification(String classification) {
+ this.classification = classification;
+ }
+
+ public String getClassification() {
+ return classification;
+ }
+
+ public void setClassification(String classification) {
+ this.classification = classification;
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorCode.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorCode.java
new file mode 100644
index 0000000000..0f45d34886
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorCode.java
@@ -0,0 +1,155 @@
+/*-
+ * ============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.common.config;
+
+public enum EcompErrorCode {
+
+ E_100("Authentication problem towards U-EB server. Reason: %s",
+ "An Authentication failure occured during access to UEB server. Please check that UEB keys are configured correctly in ASDC BE distribution configuration."), E_199(
+ "Internal authentication problem. Description: %s"),
+
+ E_200("ASDC Backend probably lost connectivity to either one of the following components: Titan DB, Elasticsearch, UEB Cluster. Please check the logs for more information."), E_201(
+ "ASDC Backend probably lost connectivity to Titan DB. Please check the logs for more information."), E_202(
+ "ASDC Backend probably lost connectivity to ElasticSearch. Please check the logs for more information."), E_203(
+ "ASDC Backend probably lost connectivity to UEB Cluster. Please check the logs for more information.",
+ "Check connectivity to UEB cluster which is configured under parameter uebServers in distribution-configuration.yaml."), E_204(
+ "Unable to connect to a valid ASDC Backend Server",
+ "Please check connectivity from this FE instance towards BE or BE Load Balancer. Please check that parameters in FE configuration.yaml: beHost, beHttpPort and beSslPort point to a valid host and port values."),
+
+ E_205("ASDC Backend Recovery to either one of the following components: Titan DB, Elasticsearch, UEB Cluster."), E_206(
+ "ASDC Backend connection recovery to Titan DB."), E_207(
+ "ASDC Backend connection recovery to ElasticSearch."), E_208(
+ "ASDC Backend connection recovery to UEB Cluster."), E_209(
+ "Connectivity to ASDC BE Server is recovered."), E_210(
+ "Connection problem towards U-EB server. Reason: %s",
+ "Please check that that parameter uebServers in distribution-configuration.yaml points to a valid UEB Cluster."), E_211(
+ "Connection problem towards U-EB server. Cannot reach host %s",
+ "Please check that that parameter uebServers in distribution-configuration.yaml points to a valid UEB Cluster."), E_212(
+ "Couldn't resolve hostIP. Desciption: %s"), E_213(
+ "Site switch over was done. Site is now in %s mode"), E_299(
+ "Internal Connection problem. Description: %s"),
+
+ // [resource/service/product]
+ E_300("Mandatory %s Component %s cannot be found in repository"),
+ // [SERVICE/RESOURCE/PRODUCT] [id] is not valid. Cannot be found in graph.
+ E_301("%s Component %s is not valid. Cannot be found in graph."), E_302(
+ "Configuration parameter %s is invalid. Value configured is %s."), E_303(
+ "Error occured during access to U-EB Server. Data not found: %s",
+ "An error occured during access to UEB Server, ASDC failed to either register or unregister to/from UEB topic."), E_304(
+ "The artifact type %s does not appear in the list of valid artifacts %s"), E_305(
+ "Configuration parameter %s is missing"), E_306(
+ "Configuration parameter %s is invalid. At least %s values shall be configured"), E_307(
+ "Invalid configuration in YAML file. %s"), E_308(
+ "Artifact uploaded has missing information. Missing %s"), E_309(
+ "Artifact %s requested is not found"), E_310(
+ "User %s requested is not found"), E_311(
+ "Ecomp error description params mismatch between code and YAML or wrong format, name: %s"), E_312(
+ "Ecomp error element not found in YAML, name: %s"),
+
+ E_399("Internal Invalid Object. Description: %s"),
+
+ E_400("The type %s of %s is invalid"), E_401("The value %s of %s from type %s is invalid"), E_402(
+ "Payload of artifact uploaded is invalid (invalid MD5 or encryption)"), E_403(
+ "Input for artifact metadata is invalid"), E_404("%s %s required is missing"), E_405(
+ "Failed to convert json input to object"), E_406("Distribution %s required is missing"),
+
+ E_499("Invalid input. Description: %s"),
+
+ E_500("Catalog-BE was not initialized properly"), E_501(
+ "Failed to add resource instance of resource %s to service %s"), E_502(
+ "Error occured during access to U-EB Server. Operation: %s",
+ "An error occured in ASDC distribution mechanism. Please check the logs for more information."), E_503(
+ "Error occured in Distribution Engine. Failed operation: %s",
+ "System Error occured in ASDC Distribution Engine. Please check ASDC logs for more details."), E_504(
+ "Failed adding node of type %s to graph."), E_505(
+ "Operation towards database failed.",
+ "Please check Titan DB health or look at the logs for more details."), E_506(
+ "Unexpected error during operation"), E_507(
+ "Going to execute rollback on graph."), E_508(
+ "Failed to lock object for update. Type = %s, Id = %s"), E_509(
+ "Failed to create node %s on graph. status is %s"), E_510(
+ "Failed to update node %s on graph. Status is %s"), E_511(
+ "Failed to delete node %s on graph. Status is %s"), E_512(
+ "Failed to retrieve node %s from graph. Status is %s"), E_513(
+ "Failed to find parent node of %s on graph. Status is %s"), E_514(
+ "Failed to fetch all nodes with type %s of parent node %s . Status is %s"), E_515(
+ "Cannot find node with type %s associated with node %s . Status is %s"), E_516(
+ "Error occured in Component Cleaner Task. Failed operation: %s"), E_517(
+ "Error when logging FE HTTP request/response"), E_518(
+ "Error when trying to access FE Portal page"),
+
+ E_599("Internal flow error. Operation: %s"),
+
+ E_900("Unexpected error during BE REST API execution"), E_901("General error during FE Health Check"), E_999(
+ "Unexpected error. Description: %s");
+
+ /*
+ * 100-199 Security/Permission Related - Authentication problems (from
+ * external client, to external server) - Certification errors -
+ *
+ * 200-299 Availability/Timeout Related - connectivity error - connection
+ * timeout
+ *
+ * 300-399 Data Access/Integrity Related - Data in graph in invalid(E.g. no
+ * creator is found for service) - Artifact is missing in ES, but exists in
+ * graph.
+ *
+ * 400-499 Schema Interface Type/Validation - received payload checksum is
+ * inavlid - received json is not valid
+ *
+ * 500-599 Business/Flow Processing Related - check out to service is not
+ * allowed - rollback is done - failed to generate heat file
+ *
+ *
+ * 600-899 Reserved – do not use
+ *
+ * 900-999 Unknown Errors - unexpected exception
+ */
+
+ String description;
+ String resolution;
+
+ EcompErrorCode(String description, String resolution) {
+ this.description = description;
+ this.resolution = resolution;
+ }
+
+ EcompErrorCode(String description) {
+ this.description = description;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getResolution() {
+ return resolution;
+ }
+
+ public void setResolution(String resolution) {
+ this.resolution = resolution;
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorConfiguration.java
new file mode 100644
index 0000000000..368104dea1
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorConfiguration.java
@@ -0,0 +1,161 @@
+/*-
+ * ============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.common.config;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import org.openecomp.sdc.common.api.BasicConfiguration;
+
+public class EcompErrorConfiguration extends BasicConfiguration {
+
+ private Map<String, EcompErrorInfo> errors = new HashMap<>();
+ static final String ECODE_PREFIX = "ASDC_";
+ private static final Pattern ECODE_PATTERN = Pattern.compile("^" + ECODE_PREFIX + "\\d{4}$");
+
+ public Map<String, EcompErrorInfo> getErrors() {
+ return errors;
+ }
+
+ public void setErrors(Map<String, EcompErrorInfo> errors) {
+ // Validating ecomp-error-configuration.yaml
+ for (Map.Entry<String, EcompErrorInfo> ecompErrorInfo : errors.entrySet()) {
+ String ecompErrorName = ecompErrorInfo.getKey();
+ EcompErrorInfo res = validateEcompErrorInfo(ecompErrorName, ecompErrorInfo.getValue());
+ if (res != null) {
+ // Validation failed!
+ EcompErrorLogUtil.logEcompError(EcompErrorName.EcompConfigFileFormat, res, this.getClass().getName());
+ return;
+ }
+ }
+ // Validation passed
+ this.errors = errors;
+ }
+
+ public EcompErrorInfo getEcompErrorInfo(String key) {
+ EcompErrorInfo clone = null;
+ EcompErrorInfo other = errors.get(key);
+ if (other != null) {
+ clone = new EcompErrorInfo();
+ clone.cloneData(other);
+ }
+ return clone;
+ }
+
+ protected EcompErrorInfo validateEcompErrorInfo(String ecompErrorName, EcompErrorInfo ecompErrorInfoToValidate) {
+ if (ecompErrorInfoToValidate == null) {
+ return getErrorInfoForConfigFile("error " + ecompErrorName + " not found ");
+ }
+ String type = ecompErrorInfoToValidate.getType();
+ if (type == null) {
+ return getErrorInfoForConfigFile("empty error type for error " + ecompErrorName
+ + ", value should be one of the following: " + Arrays.asList(EcompErrorType.values()));
+ }
+ try {
+ EcompErrorType.valueOf(type);
+ } catch (IllegalArgumentException e) {
+ return getErrorInfoForConfigFile("error type " + type + " is invalid for error " + ecompErrorName
+ + ", value should be one of the following: " + Arrays.asList(EcompErrorType.values()));
+ }
+
+ String severity = ecompErrorInfoToValidate.getSeverity();
+ if (severity == null) {
+ return getErrorInfoForConfigFile("empty error severity for error " + ecompErrorName
+ + ", value should be one of the following: " + Arrays.asList(EcompErrorSeverity.values()));
+ }
+ try {
+ EcompErrorSeverity.valueOf(severity);
+ } catch (IllegalArgumentException e) {
+ return getErrorInfoForConfigFile("error severity " + severity + " is invalid for error " + ecompErrorName
+ + ", value should be one of the following: " + Arrays.asList(EcompErrorSeverity.values()));
+ }
+ String alarmSeverity = ecompErrorInfoToValidate.getAlarmSeverity();
+ if (alarmSeverity == null) {
+ return getErrorInfoForConfigFile("empty error alarm for error " + ecompErrorName
+ + ", , value should be one of the following: " + Arrays.asList(EcompAlarmSeverity.values()));
+ }
+ try {
+ EcompAlarmSeverity.valueOf(alarmSeverity);
+ } catch (IllegalArgumentException e) {
+ return getErrorInfoForConfigFile("error alarm severity " + alarmSeverity + " is invalid for error "
+ + ecompErrorName + ", , value should be one of the following: "
+ + Arrays.asList(EcompAlarmSeverity.values()));
+ }
+
+ String code = ecompErrorInfoToValidate.getCode();
+ if (code != null && ECODE_PATTERN.matcher(code).matches()) {
+ String[] split = code.split("_");
+ int parseInt = Integer.parseInt(split[1]);
+ if (parseInt < 3010 || parseInt > 9999) {
+ return getErrorInfoForInvalidCode(code, ecompErrorName);
+ }
+ } else {
+ return getErrorInfoForInvalidCode(code, ecompErrorName);
+ }
+ return null;
+ }
+
+ private EcompErrorInfo getErrorInfoForInvalidCode(String code, String ecompErrorName) {
+ return getErrorInfoForConfigFile("error code " + code + " is invalid for error " + ecompErrorName
+ + ", should be in format ASDC_[3010-9999]");
+ }
+
+ private EcompErrorInfo getErrorInfoForConfigFile(String errorMessage) {
+ EcompErrorInfo ecompErrorInfo = new EcompErrorInfo();
+ ecompErrorInfo.setCode(ECODE_PREFIX + "3000");
+ ecompErrorInfo.setType(EcompErrorType.CONFIG_ERROR.name());
+ ecompErrorInfo.setSeverity(EcompErrorSeverity.FATAL.name());
+ ecompErrorInfo.setAlarmSeverity(EcompAlarmSeverity.CRITICAL.name());
+ ecompErrorInfo.setDescription(errorMessage);
+ return ecompErrorInfo;
+ }
+
+ @Override
+ public String toString() {
+ return "EcompErrorConfiguration [errors=" + errors + "]";
+ }
+
+ /*******************************
+ * Enums
+ */
+
+ public enum EcompErrorType {
+ RECOVERY, CONFIG_ERROR, SYSTEM_ERROR, DATA_ERROR, CONNECTION_PROBLEM, AUTHENTICATION_PROBLEM;
+ }
+
+ public enum EcompAlarmSeverity {
+ CRITICAL, MAJOR, MINOR, INFORMATIONAL, NONE;
+ }
+
+ public enum EcompErrorSeverity {
+ INFO, WARN, ERROR, FATAL;
+ }
+
+ public enum EcompErrorSeverityPrefix {
+ I, W, E, F;
+ }
+
+ public static void main(String[] args) {
+ System.out.println(Arrays.asList(EcompErrorType.values()));
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorEnum.java
new file mode 100644
index 0000000000..c79677a9ef
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorEnum.java
@@ -0,0 +1,484 @@
+/*-
+ * ============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.common.config;
+
+public enum EcompErrorEnum {
+
+ BeUebAuthenticationError(EcompErrorCode.E_100, ErrorType.AUTHENTICATION_PROBLEM, AlarmSeverity.MAJOR,
+ EcompClassification.ERROR),
+
+ InternalAuthenticationInfo(EcompErrorCode.E_199, ErrorType.AUTHENTICATION_PROBLEM, AlarmSeverity.INFORMATIONAL,
+ EcompClassification.INFORMATION), InternalAuthenticationWarning(EcompErrorCode.E_199,
+ ErrorType.AUTHENTICATION_PROBLEM, AlarmSeverity.MINOR,
+ EcompClassification.WARNING), InternalAuthenticationError(EcompErrorCode.E_199,
+ ErrorType.AUTHENTICATION_PROBLEM, AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), InternalAuthenticationFatal(EcompErrorCode.E_199,
+ ErrorType.AUTHENTICATION_PROBLEM, AlarmSeverity.CRITICAL,
+ EcompClassification.FATAL),
+
+ BeHealthCheckRecovery(EcompErrorCode.E_205, ErrorType.RECOVERY, AlarmSeverity.INFORMATIONAL,
+ EcompClassification.INFORMATION, null), BeHealthCheckTitanRecovery(EcompErrorCode.E_206, ErrorType.RECOVERY,
+ AlarmSeverity.INFORMATIONAL, EcompClassification.INFORMATION,
+ null), BeHealthCheckElasticSearchRecovery(EcompErrorCode.E_207, ErrorType.RECOVERY,
+ AlarmSeverity.INFORMATIONAL, EcompClassification.INFORMATION,
+ null), BeHealthCheckUebClusterRecovery(EcompErrorCode.E_208, ErrorType.RECOVERY,
+ AlarmSeverity.INFORMATIONAL, EcompClassification.INFORMATION,
+ null), FeHealthCheckRecovery(EcompErrorCode.E_209, ErrorType.RECOVERY,
+ AlarmSeverity.INFORMATIONAL, EcompClassification.INFORMATION,
+ null), BeHealthCheckError(EcompErrorCode.E_200, ErrorType.SYSTEM_ERROR,
+ AlarmSeverity.CRITICAL, EcompClassification.ERROR,
+ BeHealthCheckRecovery),
+
+ BeHealthCheckTitanError(EcompErrorCode.E_201, ErrorType.SYSTEM_ERROR, AlarmSeverity.CRITICAL,
+ EcompClassification.ERROR, BeHealthCheckTitanRecovery), BeHealthCheckElasticSearchError(
+ EcompErrorCode.E_202, ErrorType.SYSTEM_ERROR, AlarmSeverity.CRITICAL, EcompClassification.ERROR,
+ BeHealthCheckElasticSearchRecovery), BeHealthCheckUebClusterError(EcompErrorCode.E_203,
+ ErrorType.SYSTEM_ERROR, AlarmSeverity.CRITICAL, EcompClassification.ERROR,
+ BeHealthCheckUebClusterRecovery), FeHealthCheckError(EcompErrorCode.E_204,
+ ErrorType.SYSTEM_ERROR, AlarmSeverity.CRITICAL, EcompClassification.ERROR,
+ FeHealthCheckRecovery), BeUebConnectionError(EcompErrorCode.E_210,
+ ErrorType.CONNECTION_PROBLEM, AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), BeUebUnkownHostError(EcompErrorCode.E_211,
+ ErrorType.CONNECTION_PROBLEM, AlarmSeverity.MAJOR,
+ EcompClassification.ERROR),
+
+ FqdnResolveError(EcompErrorCode.E_212, ErrorType.CONNECTION_PROBLEM, AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), SiteSwitchoverInfo(EcompErrorCode.E_213, ErrorType.RECOVERY,
+ AlarmSeverity.INFORMATIONAL, EcompClassification.INFORMATION),
+
+ InternalConnectionInfo(EcompErrorCode.E_299, ErrorType.CONNECTION_PROBLEM, AlarmSeverity.INFORMATIONAL,
+ EcompClassification.INFORMATION), InternalConnectionWarning(EcompErrorCode.E_299,
+ ErrorType.CONNECTION_PROBLEM, AlarmSeverity.MINOR,
+ EcompClassification.WARNING), InternalConnectionError(EcompErrorCode.E_299,
+ ErrorType.CONNECTION_PROBLEM, AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), InternalConnectionFatal(EcompErrorCode.E_299,
+ ErrorType.CONNECTION_PROBLEM, AlarmSeverity.CRITICAL, EcompClassification.FATAL),
+
+ BeComponentMissingError(EcompErrorCode.E_300, ErrorType.SYSTEM_ERROR, AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), BeIncorrectComponentError(EcompErrorCode.E_301, ErrorType.SYSTEM_ERROR,
+ AlarmSeverity.MAJOR, EcompClassification.ERROR), BeInvalidConfigurationError(EcompErrorCode.E_302,
+ ErrorType.CONFIG_ERROR, AlarmSeverity.MAJOR,
+ EcompClassification.FATAL), BeUebObjectNotFoundError(EcompErrorCode.E_303,
+ ErrorType.DATA_ERROR, AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), BeDistributionEngineInvalidArtifactType(
+ EcompErrorCode.E_304, ErrorType.DATA_ERROR, AlarmSeverity.MAJOR,
+ EcompClassification.WARNING), BeMissingConfigurationError(
+ EcompErrorCode.E_305, ErrorType.CONFIG_ERROR, AlarmSeverity.MAJOR,
+ EcompClassification.FATAL), BeConfigurationInvalidListSizeError(
+ EcompErrorCode.E_306, ErrorType.CONFIG_ERROR,
+ AlarmSeverity.MAJOR,
+ EcompClassification.FATAL), ErrorConfigFileFormat(
+ EcompErrorCode.E_307, ErrorType.CONFIG_ERROR,
+ AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), BeMissingArtifactInformationError(
+ EcompErrorCode.E_308, ErrorType.DATA_ERROR,
+ AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), BeArtifactMissingError(
+ EcompErrorCode.E_309,
+ ErrorType.DATA_ERROR,
+ AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), BeUserMissingError(
+ EcompErrorCode.E_310,
+ ErrorType.DATA_ERROR,
+ AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), EcompMismatchParam(
+ EcompErrorCode.E_311,
+ ErrorType.CONFIG_ERROR,
+ AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), EcompMissingError(
+ EcompErrorCode.E_312,
+ ErrorType.CONFIG_ERROR,
+ AlarmSeverity.MAJOR,
+ EcompClassification.ERROR),
+
+ InternalDataInfo(EcompErrorCode.E_399, ErrorType.DATA_ERROR, AlarmSeverity.INFORMATIONAL,
+ EcompClassification.INFORMATION), InternalDataWarning(EcompErrorCode.E_399, ErrorType.DATA_ERROR,
+ AlarmSeverity.MINOR, EcompClassification.WARNING), InternalDataError(EcompErrorCode.E_399,
+ ErrorType.DATA_ERROR, AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), InternalDataFatal(EcompErrorCode.E_399, ErrorType.DATA_ERROR,
+ AlarmSeverity.CRITICAL, EcompClassification.FATAL),
+
+ BeInvalidTypeError(EcompErrorCode.E_400, ErrorType.DATA_ERROR, AlarmSeverity.MAJOR,
+ EcompClassification.WARNING), BeInvalidValueError(EcompErrorCode.E_401, ErrorType.DATA_ERROR,
+ AlarmSeverity.MAJOR, EcompClassification.WARNING), BeArtifactPayloadInvalid(EcompErrorCode.E_402,
+ ErrorType.DATA_ERROR, AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), BeArtifactInformationInvalidError(EcompErrorCode.E_403,
+ ErrorType.DATA_ERROR, AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), BeGraphObjectMissingError(EcompErrorCode.E_404,
+ ErrorType.DATA_ERROR, AlarmSeverity.CRITICAL,
+ EcompClassification.ERROR), BeInvalidJsonInput(EcompErrorCode.E_405,
+ ErrorType.SYSTEM_ERROR, AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), BeDistributionMissingError(
+ EcompErrorCode.E_406, ErrorType.DATA_ERROR,
+ AlarmSeverity.MAJOR, EcompClassification.ERROR),
+
+ InvalidInputInfo(EcompErrorCode.E_499, ErrorType.SYSTEM_ERROR, AlarmSeverity.INFORMATIONAL,
+ EcompClassification.INFORMATION), InvalidInputWarning(EcompErrorCode.E_499, ErrorType.SYSTEM_ERROR,
+ AlarmSeverity.MINOR, EcompClassification.WARNING), InvalidInputError(EcompErrorCode.E_499,
+ ErrorType.SYSTEM_ERROR, AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), InvalidInputFatal(EcompErrorCode.E_499, ErrorType.SYSTEM_ERROR,
+ AlarmSeverity.CRITICAL, EcompClassification.FATAL),
+
+ BeInitializationError(EcompErrorCode.E_500, ErrorType.SYSTEM_ERROR, AlarmSeverity.CRITICAL,
+ EcompClassification.ERROR), BeFailedAddingResourceInstanceError(EcompErrorCode.E_501,
+ ErrorType.SYSTEM_ERROR, AlarmSeverity.MAJOR, EcompClassification.ERROR), BeUebSystemError(
+ EcompErrorCode.E_502, ErrorType.SYSTEM_ERROR, AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), BeDistributionEngineSystemError(EcompErrorCode.E_503,
+ ErrorType.SYSTEM_ERROR, AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), BeFailedAddingNodeTypeError(EcompErrorCode.E_504,
+ ErrorType.DATA_ERROR, AlarmSeverity.CRITICAL,
+ EcompClassification.ERROR), BeDaoSystemError(EcompErrorCode.E_505,
+ ErrorType.SYSTEM_ERROR, AlarmSeverity.CRITICAL,
+ EcompClassification.ERROR), BeSystemError(EcompErrorCode.E_506,
+ ErrorType.SYSTEM_ERROR, AlarmSeverity.CRITICAL,
+ EcompClassification.ERROR), BeExecuteRollbackError(
+ EcompErrorCode.E_507, ErrorType.DATA_ERROR,
+ AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), BeFailedLockObjectError(
+ EcompErrorCode.E_508,
+ ErrorType.SYSTEM_ERROR,
+ AlarmSeverity.CRITICAL,
+ EcompClassification.WARNING), BeFailedCreateNodeError(
+ EcompErrorCode.E_509,
+ ErrorType.DATA_ERROR,
+ AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), BeFailedUpdateNodeError(
+ EcompErrorCode.E_510,
+ ErrorType.DATA_ERROR,
+ AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), BeFailedDeleteNodeError(
+ EcompErrorCode.E_511,
+ ErrorType.DATA_ERROR,
+ AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), BeFailedRetrieveNodeError(
+ EcompErrorCode.E_512,
+ ErrorType.DATA_ERROR,
+ AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), BeFailedFindParentError(
+ EcompErrorCode.E_513,
+ ErrorType.DATA_ERROR,
+ AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), BeFailedFindAllNodesError(
+ EcompErrorCode.E_514,
+ ErrorType.DATA_ERROR,
+ AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), BeFailedFindAssociationError(
+ EcompErrorCode.E_515,
+ ErrorType.DATA_ERROR,
+ AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), BeComponentCleanerSystemError(
+ EcompErrorCode.E_516,
+ ErrorType.SYSTEM_ERROR,
+ AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), FeHttpLoggingError(
+ EcompErrorCode.E_517,
+ ErrorType.SYSTEM_ERROR,
+ AlarmSeverity.MINOR,
+ EcompClassification.ERROR), FePortalServletError(
+ EcompErrorCode.E_518,
+ ErrorType.SYSTEM_ERROR,
+ AlarmSeverity.MAJOR,
+ EcompClassification.ERROR),
+
+ InternalFlowInfo(EcompErrorCode.E_599, ErrorType.SYSTEM_ERROR, AlarmSeverity.INFORMATIONAL,
+ EcompClassification.INFORMATION), InternalFlowWarning(EcompErrorCode.E_599, ErrorType.SYSTEM_ERROR,
+ AlarmSeverity.MINOR, EcompClassification.WARNING), InternalFlowError(EcompErrorCode.E_599,
+ ErrorType.SYSTEM_ERROR, AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), InternalFlowFatal(EcompErrorCode.E_599, ErrorType.SYSTEM_ERROR,
+ AlarmSeverity.CRITICAL, EcompClassification.FATAL),
+
+ BeRestApiGeneralError(EcompErrorCode.E_900, ErrorType.SYSTEM_ERROR, AlarmSeverity.CRITICAL,
+ EcompClassification.ERROR, null), FeHealthCheckGeneralError(EcompErrorCode.E_901, ErrorType.SYSTEM_ERROR,
+ AlarmSeverity.CRITICAL, EcompClassification.ERROR, null),
+
+ InternalUnexpectedInfo(EcompErrorCode.E_999, ErrorType.SYSTEM_ERROR, AlarmSeverity.INFORMATIONAL,
+ EcompClassification.INFORMATION), InternalUnexpectedWarning(EcompErrorCode.E_999, ErrorType.SYSTEM_ERROR,
+ AlarmSeverity.MINOR, EcompClassification.WARNING), InternalUnexpectedError(EcompErrorCode.E_999,
+ ErrorType.SYSTEM_ERROR, AlarmSeverity.MAJOR,
+ EcompClassification.ERROR), InternalUnexpectedFatal(EcompErrorCode.E_999,
+ ErrorType.SYSTEM_ERROR, AlarmSeverity.CRITICAL, EcompClassification.FATAL),
+
+ /*
+ * BeUebAuthenticationError(EcompErrorCode.E_100,
+ * ErrorType.AUTHENTICATION_PROBLEM, AlarmSeverity.MAJOR,
+ * EcompClassification.ERROR),
+ *
+ * InternalAuthenticationInfo(EcompErrorCode.E_199,
+ * ErrorType.AUTHENTICATION_PROBLEM, AlarmSeverity.INFORMATIONAL,
+ * EcompClassification.INFORMATION),
+ * InternalAuthenticationWarning(EcompErrorCode.E_199,
+ * ErrorType.AUTHENTICATION_PROBLEM, AlarmSeverity.MINOR,
+ * EcompClassification.WARNING),
+ * InternalAuthenticationError(EcompErrorCode.E_199,
+ * ErrorType.AUTHENTICATION_PROBLEM, AlarmSeverity.MAJOR,
+ * EcompClassification.ERROR),
+ * InternalAuthenticationFatal(EcompErrorCode.E_199,
+ * ErrorType.AUTHENTICATION_PROBLEM, AlarmSeverity.CRITICAL,
+ * EcompClassification.FATAL),
+ * //BeFailedDeletingResourceInstanceError(EcompErrorCode.E_200,
+ * ErrorType.SYSTEM_ERROR, AlarmSeverity.MAJOR, Classification.ERROR),
+ *
+ * BeHealthCheckRecovery(EcompErrorCode.E_205, ErrorType.RECOVERY,
+ * AlarmSeverity.INFORMATIONAL, EcompClassification.INFORMATION, null),
+ * BeHealthCheckTitanRecovery(EcompErrorCode.E_206, ErrorType.RECOVERY,
+ * AlarmSeverity.INFORMATIONAL, EcompClassification.INFORMATION, null),
+ * BeHealthCheckElasticSearchRecovery(EcompErrorCode.E_207,
+ * ErrorType.RECOVERY, AlarmSeverity.INFORMATIONAL,
+ * EcompClassification.INFORMATION, null),
+ * BeHealthCheckUebClusterRecovery(EcompErrorCode.E_208, ErrorType.RECOVERY,
+ * AlarmSeverity.INFORMATIONAL, EcompClassification.INFORMATION, null),
+ * FeHealthCheckRecovery(EcompErrorCode.E_209, ErrorType.RECOVERY,
+ * AlarmSeverity.INFORMATIONAL, EcompClassification.INFORMATION, null),
+ * BeHealthCheckError(EcompErrorCode.E_200, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.CRITICAL, EcompClassification.ERROR,
+ * BeHealthCheckRecovery),
+ *
+ * BeHealthCheckTitanError(EcompErrorCode.E_201, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.CRITICAL, EcompClassification.ERROR,
+ * BeHealthCheckTitanRecovery),
+ * BeHealthCheckElasticSearchError(EcompErrorCode.E_202,
+ * ErrorType.SYSTEM_ERROR, AlarmSeverity.CRITICAL,
+ * EcompClassification.ERROR, BeHealthCheckElasticSearchRecovery),
+ * BeHealthCheckUebClusterError(EcompErrorCode.E_203,
+ * ErrorType.SYSTEM_ERROR, AlarmSeverity.CRITICAL,
+ * EcompClassification.ERROR, BeHealthCheckUebClusterRecovery),
+ * FeHealthCheckError(EcompErrorCode.E_204, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.CRITICAL, EcompClassification.ERROR,
+ * FeHealthCheckRecovery), BeUebConnectionError(EcompErrorCode.E_210,
+ * ErrorType.CONNECTION_PROBLEM, AlarmSeverity.MAJOR,
+ * EcompClassification.ERROR), BeUebUnkownHostError(EcompErrorCode.E_211,
+ * ErrorType.CONNECTION_PROBLEM, AlarmSeverity.MAJOR,
+ * EcompClassification.ERROR),
+ *
+ * InternalConnectionInfo(EcompErrorCode.E_299,
+ * ErrorType.CONNECTION_PROBLEM, AlarmSeverity.INFORMATIONAL,
+ * EcompClassification.INFORMATION),
+ * InternalConnectionWarning(EcompErrorCode.E_299,
+ * ErrorType.CONNECTION_PROBLEM, AlarmSeverity.MINOR,
+ * EcompClassification.WARNING),
+ * InternalConnectionError(EcompErrorCode.E_299,
+ * ErrorType.CONNECTION_PROBLEM, AlarmSeverity.MAJOR,
+ * EcompClassification.ERROR), InternalConnectionFatal(EcompErrorCode.E_299,
+ * ErrorType.CONNECTION_PROBLEM, AlarmSeverity.CRITICAL,
+ * EcompClassification.FATAL),
+ *
+ * BeComponentMissingError(EcompErrorCode.E_300, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * BeIncorrectComponentError(EcompErrorCode.E_301, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * BeInvalidConfigurationError(EcompErrorCode.E_302, ErrorType.CONFIG_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.FATAL),
+ * BeUebObjectNotFoundError(EcompErrorCode.E_303, ErrorType.DATA_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * BeDistributionEngineInvalidArtifactType(EcompErrorCode.E_304,
+ * ErrorType.DATA_ERROR, AlarmSeverity.MAJOR, EcompClassification.WARNING),
+ * BeMissingConfigurationError(EcompErrorCode.E_305, ErrorType.CONFIG_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.FATAL),
+ * BeConfigurationInvalidListSizeError(EcompErrorCode.E_306,
+ * ErrorType.CONFIG_ERROR, AlarmSeverity.MAJOR, EcompClassification.FATAL),
+ * ErrorConfigFileFormat(EcompErrorCode.E_307, ErrorType.CONFIG_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * BeMissingArtifactInformationError(EcompErrorCode.E_308,
+ * ErrorType.DATA_ERROR, AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * BeArtifactMissingError(EcompErrorCode.E_309, ErrorType.DATA_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * BeUserMissingError(EcompErrorCode.E_310, ErrorType.DATA_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * EcompMismatchParam(EcompErrorCode.E_311, ErrorType.CONFIG_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * EcompMissingError(EcompErrorCode.E_312, ErrorType.CONFIG_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ *
+ * InternalDataInfo(EcompErrorCode.E_399, ErrorType.DATA_ERROR,
+ * AlarmSeverity.INFORMATIONAL, EcompClassification.INFORMATION),
+ * InternalDataWarning(EcompErrorCode.E_399, ErrorType.DATA_ERROR,
+ * AlarmSeverity.MINOR, EcompClassification.WARNING),
+ * InternalDataError(EcompErrorCode.E_399, ErrorType.DATA_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * InternalDataFatal(EcompErrorCode.E_399, ErrorType.DATA_ERROR,
+ * AlarmSeverity.CRITICAL, EcompClassification.FATAL),
+ *
+ * BeInvalidTypeError(EcompErrorCode.E_400, ErrorType.DATA_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.WARNING),
+ * BeInvalidValueError(EcompErrorCode.E_401, ErrorType.DATA_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.WARNING),
+ * BeArtifactPayloadInvalid(EcompErrorCode.E_402, ErrorType.DATA_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * BeArtifactInformationInvalidError(EcompErrorCode.E_403,
+ * ErrorType.DATA_ERROR, AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * BeDistributionMissingError(EcompErrorCode.E_404, ErrorType.DATA_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * BeGraphObjectMissingError(EcompErrorCode.E_404, ErrorType.DATA_ERROR,
+ * AlarmSeverity.CRITICAL, EcompClassification.ERROR),
+ * BeInvalidJsonInput(EcompErrorCode.E_405, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ *
+ * InvalidInputInfo(EcompErrorCode.E_499, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.INFORMATIONAL, EcompClassification.INFORMATION),
+ * InvalidInputWarning(EcompErrorCode.E_499, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.MINOR, EcompClassification.WARNING),
+ * InvalidInputError(EcompErrorCode.E_499, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * InvalidInputFatal(EcompErrorCode.E_499, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.CRITICAL, EcompClassification.FATAL),
+ *
+ * BeInitializationError(EcompErrorCode.E_500, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.CRITICAL, EcompClassification.ERROR),
+ * BeFailedAddingResourceInstanceError(EcompErrorCode.E_501,
+ * ErrorType.SYSTEM_ERROR, AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * BeUebSystemError(EcompErrorCode.E_502, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * BeDistributionEngineSystemError(EcompErrorCode.E_503,
+ * ErrorType.SYSTEM_ERROR, AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * BeFailedAddingNodeTypeError(EcompErrorCode.E_504, ErrorType.DATA_ERROR,
+ * AlarmSeverity.CRITICAL, EcompClassification.ERROR),
+ * BeDaoSystemError(EcompErrorCode.E_505, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.CRITICAL, EcompClassification.ERROR),
+ * BeSystemError(EcompErrorCode.E_506, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.CRITICAL, EcompClassification.ERROR),
+ * BeExecuteRollbackError(EcompErrorCode.E_507, ErrorType.DATA_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * BeFailedLockObjectError(EcompErrorCode.E_508, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.CRITICAL, EcompClassification.WARNING),
+ * BeFailedCreateNodeError(EcompErrorCode.E_509, ErrorType.DATA_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * BeFailedUpdateNodeError(EcompErrorCode.E_510, ErrorType.DATA_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * BeFailedDeleteNodeError(EcompErrorCode.E_511, ErrorType.DATA_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * BeFailedRetrieveNodeError(EcompErrorCode.E_512, ErrorType.DATA_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * BeFailedFindParentError(EcompErrorCode.E_513, ErrorType.DATA_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * BeFailedFindAllNodesError(EcompErrorCode.E_514, ErrorType.DATA_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * BeFailedFindAssociationError(EcompErrorCode.E_515, ErrorType.DATA_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * BeComponentCleanerSystemError(EcompErrorCode.E_516,
+ * ErrorType.SYSTEM_ERROR, AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * FeHttpLoggingError(EcompErrorCode.E_517, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.MINOR, EcompClassification.ERROR),
+ * FePortalServletError(EcompErrorCode.E_518, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ *
+ * InternalFlowInfo(EcompErrorCode.E_599, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.INFORMATIONAL, EcompClassification.INFORMATION),
+ * InternalFlowWarning(EcompErrorCode.E_599, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.MINOR, EcompClassification.WARNING),
+ * InternalFlowError(EcompErrorCode.E_599, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * InternalFlowFatal(EcompErrorCode.E_599, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.CRITICAL, EcompClassification.FATAL),
+ *
+ * BeRestApiGeneralError(EcompErrorCode.E_900, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.CRITICAL, EcompClassification.ERROR, null),
+ * FeHealthCheckGeneralError(EcompErrorCode.E_901, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.CRITICAL, EcompClassification.ERROR, null),
+ *
+ * InternalUnexpectedInfo(EcompErrorCode.E_999, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.INFORMATIONAL, EcompClassification.INFORMATION),
+ * InternalUnexpectedWarning(EcompErrorCode.E_999, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.MINOR, EcompClassification.WARNING),
+ * InternalUnexpectedError(EcompErrorCode.E_999, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.MAJOR, EcompClassification.ERROR),
+ * InternalUnexpectedFatal(EcompErrorCode.E_999, ErrorType.SYSTEM_ERROR,
+ * AlarmSeverity.CRITICAL, EcompClassification.FATAL),
+ */
+
+ ;
+
+ EcompErrorCode ecompErrorCode;
+ ErrorType eType;
+ AlarmSeverity alarmSeverity;
+ EcompClassification classification;
+ EcompErrorEnum clearCode;
+
+ EcompErrorEnum(EcompErrorCode ecompErrorCode, ErrorType eType, AlarmSeverity alarmSeverity,
+ EcompClassification classification, EcompErrorEnum clearCode) {
+
+ this.ecompErrorCode = ecompErrorCode;
+ this.eType = eType;
+ this.alarmSeverity = alarmSeverity;
+ this.classification = classification;
+ this.clearCode = clearCode;
+ }
+
+ EcompErrorEnum(EcompErrorCode ecompErrorCode, ErrorType eType, AlarmSeverity alarmSeverity,
+ EcompClassification classification) {
+
+ this.ecompErrorCode = ecompErrorCode;
+ this.eType = eType;
+ this.alarmSeverity = alarmSeverity;
+ this.classification = classification;
+ }
+
+ public ErrorType geteType() {
+ return eType;
+ }
+
+ public void seteType(ErrorType eType) {
+ this.eType = eType;
+ }
+
+ public AlarmSeverity getAlarmSeverity() {
+ return alarmSeverity;
+ }
+
+ public void setAlarmSeverity(AlarmSeverity alarmSeverity) {
+ this.alarmSeverity = alarmSeverity;
+ }
+
+ public EcompErrorCode getEcompErrorCode() {
+ return ecompErrorCode;
+ }
+
+ public void setEcompErrorCode(EcompErrorCode ecompErrorCode) {
+ this.ecompErrorCode = ecompErrorCode;
+ }
+
+ public EcompClassification getClassification() {
+ return classification;
+ }
+
+ public void setClassification(EcompClassification classification) {
+ this.classification = classification;
+ }
+
+ public EcompErrorEnum getClearCode() {
+ return clearCode;
+ }
+
+ public void setClearCode(EcompErrorEnum clearCode) {
+ this.clearCode = clearCode;
+ }
+
+ public static enum ErrorType {
+ RECOVERY, CONFIG_ERROR, SYSTEM_ERROR, DATA_ERROR, CONNECTION_PROBLEM, AUTHENTICATION_PROBLEM
+ }
+
+ public static enum AlarmSeverity {
+ CRITICAL, MAJOR, MINOR, INFORMATIONAL, NONE
+ }
+
+ // public String toString() {
+ // return eType + "," + eCode + "," + desc;
+ // }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorInfo.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorInfo.java
new file mode 100644
index 0000000000..e1fd34b26d
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorInfo.java
@@ -0,0 +1,78 @@
+/*-
+ * ============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.common.config;
+
+public class EcompErrorInfo {
+
+ private String type;
+ private String code;
+ private String severity;
+ private String description;
+ private String alarmSeverity;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getSeverity() {
+ return severity;
+ }
+
+ public void setSeverity(String severity) {
+ this.severity = severity;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getAlarmSeverity() {
+ return alarmSeverity;
+ }
+
+ public void setAlarmSeverity(String alarmSeverity) {
+ this.alarmSeverity = alarmSeverity;
+ }
+
+ public void cloneData(EcompErrorInfo other) {
+ this.type = other.getType();
+ this.severity = other.getSeverity();
+ this.description = other.getDescription();
+ this.code = other.getCode();
+ this.alarmSeverity = other.getAlarmSeverity();
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorLogUtil.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorLogUtil.java
new file mode 100644
index 0000000000..274625aae4
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorLogUtil.java
@@ -0,0 +1,199 @@
+/*-
+ * ============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.common.config;
+
+import java.util.Formatter;
+import java.util.IllegalFormatException;
+import java.util.Locale;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.sdc.common.config.EcompErrorConfiguration.EcompAlarmSeverity;
+import org.openecomp.sdc.common.config.EcompErrorConfiguration.EcompErrorSeverity;
+import org.openecomp.sdc.common.config.EcompErrorConfiguration.EcompErrorType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+
+import fj.data.Either;
+
+public class EcompErrorLogUtil {
+
+ private static String ECOMP_ERROR_TMPL = "ETYPE = \"%s\" ENAME = \"%s\" ECODE = \"%s\" ECONTEXT = \"%s\" EDESC = \"%s\"";
+ private static Logger log = LoggerFactory.getLogger(EcompErrorLogUtil.class.getName());
+ private static final String FATAL_ERROR_PREFIX = "FATAL ERROR!! ";
+
+ public static void logEcompError(EcompErrorName ecompErrorName, EcompErrorInfo ecompErrorInfo,
+ String ecompErrorContext, String... ecompDescriptionParams) {
+ if (ecompErrorInfo != null) {
+ StringBuilder sb = new StringBuilder();
+ Formatter formatter = new Formatter(sb, Locale.US);
+ try {
+ String description = ecompErrorInfo.getDescription();
+ String severityStr = ecompErrorInfo.getSeverity();
+ EcompErrorConfiguration.EcompErrorSeverity severity = EcompErrorSeverity.ERROR;
+ // Since there is no FATAL log level, this is how we distinguish
+ // the FATAL errors
+ if (severityStr.equals(EcompErrorConfiguration.EcompErrorSeverity.FATAL.name())) {
+ description = FATAL_ERROR_PREFIX + description;
+ severity = EcompErrorSeverity.FATAL;
+ } else if (severityStr.equals(EcompErrorConfiguration.EcompErrorSeverity.WARN.name())) {
+ severity = EcompErrorSeverity.WARN;
+ } else if (severityStr.equals(EcompErrorConfiguration.EcompErrorSeverity.INFO.name())) {
+ severity = EcompErrorSeverity.INFO;
+ }
+
+ MDC.put("alarmSeverity", ecompErrorInfo.getAlarmSeverity());
+ // else it stays ERROR
+ formatter.format(ECOMP_ERROR_TMPL, ecompErrorInfo.getType(), ecompErrorName.name(),
+ ecompErrorInfo.getCode(), ecompErrorContext, description);
+ switch (severity) {
+ case INFO:
+ log.info(formatter.toString());
+ break;
+ case WARN:
+ log.warn(formatter.toString());
+ break;
+ case ERROR:
+ log.error(formatter.toString());
+ break;
+ case FATAL:
+ // same as ERROR for now, might be additional logic later..
+ log.error(formatter.toString());
+ break;
+ default:
+ break;
+ }
+ } finally {
+ formatter.close();
+ MDC.remove("alarmSeverity");
+ }
+ }
+ }
+
+ public static void logEcompError(String ecompErrorContext, EcompErrorEnum ecompErrorEnum,
+ String... ecompDescriptionParams) {
+ logEcompError(ecompErrorContext, ecompErrorEnum, true, ecompDescriptionParams);
+ }
+
+ public static void logEcompError(String ecompErrorContext, EcompErrorEnum ecompErrorEnum, boolean logMissingParams,
+ String... ecompDescriptionParams) {
+ StringBuilder sb = new StringBuilder();
+ Formatter formatter = new Formatter(sb, Locale.US);
+ try {
+ String description = ecompErrorEnum.getEcompErrorCode().getDescription();
+
+ Either<String, Boolean> setDescriptionParamsResult = setDescriptionParams(ecompErrorEnum,
+ ecompDescriptionParams);
+ if (setDescriptionParamsResult.isLeft()) {
+ description = setDescriptionParamsResult.left().value();
+ } else {
+ EcompErrorEnum mismatchErrorEnum = EcompErrorEnum.EcompMismatchParam;
+ if (logMissingParams == true) {
+ logEcompError("logEcompError", mismatchErrorEnum, false, ecompErrorEnum.name().toString());
+ return;
+ } else {
+ log.info("Failed to log the error code " + mismatchErrorEnum);
+ return;
+ }
+ }
+ EcompClassification classification = ecompErrorEnum.getClassification();
+
+ EcompErrorConfiguration.EcompErrorSeverity severity = EcompErrorSeverity.ERROR;
+ // Since there is no FATAL log level, this is how we distinguish the
+ // FATAL errors
+ if (classification == EcompClassification.FATAL) {
+ description = FATAL_ERROR_PREFIX + description;
+ severity = EcompErrorSeverity.FATAL;
+ } else if (classification == EcompClassification.WARNING) {
+ severity = EcompErrorSeverity.WARN;
+ } else if (classification == EcompClassification.INFORMATION) {
+ severity = EcompErrorSeverity.INFO;
+ }
+
+ String eCode = createEcode(ecompErrorEnum);
+
+ MDC.put("alarmSeverity", ecompErrorEnum.alarmSeverity.name());
+ // else it stays ERROR
+ formatter.format(ECOMP_ERROR_TMPL, ecompErrorEnum.geteType(), ecompErrorEnum.name(), eCode,
+ ecompErrorContext, description);
+ switch (severity) {
+ case INFO:
+ log.info(formatter.toString());
+ break;
+ case WARN:
+ log.warn(formatter.toString());
+ break;
+ case ERROR:
+ log.error(formatter.toString());
+ break;
+ case FATAL:
+ // same as ERROR for now, might be additional logic later..
+ log.error(formatter.toString());
+ break;
+ default:
+ break;
+ }
+ } finally {
+ formatter.close();
+ MDC.remove("alarmSeverity");
+ }
+ }
+
+ public static String createEcode(EcompErrorEnum ecompErrorEnum) {
+
+ EcompClassification classification = ecompErrorEnum.getClassification();
+ String ecompErrorCode = ecompErrorEnum.getEcompErrorCode().name();
+
+ String ecodeNumber = ecompErrorCode.substring(ecompErrorCode.indexOf("_") + 1);
+ String eCode = "ASDC" + ecodeNumber + classification.getClassification();
+
+ return eCode;
+ }
+
+ private static Either<String, Boolean> setDescriptionParams(EcompErrorEnum ecompErrorEnum,
+ String... descriptionParams) {
+ String description = ecompErrorEnum.getEcompErrorCode().getDescription();
+
+ // Counting number of params in description
+ int countMatches = StringUtils.countMatches(description, AbsEcompErrorManager.PARAM_STR);
+ // Catching cases when there are more params passed than there are in
+ // the description (formatter will ignore extra params and won't throw
+ // exception)
+ if (countMatches != descriptionParams.length) {
+ return Either.right(false);
+ }
+ // Setting params of the description if any
+ StringBuilder sb = new StringBuilder();
+ Formatter formatter = new Formatter(sb, Locale.US);
+ try {
+ formatter.format(description, (Object[]) descriptionParams).toString();
+ return Either.left(formatter.toString());
+ } catch (IllegalFormatException e) {
+ // Number of passed params doesn't match number of params in config
+ // file
+ return Either.right(false);
+ } finally {
+ formatter.close();
+ }
+
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorName.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorName.java
new file mode 100644
index 0000000000..6bd139bb28
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorName.java
@@ -0,0 +1,41 @@
+/*-
+ * ============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.common.config;
+
+public enum EcompErrorName {
+ // general
+ EcompConfigFileFormat, EcompErrorNotFound, EcompErrorDescParamsMismatch,
+
+ // FE
+ FeHealthCheckConnectionError, FeHealthCheckRecovery /* Recovery */, FeHttpLoggingError, FePortalServletError, FeHealthCheckGeneralError,
+
+ // BE section here...
+ BeHealthCheckError, BeHealthCheckRecovery, /* Recovery */
+ BeRestApiGeneralError, BeInitializationError, BeResourceMissingError, BeServiceMissingError, BeMissingArtifactInformationError, BeArtifactMissingError, BeArtifactPayloadInvalid, BeUserMissingError, BeArtifactInformationInvalidError, BeIncorrectServiceError, BeFailedAddingResourceInstanceError,
+ // BeFailedDeletingResourceInstanceError,
+ BeFailedAddingCapabilityTypeError, BeCapabilityTypeMissingError, BeInterfaceMissingError,
+ // BeRepositoryObjectNotFoundError,
+ // BeRepositoryDeleteError,
+ // BeRepositoryQueryError,
+ BeDaoSystemError, BeSystemError, BeInvalidConfigurationError, BeMissingConfigurationError, BeUebConnectionError, BeUebObjectNotFoundError, BeUebSystemError, BeDistributionEngineSystemError, BeDistributionEngineInvalidArtifactType, BeConfigurationInvalidListSizeError, BeUebAuthenticationError, BeUebUnkownHostError, BeInvalidTypeError, BeInvalidValueError, BeFailedLockObjectError, BeInvalidJsonInput, BeDistributionMissingError, ErrorConfigFileFormat,
+ // model
+ BeFailedCreateNodeError, BeFailedUpdateNodeError, BeFailedDeleteNodeError, BeFailedRetrieveNodeError, BeExecuteRollbackError, BeFailedFindParentError, BeFailedFindAllNodesError, BeFailedFindAssociationError, BeFailedToAssociateError, BeComponentCleanerSystemError;
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/IEcompConfigurationManager.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/IEcompConfigurationManager.java
new file mode 100644
index 0000000000..c16d8d329b
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/IEcompConfigurationManager.java
@@ -0,0 +1,25 @@
+/*-
+ * ============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.common.config;
+
+public interface IEcompConfigurationManager {
+ public EcompErrorConfiguration getEcompErrorConfiguration();
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/IEcompErrorManager.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/IEcompErrorManager.java
new file mode 100644
index 0000000000..7b9aa8e730
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/IEcompErrorManager.java
@@ -0,0 +1,27 @@
+/*-
+ * ============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.common.config;
+
+public interface IEcompErrorManager {
+
+ public void processEcompError(EcompErrorName ecompErrorName, String ecompErrorContext, String... descriptionParams);
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java
new file mode 100644
index 0000000000..275339ee20
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java
@@ -0,0 +1,242 @@
+/*-
+ * ============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.common.config.generation;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.openecomp.sdc.common.config.EcompErrorEnum;
+import org.openecomp.sdc.common.config.EcompErrorLogUtil;
+import org.openecomp.sdc.common.config.EcompErrorEnum.AlarmSeverity;
+import org.openecomp.sdc.common.config.EcompErrorEnum.ErrorType;
+
+public class GenerateEcompErrorsCsv {
+
+ private static String DATE_FORMAT = "dd-M-yyyy-hh-mm-ss";
+
+ private static String NEW_LINE = System.getProperty("line.separator");
+
+ private static void usage() {
+ System.out.println("java org.openecomp.sdc.common.config.generation.GenerateEcompErrorsCsv <target folder>");
+ System.exit(1);
+ }
+
+ public static void main(String[] args) {
+
+ String targetFolder = "target";
+ if (args.length > 1) {
+ targetFolder = args[0];
+ }
+
+ GenerateEcompErrorsCsv ecompErrorsCsv = new GenerateEcompErrorsCsv();
+
+ ecompErrorsCsv.generateEcompErrorsCsvFile(targetFolder, true);
+ }
+
+ public static class EcompErrorRow {
+
+ String errorName;
+ String errorCode;
+ String description;
+ ErrorType errorType;
+ AlarmSeverity alarmSeverity;
+ String cleanErrorCode;
+ String resolution;
+
+ public String getErrorName() {
+ return errorName;
+ }
+
+ public void setErrorName(String errorName) {
+ this.errorName = errorName;
+ }
+
+ public String getErrorCode() {
+ return errorCode;
+ }
+
+ public void setErrorCode(String errorCode) {
+ this.errorCode = errorCode;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public ErrorType getErrorType() {
+ return errorType;
+ }
+
+ public void setErrorType(ErrorType errorType) {
+ this.errorType = errorType;
+ }
+
+ public AlarmSeverity getAlarmSeverity() {
+ return alarmSeverity;
+ }
+
+ public void setAlarmSeverity(AlarmSeverity alarmSeverity) {
+ this.alarmSeverity = alarmSeverity;
+ }
+
+ public String getCleanErrorCode() {
+ return cleanErrorCode;
+ }
+
+ public void setCleanErrorCode(String cleanErrorCode) {
+ this.cleanErrorCode = cleanErrorCode;
+ }
+
+ public String getResolution() {
+ return resolution;
+ }
+
+ public void setResolution(String resolution) {
+ this.resolution = resolution;
+ }
+
+ }
+
+ public boolean generateEcompErrorsCsvFile(String targetFolder, boolean addTimeToFileName) {
+
+ targetFolder += File.separator;
+
+ boolean result = false;
+ String dateFormatted = "";
+
+ if (addTimeToFileName == true) {
+ DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
+
+ Date date = new Date();
+
+ dateFormatted = "." + dateFormat.format(date);
+
+ }
+
+ String outputFile = targetFolder + "ecompErrorCodes" + dateFormatted + ".csv";
+
+ FileWriter writer = null;
+
+ try {
+ writer = new FileWriter(outputFile);
+
+ List<EcompErrorRow> errors = new ArrayList<>();
+
+ for (EcompErrorEnum ecompErrorEnum : EcompErrorEnum.values()) {
+
+ EcompErrorRow ecompErrorRow = new EcompErrorRow();
+
+ String errorCode = EcompErrorLogUtil.createEcode(ecompErrorEnum);
+
+ EcompErrorEnum clearCodeEnum = ecompErrorEnum.getClearCode();
+ String cleanErrorCode = null;
+ if (clearCodeEnum != null) {
+ cleanErrorCode = EcompErrorLogUtil.createEcode(clearCodeEnum);
+ }
+
+ ecompErrorRow.setAlarmSeverity(ecompErrorEnum.getAlarmSeverity());
+ ecompErrorRow.setCleanErrorCode(cleanErrorCode);
+ ecompErrorRow.setDescription(ecompErrorEnum.getEcompErrorCode().getDescription());
+ ecompErrorRow.setErrorCode(errorCode);
+ ecompErrorRow.setErrorName(ecompErrorEnum.name().toString());
+ ecompErrorRow.setErrorType(ecompErrorEnum.geteType());
+ ecompErrorRow.setResolution(ecompErrorEnum.getEcompErrorCode().getResolution());
+
+ errors.add(ecompErrorRow);
+ }
+
+ writeHeaders(writer);
+
+ for (EcompErrorRow ecompErrorRow : errors) {
+ writer.append(addInvertedCommas(ecompErrorRow.getErrorCode()));
+ writer.append(',');
+ writer.append(addInvertedCommas(ecompErrorRow.getErrorType().toString()));
+ writer.append(',');
+ writer.append(addInvertedCommas(ecompErrorRow.getDescription()));
+ writer.append(',');
+ writer.append(addInvertedCommas(ecompErrorRow.getResolution()));
+ writer.append(',');
+ writer.append(addInvertedCommas(ecompErrorRow.getAlarmSeverity().toString()));
+ writer.append(',');
+ writer.append(addInvertedCommas(ecompErrorRow.getErrorName()));
+ writer.append(',');
+ writer.append(addInvertedCommas(ecompErrorRow.getCleanErrorCode()));
+ writer.append(NEW_LINE);
+ }
+
+ result = true;
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (writer != null) {
+ try {
+ writer.flush();
+ writer.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+ return result;
+ }
+
+ private void writeHeaders(FileWriter writer) throws IOException {
+
+ writer.append("\"ERROR CODE\"");
+ writer.append(',');
+ writer.append("\"ERROR TYPE\"");
+ writer.append(',');
+ writer.append("\"DESCRIPTION\"");
+ writer.append(',');
+ writer.append("\"RESOLUTION\"");
+ writer.append(',');
+ writer.append("\"ALARM SEVERITY\"");
+ writer.append(',');
+ writer.append("\"ERROR NAME\"");
+ writer.append(',');
+ writer.append("\"CLEAN CODE\"");
+ writer.append(NEW_LINE);
+ }
+
+ private String addInvertedCommas(String str) {
+
+ if (str == null) {
+ return "\"\"";
+ }
+
+ return "\"" + str + "\"";
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKeysEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKeysEnum.java
new file mode 100644
index 0000000000..263d446674
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKeysEnum.java
@@ -0,0 +1,103 @@
+/*-
+ * ============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.common.datastructure;
+
+import java.util.Date;
+
+public enum AuditingFieldsKeysEnum {
+ // General
+ AUDIT_TIMESTAMP(Date.class, "TIMESTAMP"),
+ AUDIT_ACTION(String.class, "ACTION"),
+ AUDIT_MODIFIER_NAME(String.class, "MODIFIER_ID"),
+ AUDIT_MODIFIER_UID(String.class, "MODIFIER"),
+ AUDIT_STATUS(String.class, "STATUS"),
+ AUDIT_DESC(String.class, "DESC"),
+ AUDIT_SERVICE_INSTANCE_ID(String.class, "SERVICE_INSTANCE_ID"),
+ AUDIT_INVARIANT_UUID(String.class, "INVARIANT_UUID"),
+ AUDIT_REQUEST_ID(String.class, "REQUEST_ID"),
+
+ // Users administration
+ AUDIT_USER_UID(String.class, "USER"),
+ AUDIT_USER_BEFORE(String.class, "USER_BEFORE"),
+ AUDIT_USER_AFTER(String.class, "USER_AFTER"),
+ AUDIT_USER_DETAILS(String.class, "DETAILS"),
+
+ // Resource administration
+ AUDIT_RESOURCE_NAME(String.class, "RESOURCE_NAME"),
+ AUDIT_RESOURCE_TYPE(String.class, "RESOURCE_TYPE"),
+ AUDIT_RESOURCE_CURR_VERSION(String.class, "CURR_VERSION"),
+ AUDIT_RESOURCE_PREV_VERSION(String.class, "PREV_VERSION"),
+ AUDIT_RESOURCE_CURR_STATE(String.class, "CURR_STATE"),
+ AUDIT_RESOURCE_PREV_STATE(String.class, "PREV_STATE"),
+ AUDIT_RESOURCE_COMMENT(String.class, "COMMENT"),
+ AUDIT_ARTIFACT_DATA(String.class, "ARTIFACT_DATA"),
+ AUDIT_PREV_ARTIFACT_UUID(String.class, "PREV_ARTIFACT_UUID"),
+ AUDIT_CURR_ARTIFACT_UUID(String.class, "CURR_ARTIFACT_UUID"),
+ AUDIT_RESOURCE_DPREV_STATUS(String.class, "DPREV_STATUS"),
+ AUDIT_RESOURCE_DCURR_STATUS(String.class, "DCURR_STATUS"),
+ AUDIT_RESOURCE_TOSCA_NODE_TYPE(String.class, "TOSCA_NODE_TYPE"),
+
+ // Distribution Engine
+ AUDIT_DISTRIBUTION_ENVRIONMENT_NAME(String.class, "D_ENV"),
+ AUDIT_DISTRIBUTION_TOPIC_NAME(String.class, "TOPIC_NAME"),
+ AUDIT_DISTRIBUTION_NOTIFICATION_TOPIC_NAME(String.class, "DNOTIF_TOPIC"),
+ AUDIT_DISTRIBUTION_STATUS_TOPIC_NAME(String.class, "DSTATUS_TOPIC"),
+ AUDIT_DISTRIBUTION_ROLE(String.class, "ROLE"),
+ AUDIT_DISTRIBUTION_ID(String.class, "DID"),
+ AUDIT_DISTRIBUTION_API_KEY(String.class, "API_KEY"),
+ AUDIT_DISTRIBUTION_CONSUMER_ID(String.class, "CONSUMER_ID"),
+ AUDIT_DISTRIBUTION_RESOURCE_URL(String.class, "RESOURCE_URL"),
+ AUDIT_DISTRIBUTION_STATUS_TIME(String.class, "STATUS_TIME"),
+ AUDIT_DISTRIBUTION_STATUS_DESC(String.class, "STATUS_DESC"),
+
+ // category
+ AUDIT_CATEGORY_NAME(String.class, "CATEGORY_NAME"),
+ AUDIT_SUB_CATEGORY_NAME(String.class, "SUB_CATEGORY_NAME"),
+ AUDIT_GROUPING_NAME(String.class, "GROUPING_NAME"),
+ AUDIT_DETAILS(String.class, "DETAILS"),
+
+ // authentication
+ AUDIT_AUTH_URL(String.class, "URL"),
+ AUDIT_AUTH_USER(String.class, "USER"),
+ AUDIT_AUTH_STATUS(String.class, "AUTH_STATUS"),
+ AUDIT_AUTH_REALM(String.class, "REALM"),
+ AUDIT_ECOMP_USER(String.class, "ECOMP_USER");
+
+ private Class<?> clazz;
+ private String displayName;
+
+ AuditingFieldsKeysEnum(Class<?> clazz, String displayName) {
+ this.clazz = clazz;
+ this.displayName = displayName;
+ }
+
+ public Class<?> getValueClass() {
+ return this.clazz;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/CapList.java b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/CapList.java
new file mode 100644
index 0000000000..d202715fae
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/CapList.java
@@ -0,0 +1,324 @@
+/*-
+ * ============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.common.datastructure;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/**
+ * Thread Safe List with a cap for Max elements.<br>
+ * If an element would be inserted to the list and it is full, the oldest
+ * element will be taken out.
+ *
+ * @author mshitrit
+ *
+ * @param <T>
+ */
+public class CapList<T> implements List<T> {
+ private static final int DEFAULT_CAP = 1000;
+ private int cap;
+ private ReadWriteLock readWriteLock;
+ private List<T> innerList;
+
+ public CapList() {
+ this(DEFAULT_CAP);
+ }
+
+ public CapList(int cap) {
+ if (cap < 1) {
+ throw new RuntimeException("List Cap Must Be Positive");
+ }
+ this.cap = cap;
+ innerList = new ArrayList<>();
+ readWriteLock = new ReentrantReadWriteLock();
+ }
+
+ @Override
+ public boolean add(T e) {
+ try {
+ readWriteLock.writeLock().lock();
+ boolean result = innerList.add(e);
+ removeExtras();
+ return result;
+
+ } finally {
+ readWriteLock.writeLock().unlock();
+ }
+
+ }
+
+ private void removeExtras() {
+ while (innerList.size() > cap) {
+ innerList.remove(0);
+ }
+ }
+
+ @Override
+ public void add(int index, T element) {
+ try {
+ readWriteLock.writeLock().lock();
+ innerList.add(index, element);
+ } finally {
+ readWriteLock.writeLock().unlock();
+ }
+
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends T> c) {
+ try {
+ readWriteLock.writeLock().lock();
+ boolean result = innerList.addAll(c);
+ removeExtras();
+ return result;
+ } finally {
+ readWriteLock.writeLock().unlock();
+ }
+ }
+
+ @Override
+ public boolean addAll(int index, Collection<? extends T> c) {
+ try {
+ readWriteLock.writeLock().lock();
+ boolean result = innerList.addAll(index, c);
+ removeExtras();
+ return result;
+ } finally {
+ readWriteLock.writeLock().unlock();
+ }
+ }
+
+ @Override
+ public void clear() {
+ try {
+ readWriteLock.writeLock().lock();
+ innerList.clear();
+ } finally {
+ readWriteLock.writeLock().unlock();
+ }
+
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ try {
+ readWriteLock.readLock().lock();
+ return innerList.contains(o);
+
+ } finally {
+ readWriteLock.readLock().unlock();
+ }
+
+ }
+
+ @Override
+ public boolean containsAll(Collection<?> c) {
+ try {
+ readWriteLock.readLock().lock();
+ return innerList.containsAll(c);
+
+ } finally {
+ readWriteLock.readLock().unlock();
+ }
+ }
+
+ @Override
+ public T get(int index) {
+ try {
+ readWriteLock.readLock().lock();
+ return innerList.get(index);
+
+ } finally {
+ readWriteLock.readLock().unlock();
+ }
+ }
+
+ @Override
+ public int indexOf(Object o) {
+ try {
+ readWriteLock.readLock().lock();
+ return innerList.indexOf(o);
+
+ } finally {
+ readWriteLock.readLock().unlock();
+ }
+ }
+
+ @Override
+ public boolean isEmpty() {
+ try {
+ readWriteLock.readLock().lock();
+ return innerList.isEmpty();
+
+ } finally {
+ readWriteLock.readLock().unlock();
+ }
+ }
+
+ @Override
+ public Iterator<T> iterator() {
+ try {
+ readWriteLock.readLock().lock();
+ return innerList.iterator();
+
+ } finally {
+ readWriteLock.readLock().unlock();
+ }
+ }
+
+ @Override
+ public int lastIndexOf(Object o) {
+ try {
+ readWriteLock.readLock().lock();
+ return innerList.lastIndexOf(o);
+
+ } finally {
+ readWriteLock.readLock().unlock();
+ }
+ }
+
+ @Override
+ public ListIterator<T> listIterator() {
+ try {
+ readWriteLock.readLock().lock();
+ return innerList.listIterator();
+
+ } finally {
+ readWriteLock.readLock().unlock();
+ }
+ }
+
+ @Override
+ public ListIterator<T> listIterator(int index) {
+ try {
+ readWriteLock.readLock().lock();
+ return innerList.listIterator(index);
+
+ } finally {
+ readWriteLock.readLock().unlock();
+ }
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ try {
+ readWriteLock.writeLock().lock();
+ return innerList.remove(o);
+
+ } finally {
+ readWriteLock.writeLock().unlock();
+ }
+ }
+
+ @Override
+ public T remove(int index) {
+ try {
+ readWriteLock.writeLock().lock();
+ return innerList.remove(index);
+
+ } finally {
+ readWriteLock.writeLock().unlock();
+ }
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ try {
+ readWriteLock.writeLock().lock();
+ return innerList.removeAll(c);
+
+ } finally {
+ readWriteLock.writeLock().unlock();
+ }
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ try {
+ readWriteLock.writeLock().lock();
+ return innerList.retainAll(c);
+
+ } finally {
+ readWriteLock.writeLock().unlock();
+ }
+ }
+
+ @Override
+ public T set(int index, T element) {
+ try {
+ readWriteLock.writeLock().lock();
+ return innerList.set(index, element);
+
+ } finally {
+ readWriteLock.writeLock().unlock();
+ }
+ }
+
+ @Override
+ public int size() {
+ try {
+ readWriteLock.readLock().lock();
+ return innerList.size();
+
+ } finally {
+ readWriteLock.readLock().unlock();
+ }
+ }
+
+ @Override
+ public List<T> subList(int fromIndex, int toIndex) {
+ try {
+ readWriteLock.readLock().lock();
+ return innerList.subList(fromIndex, toIndex);
+
+ } finally {
+ readWriteLock.readLock().unlock();
+ }
+ }
+
+ @Override
+ public Object[] toArray() {
+ try {
+ readWriteLock.readLock().lock();
+ return innerList.toArray();
+
+ } finally {
+ readWriteLock.readLock().unlock();
+ }
+ }
+
+ @Override
+ public <T> T[] toArray(T[] a) {
+ try {
+ readWriteLock.readLock().lock();
+ return innerList.toArray(a);
+
+ } finally {
+ readWriteLock.readLock().unlock();
+ }
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java
new file mode 100644
index 0000000000..55b9f7f87f
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java
@@ -0,0 +1,125 @@
+/*-
+ * ============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.common.datastructure;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Formatter;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+
+/**
+ * Extending this class enforces the objects of implementing classes to have a
+ * timestamp, so that like in logstash, we can derive the index name for those
+ * object from the timestamp.
+ *
+ * @author paharoni
+ *
+ */
+public class ESTimeBasedEvent {
+
+ protected static String dateFormatPattern = "yyyy-MM-dd HH:mm:ss.SSS z";
+ protected String timestamp;
+ protected Map<String, Object> fields = new HashMap<String, Object>();
+
+ public ESTimeBasedEvent() {
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
+ simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+ this.timestamp = simpleDateFormat.format(new Date());
+ fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), this.timestamp);
+
+ }
+
+ public static ESTimeBasedEvent createEventFromJson(String jsonString) throws JSONException {
+
+ ESTimeBasedEvent event = new ESTimeBasedEvent();
+ JSONObject gsonObj;
+ gsonObj = new JSONObject(jsonString);
+ Iterator keys = gsonObj.keys();
+
+ while (keys.hasNext()) {
+ String key = (String) keys.next();
+ event.fields.put(key, gsonObj.get(key));
+ if (key.equals(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName())) {
+ event.timestamp = (String) gsonObj.get(key);
+ }
+ }
+ return event;
+ }
+
+ public String calculateYearIndexSuffix() {
+ return timestamp.substring(0, 4);
+ }
+
+ public String calculateMonthIndexSuffix() {
+ return timestamp.substring(0, 7);
+ }
+
+ public String calculateDayIndexSuffix() {
+ return timestamp.substring(0, 10);
+ }
+
+ public String calculateHourIndexSuffix() {
+ return new StringBuilder().append(timestamp.substring(0, 10)).append("-").append(timestamp.substring(11, 13))
+ .toString();
+ }
+
+ public String calculateMinuteIndexSuffix() {
+ return new StringBuilder().append(timestamp.substring(0, 10)).append("-").append(timestamp.substring(11, 13))
+ .append("-").append(timestamp.substring(14, 16)).toString();
+ }
+
+ protected String getFormattedString(String template, Object... params) {
+ String res = null;
+ StringBuilder sb = new StringBuilder();
+ Formatter formatter = new Formatter(sb, Locale.US);
+ try {
+ formatter.format(template, params);
+ res = formatter.toString();
+ } finally {
+ formatter.close();
+ }
+ return res;
+ }
+
+ public String getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(String timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public Map<String, Object> getFields() {
+ return fields;
+ }
+
+ public void setFields(Map<String, Object> fields) {
+ this.fields = fields;
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/FunctionalInterfaces.java b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/FunctionalInterfaces.java
new file mode 100644
index 0000000000..12ba17baa5
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/FunctionalInterfaces.java
@@ -0,0 +1,282 @@
+/*-
+ * ============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.common.datastructure;
+
+import java.util.function.Function;
+import java.util.function.Supplier;
+
+/**
+ * Class For Functional interfaces And Functional Methods
+ *
+ * @author mshitrit
+ *
+ */
+public class FunctionalInterfaces {
+ private static final int DEFAULT_REDO_INTERVAL_TIME_MS = 50;
+ private static final int DEFAULT_MAX_WAIT_TIME_MS = 10000;
+
+ /**
+ * @author mshitrit Consumer that takes two parameters
+ */
+ public interface ConsumerTwoParam<T1, T2> {
+ /**
+ * Same Accept method, but takes two parameters
+ *
+ * @param t1
+ * @param t2
+ */
+ void accept(T1 t1, T2 t2);
+ }
+
+ /**
+ * @author mshitrit Function that takes two parameters
+ */
+ public interface FunctionTwoParam<T1, T2, R> {
+ /**
+ * Same apply method, but takes two parameters
+ *
+ * @param t1
+ * @param t2
+ * @return
+ */
+ R apply(T1 t1, T2 t2);
+ }
+
+ /**
+ * @author mshitrit Function that throws an exception
+ */
+ public interface FunctionThrows<T, R, E extends Exception> {
+ /**
+ * Same apply method, but throws an exception
+ *
+ * @param t
+ * @return
+ */
+ R apply(T t) throws E;
+ }
+
+ /**
+ * @author mshitrit Supplier that throws an exception
+ */
+ public interface SupplierThrows<R, E extends Exception> {
+ /**
+ * Same get method, but throws an exception
+ *
+ * @return
+ * @throws E
+ */
+ R get() throws E;
+ }
+
+ /**
+ * @author mshitrit Consumer that throws an exception
+ */
+ public interface ConsumerThrows<T, E extends Exception> {
+ /**
+ * Same accept, but throws an exception
+ *
+ * @param t
+ * @throws E
+ */
+ void accept(T t) throws E;
+ }
+
+ /**
+ * @author mshitrit Runnable that throws an exception
+ */
+ public interface RunnableThrows<E extends Exception> {
+ /**
+ * Same run, but throws an exception
+ *
+ * @throws E
+ */
+ void run() throws E;
+ }
+
+ /**
+ * Runs a method that declares throwing an Exception and has a return value.
+ * <br>
+ * In case Exception Occurred replaces it with FunctionalAttException. <br>
+ * This is useful for two cases:<br>
+ * 1.using methods that throws exceptions in streams.<br>
+ * 2.replacing declared exception with undeclared exception (Runtime).<br>
+ * See below Use Case:<br>
+ * Instead of: intList.stream().map(e -> fooThrowsAndReturnsBoolean(e)); -
+ * does not compile !<br>
+ * Use This : intList.stream().map(e -> swallowException( () ->
+ * fooThrowsAndReturnsBoolean(e))); - compiles !<br>
+ *
+ * @param methodToRun
+ * @return
+ */
+ public static <R, E extends Exception> R swallowException(SupplierThrows<R, E> methodToRun) {
+ try {
+ final R result = methodToRun.get();
+ return result;
+ } catch (Exception e) {
+ throw new FunctionalAttException(e);
+ }
+ }
+
+ /**
+ * Runs a method that declares throwing an Exception without return value.
+ * <br>
+ * In case Exception Occurred replaces it with FunctionalAttException. <br>
+ * This is useful for two cases:<br>
+ * 1.using methods that throws exceptions in streams.<br>
+ * 2.replacing declared exception with undeclared exception (Runtime).<br>
+ * See below Use Case:<br>
+ *
+ * @param methodToRun
+ */
+ public static <E extends Exception> void swallowException(RunnableThrows<E> methodToRun) {
+
+ SupplierThrows<Boolean, E> runnableWrapper = () -> {
+ methodToRun.run();
+ return true;
+ };
+ swallowException(runnableWrapper);
+ }
+
+ private static class FunctionalAttException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
+ private FunctionalAttException(Exception e) {
+ super(e);
+ }
+ }
+
+ /**
+ * Runs the given method.<br>
+ * Verify the method result against the resultVerifier.<br>
+ * If verification passed returns the result.<br>
+ * If Verification failed keeps retrying until it passes or until 10 seconds
+ * pass.<br>
+ * If Exception Occurred keeps retrying until it passes or until 10 seconds
+ * pass,<br>
+ * If last retry result caused an exception - it is thrown.
+ *
+ * @param methodToRun
+ * given Method
+ * @param resultVerifier
+ * verifier for the method result
+ * @return
+ */
+ public static <R> R retryMethodOnResult(Supplier<R> methodToRun, Function<R, Boolean> resultVerifier) {
+ return retryMethodOnResult(methodToRun, resultVerifier, DEFAULT_MAX_WAIT_TIME_MS,
+ DEFAULT_REDO_INTERVAL_TIME_MS);
+ }
+
+ /**
+ * Runs the given method.<br>
+ * Verify the method result against the resultVerifier.<br>
+ * If verification passed returns the result.<br>
+ * If Verification failed keeps retrying until it passes or until maxWait
+ * pass.<br>
+ * If Exception Occurred keeps retrying until it passes or until maxWait
+ * pass,<br>
+ * If last retry result caused an exception - it is thrown.
+ *
+ * @param methodToRun
+ * given Method
+ * @param resultVerifier
+ * verifier for the method result
+ * @param maxWaitMS
+ * @param retryIntervalMS
+ * @return
+ */
+ public static <R> R retryMethodOnResult(Supplier<R> methodToRun, Function<R, Boolean> resultVerifier,
+ long maxWaitMS, long retryIntervalMS) {
+ boolean stopSearch = false;
+ R ret = null;
+ int timeElapsed = 0;
+ FunctionalAttException functionalExceotion = null;
+ boolean isExceptionInLastTry = false;
+ while (!stopSearch) {
+ try {
+ ret = methodToRun.get();
+ stopSearch = resultVerifier.apply(ret);
+ isExceptionInLastTry = false;
+ } catch (Exception e) {
+ functionalExceotion = new FunctionalAttException(e);
+ isExceptionInLastTry = true;
+
+ } finally {
+ sleep(retryIntervalMS);
+ timeElapsed += retryIntervalMS;
+ if (timeElapsed > maxWaitMS) {
+ stopSearch = true;
+ }
+ }
+
+ }
+ if (isExceptionInLastTry) {
+ throw functionalExceotion;
+ } else {
+ return ret;
+ }
+
+ }
+
+ /**
+ * Runs the given method.<br>
+ * In case exception occurred runs the method again either until succeed or
+ * until 10 seconds pass.
+ *
+ * @param methodToRun
+ * given method
+ * @return
+ */
+
+ public static <R> R retryMethodOnException(Supplier<R> methodToRun) {
+ Function<R, Boolean> dummyVerifier = someResult -> true;
+ return retryMethodOnResult(methodToRun, dummyVerifier, DEFAULT_MAX_WAIT_TIME_MS, DEFAULT_REDO_INTERVAL_TIME_MS);
+ }
+
+ /**
+ * Runs the given method.<br>
+ * In case exception occurred runs the method again either until succeed or
+ * until 10 seconds pass.
+ *
+ * @param methodToRun
+ * given method
+ */
+ public static void retryMethodOnException(Runnable methodToRun) {
+ Function<Boolean, Boolean> dummyVerifier = someResult -> true;
+ Supplier<Boolean> dummySupplier = () -> {
+ methodToRun.run();
+ return true;
+ };
+ retryMethodOnResult(dummySupplier, dummyVerifier, DEFAULT_MAX_WAIT_TIME_MS, DEFAULT_REDO_INTERVAL_TIME_MS);
+ }
+
+ /**
+ * Same as Thread.sleep but throws a FunctionalAttException
+ * (RuntimeException) instead of InterruptedException.<br>
+ *
+ * @param millis
+ */
+ public static void sleep(long millis) {
+ swallowException(() -> Thread.sleep(millis));
+
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/MonitoringFieldsKeysEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/MonitoringFieldsKeysEnum.java
new file mode 100644
index 0000000000..f92b4ef687
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/MonitoringFieldsKeysEnum.java
@@ -0,0 +1,57 @@
+/*-
+ * ============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.common.datastructure;
+
+import java.util.Date;
+
+public enum MonitoringFieldsKeysEnum {
+ MONITORING_TIMESTAMP(Date.class, "TIMESTAMP"),
+ MONITORING_HOST_IP(String.class, "HOST_IP"),
+ MONITORING_HOST_CPU(Long.class, "HOST_CPU"),
+ MONITORING_HOST_MEM(Long.class, "HOST_MEMORY"),
+ MONITORING_HOST_DISC(Long.class, "HOST_DISC"),
+ MONITORING_JVM_ID(String.class, "JVM_ID"),
+ MONITORING_JVM_CPU(Long.class, "JVM_CPU"),
+ MONITORING_JVM_MEM(Long.class, "JVM_MEMORY"),
+ MONITORING_JVM_TNUM(Long.class, "JVM_TNUM"),
+ MONITORING_APP_ID(String.class, "APP_ID"),
+ MONITORING_APP_STAT(String.class, "APP_STAT");
+
+ private Class<?> clazz;
+ private String displayName;
+
+ MonitoringFieldsKeysEnum(Class<?> clazz, String displayName) {
+ this.clazz = clazz;
+ this.displayName = displayName;
+ }
+
+ public Class<?> getValueClass() {
+ return this.clazz;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/Wrapper.java b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/Wrapper.java
new file mode 100644
index 0000000000..43fd5ca15f
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/Wrapper.java
@@ -0,0 +1,52 @@
+/*-
+ * ============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.common.datastructure;
+
+/**
+ * Very Basic Wrapper class.
+ *
+ * @author mshitrit
+ *
+ * @param <T>
+ */
+public class Wrapper<T> {
+ private T innerElement;
+
+ public Wrapper(T innerElement) {
+ this.innerElement = innerElement;
+ }
+
+ public Wrapper() {
+ this.innerElement = null;
+ }
+
+ public T getInnerElement() {
+ return innerElement;
+ }
+
+ public void setInnerElement(T innerElement) {
+ this.innerElement = innerElement;
+ }
+
+ public boolean isEmpty() {
+ return innerElement == null;
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java
new file mode 100644
index 0000000000..9b5debb53a
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java
@@ -0,0 +1,148 @@
+/*-
+ * ============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.common.impl;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.jci.listeners.FileChangeListener;
+import org.openecomp.sdc.common.api.BasicConfiguration;
+import org.openecomp.sdc.common.api.ConfigurationListener;
+import org.openecomp.sdc.common.util.YamlToObjectConverter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ConfigFileChangeListener extends FileChangeListener {
+
+ private static Logger log = LoggerFactory.getLogger(ConfigFileChangeListener.class.getName());
+
+ private Map<String, List<ConfigurationListener>> fileChangeToCallBack = new HashMap<String, List<ConfigurationListener>>();
+
+ private Object lock = new Object();
+
+ private YamlToObjectConverter yamlToObjectConverter = new YamlToObjectConverter();
+
+ @Override
+ public void onFileChange(File pFile) {
+
+ super.onFileChange(pFile);
+
+ if (pFile != null) {
+
+ if (fileChangeToCallBack != null) {
+
+ String id = findIdFromFileName(pFile.getName());
+
+ if (id != null) {
+
+ List<ConfigurationListener> listeners = fileChangeToCallBack.get(id);
+ if (listeners != null) {
+ for (ConfigurationListener configurationListener : listeners) {
+
+ Class<? extends BasicConfiguration> configClass = configurationListener.getType();
+
+ BasicConfiguration basicConfiguration = yamlToObjectConverter
+ .convert(pFile.getAbsolutePath(), configClass);
+
+ if (basicConfiguration == null) {
+ log.warn(
+ "Cannot update the listeners for file Change since the file content is invalid");
+ continue;
+ }
+ log.debug("Loaded configuration after converting is " + basicConfiguration);
+ // System.out.println("New configuration is " +
+ // basicConfiguration);
+
+ configurationListener.getCallBack().reconfigure(basicConfiguration);
+
+ }
+ }
+ } else {
+
+ log.warn("Cannot calculate id from file " + pFile.getName());
+ }
+ }
+
+ }
+
+ log.debug("File {} was changed.", pFile);
+ }
+
+ private String findIdFromFileName(String name) {
+
+ String result = null;
+ if (name != null) {
+ int startIndex = 0;
+ int endIndex = name.length();
+ if (name.contains(File.separator)) {
+ startIndex = name.lastIndexOf(File.separator);
+ }
+ // String subNameString = name.substring(startIndex, endIndex);
+ // if (subNameString.contains(".")) {
+ // endIndex = subNameString.indexOf(".");
+ // }
+
+ result = name.substring(startIndex, endIndex);
+
+ }
+
+ return result;
+ }
+
+ public void register(String id, ConfigurationListener configurationListener) {
+
+ if (configurationListener != null) {
+
+ synchronized (lock) {
+
+ List<ConfigurationListener> callbacks = fileChangeToCallBack.get(id);
+ if (callbacks == null) {
+ callbacks = new ArrayList<ConfigurationListener>();
+ fileChangeToCallBack.put(id, callbacks);
+ }
+ callbacks.add(configurationListener);
+
+ }
+
+ }
+
+ }
+
+ // public void notify(String id, BasicConfiguration object) {
+ //
+ // if (fileChangeToCallBack != null) {
+ // List<ConfigurationListener> listeners = fileChangeToCallBack
+ // .get(id);
+ // if (listeners != null) {
+ // for (ConfigurationListener configurationListener : listeners) {
+ //
+ // configurationListener.getCallBack().reconfigure(object);
+ //
+ // }
+ // }
+ // }
+ //
+ // }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ExternalConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ExternalConfiguration.java
new file mode 100644
index 0000000000..b23dcb8812
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ExternalConfiguration.java
@@ -0,0 +1,106 @@
+/*-
+ * ============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.common.impl;
+
+import java.io.File;
+
+import org.apache.commons.jci.monitor.FilesystemAlterationMonitor;
+import org.openecomp.sdc.common.api.ConfigurationSource;
+
+/**
+ *
+ * Save the
+ *
+ * @author esofer
+ *
+ */
+public class ExternalConfiguration {
+
+ private static String appName;
+ private static String appVersion;
+ private static String configDir;
+ private static ConfigurationSource configurationSource;
+
+ private static FilesystemAlterationMonitor fam = null;
+
+ private static ConfigFileChangeListener changeListener = new ConfigFileChangeListener();
+
+ private static boolean enableReconfigure = true;
+
+ public static String getAppName() {
+ return appName;
+ }
+
+ public static void setAppName(String appName) {
+ ExternalConfiguration.appName = appName;
+ }
+
+ public static String getAppVersion() {
+ return appVersion;
+ }
+
+ public static void setAppVersion(String appVersion) {
+ ExternalConfiguration.appVersion = appVersion;
+ }
+
+ public static String getConfigDir() {
+ return configDir;
+ }
+
+ public static void setConfigDir(String configDir) {
+ ExternalConfiguration.configDir = configDir;
+ }
+
+ public static ConfigurationSource getConfigurationSource() {
+ return configurationSource;
+ }
+
+ public static void setConfigurationSource(ConfigurationSource configurationSource) {
+ ExternalConfiguration.configurationSource = configurationSource;
+ }
+
+ public static ConfigFileChangeListener getChangeListener() {
+ return changeListener;
+ }
+
+ public static void listenForChanges() {
+
+ String watchingDir = configDir + File.separator + appName;
+ if (enableReconfigure) {
+ if (fam == null) {
+ fam = new FilesystemAlterationMonitor();
+ fam.setInterval(1000);
+ fam.addListener(new File(watchingDir), changeListener);
+ fam.start();
+ }
+ }
+ }
+
+ public static void stopListenForFileChanges() {
+ if (enableReconfigure) {
+ if (fam != null) {
+ fam.stop();
+ fam = null;
+ }
+ }
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/FSConfigurationSource.java b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/FSConfigurationSource.java
new file mode 100644
index 0000000000..76f64ca278
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/FSConfigurationSource.java
@@ -0,0 +1,121 @@
+/*-
+ * ============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.common.impl;
+
+import org.openecomp.sdc.common.api.ConfigurationListener;
+import org.openecomp.sdc.common.api.ConfigurationSource;
+import org.openecomp.sdc.common.api.Constants;
+import org.openecomp.sdc.common.util.YamlToObjectConverter;
+
+/**
+ * Read configuration from file system
+ *
+ * @author esofer
+ *
+ */
+public class FSConfigurationSource implements ConfigurationSource {
+
+ private YamlToObjectConverter yamlToObjectConverter = new YamlToObjectConverter();
+
+ private ConfigFileChangeListener changeListener = null;
+ private String appConfigDir = null;
+
+ public FSConfigurationSource(ConfigFileChangeListener changeListener, String appConfigDir) {
+ super();
+ this.changeListener = changeListener;
+ this.appConfigDir = appConfigDir;
+ }
+
+ /*
+ * get and watch configuration changes. The file name we looking for is the
+ * lower case of the class name separated by "-".
+ *
+ * (non-Javadoc)
+ *
+ * @see
+ * org.openecomp.sdc.common.api.ConfigurationSource#getAndWatchConfiguration
+ * (java.lang.Class, org.openecomp.sdc.common.api.ConfigurationListener)
+ */
+ public <T> T getAndWatchConfiguration(Class<T> className, ConfigurationListener configurationListener) {
+
+ String configFileName = calculateFileName(className);
+
+ T object = yamlToObjectConverter.convert(this.appConfigDir, className, configFileName);
+
+ if (configurationListener != null && changeListener != null) {
+ if (object != null) {
+ changeListener.register(configFileName, configurationListener);
+ }
+ }
+
+ return object;
+ }
+
+ public <T> void addWatchConfiguration(Class<T> className, ConfigurationListener configurationListener) {
+
+ String configFileName = calculateFileName(className);
+
+ if (configurationListener != null) {
+ changeListener.register(configFileName, configurationListener);
+ }
+
+ }
+
+ /**
+ * convert camel case string to list of words separated by "-" where each
+ * word is in lower case format. For example, MyClass will be calculated to
+ * be my-class.yaml .
+ *
+ * @param className
+ * @return file name based on the class name
+ */
+ private static <T> String calculateFileName(Class<T> className) {
+
+ String[] words = className.getSimpleName().split("(?=\\p{Upper})");
+
+ StringBuilder builder = new StringBuilder();
+
+ // There cannot be a null value returned from "split" - words != null is
+ // redundant
+ // if (words != null) {
+ boolean isFirst = true;
+ for (int i = 0; i < words.length; i++) {
+
+ String word = words[i];
+ if (word != null && !word.isEmpty()) {
+ if (!isFirst) {
+ builder.append("-");
+ } else {
+ isFirst = false;
+ }
+ builder.append(words[i].toLowerCase());
+ }
+ }
+ return builder.toString() + Constants.YAML_SUFFIX;
+
+ /*
+ * } else { return className.getSimpleName().toLowerCase() +
+ * Constants.YAML_SUFFIX; }
+ */
+
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/MutableHttpServletRequest.java b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/MutableHttpServletRequest.java
new file mode 100644
index 0000000000..c7ce7a8c32
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/MutableHttpServletRequest.java
@@ -0,0 +1,73 @@
+/*-
+ * ============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.common.impl;
+
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+public final class MutableHttpServletRequest extends HttpServletRequestWrapper {
+ // holds custom header and value mapping
+ private final Map<String, String> customHeaders;
+
+ public MutableHttpServletRequest(HttpServletRequest request) {
+ super(request);
+ this.customHeaders = new HashMap<String, String>();
+ }
+
+ public void putHeader(String name, String value) {
+ this.customHeaders.put(name, value);
+ }
+
+ public String getHeader(String name) {
+ // check the custom headers first
+ String headerValue = customHeaders.get(name);
+
+ if (headerValue != null) {
+ return headerValue;
+ }
+ // else return from into the original wrapped object
+ return ((HttpServletRequest) getRequest()).getHeader(name);
+ }
+
+ public Enumeration<String> getHeaderNames() {
+ // create a set of the custom header names
+ Set<String> set = new HashSet<String>(customHeaders.keySet());
+
+ // now add the headers from the wrapped request object
+ @SuppressWarnings("unchecked")
+ Enumeration<String> e = ((HttpServletRequest) getRequest()).getHeaderNames();
+ while (e.hasMoreElements()) {
+ // add the names of the request headers into the list
+ String n = e.nextElement();
+ set.add(n);
+ }
+
+ // create an enumeration from the set and return
+ return Collections.enumeration(set);
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/kpi/api/ASDCKpiApi.java b/common-app-api/src/main/java/org/openecomp/sdc/common/kpi/api/ASDCKpiApi.java
new file mode 100644
index 0000000000..5644ef5c41
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/kpi/api/ASDCKpiApi.java
@@ -0,0 +1,67 @@
+/*-
+ * ============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.common.kpi.api;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ASDCKpiApi {
+
+ private static Logger log = LoggerFactory.getLogger(ASDCKpiApi.class.getName());
+
+ /* Number of activated resource imports. */
+ public static void countImportResourcesKPI() {
+ // TODO Auto-generated method stub
+ log.trace("Number of activated resource imports.");
+
+ }
+
+ /* Number of created resources. */
+ public static void countCreatedResourcesKPI() {
+ // TODO Auto-generated method stub
+ log.trace("Number of created resources.");
+
+ }
+
+ /* Number of created services */
+ public static void countCreatedServicesKPI() {
+ // TODO Auto-generated method stub
+ log.trace("Number of created services.");
+
+ }
+
+ /*
+ * Number of ASDC portal accesses ( number of activated user authorizations)
+ */
+ public static void countUsersAuthorizations() {
+ // TODO Auto-generated method stub
+ log.trace("Number of activated distribution");
+
+ }
+
+ /* Number of activated distribution */
+ public static void countActivatedDistribution() {
+ // TODO Auto-generated method stub
+ log.trace("Number of activated distribution");
+
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java b/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java
new file mode 100644
index 0000000000..3f588e8aa2
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java
@@ -0,0 +1,129 @@
+/*-
+ * ============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.common.listener;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.openecomp.sdc.common.api.ConfigurationSource;
+import org.openecomp.sdc.common.api.Constants;
+import org.openecomp.sdc.common.impl.ExternalConfiguration;
+import org.openecomp.sdc.common.impl.FSConfigurationSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+
+public class AppContextListener implements ServletContextListener {
+
+ private static Logger log = LoggerFactory.getLogger(AppContextListener.class.getName());
+
+ public void contextInitialized(ServletContextEvent context) {
+
+ log.debug("ServletContextListener initialized ");
+
+ log.debug("After read values from Manifest {}", getManifestInfo(context.getServletContext()));
+
+ Map<String, String> manifestAttr = getManifestInfo(context.getServletContext());
+
+ String appName = setAndGetAttributeInContext(context, manifestAttr, Constants.APPLICATION_NAME);
+ String appVersion = setAndGetAttributeInContext(context, manifestAttr, Constants.APPLICATION_VERSION);
+
+ ExternalConfiguration.setAppName(appName);
+ ExternalConfiguration.setAppVersion(appVersion);
+ String configHome = System.getProperty(Constants.CONFIG_HOME);
+ ExternalConfiguration.setConfigDir(configHome);
+
+ String appConfigDir = configHome + File.separator + appName;
+ // ChangeListener changeListener = new ChangeListener();
+ ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
+
+ context.getServletContext().setAttribute(Constants.CONFIGURATION_SOURCE_ATTR, configurationSource);
+
+ ExternalConfiguration.setConfigurationSource(configurationSource);
+
+ ExternalConfiguration.listenForChanges();
+
+ }
+
+ public void contextDestroyed(ServletContextEvent context) {
+
+ log.debug("ServletContextListener destroyed");
+ ExternalConfiguration.stopListenForFileChanges();
+ }
+
+ private String setAndGetAttributeInContext(ServletContextEvent context, Map<String, String> manifestAttr, String attr) {
+
+ String name = manifestAttr.get(attr);
+ if (name != null) {
+ context.getServletContext().setAttribute(attr, name);
+ }
+
+ return name;
+ }
+
+ public static Map<String, String> getManifestInfo(ServletContext application) {
+
+ Map<String, String> result = new HashMap<String, String>();
+ InputStream inputStream = null;
+ try {
+
+ inputStream = application.getResourceAsStream("/META-INF/MANIFEST.MF");
+
+ Manifest manifest = new Manifest(inputStream);
+
+ Attributes attr = manifest.getMainAttributes();
+ String name = attr.getValue("Implementation-Title");
+ if (name != null) {
+ result.put(Constants.APPLICATION_NAME, name);
+ }
+
+ String version = attr.getValue("Implementation-Version");
+ if (version != null) {
+ result.put(Constants.APPLICATION_VERSION, version);
+ }
+
+ } catch (IOException e) {
+
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return result;
+
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/monitoring/MonitoringEvent.java b/common-app-api/src/main/java/org/openecomp/sdc/common/monitoring/MonitoringEvent.java
new file mode 100644
index 0000000000..61651f3ddc
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/monitoring/MonitoringEvent.java
@@ -0,0 +1,126 @@
+/*-
+ * ============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.common.monitoring;
+
+import org.openecomp.sdc.common.datastructure.ESTimeBasedEvent;
+
+public class MonitoringEvent extends ESTimeBasedEvent {
+
+ private static String MONITORING_EVENT_TEMPLATE = "hostid=\"%s\" hostcpu=\"%s\" hostmem=\"%s\" hostdisk=\"%s\" "
+ + "jvmid=\"%s\" jvmcpu=\"%s\" jvmmem=\"%s\" jvmtnum=\"%s\" " + "appid=\"%s\" appstat=\"%s\"";
+
+ private String hostid;
+ private Long hostcpu;
+ private Double hostmem;
+ private String hostdisk;
+ private String jvmid;
+ private Long jvmcpu;
+ private Long jvmmem;
+ private Integer jvmtnum;
+ private String appid;
+ private String appstat;
+
+ public String getHostid() {
+ return hostid;
+ }
+
+ public void setHostid(String hostid) {
+ this.hostid = hostid;
+ }
+
+ public Long getHostcpu() {
+ return hostcpu;
+ }
+
+ public void setHostcpu(Long hostcpu) {
+ this.hostcpu = hostcpu;
+ }
+
+ public Double getHostmem() {
+ return hostmem;
+ }
+
+ public void setHostmem(Double hostmem) {
+ this.hostmem = hostmem;
+ }
+
+ public String getHostdisk() {
+ return hostdisk;
+ }
+
+ public void setHostdisk(String hostdisk) {
+ this.hostdisk = hostdisk;
+ }
+
+ public String getJvmid() {
+ return jvmid;
+ }
+
+ public void setJvmid(String jvmid) {
+ this.jvmid = jvmid;
+ }
+
+ public Long getJvmcpu() {
+ return jvmcpu;
+ }
+
+ public void setJvmcpu(Long jvmcpu) {
+ this.jvmcpu = jvmcpu;
+ }
+
+ public Long getJvmmem() {
+ return jvmmem;
+ }
+
+ public void setJvmmem(Long jvmmem) {
+ this.jvmmem = jvmmem;
+ }
+
+ public Integer getJvmtnum() {
+ return jvmtnum;
+ }
+
+ public void setJvmtnum(Integer jvmtnum) {
+ this.jvmtnum = jvmtnum;
+ }
+
+ public String getAppid() {
+ return appid;
+ }
+
+ public void setAppid(String appid) {
+ this.appid = appid;
+ }
+
+ public String getAppstat() {
+ return appstat;
+ }
+
+ public void setAppstat(String appstat) {
+ this.appstat = appstat;
+ }
+
+ @Override
+ public String toString() {
+ return getFormattedString(MONITORING_EVENT_TEMPLATE, hostid, hostcpu, hostmem, hostdisk, jvmid, jvmcpu, jvmmem,
+ jvmtnum, appid, appstat);
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/monitoring/MonitoringMetricsFetcher.java b/common-app-api/src/main/java/org/openecomp/sdc/common/monitoring/MonitoringMetricsFetcher.java
new file mode 100644
index 0000000000..9df1aea983
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/monitoring/MonitoringMetricsFetcher.java
@@ -0,0 +1,212 @@
+/*-
+ * ============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.common.monitoring;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryMXBean;
+import java.lang.management.RuntimeMXBean;
+import java.lang.management.ThreadMXBean;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.hyperic.sigar.FileSystem;
+import org.hyperic.sigar.Sigar;
+import org.openecomp.sdc.common.impl.ExternalConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MonitoringMetricsFetcher {
+
+ private static Logger monitoringLogger = LoggerFactory.getLogger("asdc.fe.monitoring.fetcher");
+
+ private static volatile MonitoringMetricsFetcher instance;
+ private static RuntimeMXBean runtimeMXBean;
+ private static ThreadMXBean threadMXBean;
+ private static MemoryMXBean memoryMXBean;
+ private static MBeanServer platformMBeanServer;
+ private static Sigar sigarSession;
+
+ private static String appName;
+ private static String jvmName = "Unknown";
+ private final String PROCESS_CPU_TIME_ATTR = "ProcessCpuTime";
+
+ private static String FE_JVM_NAME = "jetty-fe";
+ private static String BE_JVM_NAME = "jetty-be";
+
+ private MonitoringMetricsFetcher() {
+ };
+
+ public static MonitoringMetricsFetcher getInstance() {
+ if (instance == null) {
+ instance = init();
+ }
+ return instance;
+ }
+
+ public MonitoringEvent getMonitoringMetrics() {
+ MonitoringEvent monitoringEvent = new MonitoringEvent();
+ monitoringEvent.setHostid(getFQDN());
+ monitoringEvent.setHostcpu(getHostCpuTime());
+ monitoringEvent.setHostmem(getHostUsedMemory());
+ monitoringEvent.setHostdisk(getHostUsedDisk().toString());
+
+ monitoringEvent.setJvmid(jvmName);
+
+ monitoringEvent.setJvmcpu(getJvmCpuTime());
+ monitoringEvent.setJvmmem(getJvmUsedHeapMemory());
+ monitoringEvent.setJvmtnum(getJvmThreads());
+
+ monitoringEvent.setAppid(appName);
+ // this is probably from healthcheck
+ // TODO
+ monitoringEvent.setAppstat("appStatus");
+ return monitoringEvent;
+ }
+
+ private static synchronized MonitoringMetricsFetcher init() {
+ if (instance == null) {
+ instance = new MonitoringMetricsFetcher();
+ threadMXBean = ManagementFactory.getThreadMXBean();
+ memoryMXBean = ManagementFactory.getMemoryMXBean();
+ runtimeMXBean = ManagementFactory.getRuntimeMXBean();
+ platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
+ sigarSession = new Sigar();
+ appName = ExternalConfiguration.getAppName();
+ monitoringLogger.debug("appName is {}", appName);
+ // Accoridng to Yaki, there is no "calculated" jvmName like it was
+ // in TAS,
+ // just "jetty-be" or "jetty-fe"
+ if (appName.contains("fe")) {
+ jvmName = FE_JVM_NAME;
+ } else if (appName.contains("be")) {
+ jvmName = BE_JVM_NAME;
+ } else {
+ monitoringLogger
+ .warn("Couldn't determine jvmName, appName is expected to contain \"be\" or \"fe\" string");
+ }
+ }
+ return instance;
+ }
+
+ /**
+ * Returns the number of live threads for this JVM
+ *
+ * @return number of live threads
+ */
+ private Integer getJvmThreads() {
+ return threadMXBean.getThreadCount();
+ }
+
+ /**
+ * Returns the number of used heap memory (bytes)
+ *
+ * @return the number of used heap memory (bytes)
+ */
+ private long getJvmUsedHeapMemory() {
+ return memoryMXBean.getHeapMemoryUsage().getUsed();
+ }
+
+ /**
+ * Returns the jvm cpu time (msec)
+ *
+ * @return the jvm cpu time (msec)
+ */
+ private long getJvmCpuTime() {
+
+ long cpuTime = -1;
+ try {
+ cpuTime = (long) platformMBeanServer.getAttribute(
+ new ObjectName(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME), PROCESS_CPU_TIME_ATTR);
+ } catch (Exception e) {
+ monitoringLogger.error("Couldn't measure JVM CPU time, error: {}", e);
+ }
+ return cpuTime;
+ }
+
+ /**
+ * Returns the host total cpu time (msec)
+ *
+ * @return the host total cpu time (msec)
+ */
+ private long getHostCpuTime() {
+ long cpuTime = -1;
+ try {
+ cpuTime = sigarSession.getCpu().getTotal();
+ } catch (Exception e) {
+ monitoringLogger.error("Couldn't measure host CPU time, error: {}", e);
+ }
+ return cpuTime;
+ }
+
+ /**
+ * Returns the host used memory(msec)
+ *
+ * @return the host used memory(msec)
+ */
+ private Double getHostUsedMemory() {
+ Double memory = -1.0;
+ try {
+ memory = sigarSession.getMem().getUsedPercent();
+ } catch (Exception e) {
+ monitoringLogger.error("Couldn't measure host used memory, error: {}", e);
+ }
+ return memory;
+ }
+
+ /**
+ * Returns the percentage of all available FS
+ *
+ * @return the host avail disk(bytes)
+ */
+ private Map<String, Double> getHostUsedDisk() {
+ Map<String, Double> res = new HashMap<>();
+ try {
+ FileSystem[] fileSystemList = sigarSession.getFileSystemList();
+ for (FileSystem fileSystem : fileSystemList) {
+
+ String dirName = fileSystem.getDirName();
+ double usePercent = sigarSession.getFileSystemUsage(dirName).getUsePercent() * 100;
+ res.put(dirName, usePercent);
+ }
+ } catch (Exception e) {
+ monitoringLogger.error("Couldn't measure host used disk, error: {}", e);
+ }
+ return res;
+ }
+
+ /**
+ * Returns the FQDN
+ *
+ * @return the FQDN
+ */
+ private String getFQDN() {
+ String fqdn = "";
+ try {
+ fqdn = sigarSession.getFQDN();
+ } catch (Exception e) {
+ monitoringLogger.error("Couldn't get FQDN, error: {}", e);
+ }
+ return fqdn;
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/rest/api/IRestClient.java b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/api/IRestClient.java
new file mode 100644
index 0000000000..8deb3d7d64
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/api/IRestClient.java
@@ -0,0 +1,103 @@
+/*-
+ * ============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.common.rest.api;
+
+import java.util.Properties;
+
+/**
+ * This interface describe the methods of the REST generic client. Each method
+ * will receive the destination URI and specific list of headers. With this
+ * information the REST Client will create a request to the specific REST Web
+ * server. Error from the REST Web server will be return by proprietary
+ * exception object.
+ *
+ * @author esofer
+ *
+ */
+public interface IRestClient {
+
+ /**
+ * This method will return resource according to the given URI.
+ *
+ * @param uri
+ * Full URL path to the desire resource.
+ * @param headers
+ * - list of headers in format of name and value, to be add as
+ * part of the HTTP request.
+ * @return JSON representation of the requested resource.
+ */
+ public RestResponse doGET(String uri, Properties headers);
+
+ /**
+ * This method will CREATE resource according to the given URI.
+ *
+ * @param uri
+ * Full URL path to the desire resource.
+ * @param headers
+ * - list of headers in format of name and value, to be add as
+ * part of the HTTP request.
+ * @param objectToCreate
+ * - JSON representation of the resource.
+ */
+ public RestResponse doPOST(String uri, Properties headers, Object objectToCreate);
+
+ /**
+ * This method will UPDATE resource according to the given URI.
+ *
+ * @param uri
+ * Full URL path to the desire resource.
+ * @param headers
+ * - list of headers in format of name and value, to be add as
+ * part of the HTTP request.
+ * @param objectToUpdate
+ * - JSON representation of the resource.
+ */
+ public RestResponse doPUT(String uri, Properties headers, Object objectToUpdate);
+
+ /**
+ * This method will return resource according to the given URI.
+ *
+ * @param uri
+ * Full URL path to the desire resource.
+ * @param headers
+ * - list of headers in format of name and value, to be add as
+ * part of the HTTP request.
+ *
+ */
+ public RestResponse doDELETE(String uri, Properties headers);
+
+ /**
+ * initialize the rest client instance. The timeout is infinite.
+ */
+ public boolean init() throws Exception;
+
+ /**
+ * initialize the rest client instance with a given timeout in milliseconds.
+ *
+ * @param restConfigurationInfo
+ */
+ public boolean init(RestConfigurationInfo restConfigurationInfo);
+
+ /**
+ * destroy the connections
+ */
+ public void destroy();
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/rest/api/RestClientServiceExeption.java b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/api/RestClientServiceExeption.java
new file mode 100644
index 0000000000..b64b651913
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/api/RestClientServiceExeption.java
@@ -0,0 +1,78 @@
+/*-
+ * ============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.common.rest.api;
+
+public class RestClientServiceExeption extends Exception {
+
+ private static final long serialVersionUID = 8258477052369440242L;
+
+ /**
+ * Default Constructor.
+ */
+ public RestClientServiceExeption() {
+ super();
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param msg
+ * String
+ */
+ public RestClientServiceExeption(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param cause
+ * Throwable
+ */
+ public RestClientServiceExeption(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param msg
+ * String
+ * @param cause
+ * Throwable
+ */
+ public RestClientServiceExeption(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+
+ /**
+ *
+ * @param response
+ *
+ * public RSClientServiceExeption(ClientResponse response) {
+ * super(); this.response = response; }
+ *
+ * public ClientResponse getResponse() { return response; }
+ *
+ * public void setResponse(ClientResponse response) {
+ * this.response = response; }
+ */
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/rest/api/RestConfigurationInfo.java b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/api/RestConfigurationInfo.java
new file mode 100644
index 0000000000..89a9e24dff
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/api/RestConfigurationInfo.java
@@ -0,0 +1,107 @@
+/*-
+ * ============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.common.rest.api;
+
+import org.openecomp.sdc.common.api.BasicConfiguration;
+
+public class RestConfigurationInfo extends BasicConfiguration {
+
+ private Integer readTimeoutInSec = null;
+
+ private Boolean ignoreCertificate = null;
+
+ private Integer connectionPoolSize = null;
+
+ private Integer connectTimeoutInSec = null;
+
+ /**
+ * @return the readTimeoutInSec
+ */
+ public Integer getReadTimeoutInSec() {
+ return readTimeoutInSec;
+ }
+
+ /**
+ * @param readTimeoutInSec
+ * the readTimeoutInSec to set
+ */
+ public void setReadTimeoutInSec(Integer readTimeoutInSec) {
+ this.readTimeoutInSec = readTimeoutInSec;
+ }
+
+ /**
+ * @return the ignoreCertificate
+ */
+ public Boolean getIgnoreCertificate() {
+ return ignoreCertificate;
+ }
+
+ /**
+ * @param ignoreCertificate
+ * the ignoreCertificate to set
+ */
+ public void setIgnoreCertificate(Boolean ignoreCertificate) {
+ this.ignoreCertificate = ignoreCertificate;
+ }
+
+ /**
+ * @return the connectionPoolSize
+ */
+ public Integer getConnectionPoolSize() {
+ return connectionPoolSize;
+ }
+
+ /**
+ * @param connectionPoolSize
+ * the connectionPoolSize to set
+ */
+ public void setConnectionPoolSize(Integer connectionPoolSize) {
+ this.connectionPoolSize = connectionPoolSize;
+ }
+
+ /**
+ * @return the connectTimeoutInSec
+ */
+ public Integer getConnectTimeoutInSec() {
+ return connectTimeoutInSec;
+ }
+
+ /**
+ * @param connectTimeoutInSec
+ * the connectTimeoutInSec to set
+ */
+ public void setConnectTimeoutInSec(Integer connectTimeoutInSec) {
+ this.connectTimeoutInSec = connectTimeoutInSec;
+ }
+
+ public String toString() {
+
+ StringBuilder builder = new StringBuilder();
+
+ builder.append("[ timeoutInSec=" + readTimeoutInSec + ",");
+ builder.append("connectTimeoutInSec=" + connectTimeoutInSec + ",");
+ builder.append("ignoreCertificate=" + ignoreCertificate + ",");
+ builder.append("connectionPoolSize=" + connectionPoolSize + "]");
+
+ return builder.toString();
+
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/rest/api/RestResponse.java b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/api/RestResponse.java
new file mode 100644
index 0000000000..b08cf7332b
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/api/RestResponse.java
@@ -0,0 +1,108 @@
+/*-
+ * ============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.common.rest.api;
+
+public class RestResponse {
+
+ private String response;
+
+ private String statusDescription;
+
+ private int httpStatusCode = 0;
+
+ public RestResponse(String response, String statusDescription, int httpStatusCode) {
+ super();
+ this.response = response;
+ this.statusDescription = statusDescription;
+ this.httpStatusCode = httpStatusCode;
+ }
+
+ /**
+ * @return the response
+ */
+ public String getResponse() {
+ return response;
+ }
+
+ /**
+ * @param response
+ * the response to set
+ */
+ public void setResponse(String response) {
+ this.response = response;
+ }
+
+ /**
+ * @return the httpStatusCode
+ */
+ public int getHttpStatusCode() {
+ return httpStatusCode;
+ }
+
+ /**
+ * @param httpStatusCode
+ * the httpStatusCode to set
+ */
+ public void setHttpStatusCode(int httpStatusCode) {
+ this.httpStatusCode = httpStatusCode;
+ }
+
+ /**
+ * @return the statusDescription
+ */
+ public String getStatusDescription() {
+ return statusDescription;
+ }
+
+ /**
+ * @param statusDescription
+ * the statusDescription to set
+ */
+ public void setStatusDescription(String statusDescription) {
+ this.statusDescription = statusDescription;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ *
+ * ERROR: Error from Rest Server:Status: 400 Message: Bad Request Body:
+ * Invalid cell: Cell with cell name dmgrCell22 does not exist!
+ *
+ */
+ public String toString() {
+
+ StringBuilder stringBuilder = new StringBuilder();
+
+ stringBuilder.append("Status: ");
+ stringBuilder.append(httpStatusCode);
+ stringBuilder.append("\n");
+ stringBuilder.append("Message: ");
+ stringBuilder.append(statusDescription);
+ stringBuilder.append("\n");
+ stringBuilder.append("Body: ");
+ stringBuilder.append(response);
+
+ return stringBuilder.toString();
+
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/rest/api/RestResponseAsByteArray.java b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/api/RestResponseAsByteArray.java
new file mode 100644
index 0000000000..7a4d8ee4cb
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/api/RestResponseAsByteArray.java
@@ -0,0 +1,133 @@
+/*-
+ * ============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.common.rest.api;
+
+import java.util.Arrays;
+
+import org.apache.http.HttpStatus;
+
+public class RestResponseAsByteArray {
+
+ private byte[] response;
+
+ private String statusDescription;
+
+ private int httpStatusCode = 0;
+
+ public RestResponseAsByteArray(byte[] response, String statusDescription, int httpStatusCode) {
+ super();
+ this.response = response;
+ this.statusDescription = statusDescription;
+ this.httpStatusCode = httpStatusCode;
+ }
+
+ /**
+ * @return the response
+ */
+ public byte[] getResponse() {
+ return response;
+ }
+
+ /**
+ * @param response
+ * the response to set
+ */
+ public void setResponse(byte[] response) {
+ this.response = response;
+ }
+
+ /**
+ * @return the httpStatusCode
+ */
+ public int getHttpStatusCode() {
+ return httpStatusCode;
+ }
+
+ /**
+ * @param httpStatusCode
+ * the httpStatusCode to set
+ */
+ public void setHttpStatusCode(int httpStatusCode) {
+ this.httpStatusCode = httpStatusCode;
+ }
+
+ /**
+ * @return the statusDescription
+ */
+ public String getStatusDescription() {
+ return statusDescription;
+ }
+
+ /**
+ * @param statusDescription
+ * the statusDescription to set
+ */
+ public void setStatusDescription(String statusDescription) {
+ this.statusDescription = statusDescription;
+ }
+
+ public String toString() {
+
+ StringBuilder stringBuilder = new StringBuilder();
+
+ stringBuilder.append("Status: ");
+ stringBuilder.append(httpStatusCode);
+ stringBuilder.append("\n");
+ stringBuilder.append("Message: ");
+ stringBuilder.append(statusDescription);
+ stringBuilder.append("\n");
+ stringBuilder.append("Body length: ");
+ stringBuilder.append(response == null ? 0 : response.length);
+
+ return stringBuilder.toString();
+
+ }
+
+ public String toPrettyString() {
+
+ int maxBytesToDisplay = 200;
+
+ StringBuilder stringBuilder = new StringBuilder();
+
+ stringBuilder.append("Status: ");
+ stringBuilder.append(httpStatusCode);
+ stringBuilder.append("\n");
+ stringBuilder.append("Message: ");
+ stringBuilder.append(statusDescription);
+ stringBuilder.append("\n");
+ if (httpStatusCode != HttpStatus.SC_OK) {
+ stringBuilder.append("Body(maximum " + maxBytesToDisplay + " bytes): ");
+ if (response != null) {
+ byte[] subArray = Arrays.copyOfRange(response, 0, Math.min(maxBytesToDisplay, response.length));
+ if (subArray != null && subArray.length > 0) {
+ String responseStr = new String(subArray);
+ stringBuilder.append(responseStr);
+ }
+ }
+ } else {
+ stringBuilder.append("Body length: ");
+ stringBuilder.append(response == null ? 0 : response.length);
+ }
+
+ return stringBuilder.toString();
+
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/HttpRestClientServiceImpl.java b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/HttpRestClientServiceImpl.java
new file mode 100644
index 0000000000..7175b41943
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/HttpRestClientServiceImpl.java
@@ -0,0 +1,436 @@
+/*-
+ * ============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.common.rest.impl;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.util.Map.Entry;
+import java.util.Properties;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLException;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.TrustManager;
+
+import org.apache.http.ConnectionReuseStrategy;
+import org.apache.http.HeaderElement;
+import org.apache.http.HeaderElementIterator;
+import org.apache.http.HeaderIterator;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.conn.ConnectionKeepAliveStrategy;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.conn.ssl.X509HostnameVerifier;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.PoolingClientConnectionManager;
+import org.apache.http.message.BasicHeaderElementIterator;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.CoreConnectionPNames;
+import org.apache.http.params.HttpParams;
+import org.apache.http.protocol.HTTP;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.EntityUtils;
+import org.openecomp.sdc.common.rest.api.IRestClient;
+import org.openecomp.sdc.common.rest.api.RestClientServiceExeption;
+import org.openecomp.sdc.common.rest.api.RestConfigurationInfo;
+import org.openecomp.sdc.common.rest.api.RestResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class HttpRestClientServiceImpl implements IRestClient {
+
+ private Logger log = LoggerFactory.getLogger(HttpRestClientServiceImpl.class.getName());
+
+ public final static int DEFAULT_CONNECTION_POOL_SIZE = 10;
+
+ public final static int DEFAULT_CONNECT_TIMEOUT = 10;
+
+ private DefaultHttpClient httpClient;
+
+ private SSLSocketFactory sslFactory;
+
+ private Logger logger = LoggerFactory.getLogger(HttpRestClientServiceImpl.class.getName());
+
+ PoolingClientConnectionManager cm = null;
+
+ public boolean init() {
+
+ return init(new RestConfigurationInfo());
+
+ }
+
+ public boolean init(RestConfigurationInfo restConfigurationInfo) {
+
+ boolean initialized = false;
+
+ logger.debug("HttpRestClientServiceImpl::init - start. restConfigurationInfo=" + restConfigurationInfo);
+
+ try {
+ createHttpClient(restConfigurationInfo);
+
+ initialized = true;
+ } catch (KeyManagementException e) {
+ String msg = "Failed creating client config for rest. " + e.getMessage();
+ logger.error(msg, e);
+ // throw new RestClientServiceExeption(e.getMessage());
+ } catch (NoSuchAlgorithmException e) {
+ String msg = "Failed creating client config for rest. " + e.getMessage();
+ logger.error(msg, e);
+ // throw new RestClientServiceExeption(msg);
+ }
+
+ logger.debug("HttpRestClientServiceImpl::init - finish successfully");
+
+ return initialized;
+ }
+
+ public void destroy() {
+
+ if (this.httpClient != null) {
+ this.httpClient.getConnectionManager().shutdown();
+ logger.info("After closing connection Manager of rest Client.");
+ }
+
+ }
+
+ private void createHttpClient(RestConfigurationInfo restConfigurationInfo)
+ throws KeyManagementException, NoSuchAlgorithmException {
+
+ PoolingClientConnectionManager cm = new PoolingClientConnectionManager();
+
+ Integer connPoolSizeObj = restConfigurationInfo.getConnectionPoolSize();
+ int connPoolSize = DEFAULT_CONNECTION_POOL_SIZE;
+ if (connPoolSizeObj != null) {
+ connPoolSize = connPoolSizeObj.intValue();
+ if (connPoolSize <= 0) {
+ connPoolSize = DEFAULT_CONNECTION_POOL_SIZE;
+ }
+ }
+ cm.setMaxTotal(connPoolSize);
+
+ this.httpClient = new DefaultHttpClient(cm);
+
+ int timeoutInSec = restConfigurationInfo.getReadTimeoutInSec() == null ? 0
+ : restConfigurationInfo.getReadTimeoutInSec();
+ int connectTimeoutInSec = restConfigurationInfo.getConnectTimeoutInSec() == null ? DEFAULT_CONNECT_TIMEOUT
+ : restConfigurationInfo.getConnectTimeoutInSec();
+ HttpParams params = new BasicHttpParams();
+ params.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, connectTimeoutInSec * 1000);
+ params.setParameter(CoreConnectionPNames.SO_TIMEOUT, timeoutInSec * 1000);
+
+ this.httpClient.setParams(params);
+
+ Boolean ignoreCertificateObj = restConfigurationInfo.getIgnoreCertificate();
+ boolean ignoreCertificate = false;
+ if (ignoreCertificateObj != null) {
+ ignoreCertificate = ignoreCertificateObj.booleanValue();
+ }
+ if (ignoreCertificate == true) {
+
+ this.sslFactory = createSSLSocketFactory();
+
+ Scheme scheme = new Scheme("https", 9443, sslFactory);
+ this.httpClient.getConnectionManager().getSchemeRegistry().register(scheme);
+ }
+
+ // addKeepAlive();
+
+ this.cm = cm;
+ }
+
+ private void addKeepAlive() {
+
+ this.httpClient.setReuseStrategy(new ConnectionReuseStrategy() {
+
+ public boolean keepAlive(HttpResponse response, HttpContext context) {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+ });
+
+ this.httpClient.setKeepAliveStrategy(new ConnectionKeepAliveStrategy() {
+
+ public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
+ log.debug("============ In getKeepAliveDuration ================= ");
+
+ HeaderIterator headerIterator = response.headerIterator(HTTP.CONN_KEEP_ALIVE);
+ if (headerIterator != null) {
+ HeaderElementIterator it = new BasicHeaderElementIterator(headerIterator);
+ while (it.hasNext()) {
+ HeaderElement he = it.nextElement();
+ String param = he.getName();
+ String value = he.getValue();
+ if (value != null && param.equalsIgnoreCase("timeout")) {
+ try {
+ log.debug("============ In getKeepAliveDuration ================= {}", value);
+
+ return Long.parseLong(value) * 1000;
+ } catch (NumberFormatException ignore) {
+ log.error("Failed parsing retrieved value of timeout header.", ignore);
+ }
+ }
+ }
+ }
+ return 20;
+ }
+ });
+
+ }
+
+ protected SSLSocketFactory createSSLSocketFactory() throws NoSuchAlgorithmException, KeyManagementException {
+ TrustManager easyTrustManager = new javax.net.ssl.X509TrustManager() {
+
+ public void checkClientTrusted(java.security.cert.X509Certificate[] arg0, String arg1)
+ throws CertificateException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void checkServerTrusted(java.security.cert.X509Certificate[] arg0, String arg1)
+ throws CertificateException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ };
+
+ SSLContext sslContext = SSLContext.getInstance("TLS");
+ sslContext.init(null, new TrustManager[] { easyTrustManager }, null);
+ SSLSocketFactory sslFactory = new SSLSocketFactory(sslContext);
+
+ sslFactory.setHostnameVerifier(new X509HostnameVerifier() {
+
+ public boolean verify(String arg0, SSLSession arg1) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void verify(String host, SSLSocket ssl) throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void verify(String host, java.security.cert.X509Certificate cert) throws SSLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void verify(String host, String[] cns, String[] subjectAlts) throws SSLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ });
+ return sslFactory;
+ }
+
+ /**
+ * Executes RS-GET to perform FIND.
+ *
+ * @param headerParameterKey
+ * String
+ * @param headerParameterValue
+ * String
+ * @return String
+ */
+ public RestResponse doGET(String uri, Properties headers) {
+ logger.debug("Before executing uri " + uri + ". headers = " + headers);
+
+ HttpGet httpGet = new HttpGet(uri);
+
+ RestResponse response = execute(httpGet, headers);
+
+ return response;
+ }
+
+ private void addHeadersToRequest(HttpRequestBase httpRequestBase, Properties headers) {
+
+ if (headers != null) {
+ for (Entry<Object, Object> entry : headers.entrySet()) {
+ httpRequestBase.addHeader(entry.getKey().toString(), entry.getValue().toString());
+ }
+ }
+
+ }
+
+ public RestResponse doPOST(String uri, Properties headers, Object objectToCreate) {
+
+ logger.debug("Before executing uri " + uri + ". body = "
+ + (objectToCreate != null ? objectToCreate.toString() : null) + ". headers = " + headers);
+
+ HttpPost httpPost = new HttpPost(uri);
+
+ if (objectToCreate != null) {
+ StringEntity se;
+ try {
+ se = new StringEntity(objectToCreate.toString());
+
+ // se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,
+ // "application/json"));
+ httpPost.setEntity(se);
+ } catch (UnsupportedEncodingException e) {
+ String msg = "Failed creating Entity for post request." + e.getMessage();
+ log.error(msg, e);
+ return null;
+ // throw new RestClientServiceExeption(msg);
+ }
+ }
+
+ RestResponse response = execute(httpPost, headers);
+
+ return response;
+
+ }
+
+ public RestResponse doPUT(String uri, Properties headers, Object objectToCreate) {
+
+ logger.debug("Before executing uri " + uri + ". body = "
+ + (objectToCreate != null ? objectToCreate.toString() : null) + ". headers = " + headers);
+
+ HttpPut httpPut = new HttpPut(uri);
+
+ if (objectToCreate != null) {
+ StringEntity se;
+ try {
+ se = new StringEntity(objectToCreate.toString());
+
+ // se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,
+ // "application/json"));
+ httpPut.setEntity(se);
+ } catch (UnsupportedEncodingException e) {
+ String msg = "Failed creating Entity for post request." + e.getMessage();
+ // throw new RestClientServiceExeption(msg);
+ log.error(msg, e);
+ return null;
+ }
+ }
+
+ RestResponse response = execute(httpPut, headers);
+
+ return response;
+ }
+
+ private RestResponse execute(HttpRequestBase httpRequestBase, Properties headers) {
+
+ String response = null;
+ String statusDesc = null;
+ int statusCode = HttpStatus.SC_OK;
+
+ try {
+
+ addHeadersToRequest(httpRequestBase, headers);
+
+ HttpResponse httpResponse = this.httpClient.execute(httpRequestBase);
+
+ statusCode = httpResponse.getStatusLine().getStatusCode();
+ statusDesc = httpResponse.getStatusLine().getReasonPhrase();
+
+ HttpEntity entity = httpResponse.getEntity();
+ if (entity != null) {
+ response = EntityUtils.toString(entity);
+ }
+ // ensure the connection gets released to the manager
+ EntityUtils.consume(entity);
+
+ logResponse(response, httpRequestBase.getMethod());
+
+ } catch (Exception exception) {
+ httpRequestBase.abort();
+ log.error("Failed to execute the " + httpRequestBase.getMethod() + " request " + httpRequestBase.getURI(),
+ exception);
+ // processAndThrowException(exception);
+ return null;
+ }
+
+ RestResponse restResponse = new RestResponse(response, statusDesc, statusCode);
+
+ if (logger.isDebugEnabled()) {
+ URI uri = httpRequestBase.getURI();
+ String url = uri.toString();
+ logger.debug("After executing uri " + url + ". response = " + restResponse);
+ }
+
+ return restResponse;
+ }
+
+ public RestResponse doDELETE(String uri, Properties headers) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Before executing uri " + uri + ". headers = " + headers);
+ }
+
+ HttpDelete httpDelete = new HttpDelete(uri);
+
+ RestResponse restResponse = execute(httpDelete, headers);
+
+ return restResponse;
+
+ }
+
+ /**
+ * This method print the JSON response from the REST Server
+ *
+ * @param response
+ * the JSON response from the REST server
+ * @param method
+ * name of method
+ */
+ private void logResponse(String response, String method) {
+ logger.debug(method + " response = " + response);
+ }
+
+ /**
+ * Exception during client invocation usually it happens when status code
+ * starting with 400 or 500 is returned
+ *
+ * @param exception
+ * Exception
+ * @throws RSClientServiceExeption
+ */
+ private void processAndThrowException(Exception exception) throws RestClientServiceExeption {
+
+ logger.debug("\n------------------------");
+ logger.debug("FAILURE: " + exception.getMessage());
+
+ throw new RestClientServiceExeption(exception);
+
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/RestClientServiceFactory.java b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/RestClientServiceFactory.java
new file mode 100644
index 0000000000..5bf250f59c
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/RestClientServiceFactory.java
@@ -0,0 +1,48 @@
+/*-
+ * ============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.common.rest.impl;
+
+import org.openecomp.sdc.common.rest.api.IRestClient;
+import org.openecomp.sdc.common.rest.api.RestConfigurationInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RestClientServiceFactory {
+
+ private static Logger log = LoggerFactory.getLogger(RestClientServiceFactory.class.getName());
+
+ public static IRestClient createRestClientService(RestConfigurationInfo restConfigurationInfo) {
+
+ log.trace("Enter createRestClientService");
+
+ HttpRestClientServiceImpl restClientServiceImpl = new HttpRestClientServiceImpl();
+
+ boolean result = restClientServiceImpl.init(restConfigurationInfo);
+ if (result == false) {
+ return null;
+ }
+
+ log.trace("Exit createRestClientService");
+
+ return restClientServiceImpl;
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/validator/RequestHeadersValidator.java b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/validator/RequestHeadersValidator.java
new file mode 100644
index 0000000000..5e2ff37735
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/validator/RequestHeadersValidator.java
@@ -0,0 +1,95 @@
+/*-
+ * ============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.common.rest.impl.validator;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.commons.codec.binary.Base64;
+import org.openecomp.sdc.common.api.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RequestHeadersValidator {
+ private static Logger log = LoggerFactory.getLogger(RequestHeadersValidator.class.getName());
+
+ public static void validateContentType(HttpServletRequest request, MediaType expectedContentType,
+ Map<String, String> headersMap) throws RestRequestValidationException {
+
+ log.debug("validateContentType - expected: " + expectedContentType);
+ if (request == null || expectedContentType == null) {
+ throw new RestRequestValidationException("request or media-type are null");
+ }
+ String contentType = request.getHeader(Constants.CONTENT_TYPE_HEADER);
+ if (contentType == null || !contentType.contains(MediaType.APPLICATION_JSON)) {
+ throw new RestRequestValidationException(
+ "Content-Type of requset is different then " + expectedContentType);
+ } else {
+ headersMap.put(Constants.CONTENT_TYPE_HEADER, contentType);
+ }
+ }
+
+ public static void validateIdentificationHeaders(HttpServletRequest request, List<String> identificationList,
+ Map<String, String> headersMap) throws RestRequestValidationException {
+
+ log.debug("validateIdentificationHeaders");
+ for (String requiredHeader : identificationList) {
+ String headerVal = request.getHeader(requiredHeader);
+ if (headerVal != null && !headerVal.isEmpty()) {
+ headersMap.put(requiredHeader, headerVal);
+ log.debug("found header - " + requiredHeader + ": " + headerVal);
+ } else {
+ log.error("missing identification header: " + requiredHeader);
+ throw new RestRequestValidationException("missing identification header: " + requiredHeader);
+ }
+ }
+
+ }
+
+ public static void validateMd5(byte[] encodedData, HttpServletRequest request, Map<String, String> headersMap)
+ throws RestRequestValidationException {
+
+ // validate parameters
+ if (encodedData == null || request == null) {
+ throw new RestRequestValidationException("encoded data or request are not valid");
+ }
+
+ // calculate MD5 on the data
+ String md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(encodedData);
+ byte[] encodedMd5 = Base64.encodeBase64(md5.getBytes());
+
+ // read the Content-MD5 header
+ String origMd5 = request.getHeader(Constants.MD5_HEADER);
+ if ((origMd5 == null) || origMd5.isEmpty()) {
+ throw new RestRequestValidationException("missing Content-MD5 header ");
+ }
+
+ // verify MD5 value
+ if (!origMd5.equals(new String(encodedMd5))) {
+ throw new RestRequestValidationException("uploaded file failed MD5 validation");
+ }
+ headersMap.put(Constants.MD5_HEADER, origMd5);
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/validator/RestRequestValidationException.java b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/validator/RestRequestValidationException.java
new file mode 100644
index 0000000000..90ed39e1c2
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/validator/RestRequestValidationException.java
@@ -0,0 +1,34 @@
+/*-
+ * ============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.common.rest.impl.validator;
+
+public class RestRequestValidationException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1962654783383591672L;
+
+ public RestRequestValidationException(String message) {
+ super(message);
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/servlets/BasicServlet.java b/common-app-api/src/main/java/org/openecomp/sdc/common/servlets/BasicServlet.java
new file mode 100644
index 0000000000..816ebe3416
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/servlets/BasicServlet.java
@@ -0,0 +1,30 @@
+/*-
+ * ============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.common.servlets;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+public abstract class BasicServlet {
+
+ protected Gson gson = new GsonBuilder().setPrettyPrinting().create();
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/CapabilityTypeNameEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/CapabilityTypeNameEnum.java
new file mode 100644
index 0000000000..cb78b8ed9b
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/CapabilityTypeNameEnum.java
@@ -0,0 +1,46 @@
+/*-
+ * ============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.common.util;
+
+public enum CapabilityTypeNameEnum {
+ ROOT("tosca.capabilities.Root"),
+ NODE("tosca.capabilities.Node"),
+ CONTAINER("tosca.capabilities.Container"),
+ ENDPOINT("tosca.capabilities.Endpoint"),
+ ENDPOINT_PUBLIC("tosca.capabilities.Endpoint.Public"),
+ ENDPOINT_ADMIN("tosca.capabilities.Endpoint.Admin"),
+ ENDPOINT_DATABASE("tosca.capabilities.Endpoint.Database"),
+ OPERATING_SYSTEM("tosca.capabilities.OperatingSystem"),
+ SCALABLE("tosca.capabilities.Scalable"),
+ BINDABLE("tosca.capabilities.network.Bindable"),
+ DOCKER("tosca.capabilities.Container.Docker"),
+ ATTACHMENT("tosca.capabilities.Attachment");
+
+ private String capabilityName;
+
+ private CapabilityTypeNameEnum(String capName) {
+ this.capabilityName = capName;
+ }
+
+ public String getCapabilityName() {
+ return capabilityName;
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/GeneralUtility.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/GeneralUtility.java
new file mode 100644
index 0000000000..0c62b03d14
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/GeneralUtility.java
@@ -0,0 +1,150 @@
+/*-
+ * ============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.common.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.regex.Pattern;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.io.FileUtils;
+import org.openecomp.sdc.common.api.Constants;
+
+public class GeneralUtility {
+
+ public static boolean generateTextFile(String fileName, String fileData) {
+ boolean isSuccessfull = true;
+ try {
+ FileUtils.writeStringToFile(new File(fileName), fileData);
+ } catch (IOException e) {
+ isSuccessfull = false;
+ }
+ return isSuccessfull;
+ }
+
+ public static boolean isBase64Encoded(byte[] data) {
+ return Base64.isBase64(data);
+ }
+
+ public static boolean isBase64Encoded(String str) {
+ boolean isEncoded = false;
+ try {
+ // checks if the string was properly padded to the
+ isEncoded = ((str.length() % 4 == 0) && (Pattern.matches("\\A[a-zA-Z0-9/+]+={0,2}\\z", str)));
+ if (isEncoded) {
+ // If no exception is caught, then it is possibly a base64
+ // encoded string
+ byte[] data = Base64.decodeBase64(str);
+ }
+
+ } catch (Exception e) {
+ // If exception is caught, then it is not a base64 encoded string
+ isEncoded = false;
+ }
+ return isEncoded;
+ }
+
+ /**
+ * Checks whether the passed string exceeds a limit of number of characters.
+ *
+ * @param str str
+ * @param limit limit
+ * @return the result of comparison, or false if str is null.
+ */
+ public static boolean isExceedingLimit(String str, int limit) {
+ if (str == null) {
+ return false;
+ }
+ return str.length() > limit;
+ }
+
+ /**
+ * Checks the passed string list whether the cumulative length of strings
+ * and delimiters between them exceeds a limit of number of characters. For
+ * example for list ("one","two","three") with delimiter "," the length of
+ * list is calculated 3+1+3+1+5=13
+ *
+ * @param strList strList
+ * @param limit Limit
+ * @param delimiterLength delimiterLength
+ * - 0 if there is no delimeter.
+ * @return the result of comparison, or false if strList is null.
+ */
+ public static boolean isExceedingLimit(List<String> strList, int limit, int delimiterLength) {
+ if (strList == null || strList.isEmpty()) {
+ return false;
+ }
+ int sum = 0;
+ int size = strList.size();
+ for (int i = 0; i < size - 1; i++) {
+ String str = strList.get(i);
+ if (str != null) {
+ sum += str.length();
+ }
+ sum += delimiterLength;
+ }
+ String str = strList.get(size - 1);
+ if (str != null) {
+ sum += str.length();
+ }
+ return sum > limit;
+ }
+
+ /**
+ * Return the extension as the substring from the last dot. For input
+ * "kuku.txt", "txt" will be returned. If no dot is found or input is null,
+ * empty string is returned.
+ *
+ * @param fileName fileName
+ * @return extension
+ */
+ public static String getFilenameExtension(String fileName) {
+ String res = Constants.EMPTY_STRING;
+ if (fileName != null) {
+ int indexOf = fileName.lastIndexOf('.');
+ if (indexOf != -1 && indexOf < (fileName.length() - 1)) {
+ res = fileName.substring(indexOf + 1);
+ }
+ }
+ return res;
+ }
+
+ public static String calculateMD5ByByteArray(byte[] payload) {
+ String decodedMd5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(payload);
+ byte[] encodeMd5 = Base64.encodeBase64(decodedMd5.getBytes());
+ return new String(encodeMd5);
+
+ }
+
+ /**
+ *
+ * @param data data
+ * @return
+ */
+ public static String calculateMD5ByString(String data) {
+ String calculatedMd5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(data);
+
+ // encode base-64 result
+ byte[] encodeBase64 = Base64.encodeBase64(calculatedMd5.getBytes());
+ return new String(encodeBase64);
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/GsonFactory.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/GsonFactory.java
new file mode 100644
index 0000000000..7c3bcb6cad
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/GsonFactory.java
@@ -0,0 +1,40 @@
+/*-
+ * ============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.common.util;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+public class GsonFactory {
+ private static Gson gson = null;
+
+ public static Gson getGson() {
+ if (gson == null) {
+ synchronized (GsonFactory.class) {
+ if (gson == null) {
+ gson = new GsonBuilder().disableHtmlEscaping().serializeNulls().create();
+ }
+ }
+ }
+
+ return gson;
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/HtmlCleaner.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/HtmlCleaner.java
new file mode 100644
index 0000000000..4cbd9a7760
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/HtmlCleaner.java
@@ -0,0 +1,112 @@
+/*-
+ * ============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.common.util;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.HTML.Tag;
+
+import org.apache.commons.lang3.StringEscapeUtils;
+
+public class HtmlCleaner {
+
+ private static Set<String> htmlTags = new HashSet<>();
+
+ private static String patternHtmlFullTagStr = "</?\\w+((\\s+\\w+(\\s*=\\s*(?:\".*?\"|'.*?'|[\\^'\">\\s]+))?)+\\s*|\\s*)/?>";
+
+ private static String patternHtmlTagOnlyStr = "</?(\\w+)[^>]*/?>";
+
+ private static Pattern onlyTagPattern = Pattern.compile(patternHtmlTagOnlyStr);
+
+ private static Pattern fullTagPattern = Pattern.compile(patternHtmlFullTagStr);
+
+ static {
+ Tag[] allTags = HTML.getAllTags();
+ for (Tag tag : allTags) {
+ htmlTags.add(tag.toString().toLowerCase());
+ }
+ }
+
+ public static String stripHtml(String input) {
+
+ return stripHtml(input, false);
+
+ }
+
+ public static String stripHtml(String input, boolean toEscape) {
+
+ if (input == null || true == input.isEmpty()) {
+ return input;
+ }
+
+ Matcher matcher = onlyTagPattern.matcher(input);
+
+ Set<String> tagsToRemove = new HashSet<>();
+
+ while (matcher.find()) {
+
+ int start = matcher.start();
+ int end = matcher.end();
+
+ String matchTag = input.substring(start, end);
+
+ int groupCount = matcher.groupCount();
+
+ if (groupCount > 0) {
+ String tag = matcher.group(1);
+ if (tag != null && htmlTags.contains(tag.toLowerCase())) {
+ if (false == tagsToRemove.contains(matchTag)) {
+ tagsToRemove.add(matchTag);
+ }
+ }
+ }
+ }
+
+ String stripHtmlStr = removeTagsFromString(tagsToRemove, input);
+
+ if (stripHtmlStr != null) {
+ if (true == toEscape) {
+ stripHtmlStr = StringEscapeUtils.escapeHtml4(stripHtmlStr);
+ }
+ }
+
+ return stripHtmlStr;
+
+ }
+
+ private static String removeTagsFromString(Set<String> tagsToRemove, String input) {
+
+ String stripStr = input;
+ if (input == null || true == tagsToRemove.isEmpty()) {
+ return input;
+ }
+
+ for (String tag : tagsToRemove) {
+ stripStr = stripStr.replaceAll(tag, "");
+ }
+ return stripStr;
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/HttpUtil.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/HttpUtil.java
new file mode 100644
index 0000000000..f4f34a9934
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/HttpUtil.java
@@ -0,0 +1,81 @@
+/*-
+ * ============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.common.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.HttpServletRequest;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+import fj.data.Either;
+
+public class HttpUtil {
+ public static Either<String, IOException> readJsonStringFromRequest(HttpServletRequest request) {
+ Either<String, IOException> eitherResult;
+ try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
+ ServletInputStream reader = request.getInputStream();
+ int value;
+ while ((value = reader.read()) != -1) {
+ stream.write(value);
+ }
+ eitherResult = Either.left(new String(stream.toByteArray()));
+ } catch (IOException e) {
+ eitherResult = Either.right(e);
+ }
+ return eitherResult;
+
+ }
+
+ /**
+ * Builds an object from a JSON in the POST Body of the request.
+ */
+ public static <T> Either<T, Exception> getObjectFromJson(HttpServletRequest request, Class<T> classOfT) {
+ Either<T, Exception> eitherResult;
+ try {
+ Either<String, IOException> eitherReadJson = readJsonStringFromRequest(request);
+ if (eitherReadJson.isLeft()) {
+ eitherResult = convertJsonStringToObject(eitherReadJson.left().value(), classOfT);
+ } else {
+ eitherResult = Either.right((Exception) eitherReadJson.right().value());
+ }
+ } catch (Exception e) {
+ eitherResult = Either.right(e);
+ }
+
+ return eitherResult;
+ }
+
+ public static <T> Either<T, Exception> convertJsonStringToObject(String sentJson, Class<T> classOfT) {
+ Either<T, Exception> eitherResult;
+ try {
+ Gson gson = new GsonBuilder().setPrettyPrinting().create();
+ T object = gson.fromJson(sentJson, classOfT);
+ eitherResult = Either.left(object);
+ } catch (Exception e) {
+ eitherResult = Either.right(e);
+ }
+ return eitherResult;
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/JsonUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/JsonUtils.java
new file mode 100644
index 0000000000..30d70cd019
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/JsonUtils.java
@@ -0,0 +1,45 @@
+/*-
+ * ============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.common.util;
+
+import com.google.gson.JsonElement;
+
+public class JsonUtils {
+
+ public static String toString(JsonElement jsonElement) {
+
+ if (jsonElement == null) {
+ return null;
+ }
+
+ if (false == jsonElement.isJsonNull()) {
+ if (false == jsonElement.isJsonObject()) {
+ return jsonElement.getAsString();
+ } else {
+ return jsonElement.toString();
+ }
+ } else {
+ return null;
+ }
+
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/MethodActivationStatusEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/MethodActivationStatusEnum.java
new file mode 100644
index 0000000000..bba04fa359
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/MethodActivationStatusEnum.java
@@ -0,0 +1,25 @@
+/*-
+ * ============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.common.util;
+
+public enum MethodActivationStatusEnum {
+ SUCCESS, NOT_ALLOWED, FAILED, NOT_FOUND;
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/SerializationUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/SerializationUtils.java
new file mode 100644
index 0000000000..ee2895f9fa
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/SerializationUtils.java
@@ -0,0 +1,87 @@
+/*-
+ * ============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.common.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+
+import org.nustaq.serialization.FSTConfiguration;
+import org.openecomp.sdc.be.config.BeEcompErrorManager;
+import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import fj.data.Either;
+
+public class SerializationUtils {
+
+ private static Logger log = LoggerFactory.getLogger(SerializationUtils.class.getName());
+
+ private static FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();
+
+ public static Either<byte[], Boolean> serialize(Object object) {
+
+ try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(bos)) {
+ out.writeObject(object);
+ return Either.left(bos.toByteArray());
+ } catch (Exception e) {
+ log.debug("Failed to serialize object", e);
+ return Either.right(false);
+ }
+ }
+
+ public static Either<Object, Boolean> deserialize(byte[] bytes) {
+
+ try (ByteArrayInputStream bis = new ByteArrayInputStream(bytes); ObjectInput in = new ObjectInputStream(bis)) {
+ return Either.left(in.readObject());
+ } catch (Exception e) {
+ log.debug("Failed to deserialize object", e);
+ return Either.right(false);
+ }
+ }
+
+ public static Either<byte[], Boolean> serializeExt(Object object) {
+ try {
+ byte[] value = conf.asByteArray(object);
+ return Either.left(value);
+ } catch (Exception e) {
+ return Either.right(false);
+ }
+ }
+
+ public static <T> Either<T, Boolean> deserializeExt(byte[] bytes, Class<T> clazz, String componentName) {
+ try {
+ Object object = conf.asObject(bytes);
+ T castObject = clazz.cast(object);
+ return Either.left(castObject);
+ } catch (Exception e) {
+ log.debug("Failed to deserialize object of type " + clazz + " and uid " + componentName, e);
+ BeEcompErrorManager.getInstance().logInternalUnexpectedError("DeserializeObjectFromCache",
+ "Failed to deserialize object of type " + clazz, ErrorSeverity.WARNING);
+ return Either.right(false);
+ }
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/StreamUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/StreamUtils.java
new file mode 100644
index 0000000000..90371a3403
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/StreamUtils.java
@@ -0,0 +1,136 @@
+/*-
+ * ============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.common.util;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Spliterator;
+import java.util.Spliterators.AbstractSpliterator;
+import java.util.function.Consumer;
+import java.util.function.Predicate;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
+
+/**
+ * Utility Class For Actions On Streams
+ *
+ * @author mshitrit
+ *
+ */
+public final class StreamUtils {
+ private StreamUtils() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Breaks the stream when the predicate is not met.<br>
+ * Does not evaluate elements after the stream breaks.<br>
+ * This method evaluates the stream.<br>
+ *
+ * @param stream
+ * @param predicate
+ * @return
+ */
+ public static <T> Stream<T> takeWhilePlusOneNoEval(Stream<T> stream, Predicate<T> predicate) {
+ List<T> results = new ArrayList<>();
+ Consumer<T> listAdder = e -> results.add(e);
+ stream.map(e -> {
+ listAdder.accept(e);
+ return e;
+ }).filter(e -> !predicate.test(e)).findFirst();
+ return results.stream();
+ }
+
+ public static <T> Stream<T> takeWhile(Stream<T> stream, Predicate<T> predicate) {
+ return StreamSupport.stream(takeWhile(stream.spliterator(), predicate), false);
+ }
+
+ public static <T> Stream<T> takeWhilePlusOne(Stream<T> stream, Predicate<T> predicate) {
+ return StreamSupport.stream(takeWhile(stream.spliterator(), new StopAfterFailPredicate<T>(predicate)), false);
+ }
+
+ private static <T> Spliterator<T> takeWhile(Spliterator<T> splitr, Predicate<T> predicate) {
+ return new MySplitIterator<T>(splitr, predicate);
+ }
+
+ public static class MySplitIterator<T> extends AbstractSpliterator<T> implements Spliterator<T> {
+ boolean stillGoing = true;
+ private Spliterator<T> innerItr;
+ private Predicate<T> innerPred;
+
+ private MySplitIterator(Spliterator<T> splitItr, Predicate<T> pred) {
+ super(splitItr.estimateSize(), 0);
+ innerItr = splitItr;
+ innerPred = pred;
+ }
+
+ @Override
+ public boolean tryAdvance(Consumer<? super T> action) {
+ boolean canAdvance = true;
+ if (stillGoing) {
+ stillGoing = innerItr.tryAdvance(createConsumerWrapper(action));
+ } else {
+ canAdvance = false;
+ }
+ return canAdvance;
+ }
+
+ private Consumer<? super T> createConsumerWrapper(Consumer<? super T> action) {
+ Consumer<? super T> cons = new Consumer<T>() {
+ @Override
+ public void accept(T t) {
+ stillGoing = innerPred.test(t);
+ if (stillGoing) {
+ action.accept(t);
+ }
+
+ }
+ };
+
+ return cons;
+ }
+
+ }
+
+ public static class StopAfterFailPredicate<T> implements Predicate<T> {
+ boolean hasNotFailed;
+ Predicate<T> innerPredicate;
+
+ private StopAfterFailPredicate(Predicate<T> pred) {
+ hasNotFailed = true;
+ innerPredicate = pred;
+ };
+
+ @Override
+ public boolean test(T t) {
+ boolean isPassed;
+ if (hasNotFailed) {
+ isPassed = true;
+ hasNotFailed = innerPredicate.test(t);
+ } else {
+ isPassed = false;
+ }
+ return isPassed;
+ }
+
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ThreadLocalsHolder.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ThreadLocalsHolder.java
new file mode 100644
index 0000000000..92e0c07a4f
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ThreadLocalsHolder.java
@@ -0,0 +1,63 @@
+/*-
+ * ============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.common.util;
+
+public class ThreadLocalsHolder {
+
+ private static final ThreadLocal<String> uuidThreadLocal = new ThreadLocal<>();
+ private static final ThreadLocal<Long> requestStartTimeThreadLocal = new ThreadLocal<>();
+ private static final ThreadLocal<Boolean> isMdcProcessedThreadLocal = new ThreadLocal<Boolean>() {
+ @Override
+ protected Boolean initialValue() {
+ return false;
+ }
+ };
+
+ public static void setMdcProcessed(Boolean isMdcProcessed) {
+ isMdcProcessedThreadLocal.set(isMdcProcessed);
+ }
+
+ public static void setUuid(String uuid) {
+ uuidThreadLocal.set(uuid);
+ }
+
+ public static void setRequestStartTime(Long requestStartTime) {
+ requestStartTimeThreadLocal.set(requestStartTime);
+ }
+
+ public static String getUuid() {
+ return uuidThreadLocal.get();
+ }
+
+ public static Long getRequestStartTime() {
+ return requestStartTimeThreadLocal.get();
+ }
+
+ public static Boolean isMdcProcessed() {
+ return isMdcProcessedThreadLocal.get();
+ }
+
+ public static void cleanup() {
+ uuidThreadLocal.remove();
+ requestStartTimeThreadLocal.remove();
+ isMdcProcessedThreadLocal.remove();
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java
new file mode 100644
index 0000000000..b2b0344b39
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java
@@ -0,0 +1,498 @@
+/*-
+ * ============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.common.util;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.math.NumberUtils;
+import org.apache.commons.lang3.text.WordUtils;
+import org.apache.commons.validator.routines.UrlValidator;
+import org.jsoup.Jsoup;
+import org.jsoup.helper.StringUtil;
+import org.jsoup.safety.Whitelist;
+
+import com.google.common.base.CharMatcher;
+
+public class ValidationUtils {
+ public final static Integer COMPONENT_NAME_MAX_LENGTH = 1024;
+ public final static Pattern COMPONENT_NAME_PATTERN = Pattern.compile("^[\\w \\.\\-\\_\\:\\+]{1," + COMPONENT_NAME_MAX_LENGTH + "}$");
+ public final static Integer ADDITIONAL_INFORMATION_KEY_MAX_LENGTH = 50;
+ public final static Pattern ADDITIONAL_INFORMATION_KEY_PATTERN = Pattern.compile("^[\\w\\s\\.\\-\\_]{1," + COMPONENT_NAME_MAX_LENGTH + "}$");
+ public final static Integer RSI_NAME_MAX_LENGTH = 1024;
+ public final static Pattern RSI_NAME_PATTERN = Pattern.compile("^[\\w \\s\\.\\-\\_\\:\\+]{1," + RSI_NAME_MAX_LENGTH + "}$");
+ public final static Integer COMMENT_MAX_LENGTH = 256;
+
+ public final static Integer ICON_MAX_LENGTH = 25;
+ public final static Pattern ICON_PATTERN = Pattern.compile("^[\\w\\-]{1," + ICON_MAX_LENGTH + "}$");
+ public final static Integer PROJECT_CODE_MAX_LEGTH = 10;
+ //public final static Pattern PROJECT_CODE_PATTERN = Pattern.compile("^[\\d]{5," + PROJECT_CODE_MAX_LEGTH + "}$");
+ public final static Pattern PROJECT_CODE_PATTERN = Pattern.compile("^[\\s\\w_.-]{1,50}$");
+ public final static Integer CONNTACT_ID_MAX_LENGTH = 6;
+ // Format : aannnX (where a=a-z or A-Z, n=0-9, and X=a-z,A-Z, or 0-9)
+ //public final static Pattern CONTACT_ID_PATTERN = Pattern.compile("[mM]{1}[0-9]{5}|[a-zA-Z]{2}[0-9]{4}|[a-zA-Z]{2}[0-9]{3}[a-zA-Z]{1}");
+ public final static Pattern CONTACT_ID_PATTERN = Pattern.compile("^[\\s\\w_.-]{1,50}$");
+ public final static Pattern OCTET_PATTERN = Pattern.compile("%[a-fA-F0-9]{2}");
+ public final static Pattern NONE_UTF8_PATTERN = Pattern.compile("[^\\x00-\\x7F]+");
+ public final static Pattern URL_INVALIDE_PATTERN = Pattern.compile("[,#?&@$<>~^`\\\\\\[\\]{}|\")(*!+=;%]+");
+
+ public final static Pattern ENGLISH_PATTERN = Pattern.compile("^[\\p{Graph}\\x20]+$");
+ public final static Integer COMPONENT_DESCRIPTION_MAX_LENGTH = 1024;
+ public final static Integer TAG_MAX_LENGTH = 1024;
+ public final static Integer TAG_LIST_MAX_LENGTH = 1024;
+ public final static Integer VENDOR_NAME_MAX_LENGTH = 25;
+ public final static Pattern VENDOR_NAME_PATTERN = Pattern.compile("^[\\x20-\\x21\\x23-\\x29\\x2B-\\x2E\\x30-\\x39\\x3B\\x3D\\x40-\\x5B\\x5D-\\x7B\\x7D-\\xFF]+$");
+ public final static Integer VENDOR_RELEASE_MAX_LENGTH = 25;
+ public final static Pattern VENDOR_RELEASE_PATTERN = Pattern.compile("^[\\x20-\\x21\\x23-\\x29\\x2B-\\x2E\\x30-\\x39\\x3B\\x3D\\x40-\\x5B\\x5D-\\x7B\\x7D-\\xFF]+$");
+
+ public final static Pattern CLEAN_FILENAME_PATTERN = Pattern.compile("[\\x00-\\x1f\\x80-\\x9f\\x5c/<?>\\*:|\"/]+");
+
+ public final static Pattern DASH_PATTERN = Pattern.compile("[-]+");
+ public final static Pattern UNDERSCORE_PATTERN = Pattern.compile("[_]+");
+ public final static Pattern PLUS_PATTERN = Pattern.compile("[+]+");
+ public final static Pattern SPACE_PATTERN = Pattern.compile("[ ]+");
+ public final static Pattern AMP_PATTERN = Pattern.compile("[&]+");
+ public final static Pattern DOT_PATTERN = Pattern.compile("[\\.]+");
+ public final static Pattern APOST_PATTERN = Pattern.compile("[']+");
+ public final static Pattern HASHTAG_PATTERN = Pattern.compile("[#]+");
+ public final static Pattern EQUAL_PATTERN = Pattern.compile("[=]+");
+ public final static Pattern COLON_PATTERN = Pattern.compile("[:]+");
+ public final static Pattern AT_PATTERN = Pattern.compile("[@]+");
+ public final static Pattern AND_PATTERN = Pattern.compile(" [aA][Nn][Dd] ");
+ public final static Set<String> CATEGORY_CONJUNCTIONS = new HashSet<String>(Arrays.asList("of", "to", "for", "as", "a", "an", "the"));
+
+ public final static Pattern COST_PATTERN = Pattern.compile("^[0-9]{1,5}\\.[0-9]{1,3}$");
+ public final static Pattern ARTIFACT_LABEL_PATTERN = Pattern.compile("^[a-zA-Z0-9 \\-+]+$");
+ public final static Integer ARTIFACT_LABEL_LENGTH = 25;
+ public final static Pattern CATEGORY_LABEL_PATTERN = Pattern.compile("^[a-zA-Z0-9][a-zA-Z0-9 &\\.'#=:@_\\-+]+$");
+ public final static Integer CATEGORY_LABEL_MIN_LENGTH = 4;
+ public final static Integer CATEGORY_LABEL_MAX_LENGTH = 25;
+
+ public final static Pattern COMPONENT_NAME_DELIMETER_PATTERN = Pattern.compile("[\\.\\-\\_]+");
+ public final static Pattern COMPONENT_INCTANCE_NAME_DELIMETER_PATTERN = Pattern.compile("[\\.\\-]+");
+ public final static Pattern PRODUCT_NAME_DELIMETER_PATTERN = Pattern.compile("[\\.\\-\\_&=#@':\\[\\]\\+]+");
+ public final static Integer CONSUMER_NAME_MAX_LENGTH = 255;
+ // public final static Pattern CONSUMER_NAME_PATTERN =
+ // Pattern.compile("^[\\w]{1}?[\\w\\.\\-]{0," + CONSUMER_NAME_MAX_LENGTH +
+ // "}?$");
+ public final static Pattern CONSUMER_NAME_PATTERN = Pattern.compile("^[\\w]+[\\w\\.\\-]*$");
+ public final static Integer CONSUMER_SALT_LENGTH = 32;
+ public final static Integer CONSUMER_PASSWORD_LENGTH = 64;
+ public final static Pattern CONSUMER_PASS_SALT_PATTERN = Pattern.compile("^[a-z0-9]+$");
+ public final static Pattern FLOAT_PATTERN = Pattern.compile("^[\\d]+[\\.]{1}[\\d]+$");
+ public final static Pattern CERTIFIED_VERSION_PATTERN = Pattern.compile("^[1-9][0-9]*\\.0$");
+ public final static Pattern MINOR_VERSION_PATTERN = Pattern.compile("^0\\.[1-9][0-9]*$");
+ public final static Pattern TAGS_PATTERN = Pattern.compile("<[^><]*>");
+
+ public final static Integer ARTIFACT_NAME_LENGTH = 255;
+ public final static Integer API_URL_LENGTH = 100;
+ public final static Integer ARTIFACT_DESCRIPTION_MAX_LENGTH = 256;
+
+ public final static Integer PRODUCT_FULL_NAME_MIN_LENGTH = 4;
+ public final static Integer PRODUCT_FULL_NAME_MAX_LENGTH = 100;
+
+ public static boolean validateArtifactLabel(String label) {
+ return ARTIFACT_LABEL_PATTERN.matcher(label).matches();
+ }
+
+ public static boolean validateCategoryDisplayNameFormat(String label) {
+ boolean res = true;
+ if (label != null) {
+ label = label.trim();
+ res = CATEGORY_LABEL_PATTERN.matcher(label).matches();
+ }
+ return res;
+ }
+
+ public static String normalizeCategoryName4Display(String str) {
+ if (str != null) {
+ str = str.trim();
+ str = DASH_PATTERN.matcher(str).replaceAll("-");
+ str = UNDERSCORE_PATTERN.matcher(str).replaceAll("_");
+ str = AMP_PATTERN.matcher(str).replaceAll("&");
+ str = PLUS_PATTERN.matcher(str).replaceAll("+");
+ str = DOT_PATTERN.matcher(str).replaceAll(".");
+ str = APOST_PATTERN.matcher(str).replaceAll("'");
+ str = HASHTAG_PATTERN.matcher(str).replaceAll("#");
+ str = EQUAL_PATTERN.matcher(str).replaceAll("=");
+ str = COLON_PATTERN.matcher(str).replaceAll(":");
+ str = AT_PATTERN.matcher(str).replaceAll("@");
+ str = normaliseWhitespace(str);
+ str = AND_PATTERN.matcher(str).replaceAll(" & ");
+
+ // Case normalizing
+ StringBuilder sb = new StringBuilder();
+ String[] split = str.split(" ");
+ for (int i = 0; i < split.length; i++) {
+ String splitted = split[i];
+ String lowerCase = splitted.toLowerCase();
+ // BANK OF AMERICA --> BANK of AMERICA ("of" is lowercased), but
+ // OF BANK OF AMERICA --> OF BANK of AMERICA (first "OF" is not
+ // lowercased because it's first word)
+ // Agreed with Ella, 26/11/15
+ if ((i > 0) && CATEGORY_CONJUNCTIONS.contains(lowerCase)) {
+ sb.append(lowerCase);
+ } else {
+ sb.append(WordUtils.capitalize(splitted));
+ }
+ sb.append(" ");
+ }
+ str = sb.toString().trim();
+ }
+ return str;
+ }
+
+ public static String normalizeCategoryName4Uniqueness(String str) {
+ return str.toLowerCase();
+ }
+
+ public static boolean validateCategoryDisplayNameLength(String label) {
+ return (label != null && label.length() >= CATEGORY_LABEL_MIN_LENGTH && label.length() <= CATEGORY_LABEL_MAX_LENGTH);
+ }
+
+ public static boolean validateProductFullNameLength(String fullName) {
+ return (fullName != null && fullName.length() >= PRODUCT_FULL_NAME_MIN_LENGTH && fullName.length() <= PRODUCT_FULL_NAME_MAX_LENGTH);
+ }
+
+ public static boolean validateArtifactLabelLength(String label) {
+ return label.length() > 0 && label.length() <= ARTIFACT_LABEL_LENGTH;
+ }
+
+ public static boolean validateResourceInstanceNameLength(String resourceInstanceName) {
+ return resourceInstanceName.length() <= RSI_NAME_MAX_LENGTH;
+ }
+
+ public static boolean validateResourceInstanceName(String resourceInstanceName) {
+ return RSI_NAME_PATTERN.matcher(resourceInstanceName).matches();
+ }
+
+ public static boolean validateUrlLength(String url) {
+ return url.length() <= API_URL_LENGTH;
+ }
+
+ public static boolean validateArtifactNameLength(String artifactName) {
+ return (artifactName.length() <= ARTIFACT_NAME_LENGTH && artifactName.length() > 0);
+ }
+
+ public static boolean validateComponentNamePattern(String componentName) {
+ return COMPONENT_NAME_PATTERN.matcher(componentName).matches();
+ }
+
+ public static boolean validateComponentNameLength(String componentName) {
+ return componentName.length() <= COMPONENT_NAME_MAX_LENGTH;
+ }
+
+ public static boolean validateIcon(String icon) {
+ return ICON_PATTERN.matcher(icon).matches();
+ }
+
+ public static boolean validateIconLength(String icon) {
+ return icon.length() <= ICON_MAX_LENGTH;
+ }
+
+ public static boolean validateProjectCode(String projectCode) {
+ return PROJECT_CODE_PATTERN.matcher(projectCode).matches();
+ }
+
+ public static boolean validateProjectCodeLegth(String projectCode) {
+ return projectCode.length() <= PROJECT_CODE_MAX_LEGTH;
+ }
+
+ public static boolean validateContactId(String contactId) {
+ return CONTACT_ID_PATTERN.matcher(contactId).matches();
+ }
+
+ public static boolean validateCost(String cost) {
+ return COST_PATTERN.matcher(cost).matches();
+ }
+
+ public static String removeHtmlTags(String str) {
+ return Jsoup.clean(str, Whitelist.none());
+ }
+
+ public static String removeAllTags(String htmlText) {
+
+ String stripped = TAGS_PATTERN.matcher(htmlText).replaceAll("").trim();
+ return stripped;
+ }
+
+ public static String normaliseWhitespace(String str) {
+ return StringUtil.normaliseWhitespace(str);
+ }
+
+ public static String stripOctets(String str) {
+ return OCTET_PATTERN.matcher(str).replaceAll("");
+ }
+
+ public static String removeNoneUtf8Chars(String input) {
+ return NONE_UTF8_PATTERN.matcher(input).replaceAll("");
+ }
+
+ public static boolean validateIsEnglish(String input) {
+ return ENGLISH_PATTERN.matcher(input).matches();
+ }
+
+ public static boolean validateIsAscii(String input) {
+
+ boolean isAscii = CharMatcher.ASCII.matchesAllOf(input);
+
+ return isAscii;
+ }
+
+ public static String convertHtmlTagsToEntities(String input) {
+ return StringEscapeUtils.escapeHtml4(input);
+ }
+
+ public static List<String> removeDuplicateFromList(List<String> list) {
+ Set<String> hs = new LinkedHashSet<>(list);
+ list.clear();
+ list.addAll(hs);
+ return list;
+
+ }
+
+ public static boolean validateTagLength(String tag) {
+ if (tag != null) {
+ return tag.length() <= TAG_MAX_LENGTH;
+ }
+ return false;
+ }
+
+ public static boolean validateTagListLength(int tagListLength) {
+ return tagListLength <= TAG_LIST_MAX_LENGTH;
+ }
+
+ public static boolean validateDescriptionLength(String description) {
+ return description.length() <= COMPONENT_DESCRIPTION_MAX_LENGTH;
+ }
+
+ public static boolean validateStringNotEmpty(String value) {
+ if ((value == null) || (value.trim().isEmpty())) {
+ return false;
+ }
+ return true;
+ }
+
+ public static boolean validateListNotEmpty(List<?> list) {
+ if ((list == null) || (list.isEmpty())) {
+ return false;
+ }
+ return true;
+ }
+
+ public static boolean validateVendorName(String ventorName) {
+ return VENDOR_NAME_PATTERN.matcher(ventorName).matches();
+ }
+
+ public static boolean validateVendorNameLength(String ventorName) {
+ return ventorName.length() <= VENDOR_NAME_MAX_LENGTH;
+ }
+
+ public static boolean validateVendorRelease(String vendorRelease) {
+ return VENDOR_RELEASE_PATTERN.matcher(vendorRelease).matches();
+ }
+
+ public static boolean validateVendorReleaseLength(String vendorRelease) {
+ return vendorRelease.length() <= VENDOR_RELEASE_MAX_LENGTH;
+ }
+
+ public static boolean hasBeenCertified(String version) {
+ return NumberUtils.toDouble(version) >= 1;
+ }
+
+ public static String normaliseComponentName(String name) {
+ String[] split = splitComponentName(name);
+ StringBuffer sb = new StringBuffer();
+ for (String splitElement : split) {
+ sb.append(splitElement);
+ }
+ return sb.toString();
+
+ }
+
+ public static String normaliseComponentInstanceName(String name) {
+ String[] split = splitComponentInctanceName(name);
+ StringBuffer sb = new StringBuffer();
+ for (String splitElement : split) {
+ sb.append(splitElement);
+ }
+ return sb.toString();
+
+ }
+
+ private static String[] splitComponentName(String name) {
+ String normalizedName = name.toLowerCase();
+ normalizedName = COMPONENT_NAME_DELIMETER_PATTERN.matcher(normalizedName).replaceAll(" ");
+ String[] split = normalizedName.split(" ");
+ return split;
+ }
+
+ private static String[] splitComponentInctanceName(String name) {
+ String normalizedName = name.toLowerCase();
+ normalizedName = COMPONENT_INCTANCE_NAME_DELIMETER_PATTERN.matcher(normalizedName).replaceAll(" ");
+ String[] split = normalizedName.split(" ");
+ return split;
+ }
+
+ public static String convertToSystemName(String name) {
+ String[] split = splitComponentName(name);
+ StringBuffer sb = new StringBuffer();
+ for (String splitElement : split) {
+ String capitalize = WordUtils.capitalize(splitElement);
+ sb.append(capitalize);
+ }
+ return sb.toString();
+ }
+
+ public static String normalizeFileName(String filename) {
+ // String[] split = filename.split(Pattern.quote(File.separator));
+ // String name = "";
+ //
+ // name = split[split.length - 1];
+ return cleanFileName(filename);
+
+ }
+
+ private static String cleanFileName(String str) {
+ str = CLEAN_FILENAME_PATTERN.matcher(str).replaceAll("");
+ str = normaliseWhitespace(str);
+ str = SPACE_PATTERN.matcher(str).replaceAll("-");
+ str = DASH_PATTERN.matcher(str).replaceAll("-");
+ str = StringUtils.strip(str, "-_ .");
+
+ return str;
+ }
+
+ public static boolean validateUrl(String url) {
+
+ UrlValidator urlValidator = new UrlValidator();
+ if (!urlValidator.isValid(url)) {
+ return false;
+ }
+ if (NONE_UTF8_PATTERN.matcher(url).find()) {
+ return false;
+ }
+
+ if (URL_INVALIDE_PATTERN.matcher(url).find()) {
+ return false;
+ }
+ return true;
+
+ }
+
+ public static String cleanArtifactDisplayName(String strIn) {
+ String str = DASH_PATTERN.matcher(strIn).replaceAll("-");
+ str = UNDERSCORE_PATTERN.matcher(str).replaceAll("_");
+ str = PLUS_PATTERN.matcher(str).replaceAll("+");
+ str = normaliseWhitespace(str);
+ str = str.trim();
+ // str = str.replaceAll(" ", "");
+
+ return str;
+ }
+
+ public static String normalizeArtifactLabel(String strIn) {
+
+ String str = DASH_PATTERN.matcher(strIn).replaceAll("");
+ str = UNDERSCORE_PATTERN.matcher(str).replaceAll("");
+ str = PLUS_PATTERN.matcher(str).replaceAll("");
+ str = SPACE_PATTERN.matcher(str).replaceAll("");
+ str = str.toLowerCase();
+
+ return str;
+ }
+
+ public static boolean validateAdditionalInformationKeyName(String str) {
+ return ADDITIONAL_INFORMATION_KEY_PATTERN.matcher(str).matches();
+ }
+
+ public static String normalizeAdditionalInformation(String str) {
+ if (str != null) {
+ str = DASH_PATTERN.matcher(str).replaceAll("-");
+ str = UNDERSCORE_PATTERN.matcher(str).replaceAll("_");
+ str = normaliseWhitespace(str);
+ }
+ return str;
+ }
+
+ public static boolean validateLength(String str, int length) {
+ if (str == null) {
+ return true;
+ }
+ return str.length() <= length;
+ }
+
+ public static boolean validateConsumerName(String consumerName) {
+ return CONSUMER_NAME_PATTERN.matcher(consumerName).matches();
+ }
+
+ public static boolean isUTF8Str(String str) {
+ if (NONE_UTF8_PATTERN.matcher(str).find()) {
+ return false;
+ }
+ return true;
+ }
+
+ public static boolean validateConsumerPassSalt(String consumerSalt) {
+ return CONSUMER_PASS_SALT_PATTERN.matcher(consumerSalt).matches();
+ }
+
+ public static boolean isFloatNumber(String number) {
+ return FLOAT_PATTERN.matcher(number).matches();
+ }
+
+ public static boolean validateCertifiedVersion(String version) {
+ return (version != null && CERTIFIED_VERSION_PATTERN.matcher(version).matches());
+ }
+
+ public static boolean validateMinorVersion(String version) {
+ return (version != null && MINOR_VERSION_PATTERN.matcher(version).matches());
+ }
+
+ public static String normaliseProductName(String name) {
+ String[] split = splitComponentName(PRODUCT_NAME_DELIMETER_PATTERN, name);
+ StringBuffer sb = new StringBuffer();
+ for (String splitElement : split) {
+ sb.append(splitElement);
+ }
+ return sb.toString();
+
+ }
+
+ private static String[] splitComponentName(Pattern pattern, String name) {
+ String normalizedName = name.toLowerCase();
+ normalizedName = pattern.matcher(normalizedName).replaceAll(" ");
+ String[] split = normalizedName.split(" ");
+ return split;
+ }
+
+ public static String removeHtmlTagsOnly(String htmlText) {
+ String stripped = HtmlCleaner.stripHtml(htmlText, false);
+ return stripped;
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java
new file mode 100644
index 0000000000..75ac208432
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java
@@ -0,0 +1,275 @@
+/*-
+ * ============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.common.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.codec.binary.Base64;
+import org.openecomp.sdc.be.config.DistributionEngineConfiguration;
+import org.openecomp.sdc.be.config.Configuration.ApplicationL1CacheConfig;
+import org.openecomp.sdc.be.config.Configuration.ApplicationL2CacheConfig;
+import org.openecomp.sdc.be.config.Configuration.BeMonitoringConfig;
+import org.openecomp.sdc.be.config.Configuration.DeploymentArtifactTypeConfig;
+import org.openecomp.sdc.be.config.Configuration.EcompPortalConfig;
+import org.openecomp.sdc.be.config.Configuration.ElasticSearchConfig;
+import org.openecomp.sdc.be.config.Configuration.OnboardingConfig;
+import org.openecomp.sdc.be.config.Configuration.SwitchoverDetectorConfig;
+import org.openecomp.sdc.be.config.Configuration.ToscaValidatorsConfig;
+import org.openecomp.sdc.be.config.Configuration.ElasticSearchConfig.IndicesTimeFrequencyEntry;
+import org.openecomp.sdc.be.config.DistributionEngineConfiguration.ComponentArtifactTypesConfig;
+import org.openecomp.sdc.be.config.DistributionEngineConfiguration.CreateTopicConfig;
+import org.openecomp.sdc.be.config.DistributionEngineConfiguration.DistributionNotificationTopicConfig;
+import org.openecomp.sdc.be.config.DistributionEngineConfiguration.DistributionStatusTopicConfig;
+import org.openecomp.sdc.be.config.validation.DeploymentArtifactHeatConfiguration;
+import org.openecomp.sdc.fe.config.Configuration.FeMonitoringConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.yaml.snakeyaml.TypeDescription;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.error.YAMLException;
+import org.yaml.snakeyaml.introspector.PropertyUtils;
+import org.yaml.snakeyaml.nodes.Node;
+
+public class YamlToObjectConverter {
+
+ private static Logger log = LoggerFactory.getLogger(YamlToObjectConverter.class.getName());
+
+ private static HashMap<String, Yaml> yamls = new HashMap<String, Yaml>();
+
+ private static Yaml defaultYaml = new Yaml();
+
+ static {
+
+ org.yaml.snakeyaml.constructor.Constructor deConstructor = new org.yaml.snakeyaml.constructor.Constructor(
+ DistributionEngineConfiguration.class);
+ TypeDescription deDescription = new TypeDescription(DistributionEngineConfiguration.class);
+ deDescription.putListPropertyType("distributionStatusTopic", DistributionStatusTopicConfig.class);
+ deDescription.putListPropertyType("distribNotifServiceArtifactTypes", ComponentArtifactTypesConfig.class);
+ deDescription.putListPropertyType("distribNotifResourceArtifactTypes", ComponentArtifactTypesConfig.class);
+ deDescription.putListPropertyType("createTopic", CreateTopicConfig.class);
+ deDescription.putListPropertyType("distributionNotificationTopic", DistributionNotificationTopicConfig.class);
+ deConstructor.addTypeDescription(deDescription);
+ Yaml yaml = new Yaml(deConstructor);
+ yamls.put(DistributionEngineConfiguration.class.getName(), yaml);
+
+ // FE conf
+ org.yaml.snakeyaml.constructor.Constructor feConfConstructor = new org.yaml.snakeyaml.constructor.Constructor(
+ org.openecomp.sdc.fe.config.Configuration.class);
+ TypeDescription feConfDescription = new TypeDescription(org.openecomp.sdc.fe.config.Configuration.class);
+ feConfDescription.putListPropertyType("systemMonitoring", FeMonitoringConfig.class);
+ feConfConstructor.addTypeDescription(feConfDescription);
+ yamls.put(org.openecomp.sdc.fe.config.Configuration.class.getName(), new Yaml(feConfConstructor));
+
+ // BE conf
+ org.yaml.snakeyaml.constructor.Constructor beConfConstructor = new org.yaml.snakeyaml.constructor.Constructor(
+ org.openecomp.sdc.be.config.Configuration.class);
+ TypeDescription beConfDescription = new TypeDescription(org.openecomp.sdc.be.config.Configuration.class);
+ beConfConstructor.addTypeDescription(beConfDescription);
+
+ // systemMonitoring
+ beConfDescription.putListPropertyType("systemMonitoring", BeMonitoringConfig.class);
+
+ // elasticSearch
+ beConfDescription.putListPropertyType("elasticSearch", ElasticSearchConfig.class);
+ TypeDescription esDescription = new TypeDescription(ElasticSearchConfig.class);
+ esDescription.putListPropertyType("indicesTimeFrequency", IndicesTimeFrequencyEntry.class);
+ beConfConstructor.addTypeDescription(esDescription);
+
+ // resourceDeploymentArtifacts and serviceDeploymentArtifacts
+ beConfDescription.putMapPropertyType("resourceDeploymentArtifacts", String.class,
+ DeploymentArtifactTypeConfig.class);
+ beConfDescription.putMapPropertyType("serviceDeploymentArtifacts", String.class,
+ DeploymentArtifactTypeConfig.class);
+
+ // onboarding
+ beConfDescription.putListPropertyType("onboarding", OnboardingConfig.class);
+
+ // ecompPortal
+ beConfDescription.putListPropertyType("ecompPortal", EcompPortalConfig.class);
+ // switchoverDetector
+ beConfDescription.putListPropertyType("switchoverDetector", SwitchoverDetectorConfig.class);
+
+ // ApplicationL1Cache
+ beConfDescription.putListPropertyType("applicationL1Cache", ApplicationL1CacheConfig.class);
+
+ // ApplicationL2Cache
+ beConfDescription.putListPropertyType("applicationL2Cache", ApplicationL2CacheConfig.class);
+
+ // tosca validators config
+ beConfDescription.putListPropertyType("toscaValidators", ToscaValidatorsConfig.class);
+
+ yamls.put(org.openecomp.sdc.be.config.Configuration.class.getName(), new Yaml(beConfConstructor));
+
+ // HEAT deployment artifact
+ org.yaml.snakeyaml.constructor.Constructor depArtHeatConstructor = new org.yaml.snakeyaml.constructor.Constructor(
+ DeploymentArtifactHeatConfiguration.class);
+ PropertyUtils propertyUtils = new PropertyUtils();
+ // Skip properties which are found in YAML but not found in POJO
+ propertyUtils.setSkipMissingProperties(true);
+ depArtHeatConstructor.setPropertyUtils(propertyUtils);
+ yamls.put(org.openecomp.sdc.be.config.validation.DeploymentArtifactHeatConfiguration.class.getName(),
+ new Yaml(depArtHeatConstructor));
+
+ }
+
+ private static <T> Yaml getYamlByClassName(Class<T> className) {
+
+ Yaml yaml = yamls.get(className.getName());
+ if (yaml == null) {
+ yaml = defaultYaml;
+ }
+
+ return yaml;
+ }
+
+ public <T> T convert(String dirPath, Class<T> className, String configFileName) {
+
+ T config = null;
+
+ try {
+
+ String fullFileName = dirPath + File.separator + configFileName;
+
+ config = convert(fullFileName, className);
+
+ } catch (Exception e) {
+ log.error("Failed to convert yaml file " + configFileName + " to object.", e);
+ }
+
+ return config;
+ }
+
+ public class MyYamlConstructor extends org.yaml.snakeyaml.constructor.Constructor {
+ private HashMap<String, Class<?>> classMap = new HashMap<String, Class<?>>();
+
+ public MyYamlConstructor(Class<? extends Object> theRoot) {
+ super(theRoot);
+ classMap.put(DistributionEngineConfiguration.class.getName(), DistributionEngineConfiguration.class);
+ classMap.put(DistributionStatusTopicConfig.class.getName(), DistributionStatusTopicConfig.class);
+ }
+
+ /*
+ * This is a modified version of the Constructor. Rather than using a
+ * class loader to get external classes, they are already predefined
+ * above. This approach works similar to the typeTags structure in the
+ * original constructor, except that class information is pre-populated
+ * during initialization rather than runtime.
+ *
+ * @see
+ * org.yaml.snakeyaml.constructor.Constructor#getClassForNode(org.yaml.
+ * snakeyaml.nodes.Node)
+ */
+ protected Class<?> getClassForNode(Node node) {
+ String name = node.getTag().getClassName();
+ Class<?> cl = classMap.get(name);
+ if (cl == null)
+ throw new YAMLException("Class not found: " + name);
+ else
+ return cl;
+ }
+ }
+
+ public <T> T convert(String fullFileName, Class<T> className) {
+
+ T config = null;
+
+ Yaml yaml = getYamlByClassName(className);
+
+ InputStream in = null;
+ try {
+
+ File f = new File(fullFileName);
+ if (false == f.exists()) {
+ log.warn("The file " + fullFileName + " cannot be found. Ignore reading configuration.");
+ return null;
+ }
+ in = Files.newInputStream(Paths.get(fullFileName));
+
+ config = yaml.loadAs(in, className);
+
+ // System.out.println(config.toString());
+ } catch (Exception e) {
+ log.error("Failed to convert yaml file " + fullFileName + " to object.", e);
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return config;
+ }
+
+ public <T> T convert(byte[] fileContents, Class<T> className) {
+
+ T config = null;
+
+ Yaml yaml = getYamlByClassName(className);
+
+ InputStream in = null;
+ try {
+
+ in = new ByteArrayInputStream(fileContents);
+
+ config = yaml.loadAs(in, className);
+
+ } catch (Exception e) {
+ log.error("Failed to convert yaml file to object", e);
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return config;
+ }
+
+ public boolean isValidYaml(byte[] fileContents) {
+ if (Base64.isBase64(fileContents)) {
+ log.trace("Received Base64 data - decoding before validating...");
+ fileContents = Base64.decodeBase64(fileContents);
+ }
+ try {
+ Map<String, Object> mappedToscaTemplate = (Map<String, Object>) defaultYaml
+ .load(new ByteArrayInputStream(fileContents));
+ } catch (Exception e) {
+ log.error("Failed to convert yaml file to object - yaml is invalid", e);
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ZipUtil.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ZipUtil.java
new file mode 100644
index 0000000000..ac25c40cf7
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ZipUtil.java
@@ -0,0 +1,178 @@
+/*-
+ * ============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.common.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
+
+import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ZipUtil {
+
+ private static Logger log = LoggerFactory.getLogger(ZipUtil.class.getName());
+
+ private ZipUtil() {
+ }
+
+ public static Map<String, byte[]> readZip(byte[] zipAsBytes) {
+
+ ZipInputStream zis = null;
+ zis = new ZipInputStream(new ByteArrayInputStream(zipAsBytes));
+
+ return readZip(zis);
+ }
+
+ public static Map<String, byte[]> readZip(ZipInputStream zis) {
+
+ Map<String, byte[]> fileNameToByteArray = new HashMap<String, byte[]>();
+
+ byte[] buffer = new byte[1024];
+ try {
+ // get the zipped file list entry
+ ZipEntry ze = zis.getNextEntry();
+
+ while (ze != null) {
+
+ String fileName = ze.getName();
+
+ if (false == ze.isDirectory()) {
+
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ try {
+ int len;
+ while ((len = zis.read(buffer)) > 0) {
+ os.write(buffer, 0, len);
+ }
+
+ fileNameToByteArray.put(fileName, os.toByteArray());
+
+ } finally {
+ if (os != null) {
+ os.close();
+ }
+ }
+ }
+ ze = zis.getNextEntry();
+
+ }
+
+ zis.closeEntry();
+ zis.close();
+
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ return null;
+ } finally {
+ if (zis != null) {
+ try {
+ zis.closeEntry();
+ zis.close();
+ } catch (IOException e) {
+ // TODO: add log
+ }
+
+ }
+ }
+
+ return fileNameToByteArray;
+
+ }
+
+ public static void main(String[] args) {
+
+ String zipFileName = "/src/test/resources/config/config.zip";
+
+ zipFileName = "C:\\Git_work\\D2-SDnC\\catalog-be\\src\\test\\resources\\config\\config.zip";
+
+ Path path = Paths.get(zipFileName);
+
+ try {
+ byte[] zipAsBytes = Files.readAllBytes(path);
+ // encode to base
+
+ ZipUtil.readZip(zipAsBytes);
+
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ public static byte[] zipBytes(byte[] input) throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ZipOutputStream zos = new ZipOutputStream(baos);
+ ZipEntry entry = new ZipEntry("zip");
+ entry.setSize(input.length);
+ zos.putNextEntry(entry);
+ zos.write(input);
+ zos.closeEntry();
+ zos.close();
+ return baos.toByteArray();
+ }
+
+ public static byte[] unzip(byte[] zipped) {
+ ZipInputStream zipinputstream = null;
+ ByteArrayOutputStream outputStream = null;
+ try {
+ byte[] buf = new byte[1024];
+
+ zipinputstream = new ZipInputStream(new ByteArrayInputStream(zipped));
+ ZipEntry zipentry = zipinputstream.getNextEntry();
+ outputStream = new ByteArrayOutputStream();
+ int n;
+ while ((n = zipinputstream.read(buf, 0, 1024)) > -1) {
+ outputStream.write(buf, 0, n);
+ }
+
+ return outputStream.toByteArray();
+ } catch (Exception e) {
+ throw new IllegalStateException("Can't unzip input stream", e);
+ } finally {
+ if (outputStream != null) {
+ try {
+ outputStream.close();
+ } catch (IOException e) {
+ log.debug("Failed to close output stream", e);
+ }
+ }
+ if (zipinputstream != null) {
+ try {
+ zipinputstream.closeEntry();
+ zipinputstream.close();
+ } catch (IOException e) {
+ log.debug("Failed to close zip input stream", e);
+ }
+ }
+ }
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/AbstractSdncException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/AbstractSdncException.java
new file mode 100644
index 0000000000..83e8321ea6
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/AbstractSdncException.java
@@ -0,0 +1,116 @@
+/*-
+ * ============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.exception;
+
+import java.util.Arrays;
+import java.util.Formatter;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class AbstractSdncException {
+
+ private String messageId;
+
+ private String text;
+
+ private String[] variables;
+
+ private static Logger log = LoggerFactory.getLogger(AbstractSdncException.class.getName());
+
+ private final static Pattern ERROR_PARAM_PATTERN = Pattern.compile("%\\d");
+
+ public AbstractSdncException() {
+ }
+
+ public AbstractSdncException(String messageId, String text, String[] variables) {
+ super();
+ this.messageId = messageId;
+ this.text = text;
+ this.variables = validateParameters(messageId, text, variables);
+ }
+
+ private String[] validateParameters(String messageId, String text, String[] variables) {
+ String[] res = null;
+ Matcher m = ERROR_PARAM_PATTERN.matcher(text);
+ int expectedParamsNum = 0;
+ while (m.find()) {
+ expectedParamsNum += 1;
+ }
+ int actualParamsNum = (variables != null) ? variables.length : 0;
+ if (actualParamsNum < expectedParamsNum) {
+ log.warn(
+ "Received less parameters than expected for error with messageId {}, expected: {}, actual: {}. Missing parameters are padded with null values.",
+ messageId, expectedParamsNum, actualParamsNum);
+ } else if (actualParamsNum > expectedParamsNum) {
+ log.warn(
+ "Received more parameters than expected for error with messageId {}, expected: {}, actual: {}. Extra parameters are ignored.",
+ messageId, expectedParamsNum, actualParamsNum);
+ }
+ if (variables != null) {
+ res = Arrays.copyOf(variables, expectedParamsNum);
+ }
+
+ return res;
+ }
+
+ public String getMessageId() {
+ return this.messageId;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public String[] getVariables() {
+ return variables;
+ }
+
+ public void setMessageId(String messageId) {
+ this.messageId = messageId;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public void setVariables(String[] variables) {
+ this.variables = variables;
+ }
+
+ public String getFormattedErrorMessage() {
+ String res;
+ if (variables != null && variables.length > 0) {
+ Formatter formatter = new Formatter();
+ try {
+ res = formatter.format(this.text.replaceAll("%\\d", "%s"), (Object[]) this.variables).toString();
+ } finally {
+ formatter.close();
+ }
+ } else {
+ res = this.text;
+ }
+ return res;
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/AlreadyExistException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/AlreadyExistException.java
new file mode 100644
index 0000000000..3baec2067e
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/AlreadyExistException.java
@@ -0,0 +1,41 @@
+/*-
+ * ============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.exception;
+
+/**
+ * Exception to be thrown when trying to insert an existing an element that
+ * already exists.
+ *
+ * @author luc boutier
+ */
+public class AlreadyExistException extends TechnicalException {
+ private static final long serialVersionUID = -6151150122897145634L;
+
+ /**
+ * Create a new {@link AlreadyExistException} with the cause.
+ *
+ * @param message
+ * Message.
+ */
+ public AlreadyExistException(String message) {
+ super(message);
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/DeleteLastApplicationEnvironmentException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/DeleteLastApplicationEnvironmentException.java
new file mode 100644
index 0000000000..ec33b69d82
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/DeleteLastApplicationEnvironmentException.java
@@ -0,0 +1,34 @@
+/*-
+ * ============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.exception;
+
+public class DeleteLastApplicationEnvironmentException extends TechnicalException {
+
+ private static final long serialVersionUID = -5192834855057177252L;
+
+ public DeleteLastApplicationEnvironmentException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public DeleteLastApplicationEnvironmentException(String message) {
+ super(message);
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/DeleteReferencedObjectException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/DeleteReferencedObjectException.java
new file mode 100644
index 0000000000..6957e960c3
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/DeleteReferencedObjectException.java
@@ -0,0 +1,35 @@
+/*-
+ * ============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.exception;
+
+/**
+ * This exception should be thrown when attempting to delete an object in Alien
+ * which is still referenced (used) by other object
+ *
+ * @author Minh Khang VU
+ */
+public class DeleteReferencedObjectException extends TechnicalException {
+ private static final long serialVersionUID = 1L;
+
+ public DeleteReferencedObjectException(String message) {
+ super(message);
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/FunctionalException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/FunctionalException.java
new file mode 100644
index 0000000000..5bf67484d5
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/FunctionalException.java
@@ -0,0 +1,41 @@
+/*-
+ * ============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.exception;
+
+/**
+ * All functional exception which is related to user input must go here. It's a
+ * checked exception to force error handling and checking.
+ *
+ * @author mkv
+ *
+ */
+public class FunctionalException extends Exception {
+
+ private static final long serialVersionUID = 6712845685798792493L;
+
+ public FunctionalException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public FunctionalException(String message) {
+ super(message);
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/IndexingServiceException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/IndexingServiceException.java
new file mode 100644
index 0000000000..d8b8518919
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/IndexingServiceException.java
@@ -0,0 +1,39 @@
+/*-
+ * ============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.exception;
+
+/**
+ * All errors happened while trying to access to index service
+ *
+ * @author mkv
+ */
+public class IndexingServiceException extends TechnicalException {
+
+ private static final long serialVersionUID = 8644422735660389058L;
+
+ public IndexingServiceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public IndexingServiceException(String message) {
+ super(message);
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/InvalidArgumentException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/InvalidArgumentException.java
new file mode 100644
index 0000000000..ef6cd659e4
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/InvalidArgumentException.java
@@ -0,0 +1,33 @@
+/*-
+ * ============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.exception;
+
+public class InvalidArgumentException extends TechnicalException {
+ private static final long serialVersionUID = 931646037604062840L;
+
+ public InvalidArgumentException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidArgumentException(String message) {
+ super(message);
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/NotFoundException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/NotFoundException.java
new file mode 100644
index 0000000000..988325ff3e
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/NotFoundException.java
@@ -0,0 +1,35 @@
+/*-
+ * ============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.exception;
+
+public class NotFoundException extends TechnicalException {
+
+ private static final long serialVersionUID = -5838741067731786413L;
+
+ public NotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public NotFoundException(String message) {
+ super(message);
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/OkResponseInfo.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/OkResponseInfo.java
new file mode 100644
index 0000000000..78405e0eb1
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/OkResponseInfo.java
@@ -0,0 +1,28 @@
+/*-
+ * ============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.exception;
+
+public class OkResponseInfo extends AbstractSdncException {
+
+ public OkResponseInfo(String messageId, String text, String[] variables) {
+ super(messageId, text, variables);
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/PolicyException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/PolicyException.java
new file mode 100644
index 0000000000..8c5c8609b6
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/PolicyException.java
@@ -0,0 +1,31 @@
+/*-
+ * ============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.exception;
+
+public class PolicyException extends AbstractSdncException {
+
+ public PolicyException(String messageId, String text, String[] variables) {
+ super(messageId, text, variables);
+ }
+
+ public PolicyException() {
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/ResponseFormat.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/ResponseFormat.java
new file mode 100644
index 0000000000..5ccbc25d0e
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/ResponseFormat.java
@@ -0,0 +1,191 @@
+/*-
+ * ============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.exception;
+
+/**
+ * Nested POJOs to express required JSON format of the error
+ *
+ * { "requestError": { "serviceException": { "messageId": "", "text": "",
+ * "variables": [] } } }
+ *
+ *
+ * @author paharoni
+ *
+ */
+
+public class ResponseFormat {
+
+ private int status;
+ private RequestErrorWrapper requestErrorWrapper;
+
+ public ResponseFormat() {
+ super();
+ }
+
+ public ResponseFormat(int status) {
+ super();
+ this.status = status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ public Integer getStatus() {
+ return status;
+ }
+
+ public RequestErrorWrapper getRequestError() {
+ return requestErrorWrapper;
+ }
+
+ public void setRequestError(RequestErrorWrapper requestErrorWrapper) {
+ this.requestErrorWrapper = requestErrorWrapper;
+ }
+
+ public void setPolicyException(PolicyException policyException) {
+ this.requestErrorWrapper = new RequestErrorWrapper(new RequestError());
+ requestErrorWrapper.setPolicyException(policyException);
+ }
+
+ public void setServiceException(ServiceException serviceException) {
+ this.requestErrorWrapper = new RequestErrorWrapper(new RequestError());
+ requestErrorWrapper.setServiceException(serviceException);
+ }
+
+ public void setOkResponseInfo(OkResponseInfo okResponseInfo) {
+ this.requestErrorWrapper = new RequestErrorWrapper(new RequestError());
+ requestErrorWrapper.setOkResponseInfo(okResponseInfo);
+ }
+
+ public String getFormattedMessage() {
+ if (this.requestErrorWrapper.requestError.okResponseInfo != null) {
+ return this.requestErrorWrapper.requestError.okResponseInfo.getFormattedErrorMessage();
+ }
+ if (this.requestErrorWrapper.requestError.serviceException != null) {
+ return this.requestErrorWrapper.requestError.serviceException.getFormattedErrorMessage();
+ }
+ return this.requestErrorWrapper.requestError.policyException.getFormattedErrorMessage();
+ }
+
+ public String getText() {
+ if (this.requestErrorWrapper.requestError.okResponseInfo != null) {
+ return this.requestErrorWrapper.requestError.okResponseInfo.getText();
+ }
+ if (this.requestErrorWrapper.requestError.serviceException != null) {
+ return this.requestErrorWrapper.requestError.serviceException.getText();
+ }
+ return this.requestErrorWrapper.requestError.policyException.getText();
+ }
+
+ public String[] getVariables() {
+ if (this.requestErrorWrapper.requestError.okResponseInfo != null) {
+ return this.requestErrorWrapper.requestError.okResponseInfo.getVariables();
+ }
+ if (this.requestErrorWrapper.requestError.serviceException != null) {
+ return this.requestErrorWrapper.requestError.serviceException.getVariables();
+ }
+ return this.requestErrorWrapper.requestError.policyException.getVariables();
+ }
+
+ public String getMessageId() {
+ if (this.requestErrorWrapper.requestError.okResponseInfo != null) {
+ return this.requestErrorWrapper.requestError.okResponseInfo.getMessageId();
+ }
+ if (this.requestErrorWrapper.requestError.serviceException != null) {
+ return this.requestErrorWrapper.requestError.serviceException.getMessageId();
+ }
+ return this.requestErrorWrapper.requestError.policyException.getMessageId();
+ }
+
+ public class RequestErrorWrapper {
+ private RequestError requestError;
+
+ public RequestErrorWrapper() {
+ this.requestError = new RequestError();
+ }
+
+ public RequestErrorWrapper(RequestError requestError) {
+ this.requestError = requestError;
+ }
+
+ public RequestError getRequestError() {
+ return requestError;
+ }
+
+ public void setRequestError(RequestError requestError) {
+ this.requestError = requestError;
+ }
+
+ public void setPolicyException(PolicyException policyException) {
+ requestError.setPolicyException(policyException);
+ }
+
+ public void setServiceException(ServiceException serviceException) {
+ requestError.setServiceException(serviceException);
+ }
+
+ public void setOkResponseInfo(OkResponseInfo okResponseInfo) {
+ requestError.setOkResponseInfo(okResponseInfo);
+ }
+ }
+
+ public class RequestError {
+ @SuppressWarnings("unused")
+ private PolicyException policyException;
+ @SuppressWarnings("unused")
+ private ServiceException serviceException;
+ @SuppressWarnings("unused")
+ private OkResponseInfo okResponseInfo;
+
+ public RequestError() {
+ }
+
+ public PolicyException getPolicyException() {
+ return policyException;
+ }
+
+ public ServiceException getServiceException() {
+ return serviceException;
+ }
+
+ public OkResponseInfo getOkResponseInfo() {
+ return okResponseInfo;
+ }
+
+ public void setPolicyException(PolicyException policyException) {
+ this.policyException = policyException;
+ }
+
+ public void setServiceException(ServiceException serviceException) {
+ this.serviceException = serviceException;
+ }
+
+ public void setOkResponseInfo(OkResponseInfo okResponseInfo) {
+ this.okResponseInfo = okResponseInfo;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "ResponseFormat[" + "status=" + status + ", requestErrorWrapper=" + requestErrorWrapper + ']';
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/ServiceException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/ServiceException.java
new file mode 100644
index 0000000000..3aae180517
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/ServiceException.java
@@ -0,0 +1,32 @@
+/*-
+ * ============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.exception;
+
+public class ServiceException extends AbstractSdncException {
+
+ public ServiceException(String messageId, String text, String[] variables) {
+ super(messageId, text, variables);
+ }
+
+ public ServiceException() {
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/TechnicalException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/TechnicalException.java
new file mode 100644
index 0000000000..96ef2f3159
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/TechnicalException.java
@@ -0,0 +1,40 @@
+/*-
+ * ============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.exception;
+
+/**
+ * Base class for all Alien technical exception
+ *
+ * @author mkv
+ *
+ */
+public abstract class TechnicalException extends RuntimeException {
+
+ private static final long serialVersionUID = -9152473183025390161L;
+
+ public TechnicalException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public TechnicalException(String message) {
+ super(message);
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/VersionConflictException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/VersionConflictException.java
new file mode 100644
index 0000000000..a998d6393e
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/VersionConflictException.java
@@ -0,0 +1,33 @@
+/*-
+ * ============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.exception;
+
+/**
+ * Exception happens when a4c cannot resolve version conflicts in a transparent
+ * manner for users
+ */
+public class VersionConflictException extends TechnicalException {
+ private static final long serialVersionUID = 1L;
+
+ public VersionConflictException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/Configuration.java b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/Configuration.java
new file mode 100644
index 0000000000..89953d671e
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/Configuration.java
@@ -0,0 +1,304 @@
+/*-
+ * ============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.fe.config;
+
+import java.util.Date;
+import java.util.List;
+
+import org.openecomp.sdc.common.api.BasicConfiguration;
+
+import static java.lang.String.format;
+
+public class Configuration extends BasicConfiguration {
+ /**
+ * fe FQDN
+ */
+ private String feFqdn;
+ /**
+ * backend host
+ */
+ private String beHost;
+ /**
+ * backend http port
+ */
+ private Integer beHttpPort;
+ /**
+ * backend http secured port
+ */
+ private Integer beSslPort;
+
+ private Integer healthCheckSocketTimeoutInMs;
+
+ private Integer healthCheckIntervalInSeconds;
+
+ private FeMonitoringConfig systemMonitoring;
+
+ private String kibanaHost;
+
+ private Integer kibanaPort;
+
+ private String kibanaProtocol;
+
+ private String onboardingForwardContext;
+
+ public String getKibanaProtocol() {
+ return kibanaProtocol;
+ }
+
+ public void setKibanaProtocol(String kibanaProtocol) {
+ this.kibanaProtocol = kibanaProtocol;
+ }
+
+ public String getKibanaHost() {
+ return kibanaHost;
+ }
+
+ public void setKibanaHost(String kibanaHost) {
+ this.kibanaHost = kibanaHost;
+ }
+
+ public Integer getKibanaPort() {
+ return kibanaPort;
+ }
+
+ public void setKibanaPort(Integer kibanaPort) {
+ this.kibanaPort = kibanaPort;
+ }
+
+ public FeMonitoringConfig getSystemMonitoring() {
+ return systemMonitoring;
+ }
+
+ public void setSystemMonitoring(FeMonitoringConfig systemMonitoring) {
+ this.systemMonitoring = systemMonitoring;
+ }
+
+ public Integer getHealthCheckSocketTimeoutInMs() {
+ return healthCheckSocketTimeoutInMs;
+ }
+
+ public Integer getHealthCheckSocketTimeoutInMs(int defaultVal) {
+ return healthCheckSocketTimeoutInMs == null ? defaultVal : healthCheckSocketTimeoutInMs;
+ }
+
+ public void setHealthCheckSocketTimeoutInMs(Integer healthCheckSocketTimeout) {
+ this.healthCheckSocketTimeoutInMs = healthCheckSocketTimeout;
+ }
+
+ public Integer getHealthCheckIntervalInSeconds() {
+ return healthCheckIntervalInSeconds;
+ }
+
+ public Integer getHealthCheckIntervalInSeconds(int defaultVal) {
+ return healthCheckIntervalInSeconds == null ? defaultVal : healthCheckIntervalInSeconds;
+ }
+
+ public void setHealthCheckIntervalInSeconds(Integer healthCheckInterval) {
+ this.healthCheckIntervalInSeconds = healthCheckInterval;
+ }
+
+ /**
+ * be http context
+ */
+ private String beContext;
+ /**
+ * backend protocol. http | https
+ */
+ private String beProtocol = "http";
+
+ private Date released;
+ private String version = "1111";
+ private Connection connection;
+ private List<String> protocols;
+
+ private int threadpoolSize;
+ private int requestTimeout;
+
+ private List<List<String>> identificationHeaderFields;
+ private List<List<String>> optionalHeaderFields;
+
+ public Date getReleased() {
+ return released;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setReleased(Date released) {
+ this.released = released;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public Connection getConnection() {
+ return connection;
+ }
+
+ public void setConnection(Connection connection) {
+ this.connection = connection;
+ }
+
+ public List<String> getProtocols() {
+ return protocols;
+ }
+
+ public void setProtocols(List<String> protocols) {
+ this.protocols = protocols;
+ }
+
+ public String getBeHost() {
+ return beHost;
+ }
+
+ public void setBeHost(String beHost) {
+ this.beHost = beHost;
+ }
+
+ public Integer getBeHttpPort() {
+ return beHttpPort;
+ }
+
+ public void setBeHttpPort(Integer beHttpPort) {
+ this.beHttpPort = beHttpPort;
+ }
+
+ public Integer getBeSslPort() {
+ return beSslPort;
+ }
+
+ public void setBeSslPort(Integer beSslPort) {
+ this.beSslPort = beSslPort;
+ }
+
+ public String getBeContext() {
+ return beContext;
+ }
+
+ public void setBeContext(String beContext) {
+ this.beContext = beContext;
+ }
+
+ public String getBeProtocol() {
+ return beProtocol;
+ }
+
+ public void setBeProtocol(String beProtocol) {
+ this.beProtocol = beProtocol;
+ }
+
+ public int getThreadpoolSize() {
+ return threadpoolSize;
+ }
+
+ public void setThreadpoolSize(int threadpoolSize) {
+ this.threadpoolSize = threadpoolSize;
+ }
+
+ public int getRequestTimeout() {
+ return requestTimeout;
+ }
+
+ public void setRequestTimeout(int requestTimeout) {
+ this.requestTimeout = requestTimeout;
+ }
+
+ public List<List<String>> getIdentificationHeaderFields() {
+ return identificationHeaderFields;
+ }
+
+ public void setIdentificationHeaderFields(List<List<String>> identificationHeaderFields) {
+ this.identificationHeaderFields = identificationHeaderFields;
+ }
+
+ public List<List<String>> getOptionalHeaderFields() {
+ return optionalHeaderFields;
+ }
+
+ public void setOptionalHeaderFields(List<List<String>> optionalHeaderFields) {
+ this.optionalHeaderFields = optionalHeaderFields;
+ }
+
+ public String getFeFqdn() {
+ return feFqdn;
+ }
+
+ public void setFeFqdn(String feFqdn) {
+ this.feFqdn = feFqdn;
+ }
+
+ public static class FeMonitoringConfig {
+
+ Boolean enabled;
+ Boolean isProxy;
+ Integer probeIntervalInSeconds;
+
+ public Boolean getEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(Boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public Boolean getIsProxy() {
+ return isProxy;
+ }
+
+ public void setIsProxy(Boolean isProxy) {
+ this.isProxy = isProxy;
+ }
+
+ public Integer getProbeIntervalInSeconds() {
+ return probeIntervalInSeconds;
+ }
+
+ public Integer getProbeIntervalInSeconds(int defaultVal) {
+ return probeIntervalInSeconds == null ? defaultVal : probeIntervalInSeconds;
+ }
+
+ public void setProbeIntervalInSeconds(Integer probeIntervalInSeconds) {
+ this.probeIntervalInSeconds = probeIntervalInSeconds;
+ }
+ }
+
+ public String getOnboardingForwardContext() {
+ return onboardingForwardContext;
+ }
+
+ public void setOnboardingForwardContext(String onboardingForwardContext) {
+ this.onboardingForwardContext = onboardingForwardContext;
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder().append(format("backend host: %s%n", beHost))
+ .append(format("backend http port: %s%n", beHttpPort))
+ .append(format("backend ssl port: %s%n", beSslPort)).append(format("backend context: %s%n", beContext))
+ .append(format("backend protocol: %s%n", beProtocol))
+ .append(format("onboarding forward context: %s%n", onboardingForwardContext))
+ .append(format("Version: %s%n", version)).append(format("Released: %s%n", released))
+ .append(format("Connecting to database: %s%n", connection))
+ .append(format("Supported protocols: %s%n", protocols)).toString();
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java
new file mode 100644
index 0000000000..b3164fd283
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java
@@ -0,0 +1,117 @@
+/*-
+ * ============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.fe.config;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.openecomp.sdc.common.api.BasicConfiguration;
+import org.openecomp.sdc.common.api.ConfigurationListener;
+import org.openecomp.sdc.common.api.ConfigurationSource;
+import org.openecomp.sdc.common.api.FileChangeCallback;
+import org.openecomp.sdc.common.config.EcompErrorConfiguration;
+import org.openecomp.sdc.common.config.IEcompConfigurationManager;
+import org.openecomp.sdc.common.rest.api.RestConfigurationInfo;
+
+public class ConfigurationManager implements FileChangeCallback, IEcompConfigurationManager {
+
+ ConfigurationSource configurationSource = null;
+ private static ConfigurationManager instance;
+
+ public ConfigurationManager(ConfigurationSource configurationSource) {
+ super();
+ this.configurationSource = configurationSource;
+ loadConfigurationFiles();
+ instance = this;
+ }
+
+ Map<String, Object> configurations = new HashMap<String, Object>();
+
+ private void loadConfigurationFiles() {
+
+ loadConfigurationClass(Configuration.class);
+ loadConfigurationClass(RestConfigurationInfo.class);
+ loadConfigurationClass(EcompErrorConfiguration.class);
+
+ }
+
+ private <T extends BasicConfiguration> void loadConfigurationClass(Class<T> clazz) {
+ ConfigurationListener configurationListener = new ConfigurationListener(clazz, this);
+
+ T object = configurationSource.getAndWatchConfiguration(clazz, configurationListener);
+
+ configurations.put(getKey(clazz), object);
+ }
+
+ private <T> String getKey(Class<T> class1) {
+
+ return class1.getSimpleName();
+
+ }
+
+ public Configuration getConfiguration() {
+
+ return (Configuration) configurations.get(getKey(Configuration.class));
+
+ }
+
+ public RestConfigurationInfo getRestClientConfiguration() {
+
+ return (RestConfigurationInfo) configurations.get(getKey(RestConfigurationInfo.class));
+
+ }
+
+ @Override
+ public EcompErrorConfiguration getEcompErrorConfiguration() {
+
+ return (EcompErrorConfiguration) configurations.get(getKey(EcompErrorConfiguration.class));
+
+ }
+
+ public Configuration getConfigurationAndWatch(ConfigurationListener configurationListener) {
+
+ if (configurationListener != null) {
+
+ configurationSource.addWatchConfiguration(Configuration.class, configurationListener);
+
+ }
+ return (Configuration) configurations.get(getKey(Configuration.class));
+
+ }
+
+ public void reconfigure(BasicConfiguration obj) {
+ //
+ // if (obj != null) {
+ //
+ // if (obj instanceof Configuration) {
+ // configurations.put(getKey(Configuration.class), obj);
+ // }
+ //
+ // if (obj instanceof EcompErrorConfiguration) {
+ // configurations.put(getKey(EcompErrorConfiguration.class), obj);
+ // }
+ // }
+ }
+
+ public static ConfigurationManager getConfigurationManager() {
+ return instance;
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/Connection.java b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/Connection.java
new file mode 100644
index 0000000000..7208398525
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/Connection.java
@@ -0,0 +1,48 @@
+/*-
+ * ============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.fe.config;
+
+public class Connection {
+
+ private String url;
+ private int poolSize;
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public int getPoolSize() {
+ return poolSize;
+ }
+
+ public void setPoolSize(int poolSize) {
+ this.poolSize = poolSize;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("'%s' with pool of %d", getUrl(), getPoolSize());
+ }
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/FeEcompErrorManager.java b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/FeEcompErrorManager.java
new file mode 100644
index 0000000000..6733e179ba
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/FeEcompErrorManager.java
@@ -0,0 +1,77 @@
+/*-
+ * ============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.fe.config;
+
+import org.openecomp.sdc.common.config.AbsEcompErrorManager;
+import org.openecomp.sdc.common.config.EcompErrorEnum;
+import org.openecomp.sdc.common.config.IEcompConfigurationManager;
+import org.openecomp.sdc.fe.config.ConfigurationManager;
+
+public class FeEcompErrorManager extends AbsEcompErrorManager {
+
+ private static volatile FeEcompErrorManager instance;
+ private static ConfigurationManager configurationManager;
+
+ private FeEcompErrorManager() {
+ };
+
+ public static FeEcompErrorManager getInstance() {
+ if (instance == null) {
+
+ instance = init();
+ }
+ return instance;
+ }
+
+ private static synchronized FeEcompErrorManager init() {
+ if (instance == null) {
+ instance = new FeEcompErrorManager();
+ configurationManager = ConfigurationManager.getConfigurationManager();
+ }
+ return instance;
+ }
+
+ @Override
+ public IEcompConfigurationManager getConfigurationManager() {
+ return configurationManager;
+ }
+
+ public void logFeHealthCheckRecovery(String context) {
+ processEcompError(context, EcompErrorEnum.FeHealthCheckRecovery);
+ }
+
+ public void logFeHealthCheckError(String context) {
+ processEcompError(context, EcompErrorEnum.FeHealthCheckError);
+ }
+
+ public void logFeHttpLoggingError(String context) {
+ processEcompError(context, EcompErrorEnum.FeHttpLoggingError);
+ }
+
+ public void logFePortalServletError(String context) {
+ processEcompError(context, EcompErrorEnum.FePortalServletError);
+ }
+
+ public void logFeHealthCheckGeneralError(String context) {
+ processEcompError(context, EcompErrorEnum.FeHealthCheckGeneralError);
+ }
+
+}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/fe/monitoring/FeMonitoringService.java b/common-app-api/src/main/java/org/openecomp/sdc/fe/monitoring/FeMonitoringService.java
new file mode 100644
index 0000000000..482be7697d
--- /dev/null
+++ b/common-app-api/src/main/java/org/openecomp/sdc/fe/monitoring/FeMonitoringService.java
@@ -0,0 +1,140 @@
+/*-
+ * ============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.fe.monitoring;
+
+import java.io.IOException;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.openecomp.sdc.common.api.Constants;
+import org.openecomp.sdc.common.monitoring.MonitoringEvent;
+import org.openecomp.sdc.common.monitoring.MonitoringMetricsFetcher;
+import org.openecomp.sdc.fe.config.Configuration;
+import org.openecomp.sdc.fe.config.ConfigurationManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+public class FeMonitoringService {
+
+ private static final String URL = "%s://%s:%s/sdc2/rest/monitoring";
+ private static Logger monitoringLogger = LoggerFactory.getLogger("asdc.fe.monitoring.service");
+ private static Logger log = LoggerFactory.getLogger(FeMonitoringService.class.getName());
+ private static Gson gson = new GsonBuilder().setPrettyPrinting().create();
+
+ private class MonitoringScheduledTask implements Runnable {
+ @Override
+ public void run() {
+ monitoringLogger.trace("Executing FE Monitoring Task - Start");
+ MonitoringEvent monitoringMetrics = MonitoringMetricsFetcher.getInstance().getMonitoringMetrics();
+ processMonitoringEvent(monitoringMetrics);
+ monitoringLogger.trace("Executing FE Monitoring Task - Status = {}", monitoringMetrics.toString());
+ }
+ }
+
+ /**
+ * This executor will execute the Monitoring task.
+ */
+ ScheduledExecutorService monitoringExecutor = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
+ @Override
+ public Thread newThread(Runnable r) {
+ return new Thread(r, "FE-Monitoring-Thread");
+ }
+ });
+ private ServletContext context;
+
+ public FeMonitoringService(ServletContext context) {
+ this.context = context;
+ }
+
+ public void start(int interval) {
+ Configuration config = ((ConfigurationManager) context.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR))
+ .getConfiguration();
+ if (config.getSystemMonitoring().getEnabled()) {
+ log.info("FE monitoring service enabled, interval is {} seconds", interval);
+ this.monitoringExecutor.scheduleAtFixedRate(new MonitoringScheduledTask(), 0, interval, TimeUnit.SECONDS);
+ } else {
+ log.info("FE monitoring service is disabled");
+ }
+ }
+
+ private void processMonitoringEvent(MonitoringEvent monitoringMetrics) {
+ CloseableHttpClient httpClient = null;
+ try {
+ Configuration config = ((ConfigurationManager) context.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR))
+ .getConfiguration();
+ String redirectedUrl = String.format(URL, config.getBeProtocol(), config.getBeHost(),
+ config.getBeHttpPort());
+ httpClient = getHttpClient(config);
+ HttpPost httpPost = new HttpPost(redirectedUrl);
+ String monitoringMetricsJson = gson.toJson(monitoringMetrics);
+ HttpEntity myEntity = new StringEntity(monitoringMetricsJson);
+ httpPost.setEntity(myEntity);
+ httpPost.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+ int beResponseStatus;
+ CloseableHttpResponse beResponse;
+ try {
+ beResponse = httpClient.execute(httpPost);
+ beResponseStatus = beResponse.getStatusLine().getStatusCode();
+ if (beResponseStatus != HttpStatus.SC_OK) {
+ monitoringLogger.error("Unexpected HTTP response from BE : {}", beResponseStatus);
+ }
+ } catch (Exception e) {
+ monitoringLogger.error("Monitoring error when trying to connect to BE", e);
+ }
+ } catch (Exception e) {
+ monitoringLogger.error("Unexpected monitoring error", e);
+ } finally {
+ if (httpClient != null) {
+ try {
+ httpClient.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ }
+
+ private CloseableHttpClient getHttpClient(Configuration config) {
+ int timeout = 3000;
+ RequestConfig.Builder requestBuilder = RequestConfig.custom();
+ requestBuilder.setConnectTimeout(timeout).setConnectionRequestTimeout(timeout).setSocketTimeout(timeout);
+
+ HttpClientBuilder builder = HttpClientBuilder.create();
+ builder.setDefaultRequestConfig(requestBuilder.build());
+ return builder.build();
+ }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/data_structure/CapListTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/data_structure/CapListTest.java
new file mode 100644
index 0000000000..7aeb2ac70d
--- /dev/null
+++ b/common-app-api/src/test/java/org/openecomp/sdc/common/data_structure/CapListTest.java
@@ -0,0 +1,126 @@
+/*-
+ * ============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.common.data_structure;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.junit.Test;
+import org.openecomp.sdc.common.datastructure.CapList;
+
+public class CapListTest {
+ public enum LIST_ACTION {
+ Add, Remove, Size, Get
+ }
+
+ @Test
+ public void testCap() {
+ List<Integer> testList = new CapList<>(10);
+ for (int i = 0; i < 100; i++) {
+ testList.add(i);
+ }
+ assertTrue(testList.size() == 10);
+ for (int i = 0; i < testList.size(); i++) {
+ assertTrue(testList.get(i) == (i + 90));
+ }
+ }
+
+ @Test
+ public void testThreadSafe() {
+ List<Integer> testList = new CapList<>(1000);
+
+ ExecutorService executor = Executors.newFixedThreadPool(4);
+ for (int i = 0; i < 10; i++) {
+ Runnable worker;
+ // 0 - 4
+ if (i < 5) {
+ worker = new ThreadWorker(i, LIST_ACTION.Add, testList);
+ }
+ // 5, 8
+ else if (i == 5 || i == 8) {
+ worker = new ThreadWorker(i, LIST_ACTION.Remove, testList);
+ }
+ // 6
+ else if (i == 6) {
+ worker = new ThreadWorker(i, LIST_ACTION.Size, testList);
+ }
+ // 7, 9
+ else {
+ worker = new ThreadWorker(i, LIST_ACTION.Get, testList);
+ }
+ executor.execute(worker);
+ }
+ executor.shutdown();
+ while (!executor.isTerminated()) {
+ }
+ assertTrue(testList.size() == 60);
+ }
+
+ public static class ThreadWorker implements Runnable {
+ private LIST_ACTION action;
+ private List<Integer> list;
+ private Integer id;
+
+ ThreadWorker(Integer id, LIST_ACTION action, List<Integer> list) {
+ this.action = action;
+ this.list = list;
+ this.id = id;
+ }
+
+ @Override
+ public void run() {
+ for (int i = 0; i < 20; i++) {
+ threadNap();
+ switch (action) {
+ case Add:
+ list.add(id * 100 + i);
+ break;
+ case Remove: {
+ int index = (int) (Math.random() * 10);
+ list.remove(index);
+ break;
+ }
+ case Get:
+ int index = (int) (Math.random() * 10);
+ Integer integer = list.get(index);
+
+ break;
+ case Size:
+ int size = list.size();
+ break;
+ }
+ }
+
+ }
+
+ private void threadNap() {
+ long napTime = (long) (Math.random() * 100);
+ try {
+ Thread.sleep(napTime);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java
new file mode 100644
index 0000000000..1a062576dc
--- /dev/null
+++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java
@@ -0,0 +1,549 @@
+/*-
+ * ============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.common.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.jsoup.Jsoup;
+import org.jsoup.safety.Whitelist;
+import org.junit.Test;
+import org.openecomp.sdc.common.api.Constants;
+import org.openecomp.sdc.common.util.GeneralUtility;
+import org.openecomp.sdc.common.util.HtmlCleaner;
+import org.openecomp.sdc.common.util.ValidationUtils;
+import org.openecomp.sdc.common.util.YamlToObjectConverter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.html.HTMLStyleElement;
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+
+public class CommonUtilsTest {
+ private static Logger log = LoggerFactory.getLogger(CommonUtilsTest.class.getName());
+
+ /*
+ * Validation utils start
+ */
+ @Test
+ public void testValidateServiceName() {
+
+ assertTrue(ValidationUtils.validateComponentNamePattern("1111222"));
+ assertTrue(ValidationUtils.validateComponentNamePattern("sfE4444"));
+ assertTrue(ValidationUtils.validateComponentNamePattern("1111sfd222"));
+ assertTrue(ValidationUtils.validateComponentNamePattern("11sdf 1124_22"));
+ assertTrue(ValidationUtils.validateComponentNamePattern("111----1222"));
+ assertTrue(ValidationUtils.validateComponentNamePattern("1111f .222"));
+ assertTrue(ValidationUtils.validateComponentNamePattern("1111222"));
+ assertFalse(ValidationUtils.validateComponentNamePattern("11!11222"));
+ assertFalse(ValidationUtils.validateComponentNamePattern("111|`1222"));
+
+ }
+
+ @Test
+ public void validateServiceNameLengthTest() {
+ assertTrue(ValidationUtils.validateComponentNameLength("fsdlfsdlksdsd;"));
+ // assertFalse(ValidationUtils.validateComponentNameLength("ddddddddddddddddddddddsdfsddddddddddddddddddddddsdfs"));
+ }
+
+ @Test
+ public void testValidateIcon() {
+
+ assertTrue(ValidationUtils.validateIcon("something"));
+ assertTrue(ValidationUtils.validateIcon("sfE4444"));
+ assertTrue(ValidationUtils.validateIcon("1111sfd222"));
+ assertTrue(ValidationUtils.validateIcon("11sdf1124_22"));
+ assertTrue(ValidationUtils.validateIcon("111----1222"));
+ assertFalse(ValidationUtils.validateIcon("1111f.222"));
+ assertTrue(ValidationUtils.validateIcon("1111222"));
+ assertFalse(ValidationUtils.validateIcon("1111 222"));
+ assertFalse(ValidationUtils.validateIcon("11!11222"));
+ assertFalse(ValidationUtils.validateIcon("111|`1222"));
+
+ }
+
+ @Test
+ public void testFloatParsing() {
+ assertTrue(ValidationUtils.isFloatNumber("15555.45"));
+ assertTrue(ValidationUtils.isFloatNumber("0.5"));
+ assertFalse(ValidationUtils.isFloatNumber("15555"));
+ assertFalse(ValidationUtils.isFloatNumber("1"));
+ assertFalse(ValidationUtils.isFloatNumber("jk532"));
+ assertFalse(ValidationUtils.isFloatNumber("12..6"));
+
+ }
+
+ @Test
+ public void testValidateIconLength() {
+ assertTrue(ValidationUtils.validateIconLength("fsdlfsdlksdsd"));
+ assertFalse(ValidationUtils.validateIconLength("ddddddddddddddddddddddsdfsddddddddddddddddddddddsdfs"));
+ }
+
+ // 1610OS Support - Because of changes in the validation in the ui this test needs to be fixed
+// @Test
+// public void testValidateProjectCode() {
+//
+// assertTrue(ValidationUtils.validateProjectCode("15555"));
+// assertTrue(ValidationUtils.validateProjectCode("12434501"));
+// assertTrue(ValidationUtils.validateProjectCode("00000"));
+// assertFalse(ValidationUtils.validateProjectCode("something"));
+// assertFalse(ValidationUtils.validateProjectCode("som ething"));
+// assertFalse(ValidationUtils.validateProjectCode("3255 656"));
+// assertFalse(ValidationUtils.validateProjectCode("43535t636"));
+// assertFalse(ValidationUtils.validateProjectCode("098&656"));
+// }
+
+ @Test
+ public void testValidateProjectCodeLength() {
+ assertTrue(ValidationUtils.validateProjectCodeLegth("00000"));
+ assertFalse(ValidationUtils.validateProjectCodeLegth("ddddddddddddddddddddddsdfsddddddddddddddddddddddsdfs"));
+ }
+
+ // 1610OS Support - Because of changes in the validation in the ui this test needs to be fixed
+// @Test
+// public void testValidateContactId() {
+//
+// assertTrue(ValidationUtils.validateContactId("ml7889"));
+// assertTrue(ValidationUtils.validateContactId("Ml7889"));
+// assertTrue(ValidationUtils.validateContactId("ml788r"));
+// assertFalse(ValidationUtils.validateContactId("something"));
+// assertFalse(ValidationUtils.validateContactId("mlk111"));
+// assertFalse(ValidationUtils.validateContactId("12ml89"));
+// assertFalse(ValidationUtils.validateContactId("!!78900"));
+// }
+
+ @Test
+ public void testRemoveHtml() {
+
+ assertTrue("gooboo".equals(ValidationUtils.removeHtmlTags("<b>goo<b></b></b><b>boo</b>")));
+ assertTrue("goo&lt;boo".equals(ValidationUtils.removeHtmlTags("<b>goo<b></b><</b><b>boo</b>")));
+ assertTrue("goo boo".equals(ValidationUtils.removeHtmlTags("goo boo")));
+ assertTrue("goo# . boo12".equals(ValidationUtils.removeHtmlTags("goo# . boo12")));
+ }
+
+ @Test
+ public void testnormaliseWhitespace() {
+
+ assertTrue("goo boo".equals(ValidationUtils.normaliseWhitespace("goo boo")));
+ assertTrue("goo boo ".equals(ValidationUtils.normaliseWhitespace("goo boo ")));
+ assertTrue("goo boo".equals(ValidationUtils.normaliseWhitespace("goo boo")));
+ }
+
+ @Test
+ public void teststripOctets() {
+ assertTrue("goo boo".equals(ValidationUtils.stripOctets("goo%1F boo")));
+ assertTrue("goo boo ".equals(ValidationUtils.stripOctets("goo boo %1F")));
+ assertTrue("goo boo".equals(ValidationUtils.stripOctets("%1Fgoo boo")));
+ }
+
+ @Test
+ public void testRemoveNoneUtf8Chars() {
+ assertTrue("goo boo".equals(ValidationUtils.removeNoneUtf8Chars("goo boo")));
+ assertTrue("goo boo!!._".equals(ValidationUtils.removeNoneUtf8Chars("goo boo!!._")));
+ assertTrue("goo boo".equals(ValidationUtils.removeNoneUtf8Chars("goo boo")));
+ assertTrue("goo bo123o".equals(ValidationUtils.removeNoneUtf8Chars("goo bo123o")));
+ assertTrue("goo bo123o".equals(ValidationUtils.removeNoneUtf8Chars("goo קקbo123oגכקק")));
+ assertTrue("goo bo123o".equals(ValidationUtils.removeNoneUtf8Chars("goo bo1������23o")));
+ }
+
+ @Test
+ public void validateEnglishTest() {
+ assertTrue(ValidationUtils.validateIsEnglish("ml7889"));
+ assertFalse(ValidationUtils.validateIsEnglish("ml7889קר"));
+ assertFalse(ValidationUtils.validateIsEnglish("ml7889æ–‡"));
+ }
+
+ @Test
+ public void removeDuplicateFromListTest() {
+ List<String> tagsBefore = new ArrayList<>();
+ tagsBefore.add("tag1");
+ tagsBefore.add("tag7");
+ tagsBefore.add("tag3");
+ tagsBefore.add("tag4");
+ tagsBefore.add("tag1");
+
+ List<String> tagsAfter = new ArrayList<>();
+ tagsAfter.add("tag1");
+ tagsAfter.add("tag7");
+ tagsAfter.add("tag3");
+ tagsAfter.add("tag4");
+ assertTrue(tagsAfter.containsAll(ValidationUtils.removeDuplicateFromList(tagsBefore)));
+ tagsBefore = new ArrayList<>();
+ tagsBefore.add("tag1");
+ tagsBefore.add("tag7");
+ tagsBefore.add("tag3");
+ tagsBefore.add("tag4");
+ tagsBefore.add("Tag1");
+
+ tagsAfter = new ArrayList<>();
+ tagsAfter.add("tag1");
+ tagsAfter.add("tag7");
+ tagsAfter.add("tag3");
+ tagsAfter.add("tag4");
+ tagsAfter.add("Tag1");
+ assertTrue(tagsAfter.containsAll(ValidationUtils.removeDuplicateFromList(tagsBefore)));
+ }
+
+ @Test
+ public void validateTagLengthTest() {
+ assertTrue(ValidationUtils.validateTagLength("fsdlfsdlkfjkljsdf"));
+ // assertFalse(ValidationUtils.validateTagLength("ddddddddddddddddddddddsdfsddddddddddddddddddddddsdfs"));
+
+ }
+
+ @Test
+ public void validateTagListLengthTest() {
+ assertTrue(ValidationUtils.validateTagListLength("fsdlfsdlkfjkljsdf,dsfsdfsdf".length()));
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i <= 1024; i++) {
+ sb.append("a");
+ }
+ assertFalse(ValidationUtils.validateTagListLength(sb.toString().length()));
+
+ }
+
+ @Test
+ public void validateDescriptionLengthTest() {
+ assertTrue(ValidationUtils.validateDescriptionLength("fsdlfsdlkfjkljsddgfgdfgdfgdfgff"));
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i <= 1024; i++) {
+ sb.append("a");
+ }
+ assertFalse(ValidationUtils.validateDescriptionLength(sb.toString()));
+
+ }
+
+ @Test
+ public void validateStringNotEmptyTest() {
+ assertTrue(ValidationUtils.validateStringNotEmpty("fsdlfsdlk"));
+ assertFalse(ValidationUtils.validateStringNotEmpty(""));
+ assertFalse(ValidationUtils.validateStringNotEmpty(" "));
+ assertFalse(ValidationUtils.validateStringNotEmpty(" "));
+ }
+
+ @Test
+ public void validateVendorNameTest() {
+ assertTrue(ValidationUtils.validateVendorName("fsdlfsdlk"));
+ assertTrue(ValidationUtils.validateVendorName("fsdlfsdlk.sdsd;"));
+ assertFalse(ValidationUtils.validateVendorName("sadf:"));
+ assertFalse(ValidationUtils.validateVendorName("sadf/"));
+ assertFalse(ValidationUtils.validateVendorName("sadf?"));
+ }
+
+ @Test
+ public void validateVendorNameLengthTest() {
+ assertTrue(ValidationUtils.validateVendorNameLength("fsdlfsdlk.sdsd;"));
+ assertFalse(ValidationUtils.validateVendorNameLength("ddddddddddddddddddddddsdfs"));
+ }
+
+ @Test
+ public void validateVendorReleaseTest() {
+ assertTrue(ValidationUtils.validateVendorRelease("fsdlfsdlk"));
+ assertTrue(ValidationUtils.validateVendorRelease("fsdlfsdlk.sdsd;"));
+ assertFalse(ValidationUtils.validateVendorRelease("sadf:"));
+ assertFalse(ValidationUtils.validateVendorRelease("sadf/"));
+ assertFalse(ValidationUtils.validateVendorRelease("sadf?"));
+ }
+
+ @Test
+ public void validateVendorReleaseLengthTest() {
+ assertTrue(ValidationUtils.validateVendorNameLength("fsdlfsdlk.sdsd;"));
+ assertFalse(ValidationUtils.validateVendorNameLength("ddddddddddddddddddddddsdfs"));
+ }
+
+ @Test
+ public void hasBeenCertifiedTest() {
+ assertTrue(ValidationUtils.hasBeenCertified("1.2"));
+ assertTrue(ValidationUtils.hasBeenCertified("2.2"));
+ assertTrue(ValidationUtils.hasBeenCertified("1.0"));
+ assertFalse(ValidationUtils.hasBeenCertified("0.1"));
+
+ }
+
+ @Test
+ public void normalizedNameTest() {
+ String input = "MyNewSysName";
+ String outputNorm = ValidationUtils.normaliseComponentName(input);
+ String outputSys = ValidationUtils.convertToSystemName(input);
+ log.debug("{} <> {} <> {}", input, outputNorm, outputSys);
+
+ input = "My New Sys Name";
+ outputNorm = ValidationUtils.normaliseComponentName(input);
+ outputSys = ValidationUtils.convertToSystemName(input);
+ log.debug("{} <> {} <> {}", input, outputNorm, outputSys);
+
+ input = "My.New-Sys_Name";
+ outputNorm = ValidationUtils.normaliseComponentName(input);
+ outputSys = ValidationUtils.convertToSystemName(input);
+ log.debug("{} <> {} <> {}", input, outputNorm, outputSys);
+
+ input = "My..New-Sys_Name";
+ outputNorm = ValidationUtils.normaliseComponentName(input);
+ outputSys = ValidationUtils.convertToSystemName(input);
+ log.debug("{} <> {} <> {}", input, outputNorm, outputSys);
+
+ input = "My.New--sys_NAme";
+ outputNorm = ValidationUtils.normaliseComponentName(input);
+ outputSys = ValidationUtils.convertToSystemName(input);
+ log.debug("{} <> {} <> {}", input, outputNorm, outputSys);
+
+ input = "Layer 3 Connectivity";
+ outputNorm = ValidationUtils.normaliseComponentName(input);
+ outputSys = ValidationUtils.convertToSystemName(input);
+ log.debug("{} <> {} <> {}", input, outputNorm, outputSys);
+
+ input = "Layer 3 VPN";
+ outputNorm = ValidationUtils.normaliseComponentName(input);
+ outputSys = ValidationUtils.convertToSystemName(input);
+ log.debug("{} <> {} <> {}", input, outputNorm, outputSys);
+
+ input = "Layer-3 Connectivity";
+ outputNorm = ValidationUtils.normaliseComponentName(input);
+ outputSys = ValidationUtils.convertToSystemName(input);
+ log.debug("{} <> {} <> {}", input, outputNorm, outputSys);
+
+ input = "IP-connectivity";
+ outputNorm = ValidationUtils.normaliseComponentName(input);
+ outputSys = ValidationUtils.convertToSystemName(input);
+ log.debug("{} <> {} <> {}", input, outputNorm, outputSys);
+
+ }
+
+ @Test
+ public void normalizeFileNameTest() {
+ assertTrue("too.jpeg".equals(ValidationUtils.normalizeFileName("too.jpeg")));
+ assertTrue("too..jpeg".equals(ValidationUtils.normalizeFileName("too..jpeg")));
+ assertTrue("too..jpeg".equals(ValidationUtils.normalizeFileName("t*o:o..jpe<>g")));
+ assertTrue("goo.too..jpeg".equals(ValidationUtils.normalizeFileName("goo.t*o:o..jpe<>g")));
+ assertTrue("goo.too..jpeg".equals(ValidationUtils.normalizeFileName(" goo.t*o:o..jpe<>g ")));
+ assertTrue("goo-too-mo.jpeg".equals(ValidationUtils.normalizeFileName("goo too----mo.jpeg")));
+ assertTrue("goo-too-mo.jpeg".equals(ValidationUtils.normalizeFileName(".\\..\\goo too----mo.jpeg")));
+ assertTrue("goo-too-mo.jpeg".equals(ValidationUtils.normalizeFileName("__--goo too----mo.jpeg--__")));
+ assertTrue("goo-too-mo.jpeg".equals(ValidationUtils.normalizeFileName("_ -goo too----mo.jpeg _-- _-")));
+
+ }
+
+ @Test
+ public void validateUrlTest() {
+ assertTrue(ValidationUtils.validateUrl("http://google.co.il/"));
+ assertTrue(ValidationUtils.validateUrl("https://google.co.il/"));
+ assertTrue(ValidationUtils.validateUrl("https://google.co.il/go/go"));
+ assertTrue(ValidationUtils.validateUrl("https://google.co.il/go/go"));
+ assertTrue(ValidationUtils.validateUrl("http://google.co.il/go/go"));
+ assertFalse(ValidationUtils.validateUrl("google.co.il/go/go"));
+ assertFalse(ValidationUtils.validateUrl("https://google.co.il/go/go!"));
+ assertFalse(ValidationUtils.validateUrl("https://g;oogle.co.il/go/go"));
+
+ }
+
+ @Test
+ public void normalizeArtifactLabel() {
+ assertEquals(ValidationUtils.normalizeArtifactLabel("Test--3 134++"), "test3134");
+ }
+
+ @Test
+ public void cleanArtifactLabel() {
+ assertEquals(ValidationUtils.cleanArtifactDisplayName("Test--3 134++"), "Test-3 134+");
+ }
+
+ @Test
+ public void validateArtifactLabel() {
+ assertTrue(ValidationUtils.validateArtifactLabel("dsflkjsdf345JKL"));
+ assertTrue(ValidationUtils.validateArtifactLabel("dsfsd lkj "));
+ assertTrue(ValidationUtils.validateArtifactLabel("sdfdsf---+"));
+ assertTrue(ValidationUtils.validateArtifactLabel(" - +"));
+ assertFalse(ValidationUtils.validateArtifactLabel("sfsdfhkj111="));
+ assertFalse(ValidationUtils.validateArtifactLabel("sfsdfhkj111=dfsf%"));
+ assertFalse(ValidationUtils.validateArtifactLabel("sdfsdfljghgklsdg908*"));
+
+ }
+
+ @Test
+ public void validateConsumerNameTest() {
+ assertTrue(ValidationUtils.validateConsumerName("ab037cd"));
+ assertFalse(ValidationUtils.validateConsumerName(" "));
+ assertTrue(ValidationUtils.validateConsumerName("_dD.d9"));
+ assertTrue(ValidationUtils.validateConsumerName("_dd.G9-"));
+ assertFalse(ValidationUtils.validateConsumerName(".dA.d9-"));
+ assertFalse(ValidationUtils.validateConsumerName("-d"));
+ assertFalse(ValidationUtils.validateConsumerName("d?"));
+ assertTrue(ValidationUtils.validateConsumerName("9"));
+ }
+
+ @Test
+ public void validateConsumerPassSaltTest() {
+ assertTrue(ValidationUtils.validateConsumerPassSalt("ad35fg2"));
+ assertTrue(ValidationUtils.validateConsumerPassSalt("12s"));
+ assertTrue(ValidationUtils.validateConsumerPassSalt("9"));
+ assertFalse(ValidationUtils.validateConsumerPassSalt("dA.d9-"));
+ assertFalse(ValidationUtils.validateConsumerPassSalt("dASQe"));
+ assertFalse(ValidationUtils.validateConsumerPassSalt("_d"));
+ assertFalse(ValidationUtils.validateConsumerPassSalt("?"));
+ assertFalse(ValidationUtils.validateConsumerPassSalt(""));
+ assertFalse(ValidationUtils.validateConsumerPassSalt(" "));
+ }
+
+ @Test
+ public void validateCategoryNameFormatTest() {
+ assertTrue(ValidationUtils.validateCategoryDisplayNameFormat("Net ele-2_3#456&+.'=:@@@@@#####"));
+ // this will fail at length
+ assertTrue(ValidationUtils.validateCategoryDisplayNameFormat(null));
+ // * is not allowed
+ assertFalse(ValidationUtils.validateCategoryDisplayNameFormat("Net ele-2_3#456&*+.'=:@"));
+ assertFalse(ValidationUtils.validateCategoryDisplayNameFormat(""));
+ // should start with alphanumeric
+ assertFalse(ValidationUtils.validateCategoryDisplayNameFormat("#abcdef"));
+ }
+
+ @Test
+ public void validateCategoryNameLengthTest() {
+ assertTrue(ValidationUtils.validateCategoryDisplayNameLength("Netele-2_3#456&+.'=:@@@@@"));
+ assertTrue(ValidationUtils.validateCategoryDisplayNameLength("Nete"));
+ assertFalse(ValidationUtils.validateCategoryDisplayNameLength("Netele-2_3#456&+.'=:@@@@@1"));
+ assertFalse(ValidationUtils.validateCategoryDisplayNameLength("Net"));
+ assertFalse(ValidationUtils.validateCategoryDisplayNameLength(null));
+ }
+
+ @Test
+ public void normalizeCategoryNameTest() {
+ assertEquals("NeteLE-2_3 of #456&+. & Goal a Abc'=:@ AT & T", ValidationUtils.normalizeCategoryName4Display(
+ " neteLE---2___3 OF ###456&&&+++... aNd goal A abc'''==::@@@@@ AT and T "));
+ assertEquals("The Bank of America", ValidationUtils.normalizeCategoryName4Display("The Bank OF America"));
+ }
+
+ @Test
+ public void normalizeCategoryLabelTest() {
+ assertEquals("netele-2_3 of #456&+.&goal a abc'=:@ at&t",
+ ValidationUtils.normalizeCategoryName4Uniqueness("NeteLE-2_3 of #456&+.&Goal a Abc'=:@ AT&T"));
+ }
+
+ /*
+ * Validation utils end
+ */
+
+ /*
+ * General utility start
+ */
+
+ @Test
+ public void validateFileExtension() {
+ assertEquals(Constants.EMPTY_STRING, GeneralUtility.getFilenameExtension("lalatru"));
+ assertEquals(Constants.EMPTY_STRING, GeneralUtility.getFilenameExtension("aa."));
+ assertEquals(Constants.EMPTY_STRING, GeneralUtility.getFilenameExtension(null));
+ assertEquals("yaml", GeneralUtility.getFilenameExtension("lala.tru.yaml"));
+ assertEquals("txt", GeneralUtility.getFilenameExtension("kuku.txt"));
+ }
+
+ @Test
+ public void yamlTest() {
+
+ log.debug("\"kuku\"");
+ DumperOptions options = new DumperOptions();
+ // options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
+ options.setDefaultScalarStyle(DumperOptions.ScalarStyle.FOLDED);
+ Yaml yaml = new Yaml(options);
+
+ Map<String, Object> parameters = new HashMap<String, Object>();
+ parameters.put("k1", "val");
+ parameters.put("k2", "\"val\"");
+
+ String str = yaml.dump(parameters);
+ log.debug(str);
+ }
+
+ @Test
+ public void yamlValidTest() {
+
+ StringBuffer sb = new StringBuffer();
+ sb.append("key: \"!@;/?:&=+$,_.~*'()[]\"");
+ byte[] payload = sb.toString().getBytes();// Base64.decodeBase64(sb.toString());
+
+ YamlToObjectConverter yamlToObjectConverter = new YamlToObjectConverter();
+
+ assertTrue(yamlToObjectConverter.isValidYaml(payload));
+ }
+
+ @Test
+ public void testRemoveOnlyHtmlTags() {
+
+ assertEquals("gooboo", HtmlCleaner.stripHtml("<b>goo<b></b></b><b>boo</b>"));
+ String str = HtmlCleaner.stripHtml("<esofer><b>goo<b></b><</b><b>boo</b>");
+
+ String stripHtmlAndEscape = HtmlCleaner.stripHtml("<esofer><b>goo<b></b><</b><b>boo</b>");
+ assertEquals("<esofer>goo<boo", stripHtmlAndEscape);
+
+ stripHtmlAndEscape = HtmlCleaner.stripHtml("<esofer><b>goo<b></b><</b><b>boo</b>", true);
+ assertEquals("&lt;esofer&gt;goo&lt;boo", stripHtmlAndEscape);
+
+ stripHtmlAndEscape = HtmlCleaner.stripHtml("<esofer><b>goo<b></b><&</b><b>boo</b>dvc&", true);
+ assertEquals("&lt;esofer&gt;goo&lt;&amp;boodvc&amp;", stripHtmlAndEscape);
+
+ assertEquals("esofer&gt;&gt;&lt;&lt;", HtmlCleaner.stripHtml("esofer>><<", true));
+ assertEquals("esofer>><<", HtmlCleaner.stripHtml("esofer>><<", false));
+
+ assertEquals("<esofer1>><<esofer2>", HtmlCleaner.stripHtml("<esofer1>><<esofer2>"));
+
+ assertEquals("<esofer1 a= b>><<esofer2>", HtmlCleaner.stripHtml("<esofer1 a= b><h1>><<esofer2><br>"));
+
+ assertEquals("&lt;esofer1 a= 'b'&gt;&gt;&lt;&lt;esofer2&gt;",
+ HtmlCleaner.stripHtml("<esofer1 a= 'b'>><<esofer2>", true));
+ assertEquals("<esofer1 a= 'b'>><<esofer2>", HtmlCleaner.stripHtml("<esofer1 a= 'b'>><H6><<esofer2>"));
+
+ assertEquals("<esofer1 a= b>><<esofer2>", HtmlCleaner.stripHtml("<esofer1 a= b>><<esofer2>"));
+
+ assertEquals("<esofer1 sd sa= b>><<esofer2>", HtmlCleaner.stripHtml("<esofer1 sd sa= b>><<esofer2>"));
+
+ assertEquals("&lt;esofer1 sd sa= b&gt;&gt;&lt;&lt;esofer2&gt;",
+ HtmlCleaner.stripHtml("<esofer1 sd sa= b>><<esofer2>", true));
+ assertEquals("<esofer1 sd sa= b>><<esofer2>", HtmlCleaner.stripHtml("<esofer1 sd sa= b>><<esofer2>", false));
+ assertEquals("&lt;esofer1 sd sa= b&gt;&gt;&lt;&lt;esofer2&gt;",
+ HtmlCleaner.stripHtml("<esofer1 sd sa= b>><<esofer2>", true));
+ assertEquals("<esofer1 sd sa= b>><<esofer2>",
+ HtmlCleaner.stripHtml("<esofer1 sd sa= b>><br><H1><<esofer2>", false));
+ assertEquals("&lt;esofer&gt;goo&lt;&amp;boodvc&amp;",
+ HtmlCleaner.stripHtml("<esofer><b>goo<b></b><&</b><b>boo</b>dvc&", true));
+ assertEquals("<esofer>goo<&boodvc&", HtmlCleaner.stripHtml("<esofer><b>goo<b></b><&</b><b>boo</b>dvc&", false));
+ assertEquals("<<<>>>;\"", HtmlCleaner.stripHtml("<<<>>>;\"", false));
+ assertEquals("&lt;&lt;&lt;&gt;&gt;&gt;;&quot;", HtmlCleaner.stripHtml("<<<>>>;\"", true));
+ assertEquals("<<<>>>;\"", HtmlCleaner.stripHtml("<<<>>>;\"", false));
+ assertEquals("abc ab a", HtmlCleaner.stripHtml("abc ab a", true));
+ assertEquals("abc ab a", HtmlCleaner.stripHtml("abc ab a", false));
+ assertEquals("< esofer1 sd &<>sa= b>><<esofer2>",
+ HtmlCleaner.stripHtml("< esofer1 sd &<>sa= b>><br><H1><<esofer2>", false));
+ assertEquals("sa= b>><<esofer2>", HtmlCleaner.stripHtml("<br sd &<>sa= b>><br><H1><<esofer2>", false));
+ assertEquals("< br sd &<>sa= b>><<esofer2>",
+ HtmlCleaner.stripHtml("< br sd &<>sa= b>><br><H1><<esofer2>", false));
+ assertEquals("sa= b>><<esofer2>", HtmlCleaner.stripHtml("</br sd &<>sa= b>><br><H1><<esofer2>", false));
+ assertEquals("sa= b>><<esofer2>", HtmlCleaner.stripHtml("<br sd &</>sa= b>><br><H1><<esofer2>", false));
+
+ }
+
+ /*
+ * General utility end
+ */
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/TestExternalConfiguration.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/TestExternalConfiguration.java
new file mode 100644
index 0000000000..aa3b2e4083
--- /dev/null
+++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/TestExternalConfiguration.java
@@ -0,0 +1,258 @@
+/*-
+ * ============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.common.test;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.mockito.Matchers.anyList;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.openecomp.sdc.be.config.DistributionEngineConfiguration;
+import org.openecomp.sdc.common.api.BasicConfiguration;
+import org.openecomp.sdc.common.api.ConfigurationListener;
+import org.openecomp.sdc.common.api.ConfigurationSource;
+import org.openecomp.sdc.common.api.FileChangeCallback;
+import org.openecomp.sdc.common.impl.ConfigFileChangeListener;
+import org.openecomp.sdc.common.impl.ExternalConfiguration;
+import org.openecomp.sdc.common.impl.FSConfigurationSource;
+import org.openecomp.sdc.common.test.config.TestConfiguration;
+import org.openecomp.sdc.common.test.config.TestNotExistConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestExternalConfiguration {
+
+ private static Logger log = LoggerFactory.getLogger(TestExternalConfiguration.class.getName());
+ private static final String NEW_LINE = System.getProperty("line.separator");
+ ConfigurationSource configurationSource = null;
+
+ @Before
+ public void setup() {
+
+ ExternalConfiguration.setAppName("common");
+ ExternalConfiguration.setConfigDir("src/test/resources/config");
+ ExternalConfiguration.listenForChanges();
+
+ configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), ExternalConfiguration.getConfigDir() + File.separator + ExternalConfiguration.getAppName());
+
+ }
+
+ @Test
+ public void testReadConfigurationFile() {
+
+ ConfigurationListener configurationListener = new ConfigurationListener(TestConfiguration.class, new FileChangeCallback() {
+
+ public void reconfigure(BasicConfiguration obj) {
+ // TODO Auto-generated method stub
+ log.debug("In reconfigure of {}", obj);
+ }
+
+ });
+
+ TestConfiguration testConfiguration = configurationSource.getAndWatchConfiguration(TestConfiguration.class, configurationListener);
+
+ assertTrue(testConfiguration != null);
+ log.debug("{}", testConfiguration);
+ assertEquals(testConfiguration.getBeHost(), "172.20.37.245");
+ assertEquals(testConfiguration.getBeProtocol(), "http");
+ assertEquals(testConfiguration.getBeContext(), "/sdc/rest/config/get");
+
+ }
+
+ @Test
+ public void testNotExistConfigurationFile() {
+
+ ConfigurationListener configurationListener = new ConfigurationListener(TestConfiguration.class, new FileChangeCallback() {
+
+ public void reconfigure(BasicConfiguration obj) {
+ // TODO Auto-generated method stub
+ log.debug("In reconfigure of {}", obj);
+ }
+
+ });
+
+ TestNotExistConfiguration testConfiguration = configurationSource.getAndWatchConfiguration(TestNotExistConfiguration.class, configurationListener);
+
+ assertTrue(testConfiguration == null);
+
+ }
+
+ @Test
+ public void testUpdateConfigurationFile() {
+
+ ConfigurationListener configurationListener = new ConfigurationListener(TestConfiguration.class, new FileChangeCallback() {
+
+ public void reconfigure(BasicConfiguration obj) {
+ // TODO Auto-generated method stub
+ log.debug("In reconfigure of {}", obj);
+ // assertEquals(((TestConfiguration)obj).getBeSslPort(),
+ // 8444);
+
+ // assertTrue(((TestConfiguration)obj).getBeSslPort() ==
+ // 8444);
+ }
+
+ });
+
+ TestConfiguration testConfiguration = configurationSource.getAndWatchConfiguration(TestConfiguration.class, configurationListener);
+
+ assertTrue(testConfiguration != null);
+ log.debug("{}", testConfiguration);
+ assertEquals(testConfiguration.getBeHost(), "172.20.37.245");
+ assertEquals(testConfiguration.getBeProtocol(), "http");
+ assertEquals(testConfiguration.getBeContext(), "/sdc/rest/config/get");
+
+ // updateFileContent();
+
+ }
+
+ private void updateFileContent() {
+ File file = new File(ExternalConfiguration.getConfigDir() + File.separator + ExternalConfiguration.getAppName() + File.separator + "test-configuration.yaml");
+ replaceFile(file);
+
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void replaceFile(File f1) {
+ FileReader fr = null;
+ BufferedReader br = null;
+ FileWriter fw = null;
+ BufferedWriter out = null;
+ try {
+ List<String> lines = new ArrayList<String>();
+ String line = null;
+ fr = new FileReader(f1);
+ br = new BufferedReader(fr);
+ while ((line = br.readLine()) != null) {
+ if (line.contains("beSslPort: 8443"))
+ line = line.replace("8443", "8444");
+ lines.add(line);
+ }
+
+ fw = new FileWriter(f1);
+ out = new BufferedWriter(fw);
+ for (String s : lines)
+ out.write(s + NEW_LINE);
+ out.flush();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ } finally {
+
+ if (br != null) {
+ try {
+ br.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ if (fr != null) {
+ try {
+ fr.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ if (out != null) {
+ try {
+ out.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ if (fw != null) {
+ try {
+ fw.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testReadDistributionEngineConfigurationFile() {
+
+ ConfigurationListener configurationListener = new ConfigurationListener(TestConfiguration.class, new FileChangeCallback() {
+
+ public void reconfigure(BasicConfiguration obj) {
+ // TODO Auto-generated method stub
+ log.debug("In reconfigure of ", obj);
+ }
+
+ });
+
+ DistributionEngineConfiguration deConfiguration = configurationSource.getAndWatchConfiguration(DistributionEngineConfiguration.class, configurationListener);
+
+ assertTrue(deConfiguration != null);
+ log.debug("{}", deConfiguration);
+ assertEquals(deConfiguration.getDistributionNotifTopicName(), "ASDC-DISTR-NOTIF-TOPIC");
+ assertEquals(deConfiguration.getDistributionStatusTopicName(), "ASDC-DISTR-STATUS-TOPIC");
+
+ assertEquals(deConfiguration.getDistributionStatusTopic().getConsumerGroup(), "asdc");
+ assertEquals(deConfiguration.getDistributionStatusTopic().getConsumerGroup(), "asdc");
+ assertEquals(deConfiguration.getDistributionStatusTopic().getFetchTimeSec().intValue(), 15);
+ assertEquals(deConfiguration.getDistributionStatusTopic().getPollingIntervalSec().intValue(), 60);
+
+ assertEquals(deConfiguration.getEnvironments().size(), 1);
+ assertEquals(deConfiguration.getEnvironments().iterator().next(), "PROD");
+
+ assertEquals(deConfiguration.getDistribNotifResourceArtifactTypes().getInfo(), null);
+ assertEquals(deConfiguration.getDistribNotifResourceArtifactTypes().getLifecycle().size(), 2);
+ assertTrue(deConfiguration.getDistribNotifResourceArtifactTypes().getLifecycle().contains("HEAT"));
+ assertTrue(deConfiguration.getDistribNotifResourceArtifactTypes().getLifecycle().contains("DG_XML"));
+
+ assertEquals(deConfiguration.getDistribNotifServiceArtifactTypes().getLifecycle(), null);
+ assertEquals(deConfiguration.getDistribNotifServiceArtifactTypes().getInfo().size(), 1);
+ assertTrue(deConfiguration.getDistribNotifServiceArtifactTypes().getInfo().contains("MURANO-PKG"));
+
+ assertEquals(deConfiguration.getUebPublicKey(), "fff");
+ assertEquals(deConfiguration.getUebSecretKey(), "ffff");
+ assertEquals(deConfiguration.getUebServers().size(), 3);
+ assertEquals(deConfiguration.getInitRetryIntervalSec().intValue(), 5);
+
+ }
+
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/YamlTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/YamlTest.java
new file mode 100644
index 0000000000..340bca9f1d
--- /dev/null
+++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/YamlTest.java
@@ -0,0 +1,61 @@
+/*-
+ * ============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.common.test;
+
+import static org.junit.Assert.*;
+
+import org.apache.commons.codec.binary.Base64;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openecomp.sdc.common.util.YamlToObjectConverter;
+
+public class YamlTest {
+
+ private static YamlToObjectConverter yamlToObjectConverter;
+ private static String validYaml = "heat_template_version: 2013-05-23\r\ndescription: A load-balancer server\r\nparameters:\r\n image:\r\n type: string\r\n description: Image used for servers\r\n key_name:\r\n type: string\r\n description: SSH key to connect to the servers\r\n flavor:\r\n type: string\r\n description: flavor used by the servers\r\n pool_id:\r\n type: string\r\n description: Pool to contact\r\n user_data:\r\n type: string\r\n description: Server user_data\r\n metadata:\r\n type: json\r\n network:\r\n type: string\r\n description: Network used by the server\r\n\r\nresources:\r\n server:\r\n type: OS::Nova::Server\r\n properties:\r\n flavor: {get_param: flavor}\r\n image: {get_param: image}\r\n key_name: {get_param: key_name}\r\n metadata: {get_param: metadata}\r\n user_data: {get_param: user_data}\r\n user_data_format: RAW\r\n networks: [{network: {get_param: network} }]\r\n member:\r\n type: OS::Neutron::PoolMember\r\n properties:\r\n pool_id: {get_param: pool_id}\r\n address: {get_attr: [server, first_address]}\r\n protocol_port: 80\r\n\r\noutputs:\r\n server_ip:\r\n description: IP Address of the load-balanced server.\r\n value: { get_attr: [server, first_address] }\r\n lb_member:\r\n description: LB member details.\r\n value: { get_attr: [member, show] }";
+ // Missing square brackets at the end of string
+ private static String invalidYaml = "heat_template_version: 2013-05-23\r\ndescription: A load-balancer server\r\nparameters:\r\n image:\r\n type: string\r\n description: Image used for servers\r\n key_name:\r\n type: string\r\n description: SSH key to connect to the servers\r\n flavor:\r\n type: string\r\n description: flavor used by the servers\r\n pool_id:\r\n type: string\r\n description: Pool to contact\r\n user_data:\r\n type: string\r\n description: Server user_data\r\n metadata:\r\n type: json\r\n network:\r\n type: string\r\n description: Network used by the server\r\n\r\nresources:\r\n server:\r\n type: OS::Nova::Server\r\n properties:\r\n flavor: {get_param: flavor}\r\n image: {get_param: image}\r\n key_name: {get_param: key_name}\r\n metadata: {get_param: metadata}\r\n user_data: {get_param: user_data}\r\n user_data_format: RAW\r\n networks: [{network: {get_param: network} }]\r\n member:\r\n type: OS::Neutron::PoolMember\r\n properties:\r\n pool_id: {get_param: pool_id}\r\n address: {get_attr: [server, first_address]}\r\n protocol_port: 80\r\n\r\noutputs:\r\n server_ip:\r\n description: IP Address of the load-balanced server.\r\n value: { get_attr: [server, first_address] }\r\n lb_member:\r\n description: LB member details.\r\n value: { get_attr: [member, show}";
+
+ @BeforeClass
+ public static void setup() {
+ yamlToObjectConverter = new YamlToObjectConverter();
+ }
+
+ @Test
+ public void testValidYaml() {
+ assertTrue(yamlToObjectConverter.isValidYaml(validYaml.getBytes()));
+ }
+
+ @Test
+ public void testInvalidYaml() {
+ assertFalse(yamlToObjectConverter.isValidYaml(invalidYaml.getBytes()));
+ }
+
+ @Test
+ public void testValidYamlBase64() {
+ assertTrue(yamlToObjectConverter.isValidYaml(Base64.encodeBase64(validYaml.getBytes())));
+ }
+
+ @Test
+ public void testInvalidYamlBase64() {
+ assertFalse(yamlToObjectConverter.isValidYaml(Base64.encodeBase64(invalidYaml.getBytes())));
+ }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/config/TestConfiguration.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/config/TestConfiguration.java
new file mode 100644
index 0000000000..b8bf394fd7
--- /dev/null
+++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/config/TestConfiguration.java
@@ -0,0 +1,149 @@
+/*-
+ * ============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.common.test.config;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.openecomp.sdc.common.api.BasicConfiguration;
+
+import static java.lang.String.format;
+
+public class TestConfiguration extends BasicConfiguration {
+
+ /**
+ * backend host
+ */
+ private String beHost;
+ /**
+ * backend http port
+ */
+ private Integer beHttpPort;
+ /**
+ * backend http secured port
+ */
+ private Integer beSslPort;
+ /**
+ * be http context
+ */
+ private String beContext;
+ /**
+ * backend protocol. http | https
+ */
+ private String beProtocol = "http";
+
+ private Date released;
+ private String version = "1111";
+ private TestConnection connection;
+ private List<String> protocols;
+ private Map<String, String> users;
+
+ public Date getReleased() {
+ return released;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setReleased(Date released) {
+ this.released = released;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public TestConnection getConnection() {
+ return connection;
+ }
+
+ public void setConnection(TestConnection connection) {
+ this.connection = connection;
+ }
+
+ public List<String> getProtocols() {
+ return protocols;
+ }
+
+ public void setProtocols(List<String> protocols) {
+ this.protocols = protocols;
+ }
+
+ public Map<String, String> getUsers() {
+ return users;
+ }
+
+ public void setUsers(Map<String, String> users) {
+ this.users = users;
+ }
+
+ public String getBeHost() {
+ return beHost;
+ }
+
+ public void setBeHost(String beHost) {
+ this.beHost = beHost;
+ }
+
+ public Integer getBeHttpPort() {
+ return beHttpPort;
+ }
+
+ public void setBeHttpPort(Integer beHttpPort) {
+ this.beHttpPort = beHttpPort;
+ }
+
+ public Integer getBeSslPort() {
+ return beSslPort;
+ }
+
+ public void setBeSslPort(Integer beSslPort) {
+ this.beSslPort = beSslPort;
+ }
+
+ public String getBeContext() {
+ return beContext;
+ }
+
+ public void setBeContext(String beContext) {
+ this.beContext = beContext;
+ }
+
+ public String getBeProtocol() {
+ return beProtocol;
+ }
+
+ public void setBeProtocol(String beProtocol) {
+ this.beProtocol = beProtocol;
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder().append(format("backend host: %s\n", beHost))
+ .append(format("backend http port: %s\n", beHttpPort))
+ .append(format("backend ssl port: %s\n", beSslPort)).append(format("backend context: %s\n", beContext))
+ .append(format("backend protocol: %s\n", beProtocol)).append(format("Version: %s\n", version))
+ .append(format("Released: %s\n", released)).append(format("Connecting to database: %s\n", connection))
+ .append(format("Supported protocols: %s\n", protocols)).append(format("Users: %s\n", users)).toString();
+ }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/config/TestConnection.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/config/TestConnection.java
new file mode 100644
index 0000000000..ad546f7f97
--- /dev/null
+++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/config/TestConnection.java
@@ -0,0 +1,48 @@
+/*-
+ * ============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.common.test.config;
+
+public class TestConnection {
+
+ private String url;
+ private int poolSize;
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public int getPoolSize() {
+ return poolSize;
+ }
+
+ public void setPoolSize(int poolSize) {
+ this.poolSize = poolSize;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("'%s' with pool of %d", getUrl(), getPoolSize());
+ }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/config/TestNotExistConfiguration.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/config/TestNotExistConfiguration.java
new file mode 100644
index 0000000000..76f694f5b8
--- /dev/null
+++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/config/TestNotExistConfiguration.java
@@ -0,0 +1,47 @@
+/*-
+ * ============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.common.test.config;
+
+import static java.lang.String.format;
+
+import org.openecomp.sdc.common.api.BasicConfiguration;
+
+public class TestNotExistConfiguration extends BasicConfiguration {
+
+ /**
+ * backend host
+ */
+ private String beHost;
+ /**
+ * backend http port
+ */
+ private Integer beHttpPort;
+
+ /**
+ * backend http secured port
+ */
+
+ @Override
+ public String toString() {
+ return new StringBuilder().append(format("backend host: %s\n", beHost))
+ .append(format("backend http port: %s\n", beHttpPort)).toString();
+ }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/util/StreamUtilsTests.java b/common-app-api/src/test/java/org/openecomp/sdc/common/util/StreamUtilsTests.java
new file mode 100644
index 0000000000..31dc5f5f47
--- /dev/null
+++ b/common-app-api/src/test/java/org/openecomp/sdc/common/util/StreamUtilsTests.java
@@ -0,0 +1,143 @@
+/*-
+ * ============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.common.util;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.junit.Test;
+import org.openecomp.sdc.common.util.StreamUtils;
+
+import fj.data.Either;
+
+public class StreamUtilsTests {
+ @Test
+ public void testTakeWhilePredicateNotMet() {
+ List<Either<Integer, Boolean>> list = buildListWith10Integers();
+
+ assertTrue(StreamUtils.takeWhile(list.stream(), p -> p.isLeft()).count() == 10);
+ }
+
+ @Test
+ public void testTakeWhilePredicateIsMet() {
+ List<Either<Integer, Boolean>> list = buildListWith10Integers();
+ addToBooleansToList(list);
+
+ final Stream<Either<Integer, Boolean>> takeWhileStream = StreamUtils.takeWhile(list.stream(), p -> p.isLeft());
+ assertTrue(takeWhileStream.filter(p -> p.isRight()).count() == 0);
+ }
+
+ @Test
+ public <T> void testTakeErrorEvalOnlyOnce() {
+ List<Integer> bucket = new ArrayList<>();
+ // API
+ Function<Integer, Either<Integer, Boolean>> cons = num -> {
+ Either<Integer, Boolean> ret;
+ bucket.add(num);
+ if (num > 5) {
+ ret = Either.right(false);
+ } else {
+ ret = Either.left(num);
+ }
+ ;
+ return ret;
+ };
+
+ List<Integer> num1to10 = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
+ Stream<Either<Integer, Boolean>> streamEithers = num1to10.stream().map(e -> cons.apply(e));
+ List<Either<Integer, Boolean>> collect = StreamUtils.takeWhilePlusOneNoEval(streamEithers, e -> e.isLeft())
+ .collect(Collectors.toList());
+ assertTrue(bucket.size() <= 6);
+ assertTrue(collect.size() <= 6);
+ assertTrue(collect.stream().filter(e -> e.isRight()).count() == 1);
+
+ }
+
+ @Test
+ public void testTakeWhilePlusOnePredicateNotMet() {
+ List<Either<Integer, Boolean>> list = buildListWith10Integers();
+
+ assertTrue(StreamUtils.takeWhilePlusOne(list.stream(), p -> p.isLeft()).count() == 10);
+ }
+
+ @Test
+ public void testTakeWhilePlusOnePredicateIsMet() {
+ List<Either<Integer, Boolean>> list = buildListWith10Integers();
+ addToBooleansToList(list);
+
+ final Stream<Either<Integer, Boolean>> takeWhilePlusOneStream = StreamUtils.takeWhilePlusOne(list.stream(),
+ p -> p.isLeft());
+ assertTrue(takeWhilePlusOneStream.filter(p -> p.isRight()).count() == 1);
+ }
+
+ private void addToBooleansToList(List<Either<Integer, Boolean>> list) {
+ list.add(Either.right(false));
+ list.add(Either.right(false));
+ }
+
+ private List<Either<Integer, Boolean>> buildListWith10Integers() {
+ List<Either<Integer, Boolean>> list = new ArrayList<>();
+ for (int i = 0; i < 10; i++) {
+ list.add(Either.left(i));
+ }
+ return list;
+ }
+
+ @Test
+ public void myTest() {
+ List<Integer> list = new ArrayList<Integer>();
+ for (int i = 0; i < 10; i++) {
+ list.add(i);
+ }
+
+ List<Either<Integer, Boolean>> container = new ArrayList<Either<Integer, Boolean>>();
+ list.stream().map(e -> myBusinessLogic(e, container)).filter(p -> p.isRight()).findAny();
+ // Actual Results are in container
+ assertTrue(container.size() == 6);
+
+ }
+
+ private Either<Integer, Boolean> myBusinessLogic(int e, List<Either<Integer, Boolean>> cobtainerList) {
+ Either<Integer, Boolean> eitherElement = similuteDBAccess(e);
+ // Keep The results in external List
+ cobtainerList.add(eitherElement);
+
+ return eitherElement;
+ }
+
+ private Either<Integer, Boolean> similuteDBAccess(int e) {
+ Either<Integer, Boolean> eitherElement;
+ if (e < 5) {
+ // DB Success
+ eitherElement = Either.left(e);
+ } else {
+ // DB Fail
+ eitherElement = Either.right(true);
+ }
+ return eitherElement;
+ }
+}
diff --git a/common-app-api/src/test/resources/config/common/distribution-engine-configuration.yaml b/common-app-api/src/test/resources/config/common/distribution-engine-configuration.yaml
new file mode 100644
index 0000000000..a4ce7cc08c
--- /dev/null
+++ b/common-app-api/src/test/resources/config/common/distribution-engine-configuration.yaml
@@ -0,0 +1,35 @@
+uebServers:
+ - ueb.fqdn.1:8888
+ - ueb.fqdn.2:8888
+ - ueb.fqdn.3:8888
+
+uebPublicKey: fff
+
+uebSecretKey: ffff
+
+distributionNotifTopicName: ASDC-DISTR-NOTIF-TOPIC
+distributionStatusTopicName: ASDC-DISTR-STATUS-TOPIC
+
+initRetryIntervalSec: 5
+initMaxIntervalSec: 60
+
+distribNotifServiceArtifactTypes:
+ info:
+ - MURANO-PKG
+
+distribNotifResourceArtifactTypes:
+ lifecycle:
+ - HEAT
+ - DG_XML
+
+environments:
+ - PROD
+
+distributionStatusTopic:
+ pollingIntervalSec: 60
+ fetchTimeSec: 15
+ consumerGroup: asdc
+
+createTopic:
+ partitionCount: 1
+ replicationCount: 1
diff --git a/common-app-api/src/test/resources/config/common/test-configuration.yaml b/common-app-api/src/test/resources/config/common/test-configuration.yaml
new file mode 100644
index 0000000000..38912c06ff
--- /dev/null
+++ b/common-app-api/src/test/resources/config/common/test-configuration.yaml
@@ -0,0 +1,35 @@
+# catalog backend hostname
+beHost: 172.20.37.245
+
+# catalog backend http port
+beHttpPort: 8080
+
+# catalog backend http context
+beContext: /sdc/rest/config/get
+
+# catalog backend protocol
+beProtocol: http
+
+# catalog backend ssl port
+beSslPort: 8444
+
+version: 1.0
+released: 2012-11-30
+
+# Connection parameters
+connection:
+ url: jdbc:mysql://localhost:3306/db
+ poolSize: 17
+
+# Protocols
+protocols:
+ - http
+ - https
+
+# Users
+users:
+ tom: passwd
+ bob: passwd
+
+
+
diff --git a/common-app-api/src/test/resources/logback-test.xml b/common-app-api/src/test/resources/logback-test.xml
new file mode 100644
index 0000000000..d2b9bff23f
--- /dev/null
+++ b/common-app-api/src/test/resources/logback-test.xml
@@ -0,0 +1,13 @@
+<!-- only one line, shut up logback ! -->
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <Pattern>
+ %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
+ </Pattern>
+ </encoder>
+ </appender>
+ <root level="OFF">
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration> \ No newline at end of file