Revert "music core implemented as a service" 92/72792/1
authorTschaen, Brendan <ctschaen@att.com>
Thu, 15 Nov 2018 15:31:53 +0000 (10:31 -0500)
committerTschaen, Brendan <ctschaen@att.com>
Thu, 15 Nov 2018 15:32:38 +0000 (10:32 -0500)
This reverts commit 7addd52dc73e6571028ca7f6a018e75ec1c9b0ca.

Change-Id: I0875ce10521363b8e17eb6cd2cf9d8848e572bea
Issue-ID: MUSIC-189
Signed-off-by: Tschaen, Brendan <ctschaen@att.com>
28 files changed:
src/main/java/org/onap/music/authentication/MusicAuthentication.java [deleted file]
src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java
src/main/java/org/onap/music/conductor/conditionals/RestMusicConditionalAPI.java
src/main/java/org/onap/music/datastore/CassaDataStore.java [moved from src/main/java/org/onap/music/datastore/MusicDataStore.java with 98% similarity]
src/main/java/org/onap/music/datastore/CassaLockStore.java [moved from src/main/java/org/onap/music/lockingservice/cassandra/CassaLockStore.java with 96% similarity]
src/main/java/org/onap/music/datastore/Condition.java [deleted file]
src/main/java/org/onap/music/datastore/MusicDataStoreHandle.java [deleted file]
src/main/java/org/onap/music/datastore/MusicLockState.java [moved from src/main/java/org/onap/music/lockingservice/cassandra/MusicLockState.java with 94% similarity]
src/main/java/org/onap/music/eelf/healthcheck/MusicHealthCheck.java
src/main/java/org/onap/music/main/CachingUtil.java
src/main/java/org/onap/music/main/CronJobManager.java
src/main/java/org/onap/music/main/MusicCore.java [moved from src/main/java/org/onap/music/service/impl/MusicCassaCore.java with 69% similarity]
src/main/java/org/onap/music/main/VotingAppJar.java
src/main/java/org/onap/music/response/jsonobjects/JsonResponse.java
src/main/java/org/onap/music/rest/RestMusicAdminAPI.java
src/main/java/org/onap/music/rest/RestMusicDataAPI.java
src/main/java/org/onap/music/rest/RestMusicLocksAPI.java
src/main/java/org/onap/music/rest/RestMusicQAPI.java
src/main/java/org/onap/music/service/MusicCoreService.java [deleted file]
src/test/java/org/onap/music/unittests/CassandraCQL.java [moved from src/test/java/org/onap/music/unittests/CassandraCQLQueries.java with 97% similarity]
src/test/java/org/onap/music/unittests/MusicDataStoreTest.java
src/test/java/org/onap/music/unittests/MusicLockStoreTest.java
src/test/java/org/onap/music/unittests/TestCassaLockStore.java
src/test/java/org/onap/music/unittests/TestMusicCore.java
src/test/java/org/onap/music/unittests/TestMusicCoreIntegration.java
src/test/java/org/onap/music/unittests/TestRestMusicData.java
src/test/java/org/onap/music/unittests/TestRestMusicQAPI.java
src/test/java/org/onap/music/unittests/TestVotingApp.java

diff --git a/src/main/java/org/onap/music/authentication/MusicAuthentication.java b/src/main/java/org/onap/music/authentication/MusicAuthentication.java
deleted file mode 100644 (file)
index 4967e84..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * ============LICENSE_START==========================================
- * org.onap.music
- * ===================================================================
- *  Copyright (c) 2017 AT&T Intellectual Property
- * ===================================================================
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- * 
- * ============LICENSE_END=============================================
- * ====================================================================
- */
-package org.onap.music.authentication;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.onap.music.datastore.PreparedQueryObject;
-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.exceptions.MusicServiceException;
-import org.onap.music.main.CachingUtil;
-import org.onap.music.main.MusicUtil;
-import org.onap.music.service.MusicCoreService;
-import org.onap.music.service.impl.MusicCassaCore;
-
-import com.datastax.driver.core.DataType;
-import com.datastax.driver.core.Row;
-
-public class MusicAuthentication {
-       
-       private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicAuthentication.class);
-       
-       private static MusicCoreService musicCore = MusicCassaCore.getInstance();
-       
-         /**
-     * authenticate user logic
-     * 
-     * @param nameSpace
-     * @param userId
-     * @param password
-     * @param keyspace
-     * @param aid
-     * @param operation
-     * @return
-     * @throws Exception
-     */
-    public static Map<String, Object> authenticate(String nameSpace, String userId,
-                    String password, String keyspace, String aid, String operation)
-                    throws Exception {
-        Map<String, Object> resultMap = new HashMap<>();
-        String uuid = null;
-        resultMap = CachingUtil.validateRequest(nameSpace, userId, password, keyspace, aid,
-                        operation);
-        if (!resultMap.isEmpty())
-            return resultMap;
-        String isAAFApp = null;
-        try {
-            isAAFApp= CachingUtil.isAAFApplication(nameSpace);
-        } catch(MusicServiceException e) {
-           resultMap.put("Exception", e.getMessage());
-           return resultMap;
-        }
-        if(isAAFApp == null) {
-            resultMap.put("Exception", "Namespace: "+nameSpace+" doesn't exist. Please make sure ns(appName)"
-                    + " is correct and Application is onboarded.");
-            return resultMap;
-        }
-        boolean isAAF = Boolean.valueOf(isAAFApp);
-        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);
-            resultMap.put("Exception",
-                            "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 {
-                isValid = CachingUtil.authenticateAAFUser(nameSpace, userId, password, keyspace);
-            } catch (Exception e) {
-               logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.AUTHENTICATIONERROR  ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
-                logger.error(EELFLoggerDelegate.errorLogger,"Got exception while AAF authentication for namespace " + nameSpace);
-                resultMap.put("Exception", e.getMessage());
-            }
-            if (!isValid) {
-               logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.AUTHENTICATIONERROR  ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
-                resultMap.put("Exception", "User not authenticated...");
-            }
-            if (!resultMap.isEmpty())
-                return resultMap;
-
-        }
-
-        if (operation.equals("createKeySpace")) {
-            logger.info(EELFLoggerDelegate.applicationLogger,"AID is not provided. Creating new UUID for keyspace.");
-            PreparedQueryObject pQuery = new PreparedQueryObject();
-            pQuery.appendQueryString(
-                            "select uuid from admin.keyspace_master where application_name=? and username=? and keyspace_name=? allow filtering");
-            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), nameSpace));
-            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), userId));
-            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(),
-                            MusicUtil.DEFAULTKEYSPACENAME));
-
-            try {
-                Row rs = musicCore.get(pQuery).one();
-                uuid = rs.getUUID("uuid").toString();
-                resultMap.put("uuid", "existing");
-            } catch (Exception e) {
-                logger.info(EELFLoggerDelegate.applicationLogger,"No UUID found in DB. So creating new UUID.");
-                uuid = CachingUtil.generateUUID();
-                resultMap.put("uuid", "new");
-            }
-            resultMap.put("aid", uuid);
-        }
-
-        return resultMap;
-    }
-
-}
index 281c6ca..8aadcba 100644 (file)
@@ -27,18 +27,16 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.codehaus.jettison.json.JSONObject;
-import org.onap.music.datastore.MusicDataStoreHandle;
 import org.onap.music.datastore.PreparedQueryObject;
 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.main.MusicCore;
 import org.onap.music.main.MusicUtil;
 import org.onap.music.main.ResultType;
 import org.onap.music.main.ReturnType;
 import org.onap.music.rest.RestMusicDataAPI;
-import org.onap.music.service.MusicCoreService;
-import org.onap.music.service.impl.MusicCassaCore;
 
 import com.datastax.driver.core.ColumnDefinitions;
 import com.datastax.driver.core.DataType;
@@ -48,7 +46,6 @@ import com.datastax.driver.core.TableMetadata;
 
 public class MusicConditional {
        private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RestMusicDataAPI.class);
