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