View Javadoc
1   /*******************************************************************************
2    * Copyhacked (H) 2012-2020.
3    * This program and the accompanying materials
4    * are made available under no term at all, use it like
5    * you want, but share and discuss about it
6    * every time possible with every body.
7    * 
8    * Contributors:
9    *      ron190 at ymail dot com - initial implementation
10   ******************************************************************************/
11  package com.jsql.view.terminal.interaction;
12  
13  import com.jsql.model.bean.util.Header;
14  import com.jsql.util.AnsiColorUtil;
15  import com.jsql.view.interaction.InteractionCommand;
16  import org.apache.logging.log4j.LogManager;
17  import org.apache.logging.log4j.Logger;
18  
19  import java.util.Map;
20  
21  public class MessageHeader implements InteractionCommand {
22      
23      private static final Logger LOGGER = LogManager.getRootLogger();
24  
25      private final String url;
26      private final String post;
27      private final Map<String, String> header;
28      private final Map<String, String> response;
29      private final String source;
30  
31      @SuppressWarnings("unchecked")
32      public MessageHeader(Object[] interactionParams) {
33          
34          Map<Header, Object> params = (Map<Header, Object>) interactionParams[0];
35          this.url = (String) params.get(Header.URL);
36          this.post = (String) params.get(Header.POST);
37          this.header = (Map<String, String>) params.get(Header.HEADER);
38          this.response = (Map<String, String>) params.get(Header.RESPONSE);
39          this.source = (String) params.get(Header.SOURCE);
40      }
41  
42      @Override
43      public void execute() {
44          
45          LOGGER.debug(() -> AnsiColorUtil.addGreenColor(this.getClass().getSimpleName()));
46          
47          LOGGER.debug("Method: {}", () -> this.response.get("Method"));
48          LOGGER.debug("Url: {}", this.url);
49          LOGGER.debug("Post: {}", this.post);
50          LOGGER.debug("Header: {}", this.header);
51          LOGGER.debug("Content-Length: {}", () -> this.response.get("Content-Length"));
52          LOGGER.debug("Content-Type: {}", () -> this.response.get("Content-Type"));
53          LOGGER.debug("Source: {}", () -> this.source);
54      }
55  }