aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/onap/music/datastore/MusicDataStore.java70
-rw-r--r--src/main/java/org/onap/music/datastore/jsonobjects/AAFResponse.java13
-rwxr-xr-xsrc/main/java/org/onap/music/datastore/jsonobjects/JSONCallbackResponse.java24
-rw-r--r--src/main/java/org/onap/music/datastore/jsonobjects/JsonInsert.java19
-rwxr-xr-xsrc/main/java/org/onap/music/datastore/jsonobjects/JsonNotification.java8
-rw-r--r--src/main/java/org/onap/music/datastore/jsonobjects/JsonSelect.java2
-rw-r--r--src/main/java/org/onap/music/datastore/jsonobjects/JsonUpdate.java17
-rw-r--r--src/main/java/org/onap/music/eelf/logging/EELFLoggerDelegate.java33
-rw-r--r--src/main/java/org/onap/music/exceptions/MusicPolicyVoilationException.java14
-rw-r--r--src/main/java/org/onap/music/exceptions/MusicServiceException.java33
-rw-r--r--src/main/java/org/onap/music/lockingservice/MusicLockingService.java3
-rw-r--r--src/main/java/org/onap/music/main/MusicCore.java6
-rwxr-xr-xsrc/main/java/org/onap/music/main/PropertiesListener.java9
-rwxr-xr-xsrc/main/java/org/onap/music/rest/RestMusicAdminAPI.java4
14 files changed, 164 insertions, 91 deletions
diff --git a/src/main/java/org/onap/music/datastore/MusicDataStore.java b/src/main/java/org/onap/music/datastore/MusicDataStore.java
index 9e3a4bf8..c6b022cc 100644
--- a/src/main/java/org/onap/music/datastore/MusicDataStore.java
+++ b/src/main/java/org/onap/music/datastore/MusicDataStore.java
@@ -70,33 +70,10 @@ public class MusicDataStore {
- /**
- * @param session
- */
- public void setSession(Session session) {
- this.session = session;
- }
-
- /**
- * @param session
- */
- public Session getSession() {
- return session;
- }
-
- /**
- * @param cluster
- */
- public void setCluster(Cluster cluster) {
- this.cluster = cluster;
- }
-
-
-
private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicDataStore.class);
/**
- *
+ *
*/
public MusicDataStore() {
connectToCassaCluster();
@@ -113,7 +90,7 @@ public class MusicDataStore {
}
/**
- *
+ *
* @param remoteIp
* @throws MusicServiceException
*/
@@ -121,10 +98,34 @@ public class MusicDataStore {
try {
connectToCassaCluster(remoteIp);
} catch (MusicServiceException e) {
+ logger.error("Exception", e);
logger.error(EELFLoggerDelegate.errorLogger, e.getMessage());
}
}
+
+
+ /**
+ * @param session
+ */
+ public void setSession(Session session) {
+ this.session = session;
+ }
+
+ /**
+ * @param session
+ */
+ public Session getSession() {
+ return session;
+ }
+
+ /**
+ * @param cluster
+ */
+ public void setCluster(Cluster cluster) {
+ this.cluster = cluster;
+ }
+
/**
*
* @return
@@ -134,16 +135,18 @@ public class MusicDataStore {
try {
Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces();
while (en.hasMoreElements()) {
- NetworkInterface ni = (NetworkInterface) en.nextElement();
+ NetworkInterface ni = en.nextElement();
Enumeration<InetAddress> ee = ni.getInetAddresses();
while (ee.hasMoreElements()) {
- InetAddress ia = (InetAddress) ee.nextElement();
+ InetAddress ia = ee.nextElement();
allPossibleIps.add(ia.getHostAddress());
}
}
} catch (SocketException e) {
+ logger.error("Exception", e);
logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), AppMessages.CONNCECTIVITYERROR, ErrorSeverity.ERROR, ErrorTypes.CONNECTIONERROR);
}catch(Exception e) {
+ logger.error("Exception", e);
logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), ErrorSeverity.ERROR, ErrorTypes.GENERALSERVICEERROR);
}
return allPossibleIps;
@@ -190,6 +193,7 @@ public class MusicDataStore {
break;
} catch (NoHostAvailableException e) {
+ logger.error("Exception", e);
address = it.next();
logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.HOSTUNAVAILABLE, ErrorSeverity.ERROR, ErrorTypes.CONNECTIONERROR);
}
@@ -236,6 +240,7 @@ public class MusicDataStore {
try {
session = cluster.connect();
} catch (Exception ex) {
+ logger.error("Exception", ex);
logger.error(EELFLoggerDelegate.errorLogger, ex.getMessage(),AppMessages.CASSANDRACONNECTIVITY, ErrorSeverity.ERROR, ErrorTypes.SERVICEUNAVAILABLE);
throw new MusicServiceException(
"Error while connecting to Cassandra cluster.. " + ex.getMessage());
@@ -306,8 +311,7 @@ public class MusicDataStore {
public byte[] getBlobValue(Row row, String colName, DataType colType) {
ByteBuffer bb = row.getBytes(colName);
- byte[] data = bb.array();
- return data;
+ return bb.array();
}
public boolean doesRowSatisfyCondition(Row row, Map<String, Object> condition) throws Exception {
@@ -338,7 +342,7 @@ public class MusicDataStore {
ColumnDefinitions colInfo = row.getColumnDefinitions();
HashMap<String, Object> resultOutput = new HashMap<>();
for (Definition definition : colInfo) {
- if (!definition.getName().equals("vector_ts")) {
+ if (!(("vector_ts").equals(definition.getName()))) {
if(definition.getType().toString().toLowerCase().contains("blob")) {
resultOutput.put(definition.getName(),
getBlobValue(row, definition.getName(), definition.getType()));
@@ -386,9 +390,11 @@ public class MusicDataStore {
preparedInsert = session.prepare(queryObject.getQuery());
} catch(InvalidQueryException iqe) {
+ logger.error("Exception", iqe);
logger.error(EELFLoggerDelegate.errorLogger, iqe.getMessage(),AppMessages.QUERYERROR, ErrorSeverity.CRITICAL, ErrorTypes.QUERYERROR);
throw new MusicQueryException(iqe.getMessage());
}catch(Exception e) {
+ logger.error("Exception", e);
logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.QUERYERROR, ErrorSeverity.CRITICAL, ErrorTypes.QUERYERROR);
throw new MusicQueryException(e.getMessage());
}
@@ -407,10 +413,12 @@ public class MusicDataStore {
}
catch (AlreadyExistsException ae) {
+ logger.error("Exception", ae);
logger.error(EELFLoggerDelegate.errorLogger, ae.getMessage(),AppMessages.SESSIONFAILED+ " [" + queryObject.getQuery() + "]", ErrorSeverity.ERROR, ErrorTypes.QUERYERROR);
throw new MusicServiceException(ae.getMessage());
}
catch (Exception e) {
+ logger.error("Exception", e);
logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.SESSIONFAILED+ " [" + queryObject.getQuery() + "]", ErrorSeverity.ERROR, ErrorTypes.QUERYERROR);
throw new MusicQueryException("Executing Session Failure for Request = " + "["
+ queryObject.getQuery() + "]" + " Reason = " + e.getMessage());
@@ -446,6 +454,7 @@ public class MusicDataStore {
results = session.execute(preparedEventualGet.bind(queryObject.getValues().toArray()));
} catch (Exception ex) {
+ logger.error("Exception", ex);
logger.error(EELFLoggerDelegate.errorLogger, ex.getMessage(),AppMessages.UNKNOWNERROR+ "[" + queryObject.getQuery() + "]", ErrorSeverity.ERROR, ErrorTypes.QUERYERROR);
throw new MusicServiceException(ex.getMessage());
}
@@ -476,6 +485,7 @@ public class MusicDataStore {
try {
results = session.execute(preparedEventualGet.bind(queryObject.getValues().toArray()));
} catch (Exception ex) {
+ logger.error("Exception", ex);
logger.error(EELFLoggerDelegate.errorLogger, ex.getMessage(),AppMessages.UNKNOWNERROR+ "[" + queryObject.getQuery() + "]", ErrorSeverity.ERROR, ErrorTypes.QUERYERROR);
throw new MusicServiceException(ex.getMessage());
}
diff --git a/src/main/java/org/onap/music/datastore/jsonobjects/AAFResponse.java b/src/main/java/org/onap/music/datastore/jsonobjects/AAFResponse.java
index df6089ee..b0f41311 100644
--- a/src/main/java/org/onap/music/datastore/jsonobjects/AAFResponse.java
+++ b/src/main/java/org/onap/music/datastore/jsonobjects/AAFResponse.java
@@ -2,7 +2,9 @@
* ============LICENSE_START==========================================
* org.onap.music
* ===================================================================
- * Copyright (c) 2017 AT&T Intellectual Property
+ * Copyright (c) 2017 AT&T Intellectual Property
+ * ===================================================================
+ * Modifications Copyright (c) 2018 IBM
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,21 +23,22 @@
*/
package org.onap.music.datastore.jsonobjects;
-import java.util.ArrayList;
+import java.util.List;
+
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ApiModel(value = "JsonTable", description = "Reponse class for AAF request")
public class AAFResponse {
- private ArrayList<NameSpace> ns = null;
+ private List<NameSpace> ns = null;
@ApiModelProperty(value = "Namespace value")
- public ArrayList<NameSpace> getNs() {
+ public List<NameSpace> getNs() {
return ns;
}
- public void setNs(ArrayList<NameSpace> ns) {
+ public void setNs(List<NameSpace> ns) {
this.ns = ns;
}
diff --git a/src/main/java/org/onap/music/datastore/jsonobjects/JSONCallbackResponse.java b/src/main/java/org/onap/music/datastore/jsonobjects/JSONCallbackResponse.java
index f869c342..c5a56a71 100755
--- a/src/main/java/org/onap/music/datastore/jsonobjects/JSONCallbackResponse.java
+++ b/src/main/java/org/onap/music/datastore/jsonobjects/JSONCallbackResponse.java
@@ -27,20 +27,20 @@ import java.util.Map;
public class JSONCallbackResponse {
- private String full_table;
+ private String fullTable;
private String keyspace;
private Map<String, String> changeValue;
private String operation;
- private String table_name;
- private String primary_key;
+ private String tableName;
+ private String primaryKey;
private Object miscObjects;
private List<String> updateList;
public String getFull_table() {
- return full_table;
+ return fullTable;
}
- public void setFull_table(String full_table) {
- this.full_table = full_table;
+ public void setFull_table(String fullTable) {
+ this.fullTable = fullTable;
}
public String getKeyspace() {
return keyspace;
@@ -55,16 +55,16 @@ public class JSONCallbackResponse {
this.operation = operation;
}
public String getTable_name() {
- return table_name;
+ return tableName;
}
- public void setTable_name(String table_name) {
- this.table_name = table_name;
+ public void setTable_name(String tableName) {
+ this.tableName = tableName;
}
public String getPrimary_key() {
- return primary_key;
+ return primaryKey;
}
- public void setPrimary_key(String primary_key) {
- this.primary_key = primary_key;
+ public void setPrimary_key(String primaryKey) {
+ this.primaryKey = primaryKey;
}
public Object getMiscObjects() {
return miscObjects;
diff --git a/src/main/java/org/onap/music/datastore/jsonobjects/JsonInsert.java b/src/main/java/org/onap/music/datastore/jsonobjects/JsonInsert.java
index c79ba9b7..456fb951 100644
--- a/src/main/java/org/onap/music/datastore/jsonobjects/JsonInsert.java
+++ b/src/main/java/org/onap/music/datastore/jsonobjects/JsonInsert.java
@@ -3,6 +3,7 @@
* org.onap.music
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
+ * Modifications Copyright (C) 2018 IBM.
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +34,11 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
+import org.onap.music.eelf.logging.EELFLoggerDelegate;
+import org.onap.music.eelf.logging.format.AppMessages;
+import org.onap.music.eelf.logging.format.ErrorSeverity;
+import org.onap.music.eelf.logging.format.ErrorTypes;
+
@ApiModel(value = "JsonTable", description = "Json model for table vlaues insert")
@JsonIgnoreProperties(ignoreUnknown = true)
public class JsonInsert implements Serializable {
@@ -41,10 +47,11 @@ public class JsonInsert implements Serializable {
private transient Map<String, Object> values;
private String ttl;
private String timestamp;
- private transient Map<String, Object> row_specification;
+ private transient Map<String, Object> rowSpecification;
private Map<String, String> consistencyInfo;
private Map<String, byte[]> objectMap;
-
+ private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(JsonInsert.class);
+
@ApiModelProperty(value = "objectMap")
public Map<String, byte[]> getObjectMap() {
return objectMap;
@@ -110,11 +117,11 @@ public class JsonInsert implements Serializable {
@ApiModelProperty(value = "Information for selecting specific rows for insert")
public Map<String, Object> getRow_specification() {
- return row_specification;
+ return rowSpecification;
}
- public void setRow_specification(Map<String, Object> row_specification) {
- this.row_specification = row_specification;
+ public void setRow_specification(Map<String, Object> rowSpecification) {
+ this.rowSpecification = rowSpecification;
}
public byte[] serialize() {
@@ -124,7 +131,7 @@ public class JsonInsert implements Serializable {
out = new ObjectOutputStream(bos);
out.writeObject(this);
} catch (IOException e) {
- e.printStackTrace();
+ logger.error(EELFLoggerDelegate.errorLogger, e, AppMessages.IOERROR, ErrorSeverity.ERROR, ErrorTypes.DATAERROR);
}
return bos.toByteArray();
}
diff --git a/src/main/java/org/onap/music/datastore/jsonobjects/JsonNotification.java b/src/main/java/org/onap/music/datastore/jsonobjects/JsonNotification.java
index ce244e2c..5190de58 100755
--- a/src/main/java/org/onap/music/datastore/jsonobjects/JsonNotification.java
+++ b/src/main/java/org/onap/music/datastore/jsonobjects/JsonNotification.java
@@ -3,6 +3,7 @@
* org.onap.music
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
+ * Modifications Copyright (C) 2018 IBM.
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +29,11 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import org.onap.music.eelf.logging.EELFLoggerDelegate;
+import org.onap.music.eelf.logging.format.AppMessages;
+import org.onap.music.eelf.logging.format.ErrorSeverity;
+import org.onap.music.eelf.logging.format.ErrorTypes;
+
import io.swagger.annotations.ApiModel;
@ApiModel(value = "JsonNotification", description = "Json model for callback")
@@ -45,6 +51,7 @@ public class JsonNotification implements Serializable {
private String operation_type;
private String triggerName;
private Map<String, String> response_body;
+ private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(JsonNotification.class);
public String getNotify_field() {
return notify_field;
@@ -111,6 +118,7 @@ public class JsonNotification implements Serializable {
try {
return new com.fasterxml.jackson.databind.ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this);
} catch (com.fasterxml.jackson.core.JsonProcessingException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, e, AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.GENERALSERVICEERROR);
return notify_field+ " : "+endpoint+ " : "+username+ " : "+password+ " : "+response_body;
}
diff --git a/src/main/java/org/onap/music/datastore/jsonobjects/JsonSelect.java b/src/main/java/org/onap/music/datastore/jsonobjects/JsonSelect.java
index ef56c5de..73237cd2 100644
--- a/src/main/java/org/onap/music/datastore/jsonobjects/JsonSelect.java
+++ b/src/main/java/org/onap/music/datastore/jsonobjects/JsonSelect.java
@@ -3,6 +3,7 @@
* org.onap.music
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
+ * Modifications Copyright (C) 2018 IBM.
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,7 +53,6 @@ public class JsonSelect implements Serializable {
} catch (IOException e) {
// TODO Auto-generated catch block
logger.error("Error", e);
- e.printStackTrace();
}
return bos.toByteArray();
}
diff --git a/src/main/java/org/onap/music/datastore/jsonobjects/JsonUpdate.java b/src/main/java/org/onap/music/datastore/jsonobjects/JsonUpdate.java
index c1a56819..514f34ab 100644
--- a/src/main/java/org/onap/music/datastore/jsonobjects/JsonUpdate.java
+++ b/src/main/java/org/onap/music/datastore/jsonobjects/JsonUpdate.java
@@ -3,6 +3,7 @@
* org.onap.music
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
+ * Modifications Copyright (C) 2018 IBM.
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +34,11 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
+import org.onap.music.eelf.logging.EELFLoggerDelegate;
+import org.onap.music.eelf.logging.format.AppMessages;
+import org.onap.music.eelf.logging.format.ErrorSeverity;
+import org.onap.music.eelf.logging.format.ErrorTypes;
+
@ApiModel(value = "JsonTable", description = "Json model for table update")
@JsonIgnoreProperties(ignoreUnknown = true)
public class JsonUpdate implements Serializable {
@@ -43,7 +49,8 @@ public class JsonUpdate implements Serializable {
private String timestamp;
private Map<String, String> consistencyInfo;
private transient Map<String, Object> conditions;
- private transient Map<String, Object> row_specification;
+ private transient Map<String, Object> rowSpecification;
+ private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(JsonUpdate.class);
@ApiModelProperty(value = "Conditions")
public Map<String, Object> getConditions() {
@@ -56,11 +63,11 @@ public class JsonUpdate implements Serializable {
@ApiModelProperty(value = "Information for selecting sepcific rows")
public Map<String, Object> getRow_specification() {
- return row_specification;
+ return rowSpecification;
}
- public void setRow_specification(Map<String, Object> row_specification) {
- this.row_specification = row_specification;
+ public void setRow_specification(Map<String, Object> rowSpecification) {
+ this.rowSpecification = rowSpecification;
}
@@ -125,7 +132,7 @@ public class JsonUpdate implements Serializable {
out = new ObjectOutputStream(bos);
out.writeObject(this);
} catch (IOException e) {
- e.printStackTrace();
+ logger.error(EELFLoggerDelegate.errorLogger, e,AppMessages.IOERROR, ErrorSeverity.ERROR, ErrorTypes.DATAERROR);
}
return bos.toByteArray();
}
diff --git a/src/main/java/org/onap/music/eelf/logging/EELFLoggerDelegate.java b/src/main/java/org/onap/music/eelf/logging/EELFLoggerDelegate.java
index 0c290b6f..bb28d172 100644
--- a/src/main/java/org/onap/music/eelf/logging/EELFLoggerDelegate.java
+++ b/src/main/java/org/onap/music/eelf/logging/EELFLoggerDelegate.java
@@ -228,10 +228,23 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger {
*
* @param logger
* @param msg
+ *
+ * @deprecated use {@link #error(EELF, Exception)} instead
*/
+ @Deprecated
public void error(EELFLogger logger, String msg) {
logger.error(className+ " - " + msg);
}
+
+ /**
+ * Logs a message at error level.
+ *
+ * @param logger
+ * @param msg
+ */
+ public void error(EELFLogger logger, Exception e) {
+ logger.error(className+ " - ", e);
+ }
/**
* Logs a message with parameters at error level.
@@ -239,9 +252,23 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger {
* @param logger
* @param msg
* @param arguments
+ *
+ * @deprecated use {@link #error(EELF, Exception, Object...)} instead
*/
+ @Deprecated
public void error(EELFLogger logger, String msg, Object... arguments) {
- logger.warn(msg, arguments);
+ logger.error(msg, arguments);
+ }
+
+ /**
+ * Logs a message with parameters at error level.
+ *
+ * @param logger
+ * @param msg
+ * @param arguments
+ */
+ public void error(EELFLogger logger, Exception e, Object... arguments) {
+ logger.error("Exception", e, arguments);
}
/**
@@ -252,7 +279,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger {
* @param th
*/
public void error(EELFLogger logger, String msg, Throwable th) {
- logger.warn(msg, th);
+ logger.error(msg, th);
}
/**
@@ -261,7 +288,9 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger {
* @param logger
* @param msg
* @param severtiy
+ * @deprecated use {@link #error(EELF, Exception)} instead
*/
+ @Deprecated
public void error(EELFLogger logger, String msg, Object /* AlarmSeverityEnum */ severtiy) {
logger.error(msg);
}
diff --git a/src/main/java/org/onap/music/exceptions/MusicPolicyVoilationException.java b/src/main/java/org/onap/music/exceptions/MusicPolicyVoilationException.java
index bade21a4..7de53c59 100644
--- a/src/main/java/org/onap/music/exceptions/MusicPolicyVoilationException.java
+++ b/src/main/java/org/onap/music/exceptions/MusicPolicyVoilationException.java
@@ -2,7 +2,9 @@
* ============LICENSE_START==========================================
* org.onap.music
* ===================================================================
- * Copyright (c) 2017 AT&T Intellectual Property
+ * Copyright (c) 2017 AT&T Intellectual Property
+ * ===================================================================
+ * Modifications Copyright (c) 2018 IBM
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +38,7 @@ public class MusicPolicyVoilationException extends Exception {
*
*/
public MusicPolicyVoilationException() {
- // TODO Auto-generated constructor stub
+
}
/**
@@ -44,7 +46,7 @@ public class MusicPolicyVoilationException extends Exception {
*/
public MusicPolicyVoilationException(String message) {
super(message);
- // TODO Auto-generated constructor stub
+
}
/**
@@ -52,7 +54,7 @@ public class MusicPolicyVoilationException extends Exception {
*/
public MusicPolicyVoilationException(Throwable cause) {
super(cause);
- // TODO Auto-generated constructor stub
+
}
/**
@@ -61,7 +63,7 @@ public class MusicPolicyVoilationException extends Exception {
*/
public MusicPolicyVoilationException(String message, Throwable cause) {
super(message, cause);
- // TODO Auto-generated constructor stub
+
}
/**
@@ -73,7 +75,7 @@ public class MusicPolicyVoilationException extends Exception {
public MusicPolicyVoilationException(String message, Throwable cause, boolean enableSuppression,
boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
- // TODO Auto-generated constructor stub
+
}
}
diff --git a/src/main/java/org/onap/music/exceptions/MusicServiceException.java b/src/main/java/org/onap/music/exceptions/MusicServiceException.java
index 1f0264b3..76e1f948 100644
--- a/src/main/java/org/onap/music/exceptions/MusicServiceException.java
+++ b/src/main/java/org/onap/music/exceptions/MusicServiceException.java
@@ -4,6 +4,8 @@
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
* ===================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -41,8 +43,18 @@ public class MusicServiceException extends Exception {
super(message);
}
-
-
+
+ public MusicServiceException(String message, int errorCode) {
+ super(message);
+ this.errorCode=errorCode;
+ }
+
+ public MusicServiceException(String message, int errorCode, String errorMessage) {
+ super(message);
+ this.errorCode=errorCode;
+ this.errorMessage=errorMessage;
+ }
+
public MusicServiceException(Throwable cause) {
super(cause);
@@ -60,24 +72,17 @@ public class MusicServiceException extends Exception {
super(message, cause, enableSuppression, writableStackTrace);
}
+ public void setErrorCode(int errorCode) {
+ this.errorCode=errorCode;
+ }
public int getErrorCode() {
return errorCode;
}
-
-
- public void setErrorCode(int errorCode) {
- this.errorCode = errorCode;
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage=errorMessage;
}
-
-
public String getErrorMessage() {
return errorMessage;
}
-
-
- public void setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage;
- }
-
}
diff --git a/src/main/java/org/onap/music/lockingservice/MusicLockingService.java b/src/main/java/org/onap/music/lockingservice/MusicLockingService.java
index 097055ba..a75480ae 100644
--- a/src/main/java/org/onap/music/lockingservice/MusicLockingService.java
+++ b/src/main/java/org/onap/music/lockingservice/MusicLockingService.java
@@ -103,8 +103,7 @@ public class MusicLockingService implements Watcher {
try{
data = zkLockHandle.getNodeData(lockName);
}catch (Exception ex){
- logger.error("Error", ex);
- logger.error(EELFLoggerDelegate.errorLogger, ex.getMessage(),AppMessages.UNKNOWNERROR, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
+ logger.error(EELFLoggerDelegate.errorLogger, ex,AppMessages.UNKNOWNERROR, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
}
if(data !=null)
return MusicLockState.deSerialize(data);
diff --git a/src/main/java/org/onap/music/main/MusicCore.java b/src/main/java/org/onap/music/main/MusicCore.java
index 9f7b060b..98696bab 100644
--- a/src/main/java/org/onap/music/main/MusicCore.java
+++ b/src/main/java/org/onap/music/main/MusicCore.java
@@ -189,7 +189,7 @@ public class MusicCore {
logger.info(EELFLoggerDelegate.applicationLogger,"Time taken to get lock state:" + (end - start) + " ms");
return mls;
} catch (NullPointerException | MusicLockingException e) {
- logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.INVALIDLOCK,ErrorSeverity.CRITICAL, ErrorTypes.LOCKINGERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,e, AppMessages.INVALIDLOCK,ErrorSeverity.CRITICAL, ErrorTypes.LOCKINGERROR);
}
return null;
}
@@ -213,9 +213,9 @@ public class MusicCore {
mls = releaseLock(currentLockHolder, voluntaryRelease);
}
}
- } else
+ } else {
logger.error(EELFLoggerDelegate.errorLogger,key, AppMessages.INVALIDLOCK,ErrorSeverity.CRITICAL, ErrorTypes.LOCKINGERROR);
-
+ }
/*
* call the traditional acquire lock now and if the result returned is true, set the
* begin time-stamp and lease period
diff --git a/src/main/java/org/onap/music/main/PropertiesListener.java b/src/main/java/org/onap/music/main/PropertiesListener.java
index 0ed18be2..026790ee 100755
--- a/src/main/java/org/onap/music/main/PropertiesListener.java
+++ b/src/main/java/org/onap/music/main/PropertiesListener.java
@@ -3,6 +3,7 @@
* org.onap.music
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
+ * Modifications Copyright (C) 2018 IBM.
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +38,7 @@ import org.onap.music.eelf.logging.format.ErrorTypes;
public class PropertiesListener implements ServletContextListener {
private Properties prop;
-
+ private static final String MUSIC_PROPERTIES="music.properties";
private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PropertiesListener.class);
@Override
@@ -51,8 +52,8 @@ public class PropertiesListener implements ServletContextListener {
try {
InputStream musicProps = null;
projectProp.load(new FileInputStream(musicPropertiesFilePath));
- if (projectProp.containsKey("music.properties")) {
- musicProps = new FileInputStream(projectProp.getProperty("music.properties"));
+ if (projectProp.containsKey(MUSIC_PROPERTIES)) {
+ musicProps = new FileInputStream(projectProp.getProperty(MUSIC_PROPERTIES));
} else {
musicProps = new FileInputStream(MusicUtil.getMusicPropertiesFilePath());
}
@@ -84,7 +85,7 @@ public class PropertiesListener implements ServletContextListener {
case "music.rest.ip":
MusicUtil.setMusicRestIp(prop.getProperty(key));
break;
- case "music.properties":
+ case MUSIC_PROPERTIES:
MusicUtil.setMusicPropertiesFilePath(prop.getProperty(key));
break;
case "lock.lease.period":
diff --git a/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java b/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java
index 33128f3c..7fb7b1d5 100755
--- a/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java
@@ -4,6 +4,8 @@
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
* ===================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -939,7 +941,7 @@ public class RestMusicAdminAPI {
pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), notifyOn));
MusicCore.nonKeyRelatedPut(pQuery, MusicUtil.EVENTUAL);
} catch(Exception e) {
- e.printStackTrace();
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage());
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setMessage("Callback api registration failed").toMap()).build();
}
return response.status(Status.OK).entity(new JsonResponse(ResultType.SUCCESS).setMessage("Callback api successfully deleted").toMap()).build();