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 */17packageorg.apache.jetspeed.container.url.impl;
1819import org.apache.commons.configuration.Configuration;
20import org.apache.commons.configuration.ConfigurationException;
21import org.apache.commons.configuration.PropertiesConfiguration;
22import org.apache.jetspeed.container.url.BasePortalURL;
2324/***25 * <p>26 * BasePortalURL defines the interface for manipulating Base URLs in a portal.27 * Base URLs contain the isSecure flag, server name, server port, and server scheme.28 * This abstraction was necessary for wiring the entire portal's base URL via another29 * mechanism than retrieving from the servlet request.30 * </p>31 * 32 * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>33 * @version $Id: $34 *35 */36publicclassBasePortalURLImpl implements BasePortalURL
37 {
38private String serverName;
39private String serverScheme;
40privateint serverPort;
41privateboolean secure;
4243publicBasePortalURLImpl()
44 {
45 }
4647/***48 * This constructor takes a string that represents the name of an49 * environment variable. The environment variable will be the full50 * path of a properties file to be loaded. Information from the51 * properties file will populate this object52 */53publicBasePortalURLImpl(String environmentPath) throws ConfigurationException
54 {
55 String propertyFilePath = null;
56if (environmentPath != null)
57 {
58 propertyFilePath = System.getProperty(environmentPath);
59 }
6061 PropertiesConfiguration config = null;
6263// Load the file if the path is provided64if (propertyFilePath != null)
65 {
66 config = new PropertiesConfiguration(propertyFilePath);
67 }
6869if (config != null)
70 {
71this.serverName = config.getString("portal.url.name");
72this.serverScheme = config.getString("portal.url.scheme");
73this.serverPort = config.getInt("portal.url.port");
74this.secure = config.getBoolean("portal.url.secure");
75 }
76 }
777879publicBasePortalURLImpl(Configuration config)
80 {
81this.serverName = config.getString("portal.url.name");
82this.serverScheme = config.getString("portal.url.scheme");
83this.serverPort = config.getInt("portal.url.port");
84this.secure = config.getBoolean("portal.url.secure");
85 }
8687publicBasePortalURLImpl(String serverScheme, String serverName, int serverPort, boolean secure)
88 {
89this.serverName = serverName;
90this.serverScheme = serverScheme;
91this.serverPort = serverPort;
92this.secure = secure;
93 }
9495publicboolean isSecure()
96 {
97return secure;
98 }
99100publicvoid setSecure(boolean secure)
101 {
102this.secure = secure;
103 }
104105public String getServerName()
106 {
107return serverName;
108 }
109110publicvoid setServerName(String serverName)
111 {
112this.serverName = serverName;
113 }
114115publicint getServerPort()
116 {
117return serverPort;
118 }
119120publicvoid setServerPort(int serverPort)
121 {
122this.serverPort = serverPort;
123 }
124125public String getServerScheme()
126 {
127return serverScheme;
128 }
129130publicvoid setServerScheme(String serverScheme)
131 {
132this.serverScheme = serverScheme;
133 }
134135 }