01: /*
02: * Copyright 2007 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
07: * BI Platform. The Initial Developer is Pentaho Corporation.
08: *
09: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11: * the license for the specific language governing your rights and limitations.
12: */
13: package org.pentaho.ui.portlet;
14:
15: import java.util.Enumeration;
16: import java.util.Iterator;
17: import java.util.Map;
18: import java.util.Set;
19:
20: import javax.portlet.ActionRequest;
21: import javax.portlet.ActionResponse;
22: import javax.portlet.PortalContext;
23:
24: /**
25: * Utility class with (mostly) static methods that aid in getting useful
26: * debugging information from various portlet related classes.
27: *
28: * @author Steven Barkdull
29: *
30: */
31: public class DebugUtil {
32:
33: protected String logInfo(ActionRequest request,
34: ActionResponse response) {
35: StringBuffer b = new StringBuffer();
36:
37: String ctxP = request.getContextPath();
38: b.append("Ctx Path: " + ctxP + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
39: Map pMap = request.getParameterMap();
40: b.append("Request params:\n"); //$NON-NLS-1$
41: Set ks = pMap.keySet();
42: for (Iterator k = ks.iterator(); k.hasNext();) {
43: String n = (String) k.next();
44: Object p = pMap.get(n);
45: b.append("param: " + n + ", " + p); //$NON-NLS-1$ //$NON-NLS-2$
46: }
47: PortalContext pCtx = request.getPortalContext();
48: String pInfo = pCtx.getPortalInfo();
49: b.append("\npInfo: " + pInfo); //$NON-NLS-1$
50: Enumeration en = pCtx.getPropertyNames();
51: b.append("Portlet props:\n"); //$NON-NLS-1$
52: for (; en.hasMoreElements();) {
53: String n = (String) en.nextElement();
54: String p = pCtx.getProperty(n);
55: b.append("prop: " + n + ", " + p); //$NON-NLS-1$ //$NON-NLS-2$
56: }
57:
58: b.append("\nRequest props:\n"); //$NON-NLS-1$
59: en = request.getPropertyNames();
60: while (en.hasMoreElements()) {
61: String n = (String) en.nextElement();
62: String p = request.getProperty(n);
63: b.append("prop: " + n + ", " + p); //$NON-NLS-1$ //$NON-NLS-2$
64: }
65: b.append("\n"); //$NON-NLS-1$
66: return b.toString();
67: }
68: }
|