From d6e7b63cc580e7b3822be61fe92a493ad5e222a3 Mon Sep 17 00:00:00 2001 From: "Nelson, Thomas (arthurdent3)" Date: Thu, 9 May 2019 14:16:37 +0000 Subject: Changes Listed below: - Added build version API - Updated Keyspace active to use Properties setting - Update Libraries Netty,jbcrypt,Jackson Databind and log4j - Removed some irrelivant files - Updated some usint tests to ignore some tests(This will be updated soon) - Bugfixes - Missing Values, inform user. - Respond with proper error - Fix Locking Contention issue. - Add locking retry for atomic calls. Change-Id: Ie218dd92edb0c20e4a0efe33eeaaec84e5293c44 Issue-ID: MUSIC-393 Signed-off-by: Nelson, Thomas (arthurdent3) --- .../conductor/conditionals/MusicConditional.java | 31 +++++++++++++--------- .../conditionals/RestMusicConditionalAPI.java | 7 +++-- 2 files changed, 22 insertions(+), 16 deletions(-) (limited to 'src/main/java/org/onap/music/conductor') diff --git a/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java b/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java index 69ccd104..29740d83 100644 --- a/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java +++ b/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java @@ -92,7 +92,12 @@ public class MusicConditional { String key = keyspace + "." + tablename + "." + primaryKey; - String lockId = MusicCore.createLockReference(key); + String lockId; + try { + lockId = MusicCore.createLockReference(key); + } catch (MusicLockingException e) { + return new ReturnType(ResultType.FAILURE, e.getMessage()); + } long leasePeriod = MusicUtil.getDefaultLockLeasePeriod(); ReturnType lockAcqResult = MusicCore.acquireLockWithLease(key, lockId, leasePeriod); @@ -160,7 +165,10 @@ public class MusicConditional { } - public static ReturnType update(Map queryBank, String keyspace, String tableName, String primaryKey,String primaryKeyValue,String planId,String cascadeColumnName,Map cascadeColumnValues) throws MusicLockingException, MusicQueryException, MusicServiceException { + public static ReturnType update(Map queryBank, String keyspace, String tableName, + String primaryKey, String primaryKeyValue, String planId, String cascadeColumnName, + Map cascadeColumnValues) + throws MusicLockingException, MusicQueryException, MusicServiceException { String key = keyspace + "." + tableName + "." + primaryKeyValue; String lockId = MusicCore.createLockReference(key); @@ -266,8 +274,8 @@ public class MusicConditional { queryObject.addValue(vector); if(casscadeColumn!=null && casscadeColumnValues!=null) { fieldsString.append(casscadeColumn).append(" ,"); - valueString.append("?,"); - queryObject.addValue(casscadeColumnValues); + valueString.append("?,"); + queryObject.addValue(casscadeColumnValues); } int counter = 0; @@ -276,24 +284,23 @@ public class MusicConditional { fieldsString.append(entry.getKey()); Object valueObj = entry.getValue(); if (primaryKeyName.equals(entry.getKey())) { - localPrimaryKey = entry.getValue() + ""; - localPrimaryKey = localPrimaryKey.replace("'", "''"); + localPrimaryKey = entry.getValue() + ""; + localPrimaryKey = localPrimaryKey.replace("'", "''"); } DataType colType = null; try { colType = tableInfo.getColumn(entry.getKey()).getType(); } catch(NullPointerException ex) { - logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage() +" Invalid column name : "+entry.getKey - (), AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR, ex); - + logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage() +" Invalid column name : "+entry.getKey(), + AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR, ex); } Object formattedValue = null; try { - formattedValue = MusicUtil.convertToActualDataType(colType, valueObj); + formattedValue = MusicUtil.convertToActualDataType(colType, valueObj); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), e); - } + logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), e); + } valueString.append("?"); queryObject.addValue(formattedValue); diff --git a/src/main/java/org/onap/music/conductor/conditionals/RestMusicConditionalAPI.java b/src/main/java/org/onap/music/conductor/conditionals/RestMusicConditionalAPI.java index 20fd3150..4a56825a 100644 --- a/src/main/java/org/onap/music/conductor/conditionals/RestMusicConditionalAPI.java +++ b/src/main/java/org/onap/music/conductor/conditionals/RestMusicConditionalAPI.java @@ -65,13 +65,13 @@ import io.swagger.annotations.ApiParam; @Path("/v2/conditional") @Api(value = "Conditional Api", hidden = true) -public class RestMusicConditionalAPI { + public class RestMusicConditionalAPI { private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RestMusicAdminAPI.class); private static final String XMINORVERSION = "X-minorVersion"; private static final String XPATCHVERSION = "X-patchVersion"; private static final String NS = "ns"; private static final String VERSION = "v2"; - + private MusicAuthenticator authenticator = new MusicAAFAuthentication(); @POST @@ -146,7 +146,7 @@ public class RestMusicConditionalAPI { @ApiParam(value = "Major Version", required = true) @PathParam("tablename") String tablename, JsonConditional upObj) throws Exception { ResponseBuilder response = MusicUtil.buildVersionResponse(VERSION, minorVersion, patchVersion); - + if (!authenticator.authenticateUser(ns, authorization, keyspace, aid, Operation.INSERT_INTO_TABLE)) { return response.status(Status.UNAUTHORIZED) .entity(new JsonResponse(ResultType.FAILURE) @@ -188,7 +188,6 @@ public class RestMusicConditionalAPI { if (result.getResult() == ResultType.SUCCESS) { return response.status(Status.OK) .entity(new JsonResponse(result.getResult()).setMessage(result.getMessage()).toMap()).build(); - } return response.status(Status.BAD_REQUEST) .entity(new JsonResponse(result.getResult()).setMessage(result.getMessage()).toMap()).build(); -- cgit 1.2.3-korg