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 Jun 18, 2004
020: */
021: package org.apache.roller.business.hibernate;
022:
023: import org.hibernate.Criteria;
024: import org.hibernate.HibernateException;
025: import org.hibernate.Session;
026: import org.apache.roller.RollerException;
027: import org.apache.roller.pojos.RollerConfigData;
028: import java.util.List;
029: import org.apache.commons.logging.Log;
030: import org.apache.commons.logging.LogFactory;
031: import org.apache.roller.business.ConfigManager;
032:
033: /**
034: * The *OLD* Roller configuration mechanism.
035: *
036: * This has been replaced by the PropertiesManager and the roller.properties
037: * file.
038: */
039: public class HibernateConfigManagerImpl implements ConfigManager {
040:
041: static final long serialVersionUID = -3674252864091781177L;
042:
043: private static Log log = LogFactory
044: .getLog(HibernateConfigManagerImpl.class);
045:
046: private HibernatePersistenceStrategy strategy = null;
047:
048: public HibernateConfigManagerImpl(
049: HibernatePersistenceStrategy strategy) {
050: log.debug("Instantiating Hibernate Config Manager");
051:
052: this .strategy = strategy;
053: }
054:
055: /**
056: * @see org.apache.roller.model.ConfigManager#storeRollerConfig(org.apache.roller.pojos.RollerConfig)
057: */
058: public void storeRollerConfig(RollerConfigData data)
059: throws RollerException {
060: // no longer supported
061: }
062:
063: /**
064: * This isn't part of the ConfigManager Interface, because really
065: * we shouldn't ever delete the RollerConfig. This is mostly here
066: * to assist with unit testing.
067: */
068: public void removeRollerConfig(String id) throws RollerException {
069: // no longer supported
070: }
071:
072: /**
073: * Fetch all RollerConfigs and return the first one, if any.
074: * Note: there should only be one!
075: * @see org.apache.roller.model.ConfigManager#getRollerConfig()
076: */
077: public RollerConfigData getRollerConfig() throws RollerException {
078:
079: log
080: .error("Someone is trying to use the old config!!\n"
081: + "This configuration mechanism has been deprecated\n"
082: + "You should see this message only once when you first upgrade\n"
083: + "your installation to roller 1.2\n\n"
084: + "If you continue to see this message please shoot us an email\n"
085: + "at roller-dev@incubator.apache.org with some output\n"
086: + "from your log files.\n");
087:
088: try {
089: Session session = this .strategy.getSession();
090: Criteria criteria = session
091: .createCriteria(RollerConfigData.class);
092: criteria.setMaxResults(1);
093: return (RollerConfigData) criteria.uniqueResult();
094: } catch (HibernateException e) {
095: throw new RollerException(e);
096: }
097: }
098:
099: public RollerConfigData readFromFile(String file) {
100: return null;
101: }
102:
103: public void release() {
104: }
105:
106: }
|