aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/music/rest/RestMusicLocksAPI.java
diff options
context:
space:
mode:
authorThomas Nelson Jr (arthurdent3) tn1381@att.com <tn1381@att.com>2018-03-22 00:25:28 -0400
committerThomas Nelson Jr (arthurdent3) tn1381@att.com <tn1381@att.com>2018-03-22 00:25:28 -0400
commitde47cea9e656dabfbf3608287238041ab263f05e (patch)
treea05e73a52dd1ff7458ffbc9c341c42a7bc052f0b /src/main/java/org/onap/music/rest/RestMusicLocksAPI.java
parente0a891de60058eab2b92082f7cc2dde59f0f42be (diff)
Fix for HAS to run its CSIT
Default action of AID(AuthID) was to allow only one keyspace. HAS required the ability to create more than one. Also included are some Logging and response fixes. Change-Id: I30b7d0f5a5c6e535ff2b737dc58b8d4fbd427d02 Issue-ID: MUSIC-64, OPTFRA-191 Signed-off-by: Thomas Nelson Jr (arthurdent3) tn1381@att.com <tn1381@att.com>
Diffstat (limited to 'src/main/java/org/onap/music/rest/RestMusicLocksAPI.java')
-rw-r--r--src/main/java/org/onap/music/rest/RestMusicLocksAPI.java58
1 files changed, 47 insertions, 11 deletions
diff --git a/src/main/java/org/onap/music/rest/RestMusicLocksAPI.java b/src/main/java/org/onap/music/rest/RestMusicLocksAPI.java
index d871a507..da94f9d2 100644
--- a/src/main/java/org/onap/music/rest/RestMusicLocksAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicLocksAPI.java
@@ -90,6 +90,8 @@ public class RestMusicLocksAPI {
response.addHeader(xLatestVersion,MusicUtil.getVersion());
Map<String, Object> resultMap = MusicCore.validateLock(lockName);
if (resultMap.containsKey("Exception")) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
return resultMap;
}
String keyspaceName = (String) resultMap.get("keyspace");
@@ -99,14 +101,18 @@ public class RestMusicLocksAPI {
if (resultMap.containsKey("aid"))
resultMap.remove("aid");
if (!resultMap.isEmpty()) {
- return resultMap;
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.CRITICAL, ErrorTypes.AUTHENTICATIONERROR);
+ response.setStatus(401);
+ return resultMap;
}
ResultType status = ResultType.SUCCESS;
String lockId = MusicCore.createLockReference(lockName);
if (lockId == null) {
status = ResultType.FAILURE;
- response.setStatus(400);
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.LOCKINGERROR ,ErrorSeverity.CRITICAL, ErrorTypes.LOCKINGERROR);
+ response.setStatus(400);
+ return new JsonResponse(status).setError("Lock Id is null").toMap();
}
return new JsonResponse(status).setLock(lockId).toMap();
}
@@ -138,6 +144,8 @@ public class RestMusicLocksAPI {
response.addHeader(xLatestVersion,MusicUtil.getVersion());
Map<String, Object> resultMap = MusicCore.validateLock(lockId);
if (resultMap.containsKey("Exception")) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
return resultMap;
}
String keyspaceName = (String) resultMap.get("keyspace");
@@ -147,7 +155,9 @@ public class RestMusicLocksAPI {
if (resultMap.containsKey("aid"))
resultMap.remove("aid");
if (!resultMap.isEmpty()) {
- return resultMap;
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
+ return resultMap;
}
try {
String lockName = lockId.substring(lockId.indexOf('$')+1, lockId.lastIndexOf('$'));
@@ -183,6 +193,8 @@ public class RestMusicLocksAPI {
response.addHeader(xLatestVersion,MusicUtil.getVersion());
Map<String, Object> resultMap = MusicCore.validateLock(lockId);
if (resultMap.containsKey("Exception")) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
return resultMap;
}
String keyspaceName = (String) resultMap.get("keyspace");
@@ -193,6 +205,7 @@ public class RestMusicLocksAPI {
if (resultMap.containsKey("aid"))
resultMap.remove("aid");
if (!resultMap.isEmpty()) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
response.setStatus(400);
return resultMap;
}
@@ -223,6 +236,8 @@ public class RestMusicLocksAPI {
response.addHeader(xLatestVersion,MusicUtil.getVersion());
Map<String, Object> resultMap = MusicCore.validateLock(lockName);
if (resultMap.containsKey("Exception")) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
return resultMap;
}
String keyspaceName = (String) resultMap.get("keyspace");
@@ -232,7 +247,9 @@ public class RestMusicLocksAPI {
if (resultMap.containsKey("aid"))
resultMap.remove("aid");
if (!resultMap.isEmpty()) {
- return resultMap;
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
+ return resultMap;
}
String who = MusicCore.whoseTurnIsIt(lockName);
ResultType status = ResultType.SUCCESS;
@@ -240,7 +257,10 @@ public class RestMusicLocksAPI {
if ( who == null ) {
status = ResultType.FAILURE;
error = "There was a problem getting the lock holder";
- response.setStatus(400);
+ logger.error(EELFLoggerDelegate.errorLogger,"There was a problem getting the lock holder", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
+ return new JsonResponse(status).setError(error)
+ .setLock(lockName).setLockHolder(who).toMap();
}
return new JsonResponse(status).setError(error)
.setLock(lockName).setLockHolder(who).toMap();
@@ -265,6 +285,8 @@ public class RestMusicLocksAPI {
response.addHeader(xLatestVersion,MusicUtil.getVersion());
Map<String, Object> resultMap = MusicCore.validateLock(lockName);
if (resultMap.containsKey("Exception")) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
return resultMap;
}
String keyspaceName = (String) resultMap.get("keyspace");
@@ -275,8 +297,9 @@ public class RestMusicLocksAPI {
if (resultMap.containsKey("aid"))
resultMap.remove("aid");
if (!resultMap.isEmpty()) {
- response.setStatus(400);
- return resultMap;
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
+ return resultMap;
}
MusicLockState mls = MusicCore.getMusicLockState(lockName);
@@ -285,12 +308,15 @@ public class RestMusicLocksAPI {
if(mls == null) {
jsonResponse.setError("");
jsonResponse.setMessage("No lock object created yet..");
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
+ return jsonResponse.toMap();
} else {
jsonResponse.setStatus(ResultType.SUCCESS);
jsonResponse.setLockStatus(mls.getLockStatus());
jsonResponse.setLockHolder(mls.getLockHolder());
+ return jsonResponse.toMap();
}
- return jsonResponse.toMap();
}
/**
@@ -318,6 +344,8 @@ public class RestMusicLocksAPI {
response.addHeader(xLatestVersion,MusicUtil.getVersion());
Map<String, Object> resultMap = MusicCore.validateLock(lockId);
if (resultMap.containsKey("Exception")) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
return resultMap;
}
String keyspaceName = (String) resultMap.get("keyspace");
@@ -327,13 +355,16 @@ public class RestMusicLocksAPI {
if (resultMap.containsKey("aid"))
resultMap.remove("aid");
if (!resultMap.isEmpty()) {
- response.setStatus(400);
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
return resultMap;
}
boolean voluntaryRelease = true;
MusicLockState mls = MusicCore.releaseLock(lockId,voluntaryRelease);
if(mls.getErrorMessage() != null) {
resultMap.put(ResultType.EXCEPTION.getResult(), mls.getErrorMessage());
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
return resultMap;
}
Map<String,Object> returnMap = null;
@@ -342,6 +373,8 @@ public class RestMusicLocksAPI {
.setLockStatus(mls.getLockStatus()).toMap();
}
if (mls.getLockStatus() == MusicLockState.LockStatus.LOCKED) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.LOCKINGERROR ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
returnMap = new JsonResponse(ResultType.FAILURE).setLock(lockId)
.setLockStatus(mls.getLockStatus()).toMap();
}
@@ -369,6 +402,8 @@ public class RestMusicLocksAPI {
response.addHeader(xLatestVersion,MusicUtil.getVersion());
Map<String, Object> resultMap = MusicCore.validateLock(lockName);
if (resultMap.containsKey("Exception")) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.UNKNOWNERROR ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
return resultMap;
}
String keyspaceName = (String) resultMap.get("keyspace");
@@ -378,8 +413,9 @@ public class RestMusicLocksAPI {
if (resultMap.containsKey("aid"))
resultMap.remove("aid");
if (!resultMap.isEmpty()) {
- response.setStatus(400);
- return resultMap;
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.UNKNOWNERROR ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
+ return resultMap;
}
MusicCore.deleteLock(lockName);
return new JsonResponse(ResultType.SUCCESS).toMap();