aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xpom.xml2
-rwxr-xr-xsrc/main/java/org/onap/music/main/CachingUtil.java127
-rw-r--r--src/main/java/org/onap/music/main/MusicCore.java19
-rwxr-xr-xsrc/main/java/org/onap/music/rest/RestMusicAdminAPI.java18
-rwxr-xr-xsrc/main/java/org/onap/music/rest/RestMusicDataAPI.java107
-rw-r--r--src/main/java/org/onap/music/rest/RestMusicLocksAPI.java58
-rwxr-xr-xsrc/main/java/org/onap/music/rest/RestMusicQAPI.java2
-rw-r--r--src/test/java/org/onap/music/unittests/TestRestMusicData.java14
-rw-r--r--version.properties2
9 files changed, 231 insertions, 118 deletions
diff --git a/pom.xml b/pom.xml
index 1d3f87e7..b81e6ec3 100755
--- a/pom.xml
+++ b/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.onap.music</groupId>
<artifactId>MUSIC</artifactId>
<packaging>war</packaging>
- <version>2.4.20</version>
+ <version>2.4.22</version>
<description>
This is the MUSIC REST interface, packaged as a war file.
</description>
diff --git a/src/main/java/org/onap/music/main/CachingUtil.java b/src/main/java/org/onap/music/main/CachingUtil.java
index 2c46efbc..2a105c24 100755
--- a/src/main/java/org/onap/music/main/CachingUtil.java
+++ b/src/main/java/org/onap/music/main/CachingUtil.java
@@ -62,6 +62,7 @@ public class CachingUtil implements Runnable {
private static CacheAccess<String, String> musicCache = JCS.getInstance("musicCache");
private static CacheAccess<String, Map<String, String>> aafCache = JCS.getInstance("aafCache");
private static CacheAccess<String, String> appNameCache = JCS.getInstance("appNameCache");
+ private static CacheAccess<String, Map<String, String>> musicValidateCache = JCS.getInstance("musicValidateCache");
private static Map<String, Number> userAttempts = new HashMap<>();
private static Map<String, Calendar> lastFailedTime = new HashMap<>();
@@ -104,7 +105,7 @@ public class CachingUtil implements Runnable {
map = new HashMap<>();
map.put(userId, password);
aafCache.put(nameSpace, map);
- musicCache.put(nameSpace, keySpace);
+ musicCache.put(keySpace, nameSpace);
logger.debug("Cronjob: Cache Updated with AAF response for namespace "
+ nameSpace);
}
@@ -131,7 +132,7 @@ public class CachingUtil implements Runnable {
String keySpace) throws Exception {
if (aafCache.get(nameSpace) != null) {
- if (keySpace != null && !musicCache.get(nameSpace).equals(keySpace)) {
+ if (keySpace != null && !musicCache.get(keySpace).equals(nameSpace)) {
logger.info(EELFLoggerDelegate.applicationLogger,"Create new application for the same namespace.");
} else if (aafCache.get(nameSpace).get(userId).equals(password)) {
logger.info(EELFLoggerDelegate.applicationLogger,"Authenticated with cache value..");
@@ -217,52 +218,18 @@ public class CachingUtil implements Runnable {
return responseObj;
}
- public static Map<String, Object> authenticateAIDUser(String aid, String keyspace)
- throws Exception {
- Map<String, Object> resultMap = new HashMap<>();
- String uuid = null;
- /*
- * if(aid == null || aid.length() == 0) { resultMap.put("Exception Message",
- * "AID is missing for the keyspace requested."); //create a new AID ?? } else
- */
- if (musicCache.get(keyspace) == null) {
- PreparedQueryObject pQuery = new PreparedQueryObject();
- pQuery.appendQueryString(
- "SELECT uuid from admin.keyspace_master where keyspace_name = '"
- + keyspace + "' allow filtering");
- Row rs = MusicCore.get(pQuery).one();
- try {
- uuid = rs.getUUID("uuid").toString();
- musicCache.put(keyspace, uuid);
- } catch (Exception e) {
- String msg = e.getMessage();
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), AppMessages.QUERYERROR,ErrorSeverity.ERROR, ErrorTypes.QUERYERROR);
- resultMap.put("Exception", "Unauthorized operation. Check AID and Keyspace. "
- + "Exception from MUSIC is: "
- + (msg == null ? "Keyspace is new so no AID should be passed in Header."
- : msg));
- return resultMap;
- }
- if (!musicCache.get(keyspace).toString().equals(aid)) {
- resultMap.put("Exception",
- "Unauthorized operation. Invalid AID for the keyspace");
- return resultMap;
- }
- } else if (musicCache.get(keyspace) != null
- && !musicCache.get(keyspace).toString().equals(aid)) {
- resultMap.put("Exception Message",
- "Unauthorized operation. Invalid AID for the keyspace");
- return resultMap;
- }
- resultMap.put("aid", uuid);
- return resultMap;
+ public static void updateMusicCache(String keyspace, String nameSpace) {
+ logger.info(EELFLoggerDelegate.applicationLogger,"Updating musicCache for keyspace " + keyspace + " with nameSpace " + nameSpace);
+ musicCache.put(keyspace, nameSpace);
}
- public static void updateMusicCache(String aid, String keyspace) {
- logger.info(EELFLoggerDelegate.applicationLogger,"Updating musicCache for keyspace " + keyspace + " with aid " + aid);
- musicCache.put(keyspace, aid);
+ public static void updateMusicValidateCache(String nameSpace, String userId, String password) {
+ logger.info(EELFLoggerDelegate.applicationLogger,"Updating musicCache for nameSpacce " + nameSpace + " with userId " + userId);
+ Map<String, String> map = new HashMap<>();
+ map.put(userId, password);
+ musicValidateCache.put(nameSpace, map);
}
-
+
public static void updateisAAFCache(String namespace, String isAAF) {
appNameCache.put(namespace, isAAF);
}
@@ -288,7 +255,7 @@ public class CachingUtil implements Runnable {
}
public static String getUuidFromMusicCache(String keyspace) throws MusicServiceException {
- String uuid = musicCache.get(keyspace);
+ String uuid = null;
if (uuid == null) {
PreparedQueryObject pQuery = new PreparedQueryObject();
pQuery.appendQueryString(
@@ -297,7 +264,6 @@ public class CachingUtil implements Runnable {
Row rs = MusicCore.get(pQuery).one();
try {
uuid = rs.getUUID("uuid").toString();
- musicCache.put(keyspace, uuid);
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger,"Exception occured during uuid retrieval from DB."+e.getMessage());
e.printStackTrace();
@@ -372,23 +338,70 @@ public class CachingUtil implements Runnable {
logger.error(EELFLoggerDelegate.errorLogger,"Application is not onboarded. Please contact admin.");
resultMap.put("Exception", "Application is not onboarded. Please contact admin.");
} else {
- if(!(rs.getString("username").equals(userId)) && !(rs.getString("password").equals("password"))) {
+ if(!(rs.getString("username").equals(userId)) || !(rs.getString("password").equals(password))) {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.AUTHENTICATIONERROR, ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
logger.error(EELFLoggerDelegate.errorLogger,"Namespace, UserId and password doesn't match. namespace: "+ns+" and userId: "+userId);
resultMap.put("Exception", "Namespace, UserId and password doesn't match. namespace: "+ns+" and userId: "+userId);
return resultMap;
}
- boolean is_aaf = rs.getBool("is_aaf");
- String keyspace = rs.getString("keyspace_name");
- if (!is_aaf) {
- if (!keyspace.equals(MusicUtil.DEFAULTKEYSPACENAME)) {
- logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.DATAERROR);
- logger.error(EELFLoggerDelegate.errorLogger,"Non AAF applications are allowed to have only one keyspace per application.");
- resultMap.put("Exception",
- "Non AAF applications are allowed to have only one keyspace per application.");
- }
+ }
+ return resultMap;
+ }
+
+ public static Map<String, Object> authenticateAIDUser(String nameSpace, String userId, String password,
+ String keyspace) {
+ Map<String, Object> resultMap = new HashMap<>();
+ if((musicCache.get(keyspace) != null) && (musicValidateCache.get(nameSpace) != null)
+ && (musicValidateCache.get(nameSpace).containsKey(userId))) {
+ if(!musicCache.get(keyspace).equals(nameSpace)) {
+ resultMap.put("Exception", "Namespace and keyspace doesn't match");
+ return resultMap;
+ }
+ if(!musicValidateCache.get(nameSpace).get(userId).equals(password)) {
+ resultMap.put("Exception", "Namespace, userId and password doesn't match");
+ return resultMap;
+ }
+ return resultMap;
+ }
+ PreparedQueryObject queryObject = new PreparedQueryObject();
+ queryObject.appendQueryString(
+ "select * from admin.keyspace_master where keyspace_name = ? allow filtering");
+ try {
+ queryObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), keyspace));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ Row rs = null;
+ try {
+ rs = MusicCore.get(queryObject).one();
+ } catch (MusicServiceException e) {
+ e.printStackTrace();
+ resultMap.put("Exception", "Unable to process operation. Error is "+e.getMessage());
+ return resultMap;
+ }
+ if(rs == null) {
+ resultMap.put("Exception", "Please make sure keyspace:"+keyspace+" exists.");
+ return resultMap;
+ }
+ else {
+ String user = rs.getString("username");
+ String pwd = rs.getString("password");
+ String ns = rs.getString("application_name");
+ if(!ns.equals(nameSpace)) {
+ resultMap.put("Exception", "Namespace and keyspace doesn't match");
+ return resultMap;
+ }
+ if(!user.equals(userId)) {
+ resultMap.put("Exception", "Invalid userId :"+userId);
+ return resultMap;
+ }
+ if(!pwd.equals(password)) {
+ resultMap.put("Exception", "Invalid password");
+ return resultMap;
}
}
+ CachingUtil.updateMusicCache(keyspace, nameSpace);
+ CachingUtil.updateMusicValidateCache(nameSpace, userId, password);
return resultMap;
}
}
diff --git a/src/main/java/org/onap/music/main/MusicCore.java b/src/main/java/org/onap/music/main/MusicCore.java
index 4929edd8..abeedf6f 100644
--- a/src/main/java/org/onap/music/main/MusicCore.java
+++ b/src/main/java/org/onap/music/main/MusicCore.java
@@ -897,17 +897,7 @@ public class MusicCore {
return resultMap;
}
boolean isAAF = Boolean.valueOf(isAAFApp);
- if (!isAAF && !(operation.equals("createKeySpace"))) {
- if(aid == null) {
- resultMap.put("Exception", "Aid is mandatory for nonAAF applications ");
- return resultMap;
- }
- resultMap = CachingUtil.authenticateAIDUser(aid, keyspace);
-
- if (!resultMap.isEmpty())
- return resultMap;
- }
- if (aid == null && (userId == null || password == null)) {
+ if (userId == null || password == null) {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
logger.error(EELFLoggerDelegate.errorLogger,"One or more required headers is missing. userId: " + userId
+ " :: password: " + password);
@@ -915,7 +905,12 @@ public class MusicCore {
"UserId and Password are mandatory for the operation " + operation);
return resultMap;
}
-
+ if(!isAAF && !(operation.equals("createKeySpace"))) {
+ resultMap = CachingUtil.authenticateAIDUser(nameSpace, userId, password, keyspace);
+ if (!resultMap.isEmpty())
+ return resultMap;
+
+ }
if (isAAF && nameSpace != null && userId != null && password != null) {
boolean isValid = true;
try {
diff --git a/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java b/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java
index b8008791..2d7aa833 100755
--- a/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java
@@ -92,6 +92,7 @@ public class RestMusicAdminAPI {
if (!rs.all().isEmpty()) {
resultMap.put("Exception", "Application " + appName
+ " has already been onboarded. Please contact admin.");
+ response.setStatus(400);
return resultMap;
}
@@ -113,6 +114,7 @@ public class RestMusicAdminAPI {
if (returnStr.contains("Failure")) {
resultMap.put("Exception",
"Oops. Something wrong with onboarding process. Please retry later or contact admin.");
+ response.setStatus(400);
return resultMap;
}
CachingUtil.updateisAAFCache(appName, isAAF);
@@ -173,11 +175,15 @@ public class RestMusicAdminAPI {
resultMap.put( row.getUUID("uuid").toString(),row.getString("keyspace_name"));
}
if (resultMap.isEmpty()) {
- if(uuid != null)
+ if(uuid != null) {
resultMap.put("Exception", "Please make sure Aid is correct and application is onboarded.");
- else {
+ response.setStatus(400);
+ return resultMap;
+ }else {
resultMap.put("Exception",
"Application is not onboarded. Please make sure all the information is correct.");
+ response.setStatus(400);
+ return resultMap;
}
}
return resultMap;
@@ -224,7 +230,7 @@ public class RestMusicAdminAPI {
if (result==ResultType.SUCCESS) {
resultMap.put("Success", "Your application has been deleted successfully");
} else {
- resultMap.put("Exception","Oops. Spomething went wrong. Please make sure Aid is correct or Application is onboarded");
+ resultMap.put("Exception","Oops. Something went wrong. Please make sure Aid is correct or Application is onboarded");
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
response.setStatus(400);
return resultMap;
@@ -273,9 +279,8 @@ public class RestMusicAdminAPI {
resultMap.put("Failure", "More than one Aid exists for this application, so please provide Aid.");
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MULTIPLERECORDS ,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
response.setStatus(400);
+ return resultMap;
}
-
- return resultMap;
}
@@ -355,9 +360,10 @@ public class RestMusicAdminAPI {
resultMap.put("Success", "Your application has been updated successfully");
} else {
resultMap.put("Exception",
- "Oops. Spomething went wrong. Please make sure Aid is correct and application is onboarded");
+ "Oops. Something went wrong. Please make sure Aid is correct and application is onboarded");
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
response.setStatus(400);
+ return resultMap;
}
return resultMap;
diff --git a/src/main/java/org/onap/music/rest/RestMusicDataAPI.java b/src/main/java/org/onap/music/rest/RestMusicDataAPI.java
index 4c8de434..2d095949 100755
--- a/src/main/java/org/onap/music/rest/RestMusicDataAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicDataAPI.java
@@ -154,10 +154,13 @@ public class RestMusicDataAPI {
Map<String, Object> authMap = CachingUtil.verifyOnboarding(ns, userId, password);
response.addHeader(xLatestVersion, MusicUtil.getVersion());
if (!authMap.isEmpty()) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGDATA ,ErrorSeverity.CRITICAL, ErrorTypes.AUTHENTICATIONERROR);
+ response.setStatus(401);
return new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap();
}
if(kspObject == null || kspObject.getReplicationInfo() == null) {
authMap.put(ResultType.EXCEPTION.getResult(), ResultType.BODYMISSING.getResult());
+ response.setStatus(401);
return authMap;
}
@@ -165,8 +168,8 @@ public class RestMusicDataAPI {
authMap = MusicCore.autheticateUser(ns, userId, password, keyspaceName, aid,
"createKeySpace");
} catch (Exception e) {
- logger.error(EELFLoggerDelegate.applicationLogger,
- "Exception while authenting the user.");
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.MISSINGDATA ,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError("Unable to authenticate.").toMap();
}
String newAid = null;
@@ -174,6 +177,8 @@ public class RestMusicDataAPI {
if (authMap.containsKey("aid")) {
newAid = (String) authMap.get("aid");
} else {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGDATA ,ErrorSeverity.CRITICAL, ErrorTypes.AUTHENTICATIONERROR);
+ response.setStatus(401);
return new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap();
}
}
@@ -188,7 +193,8 @@ public class RestMusicDataAPI {
try {
repString = "{" + MusicUtil.jsonMaptoSqlString(replicationInfo, ",") + "}";
} catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.MISSINGDATA ,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
+
}
queryObject.appendQueryString(
"CREATE KEYSPACE " + keyspaceName + " WITH replication = " + repString);
@@ -205,9 +211,10 @@ public class RestMusicDataAPI {
ResultType result = ResultType.FAILURE;
try {
result = MusicCore.nonKeyRelatedPut(queryObject, consistency);
- logger.error(EELFLoggerDelegate.errorLogger, "result = " + result);
+ logger.info(EELFLoggerDelegate.applicationLogger, "result = " + result);
} catch ( MusicServiceException ex) {
logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap();
}
@@ -238,10 +245,12 @@ public class RestMusicDataAPI {
queryObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), password));
queryObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), userId));
queryObject.addValue(MusicUtil.convertToActualDataType(DataType.cboolean(), isAAF));
- CachingUtil.updateMusicCache(newAid, keyspaceName);
+ CachingUtil.updateMusicCache(keyspaceName, ns);
+ CachingUtil.updateMusicValidateCache(ns, userId, password);
MusicCore.eventualPut(queryObject);
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError(e.getMessage()).toMap();
}
@@ -258,7 +267,6 @@ public class RestMusicDataAPI {
@DELETE
@Path("/{name}")
@ApiOperation(value = "Delete Keyspace", response = String.class)
- @Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Map<String, Object> dropKeySpace(
@ApiParam(value = "Major Version",
@@ -274,7 +282,6 @@ public class RestMusicDataAPI {
required = true) @HeaderParam("userId") String userId,
@ApiParam(value = "Password",
required = true) @HeaderParam("password") String password,
- JsonKeySpace kspObject,
@ApiParam(value = "Keyspace Name",
required = true) @PathParam("name") String keyspaceName,
@Context HttpServletResponse response) throws Exception {
@@ -284,6 +291,7 @@ public class RestMusicDataAPI {
if (authMap.containsKey("aid"))
authMap.remove("aid");
if (!authMap.isEmpty()) {
+ response.setStatus(401);
return authMap;
}
@@ -300,6 +308,8 @@ public class RestMusicDataAPI {
long count = row.getLong(0);
if (count == 0) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError("Keyspace not found. Please make sure keyspace exists.").toMap();
} else if (count == 1) {
pQuery = new PreparedQueryObject();
@@ -361,6 +371,8 @@ public class RestMusicDataAPI {
if (authMap.containsKey("aid"))
authMap.remove("aid");
if (!authMap.isEmpty()) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.CRITICAL, ErrorTypes.AUTHENTICATIONERROR);
+ response.setStatus(401);
return new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap();
}
String consistency = MusicUtil.EVENTUAL;
@@ -425,7 +437,8 @@ public class RestMusicDataAPI {
try {
result = MusicCore.nonKeyRelatedPut(queryObject, consistency);
} catch (MusicServiceException ex) {
- response.setStatus(400);
+ logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.CRITICAL, ErrorTypes.MUSICSERVICEERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap();
}
@@ -470,8 +483,11 @@ public class RestMusicDataAPI {
response.addHeader(xLatestVersion, MusicUtil.getVersion());
if (authMap.containsKey("aid"))
authMap.remove("aid");
- if (!authMap.isEmpty())
- return new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap();
+ if (!authMap.isEmpty()) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.CRITICAL, ErrorTypes.AUTHENTICATIONERROR);
+ response.setStatus(401);
+ return new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap();
+ }
MultivaluedMap<String, String> rowParams = info.getQueryParameters();
String indexName = "";
if (rowParams.getFirst("index_name") != null)
@@ -484,6 +500,8 @@ public class RestMusicDataAPI {
try {
result = MusicCore.nonKeyRelatedPut(query, "eventual");
} catch (MusicServiceException ex) {
+ logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(401);
return new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap();
}
@@ -528,14 +546,17 @@ public class RestMusicDataAPI {
authMap = MusicCore.autheticateUser(ns, userId, password, keyspace,
aid, "insertIntoTable");
} catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger,e.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.CRITICAL, ErrorTypes.AUTHENTICATIONERROR);
+ response.setStatus(401);
return new JsonResponse(ResultType.FAILURE).setError(e.getMessage()).toMap();
}
response.addHeader(xLatestVersion, MusicUtil.getVersion());
if (authMap.containsKey("aid"))
authMap.remove("aid");
if (!authMap.isEmpty()) {
- return new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap();
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.CRITICAL, ErrorTypes.AUTHENTICATIONERROR);
+ response.setStatus(401);
+ return new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap();
}
Map<String, Object> valuesMap = insObj.getValues();
@@ -548,7 +569,8 @@ public class RestMusicDataAPI {
.setError("Table name doesn't exists. Please check the table name.").toMap();
}
} catch (MusicServiceException e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError(e.getMessage()).toMap();
}
String primaryKeyName = tableInfo.getPrimaryKey().get(0).getName();
@@ -571,7 +593,8 @@ public class RestMusicDataAPI {
try {
colType = tableInfo.getColumn(entry.getKey()).getType();
} catch(NullPointerException ex) {
- logger.error(EELFLoggerDelegate.errorLogger, "Invalid column name : "+entry.getKey());
+ logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage() +" Invalid column name : "+entry.getKey(), AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError("Invalid column name : "+entry.getKey()).toMap();
}
@@ -596,6 +619,7 @@ public class RestMusicDataAPI {
if(primaryKey == null || primaryKey.length() <= 0) {
logger.error(EELFLoggerDelegate.errorLogger, "Some required partition key parts are missing: "+primaryKeyName );
+ response.setStatus(400);
return new JsonResponse(ResultType.SYNTAXERROR).setError("Some required partition key parts are missing: "+primaryKeyName).toMap();
}
@@ -651,10 +675,13 @@ public class RestMusicDataAPI {
}
} catch (Exception ex) {
logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap();
}
if (result==null) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError("Null result - Please Contact admin").toMap();
}
return new JsonResponse(result.getResult()).toMap();
@@ -699,13 +726,16 @@ public class RestMusicDataAPI {
authMap = MusicCore.autheticateUser(ns, userId, password, keyspace,
aid, "updateTable");
} catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger,e.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
+ response.setStatus(401);
return new JsonResponse(ResultType.FAILURE).setError(e.getMessage()).toMap();
}
response.addHeader(xLatestVersion, MusicUtil.getVersion());
if (authMap.containsKey("aid"))
authMap.remove("aid");
if (!authMap.isEmpty()) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
+ response.setStatus(401);
return new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap();
}
long startTime = System.currentTimeMillis();
@@ -723,10 +753,13 @@ public class RestMusicDataAPI {
try {
tableInfo = MusicCore.returnColumnMetadata(keyspace, tablename);
} catch (MusicServiceException e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError(e.getMessage()).toMap();
}
if (tableInfo == null) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE)
.setError("Table information not found. Please check input for table name= "
+ keyspace + "." + tablename).toMap();
@@ -743,6 +776,7 @@ public class RestMusicDataAPI {
colType = tableInfo.getColumn(entry.getKey()).getType();
} catch(NullPointerException ex) {
logger.error(EELFLoggerDelegate.errorLogger, "Invalid column name : "+entry.getKey());
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError("Invalid column name : "+entry.getKey()).toMap();
}
Object valueString = null;
@@ -790,7 +824,8 @@ public class RestMusicDataAPI {
.setError("Mandatory WHERE clause is missing. Please check the input request.").toMap();
}
} catch (MusicServiceException ex) {
- logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap();
}
@@ -820,6 +855,7 @@ public class RestMusicDataAPI {
if(lockId == null) {
logger.error(EELFLoggerDelegate.errorLogger,"LockId cannot be null. Create lock reference or"
+ " use ATOMIC instead of CRITICAL", ErrorSeverity.FATAL, ErrorTypes.MUSICSERVICEERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError("LockId cannot be null. Create lock "
+ "and acquire lock or use ATOMIC instead of CRITICAL").toMap();
}
@@ -831,7 +867,8 @@ public class RestMusicDataAPI {
operationResult = MusicCore.atomicPutWithDeleteLock(keyspace, tablename,
rowId.primarKeyValue, queryObject, conditionInfo);
} catch (MusicLockingException e) {
- logger.error(EELFLoggerDelegate.errorLogger,e.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError(e.getMessage()).toMap();
}
} else if (consistency.equalsIgnoreCase(MusicUtil.ATOMIC)) {
@@ -839,7 +876,8 @@ public class RestMusicDataAPI {
operationResult = MusicCore.atomicPut(keyspace, tablename, rowId.primarKeyValue,
queryObject, conditionInfo);
} catch (MusicLockingException e) {
- logger.error(EELFLoggerDelegate.errorLogger,e.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError(e.getMessage()).toMap();
}
}
@@ -859,6 +897,8 @@ public class RestMusicDataAPI {
logger.info(EELFLoggerDelegate.applicationLogger, timingString);
if (operationResult==null) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError("Null result - Please Contact admin").toMap();
}
return new JsonResponse(operationResult.getResult()).toMap();
@@ -903,15 +943,21 @@ public class RestMusicDataAPI {
authMap = MusicCore.autheticateUser(ns, userId, password, keyspace,
aid, "deleteFromTable");
} catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
+ response.setStatus(401);
return new JsonResponse(ResultType.FAILURE).setError(e.getMessage()).toMap();
}
response.addHeader(xLatestVersion, MusicUtil.getVersion());
if (authMap.containsKey("aid"))
authMap.remove("aid");
if (!authMap.isEmpty()) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
+ response.setStatus(401);
return new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap();
}
if(delObj == null) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGDATA ,ErrorSeverity.WARN, ErrorTypes.DATAERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError("Required HTTP Request body is missing.").toMap();
}
PreparedQueryObject queryObject = new PreparedQueryObject();
@@ -933,6 +979,8 @@ public class RestMusicDataAPI {
try {
rowId = getRowIdentifier(keyspace, tablename, info.getQueryParameters(), queryObject);
} catch (MusicServiceException ex) {
+ logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap();
}
String rowSpec = rowId.rowIdString.toString();
@@ -975,6 +1023,7 @@ public class RestMusicDataAPI {
if(lockId == null) {
logger.error(EELFLoggerDelegate.errorLogger,"LockId cannot be null. Create lock reference or"
+ " use ATOMIC instead of CRITICAL", ErrorSeverity.FATAL, ErrorTypes.MUSICSERVICEERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError("LockId cannot be null. Create lock "
+ "and acquire lock or use ATOMIC instead of CRITICAL").toMap();
}
@@ -989,10 +1038,14 @@ public class RestMusicDataAPI {
queryObject, conditionInfo);
}
} catch (MusicLockingException e) {
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE)
.setError("Unable to perform Delete operation. Exception from music").toMap();
}
if (operationResult.getResult().equals(ResultType.FAILURE)) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError(operationResult.getMessage()).toMap();
}
return new JsonResponse(operationResult.getResult()).toMap();
@@ -1008,7 +1061,6 @@ public class RestMusicDataAPI {
@DELETE
@Path("/{keyspace}/tables/{tablename}")
@ApiOperation(value = "Drop Table", response = String.class)
- @Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Map<String, Object> dropTable(
@ApiParam(value = "Major Version",
@@ -1024,7 +1076,6 @@ public class RestMusicDataAPI {
required = true) @HeaderParam("userId") String userId,
@ApiParam(value = "Password",
required = true) @HeaderParam("password") String password,
- JsonTable tabObj,
@ApiParam(value = "Keyspace Name",
required = true) @PathParam("keyspace") String keyspace,
@ApiParam(value = "Table Name",
@@ -1036,6 +1087,8 @@ public class RestMusicDataAPI {
if (authMap.containsKey("aid"))
authMap.remove("aid");
if (!authMap.isEmpty()) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
+ response.setStatus(401);
return new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap();
}
String consistency = "eventual";// for now this needs only eventual
@@ -1045,6 +1098,8 @@ public class RestMusicDataAPI {
try {
return new JsonResponse(MusicCore.nonKeyRelatedPut(query, consistency)).toMap();
} catch (MusicServiceException ex) {
+ logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap();
}
@@ -1089,7 +1144,8 @@ public class RestMusicDataAPI {
if (authMap.containsKey("aid"))
authMap.remove("aid");
if (!authMap.isEmpty()) {
- logger.error("Error while authentication... ");
+ logger.error(EELFLoggerDelegate.errorLogger,"Error while authentication... ", AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
+ response.setStatus(401);
return new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap();
}
String lockId = selObj.getConsistencyInfo().get("lockId");
@@ -1100,6 +1156,8 @@ public class RestMusicDataAPI {
try {
rowId = getRowIdentifier(keyspace, tablename, info.getQueryParameters(), queryObject);
} catch (MusicServiceException ex) {
+ logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap();
}
queryObject.appendQueryString(
@@ -1113,6 +1171,7 @@ public class RestMusicDataAPI {
if(lockId == null) {
logger.error(EELFLoggerDelegate.errorLogger,"LockId cannot be null. Create lock reference or"
+ " use ATOMIC instead of CRITICAL", ErrorSeverity.FATAL, ErrorTypes.MUSICSERVICEERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError("LockId cannot be null. Create lock "
+ "and acquire lock or use ATOMIC instead of CRITICAL").toMap();
}
@@ -1167,6 +1226,7 @@ public class RestMusicDataAPI {
authMap.remove("aid");
if (!authMap.isEmpty()) {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.AUTHENTICATIONERROR ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
+ response.setStatus(401);
return new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap();
}
PreparedQueryObject queryObject = new PreparedQueryObject();
@@ -1179,6 +1239,8 @@ public class RestMusicDataAPI {
queryObject = selectSpecificQuery(version, minorVersion, patchVersion, aid, ns,
userId, password, keyspace, tablename, info, limit);
} catch (MusicServiceException ex) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap();
}
}
@@ -1188,6 +1250,7 @@ public class RestMusicDataAPI {
return new JsonResponse(ResultType.SUCCESS).setDataResult(MusicCore.marshallResults(results)).toMap();
} catch (MusicServiceException ex) {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.UNKNOWNERROR ,ErrorSeverity.ERROR, ErrorTypes.MUSICSERVICEERROR);
+ response.setStatus(400);
return new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap();
}
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();
diff --git a/src/main/java/org/onap/music/rest/RestMusicQAPI.java b/src/main/java/org/onap/music/rest/RestMusicQAPI.java
index 9a4f6c6b..39233dc5 100755
--- a/src/main/java/org/onap/music/rest/RestMusicQAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicQAPI.java
@@ -253,6 +253,6 @@ public class RestMusicQAPI {
@ApiParam(value="Key Space",required=true) @PathParam("keyspace") String keyspace,
@ApiParam(value="Table Name",required=true) @PathParam("tablename") String tablename,
@Context HttpServletResponse response) throws Exception{
- return new RestMusicDataAPI().dropTable(version,minorVersion,patchVersion,aid, ns, userId, password, tabObj, keyspace, tablename,response);
+ return new RestMusicDataAPI().dropTable(version,minorVersion,patchVersion,aid, ns, userId, password, keyspace, tablename,response);
}
}
diff --git a/src/test/java/org/onap/music/unittests/TestRestMusicData.java b/src/test/java/org/onap/music/unittests/TestRestMusicData.java
index 5d51c4de..a8a8612a 100644
--- a/src/test/java/org/onap/music/unittests/TestRestMusicData.java
+++ b/src/test/java/org/onap/music/unittests/TestRestMusicData.java
@@ -342,7 +342,7 @@ public class TestRestMusicData {
Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
Map<String, Object> resultMap = data.dropTable("1", "1", "1",
"abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, userId, password,
- jsonTable, keyspaceName, tableName, http);
+ keyspaceName, tableName, http);
assertEquals(ResultType.SUCCESS, resultMap.get("status"));
}
@@ -360,7 +360,7 @@ public class TestRestMusicData {
jsonKeyspace.setReplicationInfo(replicationInfo);
Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
Map<String, Object> resultMap = data.dropKeySpace("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6",
- appName, userId, password, jsonKeyspace, keyspaceName, http);
+ appName, userId, password, keyspaceName, http);
assertEquals(ResultType.SUCCESS, resultMap.get("status"));
}
@@ -414,7 +414,7 @@ public class TestRestMusicData {
@Test
public void Test3_createLockReference() throws Exception {
Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
- Map<String, Object> resultMap = lock.createLockReference(lockName, uuid.toString(), appName, null, null, http);
+ Map<String, Object> resultMap = lock.createLockReference(lockName, null, appName, userId, password, http);
@SuppressWarnings("unchecked")
Map<String, Object> resultMap1 = (Map<String, Object>) resultMap.get("lock");
lockId = (String) resultMap1.get("lock");
@@ -424,28 +424,28 @@ public class TestRestMusicData {
@Test
public void Test4_accquireLock() throws Exception {
Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
- Map<String, Object> resultMap = lock.accquireLock(lockId, uuid.toString(), appName, null, null, http);
+ Map<String, Object> resultMap = lock.accquireLock(lockId, null, appName, userId, password, http);
assertEquals(ResultType.SUCCESS, resultMap.get("status"));
}
@Test
public void Test5_currentLockHolder() throws Exception {
Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
- Map<String, Object> resultMap = lock.currentLockHolder(lockName, uuid.toString(), appName, null, null, http);
+ Map<String, Object> resultMap = lock.currentLockHolder(lockName, null, appName, userId, password, http);
assertEquals(ResultType.SUCCESS, resultMap.get("status"));
}
@Test
public void Test7_unLock() throws Exception {
Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
- Map<String, Object> resultMap = lock.unLock(lockId, uuid.toString(), appName, null, null, http);
+ Map<String, Object> resultMap = lock.unLock(lockId, null, appName, userId, password, http);
assertEquals(ResultType.SUCCESS, resultMap.get("status"));
}
@Test
public void Test8_delete() throws Exception {
Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
- Map<String, Object> resultMap = lock.deleteLock(lockName, uuid.toString(), appName, null, null, http);
+ Map<String, Object> resultMap = lock.deleteLock(lockName, null, appName, userId, password, http);
assertEquals(ResultType.SUCCESS, resultMap.get("status"));
}
} \ No newline at end of file
diff --git a/version.properties b/version.properties
index b6a0bf9a..24dfb134 100644
--- a/version.properties
+++ b/version.properties
@@ -4,7 +4,7 @@
major=2
minor=4
-patch=20
+patch=22
base_version=${major}.${minor}.${patch}