summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSotiropoulos, Ioannis (is948x) <Ioannis.Sotiropoulos@amdocs.com>2018-07-12 11:02:18 +0100
committerSotiropoulos, Ioannis (is948x) <Ioannis.Sotiropoulos@amdocs.com>2018-07-12 11:02:18 +0100
commit194adee686ebb90488f739f2c637f6cb3def94d5 (patch)
treee0b5ddf0a188c559f81a228f124c246ddfdab648
parentd5322dbd0fa1e32d543b24824a28d6bf0a0b5497 (diff)
Fix sonar violations
Issue-ID: AAI-1190 Change-Id: I72894665b288416069d3c2eb84185fcc303976f7 Signed-off-by: Sotiropoulos, Ioannis (is948x) <Ioannis.Sotiropoulos@amdocs.com>
-rw-r--r--pom.xml5
-rw-r--r--src/main/java/org/onap/crud/dao/GraphDao.java4
-rw-r--r--src/main/java/org/onap/crud/dao/champ/ChampDao.java5
-rw-r--r--src/main/java/org/onap/crud/service/AbstractGraphDataService.java4
-rw-r--r--src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java12
-rw-r--r--src/main/java/org/onap/crud/service/CrudGraphDataService.java8
-rw-r--r--src/main/java/org/onap/crud/util/HashGenerator.java15
-rw-r--r--src/main/java/org/onap/schema/validation/OxmModelValidator.java11
-rw-r--r--src/test/java/org/onap/crud/service/TestDao.java4
9 files changed, 38 insertions, 30 deletions
diff --git a/pom.xml b/pom.xml
index e79e4ad..a3ee5d1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -385,12 +385,15 @@ limitations under the License.
<includes>
<include>src/main/java/**</include>
<include>src/test/java/**</include>
+ <include>pom.xml</include>
</includes>
+ <skipExistingHeaders>true</skipExistingHeaders>
</configuration>
<executions>
<execution>
<goals>
- <goal>format</goal>
+ <!-- Set goal from "check" to "format" to auto update license headers -->
+ <goal>check</goal>
</goals>
<phase>process-sources</phase>
</execution>
diff --git a/src/main/java/org/onap/crud/dao/GraphDao.java b/src/main/java/org/onap/crud/dao/GraphDao.java
index fe638ce..6c1bca9 100644
--- a/src/main/java/org/onap/crud/dao/GraphDao.java
+++ b/src/main/java/org/onap/crud/dao/GraphDao.java
@@ -20,9 +20,9 @@
*/
package org.onap.crud.dao;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.onap.aai.restclient.client.OperationResult;
import org.onap.crud.entity.Edge;
import org.onap.crud.entity.Vertex;
@@ -73,7 +73,7 @@ public interface GraphDao {
* @return - The {@link OperationResult} OperationResult
* @throws CrudException
*/
- public OperationResult getVertices(String type, Map<String, Object> filter, HashSet<String> properties, String version) throws CrudException;
+ public OperationResult getVertices(String type, Map<String, Object> filter, Set<String> properties, String version) throws CrudException;
/**
* Retrieve an {@link Edge} from the graph database by specifying its unique
diff --git a/src/main/java/org/onap/crud/dao/champ/ChampDao.java b/src/main/java/org/onap/crud/dao/champ/ChampDao.java
index 6817ea6..fd5de57 100644
--- a/src/main/java/org/onap/crud/dao/champ/ChampDao.java
+++ b/src/main/java/org/onap/crud/dao/champ/ChampDao.java
@@ -27,6 +27,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.http.NameValuePair;
@@ -168,7 +169,7 @@ public class ChampDao implements GraphDao {
}
@Override
- public OperationResult getVertices(String type, Map<String, Object> filter, HashSet<String> properties, String version) throws CrudException {
+ public OperationResult getVertices(String type, Map<String, Object> filter, Set<String> properties, String version) throws CrudException {
filter.put(org.onap.schema.validation.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
List<NameValuePair> queryParams = convertToNameValuePair(filter);
@@ -575,7 +576,7 @@ public class ChampDao implements GraphDao {
}
// https://stackoverflow.com/questions/26942330/convert-mapstring-string-to-listnamevaluepair-is-this-the-most-efficient
- private List<NameValuePair> convertToNameValuePair(String k, HashSet<String> values) {
+ private List<NameValuePair> convertToNameValuePair(String k, Set<String> values) {
List<NameValuePair> nvpList = new ArrayList<>(values.size());
values.forEach((v) -> nvpList.add(new BasicNameValuePair(k, v)));
diff --git a/src/main/java/org/onap/crud/service/AbstractGraphDataService.java b/src/main/java/org/onap/crud/service/AbstractGraphDataService.java
index fed12fd..a5b52bd 100644
--- a/src/main/java/org/onap/crud/service/AbstractGraphDataService.java
+++ b/src/main/java/org/onap/crud/service/AbstractGraphDataService.java
@@ -22,9 +22,9 @@ package org.onap.crud.service;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.ws.rs.core.EntityTag;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response.Status;
@@ -89,7 +89,7 @@ public abstract class AbstractGraphDataService {
version));
}
- public ImmutablePair<EntityTag, String> getVertices(String version, String type, Map<String, String> filter, HashSet<String> properties) throws CrudException {
+ public ImmutablePair<EntityTag, String> getVertices(String version, String type, Map<String, String> filter, Set<String> properties) throws CrudException {
type = OxmModelValidator.resolveCollectionType(version, type);
OperationResult operationResult = daoForGet.getVertices(type, OxmModelValidator.resolveCollectionfilter(version, type, filter), properties, version);
List<Vertex> vertices = Vertex.collectionFromJson(operationResult.getResult(), version);
diff --git a/src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java b/src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java
index 26f7427..aa70a66 100644
--- a/src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java
+++ b/src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java
@@ -230,7 +230,7 @@ public class CrudAsyncGraphDataService extends AbstractGraphDataService {
}
String responsePayload = responseHandler.handleVertexResponse(version, event, response);
- return new ImmutablePair<EntityTag, String>(entityTag, responsePayload);
+ return new ImmutablePair<>(entityTag, responsePayload);
}
@Override
@@ -252,7 +252,7 @@ public class CrudAsyncGraphDataService extends AbstractGraphDataService {
}
String responsePayload = responseHandler.handleEdgeResponse(version, event, response);
- return new ImmutablePair<EntityTag, String>(entityTag, responsePayload);
+ return new ImmutablePair<>(entityTag, responsePayload);
}
@Override
@@ -272,7 +272,7 @@ public class CrudAsyncGraphDataService extends AbstractGraphDataService {
}
String responsePayload = responseHandler.handleVertexResponse(version, event, response);
- return new ImmutablePair<EntityTag, String>(entityTag, responsePayload);
+ return new ImmutablePair<>(entityTag, responsePayload);
}
@Override
@@ -296,7 +296,7 @@ public class CrudAsyncGraphDataService extends AbstractGraphDataService {
}
String responsePayload = responseHandler.handleVertexResponse(version, event, response);
- return new ImmutablePair<EntityTag, String>(entityTag, responsePayload);
+ return new ImmutablePair<>(entityTag, responsePayload);
}
@Override
@@ -339,7 +339,7 @@ public class CrudAsyncGraphDataService extends AbstractGraphDataService {
}
String responsePayload = responseHandler.handleEdgeResponse(version, event, response);
- return new ImmutablePair<EntityTag, String>(entityTag, responsePayload);
+ return new ImmutablePair<>(entityTag, responsePayload);
}
@Override
@@ -361,7 +361,7 @@ public class CrudAsyncGraphDataService extends AbstractGraphDataService {
}
String responsePayload = responseHandler.handleEdgeResponse(version, event, response);
- return new ImmutablePair<EntityTag, String>(entityTag, responsePayload);
+ return new ImmutablePair<>(entityTag, responsePayload);
}
@PreDestroy
diff --git a/src/main/java/org/onap/crud/service/CrudGraphDataService.java b/src/main/java/org/onap/crud/service/CrudGraphDataService.java
index 2888ace..9ff48c7 100644
--- a/src/main/java/org/onap/crud/service/CrudGraphDataService.java
+++ b/src/main/java/org/onap/crud/service/CrudGraphDataService.java
@@ -68,7 +68,7 @@ public class CrudGraphDataService extends AbstractGraphDataService {
String payload = CrudResponseBuilder
.buildUpsertVertexResponse(OxmModelValidator.validateOutgoingPayload(version, addedVertex), version);
- return new ImmutablePair<EntityTag, String>(entityTag, payload);
+ return new ImmutablePair<>(entityTag, payload);
}
@Override
@@ -95,7 +95,7 @@ public class CrudGraphDataService extends AbstractGraphDataService {
String payload = CrudResponseBuilder
.buildUpsertEdgeResponse(RelationshipSchemaValidator.validateOutgoingPayload(version, addedEdge), version);
- return new ImmutablePair<EntityTag, String>(entityTag, payload);
+ return new ImmutablePair<>(entityTag, payload);
}
@Override
@@ -110,7 +110,7 @@ public class CrudGraphDataService extends AbstractGraphDataService {
String payload = getUpdatedVertexPayload(version, updatedVertexResult);
EntityTag entityTag = CrudServiceUtil.getETagFromHeader(updatedVertexResult.getHeaders());
- return new ImmutablePair<EntityTag, String>(entityTag, payload);
+ return new ImmutablePair<>(entityTag, payload);
}
private String getUpdatedVertexPayload(String version, OperationResult updatedVertexResult) throws CrudException {
@@ -169,7 +169,7 @@ public class CrudGraphDataService extends AbstractGraphDataService {
String payload = getUpdatedEdgePayload(version, updatedEdgeResult);
EntityTag entityTag = CrudServiceUtil.getETagFromHeader(updatedEdgeResult.getHeaders());
- return new ImmutablePair<EntityTag, String>(entityTag, payload);
+ return new ImmutablePair<>(entityTag, payload);
}
private String getUpdatedEdgePayload(String version, OperationResult updatedEdgeResult) throws CrudException {
diff --git a/src/main/java/org/onap/crud/util/HashGenerator.java b/src/main/java/org/onap/crud/util/HashGenerator.java
index 02558fa..24f1823 100644
--- a/src/main/java/org/onap/crud/util/HashGenerator.java
+++ b/src/main/java/org/onap/crud/util/HashGenerator.java
@@ -26,6 +26,7 @@ import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+
/**
* Generates a sha 256 hash
*/
@@ -38,8 +39,9 @@ public class HashGenerator {
}
/**
- * Generates a SHA 256 hash as a hexadecimal string for the inputs.
- * Calls toString on the input objects to convert into a byte stream.
+ * Generates a SHA 256 hash as a hexadecimal string for the inputs. Calls toString on the input
+ * objects to convert into a byte stream.
+ *
* @param values
* @return SHA 256 hash of the inputs as a hexadecimal string.
* @throws IOException
@@ -48,13 +50,14 @@ public class HashGenerator {
byte[] bytes = convertToBytes(values);
byte[] digest = messageDigest.digest(bytes);
StringBuilder result = new StringBuilder();
- for (byte byt : digest) result.append(Integer.toString((byt & 0xff) + 0x100, 16).substring(1));
+ for (byte byt : digest) {
+ result.append(Integer.toString((byt & 0xff) + 0x100, 16).substring(1));
+ }
return result.toString();
}
private byte[] convertToBytes(Object... values) throws IOException {
- try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutput out = new ObjectOutputStream(bos)) {
+ try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(bos)) {
for (Object object : values) {
out.writeObject(object.toString());
}
@@ -62,4 +65,4 @@ public class HashGenerator {
}
}
-} \ No newline at end of file
+}
diff --git a/src/main/java/org/onap/schema/validation/OxmModelValidator.java b/src/main/java/org/onap/schema/validation/OxmModelValidator.java
index 89b8030..d317678 100644
--- a/src/main/java/org/onap/schema/validation/OxmModelValidator.java
+++ b/src/main/java/org/onap/schema/validation/OxmModelValidator.java
@@ -43,7 +43,8 @@ import com.google.gson.JsonNull;
public class OxmModelValidator {
private static Logger logger = LoggerFactory.getInstance().getLogger(OxmModelValidator.class.getName());
-
+ private static final String OXM_LOAD_ERROR = "Error loading oxm model";
+
public enum Metadata {
NODE_TYPE("aai-node-type"),
URI("aai-uri"),
@@ -84,8 +85,8 @@ public class OxmModelValidator {
Map<String, Object> result = new HashMap<String, Object>();
if (jaxbContext == null) {
- logger.error(CrudServiceMsgs.OXM_LOAD_ERROR, "Error loading oxm model: " + version);
- throw new CrudException("Error loading oxm model: " + version, Status.NOT_FOUND);
+ logger.error(CrudServiceMsgs.OXM_LOAD_ERROR, OXM_LOAD_ERROR + ": " + version);
+ throw new CrudException(OXM_LOAD_ERROR + ": " + version, Status.NOT_FOUND);
}
final DynamicType modelObjectType = jaxbContext.getDynamicType(
CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, type)));
@@ -131,8 +132,8 @@ public class OxmModelValidator {
}
if (jaxbContext == null) {
- logger.error(CrudServiceMsgs.OXM_LOAD_ERROR, "Error loading oxm model: " + version);
- throw new CrudException("Error loading oxm model: " + version, Status.NOT_FOUND);
+ logger.error(CrudServiceMsgs.OXM_LOAD_ERROR, OXM_LOAD_ERROR + ": " + version);
+ throw new CrudException(OXM_LOAD_ERROR + ": " + version, Status.NOT_FOUND);
}
// Determine if the Object part is a collection type in the model
// definition
diff --git a/src/test/java/org/onap/crud/service/TestDao.java b/src/test/java/org/onap/crud/service/TestDao.java
index d412163..20cd04a 100644
--- a/src/test/java/org/onap/crud/service/TestDao.java
+++ b/src/test/java/org/onap/crud/service/TestDao.java
@@ -21,9 +21,9 @@
package org.onap.crud.service;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
import org.onap.aai.restclient.client.OperationResult;
@@ -98,7 +98,7 @@ public class TestDao implements GraphDao {
}
@Override
- public OperationResult getVertices(String type, Map<String, Object> filter, HashSet<String> properties, String version)
+ public OperationResult getVertices(String type, Map<String, Object> filter, Set<String> properties, String version)
throws CrudException {
OperationResult operationResult = new OperationResult();
operationResult.setResult(champVertices);