001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/sam/tags/sakai_2-4-1/samigo-app/src/java/org/sakaiproject/tool/assessment/settings/ApplicationEnvironment.java $
003: * $Id: ApplicationEnvironment.java 9268 2006-05-10 21:27:24Z daisyf@stanford.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the"License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.tool.assessment.settings;
021:
022: import org.apache.commons.logging.Log;
023: import org.apache.commons.logging.LogFactory;
024:
025: /**
026: * <p>Title: NavigoProject.org</p>
027: * <p>Description: OKI based implementation</p>
028: * <p>Copyright: Copyright 2003 Trustees of Indiana University</p>
029: * <p>Company: </p>
030: * @author <a href="mailto:lance@indiana.edu">Lance Speelmon</a>
031: * @version $Id: ApplicationEnvironment.java 9268 2006-05-10 21:27:24Z daisyf@stanford.edu $
032: */
033: public class ApplicationEnvironment
034: // extends AbstractCompositeObject
035: {
036: private static Log log = LogFactory
037: .getLog(ApplicationEnvironment.class);
038: private static ApplicationEnvironment _INSTANCE = new ApplicationEnvironment();
039: private boolean development = false;
040: private boolean testing = false;
041: private boolean regression = false;
042: private boolean staging = false;
043: private boolean training = false;
044: private boolean production = true; // favor secure production (safe than sorry)
045:
046: /**
047: * DOCUMENTATION PENDING
048: *
049: * @return DOCUMENTATION PENDING
050: */
051: public static ApplicationEnvironment getInstance() {
052: log.debug("getInstance()");
053:
054: return _INSTANCE;
055: }
056:
057: /**
058: * Creates a new ApplicationEnvironment object.
059: */
060: private ApplicationEnvironment() {
061: log.debug("new ApplicationEnvironment()");
062: PathInfo pathInfo = PathInfo.getInstance();
063: String pathToSecurity = pathInfo.getBasePathToSecurity();
064: if (log.isDebugEnabled()) {
065: log.debug("pathToSecurity=" + pathToSecurity);
066: }
067:
068: if ((pathToSecurity == null) || (pathToSecurity.length() < 1)) {
069: throw new IllegalStateException(
070: "PathInfo has not been initialized or is invalid");
071: }
072:
073: pathToSecurity = pathToSecurity.toUpperCase();
074: if (pathToSecurity.endsWith("DEV")) {
075: log.debug("pathToSecurity.endsWith(\"DEV\")");
076: this .development = true;
077: this .production = false;
078:
079: return;
080: }
081:
082: if (pathToSecurity.endsWith("TST")) {
083: log.debug("pathToSecurity.endsWith(\"TST\")");
084: this .testing = true;
085: this .production = false;
086:
087: return;
088: }
089:
090: if (pathToSecurity.endsWith("REG")) {
091: log.debug("pathToSecurity.endsWith(\"REG\")");
092: this .regression = true;
093: this .production = false;
094:
095: return;
096: }
097:
098: if (pathToSecurity.endsWith("STG")) {
099: log.debug("pathToSecurity.endsWith(\"STG\")");
100: this .staging = true;
101: this .production = false;
102:
103: return;
104: }
105:
106: if (pathToSecurity.endsWith("TRN")) {
107: log.debug("pathToSecurity.endsWith(\"TRN\")");
108: this .training = true;
109: this .production = false;
110:
111: return;
112: }
113:
114: if (pathToSecurity.endsWith("PRD")) {
115: log.debug("pathToSecurity.endsWith(\"PRD\")");
116: this .production = true;
117:
118: return;
119: }
120: }
121:
122: /**
123: * DOCUMENTATION PENDING
124: *
125: * @return DOCUMENTATION PENDING
126: */
127: public boolean isDevelopment() {
128: return development;
129: }
130:
131: /**
132: * DOCUMENTATION PENDING
133: *
134: * @return DOCUMENTATION PENDING
135: */
136: public boolean isTesting() {
137: return testing;
138: }
139:
140: /**
141: * DOCUMENTATION PENDING
142: *
143: * @return DOCUMENTATION PENDING
144: */
145: public boolean isRegression() {
146: return regression;
147: }
148:
149: /**
150: * DOCUMENTATION PENDING
151: *
152: * @return DOCUMENTATION PENDING
153: */
154: public boolean isStaging() {
155: return staging;
156: }
157:
158: /**
159: * DOCUMENTATION PENDING
160: *
161: * @return DOCUMENTATION PENDING
162: */
163: public boolean isProduction() {
164: return production;
165: }
166:
167: /**
168: * DOCUMENTATION PENDING
169: *
170: * @return DOCUMENTATION PENDING
171: */
172: public boolean isTraining() {
173: return training;
174: }
175: }
|