aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/music/rest
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/onap/music/rest')
-rwxr-xr-xsrc/main/java/org/onap/music/rest/RestMusicAdminAPI.java29
-rwxr-xr-xsrc/main/java/org/onap/music/rest/RestMusicDataAPI.java88
-rw-r--r--src/main/java/org/onap/music/rest/RestMusicLocksAPI.java49
-rwxr-xr-xsrc/main/java/org/onap/music/rest/RestMusicQAPI.java10
4 files changed, 81 insertions, 95 deletions
diff --git a/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java b/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java
index 9ae7bc32..90436499 100755
--- a/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java
@@ -47,11 +47,9 @@ import org.onap.music.eelf.logging.format.AppMessages;
import org.onap.music.eelf.logging.format.ErrorSeverity;
import org.onap.music.eelf.logging.format.ErrorTypes;
import org.onap.music.main.CachingUtil;
+import org.onap.music.main.MusicCore;
import org.onap.music.main.MusicUtil;
import org.onap.music.main.ResultType;
-import org.onap.music.service.MusicCoreService;
-import org.onap.music.service.impl.MusicCassaCore;
-
import com.datastax.driver.core.DataType;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
@@ -65,7 +63,6 @@ import io.swagger.annotations.ApiOperation;
public class RestMusicAdminAPI {
private static EELFLoggerDelegate logger =
EELFLoggerDelegate.getLogger(RestMusicAdminAPI.class);
- private static MusicCoreService musicCore = MusicCassaCore.getInstance();
/*
* API to onboard an application with MUSIC. This is the mandatory first step.
@@ -96,7 +93,7 @@ public class RestMusicAdminAPI {
pQuery.appendQueryString(
"select uuid from admin.keyspace_master where application_name = ? allow filtering");
pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), appName));
- ResultSet rs = musicCore.get(pQuery);
+ ResultSet rs = MusicCore.get(pQuery);
if (!rs.all().isEmpty()) {
resultMap.put("Exception", "Application " + appName
+ " has already been onboarded. Please contact admin.");
@@ -117,7 +114,7 @@ public class RestMusicAdminAPI {
pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), userId));
pQuery.addValue(MusicUtil.convertToActualDataType(DataType.cboolean(), isAAF));
- String returnStr = musicCore.eventualPut(pQuery).toString();
+ String returnStr = MusicCore.eventualPut(pQuery).toString();
if (returnStr.contains("Failure")) {
resultMap.put("Exception",
"Oops. Something wrong with onboarding process. Please retry later or contact admin.");
@@ -173,7 +170,7 @@ public class RestMusicAdminAPI {
if (isAAF != null)
pQuery.addValue(MusicUtil.convertToActualDataType(DataType.cboolean(),
Boolean.parseBoolean(isAAF)));
- ResultSet rs = musicCore.get(pQuery);
+ ResultSet rs = MusicCore.get(pQuery);
Iterator<Row> it = rs.iterator();
while (it.hasNext()) {
Row row = (Row) it.next();
@@ -218,20 +215,20 @@ public class RestMusicAdminAPI {
"SELECT keyspace_name FROM admin.keyspace_master WHERE uuid = ?");
pQuery.addValue(MusicUtil.convertToActualDataType(DataType.uuid(),
UUID.fromString(aid)));
- Row row = musicCore.get(pQuery).one();
+ Row row = MusicCore.get(pQuery).one();
if (row != null) {
String ks = row.getString("keyspace_name");
if (!ks.equals(MusicUtil.DEFAULTKEYSPACENAME)) {
PreparedQueryObject queryObject = new PreparedQueryObject();
queryObject.appendQueryString("DROP KEYSPACE IF EXISTS " + ks + ";");
- musicCore.nonKeyRelatedPut(queryObject, consistency);
+ MusicCore.nonKeyRelatedPut(queryObject, consistency);
}
}
pQuery = new PreparedQueryObject();
pQuery.appendQueryString("delete from admin.keyspace_master where uuid = ? IF EXISTS");
pQuery.addValue(MusicUtil.convertToActualDataType(DataType.uuid(),
UUID.fromString(aid)));
- ResultType result = musicCore.nonKeyRelatedPut(pQuery, consistency);
+ ResultType result = MusicCore.nonKeyRelatedPut(pQuery, consistency);
if (result == ResultType.SUCCESS) {
resultMap.put("Success", "Your application has been deleted successfully");
} else {
@@ -248,7 +245,7 @@ public class RestMusicAdminAPI {
pQuery.appendQueryString(
"select uuid from admin.keyspace_master where application_name = ? allow filtering");
pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), appName));
- ResultSet rs = musicCore.get(pQuery);
+ ResultSet rs = MusicCore.get(pQuery);
List<Row> rows = rs.all();
String uuid = null;
if (rows.size() == 0) {
@@ -264,19 +261,19 @@ public class RestMusicAdminAPI {
"SELECT keyspace_name FROM admin.keyspace_master WHERE uuid = ?");
pQuery.addValue(MusicUtil.convertToActualDataType(DataType.uuid(),
UUID.fromString(uuid)));
- Row row = musicCore.get(pQuery).one();
+ Row row = MusicCore.get(pQuery).one();
String ks = row.getString("keyspace_name");
if (!ks.equals(MusicUtil.DEFAULTKEYSPACENAME)) {
PreparedQueryObject queryObject = new PreparedQueryObject();
queryObject.appendQueryString("DROP KEYSPACE " + ks + ";");
- musicCore.nonKeyRelatedPut(queryObject, consistency);
+ MusicCore.nonKeyRelatedPut(queryObject, consistency);
}
pQuery = new PreparedQueryObject();
pQuery.appendQueryString("delete from admin.keyspace_master where uuid = ?");
pQuery.addValue(MusicUtil.convertToActualDataType(DataType.uuid(),
UUID.fromString(uuid)));
- musicCore.eventualPut(pQuery);
+ MusicCore.eventualPut(pQuery);
resultMap.put("Success", "Your application " + appName + " has been deleted.");
return Response.status(Status.OK).entity(resultMap).build();
} else {
@@ -326,7 +323,7 @@ public class RestMusicAdminAPI {
pQuery.appendQueryString(
"select uuid from admin.keyspace_master where application_name = ? allow filtering");
pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), appName));
- ResultSet rs = musicCore.get(pQuery);
+ ResultSet rs = MusicCore.get(pQuery);
if (!rs.all().isEmpty()) {
resultMap.put("Exception", "Application " + appName
+ " has already been onboarded. Please contact admin.");
@@ -359,7 +356,7 @@ public class RestMusicAdminAPI {
pQuery.addValue(MusicUtil.convertToActualDataType(DataType.cboolean(), isAAF));
pQuery.addValue(MusicUtil.convertToActualDataType(DataType.uuid(), UUID.fromString(aid)));
- ResultType result = musicCore.nonKeyRelatedPut(pQuery, consistency);
+ ResultType result = MusicCore.nonKeyRelatedPut(pQuery, consistency);
if (result == ResultType.SUCCESS) {
resultMap.put("Success", "Your application has been updated successfully");
diff --git a/src/main/java/org/onap/music/rest/RestMusicDataAPI.java b/src/main/java/org/onap/music/rest/RestMusicDataAPI.java
index 986d25ec..99c60b30 100755
--- a/src/main/java/org/onap/music/rest/RestMusicDataAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicDataAPI.java
@@ -48,7 +48,6 @@ import javax.ws.rs.core.UriInfo;
import org.apache.commons.lang3.StringUtils;
import org.mindrot.jbcrypt.BCrypt;
-import org.onap.music.authentication.MusicAuthentication;
import org.onap.music.datastore.PreparedQueryObject;
import org.onap.music.datastore.jsonobjects.JsonDelete;
import org.onap.music.datastore.jsonobjects.JsonInsert;
@@ -63,14 +62,12 @@ import org.onap.music.eelf.logging.format.ErrorSeverity;
import org.onap.music.eelf.logging.format.ErrorTypes;
import org.onap.music.exceptions.MusicServiceException;
import org.onap.music.main.CachingUtil;
-import org.onap.music.datastore.Condition;
-import org.onap.music.datastore.MusicDataStoreHandle;
+import org.onap.music.main.MusicCore;
+import org.onap.music.main.MusicCore.Condition;
import org.onap.music.main.MusicUtil;
import org.onap.music.main.ResultType;
import org.onap.music.main.ReturnType;
import org.onap.music.response.jsonobjects.JsonResponse;
-import org.onap.music.service.MusicCoreService;
-import org.onap.music.service.impl.MusicCassaCore;
import com.datastax.driver.core.DataType;
import com.datastax.driver.core.ResultSet;
@@ -114,7 +111,6 @@ public class RestMusicDataAPI {
private static final String XPATCHVERSION = "X-patchVersion";
private static final String NS = "ns";
private static final String VERSION = "v2";
- private static MusicCoreService musicCore = MusicCassaCore.getInstance();
private class RowIdentifier {
public String primarKeyValue;
@@ -174,7 +170,7 @@ public class RestMusicDataAPI {
try {
- authMap = MusicAuthentication.authenticate(ns, userId, password, keyspaceName, aid,
+ authMap = MusicCore.authenticate(ns, userId, password, keyspaceName, aid,
"createKeySpace");
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.MISSINGDATA ,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
@@ -219,7 +215,7 @@ public class RestMusicDataAPI {
ResultType result = ResultType.FAILURE;
try {
- result = musicCore.nonKeyRelatedPut(queryObject, consistency);
+ result = MusicCore.nonKeyRelatedPut(queryObject, consistency);
logger.info(EELFLoggerDelegate.applicationLogger, "result = " + result);
} catch ( MusicServiceException ex) {
logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR);
@@ -230,12 +226,12 @@ public class RestMusicDataAPI {
queryObject = new PreparedQueryObject();
queryObject.appendQueryString("CREATE ROLE IF NOT EXISTS '" + userId
+ "' WITH PASSWORD = '" + password + "' AND LOGIN = true;");
- musicCore.nonKeyRelatedPut(queryObject, consistency);
+ MusicCore.nonKeyRelatedPut(queryObject, consistency);
queryObject = new PreparedQueryObject();
queryObject.appendQueryString("GRANT ALL PERMISSIONS on KEYSPACE " + keyspaceName
+ " to '" + userId + "'");
queryObject.appendQueryString(";");
- musicCore.nonKeyRelatedPut(queryObject, consistency);
+ MusicCore.nonKeyRelatedPut(queryObject, consistency);
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR);
}
@@ -256,7 +252,7 @@ public class RestMusicDataAPI {
queryObject.addValue(MusicUtil.convertToActualDataType(DataType.cboolean(), isAAF));
CachingUtil.updateMusicCache(keyspaceName, ns);
CachingUtil.updateMusicValidateCache(ns, userId, hashedpwd);
- musicCore.eventualPut(queryObject);
+ MusicCore.eventualPut(queryObject);
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR);
return response.status(Response.Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(e.getMessage()).toMap()).build();
@@ -290,7 +286,7 @@ public class RestMusicDataAPI {
Map<String,String> userCredentials = MusicUtil.extractBasicAuthentication(authorization);
String userId = userCredentials.get(MusicUtil.USERID);
String password = userCredentials.get(MusicUtil.PASSWORD);
- Map<String, Object> authMap = MusicAuthentication.authenticate(ns, userId, password,keyspaceName, aid, "dropKeySpace");
+ Map<String, Object> authMap = MusicCore.authenticate(ns, userId, password,keyspaceName, aid, "dropKeySpace");
if (authMap.containsKey("aid"))
authMap.remove("aid");
if (!authMap.isEmpty()) {
@@ -306,7 +302,7 @@ public class RestMusicDataAPI {
pQuery.appendQueryString(
"select count(*) as count from admin.keyspace_master where application_name=? allow filtering;");
pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), appName));
- Row row = musicCore.get(pQuery).one();
+ Row row = MusicCore.get(pQuery).one();
long count = row.getLong(0);
if (count == 0) {
@@ -320,17 +316,17 @@ public class RestMusicDataAPI {
pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(),
MusicUtil.DEFAULTKEYSPACENAME));
pQuery.addValue(MusicUtil.convertToActualDataType(DataType.uuid(), uuid));
- musicCore.nonKeyRelatedPut(pQuery, consistency);
+ MusicCore.nonKeyRelatedPut(pQuery, consistency);
} else {
pQuery = new PreparedQueryObject();
pQuery.appendQueryString("delete from admin.keyspace_master where uuid = ?");
pQuery.addValue(MusicUtil.convertToActualDataType(DataType.uuid(), uuid));
- musicCore.nonKeyRelatedPut(pQuery, consistency);
+ MusicCore.nonKeyRelatedPut(pQuery, consistency);
}
PreparedQueryObject queryObject = new PreparedQueryObject();
queryObject.appendQueryString("DROP KEYSPACE " + keyspaceName + ";");
- ResultType result = musicCore.nonKeyRelatedPut(queryObject, consistency);
+ ResultType result = MusicCore.nonKeyRelatedPut(queryObject, consistency);
if ( result.equals(ResultType.FAILURE) ) {
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(result).setError("Error Deleteing Keyspace " + keyspaceName).toMap()).build();
}
@@ -367,7 +363,7 @@ public class RestMusicDataAPI {
Map<String,String> userCredentials = MusicUtil.extractBasicAuthentication(authorization);
String userId = userCredentials.get(MusicUtil.USERID);
String password = userCredentials.get(MusicUtil.PASSWORD);
- Map<String, Object> authMap = MusicAuthentication.authenticate(ns, userId, password, keyspace,
+ Map<String, Object> authMap = MusicCore.authenticate(ns, userId, password, keyspace,
aid, "createTable");
if (authMap.containsKey("aid"))
authMap.remove("aid");
@@ -553,7 +549,7 @@ public class RestMusicDataAPI {
ResultType result = ResultType.FAILURE;
try {
//logger.info("cjc query="+queryObject.getQuery());
- result = musicCore.createTable(keyspace, tablename, queryObject, consistency);
+ result = MusicCore.createTable(keyspace, tablename, queryObject, consistency);
} catch (MusicServiceException ex) {
logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.CRITICAL, ErrorTypes.MUSICSERVICEERROR);
response.status(Status.BAD_REQUEST);
@@ -593,7 +589,7 @@ public class RestMusicDataAPI {
Map<String,String> userCredentials = MusicUtil.extractBasicAuthentication(authorization);
String userId = userCredentials.get(MusicUtil.USERID);
String password = userCredentials.get(MusicUtil.PASSWORD);
- Map<String, Object> authMap = MusicAuthentication.authenticate(ns, userId, password, keyspace,aid, "createIndex");
+ Map<String, Object> authMap = MusicCore.authenticate(ns, userId, password, keyspace,aid, "createIndex");
if (authMap.containsKey("aid"))
authMap.remove("aid");
if (!authMap.isEmpty()) {
@@ -611,7 +607,7 @@ public class RestMusicDataAPI {
ResultType result = ResultType.FAILURE;
try {
- result = musicCore.nonKeyRelatedPut(query, "eventual");
+ result = MusicCore.nonKeyRelatedPut(query, "eventual");
} catch (MusicServiceException ex) {
logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
response.status(Status.BAD_REQUEST);
@@ -657,7 +653,7 @@ public class RestMusicDataAPI {
Map<String, Object> authMap = null;
try {
- authMap = MusicAuthentication.authenticate(ns, userId, password, keyspace,
+ authMap = MusicCore.authenticate(ns, userId, password, keyspace,
aid, "insertIntoTable");
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.CRITICAL, ErrorTypes.AUTHENTICATIONERROR);
@@ -674,7 +670,7 @@ public class RestMusicDataAPI {
PreparedQueryObject queryObject = new PreparedQueryObject();
TableMetadata tableInfo = null;
try {
- tableInfo = MusicDataStoreHandle.returnColumnMetadata(keyspace, tablename);
+ tableInfo = MusicCore.returnColumnMetadata(keyspace, tablename);
if(tableInfo == null) {
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError("Table name doesn't exists. Please check the table name.").toMap()).build();
}
@@ -799,7 +795,7 @@ public class RestMusicDataAPI {
String consistency = insObj.getConsistencyInfo().get("type");
try {
if (consistency.equalsIgnoreCase(MusicUtil.EVENTUAL)) {
- result = musicCore.eventualPut(queryObject);
+ result = MusicCore.eventualPut(queryObject);
} else if (consistency.equalsIgnoreCase(MusicUtil.CRITICAL)) {
String lockId = insObj.getConsistencyInfo().get("lockId");
if(lockId == null) {
@@ -808,9 +804,9 @@ public class RestMusicDataAPI {
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError("LockId cannot be null. Create lock "
+ "and acquire lock or use ATOMIC instead of CRITICAL").toMap()).build();
}
- result = musicCore.criticalPut(keyspace, tablename, primaryKey, queryObject, lockId,null);
+ result = MusicCore.criticalPut(keyspace, tablename, primaryKey, queryObject, lockId,null);
} else if (consistency.equalsIgnoreCase(MusicUtil.ATOMIC)) {
- result = musicCore.atomicPut(keyspace, tablename, primaryKey, queryObject, null);
+ result = MusicCore.atomicPut(keyspace, tablename, primaryKey, queryObject, null);
}
} catch (Exception ex) {
@@ -863,7 +859,7 @@ public class RestMusicDataAPI {
String password = userCredentials.get(MusicUtil.PASSWORD);
Map<String, Object> authMap;
try {
- authMap = MusicAuthentication.authenticate(ns, userId, password, keyspace,
+ authMap = MusicCore.authenticate(ns, userId, password, keyspace,
aid, "updateTable");
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
@@ -888,7 +884,7 @@ public class RestMusicDataAPI {
TableMetadata tableInfo;
try {
- tableInfo = MusicDataStoreHandle.returnColumnMetadata(keyspace, tablename);
+ tableInfo = MusicCore.returnColumnMetadata(keyspace, tablename);
} catch (MusicServiceException e) {
logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(e.getMessage()).toMap()).build();
@@ -974,14 +970,14 @@ public class RestMusicDataAPI {
selectQuery.appendQueryString("SELECT * FROM " + keyspace + "." + tablename + " WHERE "
+ rowId.rowIdString + ";");
selectQuery.addValue(rowId.primarKeyValue);
- conditionInfo = new Condition(updateObj.getConditions(), selectQuery);
+ conditionInfo = new MusicCore.Condition(updateObj.getConditions(), selectQuery);
}
ReturnType operationResult = null;
long jsonParseCompletionTime = System.currentTimeMillis();
if (consistency.equalsIgnoreCase(MusicUtil.EVENTUAL))
- operationResult = musicCore.eventualPut(queryObject);
+ operationResult = MusicCore.eventualPut(queryObject);
else if (consistency.equalsIgnoreCase(MusicUtil.CRITICAL)) {
String lockId = updateObj.getConsistencyInfo().get("lockId");
if(lockId == null) {
@@ -990,11 +986,11 @@ public class RestMusicDataAPI {
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError("LockId cannot be null. Create lock "
+ "and acquire lock or use ATOMIC instead of CRITICAL").toMap()).build();
}
- operationResult = musicCore.criticalPut(keyspace, tablename, rowId.primarKeyValue,
+ operationResult = MusicCore.criticalPut(keyspace, tablename, rowId.primarKeyValue,
queryObject, lockId, conditionInfo);
} else if (consistency.equalsIgnoreCase(MusicUtil.ATOMIC)) {
try {
- operationResult = musicCore.atomicPut(keyspace, tablename, rowId.primarKeyValue,
+ operationResult = MusicCore.atomicPut(keyspace, tablename, rowId.primarKeyValue,
queryObject, conditionInfo);
} catch (MusicLockingException | MusicQueryException | MusicServiceException e) {
logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
@@ -1067,7 +1063,7 @@ public class RestMusicDataAPI {
String password = userCredentials.get(MusicUtil.PASSWORD);
Map<String, Object> authMap = null;
try {
- authMap = MusicAuthentication.authenticate(ns, userId, password, keyspace,
+ authMap = MusicCore.authenticate(ns, userId, password, keyspace,
aid, "deleteFromTable");
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
@@ -1131,7 +1127,7 @@ public class RestMusicDataAPI {
selectQuery.appendQueryString("SELECT * FROM " + keyspace + "." + tablename + " WHERE "
+ rowId.rowIdString + ";");
selectQuery.addValue(rowId.primarKeyValue);
- conditionInfo = new Condition(delObj.getConditions(), selectQuery);
+ conditionInfo = new MusicCore.Condition(delObj.getConditions(), selectQuery);
}
String consistency = delObj.getConsistencyInfo().get("type");
@@ -1139,7 +1135,7 @@ public class RestMusicDataAPI {
ReturnType operationResult = null;
try {
if (consistency.equalsIgnoreCase(MusicUtil.EVENTUAL))
- operationResult = musicCore.eventualPut(queryObject);
+ operationResult = MusicCore.eventualPut(queryObject);
else if (consistency.equalsIgnoreCase(MusicUtil.CRITICAL)) {
String lockId = delObj.getConsistencyInfo().get("lockId");
if(lockId == null) {
@@ -1148,10 +1144,10 @@ public class RestMusicDataAPI {
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError("LockId cannot be null. Create lock "
+ "and acquire lock or use ATOMIC instead of CRITICAL").toMap()).build();
}
- operationResult = musicCore.criticalPut(keyspace, tablename, rowId.primarKeyValue,
+ operationResult = MusicCore.criticalPut(keyspace, tablename, rowId.primarKeyValue,
queryObject, lockId, conditionInfo);
} else if (consistency.equalsIgnoreCase(MusicUtil.ATOMIC)) {
- operationResult = musicCore.atomicPut(keyspace, tablename, rowId.primarKeyValue,
+ operationResult = MusicCore.atomicPut(keyspace, tablename, rowId.primarKeyValue,
queryObject, conditionInfo);
}
} catch (MusicLockingException | MusicQueryException | MusicServiceException e) {
@@ -1203,7 +1199,7 @@ public class RestMusicDataAPI {
String userId = userCredentials.get(MusicUtil.USERID);
String password = userCredentials.get(MusicUtil.PASSWORD);
Map<String, Object> authMap =
- MusicAuthentication.authenticate(ns, userId, password, keyspace, aid, "dropTable");
+ MusicCore.authenticate(ns, userId, password, keyspace, aid, "dropTable");
if (authMap.containsKey("aid"))
authMap.remove("aid");
if (!authMap.isEmpty()) {
@@ -1215,7 +1211,7 @@ public class RestMusicDataAPI {
PreparedQueryObject query = new PreparedQueryObject();
query.appendQueryString("DROP TABLE " + keyspace + "." + tablename + ";");
try {
- return response.status(Status.OK).entity(new JsonResponse(musicCore.nonKeyRelatedPut(query, consistency)).toMap()).build();
+ return response.status(Status.OK).entity(new JsonResponse(MusicCore.nonKeyRelatedPut(query, consistency)).toMap()).build();
} catch (MusicServiceException ex) {
logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap()).build();
@@ -1258,7 +1254,7 @@ public class RestMusicDataAPI {
Map<String,String> userCredentials = MusicUtil.extractBasicAuthentication(authorization);
String userId = userCredentials.get(MusicUtil.USERID);
String password = userCredentials.get(MusicUtil.PASSWORD);
- Map<String, Object> authMap = MusicAuthentication.authenticate(ns, userId, password, keyspace,aid, "selectCritical");
+ Map<String, Object> authMap = MusicCore.authenticate(ns, userId, password, keyspace,aid, "selectCritical");
if (authMap.containsKey("aid"))
authMap.remove("aid");
if (!authMap.isEmpty()) {
@@ -1290,13 +1286,13 @@ public class RestMusicDataAPI {
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError("LockId cannot be null. Create lock "
+ "and acquire lock or use ATOMIC instead of CRITICAL").toMap()).build();
}
- results = musicCore.criticalGet(keyspace, tablename, rowId.primarKeyValue, queryObject,
+ results = MusicCore.criticalGet(keyspace, tablename, rowId.primarKeyValue, queryObject,
lockId);
} else if (consistency.equalsIgnoreCase(MusicUtil.ATOMIC)) {
- results = musicCore.atomicGet(keyspace, tablename, rowId.primarKeyValue, queryObject);
+ results = MusicCore.atomicGet(keyspace, tablename, rowId.primarKeyValue, queryObject);
}
if(results!=null && results.getAvailableWithoutFetching() >0) {
- return response.status(Status.OK).entity(new JsonResponse(ResultType.SUCCESS).setDataResult(MusicDataStoreHandle.marshallResults(results)).toMap()).build();
+ return response.status(Status.OK).entity(new JsonResponse(ResultType.SUCCESS).setDataResult(MusicCore.marshallResults(results)).toMap()).build();
}
return response.status(Status.OK).entity(new JsonResponse(ResultType.SUCCESS).setError("No data found").toMap()).build();
@@ -1337,7 +1333,7 @@ public class RestMusicDataAPI {
String userId = userCredentials.get(MusicUtil.USERID);
String password = userCredentials.get(MusicUtil.PASSWORD);
Map<String, Object> authMap =
- MusicAuthentication.authenticate(ns, userId, password, keyspace, aid, "select");
+ MusicCore.authenticate(ns, userId, password, keyspace, aid, "select");
if (authMap.containsKey("aid"))
authMap.remove("aid");
if (!authMap.isEmpty()) {
@@ -1360,9 +1356,9 @@ public class RestMusicDataAPI {
}
try {
- ResultSet results = musicCore.get(queryObject);
+ ResultSet results = MusicCore.get(queryObject);
if(results.getAvailableWithoutFetching() >0) {
- return response.status(Status.OK).entity(new JsonResponse(ResultType.SUCCESS).setDataResult(MusicDataStoreHandle.marshallResults(results)).toMap()).build();
+ return response.status(Status.OK).entity(new JsonResponse(ResultType.SUCCESS).setDataResult(MusicCore.marshallResults(results)).toMap()).build();
}
return response.status(Status.OK).entity(new JsonResponse(ResultType.SUCCESS).setError("No data found").toMap()).build();
} catch (MusicServiceException ex) {
@@ -1416,7 +1412,7 @@ public class RestMusicDataAPI {
throws MusicServiceException {
StringBuilder rowSpec = new StringBuilder();
int counter = 0;
- TableMetadata tableInfo = MusicDataStoreHandle.returnColumnMetadata(keyspace, tablename);
+ TableMetadata tableInfo = MusicCore.returnColumnMetadata(keyspace, tablename);
if (tableInfo == null) {
logger.error(EELFLoggerDelegate.errorLogger,
"Table information not found. Please check input for table name= "
diff --git a/src/main/java/org/onap/music/rest/RestMusicLocksAPI.java b/src/main/java/org/onap/music/rest/RestMusicLocksAPI.java
index 92dd625e..835dda14 100644
--- a/src/main/java/org/onap/music/rest/RestMusicLocksAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicLocksAPI.java
@@ -40,14 +40,12 @@ import org.onap.music.eelf.logging.EELFLoggerDelegate;
import org.onap.music.eelf.logging.format.AppMessages;
import org.onap.music.eelf.logging.format.ErrorSeverity;
import org.onap.music.eelf.logging.format.ErrorTypes;
-import org.onap.music.lockingservice.cassandra.MusicLockState;
-import org.onap.music.authentication.MusicAuthentication;
+import org.onap.music.datastore.MusicLockState;
+import org.onap.music.main.MusicCore;
import org.onap.music.main.MusicUtil;
import org.onap.music.main.ResultType;
import org.onap.music.main.ReturnType;
import org.onap.music.response.jsonobjects.JsonResponse;
-import org.onap.music.service.MusicCoreService;
-import org.onap.music.service.impl.MusicCassaCore;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -62,7 +60,6 @@ public class RestMusicLocksAPI {
private static final String XMINORVERSION = "X-minorVersion";
private static final String XPATCHVERSION = "X-patchVersion";
private static final String VERSION = "v2";
- private static MusicCoreService musicCore = MusicCassaCore.getInstance();
/**
* Puts the requesting process in the q for this lock. The corresponding
@@ -89,7 +86,7 @@ public class RestMusicLocksAPI {
@ApiParam(value = "Application namespace",
required = true) @HeaderParam("ns") String ns) throws Exception{
ResponseBuilder response = MusicUtil.buildVersionResponse(VERSION, minorVersion, patchVersion);
- Map<String, Object> resultMap = MusicCassaCore.validateLock(lockName);
+ Map<String, Object> resultMap = MusicCore.validateLock(lockName);
if (resultMap.containsKey("Exception")) {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
return response.status(Status.BAD_REQUEST).entity(resultMap).build();
@@ -99,7 +96,7 @@ public class RestMusicLocksAPI {
String password = userCredentials.get(MusicUtil.PASSWORD);
String keyspaceName = (String) resultMap.get("keyspace");
resultMap.remove("keyspace");
- resultMap = MusicAuthentication.authenticate(ns, userId, password, keyspaceName, aid,
+ resultMap = MusicCore.authenticate(ns, userId, password, keyspaceName, aid,
"createLockReference");
if (resultMap.containsKey("aid"))
resultMap.remove("aid");
@@ -108,7 +105,7 @@ public class RestMusicLocksAPI {
return response.status(Status.UNAUTHORIZED).entity(resultMap).build();
}
ResultType status = ResultType.SUCCESS;
- String lockId = musicCore.createLockReference(lockName);
+ String lockId = MusicCore.createLockReference(lockName);
if (lockId == null) {
status = ResultType.FAILURE;
@@ -141,7 +138,7 @@ public class RestMusicLocksAPI {
@ApiParam(value = "Application namespace",
required = true) @HeaderParam("ns") String ns) throws Exception{
ResponseBuilder response = MusicUtil.buildVersionResponse(VERSION, minorVersion, patchVersion);
- Map<String, Object> resultMap = MusicCassaCore.validateLock(lockId);
+ Map<String, Object> resultMap = MusicCore.validateLock(lockId);
if (resultMap.containsKey("Exception")) {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
return response.status(Status.BAD_REQUEST).entity(resultMap).build();
@@ -151,7 +148,7 @@ public class RestMusicLocksAPI {
String password = userCredentials.get(MusicUtil.PASSWORD);
String keyspaceName = (String) resultMap.get("keyspace");
resultMap.remove("keyspace");
- resultMap = MusicAuthentication.authenticate(ns, userId, password, keyspaceName, aid,
+ resultMap = MusicCore.authenticate(ns, userId, password, keyspaceName, aid,
"accquireLock");
if (resultMap.containsKey("aid"))
resultMap.remove("aid");
@@ -161,7 +158,7 @@ public class RestMusicLocksAPI {
}
try {
String lockName = lockId.substring(lockId.indexOf('$')+1, lockId.lastIndexOf('$'));
- ReturnType lockStatus = musicCore.acquireLock(lockName,lockId);
+ ReturnType lockStatus = MusicCore.acquireLock(lockName,lockId);
if ( lockStatus.getResult().equals(ResultType.SUCCESS)) {
response.status(Status.OK);
} else {
@@ -191,7 +188,7 @@ public class RestMusicLocksAPI {
@ApiParam(value = "Application namespace",
required = true) @HeaderParam("ns") String ns) throws Exception{
ResponseBuilder response = MusicUtil.buildVersionResponse(VERSION, minorVersion, patchVersion);
- Map<String, Object> resultMap = MusicCassaCore.validateLock(lockId);
+ Map<String, Object> resultMap = MusicCore.validateLock(lockId);
if (resultMap.containsKey("Exception")) {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
return response.status(Status.BAD_REQUEST).entity(resultMap).build();
@@ -201,7 +198,7 @@ public class RestMusicLocksAPI {
String password = userCredentials.get(MusicUtil.PASSWORD);
String keyspaceName = (String) resultMap.get("keyspace");
resultMap.remove("keyspace");
- resultMap = MusicAuthentication.authenticate(ns, userId, password, keyspaceName, aid,
+ resultMap = MusicCore.authenticate(ns, userId, password, keyspaceName, aid,
"accquireLockWithLease");
if (resultMap.containsKey("aid"))
@@ -211,7 +208,7 @@ public class RestMusicLocksAPI {
return response.status(Status.BAD_REQUEST).entity(resultMap).build();
}
String lockName = lockId.substring(lockId.indexOf('$')+1, lockId.lastIndexOf('$'));
- ReturnType lockLeaseStatus = musicCore.acquireLockWithLease(lockName, lockId, lockObj.getLeasePeriod());
+ ReturnType lockLeaseStatus = MusicCore.acquireLockWithLease(lockName, lockId, lockObj.getLeasePeriod());
if ( lockLeaseStatus.getResult().equals(ResultType.SUCCESS)) {
response.status(Status.OK);
} else {
@@ -238,7 +235,7 @@ public class RestMusicLocksAPI {
@ApiParam(value = "Application namespace",
required = true) @HeaderParam("ns") String ns) throws Exception{
ResponseBuilder response = MusicUtil.buildVersionResponse(VERSION, minorVersion, patchVersion);
- Map<String, Object> resultMap = MusicCassaCore.validateLock(lockName);
+ Map<String, Object> resultMap = MusicCore.validateLock(lockName);
if (resultMap.containsKey("Exception")) {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
return response.status(Status.BAD_REQUEST).entity(resultMap).build();
@@ -248,7 +245,7 @@ public class RestMusicLocksAPI {
String password = userCredentials.get(MusicUtil.PASSWORD);
String keyspaceName = (String) resultMap.get("keyspace");
resultMap.remove("keyspace");
- resultMap = MusicAuthentication.authenticate(ns, userId, password, keyspaceName, aid,
+ resultMap = MusicCore.authenticate(ns, userId, password, keyspaceName, aid,
"currentLockHolder");
if (resultMap.containsKey("aid"))
resultMap.remove("aid");
@@ -256,7 +253,7 @@ public class RestMusicLocksAPI {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
return response.status(Status.BAD_REQUEST).entity(resultMap).build();
}
- String who = musicCore.whoseTurnIsIt(lockName);
+ String who = MusicCore.whoseTurnIsIt(lockName);
ResultType status = ResultType.SUCCESS;
String error = "";
if ( who == null ) {
@@ -287,14 +284,14 @@ public class RestMusicLocksAPI {
@ApiParam(value = "Password",
required = true) @HeaderParam("password") String password) throws Exception{
ResponseBuilder response = MusicUtil.buildVersionResponse(VERSION, minorVersion, patchVersion);
- Map<String, Object> resultMap = MusicCassaCore.validateLock(lockName);
+ Map<String, Object> resultMap = MusicCore.validateLock(lockName);
if (resultMap.containsKey("Exception")) {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
return response.status(Status.BAD_REQUEST).entity(resultMap).build();
}
String keyspaceName = (String) resultMap.get("keyspace");
resultMap.remove("keyspace");
- resultMap = MusicAuthentication.authenticate(ns, userId, password, keyspaceName, aid,
+ resultMap = MusicCore.authenticate(ns, userId, password, keyspaceName, aid,
"currentLockState");
if (resultMap.containsKey("aid"))
@@ -304,7 +301,7 @@ public class RestMusicLocksAPI {
return response.status(Status.BAD_REQUEST).entity(resultMap).build();
}
- org.onap.music.lockingservice.cassandra.MusicLockState mls = MusicCassaCore.getMusicLockState(lockName);
+ org.onap.music.datastore.MusicLockState mls = MusicCore.getMusicLockState(lockName);
Map<String,Object> returnMap = null;
JsonResponse jsonResponse = new JsonResponse(ResultType.FAILURE).setLock(lockName);
if(mls == null) {
@@ -341,7 +338,7 @@ public class RestMusicLocksAPI {
@ApiParam(value = "Application namespace",
required = true) @HeaderParam("ns") String ns) throws Exception{
ResponseBuilder response = MusicUtil.buildVersionResponse(VERSION, minorVersion, patchVersion);
- Map<String, Object> resultMap = MusicCassaCore.validateLock(lockId);
+ Map<String, Object> resultMap = MusicCore.validateLock(lockId);
if (resultMap.containsKey("Exception")) {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
return response.status(Status.BAD_REQUEST).entity(resultMap).build();
@@ -351,7 +348,7 @@ public class RestMusicLocksAPI {
String password = userCredentials.get(MusicUtil.PASSWORD);
String keyspaceName = (String) resultMap.get("keyspace");
resultMap.remove("keyspace");
- resultMap = MusicAuthentication.authenticate(ns, userId, password, keyspaceName, aid,
+ resultMap = MusicCore.authenticate(ns, userId, password, keyspaceName, aid,
"unLock");
if (resultMap.containsKey("aid"))
resultMap.remove("aid");
@@ -360,7 +357,7 @@ public class RestMusicLocksAPI {
return response.status(Status.BAD_REQUEST).entity(resultMap).build();
}
String fullyQualifiedKey = lockId.substring(lockId.indexOf('$')+1, lockId.lastIndexOf('$'));
- MusicLockState mls = musicCore.voluntaryReleaseLock(fullyQualifiedKey, lockId);
+ MusicLockState mls = MusicCore.voluntaryReleaseLock(fullyQualifiedKey, lockId);
if(mls.getErrorMessage() != null) {
resultMap.put(ResultType.EXCEPTION.getResult(), mls.getErrorMessage());
@@ -399,7 +396,7 @@ public class RestMusicLocksAPI {
@ApiParam(value = "Application namespace",
required = true) @HeaderParam("ns") String ns) throws Exception{
ResponseBuilder response = MusicUtil.buildVersionResponse(VERSION, minorVersion, patchVersion);
- Map<String, Object> resultMap = MusicCassaCore.validateLock(lockName);
+ Map<String, Object> resultMap = MusicCore.validateLock(lockName);
if (resultMap.containsKey("Exception")) {
logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.UNKNOWNERROR ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
return response.status(Status.BAD_REQUEST).entity(resultMap).build();
@@ -409,7 +406,7 @@ public class RestMusicLocksAPI {
String password = userCredentials.get(MusicUtil.PASSWORD);
String keyspaceName = (String) resultMap.get("keyspace");
resultMap.remove("keyspace");
- resultMap = MusicAuthentication.authenticate(ns, userId, password, keyspaceName, aid,
+ resultMap = MusicCore.authenticate(ns, userId, password, keyspaceName, aid,
"deleteLock");
if (resultMap.containsKey("aid"))
resultMap.remove("aid");
@@ -418,7 +415,7 @@ public class RestMusicLocksAPI {
return response.status(Status.BAD_REQUEST).entity(resultMap).build();
}
try{
- musicCore.deleteLock(lockName);
+ MusicCore.deleteLock(lockName);
}catch (Exception e) {
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(e.getMessage()).toMap()).build();
}
diff --git a/src/main/java/org/onap/music/rest/RestMusicQAPI.java b/src/main/java/org/onap/music/rest/RestMusicQAPI.java
index 9248ee1a..8af334c7 100755
--- a/src/main/java/org/onap/music/rest/RestMusicQAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicQAPI.java
@@ -45,17 +45,14 @@ import org.onap.music.eelf.logging.format.AppMessages;
import org.onap.music.eelf.logging.format.ErrorSeverity;
import org.onap.music.eelf.logging.format.ErrorTypes;
import org.apache.commons.lang3.StringUtils;
-import org.onap.music.datastore.MusicDataStoreHandle;
import org.onap.music.datastore.PreparedQueryObject;
import com.datastax.driver.core.ResultSet;
import org.onap.music.exceptions.MusicServiceException;
+import org.onap.music.main.MusicCore;
import org.onap.music.main.MusicUtil;
import org.onap.music.main.ResultType;
// cjc import org.onap.music.main.ReturnType;
import org.onap.music.response.jsonobjects.JsonResponse;
-import org.onap.music.service.MusicCoreService;
-import org.onap.music.service.impl.MusicCassaCore;
-
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@@ -67,7 +64,6 @@ import io.swagger.annotations.ApiParam;
public class RestMusicQAPI {
private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RestMusicQAPI.class);
- private static MusicCoreService musicCore = MusicCassaCore.getInstance();
// private static String xLatestVersion = "X-latestVersion";
/*
* private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RestMusicDataAPI.class);
@@ -416,9 +412,9 @@ public class RestMusicQAPI {
}
try {
- ResultSet results = musicCore.get(queryObject);
+ ResultSet results = MusicCore.get(queryObject);
return response.status(Status.OK).entity(new JsonResponse(ResultType.SUCCESS)
- .setDataResult(MusicDataStoreHandle.marshallResults(results)).toMap()).build();
+ .setDataResult(MusicCore.marshallResults(results)).toMap()).build();
} catch (MusicServiceException ex) {
logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.UNKNOWNERROR,
ErrorSeverity.ERROR, ErrorTypes.MUSICSERVICEERROR);