001: /*
002: * Copyright (c) 2001 - 2005 ivata limited.
003: * All rights reserved.
004: * -----------------------------------------------------------------------------
005: * ivata groupware may be redistributed under the GNU General Public
006: * License as published by the Free Software Foundation;
007: * version 2 of the License.
008: *
009: * These programs are free software; you can redistribute them and/or
010: * modify them under the terms of the GNU General Public License
011: * as published by the Free Software Foundation; version 2 of the License.
012: *
013: * These programs are distributed in the hope that they will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: *
017: * See the GNU General Public License in the file LICENSE.txt for more
018: * details.
019: *
020: * If you would like a copy of the GNU General Public License write to
021: *
022: * Free Software Foundation, Inc.
023: * 59 Temple Place - Suite 330
024: * Boston, MA 02111-1307, USA.
025: *
026: *
027: * To arrange commercial support and licensing, contact ivata at
028: * http://www.ivata.com/contact.jsp
029: * -----------------------------------------------------------------------------
030: * $Log: Settings.java,v $
031: * Revision 1.1 2005/09/29 13:06:05 colinmacleod
032: * First version of setting subproject.
033: * Existing classes restructured, new setting user interface created.
034: * Flexible XML UI configuration makes it easy to reuse the same web pages in
035: * other projects.
036: * Web files work as stand-alone webapp for testing.
037: *
038: * Revision 1.2 2005/04/09 17:19:57 colinmacleod
039: * Changed copyright text to GPL v2 explicitly.
040: *
041: * Revision 1.1.1.1 2005/03/10 17:51:36 colinmacleod
042: * Restructured ivata op around Hibernate/PicoContainer.
043: * Renamed ivata groupware.
044: *
045: * Revision 1.3 2004/11/12 18:16:07 colinmacleod
046: * Ordered imports.
047: *
048: * Revision 1.2 2004/11/12 15:57:19 colinmacleod
049: * Removed dependencies on SSLEXT.
050: * Moved Persistence classes to ivata masks.
051: *
052: * Revision 1.1 2004/09/30 15:15:59 colinmacleod
053: * Split off addressbook elements into security subproject.
054: *
055: * Revision 1.2 2004/07/13 19:54:31 colinmacleod
056: * Moved project to POJOs from EJBs.
057: * Applied PicoContainer to services layer (replacing session EJBs).
058: * Applied Hibernate to persistence layer (replacing entity EJBs).
059: * -----------------------------------------------------------------------------
060: */
061: package com.ivata.groupware.admin.setting;
062:
063: import java.util.Locale;
064: import java.util.Map;
065:
066: import com.ivata.groupware.admin.security.server.SecuritySession;
067: import com.ivata.groupware.admin.security.user.UserDO;
068: import com.ivata.mask.util.SystemException;
069: import com.ivata.mask.validation.ValidationErrors;
070:
071: /**
072: * @author Colin MacLeod
073: * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
074: * @since Apr 3, 2004
075: * @version $Revision: 1.1 $
076: */
077: public interface Settings {
078: /**
079: * <p>
080: * Change the value of an existing setting.
081: * </p>
082: *
083: * @param name the name of the setting to set
084: * @param value new value to be set.
085: * @param user if not <code>null</code>, then the setting for this user
086: * is set, otherwise the general setting is changed.
087: */
088: void amendSetting(final SecuritySession securitySession,
089: final String name, final Object value, final UserDO user)
090: throws SystemException;
091:
092: /**
093: * <p>Get a setting of class <code>Boolean</code>.</p>
094: *
095: * @return the setting if set, or null if not
096: * @param name the name of the setting to return the value for
097: * @param userName the user to search for. If null is specified, the
098: * default setting is searched for and returned if found.
099: * @exception SettingsDataTypeException if the setting has any class other
100: * than Boolean
101: * @return a setting of class <code>Boolean</code> for the setting
102: * name provided.
103: * @see #getSetting
104: * @see #getIntegerSetting
105: * @see #getStringSetting
106: * @throws SettingNullException if this setting does not exist.
107: */
108: Boolean getBooleanSetting(final SecuritySession securitySession,
109: final String name, final UserDO userDO)
110: throws SystemException;
111:
112: /**
113: * <p>Get a setting of class <code>Integer</code>.</p>
114: *
115: * @exception SettingsDataTypeException if the setting has any class other
116: * than Integer.
117: * @return the setting if set, or null if not
118: * @param name the name of the setting to return the value for.
119: * @param userName the user to search for. If null is specified, the
120: * default setting is searched for and returned if found.
121: * @return a setting of class <code>Integer</code> for the setting
122: * name provided.
123: * @see #getSetting
124: * @see #getStringSetting
125: * @see #getBooleanSetting
126: * @throws SettingNullException if this setting does not exist.
127: */
128: Integer getIntegerSetting(final SecuritySession securitySession,
129: final String name, final UserDO userDO)
130: throws SystemException;
131:
132: /**
133: * <p>Get a setting for a given user. The class of the returned object will
134: * depend on the <code>type</code> field of the EJB with this name and can
135: * be one of:</br/>
136: * <ul>
137: * <li><code>Integer</code></li>
138: * <li><code>String</code></li>
139: * <li><code>Boolean</code></li></p>
140: *
141: * @return the setting if set, or null if not
142: * @param name the name of the setting to return the value for
143: * @param userName the user to search for. If null is specified, the
144: * default setting is searched for and returned if found.
145: * @return a setting with the setting name provided. The type of the
146: * returned object depends on the <code>type</code> field of the
147: * setting.
148: * @see #getIntegerSetting
149: * @see #getStringSetting
150: * @see #getBooleanSetting
151: * @throws SettingNullException if this setting does not exist.
152: */
153: Object getSetting(final SecuritySession securitySession,
154: final String name, final UserDO userDO)
155: throws SystemException;
156:
157: /**
158: * <p>Get the type of a setting</p>
159: * @param name the name of the setting
160: * @return one of the static fields of <code>SettingConstants</code>
161: * @throws SettingNullException if this setting does not exist.
162: */
163: int getSettingType(final SecuritySession securitySession,
164: final String name) throws SystemException;
165:
166: /**
167: * <p>Get a setting of class String.</p>
168: *
169: * @return the setting if set, or null if not
170: * @param name the name of the setting to return the value for
171: * @param userName the user to search for. If null is specified, the
172: * default setting is searched for and returned if found.
173: * @exception SettingsDataTypeException if the setting has any class other
174: * than String
175: * @return a setting of class <code>String</code> for the setting
176: * name provided.
177: * @see #getSetting
178: * @see #getIntegerSetting
179: * @see #getBooleanSetting
180: * @throws SettingNullException if this setting does not exist.
181: */
182: String getStringSetting(final SecuritySession securitySession,
183: final String name, final UserDO userDO)
184: throws SystemException;
185:
186: /**
187: * <p>
188: * Find out whether or not a setting is enabled.
189: * </p>
190: *
191: * @param securitySession valid security session.
192: * @param name name of the setting to check.
193: * @return <code>true</code> if the setting exists and is enabled.
194: * @throws SystemException if it don't work out in some way :-)
195: */
196: boolean isSettingEnabled(final SecuritySession securitySession,
197: final String name) throws SystemException;
198:
199: /**
200: * <p>
201: * Revert a user setting back to the general value.
202: * </p>
203: *
204: * @param name the name of the setting to revert
205: * @param user the setting for this user is reverted
206: */
207: void revertSetting(final SecuritySession securitySession,
208: final String name, final UserDO user)
209: throws SystemException;
210:
211: /**
212: * <p>Confirm all of the settings passed are correct.</p>
213: *
214: * @param settings a <code>Map</code> with setting names as keys and setting
215: * values as values
216: * @param the <code>Locale</code> to get localised error messages
217: * @param settingType one of the constants in <code>SettingConstants</code>:
218: * <code>SETTING_USER</code> or <code>SETTING_SYSTEM</code>
219: * @return a collection of validation errors if any of the settings contains
220: * invalid value.
221: */
222: ValidationErrors validate(final SecuritySession securitySession,
223: final Map settings, final Locale locale,
224: final int settingType) throws SystemException;
225: }
|