1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.portals.bridges.perl;
18
19
20 import javax.portlet.PortletURL;
21
22 import org.apache.jetspeed.rewriter.Rewriter;
23 import org.apache.jetspeed.rewriter.RulesetRewriterImpl;
24
25 /***
26 * PerlContentRewriter
27 *
28 * @author <a href="mailto:rogerrutr@apache.org">Roger Ruttimann </a>
29 * @version $Id: PerlContentRewriter.java 517068 2007-03-12 01:44:37Z ate $
30 */
31 public class PerlContentRewriter extends RulesetRewriterImpl implements
32 Rewriter {
33
34 /*** WebContentURL */
35 public static final String ACTION_PARAMETER_URL = "WCURL";
36
37
38 private PortletURL actionURL = null;
39
40
41 private String actionParameterName = null;
42
43
44
45
46
47
48 private String localHostIP = null;
49
50 /***
51 * Setters/getters for members
52 */
53 public void setActionURL(PortletURL action) {
54 this.actionURL = action;
55 }
56
57 public PortletURL getActionURL() {
58 return this.actionURL;
59 }
60
61 /***
62 * @return Returns the localHostIP.
63 */
64 public String getLocalHostIP() {
65 return localHostIP;
66 }
67
68 /***
69 * @param localHostIP
70 * The localHostIP to set.
71 */
72 public void setLocalHostIP(String localHostIP) {
73 this.localHostIP = localHostIP;
74 }
75
76 /***
77 * @return Returns the actionParameterName.
78 */
79 public String getActionParameterName() {
80 return actionParameterName;
81 }
82
83 /***
84 * @param actionParameterName
85 * The actionParameterName to set.
86 */
87 public void setActionParameterName(String actionParameterName) {
88 this.actionParameterName = actionParameterName;
89 }
90
91 /***
92 * rewriteURL
93 *
94 * @param url
95 * @param tag
96 * @param attribute
97 * @return the modified url which is a portlet action
98 *
99 * Rewrites all URL's in the perl script with portlet actions. Tags include
100 * A (AREA) and FORM and replaces any localhost with the real IP address if
101 * provided
102 */
103 public String rewriteUrl(String url, String tag, String attribute) {
104 String modifiedURL = url;
105
106 System.out.println("Perl HTML output TAG = " + tag + " Attribute = " + attribute);
107
108
109
110 if (( tag.compareToIgnoreCase("A") == 0
111 || tag.compareToIgnoreCase("FORM") == 0)
112 && attribute.compareToIgnoreCase("HREF") == 0) {
113
114 if (this.actionURL != null) {
115
116 actionURL.setParameter(actionParameterName, modifiedURL);
117 modifiedURL = actionURL.toString();
118 }
119 }
120
121 return modifiedURL;
122 }
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153 }