ServerInfoContextManuallyAdd.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */

  20. package org.openspcoop2.utils.service.context.server;


  21. import org.apache.cxf.interceptor.Fault;
  22. import org.openspcoop2.utils.logger.beans.context.core.Role;
  23. import org.openspcoop2.utils.service.context.dump.DumpConfig;
  24. import org.openspcoop2.utils.service.context.dump.DumpRequest;
  25. import org.openspcoop2.utils.service.context.dump.DumpResponse;
  26. import org.openspcoop2.utils.service.context.dump.DumpUtilities;

  27. /**
  28.  * ServerInfoContextManuallyAdd
  29.  *
  30.  * @author Lorenzo Nardi (nardi@link.it)
  31.  * @author $Author$
  32.  * @version $Rev$, $Date$
  33.  */
  34. public class ServerInfoContextManuallyAdd {
  35.    
  36.     private ServerConfig serverConfig;
  37.     private ServerInfoUtilities utilities;
  38.     private DumpUtilities dumpUtilities;
  39.     private DumpConfig dumpConfig;

  40.     public ServerInfoContextManuallyAdd(ServerConfig serverConfig) {
  41.         this.serverConfig = serverConfig;
  42.         this.utilities = new ServerInfoUtilities(this.serverConfig);
  43.        
  44.         this.dumpConfig = this.serverConfig.getDumpConfig();
  45.         if(this.dumpConfig==null) {
  46.             this.dumpConfig = new DumpConfig();
  47.         }
  48.         this.dumpConfig.setRole(Role.CLIENT);
  49.        
  50.         if(this.serverConfig.isDump() && this.serverConfig.getDumpConfig() == null) {
  51.             this.serverConfig.setDumpConfig(this.dumpConfig);
  52.         }
  53.        
  54.         this.dumpUtilities = new DumpUtilities(this.serverConfig);
  55.     }

  56.     public void processBeforeSend(ServerInfoRequest request) throws Fault {
  57.         this.processBeforeSend(request, null);
  58.     }
  59.     public void processBeforeSend(ServerInfoRequest request, DumpRequest dumpRequest) throws Fault {
  60.        
  61.         this.utilities.processBeforeSend(request);
  62.         if(this.serverConfig.isDump() && dumpRequest!=null) {
  63.             this.dumpUtilities.processBeforeSend(dumpRequest);
  64.         }
  65.        
  66.     }
  67.    
  68.     public void processAfterSend(ServerInfoResponse response) throws Fault {
  69.         this.processAfterSend(response, null);
  70.     }
  71.     public void processAfterSend(ServerInfoResponse response, DumpResponse DumpResponse) throws Fault {
  72.        
  73.         this.utilities.processAfterSend(response);
  74.         if(this.serverConfig.isDump() && DumpResponse!=null) {
  75.             this.dumpUtilities.processAfterSend(DumpResponse);
  76.         }
  77.        
  78.     }
  79. }