001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.monitoring.statistics.portal;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.monitoring.MonitorNames;
019    import com.liferay.portal.monitoring.statistics.BaseDataSample;
020    
021    /**
022     * @author Rajesh Thiagarajan
023     * @author Michael C. Han
024     * @author Brian Wing Shun Chan
025     */
026    public class PortalRequestDataSample extends BaseDataSample {
027    
028            public PortalRequestDataSample(
029                    long companyId, long groupId, String referer, String remoteAddr,
030                    String user, String requestURI, String requestURL, String userAgent) {
031    
032                    _referer = referer;
033                    _remoteAddr = remoteAddr;
034                    _requestURL = requestURL;
035                    _userAgent = userAgent;
036    
037                    setCompanyId(companyId);
038                    setGroupId(groupId);
039                    setName(requestURI);
040                    setNamespace(MonitorNames.PORTAL);
041                    setUser(user);
042            }
043    
044            public String getReferer() {
045                    return _referer;
046            }
047    
048            public String getRemoteAddr() {
049                    return _remoteAddr;
050            }
051    
052            public String getRequestURL() {
053                    return _requestURL;
054            }
055    
056            public int getStatusCode() {
057                    return _statusCode;
058            }
059    
060            public String getUserAgent() {
061                    return _userAgent;
062            }
063    
064            public void setStatusCode(int statusCode) {
065                    _statusCode = statusCode;
066            }
067    
068            @Override
069            public String toString() {
070                    StringBundler sb = new StringBundler(17);
071    
072                    sb.append("{referer=");
073                    sb.append(_referer);
074                    sb.append(", ");
075                    sb.append("remoteAddr=");
076                    sb.append(_remoteAddr);
077                    sb.append(", ");
078                    sb.append("requestURL=");
079                    sb.append(_requestURL);
080                    sb.append(", ");
081                    sb.append("statusCode=");
082                    sb.append(_statusCode);
083                    sb.append(", ");
084                    sb.append("userAgent=");
085                    sb.append(_userAgent);
086                    sb.append(", ");
087                    sb.append(super.toString());
088                    sb.append("}");
089    
090                    return sb.toString();
091            }
092    
093            private final String _referer;
094            private final String _remoteAddr;
095            private final String _requestURL;
096            private int _statusCode;
097            private final String _userAgent;
098    
099    }