1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 * 9 * http://www.apache.org/licenses/LICENSE-2.010 * 11 * Unless required by applicable law or agreed to in writing, software12 * 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 and15 * limitations under the License.16 */1718packageorg.apache.jetspeed.container.url.impl;
1920import org.apache.jetspeed.container.state.NavigationalStateComponent;
21import org.apache.jetspeed.pipeline.PipelineException;
22import org.apache.jetspeed.pipeline.valve.AbstractValve;
23import org.apache.jetspeed.pipeline.valve.ValveContext;
24import org.apache.jetspeed.request.RequestContext;
25import org.apache.jetspeed.desktop.JetspeedDesktop;
2627/***28 * Creates the PortalURL for the current Request29 *30 * @author <a href="mailto:ate@apache.org">Ate Douma</a>31 * @version $Id: PortalURLValveImpl.java 588430 2007-10-26 00:08:07Z smilek $32 */33publicclassPortalURLValveImplextendsAbstractValve34 {
35private NavigationalStateComponent navComponent;
3637publicPortalURLValveImpl(NavigationalStateComponent navComponent)
38 {
39this.navComponent = navComponent;
40 }
4142publicvoid invoke(RequestContext request, ValveContext context)
43 throws PipelineException
44 {
45try46 {
47if ( request.getPortalURL() == null )
48 {
49 String encoding = request.getRequestParameter(JetspeedDesktop.DESKTOP_ENCODER_REQUEST_PARAMETER);
50if (encoding != null && encoding.equals(JetspeedDesktop.DESKTOP_ENCODER_REQUEST_PARAMETER_VALUE))
51 {
52 request.setPortalURL(navComponent.createDesktopURL(request.getRequest(), request.getCharacterEncoding()));
53 request.setAttribute( JetspeedDesktop.DESKTOP_ENABLED_REQUEST_ATTRIBUTE, Boolean.TRUE );
54 }
55else56 {
57 request.setPortalURL(navComponent.createURL(request.getRequest(), request.getCharacterEncoding()));
58 }
5960 }
61 }
62catch (Exception e)
63 {
64thrownew PipelineException(e);
65 }
66// Pass control to the next Valve in the Pipeline67 context.invokeNext( request );
68 }
6970public String toString()
71 {
72return"PortalURLValveImpl";
73 }
74 }