01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
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 edu.iu.uis.eden.web;
18:
19: import org.apache.commons.lang.StringUtils;
20: import org.kuali.rice.core.Core;
21:
22: import edu.iu.uis.eden.exception.WorkflowRuntimeException;
23:
24: /**
25: * A resolver for URLs for the user, user report, workgroup and workgroup
26: * report screens.
27: *
28: * @author ewestfal
29: */
30: public class UrlResolver {
31:
32: private static final UrlResolver INSTANCE = new UrlResolver();
33:
34: public static final String USER_URL = "user.url";
35: public static final String USER_REPORT_URL = "user.report.url";
36: public static final String WORKGROUP_URL = "workgroup.url";
37: public static final String WORKGROUP_REPORT_URL = "workgroup.report.url";
38:
39: public static UrlResolver getInstance() {
40: return INSTANCE;
41: }
42:
43: public String getUserUrl() {
44: return getUrl(USER_URL);
45: }
46:
47: public String getUserReportUrl() {
48: return getUrl(USER_REPORT_URL);
49: }
50:
51: public String getWorkgroupUrl() {
52: return getUrl(WORKGROUP_URL);
53: }
54:
55: public String getWorkgroupReportUrl() {
56: return getUrl(WORKGROUP_REPORT_URL);
57: }
58:
59: protected String getUrl(String urlName) {
60: String url = Core.getCurrentContextConfig()
61: .getProperty(urlName);
62: if (StringUtils.isEmpty(url)) {
63: throw new WorkflowRuntimeException(
64: "Could not locate the url value for '"
65: + urlName
66: + "'. Please be sure to configure it properly in your workflow.xml.");
67: }
68: return url;
69: }
70:
71: }
|