|
10 | 10 | import java.net.URISyntaxException; |
11 | 11 |
|
12 | 12 | public class URLManager { |
| 13 | + |
13 | 14 | private static final Logger log = AionLoggerFactory.getLogger(LogEnum.WLT.name()); |
14 | | - public static final String TRANSACTION_URL = "/#/transaction/"; |
| 15 | + |
| 16 | + private static final String TRANSACTION_URL = "/#/transaction/"; |
15 | 17 |
|
16 | 18 | public static void openDashboard() { |
17 | 19 | openURL(AionConstants.AION_URL); |
18 | 20 | } |
19 | 21 |
|
20 | 22 | public static void openTransaction(final String transactionHash) { |
21 | | - if(transactionHash != null && !transactionHash.isEmpty()) { |
| 23 | + if (transactionHash != null && !transactionHash.isEmpty()) { |
22 | 24 | openURL(AionConstants.AION_URL + TRANSACTION_URL + transactionHash); |
23 | 25 | } |
24 | 26 | } |
25 | 27 |
|
26 | | - public static void openURL(String URL) { |
27 | | - if(URL != null) { |
28 | | - final String OS = System.getProperty("os.name").toLowerCase(); |
29 | | - if(OS.indexOf("win") >= 0) { |
| 28 | + private static void openURL(final String URL) { |
| 29 | + if (URL != null) { |
| 30 | + final String os = System.getProperty("os.name").toLowerCase(); |
| 31 | + if (os.contains("win")) { |
30 | 32 | try { |
31 | 33 | Desktop.getDesktop().browse(new URI(URL)); |
32 | 34 | } catch (IOException | URISyntaxException e) { |
33 | 35 | log.error("Exception occurred trying to open website: %s", e.getMessage(), e); |
34 | 36 | } |
35 | | - } |
36 | | - else if(OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 ) |
37 | | - try { |
38 | | - if (Runtime.getRuntime().exec(new String[]{"which", "xdg-open"}).getInputStream().read() != -1) { |
39 | | - Runtime.getRuntime().exec(new String[]{"xdg-open", URL}); |
| 37 | + } else if (os.contains("nix") || os.contains("nux") || os.indexOf("aix") > 0) |
| 38 | + try { |
| 39 | + if (Runtime.getRuntime().exec(new String[]{"which", "xdg-open"}).getInputStream().read() != -1) { |
| 40 | + Runtime.getRuntime().exec(new String[]{"xdg-open", URL}); |
| 41 | + } |
| 42 | + } catch (IOException e) { |
| 43 | + e.printStackTrace(); |
40 | 44 | } |
41 | | - } catch (IOException e) { |
42 | | - e.printStackTrace(); |
43 | | - } |
44 | 45 | } |
45 | 46 | } |
46 | 47 | } |
0 commit comments