Gizmo uses Champ the microservice
[aai/gizmo.git] / src / main / java / org / onap / crud / dao / champ / ChampDao.java
1 /**
2  * ============LICENSE_START=======================================================
3  * Gizmo
4  * ================================================================================
5  * Copyright © 2017 AT&T Intellectual Property.
6  * Copyright © 2017 Amdocs
7  * All rights reserved.
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
12  *
13  *    http://www.apache.org/licenses/LICENSE-2.0
14  *
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=========================================================
21  *
22  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23  */
24 package org.onap.crud.dao.champ;
25
26 import net.dongliu.gson.GsonJava8TypeAdapterFactory;
27
28 import com.google.gson.Gson;
29 import com.google.gson.GsonBuilder;
30 import com.google.gson.reflect.TypeToken;
31
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.openecomp.restclient.client.OperationResult;
45 import org.openecomp.restclient.client.RestClient;
46 import org.openecomp.restclient.enums.RestAuthenticationMode;
47 import org.slf4j.MDC;
48
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.List;
54 import java.util.Map;
55 import javax.ws.rs.core.MediaType;
56 import javax.ws.rs.core.Response;
57
58 public class ChampDao implements GraphDao {
59   private RestClient client;
60   private String baseObjectUrl;
61   private String baseRelationshipUrl;
62   private String baseTransactionUrl;
63
64   private static final String HEADER_FROM_APP = "X-FromAppId";
65   private static final String HEADER_TRANS_ID = "X-TransactionId";
66   private static final String FROM_APP_NAME = "Gizmo";
67   private static final String OBJECT_SUB_URL = "objects";
68   private static final String RELATIONSHIP_SUB_URL = "relationships";
69   private static final String TRANSACTION_SUB_URL = "transaction";
70
71   private Logger logger = LoggerFactory.getInstance().getLogger(ChampDao.class.getName());
72
73   // We use a custom vertex serializer for champ because it expects "key"
74   // instead of "id"
75   private static final Gson champGson = new GsonBuilder()
76       .registerTypeAdapterFactory(new GsonJava8TypeAdapterFactory())
77       .registerTypeAdapter(Vertex.class, new ChampVertexSerializer())
78       .registerTypeAdapter(Edge.class, new ChampEdgeSerializer()).create();
79
80   public ChampDao(String champUrl, String certPassword) {
81     try {
82       client = new RestClient().authenticationMode(RestAuthenticationMode.SSL_CERT).validateServerHostname(false)
83           .validateServerCertChain(false).clientCertFile(CrudServiceConstants.CRD_CHAMP_AUTH_FILE)
84           .clientCertPassword(Password.deobfuscate(certPassword));
85
86       baseObjectUrl = champUrl + OBJECT_SUB_URL;
87       baseRelationshipUrl = champUrl + RELATIONSHIP_SUB_URL;
88       baseTransactionUrl = champUrl + TRANSACTION_SUB_URL;
89     } catch (Exception e) {
90       System.out.println("Error setting up Champ configuration");
91       e.printStackTrace();
92       System.exit(1);
93     }
94   }
95
96   @Override
97   public Vertex getVertex(String id) throws CrudException {
98     String url = baseObjectUrl + "/" + id;
99     OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
100
101     if (getResult.getResultCode() == 200) {
102       return Vertex.fromJson(getResult.getResult());
103     } else {
104       // We didn't find a vertex with the supplied id, so just throw an
105       // exception.
106       throw new CrudException("No vertex with id " + id + " found in graph",
107           javax.ws.rs.core.Response.Status.NOT_FOUND);
108     }
109   }
110
111   @Override
112   public Vertex getVertex(String id, String type) throws CrudException {
113     String url = baseObjectUrl + "/" + id;
114     OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
115
116     if (getResult.getResultCode() == 200) {
117       Vertex vert = Vertex.fromJson(getResult.getResult());
118
119       if (!vert.getType().equalsIgnoreCase(type)) {
120         // We didn't find a vertex with the supplied type, so just throw an
121         // exception.
122         throw new CrudException("No vertex with id " + id + "and type " + type + " found in graph",
123             javax.ws.rs.core.Response.Status.NOT_FOUND);
124       }
125       return vert;
126     } else {
127       // We didn't find a vertex with the supplied id, so just throw an
128       // exception.
129       throw new CrudException("No vertex with id " + id + " found in graph",
130           javax.ws.rs.core.Response.Status.NOT_FOUND);
131     }
132   }
133
134   @Override
135   public List<Edge> getVertexEdges(String id) throws CrudException {
136     String url = baseObjectUrl + "/relationships/" + id;
137
138     OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
139
140     if (getResult.getResultCode() == 200) {
141       return champGson.fromJson(getResult.getResult(), new TypeToken<List<Edge>>() {
142       }.getType());
143     } else {
144       // We didn't find a vertex with the supplied id, so just throw an
145       // exception.
146       throw new CrudException("No vertex with id " + id + " found in graph",
147           javax.ws.rs.core.Response.Status.NOT_FOUND);
148     }
149   }
150
151   @Override
152   public List<Vertex> getVertices(String type, Map<String, Object> filter) throws CrudException {
153     filter.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
154
155     String url = baseObjectUrl + "/filter" + "?"
156         + URLEncodedUtils.format(convertToNameValuePair(filter), Charset.defaultCharset());
157
158     OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
159
160     if (getResult.getResultCode() == 200) {
161       return champGson.fromJson(getResult.getResult(), new TypeToken<List<Vertex>>() {
162       }.getType());
163     } else {
164       // We didn't find a vertex with the supplied id, so just throw an
165       // exception.
166       throw new CrudException("No vertices found in graph for given filters",
167           javax.ws.rs.core.Response.Status.NOT_FOUND);
168     }
169   }
170
171   @Override
172   public Edge getEdge(String id, String type) throws CrudException {
173     String url = baseRelationshipUrl + "/" + id;
174     OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
175
176     if (getResult.getResultCode() == 200) {
177       Edge edge = Edge.fromJson(getResult.getResult());
178
179       if (!edge.getType().equalsIgnoreCase(type)) {
180         // We didn't find an edge with the supplied type, so just throw an
181         // exception.
182         throw new CrudException("No edge with id " + id + "and type " + type + " found in graph",
183             javax.ws.rs.core.Response.Status.NOT_FOUND);
184       }
185       return edge;
186     } else {
187       // We didn't find a edge with the supplied type, so just throw an
188       // exception.
189       throw new CrudException("No edge with id " + id + " found in graph", javax.ws.rs.core.Response.Status.NOT_FOUND);
190     }
191   }
192
193   @Override
194   public List<Edge> getEdges(String type, Map<String, Object> filter) throws CrudException {
195     String url = baseRelationshipUrl + "/filter" + "?"
196         + URLEncodedUtils.format(convertToNameValuePair(filter), Charset.defaultCharset());
197
198     OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
199
200     if (getResult.getResultCode() == 200) {
201       return champGson.fromJson(getResult.getResult(), new TypeToken<List<Edge>>() {
202       }.getType());
203     } else {
204       // We didn't find a vertex with the supplied id, so just throw an
205       // exception.
206       throw new CrudException("No edges found in graph for given filters", javax.ws.rs.core.Response.Status.NOT_FOUND);
207     }
208   }
209
210   @Override
211   public Vertex addVertex(String type, Map<String, Object> properties) throws CrudException {
212     String url = baseObjectUrl;
213
214     // Add the aai_node_type so that AAI can read the data created by gizmo
215     // TODO: This probably shouldn't be here
216     properties.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
217
218     Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
219     properties.forEach(insertVertexBuilder::property);
220     Vertex insertVertex = insertVertexBuilder.build();
221
222     OperationResult getResult = client.post(url, insertVertex.toJson(), createHeader(), MediaType.APPLICATION_JSON_TYPE,
223         MediaType.APPLICATION_JSON_TYPE);
224
225     if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
226       return Vertex.fromJson(getResult.getResult());
227     } else {
228       // We didn't create a vertex with the supplied type, so just throw an
229       // exception.
230       throw new CrudException("Failed to create vertex", Response.Status.fromStatusCode(getResult.getResultCode()));
231     }
232   }
233
234   @Override
235   public Vertex updateVertex(String id, String type, Map<String, Object> properties) throws CrudException {
236     String url = baseObjectUrl + "/" + id;
237
238     // Add the aai_node_type so that AAI can read the data created by gizmo
239     // TODO: This probably shouldn't be here
240     properties.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
241
242     Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
243     insertVertexBuilder.id(id);
244     properties.forEach(insertVertexBuilder::property);
245     Vertex insertVertex = insertVertexBuilder.build();
246
247     String payload = insertVertex.toJson(champGson);
248     OperationResult getResult = client.put(url, payload, createHeader(), MediaType.APPLICATION_JSON_TYPE,
249         MediaType.APPLICATION_JSON_TYPE);
250
251     if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
252       return Vertex.fromJson(getResult.getResult());
253     } else {
254       // We didn't create a vertex with the supplied type, so just throw an
255       // exception.
256       throw new CrudException("Failed to update vertex", Response.Status.fromStatusCode(getResult.getResultCode()));
257     }
258   }
259
260   @Override
261   public void deleteVertex(String id, String type) throws CrudException {
262     String url = baseObjectUrl + "/" + id;
263     OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
264
265     if (getResult.getResultCode() != Response.Status.OK.getStatusCode()) {
266       // We didn't delete a vertex with the supplied id, so just throw an
267       // exception.
268       throw new CrudException("Failed to delete vertex", Response.Status.fromStatusCode(getResult.getResultCode()));
269     }
270   }
271
272   @Override
273   public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties) throws CrudException {
274     String url = baseRelationshipUrl;
275
276     // Try requests to ensure source and target exist in Champ
277     Vertex dbSource = getVertex(source.getId().get(), source.getType());
278     Vertex dbTarget = getVertex(target.getId().get(), target.getType());
279
280     Edge.Builder insertEdgeBuilder = new Edge.Builder(type).source(dbSource).target(dbTarget);
281     properties.forEach(insertEdgeBuilder::property);
282     Edge insertEdge = insertEdgeBuilder.build();
283
284     String edgeJson = insertEdge.toJson(champGson);
285     OperationResult getResult = client.post(url, edgeJson, createHeader(), MediaType.APPLICATION_JSON_TYPE,
286         MediaType.APPLICATION_JSON_TYPE);
287
288     if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
289       return Edge.fromJson(getResult.getResult());
290     } else {
291       // We didn't create an edge with the supplied type, so just throw an
292       // exception.
293       throw new CrudException("Failed to create edge", Response.Status.fromStatusCode(getResult.getResultCode()));
294     }
295   }
296
297   @Override
298   public Edge updateEdge(Edge edge) throws CrudException {
299     if (!edge.getId().isPresent()) {
300       throw new CrudException("Unable to identify edge: " + edge.toString(), Response.Status.BAD_REQUEST);
301     }
302     String url = baseRelationshipUrl + "/" + edge.getId().get();
303
304     String edgeJson = edge.toJson(champGson);
305     OperationResult getResult = client.put(url, edgeJson, createHeader(), MediaType.APPLICATION_JSON_TYPE,
306         MediaType.APPLICATION_JSON_TYPE);
307
308     if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
309       return Edge.fromJson(getResult.getResult());
310     } else {
311       // We didn't create an edge with the supplied type, so just throw an
312       // exception.
313       throw new CrudException("Failed to update edge", Response.Status.fromStatusCode(getResult.getResultCode()));
314     }
315   }
316
317   @Override
318   public void deleteEdge(String id, String type) throws CrudException {
319     String url = baseRelationshipUrl + "/" + id;
320     OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
321
322     if (getResult.getResultCode() != 200) {
323       // We didn't find an edge with the supplied type, so just throw an
324       // exception.
325       throw new CrudException("No edge with id " + id + " found in graph", javax.ws.rs.core.Response.Status.NOT_FOUND);
326     }
327   }
328
329   @Override
330   public String openTransaction() {
331     String url = baseTransactionUrl;
332
333     OperationResult getResult = client.post(url, "", createHeader(), MediaType.TEXT_PLAIN_TYPE, MediaType.TEXT_PLAIN_TYPE);
334
335     if (getResult.getResultCode() == 200) {
336       return getResult.getResult();
337     } else {
338       return null;
339     }
340   }
341
342   @Override
343   public void commitTransaction(String id) throws CrudException {
344     String url = baseTransactionUrl + "/" + id;
345
346     OperationResult getResult = client.put(url, "{\"method\": \"commit\"}", createHeader(), MediaType.APPLICATION_JSON_TYPE,
347         MediaType.TEXT_PLAIN_TYPE);
348
349     if (getResult.getResultCode() != 200) {
350       throw new CrudException("Unable to commit transaction",
351           Response.Status.fromStatusCode(getResult.getResultCode()));
352     }
353   }
354
355   @Override
356   public void rollbackTransaction(String id) throws CrudException {
357     String url = baseTransactionUrl + "/" + id;
358
359     OperationResult getResult = client.put(url, "{\"method\": \"rollback\"}", createHeader(), MediaType.APPLICATION_JSON_TYPE,
360         MediaType.TEXT_PLAIN_TYPE);
361
362     if (getResult.getResultCode() != 200) {
363       throw new CrudException("Unable to rollback transaction",
364           Response.Status.fromStatusCode(getResult.getResultCode()));
365     }
366   }
367
368   @Override
369   public boolean transactionExists(String id) throws CrudException {
370     String url = baseTransactionUrl + "/" + id;
371     Map<String, List<String>> headers = new HashMap<>();
372     headers.put(HEADER_FROM_APP, Arrays.asList("Gizmo"));
373     headers.put(HEADER_TRANS_ID, Arrays.asList(MDC.get(LoggingContext.LoggingField.REQUEST_ID.toString())));
374
375     OperationResult getResult = client.get(url, headers, MediaType.APPLICATION_JSON_TYPE);
376
377     return getResult.getResultCode() == 200;
378   }
379
380   @Override
381   public Vertex addVertex(String type, Map<String, Object> properties, String txId) throws CrudException {
382     String url = baseObjectUrl + "?transactionId=" + txId;
383
384     // Add the aai_node_type so that AAI can read the data created by gizmo
385     // TODO: This probably shouldn't be here
386     properties.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
387
388     Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
389     properties.forEach(insertVertexBuilder::property);
390     Vertex insertVertex = insertVertexBuilder.build();
391
392     OperationResult getResult = client.post(url, insertVertex.toJson(), createHeader(), MediaType.APPLICATION_JSON_TYPE,
393         MediaType.APPLICATION_JSON_TYPE);
394
395     if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
396       return Vertex.fromJson(getResult.getResult());
397     } else {
398       // We didn't create a vertex with the supplied type, so just throw an
399       // exception.
400       throw new CrudException("Failed to create vertex", Response.Status.fromStatusCode(getResult.getResultCode()));
401     }
402   }
403
404   @Override
405   public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String txId)
406       throws CrudException {
407     String url = baseRelationshipUrl + "?transactionId=" + txId;
408
409     // Try requests to ensure source and target exist in Champ
410     Vertex dbSource = getVertex(source.getId().get(), source.getType(), txId);
411     Vertex dbTarget = getVertex(target.getId().get(), target.getType(), txId);
412
413     Edge.Builder insertEdgeBuilder = new Edge.Builder(type).source(dbSource).target(dbTarget);
414     properties.forEach(insertEdgeBuilder::property);
415     Edge insertEdge = insertEdgeBuilder.build();
416
417     OperationResult getResult = client.post(url, insertEdge.toJson(champGson), createHeader(),
418         MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_JSON_TYPE);
419
420     if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
421       return Edge.fromJson(getResult.getResult());
422     } else {
423       // We didn't create an edge with the supplied type, so just throw an
424       // exception.
425       throw new CrudException("Failed to create edge", Response.Status.fromStatusCode(getResult.getResultCode()));
426     }
427   }
428
429   @Override
430   public Vertex updateVertex(String id, String type, Map<String, Object> properties, String txId) throws CrudException {
431     String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
432
433     // Add the aai_node_type so that AAI can read the data created by gizmo
434     // TODO: This probably shouldn't be here
435     properties.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
436
437     Vertex.Builder insertVertexBuilder = new Vertex.Builder(type);
438     insertVertexBuilder.id(id);
439     properties.forEach(insertVertexBuilder::property);
440     Vertex insertVertex = insertVertexBuilder.build();
441
442     String payload = insertVertex.toJson(champGson);
443     OperationResult getResult = client.put(url, payload, createHeader(), MediaType.APPLICATION_JSON_TYPE,
444         MediaType.APPLICATION_JSON_TYPE);
445
446     if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
447       return Vertex.fromJson(getResult.getResult());
448     } else {
449       // We didn't create a vertex with the supplied type, so just throw an
450       // exception.
451       throw new CrudException("Failed to update vertex", Response.Status.fromStatusCode(getResult.getResultCode()));
452     }
453   }
454
455   @Override
456   public void deleteVertex(String id, String type, String txId) throws CrudException {
457     String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
458     OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
459
460     if (getResult.getResultCode() != Response.Status.OK.getStatusCode()) {
461       // We didn't delete a vertex with the supplied id, so just throw an
462       // exception.
463       throw new CrudException("Failed to delete vertex", Response.Status.fromStatusCode(getResult.getResultCode()));
464     }
465   }
466
467   @Override
468   public Edge updateEdge(Edge edge, String txId) throws CrudException {
469     if (!edge.getId().isPresent()) {
470       throw new CrudException("Unable to identify edge: " + edge.toString(), Response.Status.BAD_REQUEST);
471     }
472     String url = baseRelationshipUrl + "/" + edge.getId().get() + "?transactionId=" + txId;
473     OperationResult getResult = client.put(url, edge.toJson(champGson), createHeader(), MediaType.APPLICATION_JSON_TYPE,
474         MediaType.APPLICATION_JSON_TYPE);
475
476     if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
477       return Edge.fromJson(getResult.getResult());
478     } else {
479       // We didn't create an edge with the supplied type, so just throw an
480       // exception.
481       throw new CrudException("Failed to update edge: " + getResult.getFailureCause(),
482           Response.Status.fromStatusCode(getResult.getResultCode()));
483     }
484   }
485
486   @Override
487   public void deleteEdge(String id, String type, String txId) throws CrudException {
488     String url = baseRelationshipUrl + "/" + id + "?transactionId=" + txId;
489     OperationResult getResult = client.delete(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
490
491     if (getResult.getResultCode() != 200) {
492       // We didn't find an edge with the supplied type, so just throw an
493       // exception.
494       throw new CrudException("No edge with id " + id + " found in graph", javax.ws.rs.core.Response.Status.NOT_FOUND);
495     }
496   }
497
498   @Override
499   public Edge getEdge(String id, String type, String txId) throws CrudException {
500     String url = baseRelationshipUrl + "/" + id + "?transactionId=" + txId;
501     OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
502
503     if (getResult.getResultCode() == 200) {
504       Edge edge = Edge.fromJson(getResult.getResult());
505
506       if (!edge.getType().equalsIgnoreCase(type)) {
507         // We didn't find an edge with the supplied type, so just throw an
508         // exception.
509         throw new CrudException("No edge with id " + id + "and type " + type + " found in graph",
510             javax.ws.rs.core.Response.Status.NOT_FOUND);
511       }
512       return edge;
513     } else {
514       // We didn't find an edge with the supplied id, so just throw an
515       // exception.
516       throw new CrudException("No edge with id " + id + " found in graph", javax.ws.rs.core.Response.Status.NOT_FOUND);
517     }
518   }
519
520   public Vertex getVertex(String id, String type, String txId) throws CrudException {
521     String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
522     OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
523
524     if (getResult.getResultCode() == 200) {
525       Vertex vert = Vertex.fromJson(getResult.getResult());
526
527       if (!vert.getType().equalsIgnoreCase(type)) {
528         // We didn't find a vertex with the supplied type, so just throw an
529         // exception.
530         throw new CrudException("No vertex with id " + id + "and type " + type + " found in graph",
531             javax.ws.rs.core.Response.Status.NOT_FOUND);
532       }
533       return vert;
534     } else {
535       // We didn't find a vertex with the supplied id, so just throw an
536       // exception.
537       throw new CrudException("No vertex with id " + id + " found in graph",
538           javax.ws.rs.core.Response.Status.NOT_FOUND);
539     }
540   }
541
542   // https://stackoverflow.com/questions/26942330/convert-mapstring-string-to-listnamevaluepair-is-this-the-most-efficient
543   private List<NameValuePair> convertToNameValuePair(Map<String, Object> pairs) {
544     List<NameValuePair> nvpList = new ArrayList<>(pairs.size());
545
546     pairs.forEach((key, value) -> nvpList.add(new BasicNameValuePair(key, value.toString())));
547
548     return nvpList;
549   }
550   
551   private Map<String, List<String>> createHeader() {
552     Map<String, List<String>> headers = new HashMap<>();
553     headers.put(HEADER_FROM_APP, Arrays.asList(FROM_APP_NAME));
554     headers.put(HEADER_TRANS_ID, Arrays.asList(MDC.get(LoggingContext.LoggingField.REQUEST_ID.toString())));
555     return headers;
556   }
557 }