865ca01fa35d934085f8f75506248f325aa35e4c
[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 (List<Object>)valueObj;
520             case BLOB:
521
522             default:
523                 return valueObjString;
524         }
525     }
526
527     public static ByteBuffer convertToActualDataType(DataType colType, byte[] valueObj) {
528         ByteBuffer buffer = ByteBuffer.wrap(valueObj);
529         return buffer;
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         long ts = ordinal * MaxLockReferenceTimePart + (timeOfWrite - MusicEternityEpochMillis);
626
627         return ts;
628     }
629
630     public static MusicCoreService  getMusicCoreService() {
631         if(getLockUsing().equals(MusicUtil.CASSANDRA))
632             return MusicCassaCore.getInstance();
633         else
634             return MusicCassaCore.getInstance();
635     }
636
637     /**
638      * @param lockName
639      * @return
640      */
641     public static Map<String, Object> validateLock(String lockName) {
642         Map<String, Object> resultMap = new HashMap<>();
643         String[] locks = lockName.split("\\.");
644         if(locks.length < 3) {
645             resultMap.put("Error", "Invalid lock. Please make sure lock is of the type keyspaceName.tableName.primaryKey");
646             return resultMap;
647         }
648         String keyspace= locks[0];
649         if(keyspace.startsWith("$"))
650             keyspace = keyspace.substring(1);
651         resultMap.put("keyspace",keyspace);
652         return resultMap;
653     }
654
655
656     public static void setIsCadi(boolean isCadi) {
657         MusicUtil.isCadi = isCadi;
658     }
659
660     public static void writeBackToQuorum(PreparedQueryObject selectQuery, String primaryKeyName,
661             PreparedQueryObject updateQuery, String keyspace, String table,
662             Object cqlFormattedPrimaryKeyValue)
663                     throws Exception {
664         try {
665             ResultSet results = MusicDataStoreHandle.getDSHandle().executeQuorumConsistencyGet(selectQuery);
666             // write it back to a quorum
667             Row row = results.one();
668             ColumnDefinitions colInfo = row.getColumnDefinitions();
669             int totalColumns = colInfo.size();
670             int counter = 1;
671             StringBuilder fieldValueString = new StringBuilder("");
672             for (Definition definition : colInfo) {
673                 String colName = definition.getName();
674                 if (colName.equals(primaryKeyName))
675                     continue;
676                 DataType colType = definition.getType();
677                 Object valueObj = MusicDataStoreHandle.getDSHandle().getColValue(row, colName, colType);
678                 Object valueString = MusicUtil.convertToActualDataType(colType, valueObj);
679                 fieldValueString.append(colName + " = ?");
680                 updateQuery.addValue(valueString);
681                 if (counter != (totalColumns - 1))
682                     fieldValueString.append(",");
683                 counter = counter + 1;
684             }
685             updateQuery.appendQueryString("UPDATE " + keyspace + "." + table + " SET "
686                     + fieldValueString + " WHERE " + primaryKeyName + "= ? " + ";");
687             updateQuery.addValue(cqlFormattedPrimaryKeyValue);
688
689             MusicDataStoreHandle.getDSHandle().executePut(updateQuery, "critical");
690         } catch (MusicServiceException | MusicQueryException e) {
691             logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.QUERYERROR +""+updateQuery ,
692                     ErrorSeverity.MAJOR, ErrorTypes.QUERYERROR, e);
693         }
694     }
695
696     public static boolean getIsCadi() {
697         return MusicUtil.isCadi;
698     }
699
700
701     /**
702      * @return a random uuid
703      */
704     public static String generateUUID() {
705         String uuid = UUID.randomUUID().toString();
706         logger.info(EELFLoggerDelegate.applicationLogger,"New AID generated: "+uuid);
707         return uuid;
708     }
709
710     private static String checkPrefix(String prefix){
711         if (prefix == null || "".equals(prefix) || prefix.endsWith("-")) {
712             return prefix;
713         } else {
714             return prefix + "-";
715         }
716     }
717
718     /**
719      * @return the transIdPrefix
720      */
721     public static String getTransIdPrefix() {
722         return transIdPrefix;
723     }
724
725     /**
726      * @param transIdPrefix the transIdPrefix to set
727      */
728     public static void setTransIdPrefix(String transIdPrefix) {
729         MusicUtil.transIdPrefix = checkPrefix(transIdPrefix);
730     }
731
732     /**
733      * @return the conversationIdPrefix
734      */
735     public static String getConversationIdPrefix() {
736         return conversationIdPrefix;
737     }
738
739     /**
740      * @param conversationIdPrefix the conversationIdPrefix to set
741      */
742     public static void setConversationIdPrefix(String conversationIdPrefix) {
743         MusicUtil.conversationIdPrefix = checkPrefix(conversationIdPrefix);
744     }
745
746     /**
747      * @return the clientIdPrefix
748      */
749     public static String getClientIdPrefix() {
750         return clientIdPrefix;
751     }
752
753     /**
754      * @param clientIdPrefix the clientIdPrefix to set
755      */
756     public static void setClientIdPrefix(String clientIdPrefix) {
757         MusicUtil.clientIdPrefix = checkPrefix(clientIdPrefix);
758     }
759
760     /**
761      * @return the messageIdPrefix
762      */
763     public static String getMessageIdPrefix() {
764         return messageIdPrefix;
765     }
766
767     /**
768      * @param messageIdPrefix the messageIdPrefix to set
769      */
770     public static void setMessageIdPrefix(String messageIdPrefix) {
771         MusicUtil.messageIdPrefix = checkPrefix(messageIdPrefix);
772     }
773
774     /**
775      * @return the transIdRequired
776      */
777     public static Boolean getTransIdRequired() {
778         return transIdRequired;
779     }
780
781
782     /**
783      * @param transIdRequired the transIdRequired to set
784      */
785     public static void setTransIdRequired(Boolean transIdRequired) {
786         MusicUtil.transIdRequired = transIdRequired;
787     }
788
789
790     /**
791      * @return the conversationIdRequired
792      */
793     public static Boolean getConversationIdRequired() {
794         return conversationIdRequired;
795     }
796
797
798     /**
799      * @param conversationIdRequired the conversationIdRequired to set
800      */
801     public static void setConversationIdRequired(Boolean conversationIdRequired) {
802         MusicUtil.conversationIdRequired = conversationIdRequired;
803     }
804
805
806     /**
807      * @return the clientIdRequired
808      */
809     public static Boolean getClientIdRequired() {
810         return clientIdRequired;
811     }
812
813
814     /**
815      * @param clientIdRequired the clientIdRequired to set
816      */
817     public static void setClientIdRequired(Boolean clientIdRequired) {
818         MusicUtil.clientIdRequired = clientIdRequired;
819     }
820
821
822     /**
823      * @return the messageIdRequired
824      */
825     public static Boolean getMessageIdRequired() {
826         return messageIdRequired;
827     }
828
829     /**
830      * @param messageIdRequired the messageIdRequired to set
831      */
832     public static void setMessageIdRequired(Boolean messageIdRequired) {
833         MusicUtil.messageIdRequired = messageIdRequired;
834     }
835
836     /**
837     *  @return the sleep time, in milliseconds, for the lock cleanup daemon
838     */
839     public static long getLockDaemonSleepTimeMs() {
840         return lockDaemonSleepms;
841     }
842     
843     /**
844     * set the sleep time, in milliseconds, for the lock cleanup daemon
845     */
846     public static void setLockDaemonSleepTimeMs(long timeoutms) {
847         MusicUtil.lockDaemonSleepms = timeoutms;
848     }
849
850     public static Set<String> getKeyspacesToCleanLocks() {
851         return keyspacesToCleanLocks;
852     }
853
854     public static void setKeyspacesToCleanLocks(Set<String> keyspaces) {
855         MusicUtil.keyspacesToCleanLocks = keyspaces;
856     }
857
858     public static String getCipherEncKey() {
859         return MusicUtil.cipherEncKey;
860     }
861
862
863     public static void setCipherEncKey(String cipherEncKey) {
864         MusicUtil.cipherEncKey = cipherEncKey;
865         if ( null == cipherEncKey || cipherEncKey.equals("") || 
866                 cipherEncKey.equals("nothing to see here")) {
867             logger.error(EELFLoggerDelegate.errorLogger, "Missing Cipher Encryption Key.");
868         }
869     }
870
871     public static String getMusicAafNs() {
872         return MusicUtil.musicAafNs;
873     }
874
875
876     public static void setMusicAafNs(String musicAafNs) {
877         MusicUtil.musicAafNs = musicAafNs;
878     }
879
880
881
882 }
883