001: /*
002: * Copyright 2002-2005 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not 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.
015: */
016:
017: package info.jtrac.domain;
018:
019: import java.io.Serializable;
020: import java.util.LinkedHashSet;
021: import java.util.Set;
022:
023: /**
024: * Simple name value pair to hold configuration parameters
025: * in the database for JTrac, e.g. SMTP e-mail server, etc.
026: * TODO better validation, type-safety, masking of mail server password
027: */
028: public class Config implements Serializable {
029:
030: private String param; // someone reported that "key" is a reserved word in MySQL
031: private String value;
032:
033: private static final Set<String> PARAMS;
034:
035: // set up a static set of valid config key names
036: static {
037: PARAMS = new LinkedHashSet<String>();
038: PARAMS.add("mail.server.host");
039: PARAMS.add("mail.server.port");
040: PARAMS.add("mail.server.username");
041: PARAMS.add("mail.server.password");
042: PARAMS.add("mail.server.starttls.enable");
043: PARAMS.add("mail.subject.prefix");
044: PARAMS.add("mail.from");
045: PARAMS.add("mail.session.jndiname");
046: PARAMS.add("jtrac.url.base");
047: PARAMS.add("locale.default");
048: PARAMS.add("session.timeout");
049: PARAMS.add("attachment.maxsize");
050: }
051:
052: public static Set<String> getParams() {
053: return PARAMS;
054: }
055:
056: public Config() {
057: // zero arg constructor
058: }
059:
060: public Config(String param, String value) {
061: this .param = param;
062: this .value = value;
063: }
064:
065: public boolean isMailConfig() {
066: return param.startsWith("mail.")
067: || param.startsWith("jtrac.url.");
068: }
069:
070: public boolean isAttachmentConfig() {
071: return param.startsWith("attachment.");
072: }
073:
074: public boolean isSessionTimeoutConfig() {
075: return param.startsWith("session.");
076: }
077:
078: public boolean isLocaleConfig() {
079: return param.startsWith("locale.");
080: }
081:
082: //==========================================================================
083:
084: public String getParam() {
085: return param;
086: }
087:
088: public void setParam(String param) {
089: this .param = param;
090: }
091:
092: public String getValue() {
093: return value;
094: }
095:
096: public void setValue(String value) {
097: this.value = value;
098: }
099:
100: }
|