01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.jetspeed.container.url.impl;
18:
19: import javax.servlet.http.HttpServletRequest;
20:
21: import org.apache.jetspeed.PortalContext;
22: import org.apache.jetspeed.container.state.NavigationalState;
23: import org.apache.jetspeed.container.url.BasePortalURL;
24:
25: /**
26: * QueryStringEncodingPortalURL encodes the NavigationalState as query parameter
27: * *
28: * @author <a href="mailto:ate@apache.org">Ate Douma</a>
29: * @version $Id: QueryStringEncodingPortalURL.java 516448 2007-03-09 16:25:47Z ate $
30: */
31: public class QueryStringEncodingPortalURL extends AbstractPortalURL {
32: public QueryStringEncodingPortalURL(NavigationalState navState,
33: PortalContext portalContext, BasePortalURL base) {
34: super (navState, portalContext, base);
35: }
36:
37: public QueryStringEncodingPortalURL(NavigationalState navState,
38: PortalContext portalContext) {
39: super (navState, portalContext);
40: }
41:
42: public QueryStringEncodingPortalURL(String characterEncoding,
43: NavigationalState navState, PortalContext portalContext) {
44: super (characterEncoding, navState, portalContext);
45: }
46:
47: public QueryStringEncodingPortalURL(HttpServletRequest request,
48: String characterEncoding, NavigationalState navState,
49: PortalContext portalContext) {
50: super (request, characterEncoding, navState, portalContext);
51: }
52:
53: protected void decodePathAndNavigationalState(
54: HttpServletRequest request) {
55: setEncodedNavigationalState(request
56: .getParameter(getNavigationalStateParameterName()));
57: String path = null;
58: if (request.getPathInfo() != null) {
59: path = request.getPathInfo();
60: int length = path.length();
61: if (length > 1 && path.endsWith("/")) {
62: path = path.substring(0, length - 1);
63: }
64: }
65: setPath(path);
66: }
67:
68: protected String createPortletURL(String encodedNavigationalState,
69: boolean secure) {
70: StringBuffer buffer = new StringBuffer(getBaseURL(secure));
71: buffer.append(getBasePath());
72: if (getPath() != null) {
73: buffer.append(getPath());
74: }
75: if (encodedNavigationalState != null) {
76: buffer.append("?");
77: buffer.append(getNavigationalStateParameterName());
78: buffer.append("=");
79: buffer.append(encodedNavigationalState);
80: }
81: return buffer.toString();
82: }
83: }
|