1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.monitoring.statistics.portlet;
16  
17  import com.liferay.portal.kernel.util.StringBundler;
18  import com.liferay.portal.model.Portlet;
19  import com.liferay.portal.monitoring.MonitorNames;
20  import com.liferay.portal.monitoring.statistics.BaseDataSample;
21  import com.liferay.portlet.PortletResponseImpl;
22  
23  import javax.portlet.PortletRequest;
24  import javax.portlet.PortletResponse;
25  
26  /**
27   * <a href="PortletRequestDataSample.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Karthik Sudarshan
30   * @author Michael C. Han
31   * @author Brian Wing Shun Chan
32   */
33  public class PortletRequestDataSample extends BaseDataSample {
34  
35      public PortletRequestDataSample(
36          PortletRequestType requestType, PortletRequest portletRequest,
37          PortletResponse portletResponse) {
38  
39          PortletResponseImpl portletResponseImpl =
40              (PortletResponseImpl)portletResponse;
41  
42          Portlet portlet = portletResponseImpl.getPortlet();
43  
44          setCompanyId(portlet.getCompanyId());
45          setUser(portletRequest.getRemoteUser());
46          setNamespace(MonitorNames.PORTLET);
47          setName(portlet.getPortletName());
48          _portletId = portlet.getPortletId();
49          _displayName = portlet.getDisplayName();
50          _requestType = requestType;
51      }
52  
53      public String getDisplayName() {
54          return _displayName;
55      }
56  
57      public String getPortletId() {
58          return _portletId;
59      }
60  
61      public PortletRequestType getRequestType() {
62          return _requestType;
63      }
64  
65      public String toString() {
66          StringBundler sb = new StringBundler(9);
67  
68          sb.append("{displayName=");
69          sb.append(_displayName);
70          sb.append(", portletId=");
71          sb.append(_portletId);
72          sb.append(", requestType=");
73          sb.append(_requestType);
74          sb.append(", ");
75          sb.append(super.toString());
76          sb.append("}");
77  
78          return sb.toString();
79      }
80  
81      private String _displayName;
82      private String _portletId;
83      private PortletRequestType _requestType;
84  
85  }