View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      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.services.information;
18  
19  import java.util.Map;
20  
21  import javax.portlet.PortletMode;
22  import javax.portlet.WindowState;
23  
24  import org.apache.jetspeed.container.url.PortalURL;
25  import org.apache.jetspeed.request.RequestContext;
26  import org.apache.pluto.om.window.PortletWindow;
27  import org.apache.pluto.services.information.PortletURLProvider;
28  
29  /***
30   * Provides access to the Portal URL manipulation 
31   * 
32   *
33   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
34   * @version $Id: PortletURLProviderImpl.java 516448 2007-03-09 16:25:47Z ate $
35   */
36  public class PortletURLProviderImpl implements PortletURLProvider
37  {
38      private PortletWindow portletWindow = null;
39      private PortletMode mode = null;
40      private WindowState state = null;
41      private boolean action = false;
42      private boolean secure = false;
43      private Map parameters = null;
44  
45      private PortalURL url;
46      
47      public PortletURLProviderImpl(RequestContext context, PortletWindow portletWindow)
48      {
49          this.portletWindow = portletWindow;
50          
51          url = context.getPortalURL();
52      }
53  
54      public void setPortletMode(PortletMode mode)
55      {
56          this.mode = mode;
57      }
58  
59      public void setWindowState(WindowState state)
60      {
61          this.state = state;
62      }
63  
64      public void setAction()
65      {
66          action = true;
67      }
68  
69      public void setSecure()
70      {
71          secure = true;
72      }
73  
74      public void clearParameters()
75      {
76          // not used, handled by JetspeedNavigationalStateCodec itself
77      }
78  
79      public void setParameters(Map parameters)
80      {
81          this.parameters = parameters;
82      }
83  
84      public String toString()
85      {
86          return url.createPortletURL(portletWindow,parameters,mode,state,action,secure);
87      }
88  }