diff options
Diffstat (limited to 'aai-core')
3 files changed, 136 insertions, 118 deletions
diff --git a/aai-core/src/main/java/org/onap/aai/util/AAIConstants.java b/aai-core/src/main/java/org/onap/aai/util/AAIConstants.java index cbcbd46e..c7a7b4a1 100644 --- a/aai-core/src/main/java/org/onap/aai/util/AAIConstants.java +++ b/aai-core/src/main/java/org/onap/aai/util/AAIConstants.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright © 2018 IBM. + * ================================================================================ * 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 @@ -20,90 +22,91 @@ package org.onap.aai.util; public final class AAIConstants { - // - // - /** Default to unix file separator if system property file.separator is null */ - public static final String AAI_FILESEP = (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator"); - // - /** Default to opt aai if system property aai.home is null, using file.separator */ - public static final String AAI_HOME = (System.getProperty("AJSC_HOME") == null) ? AAI_FILESEP + "opt" + AAI_FILESEP + "app" + AAI_FILESEP +"aai" : System.getProperty("AJSC_HOME"); - public static final String AAI_BUNDLECONFIG_NAME = (System.getProperty("BUNDLECONFIG_DIR") == null) ? "bundleconfig" : System.getProperty("BUNDLECONFIG_DIR"); - public static final String AAI_HOME_BUNDLECONFIG = (System.getProperty("AJSC_HOME") == null) ? AAI_FILESEP + "opt" + AAI_FILESEP + "app" + AAI_FILESEP + "aai" + AAI_FILESEP + AAI_BUNDLECONFIG_NAME : System.getProperty("AJSC_HOME")+ AAI_FILESEP + AAI_BUNDLECONFIG_NAME; - - /** etc directory, relative to AAI_HOME */ - public static final String AAI_HOME_ETC = AAI_HOME_BUNDLECONFIG + AAI_FILESEP + "etc" + AAI_FILESEP; - public static final String AAI_HOME_ETC_APP_PROPERTIES = AAI_HOME_ETC + "appprops" + AAI_FILESEP; - public static final String AAI_HOME_ETC_AUTH = AAI_HOME_ETC + "auth" + AAI_FILESEP; - public static final String AAI_CONFIG_FILENAME = AAI_HOME_ETC_APP_PROPERTIES + "aaiconfig.properties"; - public static final String AAI_AUTH_CONFIG_FILENAME = AAI_HOME_ETC_AUTH + "aai_policy.json"; - public static final String REALTIME_DB_CONFIG = AAI_HOME_ETC_APP_PROPERTIES + "janusgraph-realtime.properties"; - public static final String CACHED_DB_CONFIG = AAI_HOME_ETC_APP_PROPERTIES + "janusgraph-cached.properties"; - public static final String AAI_HOME_ETC_OXM = AAI_HOME_ETC + "oxm" + AAI_FILESEP; - public static final String AAI_EVENT_DMAAP_PROPS = AAI_HOME_ETC_APP_PROPERTIES + "aaiEventDMaaPPublisher.properties"; - public static final String AAI_HOME_ETC_SCRIPT = AAI_HOME_ETC + AAI_FILESEP + "scriptdata" + AAI_FILESEP; - - public static final String AAI_LOGBACK_PROPS = "logback.xml"; - public static final String AAI_SCHEMA_MOD_LOGBACK_PROPS = "schemaMod-logback.xml"; - public static final String AAI_FORCE_DELETE_LOGBACK_PROPS = "forceDelete-logback.xml"; - - public static final String AAI_TRUSTSTORE_FILENAME = "aai.truststore.filename"; - public static final String AAI_TRUSTSTORE_PASSWD = "aai.truststore.passwd"; - public static final String AAI_KEYSTORE_FILENAME = "aai.keystore.filename"; - public static final String AAI_KEYSTORE_PASSWD = "aai.keystore.passwd"; - - public static final String AAI_SERVER_URL_BASE = "aai.server.url.base"; - public static final String AAI_SERVER_URL = "aai.server.url"; - public static final String AAI_OLDSERVER_URL = "aai.oldserver.url"; - public static final String AAI_LOCAL_REST = "https://localhost:%d/aai/%s/"; - - public static final int AAI_RESOURCES_PORT = 8447; - public static final int AAI_QUERY_PORT = 8446; - public static final int AAI_LEGACY_PORT = 8443; - - public static final String AAI_DEFAULT_API_VERSION = "v7"; - public static final String AAI_DEFAULT_API_VERSION_PROP = "aai.default.api.version"; - public static final String AAI_NOTIFICATION_CURRENT_VERSION = "aai.notification.current.version"; - + private static final String AJSC_HOME = "AJSC_HOME"; + // + // + /** Default to unix file separator if system property file.separator is null */ + public static final String AAI_FILESEP = (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator"); + // + /** Default to opt aai if system property aai.home is null, using file.separator */ + public static final String AAI_HOME = (System.getProperty(AJSC_HOME) == null) ? AAI_FILESEP + "opt" + AAI_FILESEP + "app" + AAI_FILESEP +"aai" : System.getProperty(AJSC_HOME); + public static final String AAI_BUNDLECONFIG_NAME = (System.getProperty("BUNDLECONFIG_DIR") == null) ? "bundleconfig" : System.getProperty("BUNDLECONFIG_DIR"); + public static final String AAI_HOME_BUNDLECONFIG = (System.getProperty(AJSC_HOME) == null) ? AAI_FILESEP + "opt" + AAI_FILESEP + "app" + AAI_FILESEP + "aai" + AAI_FILESEP + AAI_BUNDLECONFIG_NAME : System.getProperty(AJSC_HOME)+ AAI_FILESEP + AAI_BUNDLECONFIG_NAME; + + /** etc directory, relative to AAI_HOME */ + public static final String AAI_HOME_ETC = AAI_HOME_BUNDLECONFIG + AAI_FILESEP + "etc" + AAI_FILESEP; + public static final String AAI_HOME_ETC_APP_PROPERTIES = AAI_HOME_ETC + "appprops" + AAI_FILESEP; + public static final String AAI_HOME_ETC_AUTH = AAI_HOME_ETC + "auth" + AAI_FILESEP; + public static final String AAI_CONFIG_FILENAME = AAI_HOME_ETC_APP_PROPERTIES + "aaiconfig.properties"; + public static final String AAI_AUTH_CONFIG_FILENAME = AAI_HOME_ETC_AUTH + "aai_policy.json"; + public static final String REALTIME_DB_CONFIG = AAI_HOME_ETC_APP_PROPERTIES + "janusgraph-realtime.properties"; + public static final String CACHED_DB_CONFIG = AAI_HOME_ETC_APP_PROPERTIES + "janusgraph-cached.properties"; + public static final String AAI_HOME_ETC_OXM = AAI_HOME_ETC + "oxm" + AAI_FILESEP; + public static final String AAI_EVENT_DMAAP_PROPS = AAI_HOME_ETC_APP_PROPERTIES + "aaiEventDMaaPPublisher.properties"; + public static final String AAI_HOME_ETC_SCRIPT = AAI_HOME_ETC + AAI_FILESEP + "scriptdata" + AAI_FILESEP; + + public static final String AAI_LOGBACK_PROPS = "logback.xml"; + public static final String AAI_SCHEMA_MOD_LOGBACK_PROPS = "schemaMod-logback.xml"; + public static final String AAI_FORCE_DELETE_LOGBACK_PROPS = "forceDelete-logback.xml"; + + public static final String AAI_TRUSTSTORE_FILENAME = "aai.truststore.filename"; + public static final String AAI_TRUSTSTORE_PASSWD = "aai.truststore.passwd"; + public static final String AAI_KEYSTORE_FILENAME = "aai.keystore.filename"; + public static final String AAI_KEYSTORE_PASSWD = "aai.keystore.passwd"; + + public static final String AAI_SERVER_URL_BASE = "aai.server.url.base"; + public static final String AAI_SERVER_URL = "aai.server.url"; + public static final String AAI_OLDSERVER_URL = "aai.oldserver.url"; + public static final String AAI_LOCAL_REST = "https://localhost:%d/aai/%s/"; + + public static final int AAI_RESOURCES_PORT = 8447; + public static final int AAI_QUERY_PORT = 8446; + public static final int AAI_LEGACY_PORT = 8443; + + public static final String AAI_DEFAULT_API_VERSION = "v7"; + public static final String AAI_DEFAULT_API_VERSION_PROP = "aai.default.api.version"; + public static final String AAI_NOTIFICATION_CURRENT_VERSION = "aai.notification.current.version"; + public static final String AAI_NODENAME = "aai.config.nodename"; - public static final String AAI_BULKCONSUMER_LIMIT = "aai.bulkconsumer.payloadlimit"; - public static final String AAI_BULKCONSUMER_OVERRIDE_LIMIT = "aai.bulkconsumer.payloadoverride"; + public static final String AAI_BULKCONSUMER_LIMIT = "aai.bulkconsumer.payloadlimit"; + public static final String AAI_BULKCONSUMER_OVERRIDE_LIMIT = "aai.bulkconsumer.payloadoverride"; - public static final String AAI_TRAVERSAL_TIMEOUT_LIMIT = "aai.traversal.timeoutlimit"; - public static final String AAI_TRAVERSAL_TIMEOUT_ENABLED = "aai.traversal.timeoutenabled"; - public static final String AAI_TRAVERSAL_TIMEOUT_APP = "aai.traversal.timeout.appspecific"; + public static final String AAI_TRAVERSAL_TIMEOUT_LIMIT = "aai.traversal.timeoutlimit"; + public static final String AAI_TRAVERSAL_TIMEOUT_ENABLED = "aai.traversal.timeoutenabled"; + public static final String AAI_TRAVERSAL_TIMEOUT_APP = "aai.traversal.timeout.appspecific"; - public static final String AAI_GRAPHADMIN_TIMEOUT_LIMIT = "aai.graphadmin.timeoutlimit"; - public static final String AAI_GRAPHADMIN_TIMEOUT_ENABLED = "aai.graphadmin.timeoutenabled"; - public static final String AAI_GRAPHADMIN_TIMEOUT_APP = "aai.graphadmin.timeout.appspecific"; + public static final String AAI_GRAPHADMIN_TIMEOUT_LIMIT = "aai.graphadmin.timeoutlimit"; + public static final String AAI_GRAPHADMIN_TIMEOUT_ENABLED = "aai.graphadmin.timeoutenabled"; + public static final String AAI_GRAPHADMIN_TIMEOUT_APP = "aai.graphadmin.timeout.appspecific"; - public static final String AAI_CRUD_TIMEOUT_LIMIT = "aai.crud.timeoutlimit"; - public static final String AAI_CRUD_TIMEOUT_ENABLED = "aai.crud.timeoutenabled"; - public static final String AAI_CRUD_TIMEOUT_APP = "aai.crud.timeout.appspecific"; + public static final String AAI_CRUD_TIMEOUT_LIMIT = "aai.crud.timeoutlimit"; + public static final String AAI_CRUD_TIMEOUT_ENABLED = "aai.crud.timeoutenabled"; + public static final String AAI_CRUD_TIMEOUT_APP = "aai.crud.timeout.appspecific"; public static final String AAI_RESVERSION_ENABLEFLAG = "aai.resourceversion.enableflag"; - 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; - + 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; + public static final long HISTORY_MAX_HOURS = 192; - - public static final String LOGGING_MAX_STACK_TRACE_ENTRIES = "aai.logging.maxStackTraceEntries"; - - /*** UEB ***/ - public static final String UEB_PUB_PARTITION_AAI = "AAI"; - - /** Micro-service Names */ - public static final String AAI_TRAVERSAL_MS = "aai-traversal"; - public static final String AAI_RESOURCES_MS = "aai-resources"; - /** - * Instantiates a new AAI constants. - */ - private AAIConstants() { - // prevent instantiation - } + + public static final String LOGGING_MAX_STACK_TRACE_ENTRIES = "aai.logging.maxStackTraceEntries"; + + /*** UEB ***/ + public static final String UEB_PUB_PARTITION_AAI = "AAI"; + + /** Micro-service Names */ + public static final String AAI_TRAVERSAL_MS = "aai-traversal"; + public static final String AAI_RESOURCES_MS = "aai-resources"; + /** + * Instantiates a new AAI constants. + */ + private AAIConstants() { + // prevent instantiation + } } diff --git a/aai-core/src/main/java/org/onap/aai/util/AAIUtils.java b/aai-core/src/main/java/org/onap/aai/util/AAIUtils.java index ce53d86e..ba2cf9e2 100644 --- a/aai-core/src/main/java/org/onap/aai/util/AAIUtils.java +++ b/aai-core/src/main/java/org/onap/aai/util/AAIUtils.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright © 2018 IBM. + * ================================================================================ * 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 @@ -26,27 +28,34 @@ import java.util.Date; import java.util.TimeZone; public class AAIUtils { + + /** + * Instantiates AAIUtils. + */ + private AAIUtils() { + // prevent instantiation + } - /** - * Null check. - * - * @param <T> the generic type - * @param iterable the iterable - * @return the iterable - */ - public static <T> Iterable<T> nullCheck(Iterable<T> iterable) { - return iterable == null ? Collections.<T>emptyList() : iterable; - } + /** + * Null check. + * + * @param <T> the generic type + * @param iterable the iterable + * @return the iterable + */ + public static <T> Iterable<T> nullCheck(Iterable<T> iterable) { + return iterable == null ? Collections.<T>emptyList() : iterable; + } - /** - * Gen date. - * - * @return the string - */ - public static String genDate() { - Date date = new Date(); - DateFormat formatter = new SimpleDateFormat("YYMMdd-HH:mm:ss:SSS"); - formatter.setTimeZone(TimeZone.getTimeZone("GMT")); - return formatter.format(date); - } + /** + * Gen date. + * + * @return the string + */ + public static String genDate() { + Date date = new Date(); + DateFormat formatter = new SimpleDateFormat("YYMMdd-HH:mm:ss:SSS"); + formatter.setTimeZone(TimeZone.getTimeZone("GMT")); + return formatter.format(date); + } } diff --git a/aai-core/src/main/java/org/onap/aai/util/MapperUtil.java b/aai-core/src/main/java/org/onap/aai/util/MapperUtil.java index 70534d82..4fed0666 100644 --- a/aai-core/src/main/java/org/onap/aai/util/MapperUtil.java +++ b/aai-core/src/main/java/org/onap/aai/util/MapperUtil.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright © 2018 IBM. + * ================================================================================ * 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 @@ -26,7 +28,13 @@ import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; public class MapperUtil { - + /** + * Instantiates MapperUtil. + */ + private MapperUtil() { + // prevent instantiation + } + /** * Read as object of. * @@ -37,9 +45,9 @@ public class MapperUtil { * @throws AAIException the AAI exception */ public static <T> T readAsObjectOf(Class<T> clazz, String value) throws AAIException { - ObjectMapper MAPPER = new ObjectMapper(); + ObjectMapper mapper = new ObjectMapper(); try { - return MAPPER.readValue(value, clazz); + return mapper.readValue(value, clazz); } catch (Exception e) { throw new AAIException("AAI_4007", e); } @@ -55,13 +63,13 @@ public class MapperUtil { * @throws AAIException the AAI exception */ public static <T> T readWithDashesAsObjectOf(Class<T> clazz, String value) throws AAIException { - ObjectMapper MAPPER = new ObjectMapper(); + ObjectMapper mapper = new ObjectMapper(); try { - MAPPER.registerModule(new JaxbAnnotationModule()); - MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - MAPPER.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false); + mapper.registerModule(new JaxbAnnotationModule()); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false); - return MAPPER.readValue(value, clazz); + return mapper.readValue(value, clazz); } catch (Exception e) { throw new AAIException("AAI_4007", e); } @@ -75,10 +83,9 @@ public class MapperUtil { * @throws AAIException the AAI exception */ public static String writeAsJSONString(Object obj) throws AAIException { - ObjectMapper MAPPER = new ObjectMapper(); + ObjectMapper mapper = new ObjectMapper(); try { - String s = MAPPER.writeValueAsString(obj); - return s; + return mapper.writeValueAsString(obj); } catch (Exception e) { throw new AAIException("AAI_4008", e); } @@ -92,20 +99,19 @@ public class MapperUtil { * @throws AAIException the AAI exception */ public static String writeAsJSONStringWithDashes(Object obj) throws AAIException { - ObjectMapper MAPPER = new ObjectMapper(); + ObjectMapper mapper = new ObjectMapper(); try { - MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - MAPPER.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); - MAPPER.configure(SerializationFeature.INDENT_OUTPUT, false); - MAPPER.configure(SerializationFeature.WRAP_ROOT_VALUE, false); + mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); + mapper.configure(SerializationFeature.INDENT_OUTPUT, false); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false); - MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - MAPPER.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false); - MAPPER.registerModule(new JaxbAnnotationModule()); - String s = MAPPER.writeValueAsString(obj); - return s; + mapper.registerModule(new JaxbAnnotationModule()); + return mapper.writeValueAsString(obj); } catch (Exception e) { throw new AAIException("AAI_4008", e); } |