summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/service/MusicService.java
blob: 0ff3cd2a6d5eb1c8f7da90e6a0a83e05da83022d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
/*
 * ============LICENSE_START==========================================
 * ONAP Portal SDK
 * ===================================================================
 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
 * ===================================================================
 *
 * Unless otherwise specified, all software contained herein is licensed
 * under the Apache License, Version 2.0 (the "License");
 * you may not use this software except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *             http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Unless otherwise specified, all documentation contained herein is licensed
 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 * you may not use this documentation except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *             https://creativecommons.org/licenses/by/4.0/
 *
 * Unless required by applicable law or agreed to in writing, documentation
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * ============LICENSE_END============================================
 *
 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
 */

package org.onap.portalapp.music.service;

import java.util.HashMap;
import java.util.Map;

import org.onap.music.datastore.PreparedQueryObject;
import org.onap.music.eelf.logging.EELFLoggerDelegate;
import org.onap.music.exceptions.MusicLockingException;
import org.onap.music.exceptions.MusicServiceException;
import org.onap.music.main.MusicCore;
import org.onap.music.main.ReturnType;
import org.onap.portalapp.music.conf.MusicSession;
import org.onap.portalapp.music.model.RestResponse;
import org.onap.portalapp.music.model.RestStatusEnum;
import org.onap.portalapp.music.util.MusicProperties;
import org.onap.portalapp.music.util.MusicUtil;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.session.Session;
import org.springframework.web.client.RestTemplate;

