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