aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBharath Balasubramanian <bharathb@research.att.com>2018-09-18 02:48:41 +0000
committerGerrit Code Review <gerrit@onap.org>2018-09-18 02:48:41 +0000
commit1c28ca5b696c1c8df24c207fd1235af0b85c4186 (patch)
tree2ea4dc577eabbf91eb91fdf673d75de06cdfd049 /src
parent82c874161df1bc657ed309938cbdd24d6a3294bd (diff)
parenta9efc16e26cd57d69bb2dc691cec01ec842930cc (diff)
Merge "Update distribution files to support helm charts"
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java2
-rw-r--r--src/main/java/org/onap/music/datastore/MusicDataStore.java2
-rw-r--r--src/main/java/org/onap/music/exceptions/MusicServiceException.java38
-rwxr-xr-xsrc/main/java/org/onap/music/main/CachingUtil.java9
-rwxr-xr-xsrc/main/java/org/onap/music/rest/RestMusicAdminAPI.java154
-rwxr-xr-xsrc/main/java/org/onap/music/rest/RestMusicDataAPI.java20
6 files changed, 117 insertions, 108 deletions
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 0e8cc14a..d5e9e4d5 100644
--- a/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java
+++ b/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java
@@ -355,4 +355,4 @@ public class MusicConditional {
}
-} \ No newline at end of file
+}
diff --git a/src/main/java/org/onap/music/datastore/MusicDataStore.java b/src/main/java/org/onap/music/datastore/MusicDataStore.java
index 38f5fe9f..21b0053f 100644
--- a/src/main/java/org/onap/music/datastore/MusicDataStore.java
+++ b/src/main/java/org/onap/music/datastore/MusicDataStore.java
@@ -335,7 +335,7 @@ public class MusicDataStore {
ColumnDefinitions colInfo = row.getColumnDefinitions();
HashMap<String, Object> resultOutput = new HashMap<String, Object>();
for (Definition definition : colInfo) {
- if (!"vector_ts".equals(definition.getName())) {
+ if (!definition.getName().equals("vector_ts")) {
if(definition.getType().toString().toLowerCase().contains("blob")) {
resultOutput.put(definition.getName(),
getBlobValue(row, definition.getName(), definition.getType()));
diff --git a/src/main/java/org/onap/music/exceptions/MusicServiceException.java b/src/main/java/org/onap/music/exceptions/MusicServiceException.java
index 35ce5c8c..a3b1fc56 100644
--- a/src/main/java/org/onap/music/exceptions/MusicServiceException.java
+++ b/src/main/java/org/onap/music/exceptions/MusicServiceException.java
@@ -32,6 +32,25 @@ public class MusicServiceException extends Exception {
private int errorCode;
private String errorMessage;
+ public int getErrorCode() {
+ return errorCode;
+ }
+
+
+ public void setErrorCode(int errorCode) {
+ this.errorCode = errorCode;
+ }
+
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
public MusicServiceException() {
super();
@@ -62,23 +81,4 @@ public class MusicServiceException extends Exception {
}
- public int getErrorCode() {
- return errorCode;
- }
-
-
- public void setErrorCode(int errorCode) {
- this.errorCode = errorCode;
- }
-
-
- public String getErrorMessage() {
- return errorMessage;
- }
-
-
- public void setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage;
- }
-
}
diff --git a/src/main/java/org/onap/music/main/CachingUtil.java b/src/main/java/org/onap/music/main/CachingUtil.java
index 34bc52d3..a81887a0 100755
--- a/src/main/java/org/onap/music/main/CachingUtil.java
+++ b/src/main/java/org/onap/music/main/CachingUtil.java
@@ -147,7 +147,7 @@ public class CachingUtil implements Runnable {
public static boolean authenticateAAFUser(String nameSpace, String userId, String password,
String keySpace) throws Exception {
- if (aafCache.get(nameSpace) != null) {
+ if (aafCache.get(nameSpace) != null && musicCache.get(keySpace)!=null) {
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)) {
@@ -181,9 +181,10 @@ public class CachingUtil implements Runnable {
boolean responseObj = triggerAAF(nameSpace, userId, password);
if (responseObj) {
//if (responseObj.getNs().get(0).getAdmin().contains(userId)) {
- //Map<String, String> map = new HashMap<>();
- //map.put(userId, password);
- //aafCache.put(nameSpace, map);
+ Map<String, String> map = new HashMap<>();
+ map.put(userId, password);
+ aafCache.put(nameSpace, map);
+ CachingUtil.updateMusicCache(keySpace, nameSpace);
return true;
//}
}
diff --git a/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java b/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java
index f28f236f..0e365650 100755
--- a/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java
@@ -481,6 +481,32 @@ public class RestMusicAdminAPI {
break;
}
}
+ if(baseRequestObj == null || field_value == null) {
+ for(String element: inputUpdateList) {
+ String[] elementArr = element.split(":");
+ String newElement = null;
+ if(elementArr.length >= 2) {
+ newElement = elementArr[0]+":"+elementArr[1];
+ }
+ baseRequestObj = CachingUtil.getCallBackCache(newElement);
+ if(baseRequestObj != null) {
+ logger.info("Found the element that was changed... "+newElement);
+ break;
+ }
+ }
+ for(String element : updateList) {
+ String[] elementArr = element.split(":");
+ String newElement = null;
+ if(elementArr.length >= 2) {
+ newElement = elementArr[0]+":"+elementArr[1];
+ }
+ if(notifiyList.contains(newElement)) {
+ logger.info("Found the notifyOn property: "+newElement);
+ field_value = newElement;
+ break;
+ }
+ }
+ }
} else {
field_value = jsonResponse.getFull_table();
baseRequestObj = CachingUtil.getCallBackCache(field_value);
@@ -609,80 +635,62 @@ public class RestMusicAdminAPI {
String primaryId = tableInfo.getPrimaryKey().get(0).getName();
Map<String, String> responseBodyMap = baseRequestObj.getResponseBody();
- for (Entry<String, String> entry : new HashSet<>(responseBodyMap.entrySet())) {
- String trimmed = entry.getKey().trim();
- if (!trimmed.equals(entry.getKey())) {
- responseBodyMap.remove(entry.getKey());
- responseBodyMap.put(trimmed, entry.getValue());
- }
+ Map<String, String> newMap = new HashMap<>();
+ if(responseBodyMap.size() == 1 && responseBodyMap.containsKey("")) {
+ jsonNotification.setResponse_body(newMap);
+ } else {
+ for (Entry<String, String> entry : new HashSet<>(responseBodyMap.entrySet())) {
+ String trimmed = entry.getKey().trim();
+ if (!trimmed.equals(entry.getKey())) {
+ responseBodyMap.remove(entry.getKey());
+ responseBodyMap.put(trimmed, entry.getValue());
+ }
+ }
+
+ Set<String> keySet = responseBodyMap.keySet();
+ String cql = "select *";
+ /*for(String keys: keySet) {
+ cql = cql + keys + ",";
+ }*/
+ //cql = cql.substring(0, cql.length()-1);
+ cql = cql + " FROM "+fullNotifyArr[0]+" WHERE "+primaryId+" = ?";
+ logger.info("CQL in constructJsonNotification: "+cql);
+ PreparedQueryObject pQuery = new PreparedQueryObject();
+ pQuery.appendQueryString(cql);
+ pQuery.addValue(MusicUtil.convertToActualDataType(primaryIdType, pkValue));
+ Row row = MusicCore.get(pQuery).one();
+ if(row != null) {
+ ColumnDefinitions colInfo = row.getColumnDefinitions();
+ for (Definition definition : colInfo) {
+ String colName = definition.getName();
+ if(keySet.contains(colName)) {
+ DataType colType = definition.getType();
+ Object valueObj = MusicCore.getDSHandle().getColValue(row, colName, colType);
+ Object valueString = MusicUtil.convertToActualDataType(colType, valueObj);
+ logger.info(colName+" : "+valueString);
+ newMap.put(colName, valueString.toString());
+ keySet.remove(colName);
+ }
+ }
+ }
+ if(! keySet.isEmpty()) {
+ Iterator<String> iterator = keySet.iterator();
+ while (iterator.hasNext()) {
+ String element = iterator.next();
+ if(element != null && element.length() > 0)
+ newMap.put(element,"COLUMN_NOT_FOUND");
+ }
+ }
+
+ if("delete".equals(jsonResponse.getOperation()) || newMap.isEmpty()) {
+ newMap.put(primaryId, pkValue);
+ }
+ jsonNotification.setResponse_body(newMap);
}
-
- Set<String> keySet = responseBodyMap.keySet();
- String cql = "select *";
- /*for(String keys: keySet) {
- cql = cql + keys + ",";
- }*/
- //cql = cql.substring(0, cql.length()-1);
- cql = cql + " FROM "+fullNotifyArr[0]+" WHERE "+primaryId+" = ?";
- logger.info("CQL in constructJsonNotification: "+cql);
- PreparedQueryObject pQuery = new PreparedQueryObject();
- pQuery.appendQueryString(cql);
- pQuery.addValue(MusicUtil.convertToActualDataType(primaryIdType, pkValue));
- Row row = MusicCore.get(pQuery).one();
- Map<String, String> newMap = new HashMap<>();
- if(row != null) {
- ColumnDefinitions colInfo = row.getColumnDefinitions();
- for (Definition definition : colInfo) {
- String colName = definition.getName();
- if(keySet.contains(colName)) {
- DataType colType = definition.getType();
- Object valueObj = MusicCore.getDSHandle().getColValue(row, colName, colType);
- Object valueString = MusicUtil.convertToActualDataType(colType, valueObj);
- logger.info(colName+" : "+valueString);
- newMap.put(colName, valueString.toString());
- keySet.remove(colName);
- }
- }
- }
- if(! keySet.isEmpty()) {
- Iterator<String> iterator = keySet.iterator();
- while (iterator.hasNext()) {
- String element = iterator.next();
- newMap.put(element,"COLUMN_NOT_FOUND");
- }
- }
-
- /*if(row != null) {
- for(String keys: keySet1) {
- String value = null;
- try {
- logger.info(">>>>>>>> converting <<<<<<<<<<<< "+keys + " : "+responseBodyMap.get(keys));
- if(responseBodyMap.get(keys).equals("uuid"))
- value = row.getUUID(keys.trim()).toString();
- else if (responseBodyMap.get(keys).equals("text"))
- value = row.getString(keys.trim());
- else if (responseBodyMap.get(keys).equals("int"))
- value = String.valueOf(row.getInt(keys.trim()));
- else if (responseBodyMap.get(keys).equals("bigint"))
- value = String.valueOf(row.getLong(keys.trim()));
- } catch (Exception e) {
- newMap.put(primaryId, pkValue);
- logger.info("Error in constructJsonNotification: Invalid column..");
- }
- else if (responseBodyMap.get(keys).contains("int"))
- value = row.getLong(keys).toString();
- newMap.put(keys.trim(), value);
- }
- }*/
-
- if("delete".equals(jsonResponse.getOperation()) || newMap.isEmpty()) {
- newMap.put(primaryId, pkValue);
- }
- jsonNotification.setResponse_body(newMap);
- } catch(Exception e) {
- e.printStackTrace();
- }
- return jsonNotification;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return jsonNotification;
}
private void constructJsonCallbackFromCache() throws Exception{
diff --git a/src/main/java/org/onap/music/rest/RestMusicDataAPI.java b/src/main/java/org/onap/music/rest/RestMusicDataAPI.java
index f0c1663c..2d1a8836 100755
--- a/src/main/java/org/onap/music/rest/RestMusicDataAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicDataAPI.java
@@ -159,7 +159,7 @@ public class RestMusicDataAPI {
if (!authMap.isEmpty()) {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGDATA ,ErrorSeverity.CRITICAL, ErrorTypes.AUTHENTICATIONERROR);
response.status(Status.UNAUTHORIZED);
- return response.entity(new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap()).build();
+ return response.entity(new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Error"))).toMap()).build();
}
if(kspObject == null || kspObject.getReplicationInfo() == null) {
authMap.put(ResultType.EXCEPTION.getResult(), ResultType.BODYMISSING.getResult());
@@ -183,7 +183,7 @@ public class RestMusicDataAPI {
} else {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGDATA ,ErrorSeverity.CRITICAL, ErrorTypes.AUTHENTICATIONERROR);
response.status(Status.UNAUTHORIZED);
- return response.entity(new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap()).build();
+ return response.entity(new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Error"))).toMap()).build();
}
}
@@ -368,7 +368,7 @@ public class RestMusicDataAPI {
authMap.remove("aid");
if (!authMap.isEmpty()) {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.CRITICAL, ErrorTypes.AUTHENTICATIONERROR);
- return response.status(Status.UNAUTHORIZED).entity(new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap()).build();
+ return response.status(Status.UNAUTHORIZED).entity(new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Error"))).toMap()).build();
}
String consistency = MusicUtil.EVENTUAL;
// for now this needs only eventual consistency
@@ -594,7 +594,7 @@ public class RestMusicDataAPI {
if (!authMap.isEmpty()) {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.CRITICAL, ErrorTypes.AUTHENTICATIONERROR);
response.status(Status.UNAUTHORIZED);
- return response.entity(new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap()).build();
+ return response.entity(new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Error"))).toMap()).build();
}
MultivaluedMap<String, String> rowParams = info.getQueryParameters();
String indexName = "";
@@ -662,7 +662,7 @@ public class RestMusicDataAPI {
authMap.remove("aid");
if (!authMap.isEmpty()) {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.CRITICAL, ErrorTypes.AUTHENTICATIONERROR);
- return response.status(Status.UNAUTHORIZED).entity(new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap()).build();
+ return response.status(Status.UNAUTHORIZED).entity(new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Error"))).toMap()).build();
}
Map<String, Object> valuesMap = insObj.getValues();
@@ -872,7 +872,7 @@ public class RestMusicDataAPI {
authMap.remove("aid");
if (!authMap.isEmpty()) {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
- return response.status(Status.UNAUTHORIZED).entity(new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap()).build();
+ return response.status(Status.UNAUTHORIZED).entity(new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Error"))).toMap()).build();
}
long startTime = System.currentTimeMillis();
String operationId = UUID.randomUUID().toString();// just for infoging
@@ -1085,7 +1085,7 @@ public class RestMusicDataAPI {
authMap.remove("aid");
if (!authMap.isEmpty()) {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
- return response.status(Status.UNAUTHORIZED).entity(new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap()).build();
+ return response.status(Status.UNAUTHORIZED).entity(new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Error"))).toMap()).build();
}
if(delObj == null) {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGDATA ,ErrorSeverity.WARN, ErrorTypes.DATAERROR);
@@ -1220,7 +1220,7 @@ public class RestMusicDataAPI {
authMap.remove("aid");
if (!authMap.isEmpty()) {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
- return response.status(Status.UNAUTHORIZED).entity(new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap()).build();
+ return response.status(Status.UNAUTHORIZED).entity(new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Error"))).toMap()).build();
}
String consistency = "eventual";// for now this needs only eventual
// consistency
@@ -1275,7 +1275,7 @@ public class RestMusicDataAPI {
authMap.remove("aid");
if (!authMap.isEmpty()) {
logger.error(EELFLoggerDelegate.errorLogger,"Error while authentication... ", AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
- return response.status(Status.UNAUTHORIZED).entity(new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap()).build();
+ return response.status(Status.UNAUTHORIZED).entity(new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Error"))).toMap()).build();
}
String lockId = selObj.getConsistencyInfo().get("lockId");
@@ -1358,7 +1358,7 @@ public class RestMusicDataAPI {
authMap.remove("aid");
if (!authMap.isEmpty()) {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.AUTHENTICATIONERROR ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
- return response.status(Status.UNAUTHORIZED).entity(new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Exception"))).toMap()).build();
+ return response.status(Status.UNAUTHORIZED).entity(new JsonResponse(ResultType.FAILURE).setError(String.valueOf(authMap.get("Error"))).toMap()).build();
}
PreparedQueryObject queryObject = new PreparedQueryObject();