Merge branch 'releases/Release_2_11_4_Branch'
[jalview.git] / src / jalview / util / UserAgent.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.util;
22
23 import jalview.bin.Cache;
24
25 public class UserAgent
26 {
27
28   public static String getUserAgent(String className)
29   {
30     StringBuilder sb = new StringBuilder();
31     sb.append("Jalview");
32     sb.append('/');
33     sb.append(Cache.getDefault("VERSION", "Unknown"));
34     sb.append(" (");
35     sb.append(System.getProperty("os.name"));
36     sb.append("; ");
37     sb.append(System.getProperty("os.arch"));
38     sb.append(' ');
39     sb.append(System.getProperty("os.name"));
40     sb.append(' ');
41     sb.append(System.getProperty("os.version"));
42     sb.append("; ");
43     sb.append("java/");
44     sb.append(System.getProperty("java.version"));
45     sb.append("; ");
46     sb.append("jalview/");
47     sb.append(ChannelProperties.getProperty("channel"));
48     if (className != null)
49     {
50       sb.append("; ");
51       sb.append(className);
52     }
53     String installation = Cache.applicationProperties
54             .getProperty("INSTALLATION");
55     if (installation != null)
56     {
57       sb.append("; ");
58       sb.append(installation);
59     }
60     sb.append(')');
61     sb.append(" help@jalview.org");
62     return sb.toString();
63   }
64
65   public static String getUserAgent()
66   {
67     return getUserAgent(null);
68   }
69
70 }