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.cl.mdc.MdcContext;
34 import org.onap.aai.logging.LoggingContext;
35 import org.onap.aai.cl.api.Logger;
36 import org.onap.aai.cl.eelf.LoggerFactory;
37 import org.onap.crud.dao.GraphDao;
38 import org.onap.crud.entity.Edge;
39 import org.onap.crud.entity.Vertex;
40 import org.onap.crud.exception.CrudException;
41 import org.onap.crud.util.CrudServiceConstants;
42 import org.onap.aai.restclient.client.OperationResult;
43 import org.onap.aai.restclient.client.RestClient;
44 import org.onap.aai.restclient.enums.RestAuthenticationMode;
47 import java.nio.charset.Charset;
48 import java.util.ArrayList;
49 import java.util.Arrays;
50 import java.util.HashMap;
51 import java.util.HashSet;
52 import java.util.List;
54 import javax.ws.rs.core.MediaType;
55 import javax.ws.rs.core.Response;
57 public class ChampDao implements GraphDao {
58 protected RestClient client;
59 protected String baseObjectUrl;
60 protected String baseRelationshipUrl;
61 protected String baseTransactionUrl;
63 protected static final String HEADER_FROM_APP = "X-FromAppId";
64 protected static final String HEADER_TRANS_ID = "X-TransactionId";
65 protected static final String FROM_APP_NAME = "Gizmo";
66 protected static final String OBJECT_SUB_URL = "objects";
67 protected static final String RELATIONSHIP_SUB_URL = "relationships";
68 protected static final String TRANSACTION_SUB_URL = "transaction";
70 private Logger logger = LoggerFactory.getInstance().getLogger(ChampDao.class.getName());
72 // We use a custom vertex serializer for champ because it expects "key"
74 protected static final Gson champGson = new GsonBuilder()
75 .registerTypeAdapterFactory(new GsonJava8TypeAdapterFactory())
76 .registerTypeAdapter(Vertex.class, new ChampVertexSerializer())
77 .registerTypeAdapter(Edge.class, new ChampEdgeSerializer()).create();
82 public ChampDao(String champUrl, String certPassword) {
84 client = new RestClient().authenticationMode(RestAuthenticationMode.SSL_CERT).validateServerHostname(false)
85 .validateServerCertChain(false).clientCertFile(CrudServiceConstants.CRD_CHAMP_AUTH_FILE)
86 .clientCertPassword(Password.deobfuscate(certPassword));
88 baseObjectUrl = champUrl + OBJECT_SUB_URL;
89 baseRelationshipUrl = champUrl + RELATIONSHIP_SUB_URL;
90 baseTransactionUrl = champUrl + TRANSACTION_SUB_URL;
91 } catch (Exception e) {
92 System.out.println("Error setting up Champ configuration");
98 public ChampDao(RestClient client, String baseObjectUrl, String baseRelationshipUrl, String baseTransactionUrl) {
100 this.baseObjectUrl = baseObjectUrl;
101 this.baseRelationshipUrl = baseRelationshipUrl;
102 this.baseTransactionUrl = baseTransactionUrl;
106 public Vertex getVertex(String id, String version) throws CrudException {
107 String url = baseObjectUrl + "/" + id;
108 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
110 if (getResult.getResultCode() == 200) {
111 return Vertex.fromJson(getResult.getResult(), version);
113 // We didn't find a vertex with the supplied id, so just throw an
115 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
120 public Vertex getVertex(String id, String type, String version, Map<String, String> queryParams) throws CrudException {
121 StringBuilder strBuild = new StringBuilder(baseObjectUrl);
122 strBuild.append("/");
124 if(queryParams != null && !queryParams.isEmpty())
126 strBuild.append("?");
127 strBuild.append(URLEncodedUtils.format(convertToNameValuePair(queryParams), Charset.defaultCharset()));
130 OperationResult getResult = client.get(strBuild.toString(), createHeader(), MediaType.APPLICATION_JSON_TYPE);
132 if (getResult.getResultCode() == 200) {
133 Vertex vert = Vertex.fromJson(getResult.getResult(), version);
135 if (!vert.getType().equalsIgnoreCase(type)) {
136 // We didn't find a vertex with the supplied type, so just throw an
138 throw new CrudException("No vertex with id " + id + "and type " + type + " found in graph",
139 javax.ws.rs.core.Response.Status.NOT_FOUND);
143 // We didn't find a vertex with the supplied id, so just throw an
145 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
150 public List<Edge> getVertexEdges(String id, Map<String, String> queryParams) throws CrudException {
151 StringBuilder strBuild = new StringBuilder(baseObjectUrl);
152 strBuild.append("/relationships/");
154 if(queryParams != null && !queryParams.isEmpty())
156 strBuild.append("?");
157 strBuild.append(URLEncodedUtils.format(convertToNameValuePair(queryParams), Charset.defaultCharset()));
160 OperationResult getResult = client.get(strBuild.toString(), createHeader(), MediaType.APPLICATION_JSON_TYPE);
162 if (getResult.getResultCode() == 200) {
163 return champGson.fromJson(getResult.getResult(), new TypeToken<List<Edge>>() {
166 // We didn't find a vertex with the supplied id, so just throw an
168 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
173 public List<Vertex> getVertices(String type, Map<String, Object> filter, String version) throws CrudException {
174 return getVertices(type, filter, new HashSet<String>(), version);
178 public List<Vertex> getVertices(String type, Map<String, Object> filter, HashSet<String> properties, String version) throws CrudException {
179 filter.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
181 List<NameValuePair> queryParams = convertToNameValuePair(filter);
182 queryParams.addAll(convertToNameValuePair("properties", properties));
183 String url = baseObjectUrl + "/filter" + "?"
184 + URLEncodedUtils.format(queryParams, Charset.defaultCharset());
186 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
188 if (getResult.getResultCode() == 200) {
189 return Vertex.collectionFromJson(getResult.getResult(), version);
191 // We didn't find a vertex with the supplied id, so just throw an
193 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertices found in graph for given filters");
198 public Edge getEdge(String id, String type, Map<String, String> queryParams) throws CrudException {
199 StringBuilder strBuild = new StringBuilder(baseRelationshipUrl);
200 strBuild.append("/");
202 if(queryParams != null && !queryParams.isEmpty())
204 strBuild.append("?");
205 strBuild.append(URLEncodedUtils.format(convertToNameValuePair(queryParams), Charset.defaultCharset()));
207 OperationResult getResult = client.get(strBuild.toString(), createHeader(), MediaType.APPLICATION_JSON_TYPE);
209 if (getResult.getResultCode() == 200) {
210 Edge edge = Edge.fromJson(getResult.getResult());
212 if (!edge.getType().equalsIgnoreCase(type)) {
213 // We didn't find an edge with the supplied type, so just throw an
215 throw new CrudException("No edge with id " + id + "and type " + type + " found in graph",
216 javax.ws.rs.core.Response.Status.NOT_FOUND);
220 // We didn't find a edge with the supplied type, so just throw an
222 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
227 public List<Edge> getEdges(String type, Map<String, Object> filter) throws CrudException {
228 String url = baseRelationshipUrl + "/filter" + "?"
229 + URLEncodedUtils.format(convertToNameValuePair(filter), Charset.defaultCharset());
231 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
233 if (getResult.getResultCode() == 200) {
234 return champGson.fromJson(getResult.getResult(), new TypeToken<List<Edge>>() {
237 // We didn't find a vertex with the supplied id, so just throw an
239 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edges found in graph for given filters");
244 public Vertex addVertex(String type, Map<String, Object> properties, String version) throws CrudException {
245 String url = baseObjectUrl;
247 // Add the aai_node_type so that AAI can read the data created by gizmo
248 // TODO: This probably shouldn't be here
249 properties.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
251 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
252 properties.forEach(insertVertexBuilder::property);
253 Vertex insertVertex = insertVertexBuilder.build();
255 OperationResult getResult = client.post(url, insertVertex.toJson(), createHeader(), MediaType.APPLICATION_JSON_TYPE,
256 MediaType.APPLICATION_JSON_TYPE);
258 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
259 return Vertex.fromJson(getResult.getResult(), version);
261 // We didn't create a vertex with the supplied type, so just throw an
263 throw new CrudException("Failed to create vertex", Response.Status.fromStatusCode(getResult.getResultCode()));
268 public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version) throws CrudException {
269 String url = baseObjectUrl + "/" + id;
271 // Add the aai_node_type so that AAI can read the data created by gizmo
272 // TODO: This probably shouldn't be here
273 properties.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
275 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
276 insertVertexBuilder.id(id);
277 properties.forEach(insertVertexBuilder::property);
278 Vertex insertVertex = insertVertexBuilder.build();
280 String payload = insertVertex.toJson(champGson);
281 OperationResult getResult = client.put(url, payload, createHeader(), MediaType.APPLICATION_JSON_TYPE,
282 MediaType.APPLICATION_JSON_TYPE);
284 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
285 return Vertex.fromJson(getResult.getResult(), version);
287 // We didn't create a vertex with the supplied type, so just throw an
289 throw new CrudException("Failed to update vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
294 public void deleteVertex(String id, String type) throws CrudException {
295 String url = baseObjectUrl + "/" + id;
296 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
298 if (getResult.getResultCode() != Response.Status.OK.getStatusCode()) {
299 // We didn't delete a vertex with the supplied id, so just throw an
301 throw new CrudException("Failed to delete vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
306 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version) throws CrudException {
307 String url = baseRelationshipUrl;
309 // Try requests to ensure source and target exist in Champ
310 Vertex dbSource = getVertex(source.getId().get(), source.getType(), version, new HashMap<String, String>());
311 Vertex dbTarget = getVertex(target.getId().get(), target.getType(), version, new HashMap<String, String>());
313 Edge.Builder insertEdgeBuilder = new Edge.Builder(type).source(dbSource).target(dbTarget);
314 properties.forEach(insertEdgeBuilder::property);
315 Edge insertEdge = insertEdgeBuilder.build();
317 String edgeJson = insertEdge.toJson(champGson);
318 OperationResult getResult = client.post(url, edgeJson, createHeader(), MediaType.APPLICATION_JSON_TYPE,
319 MediaType.APPLICATION_JSON_TYPE);
321 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
322 return Edge.fromJson(getResult.getResult());
324 // We didn't create an edge with the supplied type, so just throw an
326 throw new CrudException("Failed to create edge: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
331 public Edge updateEdge(Edge edge) throws CrudException {
332 if (!edge.getId().isPresent()) {
333 throw new CrudException("Unable to identify edge: " + edge.toString(), Response.Status.BAD_REQUEST);
335 String url = baseRelationshipUrl + "/" + edge.getId().get();
337 String edgeJson = edge.toJson(champGson);
338 OperationResult getResult = client.put(url, edgeJson, createHeader(), MediaType.APPLICATION_JSON_TYPE,
339 MediaType.APPLICATION_JSON_TYPE);
341 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
342 return Edge.fromJson(getResult.getResult());
344 // We didn't create an edge with the supplied type, so just throw an
346 throw new CrudException("Failed to update edge: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
351 public void deleteEdge(String id, String type) throws CrudException {
352 String url = baseRelationshipUrl + "/" + id;
353 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
355 if (getResult.getResultCode() != 200) {
356 // We didn't find an edge with the supplied type, so just throw an
358 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
363 public String openTransaction() {
364 String url = baseTransactionUrl;
366 OperationResult getResult = client.post(url, "", createHeader(), MediaType.TEXT_PLAIN_TYPE, MediaType.TEXT_PLAIN_TYPE);
368 if (getResult.getResultCode() == 200) {
369 return getResult.getResult();
376 public void commitTransaction(String id) throws CrudException {
377 String url = baseTransactionUrl + "/" + id;
379 OperationResult getResult = client.put(url, "{\"method\": \"commit\"}", createHeader(), MediaType.APPLICATION_JSON_TYPE,
380 MediaType.TEXT_PLAIN_TYPE);
382 if (getResult.getResultCode() != 200) {
383 throw new CrudException("Unable to commit transaction",
384 Response.Status.fromStatusCode(getResult.getResultCode()));
389 public void rollbackTransaction(String id) throws CrudException {
390 String url = baseTransactionUrl + "/" + id;
392 OperationResult getResult = client.put(url, "{\"method\": \"rollback\"}", createHeader(), MediaType.APPLICATION_JSON_TYPE,
393 MediaType.TEXT_PLAIN_TYPE);
395 if (getResult.getResultCode() != 200) {
396 throw new CrudException("Unable to rollback transaction",
397 Response.Status.fromStatusCode(getResult.getResultCode()));
402 public boolean transactionExists(String id) throws CrudException {
403 String url = baseTransactionUrl + "/" + id;
404 Map<String, List<String>> headers = new HashMap<>();
405 headers.put(HEADER_FROM_APP, Arrays.asList("Gizmo"));
406 headers.put(HEADER_TRANS_ID, Arrays.asList(MDC.get(LoggingContext.LoggingField.REQUEST_ID.toString())));
408 OperationResult getResult = client.get(url, headers, MediaType.APPLICATION_JSON_TYPE);
410 return getResult.getResultCode() == 200;
414 public Vertex addVertex(String type, Map<String, Object> properties, String version, String txId) throws CrudException {
415 String url = baseObjectUrl + "?transactionId=" + txId;
417 // Add the aai_node_type so that AAI can read the data created by gizmo
418 // TODO: This probably shouldn't be here
419 properties.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
421 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
422 properties.forEach(insertVertexBuilder::property);
423 Vertex insertVertex = insertVertexBuilder.build();
425 OperationResult getResult = client.post(url, insertVertex.toJson(), createHeader(), MediaType.APPLICATION_JSON_TYPE,
426 MediaType.APPLICATION_JSON_TYPE);
428 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
429 return Vertex.fromJson(getResult.getResult(), version);
431 // We didn't create a vertex with the supplied type, so just throw an
433 throw new CrudException("Failed to create vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
438 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version, String txId)
439 throws CrudException {
440 String url = baseRelationshipUrl + "?transactionId=" + txId;
442 // Try requests to ensure source and target exist in Champ
443 Vertex dbSource = getVertex(source.getId().get(), source.getType(), version, txId);
444 Vertex dbTarget = getVertex(target.getId().get(), target.getType(), version, txId);
446 Edge.Builder insertEdgeBuilder = new Edge.Builder(type).source(dbSource).target(dbTarget);
447 properties.forEach(insertEdgeBuilder::property);
448 Edge insertEdge = insertEdgeBuilder.build();
450 OperationResult getResult = client.post(url, insertEdge.toJson(champGson), createHeader(),
451 MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_JSON_TYPE);
453 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
454 return Edge.fromJson(getResult.getResult());
456 // We didn't create an edge with the supplied type, so just throw an
458 throw new CrudException("Failed to create edge: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
463 public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version, String txId) throws CrudException {
464 String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
466 // Add the aai_node_type so that AAI can read the data created by gizmo
467 // TODO: This probably shouldn't be here
468 properties.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
470 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
471 insertVertexBuilder.id(id);
472 properties.forEach(insertVertexBuilder::property);
473 Vertex insertVertex = insertVertexBuilder.build();
475 String payload = insertVertex.toJson(champGson);
476 OperationResult getResult = client.put(url, payload, createHeader(), MediaType.APPLICATION_JSON_TYPE,
477 MediaType.APPLICATION_JSON_TYPE);
479 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
480 return Vertex.fromJson(getResult.getResult(), version);
482 // We didn't create a vertex with the supplied type, so just throw an
484 throw new CrudException("Failed to update vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
489 public void deleteVertex(String id, String type, String txId) throws CrudException {
490 String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
491 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
493 if (getResult.getResultCode() != Response.Status.OK.getStatusCode()) {
494 // We didn't delete a vertex with the supplied id, so just throw an
496 throw new CrudException("Failed to delete vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
501 public Edge updateEdge(Edge edge, String txId) throws CrudException {
502 if (!edge.getId().isPresent()) {
503 throw new CrudException("Unable to identify edge: " + edge.toString(), Response.Status.BAD_REQUEST);
505 String url = baseRelationshipUrl + "/" + edge.getId().get() + "?transactionId=" + txId;
506 OperationResult getResult = client.put(url, edge.toJson(champGson), createHeader(), MediaType.APPLICATION_JSON_TYPE,
507 MediaType.APPLICATION_JSON_TYPE);
509 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
510 return Edge.fromJson(getResult.getResult());
512 // We didn't create an edge with the supplied type, so just throw an
514 throw new CrudException("Failed to update edge: " + getResult.getFailureCause(),
515 Response.Status.fromStatusCode(getResult.getResultCode()));
520 public void deleteEdge(String id, String type, String txId) throws CrudException {
521 String url = baseRelationshipUrl + "/" + id + "?transactionId=" + txId;
522 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
524 if (getResult.getResultCode() != 200) {
525 // We didn't find an edge with the supplied type, so just throw an
527 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
532 public Edge getEdge(String id, String type, String txId) throws CrudException {
533 String url = baseRelationshipUrl + "/" + id + "?transactionId=" + txId;
534 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
536 if (getResult.getResultCode() == 200) {
537 Edge edge = Edge.fromJson(getResult.getResult());
539 if (!edge.getType().equalsIgnoreCase(type)) {
540 // We didn't find an edge with the supplied type, so just throw an
542 throw new CrudException("No edge with id " + id + "and type " + type + " found in graph",
543 javax.ws.rs.core.Response.Status.NOT_FOUND);
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");
553 public Vertex getVertex(String id, String type, String version, String txId) throws CrudException {
554 String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
555 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
557 if (getResult.getResultCode() == 200) {
558 Vertex vert = Vertex.fromJson(getResult.getResult(), version);
560 if (!vert.getType().equalsIgnoreCase(type)) {
561 // We didn't find a vertex with the supplied type, so just throw an
563 throw new CrudException("No vertex with id " + id + "and type " + type + " found in graph",
564 javax.ws.rs.core.Response.Status.NOT_FOUND);
568 // We didn't find a vertex with the supplied id, so just throw an
570 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
574 // https://stackoverflow.com/questions/26942330/convert-mapstring-string-to-listnamevaluepair-is-this-the-most-efficient
575 private List<NameValuePair> convertToNameValuePair(Map<String, ? super String> pairs) {
576 List<NameValuePair> nvpList = new ArrayList<>(pairs.size());
578 pairs.forEach((key, value) -> nvpList.add(new BasicNameValuePair(key, value.toString())));
583 // https://stackoverflow.com/questions/26942330/convert-mapstring-string-to-listnamevaluepair-is-this-the-most-efficient
584 private List<NameValuePair> convertToNameValuePair(String key, HashSet<String> values) {
585 List<NameValuePair> nvpList = new ArrayList<>(values.size());
587 values.forEach((value) -> nvpList.add(new BasicNameValuePair(key, value)));
592 private Map<String, List<String>> createHeader() {
593 Map<String, List<String>> headers = new HashMap<>();
594 headers.put(HEADER_FROM_APP, Arrays.asList(FROM_APP_NAME));
595 headers.put(HEADER_TRANS_ID, Arrays.asList(MDC.get(MdcContext.MDC_REQUEST_ID)));
599 private CrudException createErrorException(OperationResult result, javax.ws.rs.core.Response.Status defaultErrorCode , String defaultErrorMsg)
601 CrudException ce = null;
603 ce = new CrudException(result.getFailureCause(), Response.Status.fromStatusCode(result.getResultCode()));
605 ce = new CrudException(defaultErrorMsg, defaultErrorCode);