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 net.dongliu.gson.GsonJava8TypeAdapterFactory;
25 import com.google.gson.Gson;
26 import com.google.gson.GsonBuilder;
27 import com.google.gson.reflect.TypeToken;
29 import org.apache.http.NameValuePair;
30 import org.apache.http.client.utils.URLEncodedUtils;
31 import org.apache.http.message.BasicNameValuePair;
32 import org.eclipse.jetty.util.security.Password;
33 import org.onap.aai.logging.LoggingContext;
34 import org.onap.aai.cl.api.Logger;
35 import org.onap.aai.cl.eelf.LoggerFactory;
36 import org.onap.crud.dao.GraphDao;
37 import org.onap.crud.entity.Edge;
38 import org.onap.crud.entity.Vertex;
39 import org.onap.crud.exception.CrudException;
40 import org.onap.crud.util.CrudServiceConstants;
41 import org.onap.aai.restclient.client.OperationResult;
42 import org.onap.aai.restclient.client.RestClient;
43 import org.onap.aai.restclient.enums.RestAuthenticationMode;
46 import java.nio.charset.Charset;
47 import java.util.ArrayList;
48 import java.util.Arrays;
49 import java.util.HashMap;
50 import java.util.HashSet;
51 import java.util.List;
53 import javax.ws.rs.core.MediaType;
54 import javax.ws.rs.core.Response;
56 public class ChampDao implements GraphDao {
57 protected RestClient client;
58 protected String baseObjectUrl;
59 protected String baseRelationshipUrl;
60 protected String baseTransactionUrl;
62 protected static final String HEADER_FROM_APP = "X-FromAppId";
63 protected static final String HEADER_TRANS_ID = "X-TransactionId";
64 protected static final String FROM_APP_NAME = "Gizmo";
65 protected static final String OBJECT_SUB_URL = "objects";
66 protected static final String RELATIONSHIP_SUB_URL = "relationships";
67 protected static final String TRANSACTION_SUB_URL = "transaction";
69 private Logger logger = LoggerFactory.getInstance().getLogger(ChampDao.class.getName());
71 // We use a custom vertex serializer for champ because it expects "key"
73 protected static final Gson champGson = new GsonBuilder()
74 .registerTypeAdapterFactory(new GsonJava8TypeAdapterFactory())
75 .registerTypeAdapter(Vertex.class, new ChampVertexSerializer())
76 .registerTypeAdapter(Edge.class, new ChampEdgeSerializer()).create();
81 public ChampDao(String champUrl, String certPassword) {
83 client = new RestClient().authenticationMode(RestAuthenticationMode.SSL_CERT).validateServerHostname(false)
84 .validateServerCertChain(false).clientCertFile(CrudServiceConstants.CRD_CHAMP_AUTH_FILE)
85 .clientCertPassword(Password.deobfuscate(certPassword));
87 baseObjectUrl = champUrl + OBJECT_SUB_URL;
88 baseRelationshipUrl = champUrl + RELATIONSHIP_SUB_URL;
89 baseTransactionUrl = champUrl + TRANSACTION_SUB_URL;
90 } catch (Exception e) {
91 System.out.println("Error setting up Champ configuration");
97 public ChampDao(RestClient client, String baseObjectUrl, String baseRelationshipUrl, String baseTransactionUrl) {
99 this.baseObjectUrl = baseObjectUrl;
100 this.baseRelationshipUrl = baseRelationshipUrl;
101 this.baseTransactionUrl = baseTransactionUrl;
105 public Vertex getVertex(String id, String version) throws CrudException {
106 String url = baseObjectUrl + "/" + id;
107 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
109 if (getResult.getResultCode() == 200) {
110 return Vertex.fromJson(getResult.getResult(), version);
112 // We didn't find a vertex with the supplied id, so just throw an
114 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
119 public Vertex getVertex(String id, String type, String version, Map<String, String> queryParams) throws CrudException {
120 StringBuilder strBuild = new StringBuilder(baseObjectUrl);
121 strBuild.append("/");
123 if(queryParams != null && !queryParams.isEmpty())
125 strBuild.append("?");
126 strBuild.append(URLEncodedUtils.format(convertToNameValuePair(queryParams), Charset.defaultCharset()));
129 OperationResult getResult = client.get(strBuild.toString(), createHeader(), MediaType.APPLICATION_JSON_TYPE);
131 if (getResult.getResultCode() == 200) {
132 Vertex vert = Vertex.fromJson(getResult.getResult(), version);
134 if (!vert.getType().equalsIgnoreCase(type)) {
135 // We didn't find a vertex with the supplied type, so just throw an
137 throw new CrudException("No vertex with id " + id + "and type " + type + " found in graph",
138 javax.ws.rs.core.Response.Status.NOT_FOUND);
142 // We didn't find a vertex with the supplied id, so just throw an
144 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
149 public List<Edge> getVertexEdges(String id, Map<String, String> queryParams) throws CrudException {
150 StringBuilder strBuild = new StringBuilder(baseObjectUrl);
151 strBuild.append("/relationships/");
153 if(queryParams != null && !queryParams.isEmpty())
155 strBuild.append("?");
156 strBuild.append(URLEncodedUtils.format(convertToNameValuePair(queryParams), Charset.defaultCharset()));
159 OperationResult getResult = client.get(strBuild.toString(), createHeader(), MediaType.APPLICATION_JSON_TYPE);
161 if (getResult.getResultCode() == 200) {
162 return champGson.fromJson(getResult.getResult(), new TypeToken<List<Edge>>() {
165 // We didn't find a vertex with the supplied id, so just throw an
167 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
172 public List<Vertex> getVertices(String type, Map<String, Object> filter, String version) throws CrudException {
173 return getVertices(type, filter, new HashSet<String>(), version);
177 public List<Vertex> getVertices(String type, Map<String, Object> filter, HashSet<String> properties, String version) throws CrudException {
178 filter.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
180 List<NameValuePair> queryParams = convertToNameValuePair(filter);
181 queryParams.addAll(convertToNameValuePair("properties", properties));
182 String url = baseObjectUrl + "/filter" + "?"
183 + URLEncodedUtils.format(queryParams, Charset.defaultCharset());
185 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
187 if (getResult.getResultCode() == 200) {
188 return Vertex.collectionFromJson(getResult.getResult(), version);
190 // We didn't find a vertex with the supplied id, so just throw an
192 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertices found in graph for given filters");
197 public Edge getEdge(String id, String type, Map<String, String> queryParams) throws CrudException {
198 StringBuilder strBuild = new StringBuilder(baseRelationshipUrl);
199 strBuild.append("/");
201 if(queryParams != null && !queryParams.isEmpty())
203 strBuild.append("?");
204 strBuild.append(URLEncodedUtils.format(convertToNameValuePair(queryParams), Charset.defaultCharset()));
206 OperationResult getResult = client.get(strBuild.toString(), createHeader(), MediaType.APPLICATION_JSON_TYPE);
208 if (getResult.getResultCode() == 200) {
209 Edge edge = Edge.fromJson(getResult.getResult());
211 if (!edge.getType().equalsIgnoreCase(type)) {
212 // We didn't find an edge with the supplied type, so just throw an
214 throw new CrudException("No edge with id " + id + "and type " + type + " found in graph",
215 javax.ws.rs.core.Response.Status.NOT_FOUND);
219 // We didn't find a edge with the supplied type, so just throw an
221 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
226 public List<Edge> getEdges(String type, Map<String, Object> filter) throws CrudException {
227 String url = baseRelationshipUrl + "/filter" + "?"
228 + URLEncodedUtils.format(convertToNameValuePair(filter), Charset.defaultCharset());
230 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
232 if (getResult.getResultCode() == 200) {
233 return champGson.fromJson(getResult.getResult(), new TypeToken<List<Edge>>() {
236 // We didn't find a vertex with the supplied id, so just throw an
238 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edges found in graph for given filters");
243 public Vertex addVertex(String type, Map<String, Object> properties, String version) throws CrudException {
244 String url = baseObjectUrl;
246 // Add the aai_node_type so that AAI can read the data created by gizmo
247 // TODO: This probably shouldn't be here
248 properties.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
250 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
251 properties.forEach(insertVertexBuilder::property);
252 Vertex insertVertex = insertVertexBuilder.build();
254 OperationResult getResult = client.post(url, insertVertex.toJson(), createHeader(), MediaType.APPLICATION_JSON_TYPE,
255 MediaType.APPLICATION_JSON_TYPE);
257 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
258 return Vertex.fromJson(getResult.getResult(), version);
260 // We didn't create a vertex with the supplied type, so just throw an
262 throw new CrudException("Failed to create vertex", Response.Status.fromStatusCode(getResult.getResultCode()));
267 public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version) throws CrudException {
268 String url = baseObjectUrl + "/" + id;
270 // Add the aai_node_type so that AAI can read the data created by gizmo
271 // TODO: This probably shouldn't be here
272 properties.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
274 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
275 insertVertexBuilder.id(id);
276 properties.forEach(insertVertexBuilder::property);
277 Vertex insertVertex = insertVertexBuilder.build();
279 String payload = insertVertex.toJson(champGson);
280 OperationResult getResult = client.put(url, payload, createHeader(), MediaType.APPLICATION_JSON_TYPE,
281 MediaType.APPLICATION_JSON_TYPE);
283 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
284 return Vertex.fromJson(getResult.getResult(), version);
286 // We didn't create a vertex with the supplied type, so just throw an
288 throw new CrudException("Failed to update vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
293 public void deleteVertex(String id, String type) throws CrudException {
294 String url = baseObjectUrl + "/" + id;
295 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
297 if (getResult.getResultCode() != Response.Status.OK.getStatusCode()) {
298 // We didn't delete a vertex with the supplied id, so just throw an
300 throw new CrudException("Failed to delete vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
305 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version) throws CrudException {
306 String url = baseRelationshipUrl;
308 // Try requests to ensure source and target exist in Champ
309 Vertex dbSource = getVertex(source.getId().get(), source.getType(), version, new HashMap<String, String>());
310 Vertex dbTarget = getVertex(target.getId().get(), target.getType(), version, new HashMap<String, String>());
312 Edge.Builder insertEdgeBuilder = new Edge.Builder(type).source(dbSource).target(dbTarget);
313 properties.forEach(insertEdgeBuilder::property);
314 Edge insertEdge = insertEdgeBuilder.build();
316 String edgeJson = insertEdge.toJson(champGson);
317 OperationResult getResult = client.post(url, edgeJson, createHeader(), MediaType.APPLICATION_JSON_TYPE,
318 MediaType.APPLICATION_JSON_TYPE);
320 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
321 return Edge.fromJson(getResult.getResult());
323 // We didn't create an edge with the supplied type, so just throw an
325 throw new CrudException("Failed to create edge: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
330 public Edge updateEdge(Edge edge) throws CrudException {
331 if (!edge.getId().isPresent()) {
332 throw new CrudException("Unable to identify edge: " + edge.toString(), Response.Status.BAD_REQUEST);
334 String url = baseRelationshipUrl + "/" + edge.getId().get();
336 String edgeJson = edge.toJson(champGson);
337 OperationResult getResult = client.put(url, edgeJson, createHeader(), MediaType.APPLICATION_JSON_TYPE,
338 MediaType.APPLICATION_JSON_TYPE);
340 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
341 return Edge.fromJson(getResult.getResult());
343 // We didn't create an edge with the supplied type, so just throw an
345 throw new CrudException("Failed to update edge: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
350 public void deleteEdge(String id, String type) throws CrudException {
351 String url = baseRelationshipUrl + "/" + id;
352 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
354 if (getResult.getResultCode() != 200) {
355 // We didn't find an edge with the supplied type, so just throw an
357 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
362 public String openTransaction() {
363 String url = baseTransactionUrl;
365 OperationResult getResult = client.post(url, "", createHeader(), MediaType.TEXT_PLAIN_TYPE, MediaType.TEXT_PLAIN_TYPE);
367 if (getResult.getResultCode() == 200) {
368 return getResult.getResult();
375 public void commitTransaction(String id) throws CrudException {
376 String url = baseTransactionUrl + "/" + id;
378 OperationResult getResult = client.put(url, "{\"method\": \"commit\"}", createHeader(), MediaType.APPLICATION_JSON_TYPE,
379 MediaType.TEXT_PLAIN_TYPE);
381 if (getResult.getResultCode() != 200) {
382 throw new CrudException("Unable to commit transaction",
383 Response.Status.fromStatusCode(getResult.getResultCode()));
388 public void rollbackTransaction(String id) throws CrudException {
389 String url = baseTransactionUrl + "/" + id;
391 OperationResult getResult = client.put(url, "{\"method\": \"rollback\"}", createHeader(), MediaType.APPLICATION_JSON_TYPE,
392 MediaType.TEXT_PLAIN_TYPE);
394 if (getResult.getResultCode() != 200) {
395 throw new CrudException("Unable to rollback transaction",
396 Response.Status.fromStatusCode(getResult.getResultCode()));
401 public boolean transactionExists(String id) throws CrudException {
402 String url = baseTransactionUrl + "/" + id;
403 Map<String, List<String>> headers = new HashMap<>();
404 headers.put(HEADER_FROM_APP, Arrays.asList("Gizmo"));
405 headers.put(HEADER_TRANS_ID, Arrays.asList(MDC.get(LoggingContext.LoggingField.REQUEST_ID.toString())));
407 OperationResult getResult = client.get(url, headers, MediaType.APPLICATION_JSON_TYPE);
409 return getResult.getResultCode() == 200;
413 public Vertex addVertex(String type, Map<String, Object> properties, String version, String txId) throws CrudException {
414 String url = baseObjectUrl + "?transactionId=" + txId;
416 // Add the aai_node_type so that AAI can read the data created by gizmo
417 // TODO: This probably shouldn't be here
418 properties.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
420 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
421 properties.forEach(insertVertexBuilder::property);
422 Vertex insertVertex = insertVertexBuilder.build();
424 OperationResult getResult = client.post(url, insertVertex.toJson(), createHeader(), MediaType.APPLICATION_JSON_TYPE,
425 MediaType.APPLICATION_JSON_TYPE);
427 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
428 return Vertex.fromJson(getResult.getResult(), version);
430 // We didn't create a vertex with the supplied type, so just throw an
432 throw new CrudException("Failed to create vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
437 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version, String txId)
438 throws CrudException {
439 String url = baseRelationshipUrl + "?transactionId=" + txId;
441 // Try requests to ensure source and target exist in Champ
442 Vertex dbSource = getVertex(source.getId().get(), source.getType(), version, txId);
443 Vertex dbTarget = getVertex(target.getId().get(), target.getType(), version, txId);
445 Edge.Builder insertEdgeBuilder = new Edge.Builder(type).source(dbSource).target(dbTarget);
446 properties.forEach(insertEdgeBuilder::property);
447 Edge insertEdge = insertEdgeBuilder.build();
449 OperationResult getResult = client.post(url, insertEdge.toJson(champGson), createHeader(),
450 MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_JSON_TYPE);
452 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
453 return Edge.fromJson(getResult.getResult());
455 // We didn't create an edge with the supplied type, so just throw an
457 throw new CrudException("Failed to create edge: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
462 public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version, String txId) throws CrudException {
463 String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
465 // Add the aai_node_type so that AAI can read the data created by gizmo
466 // TODO: This probably shouldn't be here
467 properties.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
469 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
470 insertVertexBuilder.id(id);
471 properties.forEach(insertVertexBuilder::property);
472 Vertex insertVertex = insertVertexBuilder.build();
474 String payload = insertVertex.toJson(champGson);
475 OperationResult getResult = client.put(url, payload, createHeader(), MediaType.APPLICATION_JSON_TYPE,
476 MediaType.APPLICATION_JSON_TYPE);
478 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
479 return Vertex.fromJson(getResult.getResult(), version);
481 // We didn't create a vertex with the supplied type, so just throw an
483 throw new CrudException("Failed to update vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
488 public void deleteVertex(String id, String type, String txId) throws CrudException {
489 String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
490 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
492 if (getResult.getResultCode() != Response.Status.OK.getStatusCode()) {
493 // We didn't delete a vertex with the supplied id, so just throw an
495 throw new CrudException("Failed to delete vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
500 public Edge updateEdge(Edge edge, String txId) throws CrudException {
501 if (!edge.getId().isPresent()) {
502 throw new CrudException("Unable to identify edge: " + edge.toString(), Response.Status.BAD_REQUEST);
504 String url = baseRelationshipUrl + "/" + edge.getId().get() + "?transactionId=" + txId;
505 OperationResult getResult = client.put(url, edge.toJson(champGson), createHeader(), MediaType.APPLICATION_JSON_TYPE,
506 MediaType.APPLICATION_JSON_TYPE);
508 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
509 return Edge.fromJson(getResult.getResult());
511 // We didn't create an edge with the supplied type, so just throw an
513 throw new CrudException("Failed to update edge: " + getResult.getFailureCause(),
514 Response.Status.fromStatusCode(getResult.getResultCode()));
519 public void deleteEdge(String id, String type, String txId) throws CrudException {
520 String url = baseRelationshipUrl + "/" + id + "?transactionId=" + txId;
521 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
523 if (getResult.getResultCode() != 200) {
524 // We didn't find an edge with the supplied type, so just throw an
526 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
531 public Edge getEdge(String id, String type, String txId) throws CrudException {
532 String url = baseRelationshipUrl + "/" + id + "?transactionId=" + txId;
533 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
535 if (getResult.getResultCode() == 200) {
536 Edge edge = Edge.fromJson(getResult.getResult());
538 if (!edge.getType().equalsIgnoreCase(type)) {
539 // We didn't find an edge with the supplied type, so just throw an
541 throw new CrudException("No edge with id " + id + "and type " + type + " found in graph",
542 javax.ws.rs.core.Response.Status.NOT_FOUND);
546 // We didn't find an edge with the supplied id, so just throw an
548 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
552 public Vertex getVertex(String id, String type, String version, String txId) throws CrudException {
553 String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
554 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
556 if (getResult.getResultCode() == 200) {
557 Vertex vert = Vertex.fromJson(getResult.getResult(), version);
559 if (!vert.getType().equalsIgnoreCase(type)) {
560 // We didn't find a vertex with the supplied type, so just throw an
562 throw new CrudException("No vertex with id " + id + "and type " + type + " found in graph",
563 javax.ws.rs.core.Response.Status.NOT_FOUND);
567 // We didn't find a vertex with the supplied id, so just throw an
569 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
573 // https://stackoverflow.com/questions/26942330/convert-mapstring-string-to-listnamevaluepair-is-this-the-most-efficient
574 private List<NameValuePair> convertToNameValuePair(Map<String, ? super String> pairs) {
575 List<NameValuePair> nvpList = new ArrayList<>(pairs.size());
577 pairs.forEach((key, value) -> nvpList.add(new BasicNameValuePair(key, value.toString())));
582 // https://stackoverflow.com/questions/26942330/convert-mapstring-string-to-listnamevaluepair-is-this-the-most-efficient
583 private List<NameValuePair> convertToNameValuePair(String key, HashSet<String> values) {
584 List<NameValuePair> nvpList = new ArrayList<>(values.size());
586 values.forEach((value) -> nvpList.add(new BasicNameValuePair(key, value)));
591 private Map<String, List<String>> createHeader() {
592 Map<String, List<String>> headers = new HashMap<>();
593 headers.put(HEADER_FROM_APP, Arrays.asList(FROM_APP_NAME));
594 headers.put(HEADER_TRANS_ID, Arrays.asList(MDC.get(LoggingContext.LoggingField.REQUEST_ID.toString())));
598 private CrudException createErrorException(OperationResult result, javax.ws.rs.core.Response.Status defaultErrorCode , String defaultErrorMsg)
600 CrudException ce = null;
602 ce = new CrudException(result.getFailureCause(), Response.Status.fromStatusCode(result.getResultCode()));
604 ce = new CrudException(defaultErrorMsg, defaultErrorCode);