aboutsummaryrefslogtreecommitdiffstats
path: root/aai-resources/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'aai-resources/src/main')
-rw-r--r--aai-resources/src/main/java/org/onap/aai/IncreaseNodesTool.java25
-rw-r--r--aai-resources/src/main/java/org/onap/aai/Profiles.java2
-rw-r--r--aai-resources/src/main/java/org/onap/aai/ResourcesApp.java110
-rw-r--r--aai-resources/src/main/java/org/onap/aai/TenantIsolation/DataImportTasks.java288
-rw-r--r--aai-resources/src/main/java/org/onap/aai/config/aaf/AafAuthorizationFilter.java68
-rw-r--r--aai-resources/src/main/java/org/onap/aai/config/aaf/AafFilter.java69
-rw-r--r--aai-resources/src/main/java/org/onap/aai/config/aaf/FilterPriority.java35
-rw-r--r--aai-resources/src/main/java/org/onap/aai/config/aaf/ResponseFormatter.java45
-rw-r--r--aai-resources/src/main/java/org/onap/aai/interceptors/AAIHeaderProperties.java4
-rw-r--r--aai-resources/src/main/java/org/onap/aai/interceptors/post/ResetLoggingContext.java100
-rw-r--r--aai-resources/src/main/java/org/onap/aai/interceptors/post/ResponseTransactionLogging.java6
-rw-r--r--aai-resources/src/main/java/org/onap/aai/interceptors/pre/HeaderValidation.java92
-rw-r--r--aai-resources/src/main/java/org/onap/aai/interceptors/pre/RequestTransactionLogging.java20
-rw-r--r--aai-resources/src/main/java/org/onap/aai/interceptors/pre/SetLoggingContext.java70
-rw-r--r--aai-resources/src/main/java/org/onap/aai/interceptors/pre/TwoWaySslAuthorization.java2
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java67
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java159
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java38
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java42
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumer.java119
-rw-r--r--aai-resources/src/main/java/org/onap/aai/service/AuthorizationService.java8
-rw-r--r--aai-resources/src/main/java/org/onap/aai/web/JerseyConfiguration.java11
-rw-r--r--aai-resources/src/main/resources/aaf/onap/bath_config.csv (renamed from aai-resources/src/main/resources/aaf/bath_config.csv)0
-rw-r--r--aai-resources/src/main/resources/aaf/onap/org.onap.aai.keyfile (renamed from aai-resources/src/main/resources/aaf/org.onap.aai.keyfile)0
-rw-r--r--aai-resources/src/main/resources/aaf/onap/org.onap.aai.p12 (renamed from aai-resources/src/main/resources/aaf/org.onap.aai.p12)bin4158 -> 4158 bytes
-rw-r--r--aai-resources/src/main/resources/aaf/onap/org.onap.aai.props (renamed from aai-resources/src/main/resources/aaf/org.onap.aai.props)8
-rw-r--r--aai-resources/src/main/resources/aaf/onap/org.osaaf.location.props (renamed from aai-resources/src/main/resources/aaf/org.osaaf.location.props)0
-rw-r--r--aai-resources/src/main/resources/aaf/onap/truststoreONAPall.jks (renamed from aai-resources/src/main/resources/aaf/truststoreONAPall.jks)bin114865 -> 114865 bytes
-rw-r--r--aai-resources/src/main/resources/application.properties35
-rw-r--r--aai-resources/src/main/resources/cadi.properties2
-rw-r--r--aai-resources/src/main/resources/etc/appprops/aaiconfig.properties49
-rw-r--r--aai-resources/src/main/resources/etc/appprops/datatoolscrons.properties8
-rw-r--r--aai-resources/src/main/resources/etc/appprops/delta-event-publisher.properties4
-rw-r--r--aai-resources/src/main/resources/etc/appprops/error.properties302
-rw-r--r--aai-resources/src/main/resources/etc/appprops/janusgraph-cached.properties3
-rw-r--r--aai-resources/src/main/resources/etc/appprops/janusgraph-realtime.properties3
-rw-r--r--aai-resources/src/main/resources/logback.xml159
-rw-r--r--aai-resources/src/main/scripts/bulkprocess.sh8
-rw-r--r--aai-resources/src/main/scripts/common_functions.sh23
-rw-r--r--aai-resources/src/main/scripts/install/addManualData.sh85
-rw-r--r--aai-resources/src/main/scripts/updatePem.sh20
-rw-r--r--aai-resources/src/main/scripts/updateTool.sh24
-rw-r--r--aai-resources/src/main/scripts/vmExportCloudRegions.sh517
-rw-r--r--aai-resources/src/main/scripts/vmUpdateExport.sh75
-rw-r--r--aai-resources/src/main/scripts/vmValidateCloudRegions.sh328
45 files changed, 1979 insertions, 1054 deletions
diff --git a/aai-resources/src/main/java/org/onap/aai/IncreaseNodesTool.java b/aai-resources/src/main/java/org/onap/aai/IncreaseNodesTool.java
index 23814bf..614d16f 100644
--- a/aai-resources/src/main/java/org/onap/aai/IncreaseNodesTool.java
+++ b/aai-resources/src/main/java/org/onap/aai/IncreaseNodesTool.java
@@ -24,17 +24,16 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import org.onap.aai.restclient.PropertyPasswordConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.JanusGraph;
import org.janusgraph.core.JanusGraphTransaction;
-import org.onap.aai.config.PropertyPasswordConfiguration;
import org.onap.aai.config.SpringContextAware;
import org.onap.aai.dbmap.AAIGraph;
-import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
@@ -42,7 +41,6 @@ import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.introspection.ModelType;
import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
import org.onap.aai.logging.ErrorLogHelper;
-import org.onap.aai.logging.LoggingContext;
import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.util.AAISystemExitUtil;
import org.onap.aai.util.PositiveNumValidator;
@@ -65,7 +63,7 @@ public class IncreaseNodesTool {
protected TransactionalGraphEngine engine;
Vertex parentVtx;
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(IncreaseNodesTool.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(IncreaseNodesTool.class);
public IncreaseNodesTool(LoaderFactory loaderFactory, SchemaVersions schemaVersions){
this.loaderFactory = loaderFactory;
@@ -84,11 +82,14 @@ public class IncreaseNodesTool {
);
context.refresh();
} catch (Exception e) {
- AAIException aai = ResourcesApp.schemaServiceExceptionTranslator(e);
- LOGGER.error("Problems running the tool "+aai.getMessage());
- LoggingContext.statusCode(LoggingContext.StatusCode.ERROR);
- LoggingContext.responseCode(LoggingContext.DATA_ERROR);
- ErrorLogHelper.logError(aai.getCode(), e.getMessage() + ", resolve and retry");
+ AAIException aai = null;
+ if(e.getCause() instanceof AAIException){
+ aai = (AAIException)e.getCause();
+ } else {
+ aai = ResourcesApp.schemaServiceExceptionTranslator(e);
+ }
+ LOGGER.error("Problems starting the Increase Nodes Tool due to {}", aai.getMessage());
+ ErrorLogHelper.logException(aai);
throw aai;
}
@@ -141,7 +142,7 @@ public class IncreaseNodesTool {
GraphTraversalSource g = transaction.traversal();
for (long i = 1; i <= nodeCount; i++) {
String randomId = UUID.randomUUID().toString();
- Vertex v = g.addV().next();
+ Vertex v = g.addV(nodeType).next();
v.property("aai-node-type", nodeType);
v.property("source-of-truth", "IncreaseNodesTool");
diff --git a/aai-resources/src/main/java/org/onap/aai/Profiles.java b/aai-resources/src/main/java/org/onap/aai/Profiles.java
index ea65b9a..f35a4c9 100644
--- a/aai-resources/src/main/java/org/onap/aai/Profiles.java
+++ b/aai-resources/src/main/java/org/onap/aai/Profiles.java
@@ -25,7 +25,7 @@ public final class Profiles {
public static final String DME2 = "dme2";
public static final String ONE_WAY_SSL = "one-way-ssl";
- public static final String AAF_AUTHENTICATION = "aaf-auth";
+
public static final String TWO_WAY_SSL = "two-way-ssl";
private Profiles(){}
diff --git a/aai-resources/src/main/java/org/onap/aai/ResourcesApp.java b/aai-resources/src/main/java/org/onap/aai/ResourcesApp.java
index f653487..6377af8 100644
--- a/aai-resources/src/main/java/org/onap/aai/ResourcesApp.java
+++ b/aai-resources/src/main/java/org/onap/aai/ResourcesApp.java
@@ -19,23 +19,17 @@
*/
package org.onap.aai;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-
import org.apache.commons.lang3.exception.ExceptionUtils;
-import org.onap.aai.config.PropertyPasswordConfiguration;
+import org.onap.aai.aailog.logs.AaiDebugLog;
import org.onap.aai.config.SpringContextAware;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
-
import org.onap.aai.logging.ErrorLogHelper;
-import org.onap.aai.logging.LoggingContext;
-import org.onap.aai.logging.LoggingContext.StatusCode;
+import org.onap.aai.nodes.NodeIngestor;
+import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.onap.aai.util.AAIConfig;
-import org.slf4j.MDC;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -45,36 +39,42 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerA
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
-import org.onap.aai.nodes.NodeIngestor;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
-@SpringBootApplication
+@SpringBootApplication(
+ exclude = {
+ DataSourceAutoConfiguration.class,
+ DataSourceTransactionManagerAutoConfiguration.class,
+ HibernateJpaAutoConfiguration.class
+ }
+)
// Component Scan provides a way to look for spring beans
// It only searches beans in the following packages
// Any method annotated with @Bean annotation or any class
// with @Component, @Configuration, @Service will be picked up
@ComponentScan(basePackages = {
- "org.onap.aai.config",
- "org.onap.aai.web",
- "org.onap.aai.setup",
- "org.onap.aai.tasks",
- "org.onap.aai.service",
- "org.onap.aai.rest"
-})
-@EnableAutoConfiguration(exclude = {
- DataSourceAutoConfiguration.class,
- DataSourceTransactionManagerAutoConfiguration.class,
- HibernateJpaAutoConfiguration.class
+ "org.onap.aai.config",
+ "org.onap.aai.web",
+ "org.onap.aai.setup",
+ "org.onap.aai.tasks",
+ "org.onap.aai.service",
+ "org.onap.aai.rest",
+ "org.onap.aai.aaf",
+ "org.onap.aai.TenantIsolation",
+ "org.onap.aai.aailog",
+ "org.onap.aai.prevalidation"
})
public class ResourcesApp {
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(ResourcesApp.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(ResourcesApp.class.getName());
private static final String APP_NAME = "aai-resources";
- private static Map<String,String> contextMap;
+ private static AaiDebugLog debugLog = new AaiDebugLog();
+ static {
+ debugLog.setupMDC();
+ }
@Autowired
private Environment env;
@@ -93,17 +93,6 @@ public class ResourcesApp {
private void init() throws AAIException {
System.setProperty("org.onap.aai.serverStarted", "false");
setDefaultProps();
-
- LoggingContext.save();
- LoggingContext.component("init");
- LoggingContext.partnerName("NA");
- LoggingContext.targetEntity(APP_NAME);
- LoggingContext.requestId(UUID.randomUUID().toString());
- LoggingContext.serviceName(APP_NAME);
- LoggingContext.targetServiceName("contextInitialized");
- LoggingContext.statusCode(StatusCode.COMPLETE);
-
- contextMap = MDC.getCopyOfContextMap();
logger.info("AAI Server initialization started...");
// Setting this property to allow for encoded slash (/) in the path parameter
@@ -116,7 +105,6 @@ public class ResourcesApp {
logger.warn("You have seriously misconfigured your application");
}
- LoggingContext.restoreIfPossible();
}
@PreDestroy
@@ -129,15 +117,6 @@ public class ResourcesApp {
setDefaultProps();
- LoggingContext.save();
- LoggingContext.component("init");
- LoggingContext.partnerName("NA");
- LoggingContext.targetEntity(APP_NAME);
- LoggingContext.requestId(UUID.randomUUID().toString());
- LoggingContext.serviceName(APP_NAME);
- LoggingContext.targetServiceName("contextInitialized");
- LoggingContext.statusCode(StatusCode.COMPLETE);
-
Environment env =null;
AAIConfig.init();
try {
@@ -148,21 +127,21 @@ public class ResourcesApp {
env = app.run(args).getEnvironment();
}
catch(Exception ex){
- AAIException aai = schemaServiceExceptionTranslator(ex);
- LoggingContext.statusCode(LoggingContext.StatusCode.ERROR);
- LoggingContext.responseCode(LoggingContext.DATA_ERROR);
- logger.error("Problems starting ResourcesApp "+aai.getMessage());
+ AAIException aai = null;
+ if(ex.getCause() instanceof AAIException){
+ aai = (AAIException)ex.getCause();
+ } else {
+ aai = schemaServiceExceptionTranslator(ex);
+ }
+ logger.error("Problems starting the ResourcesApp due to {}", aai.getMessage());
ErrorLogHelper.logException(aai);
- ErrorLogHelper.logError(aai.getCode(), ex.getMessage() + ", resolve and restart Resources");
- //ErrorLogHelper.logError(aai.getCode(), aai.getMessage() + aai.getCause().toString());
throw aai;
}
- MDC.setContextMap (contextMap);
logger.info(
- "Application '{}' is running on {}!" ,
- env.getProperty("spring.application.name"),
- env.getProperty("server.port")
+ "Application '{}' is running on {}!" ,
+ env.getProperty("spring.application.name"),
+ env.getProperty("server.port")
);
// The main reason this was moved from the constructor is due
@@ -173,12 +152,10 @@ public class ResourcesApp {
AAIGraph.getInstance();
logger.info("Resources MicroService Started");
- logger.error("Resources MicroService Started");
logger.debug("Resources MicroService Started");
System.out.println("Resources Microservice Started");
- LoggingContext.restoreIfPossible();
}
public static void setDefaultProps(){
@@ -206,17 +183,18 @@ public class ResourcesApp {
}
public static AAIException schemaServiceExceptionTranslator(Exception ex) {
AAIException aai = null;
- if(ExceptionUtils.getRootCause(ex).getMessage().contains("NodeIngestor")){
+ String message = ExceptionUtils.getRootCause(ex).getMessage();
+ if(message.contains("NodeIngestor")){
aai = new AAIException("AAI_3026","Error reading OXM from SchemaService - Investigate");
}
- else if(ExceptionUtils.getRootCause(ex).getMessage().contains("EdgeIngestor")){
+ else if(message.contains("EdgeIngestor")){
aai = new AAIException("AAI_3027","Error reading EdgeRules from SchemaService - Investigate");
}
- else if(ExceptionUtils.getRootCause(ex).getMessage().contains("Connection refused")){
+ else if(message.contains("Connection refused")){
aai = new AAIException("AAI_3025","Error connecting to SchemaService - Investigate");
}
else {
- aai = new AAIException("AAI_3025","Error connecting to SchemaService - Please Investigate");
+ aai = new AAIException("AAI_3025","Unable to determine what the error is, please check external.log");
}
return aai;
diff --git a/aai-resources/src/main/java/org/onap/aai/TenantIsolation/DataImportTasks.java b/aai-resources/src/main/java/org/onap/aai/TenantIsolation/DataImportTasks.java
new file mode 100644
index 0000000..917146f
--- /dev/null
+++ b/aai-resources/src/main/java/org/onap/aai/TenantIsolation/DataImportTasks.java
@@ -0,0 +1,288 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.onap.aai.TenantIsolation;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.NavigableMap;
+import java.util.Properties;
+import java.util.TreeMap;
+import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.logging.ErrorLogHelper;
+import org.onap.aai.util.AAIConfig;
+import org.onap.aai.util.AAIConstants;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import com.att.eelf.configuration.Configuration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.commons.io.comparator.LastModifiedFileComparator;
+import org.apache.commons.io.filefilter.DirectoryFileFilter;
+import org.apache.commons.io.filefilter.FileFileFilter;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.RegexFileFilter;
+
+/**
+ * DataImportTasks
+ *
+ */
+@Component
+@PropertySource("file:${server.local.startpath}/etc/appprops/datatoolscrons.properties")
+public class DataImportTasks {
+
+ private static final Logger LOGGER;
+ private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
+
+ private static final List<String> EXTS = Arrays.asList("tar.gz", "tgz");
+
+ static {
+ Properties props = System.getProperties();
+ props.setProperty(Configuration.PROPERTY_LOGGING_FILE_NAME, AAIConstants.AAI_LOGBACK_PROPS);
+ props.setProperty(Configuration.PROPERTY_LOGGING_FILE_PATH, AAIConstants.AAI_HOME_BUNDLECONFIG);
+ LOGGER = LoggerFactory.getLogger(DataImportTasks.class);
+ }
+ /**
+ * Scheduled task to invoke importTask
+ */
+ @Scheduled(cron = "${dataimporttask.cron}" )
+ public void import1() {
+ try {
+ importTask();
+ }
+ catch (Exception e) {
+ }
+ }
+ /**
+ * The importTask method.
+ *
+ * @throws AAIException, Exception
+ */
+ public void importTask() throws AAIException, Exception {
+
+
+ if (AAIConfig.get("aai.dataimport.enable").equalsIgnoreCase("false")) {
+ LOGGER.info("Data Import is not enabled");
+ return;
+ }
+ // Check if the process was started via command line
+ if (isDataImportRunning()) {
+ LOGGER.info("There is a dataImport process already running");
+ return;
+ }
+
+ LOGGER.info("Started importTask: " + dateFormat.format(new Date()));
+
+ String inputLocation = AAIConstants.AAI_HOME_BUNDLECONFIG + AAIConfig.get("aai.dataimport.input.location");
+
+ // Check that the input location exist
+ File targetDirFile = new File(inputLocation);
+ if ( targetDirFile.exists() ) {
+ //Delete any existing payload file directories
+ deletePayload(targetDirFile);
+ }
+
+ File payloadFile = findExportedPayload();
+ if (payloadFile == null)
+ return; // already logged error in the findExportedPayload function
+
+ if ( unpackPayloadFile(payloadFile.getAbsolutePath())) {
+ String[] command = new String[2];
+ command[0] = AAIConstants.AAI_HOME + AAIConstants.AAI_FILESEP + "bin" + AAIConstants.AAI_FILESEP + "install" + AAIConstants.AAI_FILESEP + "addManualData.sh";
+ command[1] = "tenant_isolation";
+ runAddManualDataScript(command);
+ }
+
+ //clean up
+ payloadFile.delete();
+
+ }
+ /**
+ * The isDataImportRunning method, checks if the data import task was started separately via command line
+ * @return true if another process is running, false if not
+ */
+ private static boolean isDataImportRunning(){
+
+ Process process = null;
+
+ int count = 0;
+ try {
+ process = new ProcessBuilder().command("bash", "-c", "ps -ef | grep 'addManualData'").start();
+ InputStream is = process.getInputStream();
+ InputStreamReader isr = new InputStreamReader(is);
+ BufferedReader br = new BufferedReader(isr);
+
+ while (br.readLine() != null){
+ count++;
+ }
+
+ int exitVal = process.waitFor();
+ LOGGER.info("Check if dataImport is running returned: " + exitVal);
+ } catch (Exception e) {
+ ErrorLogHelper.logError("AAI_8002", "Exception while running the check to see if dataImport is running "+ e.getMessage());
+ LOGGER.info("Exception while running the check to see if dataImport is running "+ e.getMessage());
+ }
+
+ if(count > 0){
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * The findPayExportedPayload method tries to find the latest exported payload.
+ * Also deletes the old files if any or any other file in this directory
+ */
+ private static File findExportedPayload() throws AAIException {
+ String targetDir = AAIConstants.AAI_HOME_BUNDLECONFIG + AAIConfig.get("aai.dataimport.input.location");
+ File targetDirFile = new File(targetDir);
+ File payloadFile = null;
+
+ File[] allFilesArr = targetDirFile.listFiles((FileFilter) FileFileFilter.FILE);
+ if ( allFilesArr == null || allFilesArr.length == 0 ) {
+ ErrorLogHelper.logError("AAI_8001", "Unable to find payload file at " + targetDir);
+ LOGGER.info ("Unable to find payload at " + targetDir);
+ return null;
+ }
+ if ( allFilesArr.length > 1 ) {
+ Arrays.sort(allFilesArr, LastModifiedFileComparator.LASTMODIFIED_REVERSE);
+ // get the latest payload file
+ boolean foundTheLatestPayload = false;
+ for (File f : allFilesArr) {
+ if (!foundTheLatestPayload && isTargzExtension(f.getAbsolutePath())) {
+ payloadFile = f;
+ foundTheLatestPayload = true;
+ }
+ else // delete all files except the latest payload file!
+ f.delete();
+ }
+ }
+ else {
+ if (isTargzExtension(allFilesArr[0].getAbsolutePath()))
+ payloadFile = allFilesArr[0];
+ }
+
+ return payloadFile;
+ }
+
+ /**
+ * The deletePayload method deletes all the payload files that it finds at targetDirectory
+ * @param targetDirFile the directory that contains payload files
+ * @throws AAIException
+ */
+ private static void deletePayload(File targetDirFile) throws AAIException {
+
+ File[] allFilesArr = targetDirFile.listFiles((FileFilter)DirectoryFileFilter.DIRECTORY);
+ if ( allFilesArr == null || allFilesArr.length == 0 ) {
+ LOGGER.info ("No payload files found at " + targetDirFile.getPath());
+ return;
+ }
+ for ( File f : allFilesArr ) {
+ try {
+ FileUtils.deleteDirectory(f);
+ }
+ catch (IOException e) {
+
+ LOGGER.info ("Unable to delete directory " + f.getAbsolutePath() + " " + e.getMessage());
+ }
+
+ }
+
+ }
+
+ /**
+ * The isDataImportRunning method, checks if the data import task was started separately via command line
+ * @return true if another process is running, false if not
+ */
+ private static boolean unpackPayloadFile(String payLoadFileName){
+
+ Process process = null;
+
+ try {
+ process = new ProcessBuilder().command("bash", "-c", "gzip –d < " + payLoadFileName + " | tar xf -").start();
+ int exitVal = process.waitFor();
+ LOGGER.info("gzip -d returned: " + exitVal);
+ } catch (Exception e) {
+ ErrorLogHelper.logError("AAI_8002", "Exception while running the unzip "+ e.getMessage());
+ LOGGER.info("Exception while running the unzip "+ e.getMessage());
+ return false;
+ }
+ /*
+ if (payLoadFileName.indexOf(".") > 0)
+ payLoadFileName = payLoadFileName.substring(0, payLoadFileName.lastIndexOf("."));
+
+ try {
+ process = new ProcessBuilder().command("bash", "-c", "tar xf " + payLoadFileName).start();
+ int exitVal = process.waitFor();
+ LOGGER.info("tar xf returned: " + exitVal);
+ } catch (Exception e) {
+ ErrorLogHelper.logError("AAI_8002", "Exception while running the tar xf "+ e.getMessage());
+ LOGGER.info("Exception while running the tar xf "+ e.getMessage());
+ return false;
+ }
+ */
+ return true;
+ }
+
+ private static boolean isTargzExtension(String fileName) {
+ boolean found = false;
+ for (String ext : EXTS) {
+ if (fileName.toLowerCase().endsWith("." + ext)) {
+ found = true;
+ }
+ }
+ return found;
+ }
+
+ /**
+ * The runAddManualDataScript method runs a shell script/command with a variable number of arguments
+ * @param script The script/command arguments
+ */
+ private static void runAddManualDataScript(String ...script ) {
+ Process process = null;
+ try {
+ process = new ProcessBuilder().command(script).start();
+ int exitVal = process.waitFor();
+ LOGGER.info("addManualData.sh returned: " + exitVal);
+ } catch (Exception e) {
+ ErrorLogHelper.logError("AAI_8002", "Exception while running addManualData.sh "+ e.getMessage());
+ LOGGER.info("Exception while running addManualData.sh" + e.getMessage());
+ }
+
+ }
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/config/aaf/AafAuthorizationFilter.java b/aai-resources/src/main/java/org/onap/aai/config/aaf/AafAuthorizationFilter.java
deleted file mode 100644
index 653fc51..0000000
--- a/aai-resources/src/main/java/org/onap/aai/config/aaf/AafAuthorizationFilter.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 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.onap.aai.config.aaf;
-
-import org.onap.aai.Profiles;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.web.filter.OrderedRequestContextFilter;
-import org.springframework.context.annotation.Profile;
-import org.springframework.context.annotation.PropertySource;
-import org.springframework.stereotype.Component;
-
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-import static org.onap.aai.config.aaf.ResponseFormatter.errorResponse;
-
-/**
- * AAF authorization filter
- */
-
-@Component
-@Profile(Profiles.AAF_AUTHENTICATION)
-@PropertySource("file:${server.local.startpath}/aaf/permissions.properties")
-public class AafAuthorizationFilter extends OrderedRequestContextFilter {
-
- @Value("${permission.type}")
- String type;
-
- @Value("${permission.instance}")
- String instance;
-
- public AafAuthorizationFilter() {
- this.setOrder(FilterPriority.AAF_AUTHORIZATION.getPriority());
- }
-
- @Override
- protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException {
- String permission = String.format("%s|%s|%s", type, instance, request.getMethod().toLowerCase());
- if(request.getRequestURI().matches("^.*/util/echo$")){
- filterChain.doFilter(request, response);
- }
- if(!request.isUserInRole(permission)){
- errorResponse(request, response);
- }else{
- filterChain.doFilter(request,response);
- }
- }
- }
diff --git a/aai-resources/src/main/java/org/onap/aai/config/aaf/AafFilter.java b/aai-resources/src/main/java/org/onap/aai/config/aaf/AafFilter.java
deleted file mode 100644
index f1aa7c1..0000000
--- a/aai-resources/src/main/java/org/onap/aai/config/aaf/AafFilter.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 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.onap.aai.config.aaf;
-
-import org.onap.aaf.cadi.PropAccess;
-import org.onap.aaf.cadi.filter.CadiFilter;
-import org.onap.aai.Profiles;
-import org.onap.aai.ResourcesApp;
-import org.springframework.boot.web.filter.OrderedRequestContextFilter;
-import org.springframework.context.annotation.Profile;
-import org.springframework.stereotype.Component;
-
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.Properties;
-
-import static org.onap.aai.config.aaf.ResponseFormatter.*;
-
-/**
- * AAF authentication filter
- */
-
-@Component
-@Profile(Profiles.AAF_AUTHENTICATION)
-public class AafFilter extends OrderedRequestContextFilter {
-
- private final CadiFilter cadiFilter;
-
- public AafFilter() throws IOException, ServletException {
- Properties cadiProperties = new Properties();
- cadiProperties.load(ResourcesApp.class.getClassLoader().getResourceAsStream("cadi.properties"));
- cadiFilter = new CadiFilter(new PropAccess(cadiProperties));
- this.setOrder(FilterPriority.AAF_AUTHENTICATION.getPriority());
- }
-
- @Override
- protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException {
- if(!request.getRequestURI().matches("^.*/util/echo$")){
- cadiFilter.doFilter(request, response, filterChain);
- if(response.getStatus() >=400 && response.getStatus() < 500){
- errorResponse(request, response);
- }
- } else {
- filterChain.doFilter(request, response);
- }
- }
-
-
-}
diff --git a/aai-resources/src/main/java/org/onap/aai/config/aaf/FilterPriority.java b/aai-resources/src/main/java/org/onap/aai/config/aaf/FilterPriority.java
deleted file mode 100644
index 910db69..0000000
--- a/aai-resources/src/main/java/org/onap/aai/config/aaf/FilterPriority.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 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.onap.aai.config.aaf;
-
-import org.springframework.core.Ordered;
-
-public enum FilterPriority {
- AAF_AUTHENTICATION(Ordered.HIGHEST_PRECEDENCE),
- AAF_AUTHORIZATION(Ordered.HIGHEST_PRECEDENCE + 1); //higher number = lower priority
-
- private final int priority;
-
- FilterPriority(final int p) {
- priority = p;
- }
-
- public int getPriority() { return priority; }
-}
diff --git a/aai-resources/src/main/java/org/onap/aai/config/aaf/ResponseFormatter.java b/aai-resources/src/main/java/org/onap/aai/config/aaf/ResponseFormatter.java
deleted file mode 100644
index 9e09827..0000000
--- a/aai-resources/src/main/java/org/onap/aai/config/aaf/ResponseFormatter.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 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.onap.aai.config.aaf;
-
-import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.logging.ErrorLogHelper;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.ws.rs.core.MediaType;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-
-class ResponseFormatter {
-
- private static final String ACCEPT_HEADER = "accept";
-
- static void errorResponse(HttpServletRequest request, HttpServletResponse response) throws IOException {
- String accept = request.getHeader(ACCEPT_HEADER) == null ? MediaType.APPLICATION_XML : request.getHeader(ACCEPT_HEADER);
- AAIException aaie = new AAIException("AAI_3300");
- response.setStatus(aaie.getErrorObject().getHTTPResponseCode().getStatusCode());
- response.getWriter().write(ErrorLogHelper.getRESTAPIErrorResponse(Collections.singletonList(MediaType.valueOf(accept)), aaie, new ArrayList<>()));
- response.getWriter().flush();
- response.getWriter().close();
- }
-
-}
diff --git a/aai-resources/src/main/java/org/onap/aai/interceptors/AAIHeaderProperties.java b/aai-resources/src/main/java/org/onap/aai/interceptors/AAIHeaderProperties.java
index 6801aee..8783ed2 100644
--- a/aai-resources/src/main/java/org/onap/aai/interceptors/AAIHeaderProperties.java
+++ b/aai-resources/src/main/java/org/onap/aai/interceptors/AAIHeaderProperties.java
@@ -30,7 +30,9 @@ public final class AAIHeaderProperties {
public static final String TRANSACTION_ID = "X-TransactionId";
public static final String FROM_APP_ID = "X-FromAppId";
-
+
+ public static final String SOURCE_OF_TRUTH = "X-SourceOfTruth";
+
public static final String AAI_TX_ID = "X-AAI-TXID";
public static final String AAI_REQUEST = "X-REQUEST";
diff --git a/aai-resources/src/main/java/org/onap/aai/interceptors/post/ResetLoggingContext.java b/aai-resources/src/main/java/org/onap/aai/interceptors/post/ResetLoggingContext.java
deleted file mode 100644
index 04f0391..0000000
--- a/aai-resources/src/main/java/org/onap/aai/interceptors/post/ResetLoggingContext.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 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.onap.aai.interceptors.post;
-
-import java.io.IOException;
-
-import javax.annotation.Priority;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.container.ContainerRequestContext;
-import javax.ws.rs.container.ContainerResponseContext;
-import javax.ws.rs.container.ContainerResponseFilter;
-import javax.ws.rs.core.Response.Status;
-import javax.ws.rs.core.Response.StatusType;
-
-import org.onap.aai.interceptors.AAIContainerFilter;
-import org.onap.aai.logging.LoggingContext;
-import org.onap.aai.logging.LoggingContext.StatusCode;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-@Priority(AAIResponseFilterPriority.RESET_LOGGING_CONTEXT)
-public class ResetLoggingContext extends AAIContainerFilter implements ContainerResponseFilter {
-
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(ResetLoggingContext.class);
-
- @Autowired
- private HttpServletRequest httpServletRequest;
-
- @Override
- public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
- throws IOException {
-
- this.cleanLoggingContext(responseContext);
-
- }
-
- private void cleanLoggingContext(ContainerResponseContext responseContext) {
- //String url = httpServletRequest.getRequestURL().toString();
- boolean success = true;
- String uri = httpServletRequest.getRequestURI();
- String queryString = httpServletRequest.getQueryString();
-
- if(queryString != null && !queryString.isEmpty()){
- uri = uri + "?" + queryString;
- }
- // For now, we use the the HTTP status code,
- // This may change, once the requirements for response codes are defined
-
- int httpStatusCode = responseContext.getStatus();
- if ( httpStatusCode < 100 || httpStatusCode > 599 ) {
- httpStatusCode = Status.INTERNAL_SERVER_ERROR.getStatusCode();
- }
- LoggingContext.responseCode(Integer.toString(httpStatusCode));
-
- StatusType sType = responseContext.getStatusInfo();
- if ( sType != null ) {
- Status.Family sFamily = sType.getFamily();
- if ( ! ( Status.Family.SUCCESSFUL.equals(sFamily) ||
- ( Status.NOT_FOUND.equals(Status.fromStatusCode(httpStatusCode)) ) ) ) {
- success = false;
- }
- }
- else {
- if ( (httpStatusCode < 200 || httpStatusCode > 299) && ( ! ( Status.NOT_FOUND.equals(Status.fromStatusCode(httpStatusCode) ) ) ) ) {
- success = false;
- }
- }
- if (success) {
- LoggingContext.statusCode(StatusCode.COMPLETE);
- LOGGER.info(uri + " call succeeded");
- }
- else {
- LoggingContext.statusCode(StatusCode.ERROR);
- LOGGER.error(uri + " call failed with responseCode=" + httpStatusCode);
- }
- LoggingContext.clear();
-
-
- }
-
-}
diff --git a/aai-resources/src/main/java/org/onap/aai/interceptors/post/ResponseTransactionLogging.java b/aai-resources/src/main/java/org/onap/aai/interceptors/post/ResponseTransactionLogging.java
index 4a47658..bfc1636 100644
--- a/aai-resources/src/main/java/org/onap/aai/interceptors/post/ResponseTransactionLogging.java
+++ b/aai-resources/src/main/java/org/onap/aai/interceptors/post/ResponseTransactionLogging.java
@@ -19,8 +19,8 @@
*/
package org.onap.aai.interceptors.post;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.gson.JsonObject;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.interceptors.AAIContainerFilter;
@@ -42,7 +42,7 @@ import java.util.Optional;
@Priority(AAIResponseFilterPriority.RESPONSE_TRANS_LOGGING)
public class ResponseTransactionLogging extends AAIContainerFilter implements ContainerResponseFilter {
- private static final EELFLogger TRANSACTION_LOGGER = EELFManager.getInstance().getLogger(ResponseTransactionLogging.class);
+ private static final Logger TRANSACTION_LOGGER = LoggerFactory.getLogger(ResponseTransactionLogging.class);
@Autowired
private HttpServletResponse httpServletResponse;
diff --git a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/HeaderValidation.java b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/HeaderValidation.java
index dfc4376..8113fa7 100644
--- a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/HeaderValidation.java
+++ b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/HeaderValidation.java
@@ -36,6 +36,10 @@ import org.onap.aai.exceptions.AAIException;
import org.onap.aai.interceptors.AAIContainerFilter;
import org.onap.aai.interceptors.AAIHeaderProperties;
import org.onap.aai.logging.ErrorLogHelper;
+import org.onap.logging.filter.base.Constants;
+import org.onap.logging.filter.base.ONAPComponents;
+import org.onap.logging.filter.base.SimpleMap;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
@PreMatching
@Priority(AAIRequestFilterPriority.HEADER_VALIDATION)
@@ -45,36 +49,28 @@ public class HeaderValidation extends AAIContainerFilter implements ContainerReq
public void filter(ContainerRequestContext requestContext) throws IOException {
Optional<Response> oResp;
-
- String transId = requestContext.getHeaderString(AAIHeaderProperties.TRANSACTION_ID);
- String fromAppId = requestContext.getHeaderString(AAIHeaderProperties.FROM_APP_ID);
-
List<MediaType> acceptHeaderValues = requestContext.getAcceptableMediaTypes();
+ String fromAppId = getPartnerName(requestContext);
oResp = this.validateHeaderValuePresence(fromAppId, "AAI_4009", acceptHeaderValues);
if (oResp.isPresent()) {
requestContext.abortWith(oResp.get());
return;
}
+
+ String transId = getRequestId(requestContext);
oResp = this.validateHeaderValuePresence(transId, "AAI_4010", acceptHeaderValues);
if (oResp.isPresent()) {
requestContext.abortWith(oResp.get());
return;
}
-
- if (!this.isValidUUID(transId)) {
- transId = UUID.randomUUID().toString();
- requestContext.getHeaders().get(AAIHeaderProperties.TRANSACTION_ID).clear();
- requestContext.getHeaders().add(AAIHeaderProperties.TRANSACTION_ID, transId);
- }
-
}
private Optional<Response> validateHeaderValuePresence(String value, String errorCode,
List<MediaType> acceptHeaderValues) {
Response response = null;
AAIException aaie;
- if (value == null) {
+ if (value == null || value.isEmpty()) {
aaie = new AAIException(errorCode);
return Optional.of(Response.status(aaie.getErrorObject().getHTTPResponseCode())
.entity(ErrorLogHelper.getRESTAPIErrorResponse(acceptHeaderValues, aaie, new ArrayList<>()))
@@ -83,5 +79,77 @@ public class HeaderValidation extends AAIContainerFilter implements ContainerReq
return Optional.ofNullable(response);
}
+ public String getRequestId(ContainerRequestContext requestContext) {
+ String requestId = requestContext.getHeaderString(ONAPLogConstants.Headers.REQUEST_ID);
+ if (requestId == null || requestId.isEmpty()) {
+ requestId = requestContext.getHeaderString(Constants.HttpHeaders.HEADER_REQUEST_ID);
+ if (requestId == null || requestId.isEmpty()) {
+ requestId = requestContext.getHeaderString(Constants.HttpHeaders.TRANSACTION_ID);
+ if (requestId == null || requestId.isEmpty()) {
+ requestId = requestContext.getHeaderString(Constants.HttpHeaders.ECOMP_REQUEST_ID);
+ if (requestId == null || requestId.isEmpty()) {
+ return requestId;
+ }
+ }
+ }
+ }
+ if (requestContext.getHeaders().get(ONAPLogConstants.Headers.REQUEST_ID) != null) {
+ requestContext.getHeaders().get(ONAPLogConstants.Headers.REQUEST_ID).clear();
+ }
+ if (requestContext.getHeaders().get(Constants.HttpHeaders.TRANSACTION_ID) != null) {
+ requestContext.getHeaders().get(Constants.HttpHeaders.TRANSACTION_ID).clear();
+ }
+ if (requestContext.getHeaders().get(Constants.HttpHeaders.HEADER_REQUEST_ID) != null) {
+ requestContext.getHeaders().get(Constants.HttpHeaders.HEADER_REQUEST_ID).clear();
+ }
+ if (requestContext.getHeaders().get(Constants.HttpHeaders.ECOMP_REQUEST_ID) != null) {
+ requestContext.getHeaders().get(Constants.HttpHeaders.ECOMP_REQUEST_ID).clear();
+ }
+ requestContext.getHeaders().add(Constants.HttpHeaders.TRANSACTION_ID, requestId);
+ return requestId;
+ }
+
+ public String getPartnerName(ContainerRequestContext requestContext) {
+
+ // CDM header overrides everything else for source of truth
+ String sourceOfTruth = requestContext.getHeaderString(AAIHeaderProperties.SOURCE_OF_TRUTH);
+ String partnerName = requestContext.getHeaderString(ONAPLogConstants.Headers.PARTNER_NAME);
+ if ( sourceOfTruth == null || sourceOfTruth.isEmpty()) {
+
+ if (partnerName != null && !(partnerName.isEmpty())) {
+ String components[] = partnerName.split("\\.");
+ if (components.length > 1) {
+ if (!(ONAPComponents.AAI.toString().equalsIgnoreCase(components[0]))) {
+ sourceOfTruth = components[0];
+ } else {
+ // request is coming internally from AAI, check X-FromAppId
+ partnerName = null;
+ }
+ }
+ }
+ if (sourceOfTruth == null || sourceOfTruth.isEmpty()) {
+ if (partnerName == null || (partnerName.isEmpty())) {
+ partnerName = requestContext.getHeaderString(AAIHeaderProperties.FROM_APP_ID);
+ if (partnerName == null || (partnerName.isEmpty())) {
+ return partnerName;
+ }
+ }
+ }
+ }
+ if (requestContext.getHeaders().get(ONAPLogConstants.Headers.PARTNER_NAME) != null) {
+ requestContext.getHeaders().get(ONAPLogConstants.Headers.PARTNER_NAME).clear();
+ }
+ if (requestContext.getHeaders().get(AAIHeaderProperties.FROM_APP_ID) != null) {
+ requestContext.getHeaders().get(AAIHeaderProperties.FROM_APP_ID).clear();
+ }
+ if ((sourceOfTruth != null) && !(sourceOfTruth.isEmpty())) {
+ requestContext.getHeaders().add(AAIHeaderProperties.FROM_APP_ID, sourceOfTruth);
+ partnerName = sourceOfTruth;
+ }
+ else {
+ requestContext.getHeaders().add(AAIHeaderProperties.FROM_APP_ID, partnerName);
+ }
+ return partnerName;
+ }
}
diff --git a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RequestTransactionLogging.java b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RequestTransactionLogging.java
index f9976c2..54f2695 100644
--- a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RequestTransactionLogging.java
+++ b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RequestTransactionLogging.java
@@ -33,6 +33,8 @@ import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.container.PreMatching;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.UriInfo;
import org.glassfish.jersey.message.internal.ReaderWriter;
import org.glassfish.jersey.server.ContainerException;
@@ -60,6 +62,8 @@ public class RequestTransactionLogging extends AAIContainerFilter implements Con
private static final String CONTENT_TYPE = "Content-Type";
private static final String ACCEPT = "Accept";
private static final String TEXT_PLAIN = "text/plain";
+ private static final String WILDCARD = "*/*";
+ private static final String APPLICATION_JSON = "application/json";
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
@@ -85,8 +89,20 @@ public class RequestTransactionLogging extends AAIContainerFilter implements Con
requestContext.getHeaders().putSingle(CONTENT_TYPE, DEFAULT_CONTENT_TYPE);
}
- if(StringUtils.isEmpty(acceptType) || acceptType.contains(TEXT_PLAIN)){
- requestContext.getHeaders().putSingle(ACCEPT, DEFAULT_RESPONSE_TYPE);
+ if(WILDCARD.equals(acceptType) || StringUtils.isEmpty(acceptType) || acceptType.contains(TEXT_PLAIN)){
+ UriInfo uriInfo = requestContext.getUriInfo();
+ if(uriInfo != null){
+ MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters();
+ if(queryParameters != null && queryParameters.containsKey("format")){
+ // Add application/json as the default header if request contains query parameter format
+ // Since clients are assuming the default response to be application json for when format is specified
+ requestContext.getHeaders().putSingle(ACCEPT, APPLICATION_JSON);
+ } else {
+ requestContext.getHeaders().putSingle(ACCEPT, DEFAULT_RESPONSE_TYPE);
+ }
+ } else {
+ requestContext.getHeaders().putSingle(ACCEPT, DEFAULT_RESPONSE_TYPE);
+ }
}
}
diff --git a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/SetLoggingContext.java b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/SetLoggingContext.java
deleted file mode 100644
index 368d071..0000000
--- a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/SetLoggingContext.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 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.onap.aai.interceptors.pre;
-
-import java.io.IOException;
-
-import javax.annotation.Priority;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.container.ContainerRequestContext;
-import javax.ws.rs.container.ContainerRequestFilter;
-import javax.ws.rs.container.PreMatching;
-
-import org.onap.aai.interceptors.AAIContainerFilter;
-import org.onap.aai.interceptors.AAIHeaderProperties;
-import org.onap.aai.logging.LoggingContext;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.env.Environment;
-
-@PreMatching
-@Priority(AAIRequestFilterPriority.SET_LOGGING_CONTEXT)
-public class SetLoggingContext extends AAIContainerFilter implements ContainerRequestFilter {
-
- @Autowired
- private Environment environment;
-
- @Autowired
- private HttpServletRequest httpServletRequest;
-
- @Override
- public void filter(ContainerRequestContext requestContext) throws IOException {
-
- String uri = httpServletRequest.getRequestURI();
- String queryString = httpServletRequest.getQueryString();
-
- if(queryString != null && !queryString.isEmpty()){
- uri = uri + "?" + queryString;
- }
-
- String httpMethod = requestContext.getMethod();
- String transId = requestContext.getHeaderString(AAIHeaderProperties.TRANSACTION_ID);
- String fromAppId = requestContext.getHeaderString(AAIHeaderProperties.FROM_APP_ID);
-
- LoggingContext.init();
- LoggingContext.requestId(transId);
- LoggingContext.partnerName(fromAppId);
- LoggingContext.targetEntity(environment.getProperty("spring.application.name"));
- LoggingContext.component(fromAppId);
- LoggingContext.serviceName(httpMethod + " " + uri);
- LoggingContext.targetServiceName(httpMethod + " " + uri);
- LoggingContext.statusCode(LoggingContext.StatusCode.COMPLETE);
- }
-
-}
diff --git a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/TwoWaySslAuthorization.java b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/TwoWaySslAuthorization.java
index d4e8c4f..6c1c9f8 100644
--- a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/TwoWaySslAuthorization.java
+++ b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/TwoWaySslAuthorization.java
@@ -33,7 +33,7 @@ import javax.ws.rs.container.PreMatching;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.onap.aai.auth.AAIAuthCore;
+import org.onap.aai.aaf.auth.AAIAuthCore;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.interceptors.AAIContainerFilter;
import org.onap.aai.interceptors.AAIHeaderProperties;
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java
index 8033278..3f595d1 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java
@@ -19,40 +19,15 @@
*/
package org.onap.aai.rest;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.PUT;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import javax.ws.rs.core.UriBuilder;
-import javax.ws.rs.core.UriInfo;
-
+import com.google.gson.*;
import org.javatuples.Pair;
import org.onap.aai.config.SpringContextAware;
-import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.ModelType;
-import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.introspection.exceptions.AAIUnmarshallingException;
import org.onap.aai.logging.ErrorObjectNotFoundException;
-import org.onap.aai.logging.LoggingContext;
import org.onap.aai.parsers.query.QueryParser;
import org.onap.aai.rest.bulk.BulkOperation;
import org.onap.aai.rest.bulk.BulkOperationResponse;
@@ -63,18 +38,24 @@ import org.onap.aai.restcore.HttpMethod;
import org.onap.aai.restcore.RESTAPI;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.util.AAIConfig;
import org.onap.aai.util.AAIConstants;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import com.google.gson.JsonSyntaxException;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.PUT;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.*;
+import javax.ws.rs.core.Response.Status;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
/**
* The Class BulkAddConsumer.
@@ -120,26 +101,11 @@ public abstract class BulkConsumer extends RESTAPI {
String transId = headers.getRequestHeaders().getFirst("X-TransactionId");
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
- String realTime = headers.getRequestHeaders().getFirst("Real-Time");
String outputMediaType = getMediaType(headers.getAcceptableMediaTypes());
SchemaVersion version = new SchemaVersion(versionParam);
Response response = null;
try {
- DBConnectionType type = null;
- if(AAIConfig.get("aai.use.realtime", "true").equals("true")){
- type = DBConnectionType.REALTIME;
- } else {
- type = this.determineConnectionType(sourceOfTruth, realTime);
- }
-
- String serviceName = req.getMethod() + " " + req.getRequestURI().toString();
- LoggingContext.requestId(transId);
- LoggingContext.partnerName(sourceOfTruth);
- LoggingContext.serviceName(serviceName);
- LoggingContext.targetEntity(TARGET_ENTITY);
- LoggingContext.targetServiceName(serviceName);
-
/* A Response will be generated for each object in each transaction.
* To keep track of what came from where to give organized feedback to the client,
@@ -152,7 +118,7 @@ public abstract class BulkConsumer extends RESTAPI {
for (int i = 0; i < transactions.size(); i++){
HttpEntry resourceHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
- resourceHttpEntry.setHttpEntryProperties(version, type);
+ resourceHttpEntry.setHttpEntryProperties(version);
Loader loader = resourceHttpEntry.getLoader();
TransactionalGraphEngine dbEngine = resourceHttpEntry.getDbEngine();
URI thisUri = null;
@@ -515,8 +481,7 @@ public abstract class BulkConsumer extends RESTAPI {
* @param headers the headers
* @param info the info
* @param templateAction the template action
- * @param logline Generates a Response based on the given exception and adds it to the collection of responses for this request.
- * @throws ErrorObjectNotFoundException
+ * @throws ErrorObjectNotFoundException
*/
private void addExceptionCaseFailureResponse(List<List<BulkOperationResponse>> allResponses, Exception e, int index, URI thisUri, HttpHeaders headers, UriInfo info, HttpMethod templateAction) {
AAIException ex = null;
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java
index 0b544f4..e6dcc77 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java
@@ -19,46 +19,13 @@
*/
package org.onap.aai.rest;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.Encoded;
-import javax.ws.rs.GET;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriBuilder;
-import javax.ws.rs.core.UriInfo;
-
import io.swagger.jaxrs.PATCH;
import org.javatuples.Pair;
-import org.json.JSONArray;
-import org.json.JSONObject;
import org.onap.aai.concurrent.AaiCallable;
import org.onap.aai.config.SpringContextAware;
-import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
-import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.parsers.query.QueryParser;
import org.onap.aai.rest.db.DBRequest;
import org.onap.aai.rest.db.HttpEntry;
@@ -67,13 +34,19 @@ import org.onap.aai.rest.util.ValidateEncoding;
import org.onap.aai.restcore.HttpMethod;
import org.onap.aai.restcore.RESTAPI;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-import org.onap.aai.util.AAIConfig;
+import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.util.AAIConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.common.base.Joiner;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.*;
+import javax.ws.rs.core.*;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.util.*;
+import java.util.stream.Collectors;
/**
* The Class LegacyMoxyConsumer.
@@ -82,18 +55,7 @@ import com.google.common.base.Joiner;
@Path("{version: v[1-9][0-9]*|latest}")
public class LegacyMoxyConsumer extends RESTAPI {
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(LegacyMoxyConsumer.class.getName());
-
-// private HttpEntry traversalUriHttpEntry;
-
-// @Autowired
-// public LegacyMoxyConsumer(HttpEntry traversalUriHttpEntry){
-// this.traversalUriHttpEntry = traversalUriHttpEntry;
-// }
-
- public LegacyMoxyConsumer(){
-
- }
+ private static final Logger logger = LoggerFactory.getLogger(LegacyMoxyConsumer.class.getName());
/**
*
@@ -133,24 +95,18 @@ public class LegacyMoxyConsumer extends RESTAPI {
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
String transId = headers.getRequestHeaders().getFirst("X-TransactionId");
- String realTime = headers.getRequestHeaders().getFirst("Real-Time");
MediaType inputMediaType = headers.getMediaType();
- Response response = null;
- Loader loader = null;
+ Response response;
+ Loader loader;
TransactionalGraphEngine dbEngine = null;
boolean success = true;
try {
validateRequest(info);
SchemaVersion version = new SchemaVersion(versionParam);
- DBConnectionType type = null;
- if(AAIConfig.get("aai.use.realtime", "true").equals("true")){
- type = DBConnectionType.REALTIME;
- } else {
- type = this.determineConnectionType(sourceOfTruth, realTime);
- }
+
HttpEntry traversalUriHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
- traversalUriHttpEntry.setHttpEntryProperties(version, type);
+ traversalUriHttpEntry.setHttpEntryProperties(version);
loader = traversalUriHttpEntry.getLoader();
dbEngine = traversalUriHttpEntry.getDbEngine();
@@ -262,22 +218,16 @@ public class LegacyMoxyConsumer extends RESTAPI {
public Response getLegacy(String content, String versionParam, String uri, String depthParam, String cleanUp, HttpHeaders headers, UriInfo info, HttpServletRequest req, Set<String> removeQueryParams, String resultIndex, String resultSize) {
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
String transId = headers.getRequestHeaders().getFirst("X-TransactionId");
- String realTime = headers.getRequestHeaders().getFirst("Real-Time");
- Response response = null;
+ Response response;
TransactionalGraphEngine dbEngine = null;
- Loader loader = null;
+ Loader loader;
try {
validateRequest(info);
SchemaVersion version = new SchemaVersion(versionParam);
- DBConnectionType type = null;
- if(AAIConfig.get("aai.use.realtime", "true").equals("true")){
- type = DBConnectionType.REALTIME;
- } else {
- type = this.determineConnectionType(sourceOfTruth, realTime);
- }
+
final HttpEntry traversalUriHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
- traversalUriHttpEntry.setHttpEntryProperties(version, type);
+ traversalUriHttpEntry.setHttpEntryProperties(version);
dbEngine = traversalUriHttpEntry.getDbEngine();
loader = traversalUriHttpEntry.getLoader();
MultivaluedMap<String, String> params = info.getQueryParameters();
@@ -301,7 +251,7 @@ public class LegacyMoxyConsumer extends RESTAPI {
new DBRequest.Builder(HttpMethod.GET, uriObject, uriQuery, obj, headers, info, transId).build();
List<DBRequest> requests = new ArrayList<>();
requests.add(request);
- if (resultIndex != null && resultIndex != "-1" && resultSize != null && resultSize != "-1") {
+ if (resultIndex != null && !"-1".equals(resultIndex) && resultSize != null && !"-1".equals(resultSize)) {
traversalUriHttpEntry.setPaginationIndex(Integer.parseInt(resultIndex));
traversalUriHttpEntry.setPaginationBucket(Integer.parseInt(resultSize));
}
@@ -330,11 +280,11 @@ public class LegacyMoxyConsumer extends RESTAPI {
private MultivaluedMap<String, String> removeNonFilterableParams(MultivaluedMap<String, String> params) {
- String[] toRemove = { "depth", "cleanup", "nodes-only", "format", "resultIndex", "resultSize"};
+ String[] toRemove = { "depth", "cleanup", "nodes-only", "format", "resultIndex", "resultSize", "skip-related-to"};
Set<String> toRemoveSet = Arrays.stream(toRemove).collect(Collectors.toSet());
MultivaluedMap<String, String> cleanedParams = new MultivaluedHashMap<>();
- params.keySet().stream().forEach(k -> {
+ params.keySet().forEach(k -> {
if (!toRemoveSet.contains(k)) {
cleanedParams.addAll(k, params.get(k));
}
@@ -362,11 +312,9 @@ public class LegacyMoxyConsumer extends RESTAPI {
String outputMediaType = getMediaType(headers.getAcceptableMediaTypes());
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
String transId = headers.getRequestHeaders().getFirst("X-TransactionId");
- String realTime = headers.getRequestHeaders().getFirst("Real-Time");
TransactionalGraphEngine dbEngine = null;
- Response response = Response.status(404)
- .type(outputMediaType).build();
+ Response response;
boolean success = true;
@@ -374,14 +322,9 @@ public class LegacyMoxyConsumer extends RESTAPI {
validateRequest(info);
SchemaVersion version = new SchemaVersion(versionParam);
- DBConnectionType type = null;
- if(AAIConfig.get("aai.use.realtime", "true").equals("true")){
- type = DBConnectionType.REALTIME;
- } else {
- type = this.determineConnectionType(sourceOfTruth, realTime);
- }
+
HttpEntry traversalUriHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
- traversalUriHttpEntry.setHttpEntryProperties(version, type);
+ traversalUriHttpEntry.setHttpEntryProperties(version);
dbEngine = traversalUriHttpEntry.getDbEngine();
Loader loader = traversalUriHttpEntry.getLoader();
@@ -437,30 +380,20 @@ public class LegacyMoxyConsumer extends RESTAPI {
public Response deleteRelationship (String content, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
MediaType inputMediaType = headers.getMediaType();
-
- String outputMediaType = getMediaType(headers.getAcceptableMediaTypes());
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
String transId = headers.getRequestHeaders().getFirst("X-TransactionId");
- String realTime = headers.getRequestHeaders().getFirst("Real-Time");
-
- Loader loader = null;
+ Loader loader;
TransactionalGraphEngine dbEngine = null;
- Response response = Response.status(404)
- .type(outputMediaType).build();
+ Response response;
boolean success = true;
try {
this.validateRequest(info);
SchemaVersion version = new SchemaVersion(versionParam);
- DBConnectionType type = null;
- if(AAIConfig.get("aai.use.realtime", "true").equals("true")){
- type = DBConnectionType.REALTIME;
- } else {
- type = this.determineConnectionType(sourceOfTruth, realTime);
- }
+
HttpEntry traversalUriHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
- traversalUriHttpEntry.setHttpEntryProperties(version, type);
+ traversalUriHttpEntry.setHttpEntryProperties(version);
loader = traversalUriHttpEntry.getLoader();
dbEngine = traversalUriHttpEntry.getDbEngine();
@@ -533,7 +466,6 @@ public class LegacyMoxyConsumer extends RESTAPI {
public Response getRelationshipList(String versionParam, String uri, String cleanUp, HttpHeaders headers, UriInfo info, String resultIndex, String resultSize) {
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
String transId = headers.getRequestHeaders().getFirst("X-TransactionId");
- String realTime = headers.getRequestHeaders().getFirst("Real-Time");
Response response = null;
TransactionalGraphEngine dbEngine = null;
Loader loader = null;
@@ -541,14 +473,9 @@ public class LegacyMoxyConsumer extends RESTAPI {
try {
validateRequest(info);
SchemaVersion version = new SchemaVersion(versionParam);
- DBConnectionType type = null;
- if(AAIConfig.get("aai.use.realtime", "true").equals("true")){
- type = DBConnectionType.REALTIME;
- } else {
- type = this.determineConnectionType(sourceOfTruth, realTime);
- }
+
final HttpEntry traversalUriHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
- traversalUriHttpEntry.setHttpEntryProperties(version, type);
+ traversalUriHttpEntry.setHttpEntryProperties(version);
dbEngine = traversalUriHttpEntry.getDbEngine();
loader = traversalUriHttpEntry.getLoader();
MultivaluedMap<String, String> params = info.getQueryParameters();
@@ -572,7 +499,7 @@ public class LegacyMoxyConsumer extends RESTAPI {
new DBRequest.Builder(HttpMethod.GET_RELATIONSHIP, uriObject, uriQuery, obj, headers, info, transId).build();
List<DBRequest> requests = new ArrayList<>();
requests.add(request);
- if (resultIndex != null && resultIndex != "-1" && resultSize != null && resultSize != "-1") {
+ if (resultIndex != null && !"-1".equals(resultIndex) && resultSize != null && !"-1".equals(resultSize)) {
traversalUriHttpEntry.setPaginationIndex(Integer.parseInt(resultIndex));
traversalUriHttpEntry.setPaginationBucket(Integer.parseInt(resultSize));
}
@@ -627,8 +554,8 @@ public class LegacyMoxyConsumer extends RESTAPI {
parmList.add(key + "=" + value);
}
}
- String queryParams = Joiner.on("&").join(parmList);
- if (map.keySet().size() > 0) {
+ String queryParams = String.join("&", parmList);
+ if (!map.isEmpty()) {
path += params + queryParams;
}
@@ -650,27 +577,21 @@ public class LegacyMoxyConsumer extends RESTAPI {
*/
private Response handleWrites(MediaType mediaType, HttpMethod method, String content, String versionParam, String uri, HttpHeaders headers, UriInfo info) {
- Response response = null;
+ Response response;
TransactionalGraphEngine dbEngine = null;
- Loader loader = null;
- SchemaVersion version = null;
+ Loader loader;
+ SchemaVersion version;
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
String transId = headers.getRequestHeaders().getFirst("X-TransactionId");
- String realTime = headers.getRequestHeaders().getFirst("Real-Time");
- Boolean success = true;
+ boolean success = true;
try {
validateRequest(info);
version = new SchemaVersion(versionParam);
- DBConnectionType type = null;
- if(AAIConfig.get("aai.use.realtime", "true").equals("true")){
- type = DBConnectionType.REALTIME;
- } else {
- type = this.determineConnectionType(sourceOfTruth, realTime);
- }
+
HttpEntry traversalUriHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
- traversalUriHttpEntry.setHttpEntryProperties(version, type);
+ traversalUriHttpEntry.setHttpEntryProperties(version);
loader = traversalUriHttpEntry.getLoader();
dbEngine = traversalUriHttpEntry.getDbEngine();
URI uriObject = UriBuilder.fromPath(uri).build();
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java
index b9e5aa8..041952b 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java
@@ -19,43 +19,35 @@
*/
package org.onap.aai.rest;
-import java.net.URI;
-import java.util.Iterator;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import javax.ws.rs.core.UriInfo;
-
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.config.SpringContextAware;
-import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.ModelType;
-import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.rest.db.HttpEntry;
import org.onap.aai.restcore.HttpMethod;
import org.onap.aai.restcore.RESTAPI;
import org.onap.aai.serialization.db.DBSerializer;
-import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.util.AAIConfig;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.*;
+import javax.ws.rs.core.Response.Status;
+import java.net.URI;
+import java.util.Iterator;
+
/**
* The Class URLFromVertexIdConsumer.
*/
@Path("{version: v[1-9][0-9]*|latest}/generateurl")
public class URLFromVertexIdConsumer extends RESTAPI {
private ModelType introspectorFactoryType = ModelType.MOXY;
- private QueryStyle queryStyle = QueryStyle.TRAVERSAL_URI;
-
+
private final String ID_ENDPOINT = "/id/{vertexid: \\d+}";
/**
@@ -75,16 +67,14 @@ public class URLFromVertexIdConsumer extends RESTAPI {
public Response generateUrlFromVertexId(String content, @PathParam("version")String versionParam, @PathParam("vertexid")long vertexid, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
- String realTime = headers.getRequestHeaders().getFirst("Real-Time");
SchemaVersion version = new SchemaVersion(versionParam);
StringBuilder result = new StringBuilder();
- Response response = null;
+ Response response;
TransactionalGraphEngine dbEngine = null;
try {
- DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime);
HttpEntry resourceHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
- resourceHttpEntry.setHttpEntryProperties(version, type);
+ resourceHttpEntry.setHttpEntryProperties(version);
dbEngine = resourceHttpEntry.getDbEngine();
DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth);
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java
index 3451528..6637d41 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java
@@ -19,31 +19,10 @@
*/
package org.onap.aai.rest;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import javax.ws.rs.core.UriBuilder;
-import javax.ws.rs.core.UriInfo;
-
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.javatuples.Pair;
import org.onap.aai.config.SpringContextAware;
import org.onap.aai.db.props.AAIProperties;
-import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
@@ -54,11 +33,17 @@ import org.onap.aai.rest.db.DBRequest;
import org.onap.aai.rest.db.HttpEntry;
import org.onap.aai.restcore.HttpMethod;
import org.onap.aai.restcore.RESTAPI;
-import org.onap.aai.serialization.db.DBSerializer;
-import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.setup.SchemaVersion;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.*;
+import javax.ws.rs.core.*;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
/**
* The Class VertexIdConsumer.
*/
@@ -66,7 +51,6 @@ import org.onap.aai.setup.SchemaVersion;
public class VertexIdConsumer extends RESTAPI {
private ModelType introspectorFactoryType = ModelType.MOXY;
- private QueryStyle queryStyle = QueryStyle.TRAVERSAL_URI;
private final String ID_ENDPOINT = "/id/{vertexid: \\d+}";
@@ -92,22 +76,16 @@ public class VertexIdConsumer extends RESTAPI {
String outputMediaType = getMediaType(headers.getAcceptableMediaTypes());
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
String transId = headers.getRequestHeaders().getFirst("X-TransactionId");
- String realTime = headers.getRequestHeaders().getFirst("Real-Time");
SchemaVersion version = new SchemaVersion(versionParam);
- Status status = Status.NOT_FOUND;
- String result = "";
Response response = null;
TransactionalGraphEngine dbEngine = null;
try {
- int depth = setDepth(depthParam);
- DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime);
resourceHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
- resourceHttpEntry.setHttpEntryProperties(version, type);
+ resourceHttpEntry.setHttpEntryProperties(version);
dbEngine = resourceHttpEntry.getDbEngine();
Loader loader = resourceHttpEntry.getLoader();
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth);
-
+
//get type of the object represented by the given id
Vertex thisVertex = null;
Iterator<Vertex> itr = dbEngine.asAdmin().getTraversalSource().V(vertexid);
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumer.java
index b06abaa..b7b4873 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumer.java
@@ -19,18 +19,16 @@
*/
package org.onap.aai.rest.bulk;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonParser;
import org.javatuples.Pair;
import org.onap.aai.config.SpringContextAware;
-import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
import org.onap.aai.logging.ErrorLogHelper;
-import org.onap.aai.logging.LoggingContext;
import org.onap.aai.rest.bulk.pojos.Operation;
import org.onap.aai.rest.bulk.pojos.OperationResponse;
import org.onap.aai.rest.bulk.pojos.Transaction;
@@ -44,6 +42,8 @@ import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.util.AAIConfig;
import org.onap.aai.util.AAIConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
@@ -57,11 +57,21 @@ import java.util.*;
@Path(value = "{version: v[1-9][0-9]*|latest}/bulk/single-transaction")
public class BulkSingleTransactionConsumer extends RESTAPI {
- private static final String TARGET_ENTITY = "aai-resources";
private static final Set<String> validOperations = Collections.unmodifiableSet(new HashSet<>(Arrays.asList("put", "patch", "delete")));
+ private static final JsonParser parser = new JsonParser();
private int allowedOperationCount = 30;
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(BulkSingleTransactionConsumer.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(BulkSingleTransactionConsumer.class);
+
+ private final String uriPrefix;
+
+ public BulkSingleTransactionConsumer() {
+ uriPrefix = SpringContextAware.getApplicationContext().getEnvironment().getProperty("schema.uri.base.path", "");
+ }
+
+ public BulkSingleTransactionConsumer(String uriPrefix) {
+ this.uriPrefix = uriPrefix;
+ }
@POST
@Consumes(value = javax.ws.rs.core.MediaType.APPLICATION_JSON)
@@ -70,11 +80,8 @@ public class BulkSingleTransactionConsumer extends RESTAPI {
String transId = headers.getRequestHeaders().getFirst("X-TransactionId");
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
- String realTime = headers.getRequestHeaders().getFirst("Real-Time");
SchemaVersion version = new SchemaVersion(versionParam);
- DBConnectionType type;
- initLogging(req, transId, sourceOfTruth);
boolean success = true;
TransactionalGraphEngine dbEngine = null;
@@ -82,11 +89,6 @@ public class BulkSingleTransactionConsumer extends RESTAPI {
Response response;
try {
- if(AAIConfig.get("aai.use.realtime", "true").equals("true")){
- type = DBConnectionType.REALTIME;
- } else {
- type = this.determineConnectionType(sourceOfTruth, realTime);
- }
// unmarshall the payload.
Gson gson = new Gson();
@@ -107,7 +109,7 @@ public class BulkSingleTransactionConsumer extends RESTAPI {
//init http entry
HttpEntry resourceHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
- resourceHttpEntry.setHttpEntryProperties(version, type);
+ resourceHttpEntry.setHttpEntryProperties(version);
Loader loader = resourceHttpEntry.getLoader();
dbEngine = resourceHttpEntry.getDbEngine();
@@ -123,16 +125,19 @@ public class BulkSingleTransactionConsumer extends RESTAPI {
//process db requests
Pair<Boolean, List<Pair<URI, Response>>> results = resourceHttpEntry.process(dbRequests, sourceOfTruth, this.enableResourceVersion());
- //process result of db requests
- transactionResponse = buildTransactionResponse(transaction, results.getValue1());
-
//commit/rollback based on results
success = results.getValue0();
- response = Response
- .status(Response.Status.CREATED)
- .entity(new GsonBuilder().serializeNulls().create().toJson(transactionResponse))
- .build();
+ if (success) { //process result of db requests if all are successful
+ transactionResponse = buildTransactionResponse(transaction, results.getValue1());
+ response = Response
+ .status(Response.Status.CREATED)
+ .entity(new GsonBuilder().serializeNulls().create().toJson(transactionResponse))
+ .build();
+ } else {
+ response = getErrorResponseForFirstFailure(transaction, results.getValue1(), info, javax.ws.rs.HttpMethod.POST, headers);
+
+ }
} catch (AAIException e) {
response = consumerExceptionResponseGenerator(headers, info, javax.ws.rs.HttpMethod.POST, e);
@@ -152,6 +157,44 @@ public class BulkSingleTransactionConsumer extends RESTAPI {
return response;
}
+ private Response getErrorResponseForFirstFailure(Transaction transaction, List<Pair<URI, Response>> results, UriInfo info, String action, HttpHeaders headers) throws AAIException {
+ final String failureInResponse = "Operation %s with action (%s) on uri (%s) failed with status code (%s), error code (%s) and msg (%s)";
+ for (int i = 0; i < transaction.getOperations().size(); i++) {
+ if (!Response.Status.Family.familyOf(results.get(i).getValue1().getStatus()).equals(Response.Status.Family.SUCCESSFUL)) {
+ final JsonArray vars = parser.parse(results.get(i).getValue1().getEntity().toString()).getAsJsonObject()
+ .getAsJsonObject("requestError")
+ .getAsJsonObject("serviceException")
+ .getAsJsonArray("variables");
+ StringBuilder sb = new StringBuilder();
+ for (int j = 2; j < vars.size() - 1; j++) {
+ if (j != 2) {
+ sb.append(": ");
+ }
+ sb.append(vars.get(j).getAsString());
+ }
+ final AAIException e = new AAIException("AAI_3000",
+ String.format(
+ failureInResponse,
+ i,
+ vars.get(0).getAsString(),
+ vars.get(1).getAsString(),
+ results.get(i).getValue1().getStatus(),
+ vars.get(vars.size()-1).getAsString(),
+ sb.toString()
+ ));
+ ArrayList<String> templateVars = new ArrayList<>();
+ templateVars.add(action); //GET, PUT, etc
+ templateVars.add(info.getPath());
+ return Response
+ .status(results.get(i).getValue1().getStatus())
+ .entity(ErrorLogHelper.getRESTAPIErrorResponseWithLogging(headers.getAcceptableMediaTypes(), e, templateVars))
+ .build();
+ }
+ }
+ LOGGER.error("Transaction Process reported failure, none found.");
+ throw new AAIException("AAI_3000", "Transaction Process reported failure, none found.");
+ }
+
/**
* Builds the response
@@ -297,11 +340,9 @@ public class BulkSingleTransactionConsumer extends RESTAPI {
List<BulkOperation> bulkOperations = new ArrayList<>(transaction.getOperations().size());
BulkOperation bulkOperation;
- for (int i = 0; i < transaction.getOperations().size(); i++) {
- final Operation operation = transaction.getOperations().get(i);
+ for (Operation operation : transaction.getOperations()) {
bulkOperation = new BulkOperation();
-
- UriComponents uriComponents = UriComponentsBuilder.fromUriString(operation.getUri()).build();
+ UriComponents uriComponents = UriComponentsBuilder.fromUriString(getUri(operation)).build();
bulkOperation.setUri(UriBuilder.fromPath(uriComponents.getPath()).build());
bulkOperation.addUriInfoQueryParams(uriComponents.getQueryParams());
bulkOperation.setHttpMethod(getHttpMethod(operation.getAction(), bulkOperation.getUri()));
@@ -312,6 +353,17 @@ public class BulkSingleTransactionConsumer extends RESTAPI {
return bulkOperations;
}
+ private String getUri(Operation operation) {
+ String uri = operation.getUri();
+ if (uri == null || uri.isEmpty()) {
+ return uri;
+ } else if (uri.charAt(0) != '/') {
+ uri = '/' + uri;
+ }
+ return uri.replaceAll("^" + uriPrefix + "/v\\d+", "");
+ }
+
+
/**
* Map action to httpmethod
* @param action action to be mapped
@@ -386,21 +438,6 @@ public class BulkSingleTransactionConsumer extends RESTAPI {
}
- /**
- * Initialize logging context
- * @param req requestContext
- * @param transId transaction id
- * @param sourceOfTruth application source
- */
- private void initLogging(@Context HttpServletRequest req, String transId, String sourceOfTruth) {
- String serviceName = req.getMethod() + " " + req.getRequestURI().toString();
- LoggingContext.requestId(transId);
- LoggingContext.partnerName(sourceOfTruth);
- LoggingContext.serviceName(serviceName);
- LoggingContext.targetEntity(TARGET_ENTITY);
- LoggingContext.targetServiceName(serviceName);
- }
-
protected boolean enableResourceVersion() {
return true;
}
diff --git a/aai-resources/src/main/java/org/onap/aai/service/AuthorizationService.java b/aai-resources/src/main/java/org/onap/aai/service/AuthorizationService.java
index d2597d0..9b5a614 100644
--- a/aai-resources/src/main/java/org/onap/aai/service/AuthorizationService.java
+++ b/aai-resources/src/main/java/org/onap/aai/service/AuthorizationService.java
@@ -19,8 +19,8 @@
*/
package org.onap.aai.service;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.eclipse.jetty.util.security.Password;
import org.onap.aai.Profiles;
import org.onap.aai.util.AAIConstants;
@@ -41,7 +41,7 @@ import java.util.stream.Stream;
@Service
public class AuthorizationService {
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(AuthorizationService.class);
+ private static final Logger logger = LoggerFactory.getLogger(AuthorizationService.class);
private final Map<String, String> authorizedUsers = new HashMap<>();
@@ -72,7 +72,7 @@ public class AuthorizationService {
String[] usernamePasswordArray = usernamePassword.split(":");
if(usernamePasswordArray == null || usernamePasswordArray.length != 3){
- throw new RuntimeException("Not a valid entry for the realm.properties entry: " + usernamePassword);
+ throw new RuntimeException("This username / pwd is not a valid entry in realm.properties");
}
String username = usernamePasswordArray[0];
diff --git a/aai-resources/src/main/java/org/onap/aai/web/JerseyConfiguration.java b/aai-resources/src/main/java/org/onap/aai/web/JerseyConfiguration.java
index 9592639..c5f3e08 100644
--- a/aai-resources/src/main/java/org/onap/aai/web/JerseyConfiguration.java
+++ b/aai-resources/src/main/java/org/onap/aai/web/JerseyConfiguration.java
@@ -28,6 +28,8 @@ import java.util.Comparator;
import java.util.Set;
import java.util.logging.Logger;
import javax.annotation.Priority;
+import javax.ws.rs.client.ClientRequestFilter;
+import javax.ws.rs.client.ClientResponseFilter;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.container.ContainerResponseFilter;
import jersey.repackaged.com.google.common.collect.Sets;
@@ -41,6 +43,7 @@ import org.onap.aai.rest.URLFromVertexIdConsumer;
import org.onap.aai.rest.VertexIdConsumer;
import org.onap.aai.rest.bulk.BulkSingleTransactionConsumer;
import org.onap.aai.rest.util.EchoResponse;
+import org.onap.logging.filter.base.AuditLogContainerFilter;
import org.reflections.Reflections;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
@@ -55,9 +58,11 @@ public class JerseyConfiguration {
private static final String LOGGING_ENABLED_PROPERTY = "aai.request.logging.enabled";
private static final String INTERCEPTOR_PACKAGE = "org.onap.aai.interceptors";
+ private static final String LOGGING_INTERCEPTOR_PACKAGE = "org.onap.aai.aailog.filter";
private static final boolean ENABLE_RESPONSE_LOGGING = false;
private final Reflections reflections = new Reflections(INTERCEPTOR_PACKAGE);
+ private final Reflections loggingReflections = new Reflections(LOGGING_INTERCEPTOR_PACKAGE);
private final Environment environment;
@Autowired
@@ -80,7 +85,7 @@ public class JerseyConfiguration {
URLFromVertexIdConsumer.class
);
resourceConfig.registerClasses(classes);
- registerFiltersForClasses(resourceConfig, ContainerRequestFilter.class, ContainerResponseFilter.class);
+ registerFiltersForClasses(resourceConfig, ContainerRequestFilter.class, ContainerResponseFilter.class, AuditLogContainerFilter.class);
if (isLoggingEnabled()) {
logRequests(resourceConfig);
@@ -96,8 +101,8 @@ public class JerseyConfiguration {
}
private <T> void registerFiltersFor(Class<T> clazz, ResourceConfig resourceConfig) {
- Set<Class<? extends T>> filters = reflections.getSubTypesOf(clazz);
-
+ Set<Class<? extends T>> filters = loggingReflections.getSubTypesOf(clazz);
+ filters.addAll(reflections.getSubTypesOf(clazz));
throwIfPriorityAnnotationAbsent(filters);
filters.stream()
diff --git a/aai-resources/src/main/resources/aaf/bath_config.csv b/aai-resources/src/main/resources/aaf/onap/bath_config.csv
index 433b333..433b333 100644
--- a/aai-resources/src/main/resources/aaf/bath_config.csv
+++ b/aai-resources/src/main/resources/aaf/onap/bath_config.csv
diff --git a/aai-resources/src/main/resources/aaf/org.onap.aai.keyfile b/aai-resources/src/main/resources/aaf/onap/org.onap.aai.keyfile
index 3416d4a..3416d4a 100644
--- a/aai-resources/src/main/resources/aaf/org.onap.aai.keyfile
+++ b/aai-resources/src/main/resources/aaf/onap/org.onap.aai.keyfile
diff --git a/aai-resources/src/main/resources/aaf/org.onap.aai.p12 b/aai-resources/src/main/resources/aaf/onap/org.onap.aai.p12
index 023e2ea..023e2ea 100644
--- a/aai-resources/src/main/resources/aaf/org.onap.aai.p12
+++ b/aai-resources/src/main/resources/aaf/onap/org.onap.aai.p12
Binary files differ
diff --git a/aai-resources/src/main/resources/aaf/org.onap.aai.props b/aai-resources/src/main/resources/aaf/onap/org.onap.aai.props
index 6e683df..33f0f3c 100644
--- a/aai-resources/src/main/resources/aaf/org.onap.aai.props
+++ b/aai-resources/src/main/resources/aaf/onap/org.onap.aai.props
@@ -3,12 +3,12 @@
# @copyright 2016, AT&T
############################################################
cadi_x509_issuers=CN=intermediateCA_1, OU=OSAAF, O=ONAP, C=US
-cadi_keyfile=aai-resources/src/main/resources/aaf/org.onap.aai.keyfile
-cadi_keystore=aai-resources/src/main/resources/aaf/org.onap.aai.p12
+cadi_keyfile=aai-resources/src/main/resources/aaf/onap/org.onap.aai.keyfile
+cadi_keystore=aai-resources/src/main/resources/aaf/onap/org.onap.aai.p12
cadi_keystore_password=enc:383RDJRFA6yQz9AOxUxC1iIg3xTJXityw05MswnpnEtelRQy2D4r5INQjrea7GTV
#cadi_key_password=enc:<KEY PASSWORD (optional if the same as KEYSTORE PASSWORD)>
cadi_alias=aai@aai.onap.org
-cadi_truststore=aai-resources/src/main/resources/aaf/truststoreONAPall.jks
+cadi_truststore=aai-resources/src/main/resources/aaf/onap/truststoreONAPall.jks
cadi_truststore_password=enc:s77wlnZFoQ08NhnU3OSeWO6uKgRwC6sAK-wTvVubNz2
cadi_loglevel=INFO
-cadi_bath_convert=aai-resources/src/main/resources/aaf/bath_config.csv
+cadi_bath_convert=aai-resources/src/main/resources/aaf/onap/bath_config.csv
diff --git a/aai-resources/src/main/resources/aaf/org.osaaf.location.props b/aai-resources/src/main/resources/aaf/onap/org.osaaf.location.props
index 73a3a1e..73a3a1e 100644
--- a/aai-resources/src/main/resources/aaf/org.osaaf.location.props
+++ b/aai-resources/src/main/resources/aaf/onap/org.osaaf.location.props
diff --git a/aai-resources/src/main/resources/aaf/truststoreONAPall.jks b/aai-resources/src/main/resources/aaf/onap/truststoreONAPall.jks
index 2da1dcc..2da1dcc 100644
--- a/aai-resources/src/main/resources/aaf/truststoreONAPall.jks
+++ b/aai-resources/src/main/resources/aaf/onap/truststoreONAPall.jks
Binary files differ
diff --git a/aai-resources/src/main/resources/application.properties b/aai-resources/src/main/resources/application.properties
index 3cabe4a..d6064d5 100644
--- a/aai-resources/src/main/resources/application.properties
+++ b/aai-resources/src/main/resources/application.properties
@@ -4,7 +4,7 @@ info.build.name=resources
info.build.description=Resources Microservice
info.build.version=1.1.0
-spring.application.name=aai-resources
+spring.application.name=Resources Microservice
spring.jersey.type=filter
server.contextPath=/
@@ -29,7 +29,6 @@ server.basic.auth.location=${server.local.startpath}etc/auth/realm.properties
server.certs.location=${server.local.startpath}etc/auth/
#server.keystore.name=keystore.jks
server.keystore.name=aai_keystore
-#server.truststore.name=com.att.ecomp.aai.dev.trust.jks
server.truststore.name=aai_keystore
server.port=8447
server.ssl.enabled-protocols=TLSv1.1,TLSv1.2
@@ -57,7 +56,7 @@ schema.ingest.file=${server.local.startpath}/application.properties
schema.uri.base.path=/aai
# Lists all of the versions in the schema
-schema.version.list=v10,v11,v12,v13,v14,v15,v16
+schema.version.list=v10,v11,v12,v13,v14,v15,v16,v17,v18,v19
# Specifies from which version should the depth parameter to default to zero
schema.version.depth.start=v10
# Specifies from which version should the related link be displayed in response payload
@@ -70,7 +69,10 @@ schema.version.namespace.change.start=v12
# Specifies from which version should the client start seeing the edge label in payload
schema.version.edge.label.start=v12
# Specifies the version that the application should default to
-schema.version.api.default=v16
+schema.version.api.default=v19
+
+
+#schema.translator.list=schema-service
schema.translator.list=config
schema.service.base.url=https://localhost:8452/aai/schema-service/v1/
schema.service.nodes.endpoint=nodes?version=
@@ -82,3 +84,28 @@ schema.service.ssl.trust-store=${server.certs.location}${server.truststore.name}
schema.service.ssl.key-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
schema.service.ssl.trust-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
schema.service.versions.override=false
+
+# Location of the cadi properties file should be specified here
+aaf.cadi.file=${server.local.startpath}/cadi.properties
+
+delta.events.enabled=false
+
+# Specifies what type of request should it be: one-way-ssl, two-way-ssl, no-auth
+validation.service.client=one-way-ssl
+# Base url for the validation service
+validation.service.base.url=https://localhost:9501/services/validation-service
+# Client certificate to use to make the request to validation
+validation.service.ssl.key-store=${server.local.startpath}/etc/auth/aai-client-cert.p12
+# Truststore to use to make the request to validation
+validation.service.ssl.trust-store=${server.local.startpath}/etc/auth/tomcat_keystore
+# Client certificate password for the validation
+validation.service.ssl.key-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
+# Truststore password for the validation
+validation.service.ssl.trust-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
+# Amount of time that the client should wait in milliseconds before request failing
+validation.service.timeout-in-milliseconds=3000
+# List of aai node types that should be send to the validation microservice
+validation.service.node-types=generic-vnf,lag-interface,l-interface,logical-link,newvce,nos-server,p-interface,pnf,pserver,vce,vlan,vnfc,vpls-pe,vserver
+# List of X-FromAppId regexes seperated by comma to ignore the pre validation for
+# Note: please don't add any client id here as this is only for testing tools such as robot
+validation.service.exclusion-regexes=
diff --git a/aai-resources/src/main/resources/cadi.properties b/aai-resources/src/main/resources/cadi.properties
index 269610f..24d46d5 100644
--- a/aai-resources/src/main/resources/cadi.properties
+++ b/aai-resources/src/main/resources/cadi.properties
@@ -1,6 +1,6 @@
cadi_loglevel=INFO
-cadi_prop_files=aai-resources/src/main/resources/aaf/org.osaaf.location.props:aai-resources/src/main/resources/aaf/org.onap.aai.props
+cadi_prop_files=aai-resources/src/main/resources/aaf/onap/org.osaaf.location.props:aai-resources/src/main/resources/aaf/onap/org.onap.aai.props
# OAuth2
aaf_oauth2_token_url=https://AAF_LOCATE_URL/AAF_NS.token:2.0/token
diff --git a/aai-resources/src/main/resources/etc/appprops/aaiconfig.properties b/aai-resources/src/main/resources/etc/appprops/aaiconfig.properties
index d1aace6..f53fca0 100644
--- a/aai-resources/src/main/resources/etc/appprops/aaiconfig.properties
+++ b/aai-resources/src/main/resources/etc/appprops/aaiconfig.properties
@@ -45,7 +45,7 @@ aai.tools.username=AAI
aai.tools.password=AAI
aai.server.url.base=https://localhost:8443/aai/
-aai.server.url=https://localhost:8443/aai/v15/
+aai.server.url=https://localhost:8443/aai/v19/
aai.global.callback.url=https://localhost:8443/aai/
aai.truststore.filename=aai_keystore
@@ -53,18 +53,18 @@ aai.truststore.passwd.x=OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0
aai.keystore.filename=aai-client-cert.p12
aai.keystore.passwd.x=
-aai.notification.current.version=v15
+aai.notification.current.version=v19
aai.notificationEvent.default.status=UNPROCESSED
aai.notificationEvent.default.eventType=AAI-EVENT
aai.notificationEvent.default.domain=devINT1
aai.notificationEvent.default.sourceName=aai
aai.notificationEvent.default.sequenceNumber=0
aai.notificationEvent.default.severity=NORMAL
-aai.notificationEvent.default.version=v15
+aai.notificationEvent.default.version=v19
# This one lets us enable/disable resource-version checking on updates/deletes
aai.resourceversion.enableflag=true
aai.logging.maxStackTraceEntries=10
-aai.default.api.version=v15
+aai.default.api.version=v19
# Used by Model-processing code
aai.model.delete.sleep.per.vtx.msec=500
@@ -96,7 +96,7 @@ aai.jms.enable=false
aai.crud.timeoutenabled=true
#timeout app specific -1 to bypass for that app id, a whole number to override the timeout with that value (in ms)
-aai.crud.timeout.appspecific=JUNITTESTAPP1,1|JUNITTESTAPP2,-1|DCAE-CCS,-1|DCAES,-1|AAIRctFeed,-1|NewvceCreator,-1|IANewvceCreator,-1|AAI-CSIOVALS,-1
+aai.crud.timeout.appspecific=JUNITTESTAPP1,1|JUNITTESTAPP2,-1|DCAE-CCS,-1|DCAES,-1|AAIRctFeed,-1|NewvceCreator,-1|IANewvceCreator,-1|AAI-CSIOVALS,-1|AAI-SAREA,-1
#default timeout limit added for crud if not overridden (in ms)
aai.crud.timeoutlimit=100000
@@ -108,8 +108,11 @@ aai.bulkconsumer.payloadlimit=30
#aai.bulkconsumer.payloadoverride=E6F04B93462CB5B0EDF41C05A9DDF5C3FE59748F
aai.bulkconsumer.payloadoverride=false
-aai.rest.getall.depthparam=asofijaosjf-oijfadao-43jj-a508-8539cd36ecda
-aai.resourceversion.disabled.uuid=ajifsjisajfiasjf-oijfadao-43jj-a508-8539cd36ecda
+aai.rest.getall.depthparam=5807c3c3-92cd-44d7-a508-8539cd36ecda
+#data import task
+aai.dataimport.enable=true
+aai.dataimport.input.location=/etc/scriptdata/addmanualdata/tenant_isolation
+aai.resourceversion.disabled.uuid=38cf3090-6a0c-4e9d-8142-4332a7352846
aai.use.realtime=true
@@ -118,8 +121,38 @@ aai.resource.formatter.threshold=10
# Indicating whether or not to log the implicit delete objects
# Set this property to true if you want to log implicit delete objects
-aai.implied.delete.log.enabled=true
+aai.implied.delete.log.enabled=false
# Specifies how much upper bound the deletable objects should you log
# If this property is not specified it will log everything
# Uncomment it and specify an upper limit if you only want to log up to a certain deletes
#aai.implied.delete.log.limit=10000
+
+#################################################################################
+#
+# aai.implied.delete.whitelist.< X-FromAppId HTTP Header in lowercase >=<List of objects comma seperated in single quotes>
+#
+# Examples:
+#
+# aai.implied.delete.whitelist.so='vserver'
+#
+# Above example, if an HTTP Header X-FromAppId with value SO or So or sO or so
+# made a PUT request with vserver and set the children as empty in payload
+# Then they would be allowed to do so
+# For any other objects SO would not be able to delete children
+# it would fail with an error
+#
+#################################################################################
+# aai.implied.delete.whitelist.sdc=*
+#
+# Above example, if an HTTP header X-FromAppId with value sdc, case insensitive,
+# they are able to implicitly delete any children object on PUT
+#
+#################################################################################
+# aai.implied.delete.whitelist.idf='vserver','vce'
+#
+# Above example, if an HTTP header X-FromAppId with value idf, case insensitive,
+# they are able to implicitly delete on children of vce and vserver on PUT
+#
+#################################################################################
+aai.implied.delete.whitelist.sdnc='vce'
+aai.implied.delete.whitelist.ro='vserver'
diff --git a/aai-resources/src/main/resources/etc/appprops/datatoolscrons.properties b/aai-resources/src/main/resources/etc/appprops/datatoolscrons.properties
new file mode 100644
index 0000000..a4e226e
--- /dev/null
+++ b/aai-resources/src/main/resources/etc/appprops/datatoolscrons.properties
@@ -0,0 +1,8 @@
+#file feed cron expressions
+#please note these must be in Quartz cron syntax
+#column key: seconds minutes hours dayOfMonth month dayOfWeek
+#note: dayOfWeek is optional, the rest are mandatory
+#for more information refer to http://www.quartz-scheduler.org/documentation/quartz-2.x/tutorials/crontrigger.html
+#this site can generate new expressions for you: http://www.cronmaker.com/
+#BUT you must omit the last (seventh) column when you copy its output (spring expects exactly 6 fields and doesn't allow the seventh optional one)
+dataimporttask.cron=0 02 5 * * ?
diff --git a/aai-resources/src/main/resources/etc/appprops/delta-event-publisher.properties b/aai-resources/src/main/resources/etc/appprops/delta-event-publisher.properties
new file mode 100644
index 0000000..1e425a1
--- /dev/null
+++ b/aai-resources/src/main/resources/etc/appprops/delta-event-publisher.properties
@@ -0,0 +1,4 @@
+topic=AAI-DELTA-EVENT
+partition=AAI
+maxBatchSize=100
+maxAgeMs=250
diff --git a/aai-resources/src/main/resources/etc/appprops/error.properties b/aai-resources/src/main/resources/etc/appprops/error.properties
index 30b248b..b2dc448 100644
--- a/aai-resources/src/main/resources/etc/appprops/error.properties
+++ b/aai-resources/src/main/resources/etc/appprops/error.properties
@@ -3,181 +3,187 @@
#Key=Disposition:Category:Severity:Error Code:HTTP ResponseCode:RESTError Code:Error Message
#------------------------------------------------------------------------------- ----------
# testing code, please don't change unless error utility source code changes
-AAI_TESTING=5:2:WARN:0000:400:0001:Error code for testing
+AAI_TESTING=5:2:WARN:0000:400:0001:Error code for testing:0
# General success
-AAI_0000=0:0:INFO:0000:200:0000:Success
+AAI_0000=0:0:INFO:0000:200:0000:Success:0
# health check success
-AAI_0001=0:0:INFO:0001:200:0001:Success X-FromAppId=%1 X-TransactionId=%2
-AAI_0002=0:0:INFO:0002:200:0001:Successful health check
+AAI_0001=0:0:INFO:0001:200:0001:Success X-FromAppId=%1 X-TransactionId=%2:0
+AAI_0002=0:0:INFO:0002:200:0001:Successful health check:0
# Success with additional info
-AAI_0003=0:3:INFO:0003:202:0003:Success with additional info performing %1 on %2. Added %3 with key %4
-AAI_0004=0:3:INFO:0004:202:0003:Added prerequisite object to db
+AAI_0003=0:3:INFO:0003:202:0003:Success with additional info performing %1 on %2. Added %3 with key %4:0
+AAI_0004=0:3:INFO:0004:202:0003:Added prerequisite object to db:0
#--- aairest: 3000-3299
# svc errors
-AAI_3000=5:2:INFO:3000:400:3000:Invalid input performing %1 on %2
-AAI_3001=5:6:INFO:3001:404:3001:Resource not found for %1 using id %2
-AAI_3002=5:1:WARN:3002:400:3002:Error writing output performing %1 on %2
-AAI_3003=5:1:WARN:3003:400:3003:Failed to make edge to missing target node of type %3 with keys %4 performing %1 on %2
-AAI_3005=5:6:WARN:3005:404:3001:Node cannot be directly accessed for read, must be accessed via ancestor(s)
-AAI_3006=5:6:WARN:3006:404:3001:Node cannot be directly accessed for write, must be accessed via ancestor(s)
-AAI_3007=5:6:INFO:3007:410:3007:This version (%1) of the API is retired, please migrate to %2
-AAI_3008=5:6:WARN:3008:400:3008:URI is not encoded in UTF-8
-AAI_3009=5:6:WARN:3009:400:3002:Malformed URL
-AAI_3010=5:6:WARN:3010:400:3002:Cannot write via this URL
-AAI_3011=5:6:WARN:3011:400:3000:Unknown XML namespace used in payload
-AAI_3012=5:6:WARN:3012:400:3012:Unrecognized AAI function
-AAI_3013=5:6:WARN:3013:400:3013:Query payload missing required parameters %1
-AAI_3014=5:6:WARN:3014:400:3014:Query payload is invalid %1
-AAI_3015=5:6:INFO:3015:410:3015:The %1 capability is retired, please contact the A&AI SE team to identify a replacement query
-AAI_3016=5:6:INFO:3007:400:3016:Request uri is not valid, please check the version %1
-AAI_3017=5:6:INFO:3007:400:3016:Request uri is not valid, please check the uri %1
-AAI_3025=5:4:FATAL:3025:500:3025:Error connecting to Schema Service
-AAI_3026=5:4:FATAL:3026:500:3026:Error reading OXM from Schema Service
-AAI_3027=5:4:FATAL:3026:500:3026:Error reading EdgeRules from Schema Service
+AAI_3000=5:2:INFO:3000:400:3000:Invalid input performing %1 on %2:300
+AAI_3001=5:6:INFO:3001:404:3001:Resource not found for %1 using id %2:300
+AAI_3002=5:1:WARN:3002:400:3002:Error writing output performing %1 on %2:300
+AAI_3003=5:1:WARN:3003:400:3003:Failed to make edge to missing target node of type %3 with keys %4 performing %1 on %2:400
+AAI_3005=5:6:WARN:3005:404:3001:Node cannot be directly accessed for read, must be accessed via ancestor(s):100
+AAI_3006=5:6:WARN:3006:404:3001:Node cannot be directly accessed for write, must be accessed via ancestor(s):100
+AAI_3007=5:6:INFO:3007:410:3007:This version (%1) of the API is retired, please migrate to %2:500
+AAI_3008=5:6:ERROR:3008:400:3008:URI is not encoded in UTF-8:300
+AAI_3009=5:6:WARN:3009:400:3002:Malformed URL:300
+AAI_3010=5:6:WARN:3010:400:3002:Cannot write via this URL:100
+AAI_3011=5:6:WARN:3011:400:3000:Unknown XML namespace used in payload:300
+AAI_3012=5:6:WARN:3012:400:3012:Unrecognized AAI function:300
+AAI_3013=5:6:WARN:3013:400:3013:Query payload missing required parameters %1:300
+AAI_3014=5:6:WARN:3014:400:3014:Query payload is invalid %1:300
+AAI_3015=5:6:INFO:3015:410:3015:The %1 capability is retired, please contact the A&AI SE team to identify a replacement query:500
+AAI_3016=5:6:INFO:3007:400:3016:Request uri is not valid, please check the version %1:500
+AAI_3017=5:6:INFO:3007:400:3016:Request uri is not valid, please check the uri %1:500
+AAI_3025=5:4:FATAL:3025:500:3025:Error connecting to Schema Service:400
+AAI_3026=5:4:FATAL:3026:500:3026:Error reading OXM from Schema Service:400
+AAI_3027=5:4:FATAL:3026:500:3026:Error reading EdgeRules from Schema Service:400
# pol errors
-AAI_3100=5:1:WARN:3100:400:3100:Unsupported operation %1
-AAI_3101=5:1:WARN:3101:403:3101:Attempt by client %1 to execute API %2
-AAI_3102=5:1:WARN:3102:400:3102:Error parsing input performing %1 on %2
-AAI_3300=5:1:WARN:3300:403:3300:Unauthorized
-AAI_3301=5:1:WARN:3301:401:3301:Stale credentials
-AAI_3302=5:1:WARN:3302:401:3301:Not authenticated
-AAI_3303=5:1:WARN:3303:403:3300:Too many objects would be returned by this request, please refine your request and retry
+AAI_3100=5:1:WARN:3100:400:3100:Unsupported operation %1:300
+AAI_3101=5:1:WARN:3101:403:3101:Attempt by client %1 to execute API %2:100
+AAI_3102=5:1:WARN:3102:400:3102:Error parsing input performing %1 on %2:300
+AAI_3300=5:1:WARN:3300:403:3300:Unauthorized:100
+AAI_3301=5:1:WARN:3301:401:3301:Stale credentials:100
+AAI_3302=5:1:WARN:3302:401:3301:Not authenticated:100
+AAI_3303=5:1:WARN:3303:403:3300:Too many objects would be returned by this request, please refine your request and retry:500
#--- aaigen: 4000-4099
-AAI_4000=5:4:ERROR:4000:500:3002:Internal Error
-AAI_4001=5:4:FATAL:4001:500:3002:Configuration file not found
-AAI_4002=5:4:FATAL:4002:500:3002:Error reading Configuration file
-AAI_4003=5:4:ERROR:4003:500:3002:Error writing to log file
-AAI_4004=5:4:FATAL:4004:500:3002:Error reading/parsing the error properties file
-AAI_4005=5:4:FATAL:4005:500:3002:Missing or invalid configuration parameter
-AAI_4006=5:4:FATAL:4006:500:3002:Unexpected error in service
-AAI_4007=5:4:WARN:4007:500:3102:Input parsing error
-AAI_4008=5:4:ERROR:4008:500:3002:Output parsing error
-AAI_4009=4:0:WARN:4009:400:3000:Invalid X-FromAppId in header
-AAI_4010=4:0:WARN:4010:400:3000:Invalid X-TransactionId in header
-AAI_4011=5:4:ERROR:4011:500:3002:Missing data for REST error response
-AAI_4014=4:0:WARN:4014:400:3000:Invalid Accept header
-AAI_4015=4:0:WARN:4015:400:3000:You must provide at least one indexed property
-AAI_4016=4:0:WARN:4016:400:3000:The depth parameter must be a number or the string "all"
-AAI_4017=5:2:INFO:4017:400:3000:Could not set property
-AAI_4018=5:2:WARN:4018:400:3000:Unable to convert the string to integer
+AAI_4000=5:4:ERROR:4000:500:3002:Internal Error:900
+AAI_4001=5:4:FATAL:4001:500:3002:Configuration file not found:500
+AAI_4002=5:4:FATAL:4002:500:3002:Error reading Configuration file:500
+AAI_4003=5:4:ERROR:4003:500:3002:Error writing to log file:500
+AAI_4004=5:4:FATAL:4004:500:3002:Error reading/parsing the error properties file:500
+AAI_4005=5:4:FATAL:4005:500:3002:Missing or invalid configuration parameter:500
+AAI_4006=5:4:FATAL:4006:500:3002:Unexpected error in service:500
+AAI_4007=5:4:WARN:4007:500:3102:Input parsing error:500
+AAI_4008=5:4:ERROR:4008:500:3002:Output parsing error:500
+AAI_4009=4:0:WARN:4009:400:3000:Invalid X-FromAppId in header:300
+AAI_4010=4:0:WARN:4010:400:3000:Invalid X-TransactionId in header:300
+AAI_4011=5:4:ERROR:4011:500:3002:Missing data for REST error response:500
+AAI_4014=4:0:WARN:4014:400:3000:Invalid Accept header:300
+AAI_4015=4:0:WARN:4015:400:3000:You must provide at least one indexed property:400
+AAI_4016=4:0:WARN:4016:400:3000:The depth parameter must be a number or the string "all":300
+AAI_4017=5:2:INFO:4017:400:3000:Could not set property:300
+AAI_4018=5:2:WARN:4018:400:3000:Unable to convert the string to integer:500
+AAI_4019=4:0:WARN:4019:400:3000:Request failed due to violations:400
+AAI_4020=5:4:ERROR:4020:500:3000:Unknown exception to calling validation service:500
+AAI_4021=5:4:FATAL:3025:500:4021:Error connecting to Validation Service:400
+
#--- aaidbmap: 5102-5199
-AAI_5102=5:4:FATAL:5102:500:3002:Graph database is null after open
-AAI_5105=5:4:ERROR:5105:500:3002:Unexpected error reading/updating database
-AAI_5106=5:4:WARN:5106:404:3001:Node not found
-AAI_5107=5:2:WARN:5107:400:3000:Required information missing
-AAI_5108=5:2:WARN:5108:200:0:Unexpected information in request being ignored
+AAI_5102=5:4:FATAL:5102:500:3002:Graph database is null after open:400
+AAI_5105=5:4:ERROR:5105:500:3002:Unexpected error reading/updating database:300
+AAI_5106=5:4:WARN:5106:404:3001:Node not found:300
+AAI_5107=5:2:WARN:5107:400:3000:Required information missing:300
+AAI_5108=5:2:WARN:5108:200:0:Unexpected information in request being ignored:300
#--- aaidbgen: 6101-6199
-AAI_6101=5:4:ERROR:6101:500:3002:null JanusGraph object passed
-AAI_6102=5:4:WARN:6102:400:3000:Passed-in property is not valid for this nodeType
-AAI_6103=5:4:WARN:6103:400:3000:Required Node-property not found in input data
-AAI_6104=5:4:WARN:6104:400:3000:Required Node-property was passed with no data
-AAI_6105=5:4:WARN:6105:400:3000:Node-Key-Property not defined in DbMaps
-AAI_6106=5:4:WARN:6106:400:3000:Passed-in property is not valid for this edgeType
-AAI_6107=5:4:WARN:6107:400:3000:Required Edge-property not found in input data
-AAI_6108=5:4:WARN:6108:400:3000:Required Edge-property was passed with no data
-AAI_6109=5:4:WARN:6109:400:3000:Bad dependent Node value
-AAI_6110=5:4:ERROR:6110:400:3100:Node cannot be deleted
-AAI_6111=5:4:WARN:6111:400:3000:JSON processing error
-AAI_6112=5:4:ERROR:6112:400:3000:More than one node found by getUniqueNode()
-AAI_6114=5:4:INFO:6114:404:3001:Node Not Found
-AAI_6115=5:4:ERROR:6115:400:3000:Unrecognized NodeType
-AAI_6116=5:4:ERROR:6116:400:3000:Unrecognized Property
-AAI_6117=5:4:ERROR:6117:400:3000:Uniqueness constraint violated
-AAI_6118=5:4:WARN:6118:400:3000:Required Field not passed.
-AAI_6120=5:4:WARN:6120:400:3000:Bad Parameter Passed
-AAI_6121=5:4:ERROR:6121:400:3000:Problem with internal AAI reference data
-AAI_6122=5:4:ERROR:6122:400:3000:Data Set not complete in DB for this request
-AAI_6123=5:4:ERROR:6123:500:3000:Bad Data found by DataGrooming Tool - Investigate
-AAI_6124=5:4:ERROR:6124:500:3000:File read/write error
-AAI_6125=5:4:WARN:6125:500:3000:Problem Pulling Data Set
-AAI_6126=5:4:ERROR:6126:400:3000:Edge cannot be deleted
-AAI_6127=5:4:INFO:6127:404:3001:Edge Not Found
-AAI_6128=5:4:INFO:6128:500:3000:Unexpected error
-AAI_6129=5:4:INFO:6129:404:3003:Error making edge to target node
-AAI_6130=5:4:WARN:6130:412:3000:Precondition Required
-AAI_6131=5:4:WARN:6131:412:3000:Precondition Failed
-AAI_6132=5:4:WARN:6132:400:3000:Bad Model Definition
-AAI_6133=5:4:WARN:6133:400:3000:Bad Named Query Definition
-AAI_6134=5:4:ERROR:6134:500:6134:Could not persist transaction to storage back end. Exhausted retry amount
-AAI_6135=5:4:WARN:6135:412:3000:Resource version specified on create
-AAI_6136=5:4:ERROR:6136:400:3000:Object cannot hold multiple items
-AAI_6137=5:4:ERROR:6137:400:3000:Cannot perform writes on multiple vertices
-AAI_6138=5:4:ERROR:6138:400:3000:Cannot delete multiple vertices
-AAI_6139=5:4:ERROR:6139:404:3000:Attempted to add edge to vertex that does not exist
-AAI_6140=5:4:ERROR:6140:400:3000:Edge multiplicity violated
-AAI_6141=5:4:WARN:6141:400:3000:Please Refine Query
-AAI_6142=5:4:INFO:6142:400:3000:Retrying transaction
-AAI_6143=5:4:INFO:6143:400:3000:Ghost vertex found
-AAI_6144=5:4:WARN:6144:400:3000:Cycle found in graph
-AAI_6145=5:4:ERROR:6145:400:3000:Cannot create a nested/containment edge via relationship
-AAI_6146=5:4:ERROR:6146:400:3000:Ambiguous identity map found, use a URI instead
-AAI_6147=5:4:ERROR:6147:400:3000:Payload Limit Reached, reduce payload
-AAI_6148=5:4:ERROR:6148:400:3000:More than one node found %1
-AAI_6149=5:4:ERROR:6149:404:3000:No relationship was found
+AAI_6101=5:4:ERROR:6101:500:3002:null JanusGraph object passed:400
+AAI_6102=5:4:WARN:6102:400:3000:Passed-in property is not valid for this nodeType:400
+AAI_6103=5:4:WARN:6103:400:3000:Required Node-property not found in input data:400
+AAI_6104=5:4:WARN:6104:400:3000:Required Node-property was passed with no data:400
+AAI_6105=5:4:WARN:6105:400:3000:Node-Key-Property not defined in DbMaps:400
+AAI_6106=5:4:WARN:6106:400:3000:Passed-in property is not valid for this edgeType:400
+AAI_6107=5:4:WARN:6107:400:3000:Required Edge-property not found in input data:400
+AAI_6108=5:4:WARN:6108:400:3000:Required Edge-property was passed with no data:400
+AAI_6109=5:4:WARN:6109:400:3000:Bad dependent Node value:400
+AAI_6110=5:4:ERROR:6110:400:3100:Node cannot be deleted:500
+AAI_6111=5:4:WARN:6111:400:3000:JSON processing error:300
+AAI_6112=5:4:ERROR:6112:400:3000:More than one node found by getUniqueNode():400
+AAI_6114=5:4:INFO:6114:404:3001:Node Not Found:300
+AAI_6115=5:4:ERROR:6115:400:3000:Unrecognized NodeType:400
+AAI_6116=5:4:ERROR:6116:400:3000:Unrecognized Property:400
+AAI_6117=5:4:ERROR:6117:400:3000:Uniqueness constraint violated:400
+AAI_6118=5:4:WARN:6118:400:3000:Required Field not passed.:400
+AAI_6120=5:4:WARN:6120:400:3000:Bad Parameter Passed:300
+AAI_6121=5:4:ERROR:6121:400:3000:Problem with internal AAI reference data:400
+AAI_6122=5:4:ERROR:6122:400:3000:Data Set not complete in DB for this request:400
+AAI_6123=5:4:ERROR:6123:500:3000:Bad Data found by DataGrooming Tool - Investigate:300
+AAI_6124=5:4:ERROR:6124:500:3000:File read/write error:500
+AAI_6125=5:4:WARN:6125:500:3000:Problem Pulling Data Set:500
+AAI_6126=5:4:ERROR:6126:400:3000:Edge cannot be deleted:400
+AAI_6127=5:4:INFO:6127:404:3001:Edge Not Found:400
+AAI_6128=5:4:INFO:6128:500:3000:Unexpected error:900
+AAI_6129=5:4:INFO:6129:404:3003:Error making edge to target node:400
+AAI_6130=5:4:WARN:6130:412:3000:Precondition Required:300
+AAI_6131=5:4:WARN:6131:412:3000:Precondition Failed:300
+AAI_6132=5:4:WARN:6132:400:3000:Bad Model Definition:500
+AAI_6133=5:4:WARN:6133:400:3000:Bad Named Query Definition:500
+AAI_6134=5:4:ERROR:6134:500:6134:Could not persist transaction to storage back end. Exhausted retry amount:500
+AAI_6135=5:4:WARN:6135:412:3000:Resource version specified on create:300
+AAI_6136=5:4:ERROR:6136:400:3000:Object cannot hold multiple items:400
+AAI_6137=5:4:ERROR:6137:400:3000:Cannot perform writes on multiple vertices:400
+AAI_6138=5:4:ERROR:6138:400:3000:Cannot delete multiple vertices:400
+AAI_6139=5:4:ERROR:6139:404:3000:Attempted to add edge to vertex that does not exist:400
+AAI_6140=5:4:ERROR:6140:400:3000:Edge multiplicity violated:400
+AAI_6141=5:4:WARN:6141:400:3000:Please Refine Query:400
+AAI_6142=5:4:INFO:6142:400:3000:Retrying transaction:900
+AAI_6143=5:4:INFO:6143:400:3000:Ghost vertex found:400
+AAI_6144=5:4:WARN:6144:400:3000:Cycle found in graph:400
+AAI_6145=5:4:ERROR:6145:400:3000:Cannot create a nested/containment edge via relationship:400
+AAI_6146=5:4:ERROR:6146:400:3000:Ambiguous identity map found, use a URI instead:300
+AAI_6147=5:4:ERROR:6147:400:3000:Payload Limit Reached, reduce payload:300
+AAI_6148=5:4:ERROR:6148:400:3000:More than one node found %1:300
+AAI_6149=5:4:ERROR:6149:404:3000:No relationship was found:300
#--- aaicsvp: 7101-7199
-AAI_7101=5:4:ERROR:7101:500:3002:Unexpected error in CSV file processing
-AAI_7102=5:4:ERROR:7102:500:3002:Error in cleanup temporary directory
-#AAI_7103=4:2:ERROR:7103:500:3002:Unsupported user
-AAI_7104=5:4:ERROR:7104:500:3002:Failed to create directory
-AAI_7105=5:4:ERROR:7105:500:3002:Temporary directory exists
-AAI_7106=5:4:ERROR:7106:500:3002:Cannot delete
-AAI_7107=5:4:ERROR:7107:500:3002:Input file does not exist
-AAI_7108=5:4:ERROR:7108:500:3002:Output file does not exist
-AAI_7109=5:4:ERROR:7109:500:3002:Error closing file
-AAI_7110=5:4:ERROR:7110:500:3002:Error loading/reading properties file
-AAI_7111=5:4:ERROR:7111:500:3002:Error executing shell script
-AAI_7112=5:4:ERROR:7112:500:3002:Error creating output file
-AAI_7113=5:4:ERROR:7113:500:3002:Trailer record error
-AAI_7114=5:4:ERROR:7114:500:3002:Input file error
-AAI_7115=5:4:ERROR:7115:500:3002:Unexpected error
-AAI_7116=5:4:ERROR:7116:500:3002:Request error
-AAI_7117=5:4:ERROR:7117:500:3002:Error in get http client object
-AAI_7118=5:4:ERROR:7118:500:3002:Script Error
-AAI_7119=5:4:ERROR:7119:500:3002:Unknown host
+AAI_7101=5:4:ERROR:7101:500:3002:Unexpected error in CSV file processing:900
+AAI_7102=5:4:ERROR:7102:500:3002:Error in cleanup temporary directory:500
+#AAI_7103=4:2:ERROR:7103:500:3002:Unsupported user:100
+AAI_7104=5:4:ERROR:7104:500:3002:Failed to create directory:500
+AAI_7105=5:4:ERROR:7105:500:3002:Temporary directory exists:500
+AAI_7106=5:4:ERROR:7106:500:3002:Cannot delete:500
+AAI_7107=5:4:ERROR:7107:500:3002:Input file does not exist:500
+AAI_7108=5:4:ERROR:7108:500:3002:Output file does not exist:500
+AAI_7109=5:4:ERROR:7109:500:3002:Error closing file:500
+AAI_7110=5:4:ERROR:7110:500:3002:Error loading/reading properties file:500
+AAI_7111=5:4:ERROR:7111:500:3002:Error executing shell script:900
+AAI_7112=5:4:ERROR:7112:500:3002:Error creating output file:500
+AAI_7113=5:4:ERROR:7113:500:3002:Trailer record error:300
+AAI_7114=5:4:ERROR:7114:500:3002:Input file error:300
+AAI_7115=5:4:ERROR:7115:500:3002:Unexpected error:900
+AAI_7116=5:4:ERROR:7116:500:3002:Request error:900
+AAI_7117=5:4:ERROR:7117:500:3002:Error in get http client object:500
+AAI_7118=5:4:ERROR:7118:500:3002:Script Error:900
+AAI_7119=5:4:ERROR:7119:500:3002:Unknown host:900
#--- aaisdnc: 7201-7299
-AAI_7202=5:4:ERROR:7202:500:3002:Error getting connection to odl
-#AAI_7206=5:4:ERROR:7206:500:3002:Invalid data returned from ODL
+AAI_7202=5:4:ERROR:7202:500:3002:Error getting connection to odl:200
+#AAI_7206=5:4:ERROR:7206:500:3002:Invalid data returned from ODL:300
-#--- NotificationEvent, using UEB space
-AAI_7350=5:4:ERROR:7305:500:3002:Notification event creation failed
+#--- DMaaP related errors
+AAI_7304=4:5:ERROR:7304:500:3002:Error reaching DMaaP to send event:200
+AAI_7350=5:4:ERROR:7305:500:3002:Notification event creation failed:500
#--- aairestctlr: 7401-7499
-AAI_7401=5:4:ERROR:7401:500:3002:Error connecting to AAI REST API
-AAI_7402=5:4:ERROR:7402:500:3002:Unexpected error
-AAI_7403=5:4:WARN:7403:400:3001:Request error
-AAI_7404=5:4:INFO:7404:404:3001:Node not found
-AAI_7405=5:4:WARN:7405:200:0:UUID not formatted correctly, generating UUID
-AAI_7406=5:4:ERROR:7406:400:7406:Request Timed Out
+AAI_7401=5:4:ERROR:7401:500:3002:Error connecting to AAI REST API:200
+AAI_7402=5:4:ERROR:7402:500:3002:Unexpected error:900
+AAI_7403=5:4:WARN:7403:400:3001:Request error:900
+AAI_7404=5:4:INFO:7404:404:3001:Node not found:300
+AAI_7405=5:4:WARN:7405:200:0:UUID not formatted correctly, generating UUID:300
+AAI_7406=5:4:ERROR:7406:400:7406:Request Timed Out:200
#--- aaicsiovals: 7501-7599
-#AAI_7501=5:4:WARN:7501:500:3002:Error getting connection to CSI-OVALS
-AAI_7502=5:4:WARN:7502:500:3002:Bad parameter when trying to build request for CSI-OVALS
-AAI_7503=5:4:WARN:7503:500:3002:Error returned by CSI-OVALS
+#AAI_7501=5:4:WARN:7501:500:3002:Error getting connection to CSI-OVALS:200
+AAI_7502=5:4:WARN:7502:500:3002:Bad parameter when trying to build request for CSI-OVALS:300
+AAI_7503=5:4:WARN:7503:500:3002:Error returned by CSI-OVALS:500
#--- aaiauth: 9101-9199
-AAI_9101=5:0:WARN:9101:403:3300:User is not authorized to perform function
-#AAI_9102=5:0:WARN:9102:401:3301:Refresh credentials from source
-#AAI_9103=5:0:WARN:9103:403:3300:User not found
-#AAI_9104=5:0:WARN:9104:401:3302:Authentication error
-#AAI_9105=5:0:WARN:9105:403:3300:Authorization error
-#AAI_9106=5:0:WARN:9106:403:3300:Invalid AppId
-#AAI_9107=5:0:WARN:9107:403:3300:No Username in Request
-AAI_9107=5:0:WARN:9107:403:3300:SSL is not provided in request, please contact admin
-AAI_9108=5:0:WARN:9107:403:3300:Basic auth credentials is not provided in the request
+AAI_9101=5:0:WARN:9101:403:3300:User is not authorized to perform function:100
+#AAI_9102=5:0:WARN:9102:401:3301:Refresh credentials from source:100
+#AAI_9103=5:0:WARN:9103:403:3300:User not found:100
+#AAI_9104=5:0:WARN:9104:401:3302:Authentication error:100
+#AAI_9105=5:0:WARN:9105:403:3300:Authorization error:100
+#AAI_9106=5:0:WARN:9106:403:3300:Invalid AppId:300
+#AAI_9107=5:0:WARN:9107:403:3300:No Username in Request:100
+AAI_9107=5:0:WARN:9107:403:3300:SSL is not provided in request, please contact admin:100
+AAI_9108=5:0:WARN:9107:403:3300:Basic auth credentials is not provided in the request:100
+AAI_9109=5:0:WARN:9109:403:3300:User is not allowed to perform implicit delete:500
#--- aaiinstar: 9201-9299
-#AAI_9201=5:4:ERROR:9201:500:3002:Unable to send notification
-AAI_9202=5:4:ERROR:9202:500:3002:Unable to start a thread
+#AAI_9201=5:4:ERROR:9201:500:3002:Unable to send notification:200
+AAI_9202=5:4:ERROR:9202:500:3002:Unable to start a thread:500
#--- GRM DME2: 9501-9599
-AAI_9501=5:4:WARN:9501:500:3002:Unable to register with GRM retrying
-AAI_9502=5:4:ERROR:9502:500:3002:Unable to register with GRM after exhausting all retries
-AAI_9503=5:4:WARN:9503:500:3002:Unable to successfully unpublish with GRM, recommend manual cleanup but not necessary
+AAI_9501=5:4:WARN:9501:500:3002:Unable to register with GRM retrying:200
+AAI_9502=5:4:ERROR:9502:500:3002:Unable to register with GRM after exhausting all retries:200
+AAI_9503=5:4:WARN:9503:500:3002:Unable to successfully unpublish with GRM, recommend manual cleanup but not necessary:200
diff --git a/aai-resources/src/main/resources/etc/appprops/janusgraph-cached.properties b/aai-resources/src/main/resources/etc/appprops/janusgraph-cached.properties
index c90816d..a0926e7 100644
--- a/aai-resources/src/main/resources/etc/appprops/janusgraph-cached.properties
+++ b/aai-resources/src/main/resources/etc/appprops/janusgraph-cached.properties
@@ -18,6 +18,7 @@
# ============LICENSE_END=========================================================
query.fast-property=true
+query.smart-limit=false
# the following parameters are not reloaded automatically and require a manual bounce
storage.backend=inmemory
storage.hostname=localhost
@@ -33,4 +34,4 @@ cache.db-cache-time = 180000
cache.db-cache-size = 0.3
#load graphson file on startup
-load.snapshot.file=false \ No newline at end of file
+load.snapshot.file=false
diff --git a/aai-resources/src/main/resources/etc/appprops/janusgraph-realtime.properties b/aai-resources/src/main/resources/etc/appprops/janusgraph-realtime.properties
index 36256c9..3f00b55 100644
--- a/aai-resources/src/main/resources/etc/appprops/janusgraph-realtime.properties
+++ b/aai-resources/src/main/resources/etc/appprops/janusgraph-realtime.properties
@@ -18,6 +18,7 @@
# ============LICENSE_END=========================================================
query.fast-property=true
+query.smart-limit=false
# the following parameters are not reloaded automatically and require a manual bounce
storage.backend=inmemory
storage.hostname=localhost
@@ -30,4 +31,4 @@ storage.hbase.ext.zookeeper.znode.parent=/hbase-unsecure
cache.db-cache = false
#load graphson file on startup
-load.snapshot.file=false \ No newline at end of file
+load.snapshot.file=false
diff --git a/aai-resources/src/main/resources/logback.xml b/aai-resources/src/main/resources/logback.xml
index cb2f7e9..ee2c903 100644
--- a/aai-resources/src/main/resources/logback.xml
+++ b/aai-resources/src/main/resources/logback.xml
@@ -31,13 +31,29 @@
<property name="AJSC_HOME" value="${AJSC_HOME:-.}" />
<jmxConfigurator />
<property name="logDirectory" value="${AJSC_HOME}/logs" />
+ <!-- Old patterns
<property name="eelfLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%ecompServiceName|%X{partnerName}|%ecompStatusCode|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/>
<property name="eelfAuditLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%ecompServiceName|%X{partnerName}|%ecompStatusCode|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n|\r\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/>
<property name="eelfMetricLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%ecompServiceName|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%ecompStatusCode|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{targetVirtualEntity}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/>
<property name="eelfErrorLogPattern" value="%ecompStartTime|%X{requestId}|%-10t|%ecompServiceName|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%ecompErrorCategory|%ecompResponseCode|%ecompResponseDescription|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/>
<property name="eelfTransLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%ecompServiceName|%X{partnerName}|%ecompStatusCode|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{partnerName}:%m%n"/>
-
- <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
+ -->
+ <property name="p_tim" value="%d{&quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXX&quot;, UTC}"/>
+ <property name="p_lvl" value="%level"/>
+ <property name="p_log" value="%logger"/>
+ <property name="p_mdc" value="%replace(%replace(%replace(%mdc){'\t','\\\\t'}){'\n', '\\\\n'}){'\\|', '!'}"/>
+ <property name="p_msg" value="%replace(%replace(%msg){'\t', '\\\\t'}){'\n','\\\\n'}"/>
+ <property name="p_exc" value="%replace(%replace(%rootException){'\t', '\\\\t'}){'\n','\\\\n'}"/>
+ <property name="p_mak" value="%replace(%replace(%marker){'\t', '\\\\t'}){'\n','\\\\n'}"/>
+ <property name="p_thr" value="%thread"/>
+ <property name="pattern" value="%nopexception${p_tim}\t${p_thr}\t${p_lvl}\t${p_log}\t${p_mdc}\t${p_msg}\t${p_exc}\t${p_mak}\t%n"/>
+ <!-- Patterns from onap demo -->
+ <property name="errorPattern" value="%X{LogTimestamp}|%X{RequestID}|%thread|%replace(%X{ServiceName}){'\\|', '!'}|%X{PartnerName}|%X{TargetEntity}|%replace(%X{TargetServiceName}){'\\|', '!'}|%.-5level|%X{ErrorCode}|%X{ErrorDesc}|%msg%n" />
+ <property name="debugPattern" value="%X{LogTimestamp}|%X{RequestID}|%msg\t${p_mdc}\t${p_msg}\t${p_exc}\t${p_mak}\t|^%n" />
+ <property name="auditPattern" value="%X{EntryTimestamp}|%X{LogTimestamp}|%X{RequestID}|%X{ServiceInstanceID}|%thread||%replace(%X{ServiceName}){'\\|', '!'}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}||||${p_mak}|${p_mdc}|||%msg%n" />
+ <property name="metricPattern" value="%X{InvokeTimestamp}|%X{LogTimestamp}|%X{RequestID}|%X{ServiceInstanceID}|%thread||%replace(%X{ServiceName}){'\\|', '!'}|%X{PartnerName}|%X{TargetEntity}|%replace(%X{TargetServiceName}){'\\|', '!'}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}||||%X{TargetVirtualEntity}|${p_mak}|${p_mdc}|||%msg%n" />
+ <property name="transLogPattern" value="%X{LogTimestamp}|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{RequestID}|%X{ServiceInstanceID}|%-10t|%X{ServerFQDN}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%replace(%replace(%X{ResponseDesc}){'\\|', '!'}){'\r|\n', '^'}|%X{InstanceUUID}|%level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{clientIpAddress}||%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{PartnerName}:%m%n"/>
+ <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
@@ -64,71 +80,63 @@
<includeCallerData>true</includeCallerData>
<appender-ref ref="SANE" />
</appender>
-
- <appender name="METRIC"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <filter class="ch.qos.logback.classic.filter.LevelFilter">
- <level>INFO</level>
- <onMatch>ACCEPT</onMatch>
- <onMismatch>DENY</onMismatch>
- </filter>
+ <appender name="METRIC" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${logDirectory}/rest/metrics.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/rest/metrics.log.%d{yyyy-MM-dd}
- </fileNamePattern>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/rest/metrics.log.%d{yyyy-MM-dd}</fileNamePattern>
</rollingPolicy>
- <encoder class="org.onap.aai.logging.EcompEncoder">
- <pattern>${eelfMetricLogPattern}</pattern>
+ <encoder>
+ <pattern>${metricPattern}</pattern>
</encoder>
</appender>
+
<appender name="asyncMETRIC" class="ch.qos.logback.classic.AsyncAppender">
<queueSize>1000</queueSize>
<includeCallerData>true</includeCallerData>
- <appender-ref ref="METRIC" />
+ <appender-ref ref="METRIC"/>
</appender>
<appender name="DEBUG"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>DEBUG</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<file>${logDirectory}/rest/debug.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/rest/debug.log.%d{yyyy-MM-dd}
- </fileNamePattern>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/rest/debug.log.%d{yyyy-MM-dd}</fileNamePattern>
</rollingPolicy>
- <encoder class="org.onap.aai.logging.EcompEncoder">
- <pattern>${eelfLogPattern}</pattern>
+ <encoder>
+ <pattern>${debugPattern}</pattern>
</encoder>
</appender>
<appender name="asyncDEBUG" class="ch.qos.logback.classic.AsyncAppender">
<queueSize>1000</queueSize>
- <includeCallerData>true</includeCallerData>
<appender-ref ref="DEBUG" />
+ <includeCallerData>true</includeCallerData>
</appender>
-
<appender name="ERROR"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDirectory}/rest/error.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/rest/error.log.%d{yyyy-MM-dd}</fileNamePattern>
+ </rollingPolicy>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
- <file>${logDirectory}/rest/error.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${logDirectory}/rest/error.log.%d{yyyy-MM-dd}
- </fileNamePattern>
- </rollingPolicy>
- <encoder class="org.onap.aai.logging.EcompEncoder">
- <pattern>${eelfErrorLogPattern}</pattern>
+ <encoder>
+ <pattern>${errorPattern}</pattern>
</encoder>
</appender>
<appender name="asyncERROR" class="ch.qos.logback.classic.AsyncAppender">
<queueSize>1000</queueSize>
- <includeCallerData>true</includeCallerData>
- <appender-ref ref="ERROR" />
+ <appender-ref ref="ERROR"/>
</appender>
<appender name="AUDIT"
@@ -138,8 +146,8 @@
<fileNamePattern>${logDirectory}/rest/audit.log.%d{yyyy-MM-dd}
</fileNamePattern>
</rollingPolicy>
- <encoder class="org.onap.aai.logging.EcompEncoder">
- <pattern>${eelfAuditLogPattern}</pattern>
+ <encoder>
+ <pattern>${auditPattern}</pattern>
</encoder>
</appender>
@@ -161,8 +169,8 @@
<fileNamePattern>${logDirectory}/rest/translog.log.%d{yyyy-MM-dd}
</fileNamePattern>
</rollingPolicy>
- <encoder class="org.onap.aai.logging.EcompEncoder">
- <pattern>${eelfTransLogPattern}</pattern>
+ <encoder>
+ <pattern>${transLogPattern}</pattern>
</encoder>
</appender>
@@ -182,9 +190,10 @@
<fileNamePattern>${logDirectory}/dmaapAAIEventConsumer/error.log.%d{yyyy-MM-dd}
</fileNamePattern>
</rollingPolicy>
- <encoder class="org.onap.aai.logging.EcompEncoder">
- <pattern>${eelfErrorLogPattern}</pattern>
+ <encoder>
+ <pattern>${errorPattern}</pattern>
</encoder>
+
</appender>
<appender name="dmaapAAIEventConsumerDebug"
@@ -199,8 +208,8 @@
<fileNamePattern>${logDirectory}/dmaapAAIEventConsumer/debug.log.%d{yyyy-MM-dd}
</fileNamePattern>
</rollingPolicy>
- <encoder class="org.onap.aai.logging.EcompEncoder">
- <pattern>${eelfLogPattern}</pattern>
+ <encoder>
+ <pattern>${debugPattern}</pattern>
</encoder>
</appender>
<appender name="dmaapAAIEventConsumerInfo"
@@ -215,8 +224,8 @@
<fileNamePattern>${logDirectory}/dmaapAAIEventConsumer/dmaap-transaction.log.%d{yyyy-MM-dd}
</fileNamePattern>
</rollingPolicy>
- <encoder class="org.onap.aai.logging.EcompEncoder">
- <pattern>${eelfLogPattern}</pattern>
+ <encoder>
+ <pattern>${auditPattern}</pattern>
</encoder>
</appender>
<appender name="dmaapAAIEventConsumerMetric"
@@ -231,8 +240,8 @@
<fileNamePattern>${logDirectory}/dmaapAAIEventConsumer/metrics.log.%d{yyyy-MM-dd}
</fileNamePattern>
</rollingPolicy>
- <encoder class="org.onap.aai.logging.EcompEncoder">
- <pattern>${eelfMetricLogPattern}</pattern>
+ <encoder>
+ <pattern>${metricPattern}</pattern>
</encoder>
</appender>
<appender name="external"
@@ -245,10 +254,29 @@
<fileNamePattern>${logDirectory}/external/external.log.%d{yyyy-MM-dd}
</fileNamePattern>
</rollingPolicy>
- <encoder class="org.onap.aai.logging.EcompEncoder">
- <pattern>${eelfLogPattern}</pattern>
+ <encoder>
+ <pattern>${debugPattern}</pattern>
+ </encoder>
+ </appender>
+ <appender name="auth"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>DEBUG</level>
+ </filter>
+ <file>${logDirectory}/auth/auth.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/auth/auth.log.%d{yyyy-MM-dd}
+ </fileNamePattern>
+ </rollingPolicy>
+ <encoder>
+ <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}[%thread] %-5level %logger{1024} - %msg%n</pattern>
</encoder>
</appender>
+ <appender name="asyncAUTH" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>1000</queueSize>
+ <includeCallerData>true</includeCallerData>
+ <appender-ref ref="auth" />
+ </appender>
<!-- logback internals logging -->
<logger name="ch.qos.logback.classic" level="WARN" />
@@ -272,43 +300,40 @@
<logger name="org.onap.aai" level="DEBUG" additivity="false">
<appender-ref ref="asyncDEBUG" />
- <appender-ref ref="asyncERROR" />
- <appender-ref ref="asyncMETRIC" />
<appender-ref ref="asyncSANE" />
<appender-ref ref="STDOUT" />
</logger>
-
- <logger name="org.onap.aai.interceptors.post" level="DEBUG" additivity="false">
- <appender-ref ref="asynctranslog" />
+ <logger name="org.onap.aai.aaf.auth" level="DEBUG" additivity="false">
+ <appender-ref ref="asyncAUTH" />
</logger>
-
- <logger name="org.onap.aai.interceptors.pre.SetLoggingContext" level="DEBUG">
+ <logger name="org.onap.aai.aailog.logs.AaiScheduledTaskAuditLog" level="INFO">
<appender-ref ref="asyncAUDIT"/>
</logger>
-
- <logger name="org.onap.aai.interceptors.post.ResetLoggingContext" level="DEBUG">
+ <logger name="org.onap.logging.filter.base.AbstractAuditLogFilter" level="INFO">
<appender-ref ref="asyncAUDIT"/>
</logger>
+ <logger name="org.onap.aai.aailog.logs.AaiDBMetricLog" level="INFO">
+ <appender-ref ref="asyncMETRIC"/>
+ </logger>
+ <logger name="org.onap.aai.aailog.logs.AaiDmaapMetricLog" level="INFO">
+ <appender-ref ref="dmaapAAIEventConsumerMetric"/>
+ </logger>
+ <logger name="org.onap.aai.logging.ErrorLogHelper" level="WARN">
+ <appender-ref ref="asyncERROR"/>
+ </logger>
+ <logger name="org.onap.aai.interceptors.post" level="DEBUG" additivity="false">
+ <appender-ref ref="asynctranslog" />
+ </logger>
<logger name="org.onap.aai.dmaap" level="DEBUG" additivity="false">
<appender-ref ref="dmaapAAIEventConsumer" />
<appender-ref ref="dmaapAAIEventConsumerDebug" />
- <appender-ref ref="dmaapAAIEventConsumerMetric" />
</logger>
<logger name="com.att.nsa.mr" level="INFO" >
<appender-ref ref="dmaapAAIEventConsumerInfo" />
</logger>
- <!-- ============================================================================ -->
- <!-- General EELF logger -->
- <!-- ============================================================================ -->
- <logger name="com.att.eelf" level="WARN" additivity="false">
- <appender-ref ref="asyncDEBUG" />
- <appender-ref ref="asyncERROR" />
- <appender-ref ref="asyncMETRIC" />
- </logger>
-
<root level="DEBUG">
<appender-ref ref="external" />
<appender-ref ref="STDOUT" />
diff --git a/aai-resources/src/main/scripts/bulkprocess.sh b/aai-resources/src/main/scripts/bulkprocess.sh
index 5611bf7..c4bca27 100644
--- a/aai-resources/src/main/scripts/bulkprocess.sh
+++ b/aai-resources/src/main/scripts/bulkprocess.sh
@@ -43,10 +43,10 @@ if [ -z "$2" ]; then
exit 1
fi
-[[ "$XFROMAPPID" =~ [a-zA-Z0-9][a-zA-Z0-9]*-[a-zA-Z0-9][a-zA-Z0-9]* ]] || {
- echo "XFROMAPPID doesn't match the following regex [a-zA-Z0-9][a-zA-Z0-9]*-[a-zA-Z0-9][a-zA-Z0-9]*";
- exit 1;
-}
+case "${XFROMAPPID}" in
+ [a-zA-Z0-9][a-zA-Z0-9]*-[a-zA-Z0-9][a-zA-Z0-9]*) ;;
+ *) echo "XFROMAPPID doesn't match the following regex [a-zA-Z0-9][a-zA-Z0-9]*-[a-zA-Z0-9][a-zA-Z0-9]*"; exit 1; ;;
+esac
XTRANSID=$3
diff --git a/aai-resources/src/main/scripts/common_functions.sh b/aai-resources/src/main/scripts/common_functions.sh
index e99746d..14358d9 100644
--- a/aai-resources/src/main/scripts/common_functions.sh
+++ b/aai-resources/src/main/scripts/common_functions.sh
@@ -60,16 +60,19 @@ execute_spring_jar(){
JAVA_OPTS="$JAVA_OPTS -Dlogback.configurationFile=${logbackFile}";
export SOURCE_NAME=$(grep '^schema.source.name=' ${PROJECT_HOME}/resources/application.properties | cut -d"=" -f2-);
- # Needed for the schema ingest library beans
- eval $(grep '^schema\.' ${PROJECT_HOME}/resources/application.properties | \
- sed 's/^\(.*\)$/JAVA_OPTS="$JAVA_OPTS -D\1"/g' | \
- sed 's/${server.local.startpath}/${PROJECT_HOME}\/resources/g'| \
- sed 's/${schema.source.name}/'${SOURCE_NAME}'/g'\
- )
-
- JAVA_OPTS="${JAVA_OPTS} ${JAVA_POST_OPTS}";
-
- ${JAVA_HOME}/bin/java ${JVM_OPTS} ${JAVA_OPTS} -jar ${EXECUTABLE_JAR} "$@"
+ # Needed for the schema ingest library beans
+ eval $(egrep '^(schema|server)\.' ${PROJECT_HOME}/resources/application.properties | \
+ sed 's/^\(.*\)$/JAVA_OPTS="$JAVA_OPTS -D\1"/g' | \
+ sed 's/${server.local.startpath}/${PROJECT_HOME}\/resources/g'| \
+ sed 's/${schema.source.name}/'${SOURCE_NAME}'/g'\
+ )
+
+ JAVA_OPTS="${JAVA_OPTS} ${JAVA_POST_OPTS}";
+
+ "${JAVA_HOME}/bin/java" ${JVM_OPTS} ${JAVA_OPTS} -jar ${EXECUTABLE_JAR} "$@" || {
+ echo "Failed to run the tool $0 successfully";
+ exit 1;
+ }
}
# Prints the start date and the script that the user called
diff --git a/aai-resources/src/main/scripts/install/addManualData.sh b/aai-resources/src/main/scripts/install/addManualData.sh
index 016c5c3..bd7f7bd 100644
--- a/aai-resources/src/main/scripts/install/addManualData.sh
+++ b/aai-resources/src/main/scripts/install/addManualData.sh
@@ -75,41 +75,66 @@ error_exit () {
rel="/"$1"/"
k=0
-TEXT_PATH=$PROJECT_HOME/resources/etc/scriptdata/addmanualdata/*/*.txt
-COMMAND=`ls ${TEXT_PATH} | sort -f`
-
-ls ${TEXT_PATH} >/dev/null 2>&1
-if [ $? -ne 0 ]
+if [ "$1" = "tenant_isolation" ]
then
-echo "No manual data to add for $1";
-exit 0;
+ COMPLEX_TEXT_PATH=`find $PROJECT_HOME/resources/etc/scriptdata/addmanualdata/tenant_isolation/complex -name "*.txt" -print | sort -f`
+ ZONE_TEXT_PATH=`find $PROJECT_HOME/resources/etc/scriptdata/addmanualdata/tenant_isolation/zone -name "*.txt" -print | sort -f`
+ CR_TEXT_PATH=`find $PROJECT_HOME/resources/etc/scriptdata/addmanualdata/tenant_isolation/cloud-region -name "*.txt" -print | sort -f`
+ TENANT_TEXT_PATH=`find $PROJECT_HOME/resources/etc/scriptdata/addmanualdata/tenant_isolation/tenant -name "*.txt" -print | sort -f`
+ AZ_TEXT_PATH=`find $PROJECT_HOME/resources/etc/scriptdata/addmanualdata/tenant_isolation/availability-zone -name "*.txt" -print | sort -f`
+ PSERVER_TEXT_PATH=`find $PROJECT_HOME/resources/etc/scriptdata/addmanualdata/tenant_isolation/pserver -name "*.txt" -print | sort -f`
+ CUSTOMER_TEXT_PATH=`find $PROJECT_HOME/resources/etc/scriptdata/addmanualdata/tenant_isolation/customer -name "*.txt" -print | sort -f`
+ SERVICESUB_TEXT_PATH=`find $PROJECT_HOME/resources/etc/scriptdata/addmanualdata/tenant_isolation/service-subscription -name "*.txt" -print | sort -f`
+ SERVICE_TEXT_PATH=`find $PROJECT_HOME/resources/etc/scriptdata/addmanualdata/tenant_isolation/service -name "*.txt" -print | sort -f`
+
+ TEXT_PATH="${COMPLEX_TEXT_PATH} ${ZONE_TEXT_PATH} ${CR_TEXT_PATH} ${CUSTOMER_TEXT_PATH} ${SERVICE_TEXT_PATH} ${SERVICESUB_TEXT_PATH} ${TENANT_TEXT_PATH} ${AZ_TEXT_PATH} ${PSERVER_TEXT_PATH}"
+ COMMAND=${TEXT_PATH}
+elif [ "$1" = "vm_export" ]
+then
+ TEXT_PATH=$PROJECT_HOME/resources/etc/scriptdata/addmanualdata/vm_export/*.txt
+ COMMAND=`ls ${TEXT_PATH} | sort -rf`
+else
+ TEXT_PATH=$PROJECT_HOME/resources/etc/scriptdata/addmanualdata/*/*.txt
+ COMMAND=`ls ${TEXT_PATH} | sort -f`
fi
+#ls ${TEXT_PATH} >/dev/null 2>&1
+#if [ $? -ne 0 ]
+#then
+#echo "No manual data to add for $1";
+#exit 0;
+#fi
+
for filepath in ${COMMAND}
do
-contains $filepath $rel
-if [ $? -eq 0 ]
-then
-jsonfile=${filepath%???}json
-j=0
-while IFS=\n read -r i
-do
-echo "##### Begin putTool for $i ##### from file $filepath" | tee -a $OUTFILE
-resource=`echo $i | tr -d '\r'`
-errorcode=412
-$PROJECT_HOME/scripts/putTool.sh $resource $jsonfile $errorcode 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource" $j $filepath
-echo "##### End putTool for $resource #####" | tee -a $OUTFILE
-echo "Begin getTool for $resource" | tee -a $OUTFILE
-$PROJECT_HOME/scripts/getTool.sh $resource >> $OUTFILE 2>&1 || error_exit "$i" $j $filepath
-echo "End getTool for $resource" | tee -a $OUTFILE
-
-j=$(expr "$j" + 1)
-k=$(expr "$k" + 1)
-done < $filepath
-
-fi
-
-done
+ echo "File path ${filepath}"
+ contains $filepath $rel
+ if [ $? -eq 0 ]
+ then
+ jsonfile=${filepath%???}json
+ j=0
+ while IFS=\n read -r i
+ do
+ echo "##### Begin putTool for $i ##### from file $filepath" | tee -a $OUTFILE
+ resource=`echo $i | tr -d '\r'`
+ errorcode=412
+ $PROJECT_HOME/scripts/putTool.sh $resource $jsonfile $errorcode >> $OUTFILE 2>&1 || error_exit "$resource" $j $filepath
+ echo "##### End putTool for $resource #####" | tee -a $OUTFILE
+ contains $resource "relationship-list"
+ if [ $? -eq 0 ]
+ then
+ echo "skip getTool for $resource" | tee -a $OUTFILE
+ else
+ echo "Begin getTool for $resource" | tee -a $OUTFILE
+ $PROJECT_HOME/scripts/getTool.sh $resource >> $OUTFILE 2>&1 || error_exit "$i" $j $filepath
+ echo "End getTool for $resource" | tee -a $OUTFILE
+ fi
+
+ j=$(expr "$j" + 1)
+ k=$(expr "$k" + 1)
+ done < $filepath
+ fi
+ done
if [ $k -eq 0 ]
then
echo "No manual data to add for release $1";
diff --git a/aai-resources/src/main/scripts/updatePem.sh b/aai-resources/src/main/scripts/updatePem.sh
index 6e6ac6f..81ba65b 100644
--- a/aai-resources/src/main/scripts/updatePem.sh
+++ b/aai-resources/src/main/scripts/updatePem.sh
@@ -27,12 +27,24 @@ start_date;
check_user;
source_profile;
-CERTPATH=$PROJECT_HOME/resources/etc/auth/
+prop_file=$PROJECT_HOME/resources/application.properties
+
+CERTPATH=${PROJECT_HOME}/resources/etc/auth/
KEYNAME=aaiClientPrivateKey.pem
CERTNAME=aaiClientPublicCert.pem
+CERTIFICATE_FILE=${CERTPATH}aai-client-cert.p12
+
+CERTMAN_PATH=`grep ^server.certs.location $prop_file |cut -d'=' -f2 |tr -d "\015"`
+if [ -z $CERTMAN_PATH ]; then
+ echo "Property [server.certs.location] not found in file $prop_file, continuing with default"
+ pw=$(execute_spring_jar org.onap.aai.util.AAIConfigCommandLinePropGetter "" "aai.keystore.passwd" 2> /dev/null | tail -1)
+else
+ # Assume AAF certificate container use
+ pw=$(< ${CERTMAN_PATH}/.password)
+ CERTIFICATE_FILE=${CERTMAN_PATH}/certificate.pkcs12
+fi
-pw=$(execute_spring_jar org.onap.aai.util.AAIConfigCommandLinePropGetter "" "aai.keystore.passwd" 2> /dev/null | tail -1)
-openssl pkcs12 -in ${CERTPATH}/aai-client-cert.p12 -out $CERTPATH$CERTNAME -clcerts -nokeys -passin pass:$pw
-openssl pkcs12 -in ${CERTPATH}/aai-client-cert.p12 -out $CERTPATH$KEYNAME -nocerts -nodes -passin pass:$pw
+openssl pkcs12 -in ${CERTIFICATE_FILE} -out $CERTPATH$CERTNAME -nokeys -nodes -passin pass:$pw
+openssl pkcs12 -in ${CERTIFICATE_FILE} -nocerts -out $CERTPATH$KEYNAME -nodes -passin pass:$pw
end_date;
exit 0
diff --git a/aai-resources/src/main/scripts/updateTool.sh b/aai-resources/src/main/scripts/updateTool.sh
index e79edd1..ce0a8f6 100644
--- a/aai-resources/src/main/scripts/updateTool.sh
+++ b/aai-resources/src/main/scripts/updateTool.sh
@@ -129,36 +129,34 @@ fi
#or
#'physical-location-id:complex-id, city:New York'
thirdarg=$3
-isjson = false
+isjson=false
if [[ "$thirdarg" == *json || "$thirdarg" == *JSON ]]; then
- isjson = true
+ isjson=true
else
#For Usage 2, format input into JSON string format
JSONSTRING="{"
INPUT=$3
#replace any spaces with %20
- INPUT=${INPUT// /%20}
+ INPUT=$(echo ${INPUT} | sed 's/ /%20/g');
- for i in ${INPUT//,/ };
+ for i in $(echo ${INPUT} | sed 's/,/ /g');
do
#change any %20 back to space )
- i=${i//%20/ }
- #echo "after change to space=$i"
+ i=$(echo ${i} | sed 's/%20/ /g');
#trim modstring to remove any beginning spaces (" city" becomes "city")
- i="${i##*( )}"
-
+ i=$(echo ${i} | sed 's/^[ \t]*//');
+
#add JSON quotes
MODSTRING=" \"$i\","
- MODSTRING=${MODSTRING//[:]/'": "'}
- #echo "MODSTRING=$MODSTRING"
+ MODSTRING=$(echo ${MODSTRING} | sed 's/:/": "/g');
- JSONSTRING+=$MODSTRING
+ JSONSTRING="${JSONSTRING}${MODSTRING}"
done
JSONSTRING="${JSONSTRING%?}"
- JSONSTRING+=" }"
+ JSONSTRING="${JSONSTRING} }"
echo "JSON string is $JSONSTRING"
fi
@@ -225,4 +223,4 @@ else
fi
echo `date` " Done $0, returning $RC"
-exit $RC \ No newline at end of file
+exit $RC
diff --git a/aai-resources/src/main/scripts/vmExportCloudRegions.sh b/aai-resources/src/main/scripts/vmExportCloudRegions.sh
new file mode 100644
index 0000000..95ec969
--- /dev/null
+++ b/aai-resources/src/main/scripts/vmExportCloudRegions.sh
@@ -0,0 +1,517 @@
+#!/bin/ksh
+#
+###
+# ============LICENSE_START=======================================================
+# org.onap.aai
+# ================================================================================
+# 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=========================================================
+###
+
+#
+# vmExportCloudRegions.sh -- This tool is used to generate script payloads of
+# vm and interfaces linked to a specific cloud-owner to be imported
+# to the same cloud-region in a instance with its own data model and existing
+# dependent objects. This script maps predefined objects and relationsships
+# beteen the two instances. An archive is generated and manually
+# copied to the target instance. A second script, vmValidateCloudRegions.sh,
+# is run on the target instance that applies validations and replaces
+# values needed in the generated scripss.
+# generated files. The script takes 2 arguments
+
+# usage: $0 <cloud-owner> <target-basepath> <target-version>
+# <cloud-owner> is the cloud-region-owner
+# <target-version> is the replacement to be applied to aai/$version in
+# resource links from the source instance.
+
+# scriptdata/addmanualdata/vm_export/payload is populated with the target
+# files, that include json/txt files applied by addManualData script and tx
+# files which represent validations to be applied before running addManualData.
+# The naming convention of json/txt files ensures the ordering used to correctly
+# apply dependent objects. The archive is generated in
+# scriptdata/addmanualdata/vm_export/archive
+
+addTemplates() {
+ jq -n --arg related vlan-tag --arg rlabel org.onap.relationships.inventory.Uses \
+--arg rlink /aai/v1x/cloud-infrastructure/cloud-regions/cloud-region/change-this-to-cloud-owner/change-this-to-cloud-region-id/vlan-ranges/vlan-range/change-this-to-vlan-range-id/vlan-tags/vlan-tag/change-this-to-vlan-tag-id \
+'{"related-to": "\($related)", "relationship-label": "\($rlabel)", "related-link": "\($rlink)"}' > $TARGETDIR/vlan-tag-relationship-template.json
+
+ jq -n --arg related lag-interface --arg rlabel org.onap.relationships.inventory.Uses \
+--arg rlink /aai/v1x/cloud-infrastructure/pservers/pserver/change-this-to-hostname/lag-interfaces/lag-interface/bond1 \
+'{"related-to": "\($related)", "relationship-label": "\($rlabel)", "related-link": "\($rlink)"}' > $TARGETDIR/lag-interface-relationship-template.json
+
+ jq -n --arg dsl "cloud-region('cloud-owner','change-this-to-cloud-owner')('cloud-region-id','change-this-to-cloud-region-id') > vlan-range > [ vlan-tag*('vlan-id-inner', change-this-to-inner), vlan-tag*('vlan-id-outer', change-this-to-outer) ]" \
+'{"dsl": "\($dsl)"}' > $TARGETDIR/vlantagquery-template.json
+}
+
+getFileSize() {
+ echo `wc -c < $1`
+}
+
+getCloudRegions() {
+ res="cloud-infrastructure/cloud-regions?cloud-owner="$1"&format=pathed"
+ cloudres=`$PROJECT_HOME/scripts/getTool.sh "${res}" | sed '1d;$d'`
+ hasResults=`echo $cloudres | jq '.results'`
+ if [ "$hasResults" = null ]; then
+ hasResults="No-cloud-region"
+ fi
+ if [ "$hasResults" = "No-cloud-region" ]; then
+ echo "No-cloud-region"
+ else
+ echo $cloudres | jq '.results|.[]|."resource-link"' | sed -e 's/\"//g' | cut -d"/" -f4-
+ fi
+}
+
+getTenants() {
+ res=""$1"/tenants?format=pathed"
+ cloudres=`$PROJECT_HOME/scripts/getTool.sh $res | sed '1d;$d'`
+ hasResults=`echo $cloudres | jq '.results'`
+ if [ "$hasResults" = null ]; then
+ hasResults="No-tenant"
+ fi
+ if [ "$hasResults" = "No-tenant" ]; then
+ echo "No-tenant"
+ else
+ echo $cloudres | jq '.results|.[]|."resource-link"' | sed -e 's/\"//g' | cut -d"/" -f4-
+ fi
+}
+
+getVservers() {
+ res=""$1"/vservers?format=pathed"
+ cloudres=`$PROJECT_HOME/scripts/getTool.sh $res | sed '1d;$d'`
+ hasResults=`echo $cloudres | jq '.results'`
+ if [ "$hasResults" = null ]; then
+ hasResults="No-vserver"
+ fi
+ if [ "$hasResults" = "No-vserver" ]; then
+ echo "No-vserver"
+ else
+ echo $cloudres | jq '.results|.[]|."resource-link"' | sed -e 's/\"//g' | cut -d"/" -f4-
+ fi
+}
+
+getLInterfaces() {
+ res=""$1"/l-interfaces?format=pathed"
+ cloudres=`$PROJECT_HOME/scripts/getTool.sh $res | sed '1d;$d'`
+ hasResults=`echo $cloudres | jq '.results'`
+ if [ "$hasResults" = null ]; then
+ hasResults="No-l-interface"
+ fi
+ if [ "$hasResults" = "No-l-interface" ]; then
+ echo "No-l-interface"
+ else
+ echo $cloudres | jq '.results|.[]|."resource-link"' | sed -e 's/\"//g' | cut -d"/" -f4-
+ fi
+}
+
+getVlans() {
+ res=""$1"/vlans?format=pathed"
+ cloudres=`$PROJECT_HOME/scripts/getTool.sh $res | sed '1d;$d'`
+ hasResults=`echo $cloudres | jq '.results'`
+ if [ "$hasResults" = null ]; then
+ hasResults="No-vlan"
+ fi
+ if [ "$hasResults" = "No-vlan" ]; then
+ echo "No-vlan"
+ else
+ echo $cloudres | jq '.results|.[]|."resource-link"' | sed -e 's/\"//g' | cut -d"/" -f4-
+ fi
+}
+
+getSriovVfs() {
+ res=""$1"/sriov-vfs?format=pathed"
+ cloudres=`$PROJECT_HOME/scripts/getTool.sh $res | sed '1d;$d'`
+ hasResults=`echo $cloudres | jq '.results'`
+ if [ "$hasResults" = null ]; then
+ hasResults="No-sriov-vfs"
+ fi
+ if [ "$hasResults" = "No-sriov-vfs" ]; then
+ echo "No-sriov-vfs"
+ else
+ echo $cloudres | jq '.results|.[]|."resource-link"' | sed -e 's/\"//g' | cut -d"/" -f4-
+ fi
+}
+
+getTenant() {
+ res=""$1"?depth=0"
+ cloudres=`$PROJECT_HOME/scripts/getTool.sh $res | sed '1d;$d'`
+ filepath=$TARGETDIR/$regioncnt-$tenantcnt-tenant
+ echo "/"$1 > ${filepath}.txt
+ echo $cloudres | jq 'del(."resource-version")' > ${filepath}.json
+ echo $filepath
+}
+
+getVserver() {
+ res=""$1"?depth=0"
+ cloudres=`$PROJECT_HOME/scripts/getTool.sh $res | sed '1d;$d'`
+ filepath=$TARGETDIR/$regioncnt-$tenantcnt-$vservercnt-1-vserver
+ echo "/"$1 > ${filepath}.txt
+ echo $cloudres | jq 'del(."resource-version")|del(."relationship-list")' > ${filepath}.json
+ validatepath=$TARGETDIR/$regioncnt-$tenantcnt-$vservercnt-vserver-validate-notexists
+ echo "/"$1 > ${validatepath}.tx
+ echo $filepath
+}
+
+getVfModule() {
+ res=""$1"?depth=0"
+ cloudres=`$PROJECT_HOME/scripts/getTool.sh $res | sed '1d;$d'`
+ heatStackId=`echo $cloudres | jq '."heat-stack-id"' | sed 's/\"//g'`
+ if [ "$heatStackId" = "null" ]
+ then
+ echo $heatStackId
+ else
+ heatStackIdUri=`echo $heatStackId | jq -sRr @uri`
+ uri=`echo ${heatStackIdUri%???}`
+ filepath=$TARGETDIR/$regioncnt-$tenantcnt-$vservercnt-1-instance-group-$vfmodulecnt
+ echo "/network/instance-groups/instance-group/$uri" > ${filepath}.txt
+ # no need to validate, since instance-group is created if not present
+ #validatepath=$TARGETDIR/$regioncnt-$tenantcnt-$vservercnt-vserver-validate-vfmodule-$vfmodulecnt.tx
+ echo $cloudres | jq '{"heat-stack-id": ."heat-stack-id", "vf-module-name": ."vf-module-name"} | .["id"] = ."heat-stack-id" | .["instance-group-name"] = ."vf-module-name" | del(."heat-stack-id", ."vf-module-name") | .+ {"instance-group-type": "HEAT-STACK"}' > ${filepath}.json
+ echo $uri
+ fi
+}
+
+getVserverRelatedTo() {
+ res=""$1"?depth=0"
+ cloudres=`$PROJECT_HOME/scripts/getTool.sh $res | sed '1d;$d'`
+ hasResults=`echo $cloudres | jq '."relationship-list"'`
+ if [ "$hasResults" = null ]; then
+ hasResults="No-related-vf-module-or-pserver"
+ fi
+ if [ "$hasResults" = "No-related-vf-module-or-pserver" ]; then
+ echo "No-related-vf-module-or-pserver"
+ else
+ validatepath=$TARGETDIR/$regioncnt-$tenantcnt-$vservercnt-vserver-validate.tx
+ echo $cloudres | jq '[ ."relationship-list".relationship[] | select(."related-to" | contains("pserver")) ]' > ${validatepath}
+ sz=`getFileSize $validatepath`
+ pservercnt=0
+ if [ $sz = "3" ]; then
+ rm ${validatepath}
+ else
+ PSERVERS=`cat ${validatepath} | jq '.[]|."related-link"'|sed -e 's/\"//g' | cut -d"/" -f4-`
+ rm ${validatepath}
+ for pserver in ${PSERVERS}
+ do
+ validatepath=$TARGETDIR/$regioncnt-$tenantcnt-$vservercnt-vserver-validate-pserver-$pservercnt-exists.tx
+ echo $pserver > $validatepath
+ filepath=$TARGETDIR/$regioncnt-$tenantcnt-$vservercnt-0-vserver-related-to-pserver-$pservercnt
+ #echo $cloudres | jq '."relationship-list".relationship[] | select(."related-to" | contains("pserver"))' > ${filepath}.json
+ echo $cloudres | jq '."relationship-list".relationship[] | select(."related-to" | contains("pserver"))' | jq 'del(."relationship-data")' | jq 'del(."related-to-property")' > ${filepath}.json
+ echo "/"$1/relationship-list/relationship > ${filepath}.txt
+ pservercnt=$(expr "$pservercnt" + 1)
+ done
+ fi
+ validatepath=$TARGETDIR/$regioncnt-$tenantcnt-$vservercnt-vserver-validate.tx
+ echo $cloudres | jq '[ ."relationship-list".relationship[] | select(."related-to" | contains("vf-module")) ]' > ${validatepath}
+ sz=`getFileSize ${validatepath}`
+ if [ $sz = "3" ]; then
+ rm ${validatepath}
+ else
+ VFMODULES=`cat ${validatepath} | jq '.[]|."related-link"'|sed -e 's/\"//g' | cut -d"/" -f4-`
+ vfmodulecnt=0
+ rm ${validatepath}
+ for vfmodule in ${VFMODULES}
+ do
+ heatId=`getVfModule $vfmodule`
+ # add instance-group and keep pserver relationships
+ if [ `expr $pservercnt` -ne 0 ]; then
+ filepath=$TARGETDIR/$regioncnt-$tenantcnt-$vservercnt-0-vserver-related-to-instance-group
+ echo $cloudres | jq '."relationship-list".relationship |= .+ [{ "related-to": "instance-group", "relationship-label": "org.onap.relationships.inventory.MemberOf", "related-link": "/aai/v1x/network/instance-groups/instance-group/change-this-instance-group-id" }]' | jq '."relationship-list".relationship[] | select(."related-to" | contains("instance-group"))' | sed "s#change-this-instance-group-id#$heatId#" > ${filepath}.json
+echo $cloudres | jq '."relationship-list".relationship |= .+ [{ "related-to": "instance-group", "relationship-label": "org.onap.relationships.inventory.MemberOf", "related-link": "/aai/v1x/network/instance-groups/instance-group/change-this-instance-group-id" }]' | jq '."relationship-list".relationship[] | select(."related-to" | contains("instance-group"))'
+ echo "/"$1/relationship-list/relationship > ${filepath}.txt
+ vfmodulecnt=$(expr "$vfmodulecnt" + 1)
+ fi
+ done
+ fi
+ echo $filepath
+ fi
+}
+
+getLInterface() {
+ res=""$1"?depth=0"
+ cloudres=`$PROJECT_HOME/scripts/getTool.sh $res | sed '1d;$d'`
+ filepath=$TARGETDIR/$regioncnt-$tenantcnt-$vservercnt-$linterfacecnt-1-l-interface
+ echo "/"$1 > ${filepath}.txt
+ echo $cloudres | jq 'del(."resource-version")|del(."relationship-list")' > ${filepath}.json
+ echo "/"$1 > ${filepath}.txt
+ echo $cloudres | jq 'del(."resource-version")|del(."relationship-list")' > ${filepath}.json
+ echo $filepath
+}
+
+getVlan() {
+ res=""$1"?depth=0"
+ cloudres=`$PROJECT_HOME/scripts/getTool.sh $res | sed '1d;$d'`
+ filepath=$TARGETDIR/$regioncnt-$tenantcnt-$vservercnt-$linterfacecnt-0-$vlancnt-vlan-validate-vlantag.tx
+ echo $cloudres | jq 'del(."resource-version")|del(."relationship-list")' > ${filepath}
+ relpath=$TARGETDIR/$regioncnt-$tenantcnt-$vservercnt-$linterfacecnt-0-$vlancnt-vlantag-related-to
+ echo "$2/relationship-list/relationship" > ${relpath}.txt
+ # payload
+ cloudreg=`cat $TARGETDIR/$regioncnt-cloud-region.validate.exists.tx`
+ owner=`echo $cloudreg | cut -f 5 -d "/"`
+ cid=`echo $cloudreg | cut -f 6 -d "/"`
+ cat $TEMPLATEDIR/vlan-tag-relationship-template.json | sed -e "s/change-this-path-element/$targetVersion/" -e "s/change-this-to-cloud-owner/$owner/" -e "s/change-this-to-cloud-region-id/$cid/" > ${relpath}.json
+ echo $filepath
+}
+
+getSriovVf() {
+ res=""$1"?depth=0"
+ cloudres=`$PROJECT_HOME/scripts/getTool.sh $res | sed '1d;$d'`
+ filepath=$TARGETDIR/$regioncnt-$tenantcnt-$vservercnt-$linterfacecnt-$sriovvfcnt-1-sriov-vf
+ echo "/"$1 > ${filepath}.txt
+ echo $cloudres | jq 'del(."resource-version")|del(."relationship-list")' > ${filepath}.json
+ echo $filepath
+}
+
+getLagInterfaceRelatedTo() {
+ filepath=$TARGETDIR/$regioncnt-$tenantcnt-$vservercnt-$linterfacecnt-0-laginterface-related-to
+ pserverpath=$TARGETDIR/$regioncnt-$tenantcnt-$vservercnt-vserver-validate-pserver-0-exists.tx
+ if [ -s $pserverpath ];
+ then
+ server=`cat $pserverpath`
+ echo "$1/relationship-list/relationship" > ${filepath}.txt
+ hostname=`echo $server | cut -f4 -d"/"`
+ cat $TEMPLATEDIR/lag-interface-relationship-template.json | sed -e "s/change-this-path-element/$targetVersion/" -e "s/change-this-to-hostname/$hostname/" > ${filepath}.json
+ validatepath=$TARGETDIR/$regioncnt-$tenantcnt-$vservercnt-$linterfacecnt-laginterface-validate-exists
+ echo "/cloud-infrastructure/pservers/pserver/$hostname/lag-interfaces/lag-interface/bond1" > ${validatepath}.tx
+ fi
+}
+
+getSriovVfRelatedTo() {
+ res=""$1"?depth=0"
+ cloudres=`$PROJECT_HOME/scripts/getTool.sh $res | sed '1d;$d'`
+ hasResults=`echo $cloudres | jq '."relationship-list"'`
+ if [ "$hasResults" = null ]; then
+ hasResults="No-related-to-sriov-pf"
+ fi
+ if [ "$hasResults" = "No-related-to-sriov-pf" ]; then
+ echo "No-related-to-sriov-pf"
+ else
+ validatepath=$TARGETDIR/$regioncnt-$tenantcnt-$vservercnt-$linterfacecnt-$sriovvfcnt-sriovvf-validate-sriov-pf.tx
+ #echo "getSrioVfRelatedTo:" $validatepath $res >> /tmp/test.out
+ #echo "getSrioVfRelatedTo:" $validatepath $cloudres >> /tmp/test.out
+ echo $cloudres | jq '[ ."relationship-list".relationship[] | select(."related-to" | contains("sriov-pf")) ]' > ${validatepath}
+ sz=`getFileSize ${validatepath}`
+ sriovpfcnt=0
+ if [ $sz = "3" ]; then
+ rm ${validatepath}
+ else
+ SRIOVPFS=`cat ${validatepath} | jq '.[]|."related-link"'|sed -e 's/\"//g' | cut -d"/" -f4-`
+ rm ${validatepath}
+ for sriovpf in ${SRIOVPFS}
+ do
+ validatepath=$TARGETDIR/$regioncnt-$tenantcnt-$vservercnt-$linterfacecnt-$sriovvfcnt-sriovvf-validate-sriov-pf-$sriovpfcnt.tx
+ echo $sriovpf > $validatepath
+ #echo "getSrioVfRelatedTo:" $validatepath $sriovpf >> /tmp/test.out
+ filepath=$TARGETDIR/$regioncnt-$tenantcnt-$vservercnt-$linterfacecnt-$sriovvfcnt-0-sriovvf-related-to-sriov-pf-$sriovpfcnt
+ echo $cloudres | jq '."relationship-list".relationship[] | select(."related-to" | contains("sriov-pf"))' | jq 'del(."relationship-label")' | jq 'del(."relationship-data")' > ${filepath}.json
+ echo "/"$1/relationship-list/relationship > ${filepath}.txt
+ #echo "getSrioVfRelatedTo:" $filepath $cloudres >> /tmp/test.out
+ sriovpfcnt=$(expr "$sriovpfcnt" + 1)
+ done
+ fi
+ echo $filepath
+ fi
+}
+
+addValidateCloudRegion() {
+ filepath=$TARGETDIR/$regioncnt-cloud-region
+ echo "/"$1 > ${filepath}.validate.exists.tx
+}
+
+addValidateVserver() {
+ filepath=$TARGETDIR/$regioncnt-cloud-region
+ echo "/"$1 > ${filepath}.validate.exists.tx
+}
+COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P )
+. ${COMMON_ENV_PATH}/common_functions.sh
+
+. /etc/profile.d/aai.sh
+
+PROJECT_HOME=/opt/app/aai-resources
+PROGNAME=$(basename $0)
+
+TS=$(date "+%Y_%m_%d_%H_%M_%S")
+
+CHECK_USER="aaiadmin"
+userid=$( id | cut -f2 -d"(" | cut -f1 -d")" )
+if [ "${userid}" != $CHECK_USER ]; then
+ echo "You must be $CHECK_USER to run $0. The id used $userid."
+ exit 1
+fi
+TARGETDIR=$PROJECT_HOME/resources/etc/scriptdata/addmanualdata/vm_export/payload
+TEMPLATEDIR=$TARGETDIR
+mkdir -p $TARGETDIR
+rm -f $TARGETDIR/*
+
+if [ "$#" -ne 3 ]; then
+ echo "usage: $0 <cloud-owner> <target-basepath> <target-verson>"
+ exit 1
+fi
+
+addTemplates
+
+targetVersion="$2\/$3"
+
+echo "${TS}, getting vms and interfaces for cloud-region-owner: $1 with targetVersion $2/$3"
+regioncnt=0
+tenantcnt=0
+vservercnt=0
+linterfacecnt=0
+vlancnt=0
+sriovvfcnt=0
+totaltenants=0
+totalvms=0
+totalinterfaces=0
+totalvlans=0
+totalsriovvfs=0
+
+missingvms=0
+missinginterfaces=0
+missingvlans=0
+missingsriovvfs=0
+
+
+
+CLOUDS=`getCloudRegions $1`
+for cloud in ${CLOUDS}
+do
+ if [ $cloud = "No-cloud-region" ]; then
+ echo "No cloud-region found for owner " $1
+ else
+ addValidateCloudRegion $cloud
+ TENANTS=`getTenants $cloud`
+ for tenant in ${TENANTS}
+ do
+ if [ $tenant = "No-tenant" ]; then
+ echo "No tenant found for cloud-region " $cloud
+ else
+ #echo "Process tenant " $tenant
+ add=`getTenant $tenant`
+ #echo "adding tenant: " $add
+ VSERVERS=`getVservers $tenant`
+ for vserver in ${VSERVERS}
+ do
+ if [ $vserver = "No-vserver" ]; then
+ #echo "No vserver found for tenant " $tenant
+ missingvms=$(expr "$missingvms" + 1)
+ else
+ #echo "Process vserver " $vserver
+ add=`getVserver $vserver`
+ #echo "adding vserver: " $add
+ add=`getVserverRelatedTo $vserver`
+ #echo "adding vserver: related-to " $add
+ LINTERFACES=`getLInterfaces $vserver`
+ linterfacecnt=0
+ for linterface in ${LINTERFACES}
+ do
+ if [ $linterface = "No-l-interface" ]; then
+ #echo "No l-interface found for vserver " $vserver
+ missinginterfaces=$(expr "$missinginterfaces" + 1)
+ else
+ #echo "Process l-interface " $linterface
+ add=`getLInterface $linterface`
+ #echo "adding l-interface: " $add
+ VLANS=`getVlans $linterface`
+ for vlan in ${VLANS}
+ do
+ if [ $vlan = "No-vlan" ]; then
+ #echo "No vlan found for l-interface " $linterface
+ missingvlans=$(expr "$missingvlans" + 1)
+ else
+ #echo "Process vlan " $vlan
+ add=`getVlan $vlan $linterface`
+ #echo "adding vlan: " $add
+ vlancnt=$(expr "$vlancnt" + 1)
+ totalvlans=$(expr "$totalvlans" + 1)
+ fi
+ done
+ SRIOVVFS=`getSriovVfs $linterface`
+ for sriovvf in ${SRIOVVFS}
+ do
+ if [ $sriovvf = "No-sriov-vfs" ]; then
+ #echo "No sriov-vf found for l-interface " $linterface
+ # need to add relationship for pserver/lag-interface bond1
+ getLagInterfaceRelatedTo $linterface
+ missingsriovvfs=$(expr "$missingsriovvfs" + 1)
+ else
+ #echo "Processing l-interface" $linterface >> /tmp/test.out
+ #echo "Processing with sriov-vf" $sriovvf >> /tmp/test.out
+ add=`getSriovVf $sriovvf`
+ #echo "adding sriovvf: " $add
+ add=`getSriovVfRelatedTo $sriovvf`
+ #echo "adding sriovvf: related-to " $add
+ sriovvfcnt=$(expr "$sriovvfcnt" + 1)
+ totalsriovvfs=$(expr "$totalsriovvfs" + 1)
+ fi
+ done
+ vlancnt=0
+ sriovvfcnt=0
+ linterfacecnt=$(expr "$linterfacecnt" + 1)
+ totalinterfaces=$(expr "$totalinterfaces" + 1)
+ fi
+ done
+ linterfacecnt=0
+ # check that vserver related-to is present
+ if [ -e "$TARGETDIR/$regioncnt-$tenantcnt-$vservercnt-0-vserver-related-to-instance-group.json" ]; then
+ vservercnt=$(expr "$vservercnt" + 1)
+ totalvms=$(expr "$totalvms" + 1)
+ else
+ rm $TARGETDIR/$regioncnt-$tenantcnt-$vservercnt*
+ echo "no related vf-module, skip export for $vserver"
+ fi
+ fi
+ done
+ vservercnt=0
+ tenantcnt=$(expr "$tenantcnt" + 1)
+ totaltenants=$(expr "$totaltenants" + 1)
+ fi
+ done
+ tenantcnt=0
+ regioncnt=$(expr "$regioncnt" + 1)
+ fi
+done
+sed -i "s/aai\/v1./$targetVersion/g" $TARGETDIR/*related-to*.json
+echo "Total cloud-regions to process " $regioncnt
+echo "Total tenants to add " $totaltenants
+echo "Total vms to add " $totalvms
+#echo "Total interfaces to add " $totalinterfaces
+#echo "Total vlans to add " $totalvlans
+#echo "Total sriovvfs to add " $totalsriovvfs
+
+TS=$(date "+%Y_%m_%d_%H_%M_%S")
+ARCHIVEDIR=$PROJECT_HOME/resources/etc/scriptdata/addmanualdata/vm_export/archive
+if [ ! -d ${ARCHIVEDIR} ]
+then
+ mkdir -p ${ARCHIVEDIR}
+ chown aaiadmin:aaiadmin ${ARCHIVEDIR}
+ chmod u+w ${ARCHIVEDIR}
+fi
+cd ${TARGETDIR}
+tar c * -f ${ARCHIVEDIR}/vmExportArchive_${TS}.tar --exclude=payload
+if [ $? -ne 0 ]
+then
+ echo " Unable to tar ${TARGETDIR}"
+ exit 1
+fi
+cd ${ARCHIVEDIR}
+gzip ${ARCHIVEDIR}/vmExportArchive_${TS}.tar
+
+if [ $? -ne 0 ]
+then
+ echo " Unable to gzip ${ARCHIVE_DIRECTORY}/vmExportArchive_${TS}.tar"
+ exit 1
+fi
+echo "Completed successfully: ${ARCHIVE_DIRECTORY}/vmExportArchive_${TS}.tar"
+exit 0 \ No newline at end of file
diff --git a/aai-resources/src/main/scripts/vmUpdateExport.sh b/aai-resources/src/main/scripts/vmUpdateExport.sh
new file mode 100644
index 0000000..f492d2c
--- /dev/null
+++ b/aai-resources/src/main/scripts/vmUpdateExport.sh
@@ -0,0 +1,75 @@
+#!/bin/ksh
+#
+###
+# ============LICENSE_START=======================================================
+# org.onap.aai
+# ================================================================================
+# 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=========================================================
+###
+
+#
+# vmUpdateExport.sh -- This tool updates the files generated in A&AI to
+# match what is expected in narad
+# The script takes no arguments
+
+addTemplates() {
+ jq -n --arg dsl "pserver('hostname','change-this-to-hostname') > p-interface > [ sriov-pf* ]" \
+'{"dsl": "\($dsl)"}' > sriovpfquery-template.json
+}
+
+COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P )
+. ${COMMON_ENV_PATH}/common_functions.sh
+
+. /etc/profile.d/aai.sh
+
+PROJECT_HOME=/opt/app/aai-resources
+PROGNAME=$(basename $0)
+
+CHECK_USER="aaiadmin"
+userid=$( id | cut -f2 -d"(" | cut -f1 -d")" )
+if [ "${userid}" != $CHECK_USER ]; then
+ echo "You must be $CHECK_USER to run $0. The id used $userid."
+ exit 1
+fi
+VMEXPORTDIR=$PROJECT_HOME/resources/etc/scriptdata/addmanualdata/vm_export
+cd $VMEXPORTDIR
+addTemplates
+URIS=`cat *vserver-validate-pserver*tx | sort -u`
+for uri in $URIS
+do
+ hostname=`echo $uri | cut -d "/" -f 4`
+ shortname=`echo $hostname | cut -d "." -f1`
+ sed -i -e "s#relationship-value\": \"$hostname#relationship-value\" : \"$shortname#" *json
+ sed -i -e "s#property-value\": \"$hostname#property-value\" : \"$shortname#" *json
+ sed -i -e "s#pserver/$hostname#pserver/$shortname#" *json
+ sed -i -e "s#pserver/$hostname#pserver/$shortname#" *tx
+ cat sriovpfquery-template.json | sed -e "s/change-this-to-hostname/$shortname/" > sriovf.query.$shortname.json
+ res=`$PROJECT_HOME/scripts/putTool.sh "/dsl?format=pathed" sriovf.query.$shortname.json -display | sed '1d;$d'`
+ echo $res | jq '.results|.[]|."resource-link"' | sed -e 's/\"//g' | cut -d"/" -f4- > sriovf.result.$shortname
+done
+txfiles=`ls *sriovvf-validate-sriov-pf-*tx`
+for txfile in $txfiles
+do
+ uri=`cat $txfile`
+ hostname=`echo $uri | cut -d "/" -f 4`
+ pfPciId=`echo $uri | cut -d "/" -f 10`
+ interfacename=`echo $uri | cut -d "/" -f 7`
+ newuri=`grep $pfPciId sriovf.result.$hostname`
+ #echo "old uri " + $uri
+ #echo "new uri " + $newuri
+ sed -i -e "s#$uri#$newuri#" *sriovvf-related-to-sriov-pf*.json
+ sed -i -e "s#$uri#$newuri#" *sriovvf-validate-sriov-pf*.tx
+done \ No newline at end of file
diff --git a/aai-resources/src/main/scripts/vmValidateCloudRegions.sh b/aai-resources/src/main/scripts/vmValidateCloudRegions.sh
new file mode 100644
index 0000000..a8189e3
--- /dev/null
+++ b/aai-resources/src/main/scripts/vmValidateCloudRegions.sh
@@ -0,0 +1,328 @@
+#!/bin/ksh
+
+###
+# ============LICENSE_START=======================================================
+# org.onap.aai
+# ================================================================================
+# 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=========================================================
+###
+
+# this script now requires a release parameter.
+# the tool finds and sorts *.txt files within the
+# resources/etc/scriptdata/addmanualdata/$release directory containing
+# one resource to be added to the graph. The directory contains a second
+# file with the same name, but the extension is .json. This json file
+# is passed to the PutTool as the payload. The parameters passed to the
+# PutTool will have 412 failures ignored. After calling the PutTool, the
+# GetTool is called to include the object put into the graph.
+# this script is run at every installation, logging the manual data applied.
+
+# Returns 0 if the specified string contains the specified substring,
+# otherwise returns 1.
+contains() {
+ string="$1"
+ substring="$2"
+ if test "${string#*$substring}" != "$string"
+ then
+ return 0 # $substring is in $string
+ else
+ return 1 # $substring is not in $string
+ fi
+}
+
+updateRenames () {
+ echo $1 >> $PAYLOADDIR/rename.txt
+}
+
+renamefiles() {
+ FILESTORENAME=`ls $PAYLOADDIR/$1*$2`
+ for f in $FILESTORENAME
+ do
+ mv $f $f.bak
+ done
+
+}
+
+. /etc/profile.d/aai.sh
+PROJECT_HOME=/opt/app/aai-resources
+
+PROGNAME=$(basename $0)
+OUTFILE=$PROJECT_HOME/logs/misc/${PROGNAME}.log.$(date +\%Y-\%m-\%d)
+#OUTFILE=/c/temp/${PROGNAME}.log.$(date +\%Y-\%m-\%d)
+
+TS=$(date "+%Y-%m-%d %H:%M:%S")
+
+CHECK_USER="aaiadmin"
+userid=$( id | cut -f2 -d"(" | cut -f1 -d")" )
+if [ "${userid}" != $CHECK_USER ]; then
+ echo "You must be $CHECK_USER to run $0. The id used $userid."
+ exit 1
+fi
+
+error_exit () {
+ echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2 in $3" 1>&2
+ echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2 in $3" >> $OUTFILE
+# exit ${2:-"1"}
+}
+
+notfound="not-found"
+found="found"
+
+getCloudRegion() {
+ res=$1?depth=0
+ cloudres=`$PROJECT_HOME/scripts/getTool.sh $res | sed '1d;$d'`
+ hasResults=`echo $cloudres | jq '."cloud-owner"'`
+ if [ "$hasResults" = null ]; then
+ echo $notfound
+ else
+ echo $found
+ fi
+}
+
+getVserver() {
+ res=$1?depth=0
+ cloudres=`$PROJECT_HOME/scripts/getTool.sh $res | sed '1d;$d'`
+ hasResults=`echo $cloudres | jq '."vserver-id"'`
+ if [ "$hasResults" = null ]; then
+ echo $notfound
+ else
+ echo $found
+ fi
+}
+
+getPserver() {
+ res=$1?depth=0
+ cloudres=`$PROJECT_HOME/scripts/getTool.sh $res | sed '1d;$d'`
+ hasResults=`echo $cloudres | jq '."hostname"'`
+ if [ "$hasResults" = null ]; then
+ echo $notfound
+ else
+ echo $found
+ fi
+}
+
+getSriovPf() {
+ res=$1?depth=0
+ cloudres=`$PROJECT_HOME/scripts/getTool.sh $res | sed '1d;$d'`
+ hasResults=`echo $cloudres | jq '."pf-pci-id"'`
+ if [ "$hasResults" = null ]; then
+ echo $notfound
+ else
+ echo $found
+ fi
+}
+
+getLagInterface() {
+ res=$1?depth=0
+ cloudres=`$PROJECT_HOME/scripts/getTool.sh $res | sed '1d;$d'`
+ hasResults=`echo $cloudres | jq '."interface-name"'`
+ if [ "$hasResults" = null ]; then
+ echo $notfound
+ else
+ echo $found
+ fi
+}
+
+getVlanTag() {
+ vlanindex=`echo $1 | cut -f 10 -d "/" | cut -f 1-6 -d "-"`
+ cloudindex=`echo $vlanindex | cut -f 1 -d "-"`
+ cloudregion=`cat $PAYLOADDIR/$cloudindex-cloud-region.validate.exists.tx`
+ cowner=`echo $cloudregion | cut -f 5 -d "/"`
+ cid=`echo $cloudregion | cut -f 6 -d "/"`
+ inner=`cat $1 | jq '."vlan-id-inner"' | sed 's/\"//g'`
+ outer=`cat $1 | jq '."vlan-id-outer"' | sed 's/\"//g'`
+ cat $TEMPLATEDIR/vlantagquery-template.json | sed -e "s/change-this-to-cloud-owner/$cowner/" -e "s/change-this-to-cloud-region-id/$cid/" -e "s/change-this-to-inner/$inner/" -e "s/change-this-to-outer/$outer/" > $PAYLOADDIR/$vlanindex-vlan-validate-vlantag.json
+ $PROJECT_HOME/scripts/putTool.sh "/dsl?format=pathed" $PAYLOADDIR/$vlanindex-vlan-validate-vlantag.json -display > $PAYLOADDIR/$vlanindex-vlan-validate-vlantag-result.json 2>&1
+ cloudres=`cat $PAYLOADDIR/$vlanindex-vlan-validate-vlantag-result.json | sed '1,4d;$d'`
+ hasResults=`echo $cloudres | jq '.results'`
+ if [ "$hasResults" = null ]; then
+ hasResults=$notfound
+ fi
+ if [ "$hasResoults" = $notfound ]; then
+ echo $notfound
+ else
+ len=`echo $cloudres | jq '.results | length'`
+ if [ $len -eq 0 ];
+ then
+ echo "vlan-tag-not-found"
+ elif [ $len -gt 1 ];
+ then
+ echo "multiple-vlan-tag-found"
+ else
+ vlantag=`echo $cloudres | jq '.results|.[]|."resource-link"' | sed -e 's/\"//g' | cut -d"/" -f4-`
+ rangeId=`echo $vlantag| cut -f 8 -d "/"`
+ tagId=`echo $vlantag | cut -f 11 -d "/"`
+ sed -i -e "s/change-this-to-vlan-range-id/$rangeId/" -e "s/change-this-to-vlan-tag-id/$tagId/" $PAYLOADDIR/$vlanindex-vlantag-related-to.json
+ echo $found
+ fi
+ fi
+
+}
+
+PAYLOADDIR=$PROJECT_HOME/resources/etc/scriptdata/addmanualdata/vm_export
+TEMPLATEDIR=$PROJECT_HOME/resources/etc/scriptdata/addmanualdata/vm_export
+COMMAND=`find $PAYLOADDIR -name "*cloud-region.validate.exists.tx" -print | sort -f`
+
+skipValidations=$1
+if [ -z $skipValidations ]; then
+ skipValidations="1"
+fi
+
+validatecnt=0
+validcnt=0
+
+echo "${TS}, starting validations"
+
+for filepath in ${COMMAND}
+do
+ cloudindex=`echo ${filepath} | cut -f 10 -d "/" | cut -f 1 -d "-"`
+ while IFS=\n read -r i
+ do
+ cloudregion=`getCloudRegion $i`
+ if [[ $cloudregion == $found ]]
+ then
+ validcnt=$(expr $validcnt + 1)
+ else
+ echo "not importing vms under region $i"
+ renamefiles "$cloudindex" "txt"
+ renamefiles "$cloudindex" "tx"
+ fi
+ validatecnt=$(expr $validatecnt + 1)
+ done < $filepath
+done
+
+skipvalidate=false
+contains $skipValidations "vserver-validate-notexists"
+if [ $? -eq 0 ] ; then
+ skipvalidate=true
+fi
+
+COMMAND=`find $PAYLOADDIR -name "*vserver-validate-notexists.tx" -print | sort -f`
+for filepath in ${COMMAND}
+do
+ cloudindex=`echo ${filepath} | cut -f 10 -d "/" | cut -f 1-3 -d "-"`
+ while IFS=\n read -r i
+ do
+ vserver=`getVserver $i`
+ if [[ $vserver == $notfound || $skipvalidate = true ]]
+ then
+ validcnt=$(expr $validcnt + 1)
+ else
+ echo "vm exists, $i not importing vm"
+ updateRenames "$cloudindex"
+ fi
+ validatecnt=$(expr $validatecnt + 1)
+ done < $filepath
+done
+
+COMMAND=`find $PAYLOADDIR -name "*vserver-validate-pserver-*-exists.tx" -print | sort -f`
+
+for filepath in ${COMMAND}
+do
+ cloudindex=`echo ${filepath} | cut -f 10 -d "/" | cut -f 1-3 -d "-"`
+ while IFS=\n read -r i
+ do
+ pserver=`getPserver $i`
+ if [[ $pserver == $found ]]
+ then
+ validcnt=$(expr $validcnt + 1)
+ else
+ echo "missing pserver, $i, not importing related vms"
+ updateRenames "$cloudindex"
+ fi
+ validatecnt=$(expr $validatecnt + 1)
+ done < $filepath
+done
+
+COMMAND=`find $PAYLOADDIR -name "*sriovvf-validate-sriov-pf-*.tx" -print | sort -f`
+
+for filepath in ${COMMAND}
+do
+ cloudindex=`echo ${filepath} | cut -f 10 -d "/" | cut -f 1-3 -d "-"`
+ while IFS=\n read -r i
+ do
+ pserver=`getSriovPf $i`
+ if [[ $pserver == $found ]]
+ then
+ validcnt=$(expr $validcnt + 1)
+ else
+ echo "missing sriov-pf, $i, not importing related vms"
+ updateRenames "$cloudindex"
+ fi
+ validatecnt=$(expr $validatecnt + 1)
+ done < $filepath
+done
+
+COMMAND=`find $PAYLOADDIR -name "*laginterface-validate-exists.tx" -print | sort -f`
+
+for filepath in ${COMMAND}
+do
+ cloudindex=`echo ${filepath} | cut -f 10 -d "/" | cut -f 1-3 -d "-"`
+ while IFS=\n read -r i
+ do
+ laginterface=`getLagInterface $i`
+ if [[ $laginterface == $found ]]
+ then
+ validcnt=$(expr $validcnt + 1)
+ else
+ echo "missing lag-interface, $i, not importing related vms"
+ updateRenames "$cloudindex"
+ fi
+ validatecnt=$(expr $validatecnt + 1)
+ done < $filepath
+done
+
+COMMAND=`find $PAYLOADDIR -name "*vlan-validate-vlantag.tx" -print | sort -f`
+
+for filepath in ${COMMAND}
+do
+ cloudindex=`echo ${filepath} | cut -f 10 -d "/" | cut -f 1-3 -d "-"`
+ vlantag=`getVlanTag ${filepath}`
+ if [[ $vlantag == $found ]]
+ then
+ validcnt=$(expr $validcnt + 1)
+ elif [[ $vlantag == "vlan-tag-not-found" ]]
+ then
+ echo "no matching vlan-tag, $filepath, not importing related vms"
+ updateRenames "$cloudindex"
+ elif [[ $vlantag == "multiple-vlan-tag-found" ]]
+ then
+ echo "multipe vlan-tag matches, $filepath, not importing related vms"
+ updateRenames "$cloudindex"
+ else
+ echo "missing vlan-tag, $filepath, not importing related vms"
+ updateRenames "$cloudindex"
+ fi
+ validatecnt=$(expr $validatecnt + 1)
+done
+
+if [ -s $PAYLOADDIR/rename.txt ];
+then
+ cat $PAYLOADDIR/rename.txt | sed 's/^$//' | sort -u > $PAYLOADDIR/renamed.txt
+
+ while IFS=\n read -r i
+ do
+ renamefiles $i "txt"
+ renamefiles $i "tx"
+ done < "$PAYLOADDIR/renamed.txt"
+ rm $PAYLOADDIR/rename*
+fi
+TS=$(date "+%Y-%m-%d %H:%M:%S")
+echo "${TS}, validations completed"
+echo "Total validations done " $validatecnt
+echo "Total validations passed " $validcnt
+
+exit 0