001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.audit;
016    
017    import com.liferay.portal.kernel.util.AutoResetThreadLocal;
018    
019    /**
020     * @author Michael C. Han
021     */
022    public class AuditRequestThreadLocal {
023    
024            public static AuditRequestThreadLocal getAuditThreadLocal() {
025                    AuditRequestThreadLocal auditRequestThreadLocal =
026                            _auditRequestThreadLocal.get();
027    
028                    if (auditRequestThreadLocal == null) {
029                            auditRequestThreadLocal = new AuditRequestThreadLocal();
030    
031                            _auditRequestThreadLocal.set(auditRequestThreadLocal);
032                    }
033    
034                    return auditRequestThreadLocal;
035            }
036    
037            public static void removeAuditThreadLocal() {
038                    _auditRequestThreadLocal.remove();
039            }
040    
041            public String getClientHost() {
042                    return _clientHost;
043            }
044    
045            public String getClientIP() {
046                    return _clientIP;
047            }
048    
049            public String getQueryString() {
050                    return _queryString;
051            }
052    
053            public long getRealUserId() {
054                    return _realUserId;
055            }
056    
057            public String getRequestURL() {
058                    return _requestURL;
059            }
060    
061            public String getServerName() {
062                    return _serverName;
063            }
064    
065            public int getServerPort() {
066                    return _serverPort;
067            }
068    
069            public String getSessionID() {
070                    return _sessionID;
071            }
072    
073            public void setClientHost(String clientHost) {
074                    _clientHost = clientHost;
075            }
076    
077            public void setClientIP(String clientIP) {
078                    _clientIP = clientIP;
079            }
080    
081            public void setQueryString(String queryString) {
082                    _queryString = queryString;
083            }
084    
085            public void setRealUserId(long realUserId) {
086                    _realUserId = realUserId;
087            }
088    
089            public void setRequestURL(String requestURL) {
090                    _requestURL = requestURL;
091            }
092    
093            public void setServerName(String serverName) {
094                    _serverName = serverName;
095            }
096    
097            public void setServerPort(int serverPort) {
098                    _serverPort = serverPort;
099            }
100    
101            public void setSessionID(String sessionID) {
102                    _sessionID = sessionID;
103            }
104    
105            private static ThreadLocal<AuditRequestThreadLocal>
106                    _auditRequestThreadLocal =
107                            new AutoResetThreadLocal<AuditRequestThreadLocal>(
108                                    AuditRequestThreadLocal.class + "._auditRequestThreadLocal");
109    
110            private String _clientHost;
111            private String _clientIP;
112            private String _queryString;
113            private long _realUserId;
114            private String _requestURL;
115            private String _serverName;
116            private int _serverPort;
117            private String _sessionID;
118    
119    }