001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. The ASF licenses this file to You
004: * under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License. For additional information regarding
015: * copyright in this work, please see the NOTICE file in the top level
016: * directory of this distribution.
017: */
018: /*
019: * Created on Mar 4, 2004
020: */
021: package org.apache.roller.ui;
022:
023: import java.io.File;
024:
025: import javax.servlet.ServletContext;
026: import javax.servlet.ServletContextEvent;
027: import javax.servlet.http.HttpServletRequest;
028:
029: import org.apache.commons.logging.Log;
030: import org.apache.commons.logging.LogFactory;
031: import org.apache.roller.RollerException;
032: import org.apache.roller.ui.core.*;
033:
034: /**
035: * @author lance.lavandowska
036: */
037: public class MockRollerContext extends RollerContext {
038: private static Log mLogger = LogFactory.getFactory().getInstance(
039: MockRollerContext.class);
040:
041: private static ServletContext mContext = null;
042:
043: public void init(ServletContext sc) {
044: mLogger.debug("MockRollerContext initializing");
045:
046: // initialize super
047: super .contextInitialized(new ServletContextEvent(sc));
048:
049: // Save context in self and self in context
050: mContext = sc;
051: mContext.setAttribute(ROLLER_CONTEXT, this );
052: mContext.setAttribute("org.apache.roller.absoluteContextURL",
053: "/");
054: }
055:
056: //-----------------------------------------------------------------------
057: /** Because I cannot set the super's values, I have to
058: * overide the methods as well */
059: public static RollerContext getRollerContext() {
060: // get roller from servlet context
061: return (RollerContext) mContext.getAttribute(ROLLER_CONTEXT);
062: }
063:
064: //-----------------------------------------------------------------------
065: /** Because I cannot set the super's values, I have to
066: * overide the methods as well */
067: public static ServletContext getServletContext() {
068: return mContext;
069: }
070:
071: //-----------------------------------------------------------------------
072: /** Because I cannot set the super's values, I have to
073: * overide the methods as well */
074: public String getRollerVersion() {
075: return super .getRollerVersion();
076: }
077:
078: //-----------------------------------------------------------------------
079: /** Because I cannot set the super's values, I have to
080: * overide the methods as well */
081: public String getRollerBuildTime() {
082: return super .getRollerBuildTime();
083: }
084:
085: //-----------------------------------------------------------------------
086: /** Because I cannot set the super's values, I have to
087: * overide the methods as well */
088: public String getRollerBuildUser() {
089: return super .getRollerBuildUser();
090: }
091:
092: //-----------------------------------------------------------------------
093: /** Because I cannot set the super's values, I have to
094: * overide the methods as well */
095: public String getAbsoluteContextUrl() {
096: return "";
097: }
098:
099: //-----------------------------------------------------------------------
100: /** Because I cannot set the super's values, I have to
101: * overide the methods as well */
102: public String getAbsoluteContextUrl(HttpServletRequest request) {
103: return "http://localhost:8080/roller";
104: }
105:
106: //-----------------------------------------------------------------------
107: /** Because I cannot set the super's values, I have to
108: * overide the methods as well */
109: /* not available anymore ... use the new config classes instead -- Allen G
110: public RollerConfigData getRollerConfig()
111: {
112: return super.getRollerConfig();
113: }
114: */
115: //------------------------------------------------------------------------
116: public String getConfigPath() {
117: String root = System.getProperty("ro.build");
118: String configPath = root + File.separator + "roller"
119: + File.separator + "WEB-INF" + File.separator
120: + "roller-config.xml";
121: return configPath;
122: }
123:
124: protected void upgradeDatabaseIfNeeded() throws RollerException {
125: // for now, this is a no-op
126: }
127:
128: }
|