aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/aai/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/onap/aai/util')
-rw-r--r--src/main/java/org/onap/aai/util/ExceptionTranslator.java47
-rw-r--r--src/main/java/org/onap/aai/util/GraphAdminConstants.java49
-rw-r--r--src/main/java/org/onap/aai/util/GraphAdminDBUtils.java40
-rw-r--r--src/main/java/org/onap/aai/util/SendDeleteMigrationNotificationsMain.java26
-rw-r--r--src/main/java/org/onap/aai/util/SendMigrationNotificationsMain.java27
5 files changed, 177 insertions, 12 deletions
diff --git a/src/main/java/org/onap/aai/util/ExceptionTranslator.java b/src/main/java/org/onap/aai/util/ExceptionTranslator.java
new file mode 100644
index 0000000..a395c23
--- /dev/null
+++ b/src/main/java/org/onap/aai/util/ExceptionTranslator.java
@@ -0,0 +1,47 @@
+/**
+ * ============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.util;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.onap.aai.GraphAdminApp;
+import org.onap.aai.exceptions.AAIException;
+
+public class ExceptionTranslator {
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(ExceptionTranslator.class);
+ public static AAIException schemaServiceExceptionTranslator(Exception ex) {
+ AAIException aai = null;
+ LOGGER.info("Exception is " + ExceptionUtils.getRootCause(ex).getMessage() + "Root cause is"+ ExceptionUtils.getRootCause(ex).toString());
+ if(ExceptionUtils.getRootCause(ex).getMessage().contains("NodeIngestor")){
+ aai = new AAIException("AAI_3026","Error reading OXM from SchemaService - Investigate");
+ }
+ else if(ExceptionUtils.getRootCause(ex).getMessage().contains("EdgeIngestor")){
+ aai = new AAIException("AAI_3027","Error reading EdgeRules from SchemaService - Investigate");
+ }
+ else if(ExceptionUtils.getRootCause(ex).getMessage().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");
+ }
+
+ return aai;
+ }
+}
diff --git a/src/main/java/org/onap/aai/util/GraphAdminConstants.java b/src/main/java/org/onap/aai/util/GraphAdminConstants.java
new file mode 100644
index 0000000..017d92e
--- /dev/null
+++ b/src/main/java/org/onap/aai/util/GraphAdminConstants.java
@@ -0,0 +1,49 @@
+/**
+ * ============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.util;
+
+public final class GraphAdminConstants {
+
+ public static final int AAI_SNAPSHOT_DEFAULT_THREADS_FOR_CREATE = 15;
+ public static final int AAI_SNAPSHOT_DEFAULT_MAX_ERRORS_PER_THREAD = 25;
+ public static final Long AAI_SNAPSHOT_DEFAULT_VERTEX_ADD_DELAY_MS = 1L;
+ public static final Long AAI_SNAPSHOT_DEFAULT_EDGE_ADD_DELAY_MS = 1L;
+ public static final Long AAI_SNAPSHOT_DEFAULT_FAILURE_DELAY_MS = 50L;
+ public static final Long AAI_SNAPSHOT_DEFAULT_RETRY_DELAY_MS = 1500L;
+ public static final Long AAI_SNAPSHOT_DEFAULT_VERTEX_TO_EDGE_PROC_DELAY_MS = 9000L;
+ public static final Long AAI_SNAPSHOT_DEFAULT_STAGGER_THREAD_DELAY_MS = 5000L;
+
+ public static final int AAI_GROOMING_DEFAULT_MAX_FIX = 150;
+ public static final int AAI_GROOMING_DEFAULT_SLEEP_MINUTES = 7;
+
+ public static final int AAI_DUPETOOL_DEFAULT_MAX_FIX = 25;
+ public static final int AAI_DUPETOOL_DEFAULT_SLEEP_MINUTES = 7;
+
+
+
+
+ /**
+ * Instantiates a new GraphAdmin constants.
+ */
+ private GraphAdminConstants() {
+ // prevent instantiation
+ }
+
+}
diff --git a/src/main/java/org/onap/aai/util/GraphAdminDBUtils.java b/src/main/java/org/onap/aai/util/GraphAdminDBUtils.java
new file mode 100644
index 0000000..992223e
--- /dev/null
+++ b/src/main/java/org/onap/aai/util/GraphAdminDBUtils.java
@@ -0,0 +1,40 @@
+/**
+ * ============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.util;
+
+import java.util.Iterator;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+public class GraphAdminDBUtils {
+
+ private static EELFLogger LOGGER = EELFManager.getInstance().getLogger(GraphAdminDBUtils.class);
+
+ public static void logConfigs(org.apache.commons.configuration.Configuration configuration) {
+
+ if (configuration != null && configuration.getKeys() != null) {
+ Iterator<String> keys = configuration.getKeys();
+ keys.forEachRemaining(
+ key -> LOGGER.info("Key is " + key + "Value is " + configuration.getProperty(key).toString()));
+ }
+
+ }
+}
diff --git a/src/main/java/org/onap/aai/util/SendDeleteMigrationNotificationsMain.java b/src/main/java/org/onap/aai/util/SendDeleteMigrationNotificationsMain.java
index ad96efe..e559a78 100644
--- a/src/main/java/org/onap/aai/util/SendDeleteMigrationNotificationsMain.java
+++ b/src/main/java/org/onap/aai/util/SendDeleteMigrationNotificationsMain.java
@@ -21,8 +21,11 @@ package org.onap.aai.util;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
+import org.onap.aai.config.PropertyPasswordConfiguration;
import org.onap.aai.dbmap.AAIGraph;
+import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.logging.ErrorLogHelper;
import org.onap.aai.logging.LoggingContext;
import org.onap.aai.migration.EventAction;
import org.onap.aai.setup.SchemaVersions;
@@ -32,7 +35,7 @@ import java.util.*;
public class SendDeleteMigrationNotificationsMain {
- public static void main(String[] args) {
+ public static void main(String[] args) throws AAIException {
Arrays.asList(args).stream().forEach(System.out::println);
@@ -47,11 +50,22 @@ public class SendDeleteMigrationNotificationsMain {
LoggingContext.statusCode(LoggingContext.StatusCode.COMPLETE);
LoggingContext.responseCode(LoggingContext.SUCCESS);
- AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(
- "org.onap.aai.config",
- "org.onap.aai.setup"
- );
-
+ AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
+ PropertyPasswordConfiguration initializer = new PropertyPasswordConfiguration();
+ initializer.initialize(ctx);
+ try {
+ ctx.scan(
+ "org.onap.aai.config",
+ "org.onap.aai.setup"
+ );
+ ctx.refresh();
+ } catch (Exception e) {
+ AAIException aai = ExceptionTranslator.schemaServiceExceptionTranslator(e);
+ LoggingContext.statusCode(LoggingContext.StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.DATA_ERROR);
+ ErrorLogHelper.logError(aai.getCode(), e.getMessage() + ", resolve and retry");
+ throw aai;
+ }
LoaderFactory loaderFactory = ctx.getBean(LoaderFactory.class);
SchemaVersions schemaVersions = ctx.getBean(SchemaVersions.class);
String basePath = ctx.getEnvironment().getProperty("schema.uri.base.path");
diff --git a/src/main/java/org/onap/aai/util/SendMigrationNotificationsMain.java b/src/main/java/org/onap/aai/util/SendMigrationNotificationsMain.java
index 29eb1da..6ae2bb4 100644
--- a/src/main/java/org/onap/aai/util/SendMigrationNotificationsMain.java
+++ b/src/main/java/org/onap/aai/util/SendMigrationNotificationsMain.java
@@ -21,8 +21,11 @@ package org.onap.aai.util;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
+import org.onap.aai.config.PropertyPasswordConfiguration;
import org.onap.aai.dbmap.AAIGraph;
+import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.logging.ErrorLogHelper;
import org.onap.aai.logging.LoggingContext;
import org.onap.aai.migration.EventAction;
import org.onap.aai.setup.SchemaVersions;
@@ -32,7 +35,7 @@ import java.util.*;
public class SendMigrationNotificationsMain {
- public static void main(String[] args) {
+ public static void main(String[] args) throws AAIException {
Arrays.asList(args).stream().forEach(System.out::println);
@@ -47,11 +50,23 @@ public class SendMigrationNotificationsMain {
LoggingContext.statusCode(LoggingContext.StatusCode.COMPLETE);
LoggingContext.responseCode(LoggingContext.SUCCESS);
- AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(
- "org.onap.aai.config",
- "org.onap.aai.setup"
- );
-
+ AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
+ PropertyPasswordConfiguration initializer = new PropertyPasswordConfiguration();
+ initializer.initialize(ctx);
+ try {
+ ctx.scan(
+ "org.onap.aai.config",
+ "org.onap.aai.setup"
+ );
+ ctx.refresh();
+ } catch (Exception e) {
+ AAIException aai = ExceptionTranslator.schemaServiceExceptionTranslator(e);
+ System.out.println("Problems running tool "+aai.getMessage());
+ LoggingContext.statusCode(LoggingContext.StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.DATA_ERROR);
+ ErrorLogHelper.logError(aai.getCode(), e.getMessage() + ", resolve and retry");
+ throw aai;
+ }
LoaderFactory loaderFactory = ctx.getBean(LoaderFactory.class);
SchemaVersions schemaVersions = ctx.getBean(SchemaVersions.class);
String basePath = ctx.getEnvironment().getProperty("schema.uri.base.path");