View Javadoc
1   package fr.ifremer.quadrige3.synchro.server.pages.doc.debug;
2   
3   /*-
4    * #%L
5    * Quadrige3 Core :: Quadrige3 Synchro server
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2017 Ifremer
10   * %%
11   * This program is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU Affero General Public License as published by
13   * the Free Software Foundation, either version 3 of the License, or
14   * (at your option) any later version.
15   * 
16   * This program is distributed in the hope that it will be useful,
17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   * GNU General Public License for more details.
20   * 
21   * You should have received a copy of the GNU Affero General Public License
22   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23   * #L%
24   */
25  
26  
27  import fr.ifremer.quadrige3.synchro.server.config.SynchroServerConfiguration;
28  import fr.ifremer.quadrige3.synchro.server.pages.BasePage;
29  import org.apache.wicket.markup.html.basic.Label;
30  import org.apache.wicket.request.mapper.parameter.PageParameters;
31  
32  import java.io.ByteArrayOutputStream;
33  import java.io.PrintStream;
34  import java.nio.charset.StandardCharsets;
35  import java.util.Date;
36  import java.util.TimeZone;
37  
38  /**
39   * <p>DebugPage class.</p>
40   */
41  public class DebugPage extends BasePage {
42  
43      private static final long serialVersionUID = 1L;
44  
45      /**
46       * <p>Constructor for DebugPage.</p>
47       *
48       * @param parameters a {@link PageParameters} object.
49       */
50      public DebugPage(final PageParameters parameters) {
51          super(parameters);
52  
53          TimeZone tz = TimeZone.getDefault();
54          add(new Label("timezone", tz.getDisplayName() + " : " + tz.toString()));
55  
56          Date now = new Date();
57  
58          Label defaultDateTime = new Label("defaultDateTime", now.toString());
59          add(defaultDateTime);
60  
61          SynchroServerConfiguration config = SynchroServerConfiguration.getInstance();
62          ByteArrayOutputStream stream = new ByteArrayOutputStream();
63          PrintStream output = new PrintStream(stream);
64          config.getApplicationConfig().printConfig(output);
65          String allConfig = new String(stream.toByteArray(), StandardCharsets.UTF_8);
66  
67          allConfig = allConfig.replaceAll("\n", "<br/>");
68          Label envLabel = new Label("env", allConfig);
69          envLabel.setEscapeModelStrings(false);
70          add(envLabel);
71      }
72  
73  }