lowered some code smells
[music.git] / music-core / src / main / java / org / onap / music / main / MusicUtil.java
1 /*
2  * ============LICENSE_START==========================================
3  * org.onap.music
4  * ===================================================================
5  *  Copyright (c) 2017 AT&T Intellectual Property
6  * ===================================================================
7  *  Modifications Copyright (c) 2019 IBM.
8  *  Modifications Copyright (c) 2019 Samsung.
9  * ===================================================================
10  *  Licensed under the Apache License, Version 2.0 (the "License");
11  *  you may not use this file except in compliance with the License.
12  *  You may obtain a copy of the License at
13  *
14  *     http://www.apache.org/licenses/LICENSE-2.0
15  *
16  *  Unless required by applicable law or agreed to in writing, software
17  *  distributed under the License is distributed on an "AS IS" BASIS,
18  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  *  See the License for the specific language governing permissions and
20  *  limitations under the License.
21  *
22  * ============LICENSE_END=============================================
23  * ====================================================================
24  */
25
26 package org.onap.music.main;
27
28 import com.datastax.driver.core.ColumnDefinitions;
29 import com.datastax.driver.core.ColumnDefinitions.Definition;
30 import com.datastax.driver.core.ResultSet;
31 import com.datastax.driver.core.Row;
32 import java.io.File;
33 import java.io.FileNotFoundException;
34 import java.math.BigInteger;
35 import java.nio.ByteBuffer;
36 import java.util.HashMap;
37 import java.util.HashSet;
38 import java.util.List;
39 import java.util.Map;
40 import java.util.Scanner;
41 import java.util.Set;
42 import java.util.UUID;
43
44 import javax.ws.rs.core.Response;
45 import javax.ws.rs.core.Response.ResponseBuilder;
46 import org.onap.music.datastore.MusicDataStoreHandle;
47 import org.onap.music.datastore.PreparedQueryObject;
48 import org.onap.music.eelf.logging.EELFLoggerDelegate;
49 import org.onap.music.eelf.logging.format.AppMessages;
50 import org.onap.music.eelf.logging.format.ErrorSeverity;
51 import org.onap.music.eelf.logging.format.ErrorTypes;
52 import org.onap.music.exceptions.MusicQueryException;
53 import org.onap.music.exceptions.MusicServiceException;
54 import org.onap.music.service.MusicCoreService;
55 import org.onap.music.service.impl.MusicCassaCore;
56
57 import com.datastax.driver.core.ConsistencyLevel;
58 import com.datastax.driver.core.DataType;
59
60 /**
61  * @author nelson24
62  *
63  *         Properties This will take Properties and load them into MusicUtil.
64  *         This is a hack for now. Eventually it would bebest to do this in
65  *         another way.
66  *
67  */
68 public class MusicUtil {
69     private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicUtil.class);
70
71     // Consistancy Constants
72     public static final String ATOMIC = "atomic";
73     public static final String EVENTUAL = "eventual";
74     public static final String CRITICAL = "critical";
75     public static final String EVENTUAL_NB = "eventual_nb";
76     public static final String ALL = "all";
77     public static final String QUORUM = "quorum";
78     public static final String LOCAL_QUORUM = "local_quorum";
79     public static final String ONE = "one";
80     public static final String ATOMICDELETELOCK = "atomic_delete_lock";
81
82     // Header Constants
83     private static final String XLATESTVERSION = "X-latestVersion";
84     private static final String XMINORVERSION = "X-minorVersion";
85     private static final String XPATCHVERSION = "X-patchVersion";
86     public static final String AUTHORIZATION = "Authorization";
87
88     // CQL Constants
89     public static final String SELECT = "select";
90     public static final String INSERT = "insert";
91     public static final String UPDATE = "update";
92     public static final String UPSERT = "upsert";
93     public static final String USERID = "userId";
94     public static final String PASSWORD = "";
95     public static final String CASSANDRA = "cassandra";
96
97     private static final String LOCALHOST = "localhost";
98     private static final String PROPERTIES_FILE = "/opt/app/music/etc/music.properties";
99     public static final String DEFAULTKEYSPACENAME = "TBD";
100
101     private static long defaultLockLeasePeriod = 6000;
102     // Amount of times to retry to delete a lock in atomic.
103     private static int retryCount = 3;
104     private static String lockUsing = MusicUtil.CASSANDRA;
105     // Cadi OnOff
106     private static boolean isCadi = false;
107     // Keyspace Creation on/off
108     private static boolean isKeyspaceActive = false;
109     private static boolean debug = true;
110     private static String version = "0.0.0";
111     private static String build = "";
112     private static long lockDaemonSleepms = 1000;
113     private static Set<String> keyspacesToCleanLocks = new HashSet<>();
114
115     private static String musicPropertiesFilePath = PROPERTIES_FILE;
116     // private static final String[] propKeys = new String[] { MusicUtil.class.getDeclaredMethod(arg0, )"build","cassandra.host", "debug",
117     //     "version", "music.properties", "lock.lease.period", "cassandra.user", 
118     //     "cassandra.password", "aaf.endpoint.url","admin.username","admin.password",
119     //     "music.namespace","admin.aaf.role","cassandra.port","lock.using","retry.count",
120     //     "transId.header.required","conversation.header.required","clientId.header.required",
121     //     "messageId.header.required","transId.header.prefix","conversation.header.prefix",
122     //     "clientId.header.prefix","messageId.header.prefix"};
123     // Consistency Constants and variables. 
124     private static final String[] cosistencyLevel = new String[] {
125             "ALL","EACH_QUORUM","QUORUM","LOCAL_QUORUM","ONE","TWO",
126             "THREE","LOCAL_ONE","ANY","SERIAL","LOCAL_SERIAL"};
127     private static final Map<String,ConsistencyLevel> consistencyName = new HashMap<>();
128     static {
129         consistencyName.put("ONE",ConsistencyLevel.ONE);
130         consistencyName.put("TWO",ConsistencyLevel.TWO);
131         consistencyName.put("THREE",ConsistencyLevel.THREE);
132         consistencyName.put("SERIAL",ConsistencyLevel.SERIAL);
133         consistencyName.put("ALL",ConsistencyLevel.ALL);
134         consistencyName.put("EACH_QUORUM",ConsistencyLevel.EACH_QUORUM);
135         consistencyName.put("QUORUM",ConsistencyLevel.QUORUM);
136         consistencyName.put("LOCAL_QUORUM",ConsistencyLevel.LOCAL_QUORUM);
137         consistencyName.put("LOCAL_ONE",ConsistencyLevel.LOCAL_ONE);
138         consistencyName.put("LOCAL_SERIAL",ConsistencyLevel.LOCAL_SERIAL);
139     }
140
141     // Cassandra Values
142     private static String cassName = "cassandra";
143     private static String cassPwd;
144     private static String myCassaHost = LOCALHOST;
145     private static int cassandraPort = 9042;
146     private static int cassandraConnectTimeOutMS; 
147     private static int cassandraReadTimeOutMS;
148
149     // AAF
150     private static String musicAafNs = "org.onap.music.cadi";
151
152     // Locking
153     public static final long MusicEternityEpochMillis = 1533081600000L; // Wednesday, August 1, 2018 12:00:00 AM
154     public static final long MaxLockReferenceTimePart = 1000000000000L; // millis after eternity (eq sometime in 2050)
155     public static final long MaxCriticalSectionDurationMillis = 1L * 24 * 60 * 60 * 1000; // 1 day
156
157     // Response/Request tracking headers
158     private static String transIdPrefix = "false";
159     private static String conversationIdPrefix = "false";
160     private static String clientIdPrefix = "false";
161     private static String messageIdPrefix = "false";
162     private static Boolean transIdRequired = false;
163     private static Boolean conversationIdRequired = false;
164     private static Boolean clientIdRequired = false;
165     private static Boolean messageIdRequired = false;
166     private static String cipherEncKey = "";
167     
168     private static long createLockWaitPeriod = 300;
169     private static int createLockWaitIncrement = 50;
170     
171     public static long getCreateLockWaitPeriod() {
172         return createLockWaitPeriod;
173     }
174     
175     public static void setCreateLockWaitPeriod(long createLockWaitPeriod) {
176         MusicUtil.createLockWaitPeriod = createLockWaitPeriod;
177     }
178
179     public static int getCreateLockWaitIncrement() {
180         return createLockWaitIncrement;
181     }
182     
183     public static void setCreateLockWaitIncrement(int createLockWaitIncrement) {
184         MusicUtil.createLockWaitIncrement = createLockWaitIncrement;
185     }
186     
187     public MusicUtil() {
188         throw new IllegalStateException("Utility Class");
189     }
190
191     public static String getLockUsing() {
192         return lockUsing;
193     }
194
195     public static void setLockUsing(String lockUsing) {
196         MusicUtil.lockUsing = lockUsing;
197     }
198
199     /**
200      *
201      * @return cassandra port
202      */
203     public static int getCassandraPort() {
204         return cassandraPort;
205     }
206
207     /**
208      * set cassandra port
209      * @param cassandraPort
210      */
211     public static void setCassandraPort(int cassandraPort) {
212         MusicUtil.cassandraPort = cassandraPort;
213     }
214     /**
215      * @return the cassName
216      */
217     public static String getCassName() {
218         return cassName;
219     }
220
221     /**
222      * @return the cassPwd
223      */
224     public static String getCassPwd() {
225         return cassPwd;
226     }
227
228     public static int getCassandraConnectTimeOutMS() {
229         return cassandraConnectTimeOutMS;
230     }
231
232     public static void setCassandraConnectTimeOutMS(int cassandraConnectTimeOutMS) {
233         MusicUtil.cassandraConnectTimeOutMS = cassandraConnectTimeOutMS;
234     }
235
236     public static int getCassandraReadTimeOutMS() {
237         return cassandraReadTimeOutMS;
238     }
239
240     public static void setCassandraReadTimeOutMS(int cassandraReadTimeOutMS) {
241         MusicUtil.cassandraReadTimeOutMS = cassandraReadTimeOutMS;
242     }
243
244     /**
245      * Returns An array of property names that should be in the Properties
246      * files.
247      *
248 //     * @return
249 //     */
250     //    public static String[] getPropkeys() {
251     //        return propKeys.clone();
252     //    }
253
254     /**
255      * Get MusicPropertiesFilePath - Default = /opt/music/music.properties
256      * property file value - music.properties
257      *
258      * @return
259      */
260     public static String getMusicPropertiesFilePath() {
261         return musicPropertiesFilePath;
262     }
263
264     /**
265      * Set MusicPropertiesFilePath
266      *
267      * @param musicPropertiesFilePath
268      */
269     public static void setMusicPropertiesFilePath(String musicPropertiesFilePath) {
270         MusicUtil.musicPropertiesFilePath = musicPropertiesFilePath;
271     }
272
273     /**
274      * Get DefaultLockLeasePeriod - Default = 6000 property file value -
275      * lock.lease.period
276      *
277      * @return
278      */
279     public static long getDefaultLockLeasePeriod() {
280         return defaultLockLeasePeriod;
281     }
282
283     /**
284      * Set DefaultLockLeasePeriod
285      *
286      * @param defaultLockLeasePeriod
287      */
288     public static void setDefaultLockLeasePeriod(long defaultLockLeasePeriod) {
289         MusicUtil.defaultLockLeasePeriod = defaultLockLeasePeriod;
290     }
291
292     /**
293      * Set Debug
294      *
295      * @param debug
296      */
297     public static void setDebug(boolean debug) {
298         MusicUtil.debug = debug;
299     }
300
301     /**
302      * Is Debug - Default = true property file value - debug
303      *
304      * @return
305      */
306     public static boolean isDebug() {
307         return debug;
308     }
309
310     /**
311      * Set Version
312      *
313      * @param version
314      */
315     public static void setVersion(String version) {
316         MusicUtil.version = version;
317     }
318
319     /**
320      * Return the version property file value - version.
321      *
322      * @return
323      */
324     public static String getVersion() {
325         return version;
326     }
327
328     /**
329      * Set the build of project which is a combination of the 
330      * version and the date.
331      * 
332      * @param build - version-date.
333      */
334     public static void setBuild(String build) {
335         MusicUtil.build = build;
336     }
337
338     /**
339      * Return the build version-date.
340      */
341     public static String getBuild() {
342         return build;
343     }
344
345     /**
346      * Get MyCassHost - Cassandra Hostname - Default = localhost property file
347      * value - cassandra.host
348      *
349      * @return
350      */
351     public static String getMyCassaHost() {
352         return myCassaHost;
353     }
354
355     /**
356      * Set MyCassHost - Cassandra Hostname
357      *
358      * @param myCassaHost .
359      */
360     public static void setMyCassaHost(String myCassaHost) {
361         MusicUtil.myCassaHost = myCassaHost;
362     }
363
364     /**
365      * Gey default retry count
366      * @return
367      */
368     public static int getRetryCount() {
369         return retryCount;
370     }
371
372     /**
373      * Set retry count
374      * @param retryCount .
375      */
376     public static void setRetryCount(int retryCount) {
377         MusicUtil.retryCount = retryCount;
378     }
379
380
381     /**
382      * This is used to turn keyspace creation api on/off.
383      * 
384      */
385     public static void setKeyspaceActive(Boolean keyspaceActive) {
386         MusicUtil.isKeyspaceActive = keyspaceActive;
387     }
388
389     /**
390      * This is used to turn keyspace creation api on/off.
391      * @return boolean isKeyspaceActive
392      */
393     public static boolean isKeyspaceActive() {
394         return isKeyspaceActive;
395     }
396
397     /**
398      * This method depricated as its not used or needed.
399      * 
400      * @return String
401      */
402     @Deprecated
403     public static String getTestType() {
404         String testType = "";
405         try {
406             Scanner fileScanner = new Scanner(new File(""));
407             testType = fileScanner.next();// ignore the my id line
408             @SuppressWarnings("unused")
409             String batchSize = fileScanner.next();// ignore the my public ip line
410             fileScanner.close();
411         } catch (FileNotFoundException e) {
412             logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), e);
413         }
414         return testType;
415
416     }
417
418     /**
419      * Method to do a Thread Sleep.
420      * Used for adding a delay. 
421      * 
422      * @param time
423      */
424     public static void sleep(long time) {
425         try {
426             Thread.sleep(time);
427         } catch (InterruptedException e) {
428             logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), e);
429             Thread.currentThread().interrupt();
430         }
431     }
432
433     /**
434      * Utility function to check if the query object is valid.
435      *
436      * @param withparams
437      * @param queryObject
438      * @return
439      */
440     public static boolean isValidQueryObject(boolean withparams, PreparedQueryObject queryObject) {
441         if (withparams) {
442             int noOfValues = queryObject.getValues().size();
443             int noOfParams = 0;
444             char[] temp = queryObject.getQuery().toCharArray();
445             for (int i = 0; i < temp.length; i++) {
446                 if (temp[i] == '?')
447                     noOfParams++;
448             }
449             return (noOfValues == noOfParams);
450         } else {
451             return !queryObject.getQuery().isEmpty();
452         }
453
454     }
455
456     public static void setCassName(String cassName) {
457         MusicUtil.cassName = cassName;
458     }
459
460     public static void setCassPwd(String cassPwd) {
461         MusicUtil.cassPwd = cassPwd;
462     }
463
464     @SuppressWarnings("unchecked")
465     public static String convertToCQLDataType(DataType type, Object valueObj) throws Exception {
466
467         String value = "";
468         switch (type.getName()) {
469             case UUID:
470                 value = valueObj + "";
471                 break;
472             case TEXT:
473             case VARCHAR:
474                 String valueString = valueObj + "";
475                 valueString = valueString.replace("'", "''");
476                 value = "'" + valueString + "'";
477                 break;
478             case MAP: {
479                 Map<String, Object> otMap = (Map<String, Object>) valueObj;
480                 value = "{" + jsonMaptoSqlString(otMap, ",") + "}";
481                 break;
482             }
483             default:
484                 value = valueObj + "";
485                 break;
486         }
487         return value;
488     }
489
490     /**
491      *
492      * @param colType
493      * @param valueObj
494      * @return
495      * @throws MusicTypeConversionException
496      * @throws Exception
497      */
498     @SuppressWarnings("unchecked")
499     public static Object convertToActualDataType(DataType colType, Object valueObj) throws Exception {
500         String valueObjString = valueObj + "";
501         switch (colType.getName()) {
502             case UUID:
503                 return UUID.fromString(valueObjString);
504             case VARINT:
505                 return BigInteger.valueOf(Long.parseLong(valueObjString));
506             case BIGINT:
507                 return Long.parseLong(valueObjString);
508             case INT:
509                 return Integer.parseInt(valueObjString);
510             case FLOAT:
511                 return Float.parseFloat(valueObjString);
512             case DOUBLE:
513                 return Double.parseDouble(valueObjString);
514             case BOOLEAN:
515                 return Boolean.parseBoolean(valueObjString);
516             case MAP:
517                 return (Map<String, Object>) valueObj;
518             case LIST:
519                 return valueObj;
520             case BLOB:
521
522             default:
523                 return valueObjString;
524         }
525     }
526
527     public static ByteBuffer convertToActualDataType(DataType colType, byte[] valueObj) {
528         
529         return ByteBuffer.wrap(valueObj);
530     }
531
532     /**
533      *
534      * Utility function to parse json map into sql like string
535      *
536      * @param jMap
537      * @param lineDelimiter
538      * @return
539      */
540
541     public static String jsonMaptoSqlString(Map<String, Object> jMap, String lineDelimiter) throws Exception{
542         StringBuilder sqlString = new StringBuilder();
543         int counter = 0;
544         for (Map.Entry<String, Object> entry : jMap.entrySet()) {
545             Object ot = entry.getValue();
546             String value = ot + "";
547             if (ot instanceof String) {
548                 value = "'" + value.replace("'", "''") + "'";
549             }
550             sqlString.append("'" + entry.getKey() + "':" + value);
551             if (counter != jMap.size() - 1)
552                 sqlString.append(lineDelimiter);
553             counter = counter + 1;
554         }
555         return sqlString.toString();
556     }
557
558     @SuppressWarnings("unused")
559     public static String buildVersion(String major, String minor, String patch) {
560         if (minor != null) {
561             major += "." + minor;
562             if (patch != null) {
563                 major += "." + patch;
564             }
565         }
566         return major;
567     }
568
569     /**
570      * Currently this will build a header with X-latestVersion, X-minorVersion and X-pathcVersion
571      * X-latestVerstion will be equal to the latest full version.
572      * X-minorVersion - will be equal to the latest minor version.
573      * X-pathVersion - will be equal to the latest patch version.
574      * Future plans will change this.
575      * @param response
576      * @param major
577      * @param minor
578      * @param patch
579      * @return
580      */
581     public static ResponseBuilder buildVersionResponse(String major, String minor, String patch) {
582         ResponseBuilder response = Response.noContent();
583         String versionIn = buildVersion(major,minor,patch);
584         String version = MusicUtil.getVersion();
585         String[] verArray = version.split("\\.",3);
586         if ( minor != null ) {
587             response.header(XMINORVERSION,minor);
588         } else {
589             response.header(XMINORVERSION,verArray[1]);
590         }
591         if ( patch != null ) {
592             response.header(XPATCHVERSION,patch);
593         } else {
594             response.header(XPATCHVERSION,verArray[2]);
595         }
596         response.header(XLATESTVERSION,version);
597         logger.info(EELFLoggerDelegate.auditLogger,"Version In:" + versionIn);
598         return response;
599     }
600
601     public static boolean isValidConsistency(String consistency) {
602         for (String string : cosistencyLevel) {
603             if (string.equalsIgnoreCase(consistency))
604                 return true;
605         }
606         return false;
607
608     }
609
610     public static ConsistencyLevel getConsistencyLevel(String consistency) {
611         return consistencyName.get(consistency.toUpperCase());
612     }
613
614     /**
615      * Given the time of write for an update in a critical section, this method provides a transformed timestamp
616      * that ensures that a previous lock holder who is still alive can never corrupt a later critical section.
617      * The main idea is to us the lock reference to clearly demarcate the timestamps across critical sections.
618      * @param the UUID lock reference associated with the write.
619      * @param the long timeOfWrite which is the actual time at which the write took place
620      * @throws MusicServiceException
621      * @throws MusicQueryException
622      */
623     public static long v2sTimeStampInMicroseconds(long ordinal, long timeOfWrite) throws MusicServiceException, MusicQueryException{
624         // TODO: use acquire time instead of music eternity epoch
625         return ordinal * MaxLockReferenceTimePart + (timeOfWrite - MusicEternityEpochMillis);
626     }
627
628     public static MusicCoreService  getMusicCoreService() {
629         if(getLockUsing().equals(MusicUtil.CASSANDRA))
630             return MusicCassaCore.getInstance();
631         else
632             return MusicCassaCore.getInstance();
633     }
634
635     /**
636      * @param lockName
637      * @return
638      */
639     public static Map<String, Object> validateLock(String lockName) {
640         Map<String, Object> resultMap = new HashMap<>();
641         String[] locks = lockName.split("\\.");
642         if(locks.length < 3) {
643             resultMap.put("Error", "Invalid lock. Please make sure lock is of the type keyspaceName.tableName.primaryKey");
644             return resultMap;
645         }
646         String keyspace= locks[0];
647         if(keyspace.startsWith("$"))
648             keyspace = keyspace.substring(1);
649         resultMap.put("keyspace",keyspace);
650         return resultMap;
651     }
652
653
654     public static void setIsCadi(boolean isCadi) {
655         MusicUtil.isCadi = isCadi;
656     }
657
658     public static void writeBackToQuorum(PreparedQueryObject selectQuery, String primaryKeyName,
659             PreparedQueryObject updateQuery, String keyspace, String table,
660             Object cqlFormattedPrimaryKeyValue)
661                     throws Exception {
662         try {
663             ResultSet results = MusicDataStoreHandle.getDSHandle().executeQuorumConsistencyGet(selectQuery);
664             // write it back to a quorum
665             Row row = results.one();
666             ColumnDefinitions colInfo = row.getColumnDefinitions();
667             int totalColumns = colInfo.size();
668             int counter = 1;
669             StringBuilder fieldValueString = new StringBuilder("");
670             for (Definition definition : colInfo) {
671                 String colName = definition.getName();
672                 if (colName.equals(primaryKeyName))
673                     continue;
674                 DataType colType = definition.getType();
675                 Object valueObj = MusicDataStoreHandle.getDSHandle().getColValue(row, colName, colType);
676                 Object valueString = MusicUtil.convertToActualDataType(colType, valueObj);
677                 fieldValueString.append(colName + " = ?");
678                 updateQuery.addValue(valueString);
679                 if (counter != (totalColumns - 1))
680                     fieldValueString.append(",");
681                 counter = counter + 1;
682             }
683             updateQuery.appendQueryString("UPDATE " + keyspace + "." + table + " SET "
684                     + fieldValueString + " WHERE " + primaryKeyName + "= ? " + ";");
685             updateQuery.addValue(cqlFormattedPrimaryKeyValue);
686
687             MusicDataStoreHandle.getDSHandle().executePut(updateQuery, "critical");
688         } catch (MusicServiceException | MusicQueryException e) {
689             logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.QUERYERROR +""+updateQuery ,
690                     ErrorSeverity.MAJOR, ErrorTypes.QUERYERROR, e);
691         }
692     }
693
694     public static boolean getIsCadi() {
695         return MusicUtil.isCadi;
696     }
697
698
699     /**
700      * @return a random uuid
701      */
702     public static String generateUUID() {
703         String uuid = UUID.randomUUID().toString();
704         logger.info(EELFLoggerDelegate.applicationLogger,"New AID generated: "+uuid);
705         return uuid;
706     }
707
708     private static String checkPrefix(String prefix){
709         if (prefix == null || "".equals(prefix) || prefix.endsWith("-")) {
710             return prefix;
711         } else {
712             return prefix + "-";
713         }
714     }
715
716     /**
717      * @return the transIdPrefix
718      */
719     public static String getTransIdPrefix() {
720         return transIdPrefix;
721     }
722
723     /**
724      * @param transIdPrefix the transIdPrefix to set
725      */
726     public static void setTransIdPrefix(String transIdPrefix) {
727         MusicUtil.transIdPrefix = checkPrefix(transIdPrefix);
728     }
729
730     /**
731      * @return the conversationIdPrefix
732      */
733     public static String getConversationIdPrefix() {
734         return conversationIdPrefix;
735     }
736
737     /**
738      * @param conversationIdPrefix the conversationIdPrefix to set
739      */
740     public static void setConversationIdPrefix(String conversationIdPrefix) {
741         MusicUtil.conversationIdPrefix = checkPrefix(conversationIdPrefix);
742     }
743
744     /**
745      * @return the clientIdPrefix
746      */
747     public static String getClientIdPrefix() {
748         return clientIdPrefix;
749     }
750
751     /**
752      * @param clientIdPrefix the clientIdPrefix to set
753      */
754     public static void setClientIdPrefix(String clientIdPrefix) {
755         MusicUtil.clientIdPrefix = checkPrefix(clientIdPrefix);
756     }
757
758     /**
759      * @return the messageIdPrefix
760      */
761     public static String getMessageIdPrefix() {
762         return messageIdPrefix;
763     }
764
765     /**
766      * @param messageIdPrefix the messageIdPrefix to set
767      */
768     public static void setMessageIdPrefix(String messageIdPrefix) {
769         MusicUtil.messageIdPrefix = checkPrefix(messageIdPrefix);
770     }
771
772     /**
773      * @return the transIdRequired
774      */
775     public static Boolean getTransIdRequired() {
776         return transIdRequired;
777     }
778
779
780     /**
781      * @param transIdRequired the transIdRequired to set
782      */
783     public static void setTransIdRequired(Boolean transIdRequired) {
784         MusicUtil.transIdRequired = transIdRequired;
785     }
786
787
788     /**
789      * @return the conversationIdRequired
790      */
791     public static Boolean getConversationIdRequired() {
792         return conversationIdRequired;
793     }
794
795
796     /**
797      * @param conversationIdRequired the conversationIdRequired to set
798      */
799     public static void setConversationIdRequired(Boolean conversationIdRequired) {
800         MusicUtil.conversationIdRequired = conversationIdRequired;
801     }
802
803
804     /**
805      * @return the clientIdRequired
806      */
807     public static Boolean getClientIdRequired() {
808         return clientIdRequired;
809     }
810
811
812     /**
813      * @param clientIdRequired the clientIdRequired to set
814      */
815     public static void setClientIdRequired(Boolean clientIdRequired) {
816         MusicUtil.clientIdRequired = clientIdRequired;
817     }
818
819
820     /**
821      * @return the messageIdRequired
822      */
823     public static Boolean getMessageIdRequired() {
824         return messageIdRequired;
825     }
826
827     /**
828      * @param messageIdRequired the messageIdRequired to set
829      */
830     public static void setMessageIdRequired(Boolean messageIdRequired) {
831         MusicUtil.messageIdRequired = messageIdRequired;
832     }
833
834     /**
835     *  @return the sleep time, in milliseconds, for the lock cleanup daemon
836     */
837     public static long getLockDaemonSleepTimeMs() {
838         return lockDaemonSleepms;
839     }
840     
841     /**
842     * set the sleep time, in milliseconds, for the lock cleanup daemon
843     */
844     public static void setLockDaemonSleepTimeMs(long timeoutms) {
845         MusicUtil.lockDaemonSleepms = timeoutms;
846     }
847
848     public static Set<String> getKeyspacesToCleanLocks() {
849         return keyspacesToCleanLocks;
850     }
851
852     public static void setKeyspacesToCleanLocks(Set<String> keyspaces) {
853         MusicUtil.keyspacesToCleanLocks = keyspaces;
854     }
855
856     public static String getCipherEncKey() {
857         return MusicUtil.cipherEncKey;
858     }
859
860
861     public static void setCipherEncKey(String cipherEncKey) {
862         MusicUtil.cipherEncKey = cipherEncKey;
863         if ( null == cipherEncKey || cipherEncKey.equals("") || 
864                 cipherEncKey.equals("nothing to see here")) {
865             logger.error(EELFLoggerDelegate.errorLogger, "Missing Cipher Encryption Key.");
866         }
867     }
868
869     public static String getMusicAafNs() {
870         return MusicUtil.musicAafNs;
871     }
872
873
874     public static void setMusicAafNs(String musicAafNs) {
875         MusicUtil.musicAafNs = musicAafNs;
876     }
877
878
879
880 }
881