aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/onap/music/conductor/conditionals/RestMusicConditionalAPI.java9
-rw-r--r--src/main/java/org/onap/music/datastore/MusicDataStore.java11
-rw-r--r--src/main/java/org/onap/music/exceptions/MusicServiceException.java41
-rw-r--r--src/main/java/org/onap/music/lockingservice/ZkStatelessLockService.java12
-rw-r--r--src/main/java/org/onap/music/main/ReturnType.java4
-rw-r--r--src/main/java/org/onap/music/response/jsonobjects/JsonResponse.java33
6 files changed, 62 insertions, 48 deletions
diff --git a/src/main/java/org/onap/music/conductor/conditionals/RestMusicConditionalAPI.java b/src/main/java/org/onap/music/conductor/conditionals/RestMusicConditionalAPI.java
index eb466754..1343628c 100644
--- a/src/main/java/org/onap/music/conductor/conditionals/RestMusicConditionalAPI.java
+++ b/src/main/java/org/onap/music/conductor/conditionals/RestMusicConditionalAPI.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
@@ -37,7 +39,6 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.Response.Status;
-import org.codehaus.jettison.json.JSONObject;
import org.onap.music.datastore.PreparedQueryObject;
import org.onap.music.eelf.logging.EELFLoggerDelegate;
import org.onap.music.eelf.logging.format.AppMessages;
@@ -49,8 +50,6 @@ import org.onap.music.main.ResultType;
import org.onap.music.main.ReturnType;
import org.onap.music.response.jsonobjects.JsonResponse;
import org.onap.music.rest.RestMusicAdminAPI;
-import org.onap.music.conductor.*;
-
import com.datastax.driver.core.DataType;
import com.datastax.driver.core.TableMetadata;
@@ -126,8 +125,8 @@ public class RestMusicConditionalAPI {
}
Map<String, String> status = new HashMap<>();
- status.put("exists", conditions.get("exists").get("status").toString());
- status.put("nonexists", conditions.get("nonexists").get("status").toString());
+ status.put("exists", conditions.get("exists").get("status"));
+ status.put("nonexists", conditions.get("nonexists").get("status"));
ReturnType out = null;
out = MusicConditional.conditionalInsert(keyspace, tablename, casscadeColumnName, casscadeColumnData,
diff --git a/src/main/java/org/onap/music/datastore/MusicDataStore.java b/src/main/java/org/onap/music/datastore/MusicDataStore.java
index 0154ad28..9e3a4bf8 100644
--- a/src/main/java/org/onap/music/datastore/MusicDataStore.java
+++ b/src/main/java/org/onap/music/datastore/MusicDataStore.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
@@ -30,6 +32,7 @@ import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+
import org.onap.music.eelf.logging.EELFLoggerDelegate;
import org.onap.music.eelf.logging.format.AppMessages;
import org.onap.music.eelf.logging.format.ErrorSeverity;
@@ -37,6 +40,7 @@ import org.onap.music.eelf.logging.format.ErrorTypes;
import org.onap.music.exceptions.MusicQueryException;
import org.onap.music.exceptions.MusicServiceException;
import org.onap.music.main.MusicUtil;
+
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.ColumnDefinitions;
import com.datastax.driver.core.ColumnDefinitions.Definition;
@@ -54,7 +58,6 @@ import com.datastax.driver.core.TableMetadata;
import com.datastax.driver.core.exceptions.AlreadyExistsException;
import com.datastax.driver.core.exceptions.InvalidQueryException;
import com.datastax.driver.core.exceptions.NoHostAvailableException;
-import com.sun.jersey.core.util.Base64;
/**
* @author nelson24
@@ -127,7 +130,7 @@ public class MusicDataStore {
* @return
*/
private ArrayList<String> getAllPossibleLocalIps() {
- ArrayList<String> allPossibleIps = new ArrayList<String>();
+ ArrayList<String> allPossibleIps = new ArrayList<>();
try {
Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces();
while (en.hasMoreElements()) {
@@ -329,11 +332,11 @@ public class MusicDataStore {
*/
public Map<String, HashMap<String, Object>> marshalData(ResultSet results) {
Map<String, HashMap<String, Object>> resultMap =
- new HashMap<String, HashMap<String, Object>>();
+ new HashMap<>();
int counter = 0;
for (Row row : results) {
ColumnDefinitions colInfo = row.getColumnDefinitions();
- HashMap<String, Object> resultOutput = new HashMap<String, Object>();
+ HashMap<String, Object> resultOutput = new HashMap<>();
for (Definition definition : colInfo) {
if (!definition.getName().equals("vector_ts")) {
if(definition.getType().toString().toLowerCase().contains("blob")) {
diff --git a/src/main/java/org/onap/music/exceptions/MusicServiceException.java b/src/main/java/org/onap/music/exceptions/MusicServiceException.java
index a3b1fc56..1f0264b3 100644
--- a/src/main/java/org/onap/music/exceptions/MusicServiceException.java
+++ b/src/main/java/org/onap/music/exceptions/MusicServiceException.java
@@ -32,26 +32,6 @@ public class MusicServiceException extends Exception {
private int errorCode;
private String errorMessage;
- public int getErrorCode() {
- return errorCode;
- }
-
-
- public void setErrorCode(int errorCode) {
- this.errorCode = errorCode;
- }
-
-
- public String getErrorMessage() {
- return errorMessage;
- }
-
-
- public void setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage;
- }
-
-
public MusicServiceException() {
super();
}
@@ -76,9 +56,28 @@ public class MusicServiceException extends Exception {
public MusicServiceException(String message, Throwable cause, boolean enableSuppression,
- boolean writableStackTrace) {
+ boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
+ public int getErrorCode() {
+ return errorCode;
+ }
+
+
+ public void setErrorCode(int errorCode) {
+ this.errorCode = errorCode;
+ }
+
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
}
diff --git a/src/main/java/org/onap/music/lockingservice/ZkStatelessLockService.java b/src/main/java/org/onap/music/lockingservice/ZkStatelessLockService.java
index b09668b7..2aae4969 100644
--- a/src/main/java/org/onap/music/lockingservice/ZkStatelessLockService.java
+++ b/src/main/java/org/onap/music/lockingservice/ZkStatelessLockService.java
@@ -1,7 +1,10 @@
/*
* ============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. You may obtain a copy of the License at
*
@@ -72,6 +75,7 @@ public class ZkStatelessLockService extends ProtocolSupport {
}
}
+ @Override
public void close() {
try {
zookeeper.close();
@@ -198,7 +202,7 @@ public class ZkStatelessLockService extends ProtocolSupport {
names = zookeeper.getChildren(id, false);
if (names.isEmpty())
return "";
- SortedSet<ZNodeName> sortedNames = new TreeSet<ZNodeName>();
+ SortedSet<ZNodeName> sortedNames = new TreeSet<>();
for (String name : names) {
sortedNames.add(new ZNodeName(id + "/" + name));
}
@@ -328,7 +332,7 @@ public class ZkStatelessLockService extends ProtocolSupport {
// lets sort them explicitly (though they do seem to come back in order
// ususally :)
ZNodeName idName = new ZNodeName(id);
- SortedSet<ZNodeName> sortedNames = new TreeSet<ZNodeName>();
+ SortedSet<ZNodeName> sortedNames = new TreeSet<>();
for (String name : names) {
sortedNames.add(new ZNodeName(dir + "/" + name));
}
diff --git a/src/main/java/org/onap/music/main/ReturnType.java b/src/main/java/org/onap/music/main/ReturnType.java
index 1453a1bf..33f68d7d 100644
--- a/src/main/java/org/onap/music/main/ReturnType.java
+++ b/src/main/java/org/onap/music/main/ReturnType.java
@@ -28,6 +28,8 @@ public class ReturnType {
private ResultType result;
private String message;
+ private String timingInfo;
+
public ReturnType(ResultType result, String message) {
super();
this.result = result;
@@ -42,8 +44,6 @@ public class ReturnType {
this.timingInfo = timingInfo;
}
- private String timingInfo;
-
public ResultType getResult() {
return result;
}
diff --git a/src/main/java/org/onap/music/response/jsonobjects/JsonResponse.java b/src/main/java/org/onap/music/response/jsonobjects/JsonResponse.java
index a406afce..207911d7 100644
--- a/src/main/java/org/onap/music/response/jsonobjects/JsonResponse.java
+++ b/src/main/java/org/onap/music/response/jsonobjects/JsonResponse.java
@@ -26,12 +26,7 @@ import java.util.Map;
import org.onap.music.lockingservice.MusicLockState.LockStatus;
import org.onap.music.main.ResultType;
-import org.powermock.core.spi.testresult.Result;
-import com.datastax.driver.core.ColumnDefinitions;
-import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.Row;
-import com.datastax.driver.core.ColumnDefinitions.Definition;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -231,10 +226,16 @@ public class JsonResponse {
public Map<String, Object> toMap() {
Map<String, Object> fullMap = new HashMap<>();
fullMap.put("status", status);
- if (error!=null) {fullMap.put("error", error);}
- if (message!=null) {fullMap.put("message", message);}
+ if (error!=null) {
+ fullMap.put("error", error);
+ }
+ if (message!=null) {
+ fullMap.put("message", message);
+ }
- if (musicVersion!=null) {fullMap.put("version", musicVersion);}
+ if (musicVersion!=null) {
+ fullMap.put("version", musicVersion);
+ }
if (dataResult!=null) {
fullMap.put("result", dataResult);
@@ -242,10 +243,18 @@ public class JsonResponse {
if (lock!=null) {
Map<String, Object> lockMap = new HashMap<>();
- if (lock!=null) {lockMap.put("lock", lock);}
- if (lockStatus!=null) {lockMap.put("lock-status", lockStatus);}
- if (lockHolder!=null) {lockMap.put("lock-holder", lockHolder);}
- if (lockLease!=null) {lockMap.put("lock-lease", lockLease);}
+ if (lock!=null) {
+ lockMap.put("lock", lock);
+ }
+ if (lockStatus!=null) {
+ lockMap.put("lock-status", lockStatus);
+ }
+ if (lockHolder!=null) {
+ lockMap.put("lock-holder", lockHolder);
+ }
+ if (lockLease!=null) {
+ lockMap.put("lock-lease", lockLease);
+ }
fullMap.put("lock", lockMap);
}