summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-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
7 files changed, 32 insertions, 27 deletions
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