import com.datastax.driver.core.ResultSet;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class MusicService {
	static RestTemplate template = new RestTemplate();
	private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicService.class);

	private static boolean isAtomicPut = MusicUtil.isAtomicPut();
	private static boolean isAtomicGet = MusicUtil.isAtomicGet();
	private static String musicKeySpace = MusicProperties.getProperty(MusicProperties.MUSIC_SESSION_KEYSPACE);
	private static String musicMetaTable = MusicProperties.getProperty(MusicProperties.MUSIC_SESSION_META_TABLES);
	private static String musicAttrTable = MusicProperties.getProperty(MusicProperties.MUSIC_SESSION_ATTR_TABLES);

	/**
	 * Store session attribute name and values into Cassandra via Music
	 * 
	 * @param attributeName
	 * @param value
	 * @param sessionId
	 * @return ReturnType that includes required body information for Music api
	 * @throws Exception
	 */
	public static ReturnType setAttribute(String attributeName, Object value, String sessionId) throws Exception {
		logger.debug(EELFLoggerDelegate.debugLogger, "setAttribute: start with id " + sessionId);
		String tableName = null;
		ReturnType result = null;
		boolean isMeta = MusicUtil.isSessionMetaAttr(attributeName);
		PreparedQueryObject queryObject = new PreparedQueryObject();
		StringBuilder querySB = new StringBuilder();
		querySB.append("INSERT INTO ").append(musicKeySpace).append(".").append(getTableName(isMeta))
				.append(getInsertQuery(isMeta, attributeName));

		queryObject.appendQueryString(querySB.toString());
		if (isMeta) {
			queryObject.addValue(sessionId);
			queryObject.addValue(String.valueOf(value));
			tableName = musicMetaTable;
		} else {
			queryObject.addValue(sessionId);
			queryObject.addValue(attributeName);
			queryObject.addValue(MusicUtil.musicSerialize(value));
			tableName = musicAttrTable;

		}
		if (isAtomicPut)
			result = MusicCore.atomicPut(musicKeySpace, tableName, sessionId, queryObject, null);
		else
			result = MusicCore.eventualPut(queryObject);
		logger.debug(EELFLoggerDelegate.debugLogger, "setAttribute: attributeName: " + attributeName
				+ " with session id: " + sessionId + "result:" + result.getMessage());
		return result;
	}

	/**
	 * Store session meta data values into Cassandra via Music
	 * 
	 * @param session
	 * @return ReturnType that includes required body information for Music api
	 * @throws Exception
	 */
	public static ReturnType setMetaAttribute(Session session) throws Exception {
		logger.debug(EELFLoggerDelegate.debugLogger, "setMetaAttribute: start with session id: " + session.getId());
		ReturnType result = null;
		PreparedQueryObject queryObject = new PreparedQueryObject();
		StringBuilder querySB = new StringBuilder();
		querySB.append("INSERT INTO ").append(musicKeySpace).append(".").append(musicMetaTable).append("(")
				.append(MusicProperties.PRIMARY_ID).append(",").append(MusicProperties.CREATION_TIME).append(",")
				.append(MusicProperties.LAST_ACCESS_TIME).append(",").append(MusicProperties.MAX_INACTIVE_INTERVAL)
				.append(",").append(MusicProperties.SESSION_ID).append(") VALUES (?,?,?,?,?);");

		queryObject.appendQueryString(querySB.toString());
		queryObject.addValue(session.getId());
		queryObject.addValue(String.valueOf(session.getCreationTime()));
		queryObject.addValue(String.valueOf(session.getLastAccessedTime()));
		queryObject.addValue(String.valueOf(session.getMaxInactiveInterval()));
		queryObject.addValue(session.getId());
		if (isAtomicPut)
			result = MusicCore.atomicPut(musicKeySpace, musicMetaTable, session.getId(), queryObject, null);
		else
			result = MusicCore.eventualPut(queryObject);
		logger.debug(EELFLoggerDelegate.debugLogger,
				"setMetaAttribute: with session id: " + session + "result:" + result.getMessage());

		return result;
	}

	/**
	 * Retrieve session meta data from Cassandra via Music
	 * 
	 * @param sessionId
	 * @return MusicSession
	 * @throws Exception
	 */
	public static MusicSession getMetaAttribute(String sessionId) throws Exception {
		logger.debug(EELFLoggerDelegate.debugLogger, "getMetaAttribute: start with session Id: "+ sessionId);
		ResultSet result = null;
		PreparedQueryObject queryObject = new PreparedQueryObject();
		StringBuilder querySB = new StringBuilder();
		querySB.append("SELECT * FROM ").append(musicKeySpace).append(".").append(musicMetaTable).append(" WHERE ")
				.append(MusicProperties.PRIMARY_ID).append("=?;");
		queryObject.appendQueryString(querySB.toString());
		queryObject.addValue(sessionId);
		if (isAtomicGet)
			result = MusicCore.atomicGet(musicKeySpace, musicMetaTable, sessionId, queryObject);
		else
			result = MusicCore.get(queryObject);
		logger.debug(EELFLoggerDelegate.debugLogger, "getMetaAttribute: with session id: " + sessionId);
		return MusicUtil.parseMetaData(result.one());
	}

	/**
	 * Get proper column names (from meta or attribute table) base on isMeta
	 * 
	 * @param isMeta
	 * @param attributeName
	 * @return String
	 */
	private static String getInsertQuery(boolean isMeta, String attributeName) {
		logger.debug(EELFLoggerDelegate.debugLogger, "getInsertQuery: start inserting : " + attributeName);
		StringBuilder querySB = new StringBuilder();
		if (isMeta) {
			querySB.append(" (").append(MusicProperties.PRIMARY_ID).append(",").append(attributeName)
					.append(") VALUES (?,?);");
		} else {
			querySB.append(" (").append(MusicProperties.PRIMARY_ID).append(",").append(MusicProperties.ATTRIBUTE_NAME)
					.append(",").append(MusicProperties.ATTRIBUTE_BYTES).append(") VALUES (?,?,?);");
		}
		return querySB.toString();
	}

	/**
	 * Retrieve session attribute data from Cassandra via Music
	 * 
	 * @param attributeName
	 * @param sessionId
	 * @return attribute value with T type
	 * @throws Exception
	 */
	public static <T> T getAttribute(String attributeName, String sessionId) throws Exception {
		logger.debug(EELFLoggerDelegate.debugLogger, "getAttribute: start with session id: " + sessionId);
		ResultSet result = null;
		String tableName = null;
		boolean isMeta = MusicUtil.isSessionMetaAttr(attributeName);
		PreparedQueryObject queryObject = new PreparedQueryObject();
		StringBuilder querySB = new StringBuilder();
		querySB.append("SELECT ").append(getColumn(attributeName, isMeta)).append(" FROM ").append(musicKeySpace)
				.append(".").append(getTableName(isMeta)).append(" WHERE ").append(MusicProperties.PRIMARY_ID)
				.append("= ?");

		queryObject.addValue(sessionId);
		if (!isMeta) {
			querySB.append(" and ").append(MusicProperties.ATTRIBUTE_NAME).append("= ?");
			queryObject.addValue(attributeName);
			tableName = musicAttrTable;
		} else
			tableName = musicMetaTable;

		queryObject.appendQueryString(querySB.toString());
		if (isAtomicGet)
			result = MusicCore.atomicGet(musicKeySpace, tableName, sessionId, queryObject);
		else
			result = MusicCore.get(queryObject);
		return MusicUtil.musicRestResponseDataParsing(result, attributeName);

	}

	/**
	 * Remove session attribute data from Cassandra via Music
	 * 
	 * @param attributeName
	 * @param sessionId
	 * @return ReturnType
	 * @throws MusicServiceException
	 * @throws MusicLockingException 
	 */
	public static ReturnType removeAttribute(String attributeName, String sessionId) throws MusicServiceException, MusicLockingException {
		logger.debug(EELFLoggerDelegate.debugLogger, "removeAttribute: start with session id: " + sessionId);
		boolean isMeta = MusicUtil.isSessionMetaAttr(attributeName);
		ReturnType result = null;
		String tableName = null;
		PreparedQueryObject queryObject = new PreparedQueryObject();
		StringBuilder querySB = new StringBuilder();
		querySB.append("DELETE ").append(getDelColumn(isMeta, attributeName)).append(" FROM ").append(musicKeySpace)
				.append(".").append(getTableName(isMeta)).append(" WHERE ").append(MusicProperties.PRIMARY_ID)
				.append("= ? ");
		queryObject.addValue(sessionId);

		if (!isMeta) {
			querySB.append(" and ").append(MusicProperties.ATTRIBUTE_NAME).append("= ?");
			queryObject.addValue(attributeName);
			tableName = musicAttrTable;
		} else
			tableName = musicMetaTable;
		queryObject.appendQueryString(querySB.toString());
		if (isAtomicPut)
			result = MusicCore.atomicPut(musicKeySpace, tableName, sessionId, queryObject, null);
		else
			result = MusicCore.eventualPut(queryObject);
		logger.debug(EELFLoggerDelegate.debugLogger,
				"removeSession: " + attributeName + " with session id: " + sessionId + "result:" + result.getMessage());

		return result;
	}

	/**
	 * Remove entire session from Cassandra via Music
	 * 
	 * @param sessionId
	 * @return ReturnType
	 * @throws MusicServiceException
	 * @throws MusicLockingException 
	 */
	public static ReturnType removeSession(String sessionId) throws MusicServiceException, MusicLockingException {
		ReturnType result = null;
		boolean isAtomic = isAtomicPut;
		logger.debug(EELFLoggerDelegate.debugLogger, "removeSession: start with session id: " + sessionId);
		PreparedQueryObject queryObject = new PreparedQueryObject();
		StringBuilder querySB = new StringBuilder();
		querySB.append("DELETE ").append(" FROM ").append(musicKeySpace).append(".").append(musicMetaTable)
				.append(" WHERE ").append(MusicProperties.PRIMARY_ID).append("= ? ");
		queryObject.appendQueryString(querySB.toString());
		queryObject.addValue(sessionId);
		if (isAtomic)
			result = MusicCore.atomicPut(musicKeySpace, musicMetaTable, sessionId, queryObject, null);
		else
			result = MusicCore.eventualPut(queryObject);
		logger.debug(EELFLoggerDelegate.debugLogger, "removeSession: " + musicMetaTable + " with session id: "
				+ sessionId + "result:" + result.getMessage());

		queryObject = new PreparedQueryObject();
		querySB = new StringBuilder();
		querySB.append("DELETE ").append(" FROM ").append(musicKeySpace).append(".").append(musicAttrTable)
				.append(" WHERE ").append(MusicProperties.PRIMARY_ID).append("= ? ");
		queryObject.appendQueryString(querySB.toString());
		queryObject.addValue(sessionId);
		if (isAtomic)
			result = MusicCore.atomicPut(musicKeySpace, musicAttrTable, sessionId, queryObject, null);
		else
			result = MusicCore.eventualPut(queryObject);

		logger.debug(EELFLoggerDelegate.debugLogger, "removeSession: " + musicAttrTable + " with session id: "
				+ sessionId + "result:" + result.getMessage());

		return result;
	}

	/**
	 * Get proper table name (Meta or Attribute) base on isMeta.
	 * 
	 * @param isMeta
	 * @return String
	 */
	private static String getTableName(boolean isMeta) {
		StringBuilder querySB = new StringBuilder();
		if (isMeta)
			querySB.append(musicMetaTable);
		else
			querySB.append(musicAttrTable);
		return querySB.toString();
	}

	/**
	 * Get proper column name (Meta or Attribute) base on isMeta.
	 * 
	 * @param attributeName
	 * @param isMeta
	 * @return String
	 */
	private static String getColumn(String attributeName, boolean isMeta) {
		StringBuilder querySB = new StringBuilder();
		if (isMeta)
			querySB.append(attributeName);
		else
			querySB.append("attribute_bytes");
		return querySB.toString();
	}

	/**
	 * Get proper column name (Meta or Attribute) base on isMeta for removing.
	 * 
	 * @param attributeName
	 * @param isMeta
	 * @return String
	 */
	private static String getDelColumn(boolean isMeta, String attributeName) {
		StringBuilder querySB = new StringBuilder();
		if (isMeta)
			querySB.append(attributeName);
		return querySB.toString();
	}

	/**
	 * To set session attributes in Music
	 * 
	 * @param attributeName
	 * @param value
	 * @param session
	 * @param sessionId
	 * @param isMeta
	 * @return RestResponse<String>
	 * @throws JsonProcessingException
	 */

	public static RestResponse<String> setAttributeAPI(String attributeName, Object value, Session session,
			String sessionId, String className, boolean isMeta) throws JsonProcessingException {
		System.out.println("setAttribute: " + attributeName);
		RestResponse<String> portalRestResponse = null;
		HttpEntity<Map<String, Object>> entity = new HttpEntity<Map<String, Object>>(
				getMusicRestBody(attributeName, value, sessionId, session, className, isMeta), getMusicHeader());
		String url = getInsertUrl(isMeta);
		ResponseEntity<String> response = null;
		try {
			response = template.exchange(url, HttpMethod.POST, entity, String.class);
			portalRestResponse = new RestResponse<String>(RestStatusEnum.OK, "success", response.getBody());
		} catch (Exception e) {
			portalRestResponse = new RestResponse<String>(RestStatusEnum.ERROR, e.getMessage(), null);
		}
		return portalRestResponse;
	}

	/**
	 * To get session attribute in Music
	 * 
	 * @param attributeName
	 * @param value
	 * @param sessionId
	 * @param isMeta
	 * @return RestResponse<String>
	 */

	public static RestResponse<String> getAttributeAPI(String attributeName, Object value, String sessionId,
			boolean isMeta) {
		System.out.println("getAttribute: " + attributeName);
		RestResponse<String> portalRestResponse = null;
		HttpEntity<String> entity = new HttpEntity<String>(null, getMusicHeader());
		ResponseEntity<String> response = null;
		String url = getSelectSessionIdUrl(attributeName, sessionId, isMeta);
		try {
			response = template.exchange(url, HttpMethod.GET, entity, String.class);
			portalRestResponse = new RestResponse<String>(RestStatusEnum.OK, "success", response.getBody());
		} catch (Exception e) {
			portalRestResponse = new RestResponse<String>(RestStatusEnum.ERROR, e.getMessage(), null);
		}
		return portalRestResponse;
	}

	/**
	 * To remove session attribute or session meta in Music
	 * 
	 * @param attributeName
	 * @param value
	 * @param sessionId
	 * @param isMeta
	 * @return RestResponse<String>
	 */
	public static RestResponse<String> removeAttributeAPI(String attributeName, String sessionId, boolean isMeta) {
		RestResponse<String> portalRestResponse = null;
		HttpEntity<Map<String, Object>> entity = new HttpEntity<>(getMusicDelRestBody(null), getMusicHeader());
		ResponseEntity<String> response = null;
		String url = getSelectSessionIdUrl(attributeName, sessionId, true);
		try {
			response = template.exchange(url, HttpMethod.DELETE, entity, String.class);
			portalRestResponse = new RestResponse<String>(RestStatusEnum.OK, "success", response.getBody());
			url = getSelectSessionIdUrl(attributeName, sessionId, false);
			response = template.exchange(url, HttpMethod.DELETE, entity, String.class);
			portalRestResponse = new RestResponse<String>(RestStatusEnum.OK, "success", response.getBody());
		} catch (Exception e) {
			portalRestResponse = new RestResponse<String>(RestStatusEnum.ERROR, e.getMessage(), null);
		}
		return portalRestResponse;
	}

	/**
	 * Generate body for Music api calls
	 * 
	 * @return String that includes required body information for Music api
	 *         calls
	 * @throws JsonProcessingException
	 */
	public static Map<String, Object> getMusicRestBody(String attributeName, Object value, String sessionId,
			Session session, String className, boolean isMeta) throws JsonProcessingException {
		Map<String, Object> map = new HashMap<>();
		/* Set up column values */
		Map<String, Object> valueMap = new HashMap<>();
		if (isMeta) {
			valueMap.put(MusicProperties.PRIMARY_ID, session.getId());
			valueMap.put(MusicProperties.SESSION_ID, session.getId());
			valueMap.put(MusicProperties.CREATION_TIME, session.getCreationTime().toString());
			valueMap.put(MusicProperties.LAST_ACCESS_TIME, session.getLastAccessedTime().toString());
			valueMap.put(MusicProperties.MAX_INACTIVE_INTERVAL, session.getMaxInactiveInterval().toString());
		} else {
			ObjectMapper mapper = new ObjectMapper();
			valueMap.put(MusicProperties.PRIMARY_ID, sessionId);
			valueMap.put(MusicProperties.ATTRIBUTE_NAME, attributeName);
			valueMap.put(MusicProperties.ATTRIBUTE_BYTES, mapper.writeValueAsString(value));
			valueMap.put(MusicProperties.ATTRIBUTE_CLASS, className);
		}
		map.put("values", valueMap);
		/* Set up consistency setting */
		Map<String, String> consistencyInfoMap = new HashMap<>();
		consistencyInfoMap.put(MusicProperties.getProperty(MusicProperties.MUSIC_CONSISTENCYINFO),
				MusicProperties.getProperty(MusicProperties.MUSIC_CONSISTENCYINFO_VALUE));
		map.put("consistencyInfo", consistencyInfoMap);
		return map;
	}

	/**
	 * Generate body for Music delete api calls
	 * 
	 * @return String that includes required body information for Music api
	 *         calls
	 * @throws JsonProcessingException
	 */
	public static Map<String, Object> getMusicDelRestBody(String attribute_name) {
		Map<String, Object> map = new HashMap<>();
		Map<String, String> consistencyInfoMap = new HashMap<>();
		consistencyInfoMap.put(MusicProperties.getProperty(MusicProperties.MUSIC_CONSISTENCYINFO),
				MusicProperties.getProperty(MusicProperties.MUSIC_CONSISTENCYINFO_VALUE));
		if (attribute_name != null && !attribute_name.equals("")) {
			Map<String, String> conditionsMap = new HashMap<>();
			conditionsMap.put("attribute_name", attribute_name);
			map.put("conditions", conditionsMap);
		}
		map.put("consistencyInfo", consistencyInfoMap);
		return map;
	}

	private static String getSelectSessionIdUrl(String attributeName, String sessionId, boolean isMeta) {
		String path = constructPath(isMeta);
		StringBuilder attriPath = new StringBuilder();
		attriPath.append(path).append(MusicProperties.getProperty(MusicProperties.MUSIC_ROWS)).append("?")
				.append(MusicProperties.PRIMARY_ID).append("=").append(sessionId);
		return attriPath.toString();
	}

	private static String getInsertUrl(boolean isMeta) {
		String path = constructPath(isMeta);
		StringBuilder attriPath = new StringBuilder();
		attriPath.append(path);
		attriPath.append(MusicProperties.getProperty(MusicProperties.MUSIC_ROWS));
		return attriPath.toString();
	}

	/**
	 * Generate header for Music api calls
	 * 
	 * @return header that contains required header information for Music api
	 *         calls
	 */
	private static HttpHeaders getMusicHeader() {
		HttpHeaders headers = new HttpHeaders();
		headers.setContentType(MediaType.APPLICATION_JSON);
		headers.add("X-minorVersion", MusicProperties.getProperty(MusicProperties.MUSIC_X_MINOR_VERSION));
		headers.add("X-patchVersion", MusicProperties.getProperty(MusicProperties.MUSIC_X_PATCH_VERSION));
		headers.add("ns", MusicProperties.getProperty(MusicProperties.MUSIC_NS));
		headers.add("userId", MusicProperties.getProperty(MusicProperties.MUSIC_USER_ID));
		headers.add("password", MusicProperties.getProperty(MusicProperties.MUSIC_PASSWORD));
		return headers;
	}

	/**
	 * Construct URL for Music api calls
	 * 
	 * @return path
	 */
	private static String constructPath(boolean isMeta) {
		StringBuilder path = new StringBuilder();
		path.append(MusicProperties.getProperty(MusicProperties.MUSIC_ENDPOINT))
				.append(MusicProperties.getProperty(MusicProperties.MUSIC_VERSION)).append("/")
				.append(MusicProperties.getProperty(MusicProperties.MUSIC_KEYSPACE)).append("/").append(musicKeySpace)
				.append("/").append(MusicProperties.getProperty(MusicProperties.MUSIC_TABLES)).append("/");
		if (isMeta)
			path.append(musicMetaTable);
		else
			path.append(musicAttrTable);
		path.append("/");
		return path.toString();
	}

}