%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.desktop.impl.JetspeedDesktopContextImpl |
|
|
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.desktop.impl; |
|
18 | ||
19 | import java.util.Locale; |
|
20 | import java.util.ResourceBundle; |
|
21 | ||
22 | import org.apache.jetspeed.container.url.BasePortalURL; |
|
23 | import org.apache.jetspeed.decoration.LayoutDecoration; |
|
24 | import org.apache.jetspeed.decoration.Theme; |
|
25 | import org.apache.jetspeed.desktop.JetspeedDesktopContext; |
|
26 | import org.apache.jetspeed.headerresource.HeaderResource; |
|
27 | import org.apache.jetspeed.headerresource.HeaderResourceLib; |
|
28 | import org.apache.jetspeed.request.RequestContext; |
|
29 | ||
30 | /** |
|
31 | * Jetspeed Desktop |
|
32 | * |
|
33 | * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a> |
|
34 | * @author <a href="mailto:smilek@apache.org">Steve Milek</a> |
|
35 | * @version $Id: JetspeedDesktopContextImpl.java $ |
|
36 | */ |
|
37 | public class JetspeedDesktopContextImpl implements JetspeedDesktopContext |
|
38 | { |
|
39 | // Jetspeed Request Context |
|
40 | RequestContext context; |
|
41 | ||
42 | // base portal url to override default url server info from servlet |
|
43 | 0 | private BasePortalURL baseUrlAccess = null; |
44 | ||
45 | private LayoutDecoration layoutDecoration; |
|
46 | ||
47 | // default extension for layout templates |
|
48 | private String defaultLayoutTemplateExtension; |
|
49 | ||
50 | ||
51 | // ... save generated portal urls to avoid duplicate effort |
|
52 | private String portalBaseUrl; |
|
53 | private String portalUrl; |
|
54 | ||
55 | private HeaderResource headerResource; |
|
56 | ||
57 | public JetspeedDesktopContextImpl( RequestContext context, BasePortalURL baseUrlAccess, Theme theme, HeaderResource headerResource, String defaultLayoutTemplateExtension ) |
|
58 | 0 | { |
59 | // String layoutDecorator, String layoutDecoratorRootPath, String resourceName |
|
60 | 0 | this.context = context; |
61 | 0 | this.baseUrlAccess = baseUrlAccess; |
62 | 0 | this.layoutDecoration = theme.getPageLayoutDecoration(); |
63 | 0 | this.headerResource = headerResource; |
64 | 0 | this.defaultLayoutTemplateExtension = defaultLayoutTemplateExtension; |
65 | 0 | } |
66 | ||
67 | ||
68 | // get portal urls - each of these methods is copied from HeaderResourceImpl.java |
|
69 | ||
70 | /** |
|
71 | * Portal base url ( e.g. http://localhost:8080/jetspeed ) |
|
72 | * |
|
73 | * @return portal base url |
|
74 | */ |
|
75 | public String getPortalBaseUrl() |
|
76 | { |
|
77 | 0 | if ( this.portalBaseUrl == null ) |
78 | { |
|
79 | 0 | this.portalBaseUrl = HeaderResourceLib.getPortalBaseUrl( context, class="keyword">this.baseUrlAccess ); |
80 | } |
|
81 | 0 | return this.portalBaseUrl; |
82 | } |
|
83 | ||
84 | /** |
|
85 | * Portal base url ( e.g. http://localhost:8080/jetspeed ) |
|
86 | * |
|
87 | * @return portal base url |
|
88 | */ |
|
89 | public String getPortalBaseUrl( boolean encode ) |
|
90 | { |
|
91 | 0 | String baseurl = getPortalBaseUrl(); |
92 | 0 | if ( ! encode ) |
93 | { |
|
94 | 0 | return baseurl; |
95 | } |
|
96 | else |
|
97 | { |
|
98 | 0 | return context.getResponse().encodeURL( baseurl ); |
99 | } |
|
100 | } |
|
101 | ||
102 | /** |
|
103 | * Portal base url with relativePath argument appended ( e.g. http://localhost:8080/jetspeed/javascript/dojo/ ) |
|
104 | * |
|
105 | * @return portal base url with relativePath argument appended |
|
106 | */ |
|
107 | public String getPortalResourceUrl( String relativePath ) |
|
108 | { |
|
109 | 0 | return getPortalResourceUrl( relativePath, false ); |
110 | } |
|
111 | ||
112 | /** |
|
113 | * Portal base url with relativePath argument appended ( e.g. http://localhost:8080/jetspeed/javascript/dojo/ ) |
|
114 | * |
|
115 | * @return portal base url with relativePath argument appended |
|
116 | */ |
|
117 | public String getPortalResourceUrl( String relativePath, boolean encode ) |
|
118 | { |
|
119 | 0 | return HeaderResourceLib.getPortalResourceUrl( relativePath, getPortalBaseUrl(), encode, context ); |
120 | } |
|
121 | ||
122 | /** |
|
123 | * Portal base servlet url ( e.g. http://localhost:8080/jetspeed/desktop/ ) |
|
124 | * |
|
125 | * @return portal base servlet url |
|
126 | */ |
|
127 | public String getPortalUrl() |
|
128 | { |
|
129 | 0 | if ( this.portalUrl == null ) |
130 | { |
|
131 | 0 | this.portalUrl = HeaderResourceLib.getPortalUrl( getPortalBaseUrl(), context ); |
132 | } |
|
133 | 0 | return this.portalUrl; |
134 | } |
|
135 | ||
136 | /** |
|
137 | * Portal base servlet url ( e.g. http://localhost:8080/jetspeed/desktop/ ) |
|
138 | * |
|
139 | * @return portal base servlet url |
|
140 | */ |
|
141 | public String getPortalUrl( boolean encode ) |
|
142 | { |
|
143 | 0 | return getPortalUrl( null, encode ); |
144 | } |
|
145 | ||
146 | /** |
|
147 | * Portal base servlet url with relativePath argument appended ( e.g. http://localhost:8080/jetspeed/desktop/default-page.psml ) |
|
148 | * |
|
149 | * @return portal base servlet url with relativePath argument appended |
|
150 | */ |
|
151 | public String getPortalUrl( String relativePath ) |
|
152 | { |
|
153 | 0 | return getPortalUrl( relativePath, false ); |
154 | } |
|
155 | ||
156 | /** |
|
157 | * Portal base servlet url with relativePath argument appended ( e.g. http://localhost:8080/jetspeed/desktop/default-page.psml ) |
|
158 | * |
|
159 | * @return portal base servlet url with relativePath argument appended |
|
160 | */ |
|
161 | public String getPortalUrl( String relativePath, boolean encode ) |
|
162 | { |
|
163 | 0 | return HeaderResourceLib.getPortalResourceUrl( relativePath, getPortalUrl(), encode, context ); |
164 | } |
|
165 | ||
166 | public String getLayoutDecorationName() |
|
167 | { |
|
168 | 0 | return layoutDecoration.getName(); |
169 | } |
|
170 | ||
171 | public String getLayoutTemplatePath() |
|
172 | { |
|
173 | 0 | return getLayoutTemplatePath( null ); |
174 | } |
|
175 | public String getLayoutTemplatePath( String layoutTemplateIdPropertyName ) |
|
176 | { |
|
177 | 0 | String id = null; |
178 | 0 | if ( layoutTemplateIdPropertyName != null ) |
179 | { |
|
180 | 0 | id = layoutDecoration.getProperty( layoutTemplateIdPropertyName ); |
181 | } |
|
182 | ||
183 | 0 | if ( id == null || id.length() == 0 ) |
184 | { |
|
185 | 0 | id = layoutDecoration.getProperty( LAYOUT_TEMPLATE_ID_PROP ); |
186 | } |
|
187 | ||
188 | 0 | if ( id == null || id.length() == 0 ) |
189 | { |
|
190 | 0 | id = LAYOUT_TEMPLATE_ID_DEFAULT; |
191 | } |
|
192 | ||
193 | 0 | String ext = layoutDecoration.getProperty( LAYOUT_DESKTOP_TEMPLATE_EXTENSION_PROP ); |
194 | 0 | if ( ext == null ) |
195 | 0 | ext = layoutDecoration.getProperty( LAYOUT_TEMPLATE_EXTENSION_PROP ); |
196 | 0 | if ( ext == null ) |
197 | { |
|
198 | 0 | ext = this.defaultLayoutTemplateExtension; |
199 | } |
|
200 | 0 | return layoutDecoration.getBasePath( id + ext ); |
201 | } |
|
202 | ||
203 | public String getLayoutBasePath() |
|
204 | { |
|
205 | 0 | return layoutDecoration.getBasePath(); |
206 | } |
|
207 | public String getLayoutBasePath( String relativePath ) |
|
208 | { |
|
209 | 0 | return layoutDecoration.getBasePath( relativePath ); |
210 | } |
|
211 | ||
212 | public String getLayoutBaseUrl() |
|
213 | { |
|
214 | 0 | return getPortalResourceUrl( getLayoutBasePath(), false ); |
215 | } |
|
216 | public String getLayoutBaseUrl( String relativePath ) |
|
217 | { |
|
218 | 0 | return getPortalResourceUrl( getLayoutBasePath( relativePath ), false ); |
219 | } |
|
220 | ||
221 | public ResourceBundle getLayoutResourceBundle( Locale locale ) |
|
222 | { |
|
223 | 0 | return layoutDecoration.getResourceBundle( locale, this.context ); |
224 | } |
|
225 | ||
226 | public HeaderResource getHeaderResource() |
|
227 | { |
|
228 | 0 | return this.headerResource; |
229 | } |
|
230 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |