001    /**
002     * Copyright (c) 2000-2010 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.portlet;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.model.Portlet;
019    import com.liferay.portal.monitoring.MonitorNames;
020    import com.liferay.portal.monitoring.statistics.BaseDataSample;
021    import com.liferay.portlet.PortletResponseImpl;
022    
023    import javax.portlet.PortletRequest;
024    import javax.portlet.PortletResponse;
025    
026    /**
027     * @author Karthik Sudarshan
028     * @author Michael C. Han
029     * @author Brian Wing Shun Chan
030     */
031    public class PortletRequestDataSample extends BaseDataSample {
032    
033            public PortletRequestDataSample(
034                    PortletRequestType requestType, PortletRequest portletRequest,
035                    PortletResponse portletResponse) {
036    
037                    PortletResponseImpl portletResponseImpl =
038                            (PortletResponseImpl)portletResponse;
039    
040                    Portlet portlet = portletResponseImpl.getPortlet();
041    
042                    setCompanyId(portlet.getCompanyId());
043                    setUser(portletRequest.getRemoteUser());
044                    setNamespace(MonitorNames.PORTLET);
045                    setName(portlet.getPortletName());
046                    _portletId = portlet.getPortletId();
047                    _displayName = portlet.getDisplayName();
048                    _requestType = requestType;
049            }
050    
051            public String getDisplayName() {
052                    return _displayName;
053            }
054    
055            public String getPortletId() {
056                    return _portletId;
057            }
058    
059            public PortletRequestType getRequestType() {
060                    return _requestType;
061            }
062    
063            public String toString() {
064                    StringBundler sb = new StringBundler(9);
065    
066                    sb.append("{displayName=");
067                    sb.append(_displayName);
068                    sb.append(", portletId=");
069                    sb.append(_portletId);
070                    sb.append(", requestType=");
071                    sb.append(_requestType);
072                    sb.append(", ");
073                    sb.append(super.toString());
074                    sb.append("}");
075    
076                    return sb.toString();
077            }
078    
079            private String _displayName;
080            private String _portletId;
081            private PortletRequestType _requestType;
082    
083    }