2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
22 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
24 package org.onap.crud.dao.champ;
26 import net.dongliu.gson.GsonJava8TypeAdapterFactory;
28 import com.google.gson.Gson;
29 import com.google.gson.GsonBuilder;
30 import com.google.gson.reflect.TypeToken;
32 import org.apache.http.NameValuePair;
33 import org.apache.http.client.utils.URLEncodedUtils;
34 import org.apache.http.message.BasicNameValuePair;
35 import org.eclipse.jetty.util.security.Password;
36 import org.onap.aai.logging.LoggingContext;
37 import org.onap.aai.cl.api.Logger;
38 import org.onap.aai.cl.eelf.LoggerFactory;
39 import org.onap.crud.dao.GraphDao;
40 import org.onap.crud.entity.Edge;
41 import org.onap.crud.entity.Vertex;
42 import org.onap.crud.exception.CrudException;
43 import org.onap.crud.util.CrudServiceConstants;
44 import org.onap.aai.restclient.client.OperationResult;
45 import org.onap.aai.restclient.client.RestClient;
46 import org.onap.aai.restclient.enums.RestAuthenticationMode;
49 import java.nio.charset.Charset;
50 import java.util.ArrayList;
51 import java.util.Arrays;
52 import java.util.HashMap;
53 import java.util.HashSet;
54 import java.util.List;
56 import javax.ws.rs.core.MediaType;
57 import javax.ws.rs.core.Response;
59 public class ChampDao implements GraphDao {
60 protected RestClient client;
61 protected String baseObjectUrl;
62 protected String baseRelationshipUrl;
63 protected String baseTransactionUrl;
65 protected static final String HEADER_FROM_APP = "X-FromAppId";
66 protected static final String HEADER_TRANS_ID = "X-TransactionId";
67 protected static final String FROM_APP_NAME = "Gizmo";
68 protected static final String OBJECT_SUB_URL = "objects";
69 protected static final String RELATIONSHIP_SUB_URL = "relationships";
70 protected static final String TRANSACTION_SUB_URL = "transaction";
72 private Logger logger = LoggerFactory.getInstance().getLogger(ChampDao.class.getName());
74 // We use a custom vertex serializer for champ because it expects "key"
76 protected static final Gson champGson = new GsonBuilder()
77 .registerTypeAdapterFactory(new GsonJava8TypeAdapterFactory())
78 .registerTypeAdapter(Vertex.class, new ChampVertexSerializer())
79 .registerTypeAdapter(Edge.class, new ChampEdgeSerializer()).create();
84 public ChampDao(String champUrl, String certPassword) {
86 client = new RestClient().authenticationMode(RestAuthenticationMode.SSL_CERT).validateServerHostname(false)
87 .validateServerCertChain(false).clientCertFile(CrudServiceConstants.CRD_CHAMP_AUTH_FILE)
88 .clientCertPassword(Password.deobfuscate(certPassword));
90 baseObjectUrl = champUrl + OBJECT_SUB_URL;
91 baseRelationshipUrl = champUrl + RELATIONSHIP_SUB_URL;
92 baseTransactionUrl = champUrl + TRANSACTION_SUB_URL;
93 } catch (Exception e) {
94 System.out.println("Error setting up Champ configuration");
100 public ChampDao(RestClient client, String baseObjectUrl, String baseRelationshipUrl, String baseTransactionUrl) {
101 this.client = client;
102 this.baseObjectUrl = baseObjectUrl;
103 this.baseRelationshipUrl = baseRelationshipUrl;
104 this.baseTransactionUrl = baseTransactionUrl;
108 public Vertex getVertex(String id, String version) throws CrudException {
109 String url = baseObjectUrl + "/" + id;
110 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
112 if (getResult.getResultCode() == 200) {
113 return Vertex.fromJson(getResult.getResult(), version);
115 // We didn't find a vertex with the supplied id, so just throw an
117 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
122 public Vertex getVertex(String id, String type, String version, Map<String, String> queryParams) throws CrudException {
123 StringBuilder strBuild = new StringBuilder(baseObjectUrl);
124 strBuild.append("/");
126 if(queryParams != null && !queryParams.isEmpty())
128 strBuild.append("?");
129 strBuild.append(URLEncodedUtils.format(convertToNameValuePair(queryParams), Charset.defaultCharset()));
132 OperationResult getResult = client.get(strBuild.toString(), createHeader(), MediaType.APPLICATION_JSON_TYPE);
134 if (getResult.getResultCode() == 200) {
135 Vertex vert = Vertex.fromJson(getResult.getResult(), version);
137 if (!vert.getType().equalsIgnoreCase(type)) {
138 // We didn't find a vertex with the supplied type, so just throw an
140 throw new CrudException("No vertex with id " + id + "and type " + type + " found in graph",
141 javax.ws.rs.core.Response.Status.NOT_FOUND);
145 // We didn't find a vertex with the supplied id, so just throw an
147 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
152 public List<Edge> getVertexEdges(String id, Map<String, String> queryParams) throws CrudException {
153 StringBuilder strBuild = new StringBuilder(baseObjectUrl);
154 strBuild.append("/relationships/");
156 if(queryParams != null && !queryParams.isEmpty())
158 strBuild.append("?");
159 strBuild.append(URLEncodedUtils.format(convertToNameValuePair(queryParams), Charset.defaultCharset()));
162 OperationResult getResult = client.get(strBuild.toString(), createHeader(), MediaType.APPLICATION_JSON_TYPE);
164 if (getResult.getResultCode() == 200) {
165 return champGson.fromJson(getResult.getResult(), new TypeToken<List<Edge>>() {
168 // We didn't find a vertex with the supplied id, so just throw an
170 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
175 public List<Vertex> getVertices(String type, Map<String, Object> filter, String version) throws CrudException {
176 return getVertices(type, filter, new HashSet<String>(), version);
180 public List<Vertex> getVertices(String type, Map<String, Object> filter, HashSet<String> properties, String version) throws CrudException {
181 filter.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
183 List<NameValuePair> queryParams = convertToNameValuePair(filter);
184 queryParams.addAll(convertToNameValuePair("properties", properties));
185 String url = baseObjectUrl + "/filter" + "?"
186 + URLEncodedUtils.format(queryParams, Charset.defaultCharset());
188 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
190 if (getResult.getResultCode() == 200) {
191 return Vertex.collectionFromJson(getResult.getResult(), version);
193 // We didn't find a vertex with the supplied id, so just throw an
195 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertices found in graph for given filters");
200 public Edge getEdge(String id, String type, Map<String, String> queryParams) throws CrudException {
201 StringBuilder strBuild = new StringBuilder(baseRelationshipUrl);
202 strBuild.append("/");
204 if(queryParams != null && !queryParams.isEmpty())
206 strBuild.append("?");
207 strBuild.append(URLEncodedUtils.format(convertToNameValuePair(queryParams), Charset.defaultCharset()));
209 OperationResult getResult = client.get(strBuild.toString(), createHeader(), MediaType.APPLICATION_JSON_TYPE);
211 if (getResult.getResultCode() == 200) {
212 Edge edge = Edge.fromJson(getResult.getResult());
214 if (!edge.getType().equalsIgnoreCase(type)) {
215 // We didn't find an edge with the supplied type, so just throw an
217 throw new CrudException("No edge with id " + id + "and type " + type + " found in graph",
218 javax.ws.rs.core.Response.Status.NOT_FOUND);
222 // We didn't find a edge with the supplied type, so just throw an
224 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
229 public List<Edge> getEdges(String type, Map<String, Object> filter) throws CrudException {
230 String url = baseRelationshipUrl + "/filter" + "?"
231 + URLEncodedUtils.format(convertToNameValuePair(filter), Charset.defaultCharset());
233 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
235 if (getResult.getResultCode() == 200) {
236 return champGson.fromJson(getResult.getResult(), new TypeToken<List<Edge>>() {
239 // We didn't find a vertex with the supplied id, so just throw an
241 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edges found in graph for given filters");
246 public Vertex addVertex(String type, Map<String, Object> properties, String version) throws CrudException {
247 String url = baseObjectUrl;
249 // Add the aai_node_type so that AAI can read the data created by gizmo
250 // TODO: This probably shouldn't be here
251 properties.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
253 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
254 properties.forEach(insertVertexBuilder::property);
255 Vertex insertVertex = insertVertexBuilder.build();
257 OperationResult getResult = client.post(url, insertVertex.toJson(), createHeader(), MediaType.APPLICATION_JSON_TYPE,
258 MediaType.APPLICATION_JSON_TYPE);
260 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
261 return Vertex.fromJson(getResult.getResult(), version);
263 // We didn't create a vertex with the supplied type, so just throw an
265 throw new CrudException("Failed to create vertex", Response.Status.fromStatusCode(getResult.getResultCode()));
270 public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version) throws CrudException {
271 String url = baseObjectUrl + "/" + id;
273 // Add the aai_node_type so that AAI can read the data created by gizmo
274 // TODO: This probably shouldn't be here
275 properties.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
277 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
278 insertVertexBuilder.id(id);
279 properties.forEach(insertVertexBuilder::property);
280 Vertex insertVertex = insertVertexBuilder.build();
282 String payload = insertVertex.toJson(champGson);
283 OperationResult getResult = client.put(url, payload, createHeader(), MediaType.APPLICATION_JSON_TYPE,
284 MediaType.APPLICATION_JSON_TYPE);
286 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
287 return Vertex.fromJson(getResult.getResult(), version);
289 // We didn't create a vertex with the supplied type, so just throw an
291 throw new CrudException("Failed to update vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
296 public void deleteVertex(String id, String type) throws CrudException {
297 String url = baseObjectUrl + "/" + id;
298 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
300 if (getResult.getResultCode() != Response.Status.OK.getStatusCode()) {
301 // We didn't delete a vertex with the supplied id, so just throw an
303 throw new CrudException("Failed to delete vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
308 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version) throws CrudException {
309 String url = baseRelationshipUrl;
311 // Try requests to ensure source and target exist in Champ
312 Vertex dbSource = getVertex(source.getId().get(), source.getType(), version, new HashMap<String, String>());
313 Vertex dbTarget = getVertex(target.getId().get(), target.getType(), version, new HashMap<String, String>());
315 Edge.Builder insertEdgeBuilder = new Edge.Builder(type).source(dbSource).target(dbTarget);
316 properties.forEach(insertEdgeBuilder::property);
317 Edge insertEdge = insertEdgeBuilder.build();
319 String edgeJson = insertEdge.toJson(champGson);
320 OperationResult getResult = client.post(url, edgeJson, createHeader(), MediaType.APPLICATION_JSON_TYPE,
321 MediaType.APPLICATION_JSON_TYPE);
323 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
324 return Edge.fromJson(getResult.getResult());
326 // We didn't create an edge with the supplied type, so just throw an
328 throw new CrudException("Failed to create edge: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
333 public Edge updateEdge(Edge edge) throws CrudException {
334 if (!edge.getId().isPresent()) {
335 throw new CrudException("Unable to identify edge: " + edge.toString(), Response.Status.BAD_REQUEST);
337 String url = baseRelationshipUrl + "/" + edge.getId().get();
339 String edgeJson = edge.toJson(champGson);
340 OperationResult getResult = client.put(url, edgeJson, createHeader(), MediaType.APPLICATION_JSON_TYPE,
341 MediaType.APPLICATION_JSON_TYPE);
343 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
344 return Edge.fromJson(getResult.getResult());
346 // We didn't create an edge with the supplied type, so just throw an
348 throw new CrudException("Failed to update edge: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
353 public void deleteEdge(String id, String type) throws CrudException {
354 String url = baseRelationshipUrl + "/" + id;
355 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
357 if (getResult.getResultCode() != 200) {
358 // We didn't find an edge with the supplied type, so just throw an
360 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
365 public String openTransaction() {
366 String url = baseTransactionUrl;
368 OperationResult getResult = client.post(url, "", createHeader(), MediaType.TEXT_PLAIN_TYPE, MediaType.TEXT_PLAIN_TYPE);
370 if (getResult.getResultCode() == 200) {
371 return getResult.getResult();
378 public void commitTransaction(String id) throws CrudException {
379 String url = baseTransactionUrl + "/" + id;
381 OperationResult getResult = client.put(url, "{\"method\": \"commit\"}", createHeader(), MediaType.APPLICATION_JSON_TYPE,
382 MediaType.TEXT_PLAIN_TYPE);
384 if (getResult.getResultCode() != 200) {
385 throw new CrudException("Unable to commit transaction",
386 Response.Status.fromStatusCode(getResult.getResultCode()));
391 public void rollbackTransaction(String id) throws CrudException {
392 String url = baseTransactionUrl + "/" + id;
394 OperationResult getResult = client.put(url, "{\"method\": \"rollback\"}", createHeader(), MediaType.APPLICATION_JSON_TYPE,
395 MediaType.TEXT_PLAIN_TYPE);
397 if (getResult.getResultCode() != 200) {
398 throw new CrudException("Unable to rollback transaction",
399 Response.Status.fromStatusCode(getResult.getResultCode()));
404 public boolean transactionExists(String id) throws CrudException {
405 String url = baseTransactionUrl + "/" + id;
406 Map<String, List<String>> headers = new HashMap<>();
407 headers.put(HEADER_FROM_APP, Arrays.asList("Gizmo"));
408 headers.put(HEADER_TRANS_ID, Arrays.asList(MDC.get(LoggingContext.LoggingField.REQUEST_ID.toString())));
410 OperationResult getResult = client.get(url, headers, MediaType.APPLICATION_JSON_TYPE);
412 return getResult.getResultCode() == 200;
416 public Vertex addVertex(String type, Map<String, Object> properties, String version, String txId) throws CrudException {
417 String url = baseObjectUrl + "?transactionId=" + txId;
419 // Add the aai_node_type so that AAI can read the data created by gizmo
420 // TODO: This probably shouldn't be here
421 properties.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
423 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
424 properties.forEach(insertVertexBuilder::property);
425 Vertex insertVertex = insertVertexBuilder.build();
427 OperationResult getResult = client.post(url, insertVertex.toJson(), createHeader(), MediaType.APPLICATION_JSON_TYPE,
428 MediaType.APPLICATION_JSON_TYPE);
430 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
431 return Vertex.fromJson(getResult.getResult(), version);
433 // We didn't create a vertex with the supplied type, so just throw an
435 throw new CrudException("Failed to create vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
440 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version, String txId)
441 throws CrudException {
442 String url = baseRelationshipUrl + "?transactionId=" + txId;
444 // Try requests to ensure source and target exist in Champ
445 Vertex dbSource = getVertex(source.getId().get(), source.getType(), version, txId);
446 Vertex dbTarget = getVertex(target.getId().get(), target.getType(), version, txId);
448 Edge.Builder insertEdgeBuilder = new Edge.Builder(type).source(dbSource).target(dbTarget);
449 properties.forEach(insertEdgeBuilder::property);
450 Edge insertEdge = insertEdgeBuilder.build();
452 OperationResult getResult = client.post(url, insertEdge.toJson(champGson), createHeader(),
453 MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_JSON_TYPE);
455 if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
456 return Edge.fromJson(getResult.getResult());
458 // We didn't create an edge with the supplied type, so just throw an
460 throw new CrudException("Failed to create edge: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
465 public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version, String txId) throws CrudException {
466 String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
468 // Add the aai_node_type so that AAI can read the data created by gizmo
469 // TODO: This probably shouldn't be here
470 properties.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
472 Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
473 insertVertexBuilder.id(id);
474 properties.forEach(insertVertexBuilder::property);
475 Vertex insertVertex = insertVertexBuilder.build();
477 String payload = insertVertex.toJson(champGson);
478 OperationResult getResult = client.put(url, payload, createHeader(), MediaType.APPLICATION_JSON_TYPE,
479 MediaType.APPLICATION_JSON_TYPE);
481 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
482 return Vertex.fromJson(getResult.getResult(), version);
484 // We didn't create a vertex with the supplied type, so just throw an
486 throw new CrudException("Failed to update vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
491 public void deleteVertex(String id, String type, String txId) throws CrudException {
492 String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
493 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
495 if (getResult.getResultCode() != Response.Status.OK.getStatusCode()) {
496 // We didn't delete a vertex with the supplied id, so just throw an
498 throw new CrudException("Failed to delete vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
503 public Edge updateEdge(Edge edge, String txId) throws CrudException {
504 if (!edge.getId().isPresent()) {
505 throw new CrudException("Unable to identify edge: " + edge.toString(), Response.Status.BAD_REQUEST);
507 String url = baseRelationshipUrl + "/" + edge.getId().get() + "?transactionId=" + txId;
508 OperationResult getResult = client.put(url, edge.toJson(champGson), createHeader(), MediaType.APPLICATION_JSON_TYPE,
509 MediaType.APPLICATION_JSON_TYPE);
511 if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
512 return Edge.fromJson(getResult.getResult());
514 // We didn't create an edge with the supplied type, so just throw an
516 throw new CrudException("Failed to update edge: " + getResult.getFailureCause(),
517 Response.Status.fromStatusCode(getResult.getResultCode()));
522 public void deleteEdge(String id, String type, String txId) throws CrudException {
523 String url = baseRelationshipUrl + "/" + id + "?transactionId=" + txId;
524 OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
526 if (getResult.getResultCode() != 200) {
527 // We didn't find an edge with the supplied type, so just throw an
529 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
534 public Edge getEdge(String id, String type, String txId) throws CrudException {
535 String url = baseRelationshipUrl + "/" + id + "?transactionId=" + txId;
536 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
538 if (getResult.getResultCode() == 200) {
539 Edge edge = Edge.fromJson(getResult.getResult());
541 if (!edge.getType().equalsIgnoreCase(type)) {
542 // We didn't find an edge with the supplied type, so just throw an
544 throw new CrudException("No edge with id " + id + "and type " + type + " found in graph",
545 javax.ws.rs.core.Response.Status.NOT_FOUND);
549 // We didn't find an edge with the supplied id, so just throw an
551 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
555 public Vertex getVertex(String id, String type, String version, String txId) throws CrudException {
556 String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
557 OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
559 if (getResult.getResultCode() == 200) {
560 Vertex vert = Vertex.fromJson(getResult.getResult(), version);
562 if (!vert.getType().equalsIgnoreCase(type)) {
563 // We didn't find a vertex with the supplied type, so just throw an
565 throw new CrudException("No vertex with id " + id + "and type " + type + " found in graph",
566 javax.ws.rs.core.Response.Status.NOT_FOUND);
570 // We didn't find a vertex with the supplied id, so just throw an
572 throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No vertex with id " + id + " found in graph");
576 // https://stackoverflow.com/questions/26942330/convert-mapstring-string-to-listnamevaluepair-is-this-the-most-efficient
577 private List<NameValuePair> convertToNameValuePair(Map<String, ? super String> pairs) {
578 List<NameValuePair> nvpList = new ArrayList<>(pairs.size());
580 pairs.forEach((key, value) -> nvpList.add(new BasicNameValuePair(key, value.toString())));
585 // https://stackoverflow.com/questions/26942330/convert-mapstring-string-to-listnamevaluepair-is-this-the-most-efficient
586 private List<NameValuePair> convertToNameValuePair(String key, HashSet<String> values) {
587 List<NameValuePair> nvpList = new ArrayList<>(values.size());
589 values.forEach((value) -> nvpList.add(new BasicNameValuePair(key, value)));
594 private Map<String, List<String>> createHeader() {
595 Map<String, List<String>> headers = new HashMap<>();
596 headers.put(HEADER_FROM_APP, Arrays.asList(FROM_APP_NAME));
597 headers.put(HEADER_TRANS_ID, Arrays.asList(MDC.get(LoggingContext.LoggingField.REQUEST_ID.toString())));
601 private CrudException createErrorException(OperationResult result, javax.ws.rs.core.Response.Status defaultErrorCode , String defaultErrorMsg)
603 CrudException ce = null;
605 ce = new CrudException(result.getFailureCause(), Response.Status.fromStatusCode(result.getResultCode()));
607 ce = new CrudException(defaultErrorMsg, defaultErrorCode);