summaryrefslogtreecommitdiffstats
path: root/appc-common/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'appc-common/src/main/java')
-rw-r--r--appc-common/src/main/java/org/openecomp/appc/Constants.java44
-rw-r--r--appc-common/src/main/java/org/openecomp/appc/cache/CacheStrategies.java27
-rw-r--r--appc-common/src/main/java/org/openecomp/appc/cache/CacheStrategy.java28
-rw-r--r--appc-common/src/main/java/org/openecomp/appc/cache/MetadataCache.java28
-rw-r--r--appc-common/src/main/java/org/openecomp/appc/cache/impl/LRUCache.java51
-rw-r--r--appc-common/src/main/java/org/openecomp/appc/cache/impl/MetadataCacheFactory.java50
-rw-r--r--appc-common/src/main/java/org/openecomp/appc/cache/impl/MetadataCacheImpl.java58
-rw-r--r--appc-common/src/main/java/org/openecomp/appc/configuration/Configuration.java6
-rw-r--r--appc-common/src/main/java/org/openecomp/appc/configuration/ConfigurationFactory.java2
-rw-r--r--appc-common/src/main/java/org/openecomp/appc/configuration/package.html1
-rw-r--r--appc-common/src/main/java/org/openecomp/appc/i18n/Msg.java171
-rw-r--r--appc-common/src/main/java/org/openecomp/appc/logging/LoggingConstants.java1
-rw-r--r--appc-common/src/main/java/org/openecomp/appc/logging/LoggingUtils.java28
-rw-r--r--appc-common/src/main/java/org/openecomp/appc/metadata/MetadataService.java29
-rw-r--r--appc-common/src/main/java/org/openecomp/appc/metadata/impl/MetadataServiceImpl.java113
-rw-r--r--appc-common/src/main/java/org/openecomp/appc/metadata/objects/DependencyModelIdentifier.java79
16 files changed, 693 insertions, 23 deletions
diff --git a/appc-common/src/main/java/org/openecomp/appc/Constants.java b/appc-common/src/main/java/org/openecomp/appc/Constants.java
index bd72acfcf..7ddf38d03 100644
--- a/appc-common/src/main/java/org/openecomp/appc/Constants.java
+++ b/appc-common/src/main/java/org/openecomp/appc/Constants.java
@@ -50,9 +50,15 @@ public final class Constants {
@SuppressWarnings("nls")
public static final String ATTRIBUTE_ERROR_MESSAGE = "error-message";
- public static final String DG_OUTPUT_STATUS_MESSAGE = "output.status.message";
+ /**
+ * The name for the success message attribute to be set in the context
+ */
+ @SuppressWarnings("nls")
+ public static final String ATTRIBUTE_SUCCESS_MESSAGE = "success-message";
public static final String DG_ATTRIBUTE_STATUS = "SvcLogic.status";
+ public static final String DG_OUTPUT_STATUS_CODE = "output.status.code";
+ public static final String DG_OUTPUT_STATUS_MESSAGE = "output.status.message";
/**
* The property that defines the name of the DG service logic to be loaded
@@ -156,20 +162,12 @@ public final class Constants {
*/
public static final String PROPERTY_STACK_STATE_CHANGE_TIMEOUT ="org.openecomp.appc.stack.state.change.timeout" ;
- /**
- * Private default constructor prevents instantiation
- */
-
@SuppressWarnings("nls")
public static final String STATUS_GETTER = "status-getter";
-
-
-
@SuppressWarnings("nls")
public static final String VM_FUSION_STATUS_GETTER = "fusion-vm-status-getter";
-
/**
* The name for the status vm attribute to be set in the context when executing a vmstatuscheck.
*/
@@ -177,6 +175,34 @@ public final class Constants {
@SuppressWarnings("nls")
public static final String STATUS_OF_VM = "status-vm";
+ /**
+ * Yang revision value to be used while generating YANG module
+ */
+ public static final String YANG_REVISION = "2017-03-03";
+ /**
+ * Yang revision format to be used while formatting YANG revision date
+ */
+ public static final String YANG_REVISION_FORMAT = "YYYY-MM-DD";
+
+ /**
+ * Base container for yang that is generated to store in MD-SAL datastore
+ */
+ public static final String YANG_BASE_CONTAINER = "vnf-config-repo";
+
+ /**
+ *VNF config list for yang that is generated to store in MD-SAL datastore
+ */
+ public static final String YANG_VNF_CONFIG_LIST = "vnf-config-list";
+
+ /**
+ *Base container of VNF configuration data for yang that is generated to store in MD-SAL datastore
+ */
+ public static final String YANG_VNF_CONFIG = "vnf-config";
+
+ /**
+ * Private default constructor prevents instantiation
+ */
+
private Constants() {
}
diff --git a/appc-common/src/main/java/org/openecomp/appc/cache/CacheStrategies.java b/appc-common/src/main/java/org/openecomp/appc/cache/CacheStrategies.java
new file mode 100644
index 000000000..780dbc59b
--- /dev/null
+++ b/appc-common/src/main/java/org/openecomp/appc/cache/CacheStrategies.java
@@ -0,0 +1,27 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * 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.appc.cache;
+
+
+public enum CacheStrategies {
+ LRU;
+}
diff --git a/appc-common/src/main/java/org/openecomp/appc/cache/CacheStrategy.java b/appc-common/src/main/java/org/openecomp/appc/cache/CacheStrategy.java
new file mode 100644
index 000000000..c269ad231
--- /dev/null
+++ b/appc-common/src/main/java/org/openecomp/appc/cache/CacheStrategy.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * 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.appc.cache;
+
+
+public interface CacheStrategy <K,V>{
+ V getObject(K key);
+ void putObject(K key,V value);
+}
diff --git a/appc-common/src/main/java/org/openecomp/appc/cache/MetadataCache.java b/appc-common/src/main/java/org/openecomp/appc/cache/MetadataCache.java
new file mode 100644
index 000000000..db5915bcf
--- /dev/null
+++ b/appc-common/src/main/java/org/openecomp/appc/cache/MetadataCache.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * 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.appc.cache;
+
+
+public interface MetadataCache <K,V>{
+ V getObject(K key);
+ void putObject(K key,V value);
+}
diff --git a/appc-common/src/main/java/org/openecomp/appc/cache/impl/LRUCache.java b/appc-common/src/main/java/org/openecomp/appc/cache/impl/LRUCache.java
new file mode 100644
index 000000000..0e8ba7308
--- /dev/null
+++ b/appc-common/src/main/java/org/openecomp/appc/cache/impl/LRUCache.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * 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.appc.cache.impl;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.openecomp.appc.cache.CacheStrategy;
+
+public class LRUCache<K,V> implements CacheStrategy<K,V> {
+
+ private Map<K,V> map;
+
+ LRUCache(final Integer capacity){
+ map = new LinkedHashMap<K,V>(capacity, 0.75F, true){
+ @Override
+ protected boolean removeEldestEntry(Map.Entry<K, V> eldest){
+ return size() > capacity;
+ }
+ };
+ }
+
+ @Override
+ public V getObject(K key) {
+ return map.get(key);
+ }
+
+ @Override
+ public void putObject(K key, V value) {
+ map.put(key,value);
+ }
+}
diff --git a/appc-common/src/main/java/org/openecomp/appc/cache/impl/MetadataCacheFactory.java b/appc-common/src/main/java/org/openecomp/appc/cache/impl/MetadataCacheFactory.java
new file mode 100644
index 000000000..358b3bfd5
--- /dev/null
+++ b/appc-common/src/main/java/org/openecomp/appc/cache/impl/MetadataCacheFactory.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * 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.appc.cache.impl;
+
+import org.openecomp.appc.cache.CacheStrategies;
+import org.openecomp.appc.cache.CacheStrategy;
+import org.openecomp.appc.cache.MetadataCache;
+
+public class MetadataCacheFactory {
+
+ private static class ReferenceHolder{
+ private static final MetadataCacheFactory FACTORY = new MetadataCacheFactory();
+ }
+ private MetadataCacheFactory(){
+
+ }
+
+ public static MetadataCacheFactory getInstance(){
+ return ReferenceHolder.FACTORY;
+ }
+
+ public MetadataCache getMetadataCache(){
+ return new MetadataCacheImpl();
+ }
+ public MetadataCache getMetadataCache(CacheStrategies cacheStrategy){
+ return new MetadataCacheImpl(cacheStrategy);
+ }
+
+
+
+}
diff --git a/appc-common/src/main/java/org/openecomp/appc/cache/impl/MetadataCacheImpl.java b/appc-common/src/main/java/org/openecomp/appc/cache/impl/MetadataCacheImpl.java
new file mode 100644
index 000000000..e54de8781
--- /dev/null
+++ b/appc-common/src/main/java/org/openecomp/appc/cache/impl/MetadataCacheImpl.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * 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.appc.cache.impl;
+
+import org.openecomp.appc.cache.CacheStrategies;
+import org.openecomp.appc.cache.CacheStrategy;
+import org.openecomp.appc.cache.MetadataCache;
+
+
+public class MetadataCacheImpl<K,V> implements MetadataCache<K,V> {
+
+ private CacheStrategy strategy;
+
+ MetadataCacheImpl(){
+ this(CacheStrategies.LRU);
+ }
+
+ MetadataCacheImpl(CacheStrategies strategy){
+ this.strategy = initializeStrategy(strategy);
+ }
+
+ private CacheStrategy initializeStrategy(CacheStrategies strategy) {
+ switch (strategy){
+ case LRU:
+ return new LRUCache<>(50);
+ }
+ return null;
+ }
+
+ @Override
+ public V getObject(K key) {
+ return (V)strategy.getObject(key);
+ }
+
+ @Override
+ public void putObject(K key, V value) {
+ strategy.putObject(key,value);
+ }
+}
diff --git a/appc-common/src/main/java/org/openecomp/appc/configuration/Configuration.java b/appc-common/src/main/java/org/openecomp/appc/configuration/Configuration.java
index f64129011..d93b7588e 100644
--- a/appc-common/src/main/java/org/openecomp/appc/configuration/Configuration.java
+++ b/appc-common/src/main/java/org/openecomp/appc/configuration/Configuration.java
@@ -37,10 +37,10 @@ import org.slf4j.Logger;
*/
public interface Configuration {
- String PROPERTY_BOOTSTRAP_FILE_NAME = "org.openecomp.appc.bootstrap.file";
+ String PROPERTY_BOOTSTRAP_FILE_NAME = "org_openecomp_appc_bootstrap_file"; //
String DEFAULT_BOOTSTRAP_FILE_NAME = "appc.properties";
- String PROPERTY_BOOTSTRAP_FILE_PATH = "org.openecomp.appc.bootstrap.path";
- String DEFAULT_BOOTSTRAP_FILE_PATH = "${user.home},etc,../etc";
+ String PROPERTY_BOOTSTRAP_FILE_PATH = "org_openecomp_appc_bootstrap_path"; //
+ String DEFAULT_BOOTSTRAP_FILE_PATH = "/opt/openecomp/appc/data/properties,${user.home},etc,../etc";
String PROPERTY_RESOURCE_BUNDLES = "org.openecomp.appc.resources";
String DEFAULT_RESOURCE_BUNDLES = "org/openecomp/appc/i18n/MessageResources";
diff --git a/appc-common/src/main/java/org/openecomp/appc/configuration/ConfigurationFactory.java b/appc-common/src/main/java/org/openecomp/appc/configuration/ConfigurationFactory.java
index bbfd90de1..17a356745 100644
--- a/appc-common/src/main/java/org/openecomp/appc/configuration/ConfigurationFactory.java
+++ b/appc-common/src/main/java/org/openecomp/appc/configuration/ConfigurationFactory.java
@@ -113,7 +113,7 @@ public final class ConfigurationFactory {
/**
* The default properties resource to be loaded
*/
- private static final String DEFAULT_PROPERTIES = "org/openecomp/appc/default.properties";
+ private static final String DEFAULT_PROPERTIES = "/opt/openecomp/appc/data/properties/appc.properties";
/**
* This collection allows for special configurations to be created and maintained, organized by some identification
diff --git a/appc-common/src/main/java/org/openecomp/appc/configuration/package.html b/appc-common/src/main/java/org/openecomp/appc/configuration/package.html
index 4460a9e5c..5991f91b5 100644
--- a/appc-common/src/main/java/org/openecomp/appc/configuration/package.html
+++ b/appc-common/src/main/java/org/openecomp/appc/configuration/package.html
@@ -168,3 +168,4 @@
</p>
</body>
</html>
+>>>>>>> app-controller/master:appc-common/src/main/java/org/openecomp/appc/configuration/package.html
diff --git a/appc-common/src/main/java/org/openecomp/appc/i18n/Msg.java b/appc-common/src/main/java/org/openecomp/appc/i18n/Msg.java
index 3e4237258..21f088323 100644
--- a/appc-common/src/main/java/org/openecomp/appc/i18n/Msg.java
+++ b/appc-common/src/main/java/org/openecomp/appc/i18n/Msg.java
@@ -254,6 +254,11 @@ public enum Msg implements EELFResolvableErrorEnum {
SNAPSHOTING_SERVER,
/**
+ * {0} IAAS Adapter look for server requested
+ */
+ LOOKING_SERVER_UP,
+
+ /**
* {0} IAAS Adapter cannot perform requested service, VM url '{1}' is invalid
*/
INVALID_SELF_LINK_URL,
@@ -320,6 +325,11 @@ public enum Msg implements EELFResolvableErrorEnum {
UNPAUSE_SERVER,
/**
+ * Server {0} is being rebuilt...
+ */
+ REBUILD_SERVER,
+
+ /**
* Connection to provider {0} at identity {1} using tenant name {2} (id {3}) failed, reason={4}, retrying in {5}
* seconds, attempt {6} of {7}.
*/
@@ -336,6 +346,11 @@ public enum Msg implements EELFResolvableErrorEnum {
STOPPING_SERVER,
/**
+ * {0} IAAS Adapter start server requested
+ */
+ STARTING_SERVER,
+
+ /**
* Server {0} (id {1}) failed to rebuild, reason {2}
*/
REBUILD_SERVER_FAILED,
@@ -391,6 +406,11 @@ public enum Msg implements EELFResolvableErrorEnum {
* Server {0} (id {1}) failed to evacuate, reason {2}
*/
EVACUATE_SERVER_FAILED,
+
+ /**
+ * Server {0} evacuate from host {1} to host {2} failed during the rebuild on host {2}, reason {3}
+ */
+ EVACUATE_SERVER_REBUILD_FAILED,
/**
* APP-C instance is too busy
@@ -465,6 +485,11 @@ public enum Msg implements EELFResolvableErrorEnum {
AAI_DELETE_FAILED,
/**
+ * APP-C is unable to query AAI for VNF_ID {0}
+ */
+ AAI_QUERY_FAILED,
+
+ /**
* VNF {0} is configured
*/
VNF_CONFIGURED,
@@ -495,6 +520,21 @@ public enum Msg implements EELFResolvableErrorEnum {
VNF_TEST_FAILED,
/**
+ * VNF {0} test failed for reason {1}
+ */
+ VNF_NOT_FOUND,
+
+ /**
+ * VNF {0} Healthcheck operation failed for reason {1}
+ */
+ VNF_HEALTHCECK_FAILED,
+
+ /**
+ * VM {0} Healthcheck operation failed for reason {1}
+ */
+ VM_HEALTHCECK_FAILED,
+
+ /**
* Server {0} (id {1}) failed to stop during {2} phase, reason {3}
*/
STOP_SERVER_FAILED,
@@ -568,7 +608,7 @@ public enum Msg implements EELFResolvableErrorEnum {
CLOSE_CONTEXT_FAILED,
/**
- * Stack {0} is being snapshoted...
+ * {0} IAAS Adapter snapshoting stack
*/
SNAPSHOTING_STACK,
@@ -578,7 +618,7 @@ public enum Msg implements EELFResolvableErrorEnum {
STACK_SNAPSHOTED,
/**
- * Stack {0} is being restored to snapshot {1}...
+ * {0} IAAS Adapter restoring stack
*/
RESTORING_STACK,
@@ -588,6 +628,11 @@ public enum Msg implements EELFResolvableErrorEnum {
STACK_RESTORED,
/**
+ * {0} IAAS Adapter checking server
+ */
+ CHECKING_SERVER,
+
+ /**
* Parameter {0} is missing in svc request of {1}.
*/
MISSING_PARAMETER_IN_REQUEST,
@@ -601,8 +646,128 @@ public enum Msg implements EELFResolvableErrorEnum {
* Operation '{0}' for VNF type '{1}' from Source '{2}' with RequestID '{3}' on '{4}' with action '{5}'
* ended in {6}ms with result '{7}'
*/
- APPC_METRIC_MSG;
+ APPC_METRIC_MSG,
+
+ /**
+ * Parsing failied for{0}
+ */
+ INPUT_PAYLOAD_PARSING_FAILED,
+
+ /**
+ * Error occurred for due to {0}
+ */
+ APPC_EXCEPTION,
+
+ /**
+ * SSH Data Exception occurred due to {0}
+ */
+ SSH_DATA_EXCEPTION,
+
+ /**
+ * Json processing exception occurred due to {0}
+ */
+ JSON_PROCESSING_EXCEPTION,
+
+ /**
+ * Operation {0} succeed for {1}
+ */
+ SUCCESS_EVENT_MESSAGE,
+
+ /**
+ * Dependency model not found for VNF type {0} due to {1}
+ */
+ DEPENDENCY_MODEL_NOT_FOUND,
+
+ /**
+ * Invalid Dependency model for VNF Type {0} due to {1}
+ */
+ INVALID_DEPENDENCY_MODEL,
+
+ /**
+ * Failed to retrieve VNFC DG
+ */
+ FAILURE_RETRIEVE_VNFC_DG,
+
+ /**
+ * Network check for Server {0} failed for Port {1}
+ *
+ */
+ SERVER_NETWORK_ERROR,
+
+ /**
+ * Hypervisor check for Server {0} failed. Status is DOWN or UNKNOWN
+ *
+ */
+ HYPERVISOR_DOWN_ERROR,
+
+ /**
+ * Hypervisor Network check for Server {0} failed. Not reachable by APPC
+ *
+ */
+ HYPERVISOR_NETWORK_ERROR,
+
+ /**
+ * Restart application operation failed on server : {0}, reason {1}
+ */
+ APPLICATION_RESTART_FAILED,
+
+ /**
+ * Start application operation failed on server : {0}, reason {1}
+ */
+ APPLICATION_START_FAILED,
+
+ /**
+ * Start application operation failed on server : {0}, reason {1}
+ */
+ APPLICATION_STOP_FAILED,
+
+ /**
+ * Application on server {0} is being restarted...
+ */
+ RESTART_APPLICATION,
+
+ /**
+ * Application on server {0} is being started...
+ */
+ START_APPLICATION,
+
+ /**
+ * Application on server {0} is being started...
+ */
+ STOP_APPLICATION,
+
+ /**
+ * APPC LCM operations are disabled
+ */
+ LCM_OPERATIONS_DISABLED,
+
+ /**
+ * Application {0} received exception {1} while attempting to execute oam operation {2}, exception message = {3}|\
+ */
+ OAM_OPERATION_EXCEPTION,
+
+ /**
+ * Application {0} is stopping... Waiting for {1} LCM request to complete
+ */
+ OAM_OPERATION_STOPPING,
+
+ /**
+ * Application {0} is stopped
+ */
+ OAM_OPERATION_STOPPED,
+
+
+ /**
+ * Application {0} is started
+ */
+ OAM_OPERATION_STARTING,
+
+ /**
+ * Application {0} is started
+ */
+ OAM_OPERATION_STARTED,
+ ;
/**
* Static initializer to ensure the resource bundles for this class are loaded...
*/
diff --git a/appc-common/src/main/java/org/openecomp/appc/logging/LoggingConstants.java b/appc-common/src/main/java/org/openecomp/appc/logging/LoggingConstants.java
index dcc797138..2a600978f 100644
--- a/appc-common/src/main/java/org/openecomp/appc/logging/LoggingConstants.java
+++ b/appc-common/src/main/java/org/openecomp/appc/logging/LoggingConstants.java
@@ -51,6 +51,7 @@ public class LoggingConstants {
public static final String AAI = "A&AI";
public static final String DB = "DataBase";
public static final String APPC_PROVIDER = "APPC Provider";
+ public static final String APPC_OAM_PROVIDER = "APPC OAM Provider";
public static final String STATE_MACHINE = "StateMachine";
public static final String WORKFLOW_MANAGER = "WorkflowManager";
public static final String REQUEST_VALIDATOR = "RequestValidator";
diff --git a/appc-common/src/main/java/org/openecomp/appc/logging/LoggingUtils.java b/appc-common/src/main/java/org/openecomp/appc/logging/LoggingUtils.java
index c186a4afa..6ff192b20 100644
--- a/appc-common/src/main/java/org/openecomp/appc/logging/LoggingUtils.java
+++ b/appc-common/src/main/java/org/openecomp/appc/logging/LoggingUtils.java
@@ -21,6 +21,13 @@
package org.openecomp.appc.logging;
+import org.openecomp.appc.i18n.Msg;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.att.eelf.i18n.EELFResolvableErrorEnum;
+import com.att.eelf.i18n.EELFResourceManager;
+import org.slf4j.MDC;
+
import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID;
import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME;
@@ -31,13 +38,6 @@ import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.TimeZone;
-import org.openecomp.appc.i18n.Msg;
-import org.slf4j.MDC;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.att.eelf.i18n.EELFResourceManager;
-
public class LoggingUtils {
@@ -77,6 +77,20 @@ public class LoggingUtils {
cleanAuditErrorContext();
}
+ public static void auditInfo(Instant beginTimeStamp, Instant endTimeStamp, String code, String responseDescription, String className,EELFResolvableErrorEnum resourceId, String... arguments) {
+ populateAuditLogContext(beginTimeStamp, endTimeStamp, code, responseDescription, className);
+ auditLogger.info(resourceId,arguments);
+ cleanAuditErrorContext();
+ }
+
+ public static void auditWarn(Instant beginTimeStamp, Instant endTimeStamp, String code, String responseDescription, String className,EELFResolvableErrorEnum resourceId, String... arguments) {
+ populateAuditLogContext(beginTimeStamp, endTimeStamp, code, responseDescription, className);
+ auditLogger.warn(resourceId,arguments);
+ cleanAuditErrorContext();
+ }
+
+
+
public static void logMetricsMessage(Instant beginTimeStamp, Instant endTimeStamp, String targetEntity, String targetServiceName, String statusCode, String responseCode, String responseDescription, String className) {
populateMetricLogContext(beginTimeStamp, endTimeStamp, targetEntity, targetServiceName, statusCode, responseCode, responseDescription, className);
metricLogger.info(EELFResourceManager.format(Msg.APPC_METRIC_MSG,
diff --git a/appc-common/src/main/java/org/openecomp/appc/metadata/MetadataService.java b/appc-common/src/main/java/org/openecomp/appc/metadata/MetadataService.java
new file mode 100644
index 000000000..f8b54c717
--- /dev/null
+++ b/appc-common/src/main/java/org/openecomp/appc/metadata/MetadataService.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * 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.appc.metadata;
+
+import org.openecomp.appc.metadata.objects.DependencyModelIdentifier;
+
+
+public interface MetadataService {
+ String getVnfModel(DependencyModelIdentifier modelIdentifier);
+}
diff --git a/appc-common/src/main/java/org/openecomp/appc/metadata/impl/MetadataServiceImpl.java b/appc-common/src/main/java/org/openecomp/appc/metadata/impl/MetadataServiceImpl.java
new file mode 100644
index 000000000..fb393aa74
--- /dev/null
+++ b/appc-common/src/main/java/org/openecomp/appc/metadata/impl/MetadataServiceImpl.java
@@ -0,0 +1,113 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * 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.appc.metadata.impl;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.openecomp.sdnc.sli.resource.dblib.DbLibService;
+
+import javax.sql.rowset.CachedRowSet;
+
+import org.openecomp.appc.cache.MetadataCache;
+import org.openecomp.appc.cache.impl.MetadataCacheFactory;
+import org.openecomp.appc.metadata.MetadataService;
+import org.openecomp.appc.metadata.objects.DependencyModelIdentifier;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+
+public class MetadataServiceImpl implements MetadataService {
+
+ private DbLibService dbLibService;
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(MetadataServiceImpl.class);
+
+ private MetadataCache<DependencyModelIdentifier,String> cache;
+
+ public MetadataServiceImpl(){
+ initialize();
+ }
+
+ private void initialize(){
+ cache = MetadataCacheFactory.getInstance().getMetadataCache();
+ // TODO initialze dbLibService
+ }
+
+ public void setDbLibService(DbLibService dbLibService) {
+ this.dbLibService = dbLibService;
+ }
+
+ @Override
+ public String getVnfModel(DependencyModelIdentifier modelIdentifier) {
+ logger.debug("Reading Vnf Model data from cache for vnfType : "+ modelIdentifier.getVnfType() +" and catalog version : " +modelIdentifier.getCatalogVersion());
+ String vnfModel = cache.getObject(modelIdentifier);
+ if(vnfModel ==null || vnfModel.length() ==0){
+ logger.debug("Vnf Model not available in cache. Reading from database.");
+ vnfModel = readVnfModel(modelIdentifier);
+ if(vnfModel !=null && vnfModel.length()>0){
+ logger.debug("Adding retrieved Vnf Model to cache.");
+ addVnfModel(modelIdentifier,vnfModel);
+ }
+ }
+ return vnfModel;
+ }
+
+ private void addVnfModel(DependencyModelIdentifier modelIdentifier, String vnfModel) {
+ cache.putObject(modelIdentifier,vnfModel);
+ }
+
+ private String readVnfModel(DependencyModelIdentifier modelIdentifier) {
+
+ logger.debug("Reading Vnf Model data from database for RESOURCE_NAME : "+ modelIdentifier.getVnfType() +" and RESOURCE_VERSION : " +modelIdentifier.getCatalogVersion());
+ StringBuilder query = new StringBuilder();
+ String vnfModel =null;
+ query.append("SELECT ARTIFACT_CONTENT FROM sdnctl.ASDC_ARTIFACTS WHERE RESOURCE_NAME = ? ") ;
+ ArrayList<String> argList = new ArrayList<>();
+ argList.add(modelIdentifier.getVnfType());
+
+ if (modelIdentifier.getCatalogVersion()==null){
+ query.append(" ORDER BY SUBSTRING_INDEX(RESOURCE_VERSION, '.', 1)*1 DESC , " +
+ "SUBSTRING_INDEX(SUBSTRING_INDEX(RESOURCE_VERSION, '.', 2),'.', -1) *1 DESC , " +
+ "SUBSTRING_INDEX(RESOURCE_VERSION, '.', -1)*1 DESC ;");
+ }else{
+ query.append("AND RESOURCE_VERSION = ? ;");
+ argList.add(modelIdentifier.getCatalogVersion());
+ }
+ try {
+ final CachedRowSet data = dbLibService.getData(query.toString(), argList, "sdnctl");
+ if (data.first()) {
+ vnfModel = data.getString("ARTIFACT_CONTENT");
+ if (vnfModel == null || vnfModel.isEmpty()) {
+ logger.error("Invalid dependency model for vnf type : "+ modelIdentifier.getVnfType() +" and catalog version : " +modelIdentifier.getCatalogVersion());
+ throw new RuntimeException("Invalid or Empty VNF Model");
+ }
+ logger.debug("Retrieved Vnf Model : " + vnfModel);
+ }else {
+ logger.warn("VNF Model not found in datastore for RESOURCE_NAME : "+ modelIdentifier.getVnfType() +" AND RESOURCE_VERSION : " +modelIdentifier.getCatalogVersion());
+ }
+ } catch (SQLException e) {
+ throw new RuntimeException("Database error occurred");
+ }
+ return vnfModel;
+ }
+}
diff --git a/appc-common/src/main/java/org/openecomp/appc/metadata/objects/DependencyModelIdentifier.java b/appc-common/src/main/java/org/openecomp/appc/metadata/objects/DependencyModelIdentifier.java
new file mode 100644
index 000000000..e3c82487e
--- /dev/null
+++ b/appc-common/src/main/java/org/openecomp/appc/metadata/objects/DependencyModelIdentifier.java
@@ -0,0 +1,79 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * 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.appc.metadata.objects;
+
+
+public class DependencyModelIdentifier {
+ private String vnfType;
+ private String catalogVersion;
+
+ public DependencyModelIdentifier(String vnfType, String catalogVersion){
+ this.vnfType = vnfType;
+ this.catalogVersion = catalogVersion;
+ }
+
+ public int hashCode(){
+ final int prime = 31;
+ int result = 1;
+ result = result * prime + (this.vnfType == null ? 0 :this.vnfType.hashCode());
+ result = result * prime + (this.catalogVersion == null ? 0 :this.catalogVersion.hashCode());
+ return result;
+ }
+
+ public boolean equals(Object obj){
+ if(obj ==null)
+ return false;
+ if(!(obj instanceof DependencyModelIdentifier))
+ return false;
+
+ DependencyModelIdentifier modelIdentifier = (DependencyModelIdentifier)obj;
+ if(this.vnfType == null){
+ if(modelIdentifier.vnfType !=null)
+ return false;
+ }
+ else if(!this.vnfType.equals(modelIdentifier.vnfType))
+ return false;
+
+ if(this.catalogVersion == null){
+ if(modelIdentifier.catalogVersion !=null)
+ return false;
+ }
+ else if(!this.catalogVersion.equals(modelIdentifier.catalogVersion))
+ return false;
+
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "DependencyModelIdentifier : vnfType = "+vnfType + " , catalogVersion = " +catalogVersion;
+ }
+
+ public String getVnfType() {
+ return vnfType;
+ }
+
+ public String getCatalogVersion() {
+ return catalogVersion;
+ }
+
+}