1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.kernel.audit;
24  
25  /**
26   * <a href="AuditRequestThreadLocal.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Michael C. Han
29   */
30  public class AuditRequestThreadLocal {
31  
32      public static AuditRequestThreadLocal getAuditThreadLocal() {
33          AuditRequestThreadLocal auditRequestThreadLocal =
34              _auditRequestThreadLocal.get();
35  
36          if (auditRequestThreadLocal == null) {
37              auditRequestThreadLocal = new AuditRequestThreadLocal();
38  
39              _auditRequestThreadLocal.set(auditRequestThreadLocal);
40          }
41  
42          return auditRequestThreadLocal;
43      }
44  
45      public static void removeAuditThreadLocal() {
46          _auditRequestThreadLocal.remove();
47      }
48  
49      public String getClientHost() {
50          return _clientHost;
51      }
52  
53      public String getClientIP() {
54          return _clientIP;
55      }
56  
57      public String getQueryString() {
58          return _queryString;
59      }
60  
61      public long getRealUserId() {
62          return _realUserId;
63      }
64  
65      public String getRequestURL() {
66          return _requestURL;
67      }
68  
69      public String getServerName() {
70          return _serverName;
71      }
72  
73      public int getServerPort() {
74          return _serverPort;
75      }
76  
77      public String getSessionID() {
78          return _sessionID;
79      }
80  
81      public void setClientHost(String clientHost) {
82          _clientHost = clientHost;
83      }
84  
85      public void setClientIP(String clientIP) {
86          _clientIP = clientIP;
87      }
88  
89      public void setQueryString(String queryString) {
90          _queryString = queryString;
91      }
92  
93      public void setRealUserId(long realUserId) {
94          _realUserId = realUserId;
95      }
96  
97      public void setRequestURL(String requestURL) {
98          _requestURL = requestURL;
99      }
100 
101     public void setServerName(String serverName) {
102         _serverName = serverName;
103     }
104 
105     public void setServerPort(int serverPort) {
106         _serverPort = serverPort;
107     }
108 
109     public void setSessionID(String sessionID) {
110         _sessionID = sessionID;
111     }
112 
113     private static ThreadLocal<AuditRequestThreadLocal>
114         _auditRequestThreadLocal = new ThreadLocal<AuditRequestThreadLocal>();
115 
116     private String _clientHost;
117     private String _clientIP;
118     private String _queryString;
119     private long _realUserId;
120     private String _requestURL;
121     private String _serverName;
122     private int _serverPort;
123     private String _sessionID;
124 
125 }