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 client = new RestClient().authenticationMode(RestAuthenticationMode.SSL_CERT).validateServerHostname(false)
78 .validateServerCertChain(false).clientCertFile(CrudServiceConstants.CRD_CHAMP_AUTH_FILE)
79 .clientCertPassword(Password.deobfuscate(certPassword));
81 baseObjectUrl = champUrl + OBJECT_SUB_URL;
82 baseRelationshipUrl = champUrl + RELATIONSHIP_SUB_URL;
83 baseTransactionUrl = champUrl + TRANSACTION_SUB_URL;
84 } catch (Exception e) {
85 System.out.println("Error setting up Champ configuration");
91 public ChampDao(RestClient client, String baseObjectUrl, String baseRelationshipUrl, String baseTransactionUrl) {
93 this.baseObjectUrl = baseObjectUrl;
94 this.baseRelationshipUrl = baseRelationshipUrl;
95 this.baseTransactionUrl = baseTransactionUrl;
99 public Vertex getVertex(String id, String version) throws CrudException {
100 String url = baseObjectUrl + "/" + id;
101 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
103 if (getResult.getResultCode() == 200) {
104 return Vertex.fromJson(getResult.getResult(), version);
106 // We didn't find a vertex with the supplied id, so just throw an
108 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
113 public OperationResult getVertex(String id, String type, String version, Map<String, String> queryParams) throws CrudException {
114 StringBuilder strBuild = new StringBuilder(baseObjectUrl);
115 strBuild.append("/");
117 if(queryParams != null && !queryParams.isEmpty())
119 strBuild.append("?");
120 strBuild.append(URLEncodedUtils.format(convertToNameValuePair(queryParams), Charset.defaultCharset()));
123 OperationResult getResult = client.get(strBuild.toString(), createHeader(), MediaType.APPLICATION_JSON_TYPE);
125 if (getResult.getResultCode() == 200) {
126 Vertex vert = Vertex.fromJson(getResult.getResult(), version);
128 if (!vert.getType().equalsIgnoreCase(type)) {
129 // We didn't find a vertex with the supplied type, so just throw an
131 throw new CrudException("No vertex with id " + id + " and type " + type + " found in graph",
132 javax.ws.rs.core.Response.Status.NOT_FOUND);
136 // We didn't find a vertex with the supplied id, so just throw an
138 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
143 public List<Edge> getVertexEdges(String id, Map<String, String> queryParams, String txId) throws CrudException {
144 StringBuilder strBuild = new StringBuilder(baseObjectUrl);
145 strBuild.append("/relationships/");
148 Map<String,String> queryParamsCopy = null;
149 if (queryParams != null) {
150 queryParamsCopy = new HashMap<String,String>(queryParams);
153 queryParamsCopy = new HashMap<String,String>();
157 queryParamsCopy.put("transactionId", txId);
160 if (!queryParamsCopy.isEmpty())
162 strBuild.append("?");
163 strBuild.append(URLEncodedUtils.format(convertToNameValuePair(queryParamsCopy), Charset.defaultCharset()));
166 OperationResult getResult = client.get(strBuild.toString(), createHeader(), MediaType.APPLICATION_JSON_TYPE);
168 if (getResult.getResultCode() == 200) {
169 return champGson.fromJson(getResult.getResult(), new TypeToken<List<Edge>>() {
172 // We didn't find a vertex with the supplied id, so just throw an
174 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
179 public OperationResult getVertices(String type, Map<String, Object> filter, String version) throws CrudException {
180 return getVertices(type, filter, new HashSet<String>(), version);
184 public OperationResult getVertices(String type, Map<String, Object> filter, Set<String> properties, String version) throws CrudException {
185 filter.put(org.onap.schema.validation.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
187 List<NameValuePair> queryParams = convertToNameValuePair(filter);
188 queryParams.addAll(convertToNameValuePair("properties", properties));
189 String url = baseObjectUrl + "/filter" + "?"
190 + URLEncodedUtils.format(queryParams, Charset.defaultCharset());
192 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
194 if (getResult.getResultCode() == 200) {
197 // We didn't find a vertex with the supplied id, so just throw an
199 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertices found in graph for given filters");
204 public OperationResult getEdge(String id, String type, Map<String, String> queryParams) throws CrudException {
205 StringBuilder strBuild = new StringBuilder(baseRelationshipUrl);
206 strBuild.append("/");
208 if(queryParams != null && !queryParams.isEmpty())
210 strBuild.append("?");
211 strBuild.append(URLEncodedUtils.format(convertToNameValuePair(queryParams), Charset.defaultCharset()));
213 OperationResult getResult = client.get(strBuild.toString(), createHeader(), MediaType.APPLICATION_JSON_TYPE);
215 if (getResult.getResultCode() == 200) {
216 Edge edge = Edge.fromJson(getResult.getResult());
218 if (!edge.getType().equalsIgnoreCase(type)) {
219 // We didn't find an edge with the supplied type, so just throw an
221 throw new CrudException("No edge with id " + id + " and type " + type + " found in graph",
222 javax.ws.rs.core.Response.Status.NOT_FOUND);
226 // We didn't find a edge with the supplied type, so just throw an
228 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
233 public OperationResult getEdges(String type, Map<String, Object> filter) throws CrudException {
234 String url = baseRelationshipUrl + "/filter" + "?"
235 + URLEncodedUtils.format(convertToNameValuePair(filter), Charset.defaultCharset());
237 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
239 if (getResult.getResultCode() == 200) {
242 // We didn't find a vertex with the supplied id, so just throw an
244 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edges found in graph for given filters");
249 public OperationResult addVertex(String type, Map<String, Object> properties, String version) throws CrudException {
250 String url = baseObjectUrl;
252 // Add the aai_node_type so that AAI can read the data created by gizmo
253 // TODO: This probably shouldn't be here
254 properties.put(org.onap.schema.validation.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
256 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
257 properties.forEach(insertVertexBuilder::property);
258 Vertex insertVertex = insertVertexBuilder.build();
260 OperationResult getResult = client.post(url, insertVertex.toJson(), createHeader(), MediaType.APPLICATION_JSON_TYPE,
261 MediaType.APPLICATION_JSON_TYPE);
263 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
266 // We didn't create a vertex with the supplied type, so just throw an
268 throw new CrudException("Failed to create vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
273 public OperationResult updateVertex(String id, String type, Map<String, Object> properties, String version) throws CrudException {
274 String url = baseObjectUrl + "/" + id;
276 // Add the aai_node_type so that AAI can read the data created by gizmo
277 // TODO: This probably shouldn't be here
278 properties.put(org.onap.schema.validation.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
280 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
281 insertVertexBuilder.id(id);
282 properties.forEach(insertVertexBuilder::property);
283 Vertex insertVertex = insertVertexBuilder.build();
285 String payload = insertVertex.toJson(champGson);
286 OperationResult getResult = client.put(url, payload, createHeader(), MediaType.APPLICATION_JSON_TYPE,
287 MediaType.APPLICATION_JSON_TYPE);
289 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
292 // We didn't create a vertex with the supplied type, so just throw an
294 throw new CrudException("Failed to update vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
299 public void deleteVertex(String id, String type) throws CrudException {
300 String url = baseObjectUrl + "/" + id;
301 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
303 if (getResult.getResultCode() != Response.Status.OK.getStatusCode()) {
304 // We didn't delete a vertex with the supplied id, so just throw an
306 throw new CrudException("Failed to delete vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
311 public OperationResult addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version) throws CrudException {
312 String url = baseRelationshipUrl;
314 // Try requests to ensure source and target exist in Champ
315 OperationResult dbSourceOpResult = getVertex(source.getId().get(), source.getType(), version, new HashMap<String, String>());
316 Vertex dbSource = Vertex.fromJson(dbSourceOpResult.getResult(), version);
317 OperationResult dbTargetOpResult = getVertex(target.getId().get(), target.getType(), version, new HashMap<String, String>());
318 Vertex dbTarget = Vertex.fromJson(dbTargetOpResult.getResult(), version);
320 Edge.Builder insertEdgeBuilder = new Edge.Builder(type).source(dbSource).target(dbTarget);
321 properties.forEach(insertEdgeBuilder::property);
322 Edge insertEdge = insertEdgeBuilder.build();
324 String edgeJson = insertEdge.toJson(champGson);
325 OperationResult getResult = client.post(url, edgeJson, createHeader(), MediaType.APPLICATION_JSON_TYPE,
326 MediaType.APPLICATION_JSON_TYPE);
328 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
331 // We didn't create an edge with the supplied type, so just throw an
333 throw new CrudException("Failed to create edge: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
338 public OperationResult updateEdge(Edge edge) throws CrudException {
339 if (!edge.getId().isPresent()) {
340 throw new CrudException("Unable to identify edge: " + edge.toString(), Response.Status.BAD_REQUEST);
342 String url = baseRelationshipUrl + "/" + edge.getId().get();
344 String edgeJson = edge.toJson(champGson);
345 OperationResult getResult = client.put(url, edgeJson, createHeader(), MediaType.APPLICATION_JSON_TYPE,
346 MediaType.APPLICATION_JSON_TYPE);
348 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
351 // We didn't create an edge with the supplied type, so just throw an
353 throw new CrudException("Failed to update edge: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
358 public void deleteEdge(String id) throws CrudException {
359 String url = baseRelationshipUrl + "/" + id;
360 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
362 if (getResult.getResultCode() != 200) {
363 // We didn't find an edge with the supplied type, so just throw an
365 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
370 public String openTransaction() {
371 String url = baseTransactionUrl;
373 OperationResult getResult = client.post(url, "", createHeader(), MediaType.TEXT_PLAIN_TYPE, MediaType.TEXT_PLAIN_TYPE);
375 if (getResult.getResultCode() == 200) {
376 return getResult.getResult();
383 public void commitTransaction(String id) throws CrudException {
384 String url = baseTransactionUrl + "/" + id;
386 OperationResult getResult = client.put(url, "{\"method\": \"commit\"}", createHeader(), MediaType.APPLICATION_JSON_TYPE,
387 MediaType.TEXT_PLAIN_TYPE);
389 if (getResult.getResultCode() != 200) {
390 throw new CrudException("Unable to commit transaction",
391 Response.Status.fromStatusCode(getResult.getResultCode()));
396 public void rollbackTransaction(String id) throws CrudException {
397 String url = baseTransactionUrl + "/" + id;
399 OperationResult getResult = client.put(url, "{\"method\": \"rollback\"}", createHeader(), MediaType.APPLICATION_JSON_TYPE,
400 MediaType.TEXT_PLAIN_TYPE);
402 if (getResult.getResultCode() != 200) {
403 throw new CrudException("Unable to rollback transaction",
404 Response.Status.fromStatusCode(getResult.getResultCode()));
409 public boolean transactionExists(String id) throws CrudException {
410 String url = baseTransactionUrl + "/" + id;
411 Map<String, List<String>> headers = new HashMap<>();
412 headers.put(HEADER_FROM_APP, Arrays.asList("Gizmo"));
413 headers.put(HEADER_TRANS_ID, Arrays.asList(MDC.get(MdcContext.MDC_REQUEST_ID)));
415 OperationResult getResult = client.get(url, headers, MediaType.APPLICATION_JSON_TYPE);
417 return getResult.getResultCode() == 200;
421 public Vertex addVertex(String type, Map<String, Object> properties, String version, String txId) throws CrudException {
422 String url = baseObjectUrl + "?transactionId=" + txId;
424 // Add the aai_node_type so that AAI can read the data created by gizmo
425 // TODO: This probably shouldn't be here
426 properties.put(org.onap.schema.validation.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
428 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
429 properties.forEach(insertVertexBuilder::property);
430 Vertex insertVertex = insertVertexBuilder.build();
432 OperationResult getResult = client.post(url, insertVertex.toJson(), createHeader(), MediaType.APPLICATION_JSON_TYPE,
433 MediaType.APPLICATION_JSON_TYPE);
435 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
436 return Vertex.fromJson(getResult.getResult(), version);
438 // We didn't create a vertex with the supplied type, so just throw an
440 throw new CrudException("Failed to create vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
445 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version, String txId)
446 throws CrudException {
447 String url = baseRelationshipUrl + "?transactionId=" + txId;
449 // Try requests to ensure source and target exist in Champ
450 Vertex dbSource = getVertex(source.getId().get(), source.getType(), version, txId);
451 Vertex dbTarget = getVertex(target.getId().get(), target.getType(), version, txId);
453 Edge.Builder insertEdgeBuilder = new Edge.Builder(type).source(dbSource).target(dbTarget);
454 properties.forEach(insertEdgeBuilder::property);
455 Edge insertEdge = insertEdgeBuilder.build();
457 OperationResult getResult = client.post(url, insertEdge.toJson(champGson), createHeader(),
458 MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_JSON_TYPE);
460 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
461 return Edge.fromJson(getResult.getResult());
463 // We didn't create an edge with the supplied type, so just throw an
465 throw new CrudException("Failed to create edge: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
470 public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version, String txId) throws CrudException {
471 String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
473 // Add the aai_node_type so that AAI can read the data created by gizmo
474 // TODO: This probably shouldn't be here
475 properties.put(org.onap.schema.validation.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
477 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
478 insertVertexBuilder.id(id);
479 properties.forEach(insertVertexBuilder::property);
480 Vertex insertVertex = insertVertexBuilder.build();
482 String payload = insertVertex.toJson(champGson);
483 OperationResult getResult = client.put(url, payload, createHeader(), MediaType.APPLICATION_JSON_TYPE,
484 MediaType.APPLICATION_JSON_TYPE);
486 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
487 return Vertex.fromJson(getResult.getResult(), version);
489 // We didn't create a vertex with the supplied type, so just throw an
491 throw new CrudException("Failed to update vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
496 public void deleteVertex(String id, String type, String txId) throws CrudException {
497 String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
498 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
500 if (getResult.getResultCode() != Response.Status.OK.getStatusCode()) {
501 // We didn't delete a vertex with the supplied id, so just throw an
503 throw new CrudException("Failed to delete vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
508 public Edge updateEdge(Edge edge, String txId) throws CrudException {
509 if (!edge.getId().isPresent()) {
510 throw new CrudException("Unable to identify edge: " + edge.toString(), Response.Status.BAD_REQUEST);
512 String url = baseRelationshipUrl + "/" + edge.getId().get() + "?transactionId=" + txId;
513 OperationResult getResult = client.put(url, edge.toJson(champGson), createHeader(), MediaType.APPLICATION_JSON_TYPE,
514 MediaType.APPLICATION_JSON_TYPE);
516 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
517 return Edge.fromJson(getResult.getResult());
519 // We didn't create an edge with the supplied type, so just throw an
521 throw new CrudException("Failed to update edge: " + getResult.getFailureCause(),
522 Response.Status.fromStatusCode(getResult.getResultCode()));
527 public void deleteEdge(String id, String txId) throws CrudException {
528 String url = baseRelationshipUrl + "/" + id + "?transactionId=" + txId;
529 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
531 if (getResult.getResultCode() != 200) {
532 // We didn't find an edge with the supplied type, so just throw an
534 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
539 public Edge getEdge(String id, String txId) throws CrudException {
540 String url = baseRelationshipUrl + "/" + id + "?transactionId=" + txId;
541 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
543 if (getResult.getResultCode() == 200) {
544 Edge edge = Edge.fromJson(getResult.getResult());
547 // We didn't find an edge with the supplied id, so just throw an
549 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
554 public Edge getEdge(String id) throws CrudException {
555 String url = baseRelationshipUrl + "/" + id;
556 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
558 if (getResult.getResultCode() == 200) {
559 Edge edge = Edge.fromJson(getResult.getResult());
562 // We didn't find an edge with the supplied id, so just throw an exception.
563 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
567 public Vertex getVertex(String id, String type, String version, String txId) throws CrudException {
568 String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
569 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
571 if (getResult.getResultCode() == 200) {
572 Vertex vert = Vertex.fromJson(getResult.getResult(), version);
574 if (!vert.getType().equalsIgnoreCase(type)) {
575 // We didn't find a vertex with the supplied type, so just throw an
577 throw new CrudException("No vertex with id " + id + " and type " + type + " found in graph",
578 javax.ws.rs.core.Response.Status.NOT_FOUND);
582 // We didn't find a vertex with the supplied id, so just throw an
584 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
588 // https://stackoverflow.com/questions/26942330/convert-mapstring-string-to-listnamevaluepair-is-this-the-most-efficient
589 private List<NameValuePair> convertToNameValuePair(Map<String, ? super String> pairs) {
590 List<NameValuePair> nvpList = new ArrayList<>(pairs.size());
592 pairs.forEach((key, value) -> nvpList.add(new BasicNameValuePair(key, value.toString())));
597 // https://stackoverflow.com/questions/26942330/convert-mapstring-string-to-listnamevaluepair-is-this-the-most-efficient
598 private List<NameValuePair> convertToNameValuePair(String k, Set<String> values) {
599 List<NameValuePair> nvpList = new ArrayList<>(values.size());
601 values.forEach((v) -> nvpList.add(new BasicNameValuePair(k, v)));
606 private Map<String, List<String>> createHeader() {
607 Map<String, List<String>> headers = new HashMap<>();
608 headers.put(HEADER_FROM_APP, Arrays.asList(FROM_APP_NAME));
609 headers.put(HEADER_TRANS_ID, Arrays.asList(MDC.get(MdcContext.MDC_REQUEST_ID)));
613 private CrudException createErrorException(OperationResult result, javax.ws.rs.core.Response.Status defaultErrorCode , String defaultErrorMsg)
615 CrudException ce = null;
617 ce = new CrudException(result.getFailureCause(), Response.Status.fromStatusCode(result.getResultCode()));
619 ce = new CrudException(defaultErrorMsg, defaultErrorCode);