Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
CoreConfigHelper |
|
| 2.5;2.5 |
1 | /* | |
2 | * Copyright 2011 The Kuali Foundation | |
3 | * | |
4 | * Licensed under the Educational Community License, Version 1.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.opensource.org/licenses/ecl1.php | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | package org.kuali.rice.core.api.config; | |
17 | ||
18 | import org.apache.commons.lang.StringUtils; | |
19 | import org.kuali.rice.core.api.CoreConstants; | |
20 | import org.kuali.rice.core.api.config.property.ConfigContext; | |
21 | ||
22 | /** | |
23 | * A utility class to help with retrieving commong configuration parameters. | |
24 | * | |
25 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
26 | * | |
27 | */ | |
28 | public final class CoreConfigHelper { | |
29 | ||
30 | /** | |
31 | * Returns the ID of this application. | |
32 | * | |
33 | * @return the ID of this application, should never return a null or blank value | |
34 | * | |
35 | * @throws IllegalStateException if the application ID is not configured properly | |
36 | */ | |
37 | public static String getApplicationId() { | |
38 | 0 | String applicationId = ConfigContext.getCurrentContextConfig().getProperty(CoreConstants.Config.APPLICATION_ID); |
39 | 0 | if (StringUtils.isBlank(applicationId)) { |
40 | 0 | throw new IllegalStateException(CoreConstants.Config.APPLICATION_ID + " configuration parameter was not configured, please configure a proper non-empty value."); |
41 | } | |
42 | 0 | return applicationId; |
43 | } | |
44 | ||
45 | 0 | private CoreConfigHelper() { |
46 | 0 | throw new UnsupportedOperationException("Should never be invoked!"); |
47 | } | |
48 | ||
49 | } |