1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
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  }