KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > business > hibernate > HibernateConfigManagerImpl


1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
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. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */

18 /*
19  * Created on Jun 18, 2004
20  */

21 package org.apache.roller.business.hibernate;
22
23 import org.hibernate.Criteria;
24 import org.hibernate.HibernateException;
25 import org.hibernate.Session;
26 import org.apache.roller.RollerException;
27 import org.apache.roller.pojos.RollerConfigData;
28 import java.util.List JavaDoc;
29 import org.apache.commons.logging.Log;
30 import org.apache.commons.logging.LogFactory;
31 import org.apache.roller.model.ConfigManager;
32
33
34 /**
35  * The *OLD* Roller configuration mechanism.
36  *
37  * This has been replaced by the PropertiesManager and the roller.properties
38  * file.
39  */

40 public class HibernateConfigManagerImpl implements ConfigManager {
41     
42     static final long serialVersionUID = -3674252864091781177L;
43     
44     private static Log log = LogFactory.getLog(HibernateConfigManagerImpl.class);
45     
46     private HibernatePersistenceStrategy strategy = null;
47     
48     
49     public HibernateConfigManagerImpl(HibernatePersistenceStrategy strategy) {
50         log.debug("Instantiating Hibernate Config Manager");
51         
52         this.strategy = strategy;
53     }
54     
55     
56     /**
57      * @see org.apache.roller.model.ConfigManager#storeRollerConfig(org.apache.roller.pojos.RollerConfig)
58      */

59     public void storeRollerConfig(RollerConfigData data) throws RollerException {
60         // no longer supported
61
}
62     
63     
64     /**
65      * This isn't part of the ConfigManager Interface, because really
66      * we shouldn't ever delete the RollerConfig. This is mostly here
67      * to assist with unit testing.
68      */

69     public void removeRollerConfig(String JavaDoc id) throws RollerException {
70         // no longer supported
71
}
72     
73     
74     /**
75      * Fetch all RollerConfigs and return the first one, if any.
76      * Note: there should only be one!
77      * @see org.apache.roller.model.ConfigManager#getRollerConfig()
78      */

79     public RollerConfigData getRollerConfig() throws RollerException {
80         
81         log.error("Someone is trying to use the old config!!\n"+
82                 "This configuration mechanism has been deprecated\n"+
83                 "You should see this message only once when you first upgrade\n"+
84                 "your installation to roller 1.2\n\n"+
85                 "If you continue to see this message please shoot us an email\n"+
86                 "at roller-dev@incubator.apache.org with some output\n"+
87                 "from your log files.\n");
88         
89         try {
90             Session session = this.strategy.getSession();
91             Criteria criteria = session.createCriteria(RollerConfigData.class);
92             criteria.setMaxResults(1);
93             return (RollerConfigData) criteria.uniqueResult();
94         } catch (HibernateException e) {
95             throw new RollerException(e);
96         }
97     }
98     
99     
100     public RollerConfigData readFromFile(String JavaDoc file) {
101         return null;
102     }
103     
104     
105     public void release() {}
106     
107 }
108
Popular Tags