001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.portlet;
016    
017    import java.io.Serializable;
018    
019    import java.util.Map;
020    import java.util.Set;
021    
022    import javax.portlet.PortletURL;
023    import javax.portlet.ResourceURL;
024    
025    /**
026     * Represents a URL pointing to a portlet.
027     *
028     * @author Brian Wing Shun Chan
029     * @see    com.liferay.portlet.PortletURLImpl
030     */
031    public interface LiferayPortletURL
032            extends PortletURL, ResourceURL, Serializable {
033    
034            /**
035             * Adds a parameter that is included in the friendly URL path and does not
036             * need to appear in the query string.
037             *
038             * @param name the name of the parameter that is included in the path
039             */
040            public void addParameterIncludedInPath(String name);
041    
042            /**
043             * Gets the lifecycle of the portlet this URL points to.
044             *
045             * @return the portlet lifecycle
046             * @see    #setLifecycle(String)
047             */
048            public String getLifecycle();
049    
050            /**
051             * Gets the first value of the URL parameter.
052             *
053             * @param  name the name of the URL parameter to get the value of
054             * @return the first value of the URL parameter
055             */
056            public String getParameter(String name);
057    
058            /**
059             * Gets the id of the portlet this URL points to.
060             *
061             * @return the id of the portlet this URL points to
062             */
063            public String getPortletId();
064    
065            /**
066             * Gets the map of reserved parameters for this URL.
067             *
068             * <p>
069             * This method is only used internally. Reserved parameters contain special,
070             * Liferay specific information, such as <code>p_p_id</code> and
071             * <code>p_p_lifecycle</code>.
072             * </p>
073             *
074             * @return the reserved parameter names and values in a read-only map
075             */
076            public Map<String, String> getReservedParameterMap();
077    
078            /**
079             * Gets the id of the resource this URL points to.
080             *
081             * @return the id of the resource this URL points to
082             */
083            public String getResourceID();
084    
085            /**
086             * Determines whether this URL is an anchor pointing to the specified
087             * portlet on the page.
088             *
089             * @return whether this URL is an anchor pointing to the specified portlet
090             *                 on the page
091             * @see    #setAnchor(boolean)
092             */
093            public boolean isAnchor();
094    
095            /**
096             * Determines whether the render parameters in the current request should be
097             * copied to this URL.
098             *
099             * @return whether the render parameters in the current request should be
100             *                 copied to this URL
101             * @see    #setCopyCurrentRenderParameters(boolean)
102             */
103            public boolean isCopyCurrentRenderParameters();
104    
105            /**
106             * Determines whether this URL should be encrypted.
107             *
108             * @return true if this URL should be encrypted; false otherwise
109             * @see    #setEncrypt(boolean)
110             */
111            public boolean isEncrypt();
112    
113            /**
114             * Determines whether this URL should be XML escaped.
115             *
116             * @return true if this URL should be XML escaped; false otherwise
117             * @see    #setEscapeXml(boolean)
118             */
119            public boolean isEscapeXml();
120    
121            /**
122             * Determines whether the parameter is included in the friendly URL path.
123             *
124             * @param  name the name of the parameter to check for inclusion in the path
125             * @return whether the parameter is included in the friendly URL path
126             * @see    #addParameterIncludedInPath(String)
127             */
128            public boolean isParameterIncludedInPath(String name);
129    
130            /**
131             * Determines whether this URL is secure (https).
132             *
133             * @return true if this URL is secure; false otherwise
134             */
135            public boolean isSecure();
136    
137            /**
138             * Sets the lifecycle of the portlet this URL points to.
139             *
140             * <p>
141             * Valid lifecycles are:
142             * </p>
143             *
144             * <ul>
145             * <li>
146             * {@link javax.portlet.PortletRequest#ACTION_PHASE}
147             * </li>
148             * <li>
149             * {@link javax.portlet.PortletRequest#RENDER_PHASE}
150             * </li>
151             * <li>
152             * {@link javax.portlet.PortletRequest#RESOURCE_PHASE}
153             * </li>
154             * </ul>
155             *
156             * @param lifecycle the lifecycle of the portlet this URL points to
157             */
158            public void setLifecycle(String lifecycle);
159    
160            /**
161             * Sets the URL parameter to the value.
162             *
163             * @param name the name of the URL parameter
164             * @param value the value of the URL parameter
165             * @param append whether the new value should be appended to any existing
166             *                values for the parameter. If <code>append</code> is
167             *                <code>false</code> any existing values will be overwritten with
168             *                the new value.
169             */
170            public void setParameter(String name, String value, boolean append);
171    
172            /**
173             * Sets the URL parameter the values.
174             *
175             * @param name the name of the URL parameter
176             * @param append whether the new values should be appended to any existing
177             *                values for the parameter. If <code>append</code> is
178             *                <code>false</code> any existing values will be overwritten with
179             *                the new values.
180             */
181            public void setParameter(String name, String[] values, boolean append);
182    
183            public Set<String> getParametersIncludedInPath();
184    
185            /**
186             * Sets whether this URL is an anchor pointing to the specified portlet on
187             * the page.
188             *
189             * <p>
190             * An anchor URL will cause the user's browser to automatically jump down to
191             * the specified portlet after the page loads, avoiding the need to scroll.
192             * </p>
193             *
194             * @param anchor whether this URL is an anchor pointing to the specified
195             *                portlet on the page
196             */
197            public void setAnchor(boolean anchor);
198    
199            /**
200             * Sets whether the render parameters in the current request should be
201             * copied to this URL.
202             *
203             * <p>
204             * New parameters set on this URL will appear before the copied render
205             * parameters.
206             * </p>
207             *
208             * @param copyCurrentRenderParameters whether the render parameters in the
209             *                current request should be copied to this URL
210             */
211            public void setCopyCurrentRenderParameters(
212                    boolean copyCurrentRenderParameters);
213    
214            /**
215             * Sets the id of the user to impersonate.
216             *
217             * <p>
218             * When a page is accessed while impersonating a user, it will appear
219             * exactly as it would to that user.
220             * </p>
221             *
222             * @param doAsUserId the id of the user to impersonate in the portlet this
223             *                URL points to
224             */
225            public void setDoAsUserId(long doAsUserId);
226    
227            public void setDoAsUserLanguageId(String doAsUserLanguageId);
228    
229            /**
230             * Sets whether this URL should be encrypted.
231             *
232             * <p>
233             * In an encrypted URL, the value of every parameter will be encrypted using
234             * the company's key. This allows sensitive information to be placed in the
235             * URL without being vulnerable to snooping.
236             * </p>
237             *
238             * <p>
239             * Note that this is not the same as making a URL {@link #setSecure(boolean)
240             * secure}.
241             * </p>
242             */
243            public void setEncrypt(boolean encrypt);
244    
245            /**
246             * Sets whether this URL should be XML escaped.
247             *
248             * <p>
249             * If a URL is XML escaped, it will automatically have special characters
250             * escaped when it is converted to a string or written to a {@link
251             * java.io.Writer}.
252             * </p>
253             *
254             * @param escapeXml whether this URL should be XML escaped
255             */
256            public void setEscapeXml(boolean escapeXml);
257    
258            /**
259             * Sets the portlet layout id.
260             *
261             * @param plid the portlet layout id
262             */
263            public void setPlid(long plid);
264    
265            /**
266             * Sets the id of the target portlet.
267             */
268            public void setPortletId(String portletId);
269    
270    }