2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 package org.onap.crud.dao.champ;
23 import java.nio.charset.Charset;
24 import java.util.ArrayList;
25 import java.util.Arrays;
26 import java.util.HashMap;
27 import java.util.HashSet;
28 import java.util.List;
31 import javax.ws.rs.core.MediaType;
32 import javax.ws.rs.core.Response;
33 import org.apache.http.NameValuePair;
34 import org.apache.http.client.utils.URLEncodedUtils;
35 import org.apache.http.message.BasicNameValuePair;
36 import org.eclipse.jetty.util.security.Password;
37 import org.onap.aai.cl.mdc.MdcContext;
38 import org.onap.aai.restclient.client.OperationResult;
39 import org.onap.aai.restclient.client.RestClient;
40 import org.onap.aai.restclient.enums.RestAuthenticationMode;
41 import org.onap.crud.dao.GraphDao;
42 import org.onap.crud.entity.Edge;
43 import org.onap.crud.entity.Vertex;
44 import org.onap.crud.exception.CrudException;
45 import org.onap.crud.util.CrudServiceConstants;
47 import com.google.gson.Gson;
48 import com.google.gson.GsonBuilder;
49 import com.google.gson.reflect.TypeToken;
50 import net.dongliu.gson.GsonJava8TypeAdapterFactory;
52 public class ChampDao implements GraphDao {
53 protected RestClient client;
54 protected String baseObjectUrl;
55 protected String baseRelationshipUrl;
56 protected String baseTransactionUrl;
58 protected static final String HEADER_FROM_APP = "X-FromAppId";
59 protected static final String HEADER_TRANS_ID = "X-TransactionId";
60 protected static final String FROM_APP_NAME = "Gizmo";
61 protected static final String OBJECT_SUB_URL = "objects";
62 protected static final String RELATIONSHIP_SUB_URL = "relationships";
63 protected static final String TRANSACTION_SUB_URL = "transaction";
65 // We use a custom vertex serializer for champ because it expects "key"
67 protected static final Gson champGson = new GsonBuilder()
68 .registerTypeAdapterFactory(new GsonJava8TypeAdapterFactory())
69 .registerTypeAdapter(Vertex.class, new ChampVertexSerializer())
70 .registerTypeAdapter(Edge.class, new ChampEdgeSerializer()).create();
75 public ChampDao(String champUrl, String certPassword) {
77 String deobfuscatedCertPassword = certPassword.startsWith("OBF:")?Password.deobfuscate(certPassword):certPassword;
78 client = new RestClient().authenticationMode(RestAuthenticationMode.SSL_CERT).validateServerHostname(false)
79 .validateServerCertChain(false).clientCertFile(CrudServiceConstants.CRD_CHAMP_AUTH_FILE)
80 .clientCertPassword(deobfuscatedCertPassword);
82 baseObjectUrl = champUrl + OBJECT_SUB_URL;
83 baseRelationshipUrl = champUrl + RELATIONSHIP_SUB_URL;
84 baseTransactionUrl = champUrl + TRANSACTION_SUB_URL;
85 } catch (Exception e) {
86 System.out.println("Error setting up Champ configuration");
92 public ChampDao(RestClient client, String baseObjectUrl, String baseRelationshipUrl, String baseTransactionUrl) {
94 this.baseObjectUrl = baseObjectUrl;
95 this.baseRelationshipUrl = baseRelationshipUrl;
96 this.baseTransactionUrl = baseTransactionUrl;
100 public Vertex getVertex(String id, String version) throws CrudException {
101 String url = baseObjectUrl + "/" + id;
102 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
104 if (getResult.getResultCode() == 200) {
105 return Vertex.fromJson(getResult.getResult(), version);
107 // We didn't find a vertex with the supplied id, so just throw an
109 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
114 public OperationResult getVertex(String id, String type, String version, Map<String, String> queryParams) throws CrudException {
115 StringBuilder strBuild = new StringBuilder(baseObjectUrl);
116 strBuild.append("/");
118 if(queryParams != null && !queryParams.isEmpty())
120 strBuild.append("?");
121 strBuild.append(URLEncodedUtils.format(convertToNameValuePair(queryParams), Charset.defaultCharset()));
124 OperationResult getResult = client.get(strBuild.toString(), createHeader(), MediaType.APPLICATION_JSON_TYPE);
126 if (getResult.getResultCode() == 200) {
127 Vertex vert = Vertex.fromJson(getResult.getResult(), version);
129 if (!vert.getType().equalsIgnoreCase(type)) {
130 // We didn't find a vertex with the supplied type, so just throw an
132 throw new CrudException("No vertex with id " + id + " and type " + type + " found in graph",
133 javax.ws.rs.core.Response.Status.NOT_FOUND);
137 // We didn't find a vertex with the supplied id, so just throw an
139 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
144 public List<Edge> getVertexEdges(String id, Map<String, String> queryParams, String txId) throws CrudException {
145 StringBuilder strBuild = new StringBuilder(baseObjectUrl);
146 strBuild.append("/relationships/");
149 Map<String,String> queryParamsCopy = null;
150 if (queryParams != null) {
151 queryParamsCopy = new HashMap<String,String>(queryParams);
154 queryParamsCopy = new HashMap<String,String>();
158 queryParamsCopy.put("transactionId", txId);
161 if (!queryParamsCopy.isEmpty())
163 strBuild.append("?");
164 strBuild.append(URLEncodedUtils.format(convertToNameValuePair(queryParamsCopy), Charset.defaultCharset()));
167 OperationResult getResult = client.get(strBuild.toString(), createHeader(), MediaType.APPLICATION_JSON_TYPE);
169 if (getResult.getResultCode() == 200) {
170 return champGson.fromJson(getResult.getResult(), new TypeToken<List<Edge>>() {
173 // We didn't find a vertex with the supplied id, so just throw an
175 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
180 public OperationResult getVertices(String type, Map<String, Object> filter, String version) throws CrudException {
181 return getVertices(type, filter, new HashSet<String>(), version);
185 public OperationResult getVertices(String type, Map<String, Object> filter, Set<String> properties, String version) throws CrudException {
186 filter.put(org.onap.schema.validation.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
188 List<NameValuePair> queryParams = convertToNameValuePair(filter);
189 queryParams.addAll(convertToNameValuePair("properties", properties));
190 String url = baseObjectUrl + "/filter" + "?"
191 + URLEncodedUtils.format(queryParams, Charset.defaultCharset());
193 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
195 if (getResult.getResultCode() == 200) {
198 // We didn't find a vertex with the supplied id, so just throw an
200 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertices found in graph for given filters");
205 public OperationResult getEdge(String id, String type, Map<String, String> queryParams) throws CrudException {
206 StringBuilder strBuild = new StringBuilder(baseRelationshipUrl);
207 strBuild.append("/");
209 if(queryParams != null && !queryParams.isEmpty())
211 strBuild.append("?");
212 strBuild.append(URLEncodedUtils.format(convertToNameValuePair(queryParams), Charset.defaultCharset()));
214 OperationResult getResult = client.get(strBuild.toString(), createHeader(), MediaType.APPLICATION_JSON_TYPE);
216 if (getResult.getResultCode() == 200) {
217 Edge edge = Edge.fromJson(getResult.getResult());
219 if (!edge.getType().equalsIgnoreCase(type)) {
220 // We didn't find an edge with the supplied type, so just throw an
222 throw new CrudException("No edge with id " + id + " and type " + type + " found in graph",
223 javax.ws.rs.core.Response.Status.NOT_FOUND);
227 // We didn't find a edge with the supplied type, so just throw an
229 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
234 public OperationResult getEdges(String type, Map<String, Object> filter) throws CrudException {
235 String url = baseRelationshipUrl + "/filter" + "?"
236 + URLEncodedUtils.format(convertToNameValuePair(filter), Charset.defaultCharset());
238 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
240 if (getResult.getResultCode() == 200) {
243 // We didn't find a vertex with the supplied id, so just throw an
245 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edges found in graph for given filters");
250 public OperationResult addVertex(String type, Map<String, Object> properties, String version) throws CrudException {
251 String url = baseObjectUrl;
253 // Add the aai_node_type so that AAI can read the data created by gizmo
254 // TODO: This probably shouldn't be here
255 properties.put(org.onap.schema.validation.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
257 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
258 properties.forEach(insertVertexBuilder::property);
259 Vertex insertVertex = insertVertexBuilder.build();
261 OperationResult getResult = client.post(url, insertVertex.toJson(), createHeader(), MediaType.APPLICATION_JSON_TYPE,
262 MediaType.APPLICATION_JSON_TYPE);
264 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
267 // We didn't create a vertex with the supplied type, so just throw an
269 throw new CrudException("Failed to create vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
274 public OperationResult updateVertex(String id, String type, Map<String, Object> properties, String version) throws CrudException {
275 String url = baseObjectUrl + "/" + id;
277 // Add the aai_node_type so that AAI can read the data created by gizmo
278 // TODO: This probably shouldn't be here
279 properties.put(org.onap.schema.validation.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
281 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
282 insertVertexBuilder.id(id);
283 properties.forEach(insertVertexBuilder::property);
284 Vertex insertVertex = insertVertexBuilder.build();
286 String payload = insertVertex.toJson(champGson);
287 OperationResult getResult = client.put(url, payload, createHeader(), MediaType.APPLICATION_JSON_TYPE,
288 MediaType.APPLICATION_JSON_TYPE);
290 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
293 // We didn't create a vertex with the supplied type, so just throw an
295 throw new CrudException("Failed to update vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
300 public void deleteVertex(String id, String type) throws CrudException {
301 String url = baseObjectUrl + "/" + id;
302 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
304 if (getResult.getResultCode() != Response.Status.OK.getStatusCode()) {
305 // We didn't delete a vertex with the supplied id, so just throw an
307 throw new CrudException("Failed to delete vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
312 public OperationResult addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version) throws CrudException {
313 String url = baseRelationshipUrl;
315 // Try requests to ensure source and target exist in Champ
316 OperationResult dbSourceOpResult = getVertex(source.getId().get(), source.getType(), version, new HashMap<String, String>());
317 Vertex dbSource = Vertex.fromJson(dbSourceOpResult.getResult(), version);
318 OperationResult dbTargetOpResult = getVertex(target.getId().get(), target.getType(), version, new HashMap<String, String>());
319 Vertex dbTarget = Vertex.fromJson(dbTargetOpResult.getResult(), version);
321 Edge.Builder insertEdgeBuilder = new Edge.Builder(type).source(dbSource).target(dbTarget);
322 properties.forEach(insertEdgeBuilder::property);
323 Edge insertEdge = insertEdgeBuilder.build();
325 String edgeJson = insertEdge.toJson(champGson);
326 OperationResult getResult = client.post(url, edgeJson, createHeader(), MediaType.APPLICATION_JSON_TYPE,
327 MediaType.APPLICATION_JSON_TYPE);
329 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
332 // We didn't create an edge with the supplied type, so just throw an
334 throw new CrudException("Failed to create edge: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
339 public OperationResult updateEdge(Edge edge) throws CrudException {
340 if (!edge.getId().isPresent()) {
341 throw new CrudException("Unable to identify edge: " + edge.toString(), Response.Status.BAD_REQUEST);
343 String url = baseRelationshipUrl + "/" + edge.getId().get();
345 String edgeJson = edge.toJson(champGson);
346 OperationResult getResult = client.put(url, edgeJson, createHeader(), MediaType.APPLICATION_JSON_TYPE,
347 MediaType.APPLICATION_JSON_TYPE);
349 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
352 // We didn't create an edge with the supplied type, so just throw an
354 throw new CrudException("Failed to update edge: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
359 public void deleteEdge(String id) throws CrudException {
360 String url = baseRelationshipUrl + "/" + id;
361 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
363 if (getResult.getResultCode() != 200) {
364 // We didn't find an edge with the supplied type, so just throw an
366 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
371 public String openTransaction() {
372 String url = baseTransactionUrl;
374 OperationResult getResult = client.post(url, "", createHeader(), MediaType.TEXT_PLAIN_TYPE, MediaType.TEXT_PLAIN_TYPE);
376 if (getResult.getResultCode() == 200) {
377 return getResult.getResult();
384 public void commitTransaction(String id) throws CrudException {
385 String url = baseTransactionUrl + "/" + id;
387 OperationResult getResult = client.put(url, "{\"method\": \"commit\"}", createHeader(), MediaType.APPLICATION_JSON_TYPE,
388 MediaType.TEXT_PLAIN_TYPE);
390 if (getResult.getResultCode() != 200) {
391 throw new CrudException("Unable to commit transaction",
392 Response.Status.fromStatusCode(getResult.getResultCode()));
397 public void rollbackTransaction(String id) throws CrudException {
398 String url = baseTransactionUrl + "/" + id;
400 OperationResult getResult = client.put(url, "{\"method\": \"rollback\"}", createHeader(), MediaType.APPLICATION_JSON_TYPE,
401 MediaType.TEXT_PLAIN_TYPE);
403 if (getResult.getResultCode() != 200) {
404 throw new CrudException("Unable to rollback transaction",
405 Response.Status.fromStatusCode(getResult.getResultCode()));
410 public boolean transactionExists(String id) throws CrudException {
411 String url = baseTransactionUrl + "/" + id;
412 Map<String, List<String>> headers = new HashMap<>();
413 headers.put(HEADER_FROM_APP, Arrays.asList("Gizmo"));
414 headers.put(HEADER_TRANS_ID, Arrays.asList(MDC.get(MdcContext.MDC_REQUEST_ID)));
416 OperationResult getResult = client.get(url, headers, MediaType.APPLICATION_JSON_TYPE);
418 return getResult.getResultCode() == 200;
422 public Vertex addVertex(String type, Map<String, Object> properties, String version, String txId) throws CrudException {
423 String url = baseObjectUrl + "?transactionId=" + txId;
425 // Add the aai_node_type so that AAI can read the data created by gizmo
426 // TODO: This probably shouldn't be here
427 properties.put(org.onap.schema.validation.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
429 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
430 properties.forEach(insertVertexBuilder::property);
431 Vertex insertVertex = insertVertexBuilder.build();
433 OperationResult getResult = client.post(url, insertVertex.toJson(), createHeader(), MediaType.APPLICATION_JSON_TYPE,
434 MediaType.APPLICATION_JSON_TYPE);
436 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
437 return Vertex.fromJson(getResult.getResult(), version);
439 // We didn't create a vertex with the supplied type, so just throw an
441 throw new CrudException("Failed to create vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
446 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version, String txId)
447 throws CrudException {
448 String url = baseRelationshipUrl + "?transactionId=" + txId;
450 // Try requests to ensure source and target exist in Champ
451 Vertex dbSource = getVertex(source.getId().get(), source.getType(), version, txId);
452 Vertex dbTarget = getVertex(target.getId().get(), target.getType(), version, txId);
454 Edge.Builder insertEdgeBuilder = new Edge.Builder(type).source(dbSource).target(dbTarget);
455 properties.forEach(insertEdgeBuilder::property);
456 Edge insertEdge = insertEdgeBuilder.build();
458 OperationResult getResult = client.post(url, insertEdge.toJson(champGson), createHeader(),
459 MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_JSON_TYPE);
461 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
462 return Edge.fromJson(getResult.getResult());
464 // We didn't create an edge with the supplied type, so just throw an
466 throw new CrudException("Failed to create edge: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
471 public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version, String txId) throws CrudException {
472 String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
474 // Add the aai_node_type so that AAI can read the data created by gizmo
475 // TODO: This probably shouldn't be here
476 properties.put(org.onap.schema.validation.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
478 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
479 insertVertexBuilder.id(id);
480 properties.forEach(insertVertexBuilder::property);
481 Vertex insertVertex = insertVertexBuilder.build();
483 String payload = insertVertex.toJson(champGson);
484 OperationResult getResult = client.put(url, payload, createHeader(), MediaType.APPLICATION_JSON_TYPE,
485 MediaType.APPLICATION_JSON_TYPE);
487 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
488 return Vertex.fromJson(getResult.getResult(), version);
490 // We didn't create a vertex with the supplied type, so just throw an
492 throw new CrudException("Failed to update vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
497 public void deleteVertex(String id, String type, String txId) throws CrudException {
498 String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
499 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
501 if (getResult.getResultCode() != Response.Status.OK.getStatusCode()) {
502 // We didn't delete a vertex with the supplied id, so just throw an
504 throw new CrudException("Failed to delete vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
509 public Edge updateEdge(Edge edge, String txId) throws CrudException {
510 if (!edge.getId().isPresent()) {
511 throw new CrudException("Unable to identify edge: " + edge.toString(), Response.Status.BAD_REQUEST);
513 String url = baseRelationshipUrl + "/" + edge.getId().get() + "?transactionId=" + txId;
514 OperationResult getResult = client.put(url, edge.toJson(champGson), createHeader(), MediaType.APPLICATION_JSON_TYPE,
515 MediaType.APPLICATION_JSON_TYPE);
517 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
518 return Edge.fromJson(getResult.getResult());
520 // We didn't create an edge with the supplied type, so just throw an
522 throw new CrudException("Failed to update edge: " + getResult.getFailureCause(),
523 Response.Status.fromStatusCode(getResult.getResultCode()));
528 public void deleteEdge(String id, String txId) throws CrudException {
529 String url = baseRelationshipUrl + "/" + id + "?transactionId=" + txId;
530 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
532 if (getResult.getResultCode() != 200) {
533 // We didn't find an edge with the supplied type, so just throw an
535 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
540 public Edge getEdge(String id, String txId) throws CrudException {
541 String url = baseRelationshipUrl + "/" + id + "?transactionId=" + txId;
542 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
544 if (getResult.getResultCode() == 200) {
545 Edge edge = Edge.fromJson(getResult.getResult());
548 // We didn't find an edge with the supplied id, so just throw an
550 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
555 public Edge getEdge(String id) throws CrudException {
556 String url = baseRelationshipUrl + "/" + id;
557 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
559 if (getResult.getResultCode() == 200) {
560 Edge edge = Edge.fromJson(getResult.getResult());
563 // We didn't find an edge with the supplied id, so just throw an exception.
564 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
568 public Vertex getVertex(String id, String type, String version, String txId) throws CrudException {
569 String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
570 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
572 if (getResult.getResultCode() == 200) {
573 Vertex vert = Vertex.fromJson(getResult.getResult(), version);
575 if (!vert.getType().equalsIgnoreCase(type)) {
576 // We didn't find a vertex with the supplied type, so just throw an
578 throw new CrudException("No vertex with id " + id + " and type " + type + " found in graph",
579 javax.ws.rs.core.Response.Status.NOT_FOUND);
583 // We didn't find a vertex with the supplied id, so just throw an
585 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
589 // https://stackoverflow.com/questions/26942330/convert-mapstring-string-to-listnamevaluepair-is-this-the-most-efficient
590 private List<NameValuePair> convertToNameValuePair(Map<String, ? super String> pairs) {
591 List<NameValuePair> nvpList = new ArrayList<>(pairs.size());
593 pairs.forEach((key, value) -> nvpList.add(new BasicNameValuePair(key, value.toString())));
598 // https://stackoverflow.com/questions/26942330/convert-mapstring-string-to-listnamevaluepair-is-this-the-most-efficient
599 private List<NameValuePair> convertToNameValuePair(String k, Set<String> values) {
600 List<NameValuePair> nvpList = new ArrayList<>(values.size());
602 values.forEach((v) -> nvpList.add(new BasicNameValuePair(k, v)));
607 private Map<String, List<String>> createHeader() {
608 Map<String, List<String>> headers = new HashMap<>();
609 headers.put(HEADER_FROM_APP, Arrays.asList(FROM_APP_NAME));
610 headers.put(HEADER_TRANS_ID, Arrays.asList(MDC.get(MdcContext.MDC_REQUEST_ID)));
614 private CrudException createErrorException(OperationResult result, javax.ws.rs.core.Response.Status defaultErrorCode , String defaultErrorMsg)
616 CrudException ce = null;
618 ce = new CrudException(result.getFailureCause(), Response.Status.fromStatusCode(result.getResultCode()));
620 ce = new CrudException(defaultErrorMsg, defaultErrorCode);