-       private static MusicCoreService musicCore = MusicCassaCore.getInstance();
 
        public static ReturnType conditionalInsert(String keyspace, String tablename, String casscadeColumnName,
                        Map<String, Object> casscadeColumnData, String primaryKey, Map<String, Object> valuesMap,
@@ -56,7 +53,7 @@ public class MusicConditional {
 
                Map<String, PreparedQueryObject> queryBank = new HashMap<>();
                TableMetadata tableInfo = null;
-               tableInfo = MusicDataStoreHandle.returnColumnMetadata(keyspace, tablename);
+               tableInfo = MusicCore.returnColumnMetadata(keyspace, tablename);
                DataType primaryIdType = tableInfo.getPrimaryKey().get(0).getType();
                String primaryId = tableInfo.getPrimaryKey().get(0).getName();
                DataType casscadeColumnType = tableInfo.getColumn(casscadeColumnName).getType();
@@ -87,15 +84,15 @@ public class MusicConditional {
                
                
                String key = keyspace + "." + tablename + "." + primaryKey;
-               String lockId = musicCore.createLockReference(key);
+               String lockId = MusicCore.createLockReference(key);
                long leasePeriod = MusicUtil.getDefaultLockLeasePeriod();
-               ReturnType lockAcqResult = musicCore.acquireLockWithLease(key, lockId, leasePeriod);
+               ReturnType lockAcqResult = MusicCore.acquireLockWithLease(key, lockId, leasePeriod);
 
                try {
                        if (lockAcqResult.getResult().equals(ResultType.SUCCESS)) {
                                ReturnType criticalPutResult = conditionalInsertAtomic(lockId, keyspace, tablename, primaryKey,
                                                queryBank);
-                               musicCore.destroyLockRef(key,lockId);
+                               MusicCore.destroyLockRef(key,lockId);
                                if (criticalPutResult.getMessage().contains("insert"))
                                        criticalPutResult
                                                        .setMessage("Insert values: ");
@@ -105,11 +102,11 @@ public class MusicConditional {
                                return criticalPutResult;
 
                        } else {
-                               musicCore.destroyLockRef(key,lockId);
+                               MusicCore.destroyLockRef(key,lockId);
                                return lockAcqResult;
                        }
                } catch (Exception e) {
-                       musicCore.destroyLockRef(key,lockId);
+                       MusicCore.destroyLockRef(key,lockId);
                        return new ReturnType(ResultType.FAILURE, e.getMessage());
                }
 
@@ -122,18 +119,18 @@ public class MusicConditional {
 
                try {
                        String fullyQualifiedKey = keyspace + "." + tableName + "." + primaryKey;
-               ReturnType lockAcqResult = musicCore.acquireLock(fullyQualifiedKey, lockId);
+               ReturnType lockAcqResult = MusicCore.acquireLock(fullyQualifiedKey, lockId);
                if (lockAcqResult.getResult().equals(ResultType.SUCCESS)) {
                                try {
-                                       results = MusicDataStoreHandle.getDSHandle().executeCriticalGet(queryBank.get(MusicUtil.SELECT));
+                                       results = MusicCore.getDSHandle().executeCriticalGet(queryBank.get(MusicUtil.SELECT));
                                } catch (Exception e) {
                                        return new ReturnType(ResultType.FAILURE, e.getMessage());
                                }
                                if (results.all().isEmpty()) {
-                                       MusicDataStoreHandle.getDSHandle().executePut(queryBank.get(MusicUtil.INSERT), "critical");
+                                       MusicCore.getDSHandle().executePut(queryBank.get(MusicUtil.INSERT), "critical");
                                        return new ReturnType(ResultType.SUCCESS, "insert");
                                } else {
-                                       MusicDataStoreHandle.getDSHandle().executePut(queryBank.get(MusicUtil.UPDATE), "critical");
+                                       MusicCore.getDSHandle().executePut(queryBank.get(MusicUtil.UPDATE), "critical");
                                        return new ReturnType(ResultType.SUCCESS, "update");
                                }
                        } else {
@@ -155,20 +152,20 @@ public class MusicConditional {
        public static ReturnType update(Map<String,PreparedQueryObject> queryBank, String keyspace, String tableName, String primaryKey,String primaryKeyValue,String planId,String cascadeColumnName,Map<String,String> cascadeColumnValues) {
 
                String key = keyspace + "." + tableName + "." + primaryKeyValue;
-               String lockId = musicCore.createLockReference(key);
+               String lockId = MusicCore.createLockReference(key);
                long leasePeriod = MusicUtil.getDefaultLockLeasePeriod();
                try {
-               ReturnType lockAcqResult = musicCore.acquireLockWithLease(key, lockId, leasePeriod);
+               ReturnType lockAcqResult = MusicCore.acquireLockWithLease(key, lockId, leasePeriod);
                        if (lockAcqResult.getResult().equals(ResultType.SUCCESS)) {
                                return updateAtomic(lockId, keyspace, tableName, primaryKey,primaryKeyValue, queryBank,planId,cascadeColumnValues,cascadeColumnName);
 
                        } else {
-                               musicCore.destroyLockRef(key,lockId);
+                               MusicCore.destroyLockRef(key,lockId);
                                return lockAcqResult;
                        }
 
                } catch (Exception e) {
-                       musicCore.destroyLockRef(key,lockId);
+                       MusicCore.destroyLockRef(key,lockId);
                        return new ReturnType(ResultType.FAILURE, e.getMessage());
 
                }
@@ -179,9 +176,9 @@ public class MusicConditional {
                String key = keyspace + "." + tableName + "." + primaryKeyValue;
                long leasePeriod = MusicUtil.getDefaultLockLeasePeriod();
                try {
-                       ReturnType lockAcqResult = musicCore.acquireLockWithLease(key, lockId, leasePeriod);
+                       ReturnType lockAcqResult = MusicCore.acquireLockWithLease(key, lockId, leasePeriod);
                        if (lockAcqResult.getResult().equals(ResultType.SUCCESS)) {
-                               Row row  = MusicDataStoreHandle.getDSHandle().executeCriticalGet(queryBank.get(MusicUtil.SELECT)).one();
+                               Row row  = MusicCore.getDSHandle().executeCriticalGet(queryBank.get(MusicUtil.SELECT)).one();
                                
                                if(row != null) {
                                        Map<String, String> updatedValues = cascadeColumnUpdateSpecific(row, cascadeColumnValues, casscadeColumnName, planId);
@@ -194,14 +191,14 @@ public class MusicConditional {
                                        update.addValue(MusicUtil.convertToActualDataType(DataType.text(), vector_ts));
                                        update.addValue(MusicUtil.convertToActualDataType(DataType.text(), primaryKeyValue));
                                        try {
-                                               MusicDataStoreHandle.getDSHandle().executePut(update, "critical");
+                                               MusicCore.getDSHandle().executePut(update, "critical");
                                        } catch (Exception ex) {
                                                return new ReturnType(ResultType.FAILURE, ex.getMessage());
                                        }
                                }else {
                                        return new ReturnType(ResultType.FAILURE,"Cannot find data related to key: "+primaryKey);
                                }
-                               MusicDataStoreHandle.getDSHandle().executePut(queryBank.get(MusicUtil.UPSERT), "critical");
+                               MusicCore.getDSHandle().executePut(queryBank.get(MusicUtil.UPSERT), "critical");
                                return new ReturnType(ResultType.SUCCESS, "update success");
 
                        } else {
index 63c104f..4292749 100644 (file)
@@ -38,19 +38,17 @@ import javax.ws.rs.core.Response.ResponseBuilder;
 import javax.ws.rs.core.Response.Status;
 
 import org.codehaus.jettison.json.JSONObject;
-import org.onap.music.datastore.MusicDataStoreHandle;
 import org.onap.music.datastore.PreparedQueryObject;
 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.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.rest.RestMusicAdminAPI;
-import org.onap.music.service.impl.MusicCassaCore;
-import org.onap.music.authentication.MusicAuthentication;
 import org.onap.music.conductor.*;
 
 
@@ -105,7 +103,7 @@ public class RestMusicConditionalAPI {
 
                Map<String, Object> authMap = null;
                try {
-                       authMap = MusicAuthentication.authenticate(ns, userId, password, keyspace, aid, "insertIntoTable");
+                       authMap = MusicCore.authenticate(ns, userId, password, keyspace, aid, "insertIntoTable");
                } catch (Exception e) {
                        logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGINFO, ErrorSeverity.CRITICAL,
                                        ErrorTypes.AUTHENTICATIONERROR);
@@ -176,7 +174,7 @@ public class RestMusicConditionalAPI {
 
                Map<String, Object> authMap = null;
                try {
-                       authMap = MusicAuthentication.authenticate(ns, userId, password, keyspace, aid, "updateTable");
+                       authMap = MusicCore.authenticate(ns, userId, password, keyspace, aid, "updateTable");
                } catch (Exception e) {
                        logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGINFO, ErrorSeverity.CRITICAL,
                                        ErrorTypes.AUTHENTICATIONERROR);
@@ -196,7 +194,7 @@ public class RestMusicConditionalAPI {
                String planId = casscadeColumnData.get("key").toString();
                Map<String,String> casscadeColumnValueMap = (Map<String, String>) casscadeColumnData.get("value");
                TableMetadata tableInfo = null;
-               tableInfo = MusicDataStoreHandle.returnColumnMetadata(keyspace, tablename);
+               tableInfo = MusicCore.returnColumnMetadata(keyspace, tablename);
                DataType primaryIdType = tableInfo.getPrimaryKey().get(0).getType();
                String primaryId = tableInfo.getPrimaryKey().get(0).getName();
                
@@ -89,7 +89,7 @@ import com.sun.jersey.core.util.Base64;
  * @author bharathb
  *
  */
-public class MusicDataStore {
+public class CassaDataStore {
 
     private Session session;
     private Cluster cluster;
@@ -119,12 +119,12 @@ public class MusicDataStore {
 
 
 
-    private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicDataStore.class);
+    private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(CassaDataStore.class);
 
     /**
      * 
      */
-    public MusicDataStore() {
+    public CassaDataStore() {
         connectToCassaCluster();
     }
 
@@ -133,7 +133,7 @@ public class MusicDataStore {
      * @param cluster
      * @param session
      */
-    public MusicDataStore(Cluster cluster, Session session) {
+    public CassaDataStore(Cluster cluster, Session session) {
         this.session = session;
         this.cluster = cluster;
     }
@@ -143,7 +143,7 @@ public class MusicDataStore {
      * @param remoteIp
      * @throws MusicServiceException
      */
-    public MusicDataStore(String remoteIp) {
+    public CassaDataStore(String remoteIp) {
         try {
             connectToCassaCluster(remoteIp);
         } catch (MusicServiceException e) {
@@ -1,9 +1,7 @@
-package org.onap.music.lockingservice.cassandra;
+package org.onap.music.datastore;
 
 import java.util.UUID;
 
-import org.onap.music.datastore.MusicDataStore;
-import org.onap.music.datastore.PreparedQueryObject;
 import org.onap.music.eelf.logging.EELFLoggerDelegate;
 import org.onap.music.exceptions.MusicQueryException;
 import org.onap.music.exceptions.MusicServiceException;
@@ -32,12 +30,12 @@ public class CassaLockStore {
                        
                }
        }
-       MusicDataStore dsHandle;
+       CassaDataStore dsHandle;
        public CassaLockStore() {
-               dsHandle = new MusicDataStore();
+               dsHandle = new CassaDataStore();
        }
        
-       public CassaLockStore(MusicDataStore dsHandle) {
+       public CassaLockStore(CassaDataStore dsHandle) {
                this.dsHandle=dsHandle;
        }
 
diff --git a/src/main/java/org/onap/music/datastore/Condition.java b/src/main/java/org/onap/music/datastore/Condition.java
deleted file mode 100644 (file)
index f08a875..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * ============LICENSE_START==========================================
- * org.onap.music
- * ===================================================================
- *  Copyright (c) 2017 AT&T Intellectual Property
- * ===================================================================
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- * 
- * ============LICENSE_END=============================================
- * ====================================================================
- */
-package org.onap.music.datastore;
-
-import java.util.Map;
-
-import org.onap.music.eelf.logging.EELFLoggerDelegate;
-import org.onap.music.service.MusicCoreService;
-import org.onap.music.service.impl.MusicCassaCore;
-
-import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.Row;
-
-
-
-    public class Condition {
-        Map<String, Object> conditions;
-        PreparedQueryObject selectQueryForTheRow;
-        private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(Condition.class);
-        private static MusicCoreService musicCore = MusicCassaCore.getInstance();
-
-        public Condition(Map<String, Object> conditions, PreparedQueryObject selectQueryForTheRow) {
-            this.conditions = conditions;
-            this.selectQueryForTheRow = selectQueryForTheRow;
-        }
-
-        public boolean testCondition() throws Exception {
-            // first generate the row
-            ResultSet results = musicCore.quorumGet(selectQueryForTheRow);
-            Row row = results.one();
-            return MusicDataStoreHandle.getDSHandle().doesRowSatisfyCondition(row, conditions);
-        }
-    }
-
diff --git a/src/main/java/org/onap/music/datastore/MusicDataStoreHandle.java b/src/main/java/org/onap/music/datastore/MusicDataStoreHandle.java
deleted file mode 100644 (file)
index a2d9386..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * ============LICENSE_START==========================================
- * org.onap.music
- * ===================================================================
- *  Copyright (c) 2017 AT&T Intellectual Property
- * ===================================================================
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- * 
- * ============LICENSE_END=============================================
- * ====================================================================
- */
-package org.onap.music.datastore;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.onap.music.eelf.logging.EELFLoggerDelegate;
-import org.onap.music.exceptions.MusicServiceException;
-import org.onap.music.main.MusicUtil;
-import org.onap.music.service.impl.MusicCassaCore;
-
-import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.TableMetadata;
-
-public class MusicDataStoreHandle {
-       
-        public static MusicDataStore mDstoreHandle = null;
-        private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicDataStoreHandle.class);
-       
-    /**
-     * 
-     * @param remoteIp
-     * @return
-     */
-    public static MusicDataStore getDSHandle(String remoteIp) {
-        logger.info(EELFLoggerDelegate.applicationLogger,"Acquiring data store handle");
-        long start = System.currentTimeMillis();
-        if (mDstoreHandle == null) {
-               try {
-                       MusicUtil.loadProperties();
-               } catch (Exception e) {
-                       logger.error(EELFLoggerDelegate.errorLogger, "No properties file defined. Falling back to default.");
-               }
-            mDstoreHandle = new MusicDataStore(remoteIp);
-        }
-        long end = System.currentTimeMillis();
-        logger.info(EELFLoggerDelegate.applicationLogger,"Time taken to acquire data store handle:" + (end - start) + " ms");
-        return mDstoreHandle;
-    }
-
-    /**
-     * 
-     * @return
-     * @throws MusicServiceException 
-     */
-    public static MusicDataStore getDSHandle() throws MusicServiceException {
-               
-        logger.info(EELFLoggerDelegate.applicationLogger,"Acquiring data store handle");
-        long start = System.currentTimeMillis();
-        if (mDstoreHandle == null) {
-               try {
-                       MusicUtil.loadProperties();
-               } catch (Exception e) {
-                       logger.error(EELFLoggerDelegate.errorLogger, "No properties file defined. Falling back to default.");
-               }
-            // Quick Fix - Best to put this into every call to getDSHandle?
-            if (! MusicUtil.getMyCassaHost().equals("localhost") ) {
-                mDstoreHandle = new MusicDataStore(MusicUtil.getMyCassaHost());
-            } else {
-                mDstoreHandle = new MusicDataStore();
-            }
-        }
-        if(mDstoreHandle.getSession() == null) {
-               String message = "Connection to Cassandra has not been enstablished."
-                               + " Please check connection properites and reboot.";
-               logger.info(EELFLoggerDelegate.applicationLogger, message);
-            throw new MusicServiceException(message);
-        }
-        long end = System.currentTimeMillis();
-        logger.info(EELFLoggerDelegate.applicationLogger,"Time taken to acquire data store handle:" + (end - start) + " ms");
-        return mDstoreHandle;
-    }
-    
-    /**
-     * 
-     * @param keyspace
-     * @param tablename
-     * @return
-     * @throws MusicServiceException 
-     */
-    public static TableMetadata returnColumnMetadata(String keyspace, String tablename) throws MusicServiceException {
-        return MusicDataStoreHandle.getDSHandle().returnColumnMetadata(keyspace, tablename);
-    }
-    
-    /**
-     * 
-     * @param results
-     * @return
-     * @throws MusicServiceException 
-     */
-    public static Map<String, HashMap<String, Object>> marshallResults(ResultSet results) throws MusicServiceException {
-        return MusicDataStoreHandle.getDSHandle().marshalData(results);
-    }
-
-}
@@ -1,4 +1,4 @@
-package org.onap.music.lockingservice.cassandra;
+package org.onap.music.datastore;
 public class MusicLockState {
     public enum LockStatus {
         UNLOCKED, BEING_LOCKED, LOCKED
index 65e1950..5f6329a 100644 (file)
@@ -26,10 +26,9 @@ import java.util.UUID;
 import org.onap.music.datastore.PreparedQueryObject;
 import org.onap.music.eelf.logging.EELFLoggerDelegate;
 import org.onap.music.exceptions.MusicServiceException;
+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.ConsistencyLevel;
 
@@ -40,7 +39,6 @@ import com.datastax.driver.core.ConsistencyLevel;
 public class MusicHealthCheck {
 
        private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicUtil.class);
-       private static MusicCoreService musicCore = MusicCassaCore.getInstance();
 
        private String cassandrHost;
        private String zookeeperHost;
@@ -80,7 +78,7 @@ public class MusicHealthCheck {
                PreparedQueryObject pQuery = new PreparedQueryObject();
                pQuery.appendQueryString("insert into admin.healthcheck (id) values (?)");
                pQuery.addValue(UUID.randomUUID());
-                       ResultType rs = musicCore.nonKeyRelatedPut(pQuery, consistency);
+                       ResultType rs = MusicCore.nonKeyRelatedPut(pQuery, consistency);
                        System.out.println(rs);
                        if (rs != null) {
                                return Boolean.TRUE;
@@ -96,7 +94,7 @@ public class MusicHealthCheck {
                pQuery.appendQueryString("CREATE TABLE admin.healthcheck (id uuid PRIMARY KEY)");
                ResultType rs = null ;
                try {
-                       rs = musicCore.nonKeyRelatedPut(pQuery, ConsistencyLevel.ONE.toString());
+                       rs = MusicCore.nonKeyRelatedPut(pQuery, ConsistencyLevel.ONE.toString());
                } catch (MusicServiceException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
index 5c253f5..d365411 100755 (executable)
@@ -41,8 +41,6 @@ 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.exceptions.MusicServiceException;
-import org.onap.music.service.MusicCoreService;
-import org.onap.music.service.impl.MusicCassaCore;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.datastax.driver.core.DataType;
@@ -69,7 +67,6 @@ public class CachingUtil implements Runnable {
     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<>();
-    private static MusicCoreService musicCore = MusicCassaCore.getInstance();
 
     public boolean isCacheRefreshNeeded() {
         if (aafCache.get("initBlankMap") == null)
@@ -94,7 +91,7 @@ public class CachingUtil implements Runnable {
             logger.error(EELFLoggerDelegate.errorLogger, e1.getMessage(),AppMessages.CACHEERROR, ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
             e1.printStackTrace();
         }
-        ResultSet rs = musicCore.get(pQuery);
+        ResultSet rs = MusicCore.get(pQuery);
         Iterator<Row> it = rs.iterator();
         Map<String, String> map = null;
         while (it.hasNext()) {
@@ -248,7 +245,7 @@ public class CachingUtil implements Runnable {
                                             + namespace + "' allow filtering");
             Row rs = null;
             try {
-                rs = musicCore.get(pQuery).one();
+                rs = MusicCore.get(pQuery).one();
             } catch(InvalidQueryException e) {
                 logger.error(EELFLoggerDelegate.errorLogger,"Exception admin keyspace not configured."+e.getMessage());
                 throw new MusicServiceException("Please make sure admin.keyspace_master table is configured.");
@@ -272,7 +269,7 @@ public class CachingUtil implements Runnable {
             pQuery.appendQueryString(
                             "SELECT uuid from admin.keyspace_master where keyspace_name = '"
                                             + keyspace + "' allow filtering");
-            Row rs = musicCore.get(pQuery).one();
+            Row rs = MusicCore.get(pQuery).one();
             try {
                 uuid = rs.getUUID("uuid").toString();
             } catch (Exception e) {
@@ -289,7 +286,7 @@ public class CachingUtil implements Runnable {
         pQuery.appendQueryString(
                         "SELECT application_name from admin.keyspace_master where keyspace_name = '"
                                         + keyspace + "' allow filtering");
-        Row rs = musicCore.get(pQuery).one();
+        Row rs = MusicCore.get(pQuery).one();
         try {
             appName = rs.getString("application_name");
         } catch (Exception e) {
@@ -338,7 +335,7 @@ public class CachingUtil implements Runnable {
         }
         Row rs = null;
                try {
-                       rs = musicCore.get(queryObject).one();
+                       rs = MusicCore.get(queryObject).one();
                } catch (MusicServiceException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
@@ -389,7 +386,7 @@ public class CachingUtil implements Runnable {
         }
         Row rs = null;
         try {
-            rs = musicCore.get(queryObject).one();
+            rs = MusicCore.get(queryObject).one();
         } catch (MusicServiceException e) {
             e.printStackTrace();
             resultMap.put("Exception", "Unable to process operation. Error is "+e.getMessage());
index 2ed1a97..5b7a8de 100644 (file)
@@ -34,8 +34,6 @@ import javax.servlet.annotation.WebListener;
 import org.onap.music.datastore.PreparedQueryObject;
 import org.onap.music.exceptions.MusicLockingException;
 import org.onap.music.exceptions.MusicServiceException;
-import org.onap.music.service.MusicCoreService;
-import org.onap.music.service.impl.MusicCassaCore;
 
 import com.datastax.driver.core.ResultSet;
 import com.datastax.driver.core.Row;
@@ -44,7 +42,6 @@ import com.datastax.driver.core.Row;
 public class CronJobManager implements ServletContextListener {
 
     private ScheduledExecutorService scheduler;
-    private static MusicCoreService musicCore = MusicCassaCore.getInstance();
 
     @Override
     public void contextInitialized(ServletContextEvent event) {
@@ -54,7 +51,7 @@ public class CronJobManager implements ServletContextListener {
         String consistency = MusicUtil.EVENTUAL;
         pQuery.appendQueryString("CREATE TABLE IF NOT EXISTS admin.locks ( lock_id text PRIMARY KEY, ctime text)");
         try {
-            ResultType result = musicCore.nonKeyRelatedPut(pQuery, consistency);
+            ResultType result = MusicCore.nonKeyRelatedPut(pQuery, consistency);
         } catch (MusicServiceException e1) {
             e1.printStackTrace();
         }
@@ -63,7 +60,7 @@ public class CronJobManager implements ServletContextListener {
         pQuery.appendQueryString(
                         "select * from admin.locks");
             try {
-                ResultSet rs = musicCore.get(pQuery);
+                ResultSet rs = MusicCore.get(pQuery);
                 Iterator<Row> it = rs.iterator();
                 StringBuilder deleteKeys = new StringBuilder();
                 Boolean expiredKeys = false;
@@ -74,7 +71,7 @@ public class CronJobManager implements ServletContextListener {
                     if(System.currentTimeMillis() >= ctime + 24 * 60 * 60 * 1000) {
                         expiredKeys = true;
                         String new_id = id.substring(1);
-                        musicCore.deleteLock(new_id);
+                        MusicCore.deleteLock(new_id);
                         deleteKeys.append(id).append(",");
                     }
                     else {
@@ -106,7 +103,7 @@ public class CronJobManager implements ServletContextListener {
                            expiredKeys = true;
                            String id = pair.getKey();
                            deleteKeys.append("'").append(id).append("'").append(",");
-                           musicCore.deleteLock(id.substring(1));
+                           MusicCore.deleteLock(id.substring(1));
                            MusicUtil.zkNodeMap.remove(id);
                            
                        } catch (MusicLockingException e) {
@@ -132,7 +129,7 @@ public class CronJobManager implements ServletContextListener {
         pQuery.appendQueryString(
                         "DELETE FROM admin.locks WHERE lock_id IN ("+deleteKeys+")");
         try {
-               musicCore.nonKeyRelatedPut(pQuery, "eventual");
+            MusicCore.nonKeyRelatedPut(pQuery, "eventual");
         } catch (Exception e) {
               e.printStackTrace();
         }
@@ -19,7 +19,7 @@
  * ============LICENSE_END=============================================
  * ====================================================================
  */
-package org.onap.music.service.impl;
+package org.onap.music.main;
 
 
 import java.io.StringWriter;
@@ -28,9 +28,10 @@ import java.util.Map;
 import java.util.StringTokenizer;
 import java.util.UUID;
 
-import org.onap.music.datastore.MusicDataStore;
-import org.onap.music.datastore.MusicDataStoreHandle;
-import org.onap.music.datastore.Condition;
+import org.onap.music.datastore.CassaDataStore;
+import org.onap.music.datastore.CassaLockStore;
+import org.onap.music.datastore.CassaLockStore.LockObject;
+import org.onap.music.datastore.MusicLockState;
 import org.onap.music.datastore.PreparedQueryObject;
 import org.onap.music.eelf.logging.EELFLoggerDelegate;
 import org.onap.music.eelf.logging.format.AppMessages;
@@ -39,13 +40,6 @@ import org.onap.music.eelf.logging.format.ErrorTypes;
 import org.onap.music.exceptions.MusicLockingException;
 import org.onap.music.exceptions.MusicQueryException;
 import org.onap.music.exceptions.MusicServiceException;
-import org.onap.music.lockingservice.cassandra.CassaLockStore;
-import org.onap.music.lockingservice.cassandra.MusicLockState;
-import org.onap.music.lockingservice.cassandra.CassaLockStore.LockObject;
-import org.onap.music.main.MusicUtil;
-import org.onap.music.main.ResultType;
-import org.onap.music.main.ReturnType;
-import org.onap.music.service.MusicCoreService;
 
 import com.datastax.driver.core.ColumnDefinitions;
 import com.datastax.driver.core.ColumnDefinitions.Definition;
@@ -60,31 +54,38 @@ import com.datastax.driver.core.TableMetadata;
  * 
  *
  */
-public class MusicCassaCore implements MusicCoreService {
+public class MusicCore {
 
-    public static CassaLockStore mLockHandle = null;;
-    private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicCassaCore.class);
+    public static CassaLockStore mLockHandle = null;
+    public static CassaDataStore mDstoreHandle = null;
+    private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicCore.class);
     private static boolean unitTestRun=true;
-    private static MusicCassaCore musicCassaCoreInstance = null;
     
-    private MusicCassaCore() {
-       
-    }
-    public static MusicCassaCore getInstance() {
-       
-       if(musicCassaCoreInstance == null) {
-               musicCassaCoreInstance = new MusicCassaCore();
-       }
-       return musicCassaCoreInstance;
+    public static class Condition {
+        Map<String, Object> conditions;
+        PreparedQueryObject selectQueryForTheRow;
+
+        public Condition(Map<String, Object> conditions, PreparedQueryObject selectQueryForTheRow) {
+            this.conditions = conditions;
+            this.selectQueryForTheRow = selectQueryForTheRow;
+        }
+
+        public boolean testCondition() throws Exception {
+            // first generate the row
+            ResultSet results = quorumGet(selectQueryForTheRow);
+            Row row = results.one();
+            return getDSHandle().doesRowSatisfyCondition(row, conditions);
+        }
     }
-    
+
+
     public static CassaLockStore getLockingServiceHandle() throws MusicLockingException {
         logger.info(EELFLoggerDelegate.applicationLogger,"Acquiring lock store handle");
         long start = System.currentTimeMillis();
 
         if (mLockHandle == null) {
             try {
-                mLockHandle = new CassaLockStore(MusicDataStoreHandle.getDSHandle());
+                mLockHandle = new CassaLockStore(getDSHandle());
             } catch (Exception e) {
                logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.LOCKHANDLE,ErrorSeverity.CRITICAL, ErrorTypes.LOCKINGERROR);
                 throw new MusicLockingException("Failed to aquire Locl store handle " + e);
@@ -95,9 +96,61 @@ public class MusicCassaCore implements MusicCoreService {
         return mLockHandle;
     }
 
+    /**
+     * 
+     * @param remoteIp
+     * @return
+     */
+    public static CassaDataStore getDSHandle(String remoteIp) {
+        logger.info(EELFLoggerDelegate.applicationLogger,"Acquiring data store handle");
+        long start = System.currentTimeMillis();
+        if (mDstoreHandle == null) {
+               try {
+                       MusicUtil.loadProperties();
+               } catch (Exception e) {
+                       logger.error(EELFLoggerDelegate.errorLogger, "No properties file defined. Falling back to default.");
+               }
+            mDstoreHandle = new CassaDataStore(remoteIp);
+        }
+        long end = System.currentTimeMillis();
+        logger.info(EELFLoggerDelegate.applicationLogger,"Time taken to acquire data store handle:" + (end - start) + " ms");
+        return mDstoreHandle;
+    }
 
+    /**
+     * 
+     * @return
+     * @throws MusicServiceException 
+     */
+    public static CassaDataStore getDSHandle() throws MusicServiceException {
+               
+        logger.info(EELFLoggerDelegate.applicationLogger,"Acquiring data store handle");
+        long start = System.currentTimeMillis();
+        if (mDstoreHandle == null) {
+               try {
+                       MusicUtil.loadProperties();
+               } catch (Exception e) {
+                       logger.error(EELFLoggerDelegate.errorLogger, "No properties file defined. Falling back to default.");
+               }
+            // Quick Fix - Best to put this into every call to getDSHandle?
+            if (! MusicUtil.getMyCassaHost().equals("localhost") ) {
+                mDstoreHandle = new CassaDataStore(MusicUtil.getMyCassaHost());
+            } else {
+                mDstoreHandle = new CassaDataStore();
+            }
+        }
+        if(mDstoreHandle.getSession() == null) {
+               String message = "Connection to Cassandra has not been enstablished."
+                               + " Please check connection properites and reboot.";
+               logger.info(EELFLoggerDelegate.applicationLogger, message);
+            throw new MusicServiceException(message);
+        }
+        long end = System.currentTimeMillis();
+        logger.info(EELFLoggerDelegate.applicationLogger,"Time taken to acquire data store handle:" + (end - start) + " ms");
+        return mDstoreHandle;
+    }
 
-    public  String createLockReference(String fullyQualifiedKey) {
+    public static String createLockReference(String fullyQualifiedKey) {
         String[] splitString = fullyQualifiedKey.split("\\.");
         String keyspace = splitString[0];
         String table = splitString[1];
@@ -117,12 +170,12 @@ public class MusicCassaCore implements MusicCoreService {
     }
 
 
-    public  ReturnType acquireLockWithLease(String fullyQualifiedKey, String lockReference, long leasePeriod) throws MusicLockingException, MusicQueryException, MusicServiceException  {
+    public static ReturnType acquireLockWithLease(String fullyQualifiedKey, String lockReference, long leasePeriod) throws MusicLockingException, MusicQueryException, MusicServiceException  {
        evictExpiredLockHolder(fullyQualifiedKey,leasePeriod);
                return acquireLock(fullyQualifiedKey, lockReference);
     }
 
-    private  void evictExpiredLockHolder(String fullyQualifiedKey, long leasePeriod) throws MusicLockingException, MusicQueryException, MusicServiceException {
+    private static void evictExpiredLockHolder(String fullyQualifiedKey, long leasePeriod) throws MusicLockingException, MusicQueryException, MusicServiceException {
 
         String[] splitString = fullyQualifiedKey.split("\\.");
         String keyspace = splitString[0];
@@ -162,7 +215,7 @@ public class MusicCassaCore implements MusicCoreService {
                return new ReturnType(ResultType.SUCCESS, lockReference+" is top of lock store");
     }
     
-    public  ReturnType acquireLock(String fullyQualifiedKey, String lockReference) throws MusicLockingException, MusicQueryException, MusicServiceException {
+    public static ReturnType acquireLock(String fullyQualifiedKey, String lockReference) throws MusicLockingException, MusicQueryException, MusicServiceException {
         String[] splitString = fullyQualifiedKey.split("\\.");
         String keyspace = splitString[0];
         String table = splitString[1];
@@ -178,7 +231,7 @@ public class MusicCassaCore implements MusicCoreService {
                String query = "select * from "+syncTable+" where key='"+fullyQualifiedKey+"';";
         PreparedQueryObject readQueryObject = new PreparedQueryObject();
         readQueryObject.appendQueryString(query);
-               ResultSet results = MusicDataStoreHandle.getDSHandle().executeCriticalGet(readQueryObject);                     
+               ResultSet results = getDSHandle().executeCriticalGet(readQueryObject);                  
                if (results.all().size() != 0) {
                        logger.info("In acquire lock: Since there was a forcible release, need to sync quorum!");
                        try {
@@ -192,7 +245,7 @@ public class MusicCassaCore implements MusicCoreService {
                        String cleanQuery = "delete * from music_internal.unsynced_keys where key='"+fullyQualifiedKey+"';";
                PreparedQueryObject deleteQueryObject = new PreparedQueryObject();
                deleteQueryObject.appendQueryString(cleanQuery);
-               MusicDataStoreHandle.getDSHandle().executePut(deleteQueryObject, "critical");
+                       getDSHandle().executePut(deleteQueryObject, "critical");
                }
                
                getLockingServiceHandle().updateLockAcquireTime(keyspace, table, primaryKeyValue, lockReference);
@@ -211,7 +264,7 @@ public class MusicCassaCore implements MusicCoreService {
      * 
      * 
      */
-    public  ResultType createTable(String keyspace, String table, PreparedQueryObject tableQueryObject, String consistency) throws MusicServiceException {
+    public static ResultType createTable(String keyspace, String table, PreparedQueryObject tableQueryObject, String consistency) throws MusicServiceException {
                boolean result = false;
        
                try {
@@ -232,11 +285,11 @@ public class MusicCassaCore implements MusicCoreService {
                        
                        queryObject.appendQueryString(tabQuery);
                        result = false;
-                       result = MusicDataStoreHandle.getDSHandle().executePut(queryObject, "eventual");
+                       result = getDSHandle().executePut(queryObject, "eventual");
 
                
                        //create actual table
-                       result = MusicDataStoreHandle.getDSHandle().executePut(tableQueryObject, consistency);
+                       result = getDSHandle().executePut(tableQueryObject, consistency);
                } catch (MusicQueryException | MusicServiceException | MusicLockingException ex) {
                        logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR  ,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR);
                        throw new MusicServiceException(ex.getMessage());
@@ -250,7 +303,7 @@ public class MusicCassaCore implements MusicCoreService {
         PreparedQueryObject updateQuery = new PreparedQueryObject();
 
         // get the primary key d
-        TableMetadata tableInfo = MusicDataStoreHandle.returnColumnMetadata(keyspace, table);
+        TableMetadata tableInfo = returnColumnMetadata(keyspace, table);
         String primaryKeyName = tableInfo.getPrimaryKey().get(0).getName();// we only support single
                                                                            // primary key
         DataType primaryKeyType = tableInfo.getPrimaryKey().get(0).getType();
@@ -263,7 +316,7 @@ public class MusicCassaCore implements MusicCoreService {
         selectQuery.addValue(cqlFormattedPrimaryKeyValue);
         ResultSet results = null;
         try {
-            results = MusicDataStoreHandle.getDSHandle().executeCriticalGet(selectQuery);
+            results = getDSHandle().executeCriticalGet(selectQuery);
             // write it back to a quorum
             Row row = results.one();
             ColumnDefinitions colInfo = row.getColumnDefinitions();
@@ -275,7 +328,7 @@ public class MusicCassaCore implements MusicCoreService {
                 if (colName.equals(primaryKeyName))
                     continue;
                 DataType colType = definition.getType();
-                Object valueObj = MusicDataStoreHandle.getDSHandle().getColValue(row, colName, colType);
+                Object valueObj = getDSHandle().getColValue(row, colName, colType);
                 Object valueString = MusicUtil.convertToActualDataType(colType, valueObj);
                 fieldValueString.append(colName + " = ?");
                 updateQuery.addValue(valueString);
@@ -287,7 +340,7 @@ public class MusicCassaCore implements MusicCoreService {
                             + fieldValueString + " WHERE " + primaryKeyName + "= ? " + ";");
             updateQuery.addValue(cqlFormattedPrimaryKeyValue);
 
-            MusicDataStoreHandle.getDSHandle().executePut(updateQuery, "critical");
+            getDSHandle().executePut(updateQuery, "critical");
         } catch (MusicServiceException | MusicQueryException e) {
                logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.QUERYERROR +""+updateQuery ,ErrorSeverity.MAJOR, ErrorTypes.QUERYERROR);
         }
@@ -301,10 +354,10 @@ public class MusicCassaCore implements MusicCoreService {
      * @param query
      * @return ResultSet
      */
-    public  ResultSet quorumGet(PreparedQueryObject query) {
+    public static ResultSet quorumGet(PreparedQueryObject query) {
         ResultSet results = null;
         try {
-            results = MusicDataStoreHandle.getDSHandle().executeCriticalGet(query);
+            results = getDSHandle().executeCriticalGet(query);
         } catch (MusicServiceException | MusicQueryException e) {
                logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.MAJOR, ErrorTypes.GENERALSERVICEERROR);
         
@@ -313,14 +366,22 @@ public class MusicCassaCore implements MusicCoreService {
 
     }
 
-
+    /**
+     * 
+     * @param results
+     * @return
+     * @throws MusicServiceException 
+     */
+    public static Map<String, HashMap<String, Object>> marshallResults(ResultSet results) throws MusicServiceException {
+        return getDSHandle().marshalData(results);
+    }
 
     /**
      * 
      * @param fullyQualifiedKey lockName
      * @return
      */
-    public  String whoseTurnIsIt(String fullyQualifiedKey) {
+    public static String whoseTurnIsIt(String fullyQualifiedKey) {
         String[] splitString = fullyQualifiedKey.split("\\.");
         String keyspace = splitString[0];
         String table = splitString[1];
@@ -343,7 +404,7 @@ public class MusicCassaCore implements MusicCoreService {
         return st.nextToken("$");
     }
 
-    public  MusicLockState destroyLockRef(String fullyQualifiedKey, String lockReference) {
+    public static MusicLockState destroyLockRef(String fullyQualifiedKey, String lockReference) {
         long start = System.currentTimeMillis();
         String[] splitString = fullyQualifiedKey.split("\\.");
         String keyspace = splitString[0];
@@ -359,11 +420,11 @@ public class MusicCassaCore implements MusicCoreService {
         return getMusicLockState(fullyQualifiedKey);
     }
 
-    public   MusicLockState  voluntaryReleaseLock(String fullyQualifiedKey, String lockReference) throws MusicLockingException{
+    public static  MusicLockState  voluntaryReleaseLock(String fullyQualifiedKey, String lockReference) throws MusicLockingException{
                return destroyLockRef(fullyQualifiedKey, lockReference);
        }
 
-    public  MusicLockState  forciblyReleaseLock(String fullyQualifiedKey, String lockReference) throws MusicLockingException, MusicServiceException, MusicQueryException{
+    public static  MusicLockState  forciblyReleaseLock(String fullyQualifiedKey, String lockReference) throws MusicLockingException, MusicServiceException, MusicQueryException{
         String[] splitString = fullyQualifiedKey.split("\\.");
         String keyspace = splitString[0];
         String table = splitString[1];
@@ -375,7 +436,7 @@ public class MusicCassaCore implements MusicCoreService {
                queryObject.addValue(fullyQualifiedKey);
                String insQuery = "insert into "+syncTable+" (key) values "+values+"';";
         queryObject.appendQueryString(insQuery);
-        MusicDataStoreHandle.getDSHandle().executePut(queryObject, "critical");        
+        getDSHandle().executePut(queryObject, "critical");     
         
         //now release the lock
                return destroyLockRef(fullyQualifiedKey, lockReference);
@@ -386,10 +447,26 @@ public class MusicCassaCore implements MusicCoreService {
      * @param lockName
      * @throws MusicLockingException 
      */
-    public  void deleteLock(String lockName) throws MusicLockingException {
+    public static void deleteLock(String lockName) throws MusicLockingException {
                //deprecated
        }
 
+
+
+    /**
+     * 
+     * @param keyspace
+     * @param tablename
+     * @return
+     * @throws MusicServiceException 
+     */
+    public static TableMetadata returnColumnMetadata(String keyspace, String tablename) throws MusicServiceException {
+        return getDSHandle().returnColumnMetadata(keyspace, tablename);
+    }
+
+
+
+
     // Prepared Query Additions.
 
     /**
@@ -398,10 +475,10 @@ public class MusicCassaCore implements MusicCoreService {
      * @return ReturnType
      * @throws MusicServiceException
      */
-    public  ReturnType eventualPut(PreparedQueryObject queryObject) {
+    public static ReturnType eventualPut(PreparedQueryObject queryObject) {
         boolean result = false;
         try {
-            result = MusicDataStoreHandle.getDSHandle().executePut(queryObject, MusicUtil.EVENTUAL);
+            result = getDSHandle().executePut(queryObject, MusicUtil.EVENTUAL);
         } catch (MusicServiceException | MusicQueryException ex) {
                logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), "[ERR512E] Failed to get ZK Lock Handle "  ,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR);
             logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage() + "  " + ex.getCause() + " " + ex);
@@ -423,7 +500,7 @@ public class MusicCassaCore implements MusicCoreService {
      * @param lockReference
      * @return
      */
-    public  ReturnType criticalPut(String keyspace, String table, String primaryKeyValue,
+    public static ReturnType criticalPut(String keyspace, String table, String primaryKeyValue,
                     PreparedQueryObject queryObject, String lockReference, Condition conditionInfo) {
         long start = System.currentTimeMillis();
         try {
@@ -445,7 +522,7 @@ public class MusicCassaCore implements MusicCoreService {
           String query = queryObject.getQuery();
           query = query.replaceFirst("SET", "using TIMESTAMP "+ v2sTimeStampInMicroseconds(lockReference, System.currentTimeMillis())+ " SET");
          queryObject.replaceQueryString(query);
-         MusicDataStoreHandle.getDSHandle().executePut(queryObject, MusicUtil.CRITICAL);
+         getDSHandle().executePut(queryObject, MusicUtil.CRITICAL);
           long end = System.currentTimeMillis();
           logger.info(EELFLoggerDelegate.applicationLogger,"Time taken for the critical put:" + (end - start) + " ms");
         }catch (MusicQueryException | MusicServiceException | MusicLockingException  e) {
@@ -467,12 +544,12 @@ public class MusicCassaCore implements MusicCoreService {
      * 
      * 
      */
-    public  ResultType nonKeyRelatedPut(PreparedQueryObject queryObject, String consistency) throws MusicServiceException {
+    public static ResultType nonKeyRelatedPut(PreparedQueryObject queryObject, String consistency) throws MusicServiceException {
         // this is mainly for some functions like keyspace creation etc which does not
         // really need the bells and whistles of Music locking.
         boolean result = false;
         try {
-            result = MusicDataStoreHandle.getDSHandle().executePut(queryObject, consistency);
+            result = getDSHandle().executePut(queryObject, consistency);
         } catch (MusicQueryException | MusicServiceException ex) {
                logger.error(EELFLoggerDelegate.errorLogger, ex.getMessage(), AppMessages.UNKNOWNERROR,
                     ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR);
@@ -488,10 +565,10 @@ public class MusicCassaCore implements MusicCoreService {
      * @return ResultSet
      * @throws MusicServiceException 
      */
-    public  ResultSet get(PreparedQueryObject queryObject) throws MusicServiceException {
+    public static ResultSet get(PreparedQueryObject queryObject) throws MusicServiceException {
         ResultSet results = null;
         try {
-                       results = MusicDataStoreHandle.getDSHandle().executeEventualGet(queryObject);
+                       results = getDSHandle().executeEventualGet(queryObject);
         } catch (MusicQueryException | MusicServiceException e) {
             logger.error(EELFLoggerDelegate.errorLogger,e.getMessage());
             throw new MusicServiceException(e.getMessage());
@@ -510,7 +587,7 @@ public class MusicCassaCore implements MusicCoreService {
      * @param lockReference lock ID to check if the resource is free to perform the operation.
      * @return ResultSet
      */
-    public  ResultSet criticalGet(String keyspace, String table, String primaryKeyValue,
+    public static ResultSet criticalGet(String keyspace, String table, String primaryKeyValue,
                     PreparedQueryObject queryObject, String lockReference) throws MusicServiceException {
         ResultSet results = null;
         
@@ -518,7 +595,7 @@ public class MusicCassaCore implements MusicCoreService {
             ReturnType result = isTopOfLockStore(keyspace, table, primaryKeyValue, lockReference);
             if(result.getResult().equals(ResultType.FAILURE))
                        return null;//not top of the lock store q
-                results = MusicDataStoreHandle.getDSHandle().executeCriticalGet(queryObject);
+                results = getDSHandle().executeCriticalGet(queryObject);
         } catch (MusicQueryException | MusicServiceException | MusicLockingException e) {
                        logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR  ,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR);
         }
@@ -537,7 +614,7 @@ public class MusicCassaCore implements MusicCoreService {
      * @throws MusicServiceException 
      * @throws MusicQueryException 
      */
-    public  ReturnType atomicPut(String keyspaceName, String tableName, String primaryKey,
+    public static ReturnType atomicPut(String keyspaceName, String tableName, String primaryKey,
                     PreparedQueryObject queryObject, Condition conditionInfo) throws MusicLockingException, MusicQueryException, MusicServiceException {
         long start = System.currentTimeMillis();
         String fullyQualifiedKey = keyspaceName + "." + tableName + "." + primaryKey;
@@ -580,7 +657,7 @@ public class MusicCassaCore implements MusicCoreService {
      * @throws MusicLockingException 
      * @throws MusicQueryException 
      */
-    public  ResultSet atomicGet(String keyspaceName, String tableName, String primaryKey,
+    public static ResultSet atomicGet(String keyspaceName, String tableName, String primaryKey,
                     PreparedQueryObject queryObject) throws MusicServiceException, MusicLockingException, MusicQueryException {
         String fullyQualifiedKey = keyspaceName + "." + tableName + "." + primaryKey;
         String lockReference = createLockReference(fullyQualifiedKey);
@@ -604,7 +681,96 @@ public class MusicCassaCore implements MusicCoreService {
                return null;
     }
 
-  
+    /**
+     * authenticate user logic
+     * 
+     * @param nameSpace
+     * @param userId
+     * @param password
+     * @param keyspace
+     * @param aid
+     * @param operation
+     * @return
+     * @throws Exception
+     */
+    public static Map<String, Object> authenticate(String nameSpace, String userId,
+                    String password, String keyspace, String aid, String operation)
+                    throws Exception {
+        Map<String, Object> resultMap = new HashMap<>();
+        String uuid = null;
+        resultMap = CachingUtil.validateRequest(nameSpace, userId, password, keyspace, aid,
+                        operation);
+        if (!resultMap.isEmpty())
+            return resultMap;
+        String isAAFApp = null;
+        try {
+            isAAFApp= CachingUtil.isAAFApplication(nameSpace);
+        } catch(MusicServiceException e) {
+           resultMap.put("Exception", e.getMessage());
+           return resultMap;
+        }
+        if(isAAFApp == null) {
+            resultMap.put("Exception", "Namespace: "+nameSpace+" doesn't exist. Please make sure ns(appName)"
+                    + " is correct and Application is onboarded.");
+            return resultMap;
+        }
+        boolean isAAF = Boolean.valueOf(isAAFApp);
+        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);
+            resultMap.put("Exception",
+                            "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 {
+                isValid = CachingUtil.authenticateAAFUser(nameSpace, userId, password, keyspace);
+            } catch (Exception e) {
+               logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.AUTHENTICATIONERROR  ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
+                logger.error(EELFLoggerDelegate.errorLogger,"Got exception while AAF authentication for namespace " + nameSpace);
+                resultMap.put("Exception", e.getMessage());
+            }
+            if (!isValid) {
+               logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.AUTHENTICATIONERROR  ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
+                resultMap.put("Exception", "User not authenticated...");
+            }
+            if (!resultMap.isEmpty())
+                return resultMap;
+
+        }
+
+        if (operation.equals("createKeySpace")) {
+            logger.info(EELFLoggerDelegate.applicationLogger,"AID is not provided. Creating new UUID for keyspace.");
+            PreparedQueryObject pQuery = new PreparedQueryObject();
+            pQuery.appendQueryString(
+                            "select uuid from admin.keyspace_master where application_name=? and username=? and keyspace_name=? allow filtering");
+            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), nameSpace));
+            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), userId));
+            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(),
+                            MusicUtil.DEFAULTKEYSPACENAME));
+
+            try {
+                Row rs = MusicCore.get(pQuery).one();
+                uuid = rs.getUUID("uuid").toString();
+                resultMap.put("uuid", "existing");
+            } catch (Exception e) {
+                logger.info(EELFLoggerDelegate.applicationLogger,"No UUID found in DB. So creating new UUID.");
+                uuid = CachingUtil.generateUUID();
+                resultMap.put("uuid", "new");
+            }
+            resultMap.put("aid", uuid);
+        }
+
+        return resultMap;
+    }
     
     /**
      * @param lockName
@@ -657,13 +823,4 @@ public class MusicCassaCore implements MusicCoreService {
                x = x.replaceFirst("top", "sword");
                System.out.print(x); //returns sword pickaxe
        }
-
-
-
-       @Override
-       public ReturnType atomicPutWithDeleteLock(String keyspaceName, String tableName, String primaryKey,
-                       PreparedQueryObject queryObject, Condition conditionInfo) throws MusicLockingException {
-               //Deprecated
-               return null;
-       }
 }
index 68c6923..1c47563 100644 (file)
@@ -7,8 +7,7 @@ import org.onap.music.datastore.PreparedQueryObject;
 import org.onap.music.exceptions.MusicLockingException;
 import org.onap.music.exceptions.MusicQueryException;
 import org.onap.music.exceptions.MusicServiceException;
-import org.onap.music.service.MusicCoreService;
-import org.onap.music.service.impl.MusicCassaCore;
+import org.onap.music.main.MusicCore;
 
 import com.datastax.driver.core.ResultSet;
 import com.datastax.driver.core.Row;
@@ -20,7 +19,6 @@ public class VotingAppJar
 {
        String keyspaceName;
        String tableName;
-       private static MusicCoreService musicCore = MusicCassaCore.getInstance();
        
        public VotingAppJar() throws MusicServiceException {
                keyspaceName = "VotingAppForMusic";
@@ -49,7 +47,7 @@ public class VotingAppJar
                 "CREATE KEYSPACE " + keyspaceName + " WITH REPLICATION = " + replicationInfo.toString().replaceAll("=", ":"));
                
                try {
-                       musicCore.nonKeyRelatedPut(queryObject, "eventual");
+                       MusicCore.nonKeyRelatedPut(queryObject, "eventual");
                } catch (MusicServiceException e) {
                        if (e.getMessage().equals("Keyspace votingappformusic already exists")) {
                                // ignore
@@ -65,7 +63,7 @@ public class VotingAppJar
                 "CREATE TABLE " + keyspaceName + "." + tableName + " (name text PRIMARY KEY, count varint);");
                
                try {
-                       musicCore.createTable(keyspaceName, tableName, queryObject, "eventual");                
+                       MusicCore.createTable(keyspaceName, tableName, queryObject, "eventual");                
                } catch (MusicServiceException e) {
                        if (e.getMessage().equals("Table votingappformusic.votevount already exists")) {
                                //ignore
@@ -81,7 +79,7 @@ public class VotingAppJar
                 "INSERT INTO " + keyspaceName + "." + tableName + " (name, count) "
                                + "VALUES ('"+candidateName+"', 0);");
                
-               musicCore.nonKeyRelatedPut(queryObject, "eventual");
+               MusicCore.nonKeyRelatedPut(queryObject, "eventual");
        }
 
        public void vote() throws MusicLockingException, MusicQueryException, MusicServiceException {
@@ -96,13 +94,13 @@ public class VotingAppJar
                queryObject.appendQueryString(
                 "INSERT INTO " + keyspaceName + "." + tableName + " (name, count) "
                                + "VALUES ('"+candidateName+"', "+numVotes+");");
-               musicCore.atomicPut(keyspaceName, tableName, candidateName, queryObject, null);
+               MusicCore.atomicPut(keyspaceName, tableName, candidateName, queryObject, null);
        }
 
        private void readAllVotes() throws MusicServiceException {
                PreparedQueryObject queryObject = new PreparedQueryObject();
                queryObject.appendQueryString("SELECT * FROM " + keyspaceName + "." + tableName);
-               ResultSet rs = musicCore.get(queryObject);
+               ResultSet rs = MusicCore.get(queryObject);
                for(Row candidate : rs.all()) {
                        System.out.println(candidate.getString("name") + " - " + candidate.getVarint("count"));
                }
index 958ef6e..6a84360 100644 (file)
@@ -24,7 +24,7 @@ package org.onap.music.response.jsonobjects;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.onap.music.lockingservice.cassandra.MusicLockState.LockStatus;
+import org.onap.music.datastore.MusicLockState.LockStatus;
 import org.onap.music.main.ResultType;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
index 9ae7bc3..9043649 100755 (executable)
@@ -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");
index 986d25e..99c60b3 100755 (executable)
@@ -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= "
index 92dd625..835dda1 100644 (file)
@@ -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();
                }
index 9248ee1..8af334c 100755 (executable)
@@ -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);
diff --git a/src/main/java/org/onap/music/service/MusicCoreService.java b/src/main/java/org/onap/music/service/MusicCoreService.java
deleted file mode 100644 (file)
index 6b7cc65..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * ============LICENSE_START==========================================
- * org.onap.music
- * ===================================================================
- *  Copyright (c) 2017 AT&T Intellectual Property
- * ===================================================================
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- * 
- * ============LICENSE_END=============================================
- * ====================================================================
- */
-package org.onap.music.service;
-
-import org.onap.music.datastore.Condition;
-import org.onap.music.datastore.PreparedQueryObject;
-import org.onap.music.exceptions.MusicLockingException;
-import org.onap.music.exceptions.MusicQueryException;
-import org.onap.music.exceptions.MusicServiceException;
-import org.onap.music.lockingservice.cassandra.MusicLockState;
-import org.onap.music.main.ResultType;
-import org.onap.music.main.ReturnType;
-import org.onap.music.lockingservice.cassandra.*;
-
-import com.datastax.driver.core.ResultSet;
-
-
-
-/**
- * @author srupane
- *
- */
-public interface MusicCoreService {
-       
-       // Core Music Database Methods
-       
-
-       public ReturnType eventualPut(PreparedQueryObject queryObject);
-
-       public ReturnType criticalPut(String keyspaceName, String tableName, String primaryKey,
-                       PreparedQueryObject queryObject, String lockId, Condition conditionInfo);
-
-       public ResultType nonKeyRelatedPut(PreparedQueryObject queryObject, String consistency)
-                       throws MusicServiceException;
-
-       public ResultSet get(PreparedQueryObject queryObject) throws MusicServiceException;
-
-       public ResultSet atomicGet(String keyspaceName, String tableName, String primaryKey,
-                       PreparedQueryObject queryObject) throws MusicServiceException, MusicLockingException, MusicQueryException;
-
-       public ReturnType atomicPutWithDeleteLock(String keyspaceName, String tableName, String primaryKey,
-                       PreparedQueryObject queryObject, Condition conditionInfo) throws MusicLockingException;
-
-       public ReturnType atomicPut(String keyspaceName, String tableName, String primaryKey,
-                       PreparedQueryObject queryObject, Condition conditionInfo)
-                       throws MusicLockingException, MusicQueryException, MusicServiceException;
-
-       public ResultSet criticalGet(String keyspaceName, String tableName, String primaryKey,
-                       PreparedQueryObject queryObject, String lockId) throws MusicServiceException;
-
-       // Core Music Locking Service Methods
-
-       public String createLockReference(String fullyQualifiedKey); // lock name
-
-       public ReturnType acquireLockWithLease(String key, String lockReference, long leasePeriod)
-                       throws MusicLockingException, MusicQueryException, MusicServiceException; // key,lock id,time
-
-       public ReturnType acquireLock(String key, String lockReference)
-                       throws MusicLockingException, MusicQueryException, MusicServiceException; // key,lock id
-
-       public ResultType createTable(String keyspace, String table, PreparedQueryObject tableQueryObject,
-                       String consistency) throws MusicServiceException;
-
-       public ResultSet quorumGet(PreparedQueryObject query);
-
-       public String whoseTurnIsIt(String fullyQualifiedKey);// lock name
-
-       public MusicLockState destroyLockRef(String fullyQualifiedKey, String lockReference); // lock name, lock id
-
-       public MusicLockState voluntaryReleaseLock(String fullyQualifiedKey, String lockReference)
-                       throws MusicLockingException;// lock name,lock id
-
-       public void deleteLock(String lockName) throws MusicLockingException;
-
-}
@@ -45,10 +45,10 @@ import com.datastax.driver.core.exceptions.NoHostAvailableException;
 import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.thrift.transport.TTransportException;
 import org.cassandraunit.utils.EmbeddedCassandraServerHelper;
-import org.onap.music.datastore.MusicDataStore;
+import org.onap.music.datastore.CassaDataStore;
 import org.onap.music.datastore.PreparedQueryObject;
 
-public class CassandraCQLQueries {
+public class CassandraCQL {
 
     public static final String createKeySpace =
                     "CREATE KEYSPACE IF NOT EXISTS testCassa WITH replication = "
@@ -222,7 +222,7 @@ public class CassandraCQLQueries {
         return allPossibleIps;
     }
 
-    public static MusicDataStore connectToEmbeddedCassandra() {
+    public static CassaDataStore connectToEmbeddedCassandra() {
         Iterator<String> it = getAllPossibleLocalIps().iterator();
         String address = "localhost";
 
@@ -249,7 +249,7 @@ public class CassandraCQLQueries {
 
             }
         }
-        return new MusicDataStore(cluster, session);
+        return new CassaDataStore(cluster, session);
 
     }
 
index 62275bb..3f7fd3b 100644 (file)
@@ -33,7 +33,7 @@ import org.mockito.Mock;
 import org.onap.music.exceptions.MusicQueryException;
 import org.onap.music.exceptions.MusicServiceException;
 
-import org.onap.music.datastore.MusicDataStore;
+import org.onap.music.datastore.CassaDataStore;
 import org.onap.music.datastore.PreparedQueryObject;
 
 import com.datastax.driver.core.DataType;
@@ -44,12 +44,12 @@ import com.datastax.driver.core.TableMetadata;
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 public class MusicDataStoreTest {
 
-    static MusicDataStore dataStore;
+    static CassaDataStore dataStore;
     static PreparedQueryObject testObject;
 
     @BeforeClass
     public static void init() {
-        dataStore = CassandraCQLQueries.connectToEmbeddedCassandra();
+        dataStore = CassandraCQL.connectToEmbeddedCassandra();
 
     }
 
@@ -57,7 +57,7 @@ public class MusicDataStoreTest {
     public static void close() throws MusicServiceException, MusicQueryException {
  
         testObject = new PreparedQueryObject();
-        testObject.appendQueryString(CassandraCQLQueries.dropKeyspace);
+        testObject.appendQueryString(CassandraCQL.dropKeyspace);
         dataStore.executePut(testObject, "eventual");
         dataStore.close();
 
@@ -67,10 +67,10 @@ public class MusicDataStoreTest {
     public void Test1_SetUp() throws MusicServiceException, MusicQueryException {
         boolean result = false;
         testObject = new PreparedQueryObject();
-        testObject.appendQueryString(CassandraCQLQueries.createKeySpace);
+        testObject.appendQueryString(CassandraCQL.createKeySpace);
         result = dataStore.executePut(testObject, "eventual");;
         testObject = new PreparedQueryObject();
-        testObject.appendQueryString(CassandraCQLQueries.createTableEmployees);
+        testObject.appendQueryString(CassandraCQL.createTableEmployees);
         result = dataStore.executePut(testObject, "eventual");
         assertEquals(true, result);
 
@@ -78,21 +78,21 @@ public class MusicDataStoreTest {
 
     @Test
     public void Test2_ExecutePut_eventual_insert() throws MusicServiceException, MusicQueryException {
-        testObject = CassandraCQLQueries.setPreparedInsertQueryObject1();
+        testObject = CassandraCQL.setPreparedInsertQueryObject1();
         boolean result = dataStore.executePut(testObject, "eventual");
         assertEquals(true, result);
     }
 
     @Test
     public void Test3_ExecutePut_critical_insert() throws MusicServiceException, MusicQueryException {
-        testObject = CassandraCQLQueries.setPreparedInsertQueryObject2();
+        testObject = CassandraCQL.setPreparedInsertQueryObject2();
         boolean result = dataStore.executePut(testObject, "Critical");
         assertEquals(true, result);
     }
 
     @Test
     public void Test4_ExecutePut_eventual_update() throws MusicServiceException, MusicQueryException {
-        testObject = CassandraCQLQueries.setPreparedUpdateQueryObject();
+        testObject = CassandraCQL.setPreparedUpdateQueryObject();
         boolean result = false;
         result = dataStore.executePut(testObject, "eventual");
         assertEquals(true, result);
@@ -101,7 +101,7 @@ public class MusicDataStoreTest {
     @Test
     public void Test5_ExecuteEventualGet() throws MusicServiceException, MusicQueryException {
         testObject = new PreparedQueryObject();
-        testObject.appendQueryString(CassandraCQLQueries.selectALL);
+        testObject.appendQueryString(CassandraCQL.selectALL);
         boolean result = false;
         int count = 0;
         ResultSet output = null;
@@ -120,7 +120,7 @@ public class MusicDataStoreTest {
 
     @Test
     public void Test6_ExecuteCriticalGet() throws MusicServiceException, MusicQueryException {
-        testObject = CassandraCQLQueries.setPreparedGetQuery();
+        testObject = CassandraCQL.setPreparedGetQuery();
         boolean result = false;
         int count = 0;
         ResultSet output = null;
index 45ce929..8677453 100644 (file)
@@ -32,8 +32,9 @@ import org.junit.runners.MethodSorters;
 import org.mockito.Mock;
 import org.onap.music.exceptions.MusicQueryException;
 import org.onap.music.exceptions.MusicServiceException;
-import org.onap.music.lockingservice.cassandra.CassaLockStore;
-import org.onap.music.datastore.MusicDataStore;
+
+import org.onap.music.datastore.CassaDataStore;
+import org.onap.music.datastore.CassaLockStore;
 import org.onap.music.datastore.PreparedQueryObject;
 
 import com.datastax.driver.core.DataType;
@@ -44,13 +45,13 @@ import com.datastax.driver.core.TableMetadata;
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 public class MusicLockStoreTest {
 
-    static MusicDataStore dataStore;
+    static CassaDataStore dataStore;
     static CassaLockStore lockStore;
     static PreparedQueryObject testObject;
 
     @BeforeClass
     public static void init() {
-        dataStore = CassandraCQLQueries.connectToEmbeddedCassandra();
+        dataStore = CassandraCQL.connectToEmbeddedCassandra();
         lockStore = new CassaLockStore(dataStore);
 
     }
@@ -58,7 +59,7 @@ public class MusicLockStoreTest {
     @AfterClass
     public static void close() throws MusicServiceException, MusicQueryException {
         testObject = new PreparedQueryObject();
-        testObject.appendQueryString(CassandraCQLQueries.dropKeyspace);
+        testObject.appendQueryString(CassandraCQL.dropKeyspace);
         dataStore.executePut(testObject, "eventual");
         dataStore.close();
 
@@ -68,10 +69,10 @@ public class MusicLockStoreTest {
     public void Test1_SetUp() throws MusicServiceException, MusicQueryException {
         boolean result = false;
         testObject = new PreparedQueryObject();
-        testObject.appendQueryString(CassandraCQLQueries.createKeySpace);
+        testObject.appendQueryString(CassandraCQL.createKeySpace);
         result = dataStore.executePut(testObject, "eventual");;
         testObject = new PreparedQueryObject();
-        testObject.appendQueryString(CassandraCQLQueries.createTableEmployees);
+        testObject.appendQueryString(CassandraCQL.createTableEmployees);
         result = dataStore.executePut(testObject, "eventual");
         assertEquals(true, result);
 
@@ -92,14 +93,14 @@ public class MusicLockStoreTest {
 
     @Test
     public void Test3_ExecutePut_critical_insert() throws MusicServiceException, MusicQueryException {
-        testObject = CassandraCQLQueries.setPreparedInsertQueryObject2();
+        testObject = CassandraCQL.setPreparedInsertQueryObject2();
         boolean result = dataStore.executePut(testObject, "Critical");
         assertEquals(true, result);
     }
 
     @Test
     public void Test4_ExecutePut_eventual_update() throws MusicServiceException, MusicQueryException {
-        testObject = CassandraCQLQueries.setPreparedUpdateQueryObject();
+        testObject = CassandraCQL.setPreparedUpdateQueryObject();
         boolean result = false;
         result = dataStore.executePut(testObject, "eventual");
         assertEquals(true, result);
@@ -108,7 +109,7 @@ public class MusicLockStoreTest {
     @Test
     public void Test5_ExecuteEventualGet() throws MusicServiceException, MusicQueryException {
         testObject = new PreparedQueryObject();
-        testObject.appendQueryString(CassandraCQLQueries.selectALL);
+        testObject.appendQueryString(CassandraCQL.selectALL);
         boolean result = false;
         int count = 0;
         ResultSet output = null;
@@ -127,7 +128,7 @@ public class MusicLockStoreTest {
 
     @Test
     public void Test6_ExecuteCriticalGet() throws MusicServiceException, MusicQueryException {
-        testObject = CassandraCQLQueries.setPreparedGetQuery();
+        testObject = CassandraCQL.setPreparedGetQuery();
         boolean result = false;
         int count = 0;
         ResultSet output = null;
index 2f3750a..bf05812 100644 (file)
@@ -2,18 +2,16 @@ package org.onap.music.unittests;
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.UUID;
 
+import org.onap.music.datastore.CassaLockStore;
 import org.onap.music.datastore.PreparedQueryObject;
 import org.onap.music.exceptions.MusicQueryException;
 import org.onap.music.exceptions.MusicServiceException;
-import org.onap.music.lockingservice.cassandra.CassaLockStore;
-import org.onap.music.service.MusicCoreService;
-import org.onap.music.service.impl.MusicCassaCore;
+import org.onap.music.main.MusicCore;
 
 public class TestCassaLockStore {
        
-       static MusicCoreService musicCore  = MusicCassaCore.getInstance();
-       
        
        public static void main(String[] args) {
                
@@ -29,12 +27,12 @@ public class TestCassaLockStore {
             
             PreparedQueryObject queryObject = new PreparedQueryObject();
             queryObject.appendQueryString("CREATE KEYSPACE " + keyspace + " WITH REPLICATION = " + replicationInfo.toString().replaceAll("=", ":"));
-            musicCore.nonKeyRelatedPut(queryObject, "eventual");
+            MusicCore.nonKeyRelatedPut(queryObject, "eventual");
 
             
             queryObject = new PreparedQueryObject();
             queryObject.appendQueryString("CREATE TABLE " + keyspace + "." + table + " (name text PRIMARY KEY, count varint);");
-            musicCore.createTable(keyspace, table, queryObject, "eventual");              
+            MusicCore.createTable(keyspace, table, queryObject, "eventual");              
 
                        
                        lockStore.createLockQueue(keyspace, table);
index 6f0a93a..01d2ffb 100644 (file)
@@ -1,6 +1,10 @@
 package org.onap.music.unittests;
 
+import static org.junit.Assert.assertEquals;
+
 import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
 import org.junit.AfterClass;
@@ -9,14 +13,12 @@ import org.junit.FixMethodOrder;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runners.MethodSorters;
-import org.onap.music.datastore.MusicDataStore;
-import org.onap.music.datastore.MusicDataStoreHandle;
+import org.onap.music.datastore.CassaDataStore;
+import org.onap.music.datastore.CassaLockStore;
 import org.onap.music.datastore.PreparedQueryObject;
 import org.onap.music.exceptions.MusicQueryException;
 import org.onap.music.exceptions.MusicServiceException;
-import org.onap.music.lockingservice.cassandra.CassaLockStore;
-import org.onap.music.service.MusicCoreService;
-import org.onap.music.service.impl.MusicCassaCore;
+import org.onap.music.main.MusicCore;
 
 import com.datastax.driver.core.ResultSet;
 
@@ -25,17 +27,16 @@ import com.datastax.driver.core.ResultSet;
 public class TestMusicCore {
        
        static PreparedQueryObject testObject;
-    static MusicDataStore dataStore;
+    static CassaDataStore dataStore;
     String keyspace = "MusicCoreUnitTestKp";
     String table = "SampleTable";
-    static MusicCoreService musicCore = MusicCassaCore.getInstance();
 
     @BeforeClass
     public static void init() {
        System.out.println("TestMusicCore Init");
         try {
-            MusicDataStoreHandle.mDstoreHandle = CassandraCQLQueries.connectToEmbeddedCassandra();
-            CassaLockStore mLockHandle = new CassaLockStore(MusicDataStoreHandle.mDstoreHandle);
+            MusicCore.mDstoreHandle = CassandraCQL.connectToEmbeddedCassandra();
+            MusicCore.mLockHandle = new CassaLockStore(MusicCore.mDstoreHandle);
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -45,9 +46,9 @@ public class TestMusicCore {
     public static void close() throws MusicServiceException, MusicQueryException {
        System.out.println("After class TestMusicCore");
         testObject = new PreparedQueryObject();
-        testObject.appendQueryString(CassandraCQLQueries.dropKeyspace);
-        musicCore.eventualPut(testObject);
-        MusicDataStoreHandle.mDstoreHandle.close();
+        testObject.appendQueryString(CassandraCQL.dropKeyspace);
+        MusicCore.eventualPut(testObject);
+        MusicCore.mDstoreHandle.close();
     }
 
     @Test
@@ -60,7 +61,7 @@ public class TestMusicCore {
         PreparedQueryObject queryObject = new PreparedQueryObject();
         queryObject.appendQueryString(
           "CREATE KEYSPACE " + keyspace + " WITH REPLICATION = " + replicationInfo.toString().replaceAll("=", ":"));
-        musicCore.nonKeyRelatedPut(queryObject, "eventual");
+        MusicCore.nonKeyRelatedPut(queryObject, "eventual");
         
         
         //check with the system table in cassandra
@@ -76,7 +77,7 @@ public class TestMusicCore {
                PreparedQueryObject queryObject = new PreparedQueryObject();
         queryObject.appendQueryString(
           "CREATE TABLE " + keyspace + "." + table + " (name text PRIMARY KEY, count varint);");
-        musicCore.createTable(keyspace, table, queryObject, "eventual");              
+        MusicCore.createTable(keyspace, table, queryObject, "eventual");              
 
         
         //check with the system table in cassandra
index 53b6d8b..9b4fc22 100644 (file)
@@ -19,29 +19,26 @@ package org.onap.music.unittests;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-
+import static org.junit.Assert.assertTrue;
+import java.io.File;
 import java.util.List;
-
+import org.apache.curator.test.TestingServer;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.FixMethodOrder;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runners.MethodSorters;
-import org.onap.music.datastore.MusicDataStoreHandle;
 import org.onap.music.datastore.PreparedQueryObject;
 import org.onap.music.exceptions.MusicQueryException;
 import org.onap.music.exceptions.MusicServiceException;
-import org.onap.music.lockingservice.cassandra.CassaLockStore;
-import org.onap.music.lockingservice.cassandra.MusicLockState;
-import org.onap.music.lockingservice.cassandra.MusicLockState.LockStatus;
-import org.onap.music.service.MusicCoreService;
-import org.onap.music.service.impl.*;
+import org.onap.music.datastore.CassaLockStore;
+import org.onap.music.datastore.MusicLockState;
+import org.onap.music.datastore.MusicLockState.LockStatus;
+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.service.impl.MusicCassaCore;
-
 import com.datastax.driver.core.ResultSet;
 import com.datastax.driver.core.Row;
 
@@ -52,13 +49,12 @@ public class TestMusicCoreIntegration {
     static PreparedQueryObject testObject;
     static String lockId = null;
     static String lockName = "ks1.tb1.pk1";
-    static MusicCassaCore musicCore = MusicCassaCore.getInstance();
 
     @BeforeClass
     public static void init() throws Exception {
         try {
-            MusicDataStoreHandle.mDstoreHandle = CassandraCQLQueries.connectToEmbeddedCassandra();
-            MusicCassaCore.mLockHandle = new CassaLockStore(MusicDataStoreHandle.mDstoreHandle);
+            MusicCore.mDstoreHandle = CassandraCQL.connectToEmbeddedCassandra();
+            MusicCore.mLockHandle = new CassaLockStore(MusicCore.mDstoreHandle);
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -68,31 +64,31 @@ public class TestMusicCoreIntegration {
     public static void tearDownAfterClass() throws Exception {
         System.out.println("After class");
         testObject = new PreparedQueryObject();
-        testObject.appendQueryString(CassandraCQLQueries.dropKeyspace);
-        musicCore.eventualPut(testObject);
-        musicCore.deleteLock(lockName);
-        MusicDataStoreHandle.mDstoreHandle.close();
+        testObject.appendQueryString(CassandraCQL.dropKeyspace);
+        MusicCore.eventualPut(testObject);
+        MusicCore.deleteLock(lockName);
+        MusicCore.mDstoreHandle.close();
     }
 
     @Test
     public void Test1_SetUp() throws MusicServiceException, MusicQueryException {
-        MusicDataStoreHandle.mDstoreHandle = CassandraCQLQueries.connectToEmbeddedCassandra();
-        MusicCassaCore.mLockHandle = new CassaLockStore(MusicDataStoreHandle.mDstoreHandle);
+        MusicCore.mDstoreHandle = CassandraCQL.connectToEmbeddedCassandra();
+        MusicCore.mLockHandle = new CassaLockStore(MusicCore.mDstoreHandle);
         ResultType result = ResultType.FAILURE;
         testObject = new PreparedQueryObject();
-        testObject.appendQueryString(CassandraCQLQueries.createKeySpace);
-        musicCore.eventualPut(testObject);
+        testObject.appendQueryString(CassandraCQL.createKeySpace);
+        MusicCore.eventualPut(testObject);
         testObject = new PreparedQueryObject();
-        testObject.appendQueryString(CassandraCQLQueries.createTableEmployees);
-        result = musicCore.nonKeyRelatedPut(testObject, MusicUtil.EVENTUAL);
+        testObject.appendQueryString(CassandraCQL.createTableEmployees);
+        result = MusicCore.nonKeyRelatedPut(testObject, MusicUtil.EVENTUAL);
         assertEquals(ResultType.SUCCESS, result);
     }
 
     @Test
     public void Test2_atomicPut() throws Exception {
         testObject = new PreparedQueryObject();
-        testObject = CassandraCQLQueries.setPreparedInsertQueryObject1();
-        ReturnType returnType = musicCore.atomicPut("testCassa", "employees", "Mr Test one",
+        testObject = CassandraCQL.setPreparedInsertQueryObject1();
+        ReturnType returnType = MusicCore.atomicPut("testCassa", "employees", "Mr Test one",
                         testObject, null);
         assertEquals(ResultType.SUCCESS, returnType.getResult());
     }
@@ -101,28 +97,28 @@ public class TestMusicCoreIntegration {
     @Test
     public void Test5_atomicGet() throws Exception {
         testObject = new PreparedQueryObject();
-        testObject = CassandraCQLQueries.setPreparedGetQuery();
+        testObject = CassandraCQL.setPreparedGetQuery();
         ResultSet resultSet =
-                        musicCore.atomicGet("testCassa", "employees", "Mr Test two", testObject);
+                        MusicCore.atomicGet("testCassa", "employees", "Mr Test two", testObject);
         List<Row> rows = resultSet.all();
         assertEquals(1, rows.size());
     }
 
     @Test
     public void Test6_createLockReference() throws Exception {
-        lockId = musicCore.createLockReference(lockName);
+        lockId = MusicCore.createLockReference(lockName);
         assertNotNull(lockId);
     }
 
     @Test
     public void Test7_acquireLockwithLease() throws Exception {
-        ReturnType lockLeaseStatus = musicCore.acquireLockWithLease(lockName, lockId, 1000);
+        ReturnType lockLeaseStatus = MusicCore.acquireLockWithLease(lockName, lockId, 1000);
         assertEquals(ResultType.SUCCESS, lockLeaseStatus.getResult());
     }
 
     @Test
     public void Test8_acquireLock() throws Exception {
-        ReturnType lockStatus = musicCore.acquireLock(lockName, lockId);
+        ReturnType lockStatus = MusicCore.acquireLock(lockName, lockId);
         assertEquals(ResultType.SUCCESS, lockStatus.getResult());
     }
 
@@ -130,9 +126,9 @@ public class TestMusicCoreIntegration {
     public void Test9_release() throws Exception {
         MusicLockState musicLockState = new MusicLockState(LockStatus.LOCKED, "id1");
         MusicLockState musicLockState1 = new MusicLockState(LockStatus.UNLOCKED, "id1");
-        musicCore.whoseTurnIsIt(lockName);
-        MusicLockState mls = musicCore.getMusicLockState(lockName);
-        MusicLockState mls1 = musicCore.voluntaryReleaseLock(lockName,lockId);
+        MusicCore.whoseTurnIsIt(lockName);
+        MusicLockState mls = MusicCore.getMusicLockState(lockName);
+        MusicLockState mls1 = MusicCore.voluntaryReleaseLock(lockName,lockId);
         assertEquals(musicLockState.getLockStatus(), mls.getLockStatus());
         assertEquals(musicLockState1.getLockStatus(), mls1.getLockStatus());
     }
index 01ae861..f0c52a3 100644 (file)
@@ -21,17 +21,15 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertTrue;
-
+import java.io.File;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
-
 import javax.servlet.http.HttpServletResponse;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
-
 import org.apache.curator.test.TestingServer;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -46,7 +44,7 @@ import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
 import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.music.datastore.MusicDataStoreHandle;
+import org.onap.music.datastore.CassaLockStore;
 import org.onap.music.datastore.PreparedQueryObject;
 import org.onap.music.datastore.jsonobjects.JsonDelete;
 import org.onap.music.datastore.jsonobjects.JsonInsert;
@@ -55,16 +53,13 @@ import org.onap.music.datastore.jsonobjects.JsonOnboard;
 import org.onap.music.datastore.jsonobjects.JsonSelect;
 import org.onap.music.datastore.jsonobjects.JsonTable;
 import org.onap.music.datastore.jsonobjects.JsonUpdate;
-import org.onap.music.lockingservice.cassandra.CassaLockStore;
 import org.onap.music.main.CachingUtil;
-import org.onap.music.service.impl.*;
+import org.onap.music.main.MusicCore;
 import org.onap.music.main.MusicUtil;
 import org.onap.music.main.ResultType;
 import org.onap.music.rest.RestMusicAdminAPI;
 import org.onap.music.rest.RestMusicDataAPI;
 import org.onap.music.rest.RestMusicLocksAPI;
-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;
@@ -92,7 +87,7 @@ public class TestRestMusicData {
     CachingUtil cachUtilMock;
     
     @InjectMocks
-      private static MusicCassaCore MusicCore =MusicCassaCore.getInstance();
+      private MusicCore mCore;
     //*/
     
     static String appName = "TestApp";
@@ -114,8 +109,8 @@ public class TestRestMusicData {
     @BeforeClass
     public static void init() throws Exception {
        try {
-            MusicDataStoreHandle.mDstoreHandle = CassandraCQLQueries.connectToEmbeddedCassandra();
-            MusicCore.mLockHandle = new CassaLockStore(MusicDataStoreHandle.mDstoreHandle);
+            MusicCore.mDstoreHandle = CassandraCQL.connectToEmbeddedCassandra();
+            MusicCore.mLockHandle = new CassaLockStore(MusicCore.mDstoreHandle);
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -129,8 +124,8 @@ public class TestRestMusicData {
         testObject = new PreparedQueryObject();
         testObject.appendQueryString("DROP KEYSPACE IF EXISTS admin");
         MusicCore.eventualPut(testObject);
-        if(MusicDataStoreHandle.mDstoreHandle!=null)
-               MusicDataStoreHandle.mDstoreHandle.close();
+        if(MusicCore.mDstoreHandle!=null)
+               MusicCore.mDstoreHandle.close();
         if(zkServer!=null)
                zkServer.stop();
     }
index 93591bf..a3d3d70 100644 (file)
@@ -47,8 +47,7 @@ import org.mindrot.jbcrypt.BCrypt;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.music.lockingservice.cassandra.CassaLockStore;
-import org.onap.music.datastore.MusicDataStoreHandle;
+import org.onap.music.datastore.CassaLockStore;
 import org.onap.music.datastore.PreparedQueryObject;
 import org.onap.music.datastore.jsonobjects.JsonDelete;
 import org.onap.music.datastore.jsonobjects.JsonInsert;
@@ -58,12 +57,12 @@ import org.onap.music.datastore.jsonobjects.JsonKeySpace;
 import org.onap.music.datastore.jsonobjects.JsonSelect;
 import org.onap.music.datastore.jsonobjects.JsonTable;
 import org.onap.music.datastore.jsonobjects.JsonUpdate;
+import org.onap.music.main.MusicCore;
 import org.onap.music.main.MusicUtil;
 //import org.onap.music.main.ResultType;
 import org.onap.music.rest.RestMusicAdminAPI;
 import org.onap.music.rest.RestMusicDataAPI;
 import org.onap.music.rest.RestMusicQAPI;
-import org.onap.music.service.impl.MusicCassaCore;
 import org.onap.music.rest.RestMusicLocksAPI;
 import com.datastax.driver.core.DataType;
 import com.datastax.driver.core.ResultSet;
@@ -120,13 +119,12 @@ public class TestRestMusicQAPI {
     static JsonKeySpace kspObject=null;
     static RestMusicDataAPI data = new RestMusicDataAPI();
     static Response resp;
-    static MusicCassaCore MusicCore = MusicCassaCore.getInstance();
     
     @BeforeClass
     public static void init() throws Exception {
         try {
-            MusicDataStoreHandle.mDstoreHandle = CassandraCQLQueries.connectToEmbeddedCassandra();
-            MusicCassaCore.mLockHandle = new CassaLockStore(MusicDataStoreHandle.mDstoreHandle);
+            MusicCore.mDstoreHandle = CassandraCQL.connectToEmbeddedCassandra();
+            MusicCore.mLockHandle = new CassaLockStore(MusicCore.mDstoreHandle);
 
            // System.out.println("before class keysp");
             //resp=data.createKeySpace(majorV,minorV,patchV,aid,appName,userId,password,kspObject,keyspaceName);
@@ -213,8 +211,8 @@ public class TestRestMusicQAPI {
         testObject = new PreparedQueryObject();
         testObject.appendQueryString("DROP KEYSPACE IF EXISTS admin");
         MusicCore.eventualPut(testObject);
-        if (MusicDataStoreHandle.mDstoreHandle!=null)
-               MusicDataStoreHandle.mDstoreHandle.close();
+        if (MusicCore.mDstoreHandle!=null)
+               MusicCore.mDstoreHandle.close();
         if (zkServer!=null)
                zkServer.stop();
     }
index 8ac7180..e7a1e25 100644 (file)
@@ -2,12 +2,12 @@ package org.onap.music.unittests;
 
 import java.util.HashMap;
 import java.util.Map;
-
 import org.onap.music.datastore.PreparedQueryObject;
 import org.onap.music.exceptions.MusicLockingException;
 import org.onap.music.exceptions.MusicQueryException;
 import org.onap.music.exceptions.MusicServiceException;
-import org.onap.music.service.impl.MusicCassaCore;
+import org.onap.music.main.MusicCore;
 
 import com.datastax.driver.core.ResultSet;
 import com.datastax.driver.core.Row;
@@ -19,7 +19,6 @@ public class TestVotingApp
 {
     String keyspaceName;
     String tableName;
-    static MusicCassaCore MusicCore = MusicCassaCore.getInstance();
        
     public TestVotingApp() throws MusicServiceException {
         keyspaceName = "VotingAppForMusic"+System.currentTimeMillis();