From 280f8015d06af1f41a3ef12e8300801c7a5e0d54 Mon Sep 17 00:00:00 2001 From: AviZi Date: Fri, 9 Jun 2017 02:39:56 +0300 Subject: [SDC-29] Amdocs OnBoard 1707 initial commit. Change-Id: Ie4d12a3f574008b792899b368a0902a8b46b5370 Signed-off-by: AviZi --- .../openecomp-nosqldb-api/pom.xml | 19 +++++---- .../openecomp-nosqldb-api/pom.xml.versionsBackup | 45 ++++++++++++++++++++++ .../org/openecomp/core/util/UniqueValueUtil.java | 41 +++++++++++++++++--- 3 files changed, 92 insertions(+), 13 deletions(-) create mode 100644 openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/pom.xml.versionsBackup (limited to 'openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api') diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/pom.xml b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/pom.xml index 4ff52e5e33..bce553cfde 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/pom.xml +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/pom.xml @@ -2,6 +2,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + openecomp-nosqldb-api + openecomp-nosqldb-api + org.openecomp.core + openecomp-sdc-lib org.openecomp.sdc @@ -9,13 +13,9 @@ ../../.. - openecomp-nosqldb-api - openecomp-nosqldb-api - - - org.openecomp.sdc + org.openecomp.core openecomp-facade-api ${project.version} @@ -30,11 +30,16 @@ ${datasatx.version} - org.openecomp.sdc + org.openecomp.core openecomp-facade-core ${project.version} + + org.openecomp.sdc + openecomp-sdc-logging-core + ${project.version} + - \ No newline at end of file + diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/pom.xml.versionsBackup b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/pom.xml.versionsBackup new file mode 100644 index 0000000000..288274d728 --- /dev/null +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/pom.xml.versionsBackup @@ -0,0 +1,45 @@ + + 4.0.0 + + openecomp-nosqldb-api + openecomp-nosqldb-api + org.openecomp.core + + + openecomp-sdc-lib + org.openecomp.sdc + 1.0-SNAPSHOT + ../../.. + + + + + org.openecomp.core + openecomp-facade-api + 1.0-SNAPSHOT + + + com.datastax.cassandra + cassandra-driver-core + ${datasatx.version} + + + com.datastax.cassandra + cassandra-driver-mapping + ${datasatx.version} + + + org.openecomp.core + openecomp-facade-core + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-logging-core + 1.0-SNAPSHOT + + + + + \ No newline at end of file diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/src/main/java/org/openecomp/core/util/UniqueValueUtil.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/src/main/java/org/openecomp/core/util/UniqueValueUtil.java index a82c97c51c..d2dee5e512 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/src/main/java/org/openecomp/core/util/UniqueValueUtil.java +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/src/main/java/org/openecomp/core/util/UniqueValueUtil.java @@ -27,21 +27,18 @@ import org.openecomp.core.utilities.CommonMethods; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; +import org.openecomp.sdc.common.utils.CommonUtil; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; import java.util.Optional; -/** - * The type Unique value util. - */ public class UniqueValueUtil { - /** - * The constant UNIQUE_VALUE_VIOLATION. - */ public static final String UNIQUE_VALUE_VIOLATION = "UNIQUE_VALUE_VIOLATION"; private static final String UNIQUE_VALUE_VIOLATION_MSG = "%s with the value '%s' already exists."; private static final UniqueValueDao uniqueValueDao = UniqueValueDaoFactory.getInstance().createInterface(); + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); /** * Create unique value. @@ -50,12 +47,18 @@ public class UniqueValueUtil { * @param uniqueCombination the unique combination */ public static void createUniqueValue(String type, String... uniqueCombination) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + Optional value = formatValue(uniqueCombination); if (!value.isPresent()) { return; } validateUniqueValue(type, value.get(), uniqueCombination); uniqueValueDao.create(new UniqueValueEntity(type, value.get())); + + mdcDataDebugMessage.debugExitMessage(null, null); } /** @@ -65,11 +68,17 @@ public class UniqueValueUtil { * @param uniqueCombination the unique combination */ public static void deleteUniqueValue(String type, String... uniqueCombination) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + Optional value = formatValue(uniqueCombination); if (!value.isPresent()) { return; } uniqueValueDao.delete(new UniqueValueEntity(type, value.get())); + + mdcDataDebugMessage.debugExitMessage(null, null); } /** @@ -82,12 +91,18 @@ public class UniqueValueUtil { */ public static void updateUniqueValue(String type, String oldValue, String newValue, String... uniqueContext) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + if ((newValue != null && oldValue != null && !newValue.toLowerCase().equals(oldValue.toLowerCase())) || newValue == null || oldValue == null) { createUniqueValue(type, CommonMethods.concat(uniqueContext, new String[]{newValue})); deleteUniqueValue(type, CommonMethods.concat(uniqueContext, new String[]{oldValue})); } + + mdcDataDebugMessage.debugExitMessage(null, null); } /** @@ -97,14 +112,20 @@ public class UniqueValueUtil { * @param uniqueCombination the unique combination */ public static void validateUniqueValue(String type, String... uniqueCombination) { + mdcDataDebugMessage.debugEntryMessage(null, null); + Optional value = formatValue(uniqueCombination); if (!value.isPresent()) { return; } validateUniqueValue(type, value.get(), uniqueCombination); + + mdcDataDebugMessage.debugExitMessage(null, null); } private static void validateUniqueValue(String type, String value, String... uniqueCombination) { + mdcDataDebugMessage.debugEntryMessage(null, null); + if (uniqueValueDao.get(new UniqueValueEntity(type, value)) != null) { throw new CoreException(new ErrorCode.ErrorCodeBuilder() .withCategory(ErrorCategory.APPLICATION) @@ -112,9 +133,15 @@ public class UniqueValueUtil { .withMessage(String.format(UNIQUE_VALUE_VIOLATION_MSG, type, uniqueCombination[uniqueCombination.length - 1])).build()); } + + mdcDataDebugMessage.debugExitMessage(null, null); } private static Optional formatValue(String[] uniqueCombination) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + if (uniqueCombination == null || uniqueCombination.length == 0 || uniqueCombination[uniqueCombination.length - 1] == null) { return Optional.empty(); @@ -122,6 +149,8 @@ public class UniqueValueUtil { uniqueCombination[uniqueCombination.length - 1] = uniqueCombination[uniqueCombination.length - 1].toLowerCase(); + + mdcDataDebugMessage.debugExitMessage(null, null); return Optional.of(CommonMethods.arrayToSeparatedString(uniqueCombination, '_')); } } -- cgit 1.2.3-korg