001: package org.nemesis.forum.config;
002:
003: import java.util.ArrayList;
004: import java.util.Iterator;
005: import java.util.List;
006: import java.util.Properties;
007:
008: import org.apache.commons.lang.StringUtils;
009: import org.nemesis.forum.search.Indexer;
010:
011: /**
012: * @author dlaurent
013: *
014: * application configuration
015: * @see nemesis-forum-config.xml
016: */
017: public class Config {
018:
019: public static String DATA_DIR = InitServlet.DATA_PATH;
020:
021: private String JDBCConnectionProviderClass = null;
022:
023: private Properties JDBCProviderProperties = new Properties();
024:
025: private List userExtendedProperties = new ArrayList();
026: private List forumExtendedProperties = new ArrayList();
027: private List messageExtendedProperties = new ArrayList();
028:
029: private boolean autoIndex = false;
030:
031: /**
032: * protected constructor
033: */
034: protected Config() {
035: super ();
036: new Indexer();
037: }
038:
039: public void addUserExtendedProperties(String s) {
040: userExtendedProperties.add(s);
041: }
042:
043: public void addForumExtendedProperties(String s) {
044: forumExtendedProperties.add(s);
045: }
046:
047: public void addMessageExtendedProperties(String s) {
048: messageExtendedProperties.add(s);
049: }
050:
051: public void addJDBCProviderProperties(String key, String value) {
052: JDBCProviderProperties.put(key, StringUtils.replace(value,
053: "{data.dir}", DATA_DIR));
054: }
055:
056: /**
057: * @return the JDBC provider class
058: */
059: public String getJDBCConnectionProviderClass() {
060: return JDBCConnectionProviderClass;
061: }
062:
063: /**
064: * @param string the provider class
065: */
066: public void setJDBCConnectionProviderClass(String string) {
067: JDBCConnectionProviderClass = string;
068: }
069:
070: /**
071: * @return
072: */
073: public List getForumExtendedProperties() {
074: return forumExtendedProperties;
075: }
076:
077: /**
078: * @return
079: */
080: public Properties getJDBCProviderProperties() {
081: return JDBCProviderProperties;
082: }
083:
084: /**
085: * @return
086: */
087: public List getMessageExtendedProperties() {
088: return messageExtendedProperties;
089: }
090:
091: /**
092: * @return
093: */
094: public List getUserExtendedProperties() {
095: return userExtendedProperties;
096: }
097:
098: public String toString() {
099: StringBuffer sb = new StringBuffer("Config :\n");
100: sb.append("\nDATA_DIR:" + DATA_DIR);
101: sb.append("\nJDBCConnectionProviderClass:"
102: + JDBCConnectionProviderClass);
103: sb.append("\nJDBCProviderProperties:"
104: + JDBCProviderProperties.toString());
105:
106: sb.append("\nuserExtendedProperties:");
107: for (Iterator it = userExtendedProperties.iterator(); it
108: .hasNext();) {
109: sb.append("\n\t>" + it.next());
110: }
111: sb.append("\nforumExtendedProperties:");
112: for (Iterator it = forumExtendedProperties.iterator(); it
113: .hasNext();) {
114: sb.append("\n\t>" + it.next());
115: }
116: sb.append("\nmessageExtendedProperties:");
117: for (Iterator it = messageExtendedProperties.iterator(); it
118: .hasNext();) {
119: sb.append("\n\t>" + it.next());
120: }
121:
122: sb.append("\nautoindex:" + autoIndex);
123:
124: return sb.toString();
125: }
126:
127: /**
128: * @return datadir
129: */
130: public String getDataDir() {
131: return DATA_DIR;
132: }
133:
134: /**
135: * @return
136: */
137: public boolean isAutoIndex() {
138: return autoIndex;
139: }
140:
141: /**
142: * @param b
143: */
144: public void setAutoIndex(boolean b) {
145: autoIndex = b;
146: }
147:
148: }
|