KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > admin > setting > Settings


1 /*
2  * Copyright (c) 2001 - 2005 ivata limited.
3  * All rights reserved.
4  * -----------------------------------------------------------------------------
5  * ivata groupware may be redistributed under the GNU General Public
6  * License as published by the Free Software Foundation;
7  * version 2 of the License.
8  *
9  * These programs are free software; you can redistribute them and/or
10  * modify them under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; version 2 of the License.
12  *
13  * These programs are distributed in the hope that they will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * See the GNU General Public License in the file LICENSE.txt for more
18  * details.
19  *
20  * If you would like a copy of the GNU General Public License write to
21  *
22  * Free Software Foundation, Inc.
23  * 59 Temple Place - Suite 330
24  * Boston, MA 02111-1307, USA.
25  *
26  *
27  * To arrange commercial support and licensing, contact ivata at
28  * http://www.ivata.com/contact.jsp
29  * -----------------------------------------------------------------------------
30  * $Log: Settings.java,v $
31  * Revision 1.2 2005/04/09 17:19:57 colinmacleod
32  * Changed copyright text to GPL v2 explicitly.
33  *
34  * Revision 1.1.1.1 2005/03/10 17:51:36 colinmacleod
35  * Restructured ivata op around Hibernate/PicoContainer.
36  * Renamed ivata groupware.
37  *
38  * Revision 1.3 2004/11/12 18:16:07 colinmacleod
39  * Ordered imports.
40  *
41  * Revision 1.2 2004/11/12 15:57:19 colinmacleod
42  * Removed dependencies on SSLEXT.
43  * Moved Persistence classes to ivata masks.
44  *
45  * Revision 1.1 2004/09/30 15:15:59 colinmacleod
46  * Split off addressbook elements into security subproject.
47  *
48  * Revision 1.2 2004/07/13 19:54:31 colinmacleod
49  * Moved project to POJOs from EJBs.
50  * Applied PicoContainer to services layer (replacing session EJBs).
51  * Applied Hibernate to persistence layer (replacing entity EJBs).
52  * -----------------------------------------------------------------------------
53  */

54 package com.ivata.groupware.admin.setting;
55
56 import java.util.Locale JavaDoc;
57 import java.util.Map JavaDoc;
58
59 import com.ivata.groupware.admin.security.server.SecuritySession;
60 import com.ivata.groupware.admin.security.user.UserDO;
61 import com.ivata.mask.util.SystemException;
62 import com.ivata.mask.validation.ValidationErrors;
63
64 /**
65  * @author Colin MacLeod
66  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
67  * @since Apr 3, 2004
68  * @version $Revision: 1.2 $
69  */

70 public interface Settings {
71     /**
72      * <p>
73      * Change the value of an existing setting.
74      * </p>
75      *
76      * @param name the name of the setting to set
77      * @param value new value to be set.
78      * @param user if not <code>null</code>, then the setting for this user
79      * is set, otherwise the general setting is changed.
80      */

81     void amendSetting(final SecuritySession securitySession,
82             final String JavaDoc name,
83             final Object JavaDoc value,
84             final UserDO user)
85             throws SystemException;
86
87     /**
88      * <p>Get a setting of class <code>Boolean</code>.</p>
89      *
90      * @return the setting if set, or null if not
91      * @param name the name of the setting to return the value for
92      * @param userName the user to search for. If null is specified, the
93      * default setting is searched for and returned if found.
94      * @exception SettingsDataTypeException if the setting has any class other
95      * than Boolean
96      * @return a setting of class <code>Boolean</code> for the setting
97      * name provided.
98      * @see #getSetting
99      * @see #getIntegerSetting
100      * @see #getStringSetting
101      * @throws SettingNullException if this setting does not exist.
102      */

103     Boolean JavaDoc getBooleanSetting(final SecuritySession securitySession,
104             final String JavaDoc name,
105             final UserDO userDO)
106         throws SystemException;
107
108     /**
109      * <p>Get a setting of class <code>Integer</code>.</p>
110      *
111      * @exception SettingsDataTypeException if the setting has any class other
112      * than Integer.
113      * @return the setting if set, or null if not
114      * @param name the name of the setting to return the value for.
115      * @param userName the user to search for. If null is specified, the
116      * default setting is searched for and returned if found.
117      * @return a setting of class <code>Integer</code> for the setting
118      * name provided.
119      * @see #getSetting
120      * @see #getStringSetting
121      * @see #getBooleanSetting
122      * @throws SettingNullException if this setting does not exist.
123      */

124     Integer JavaDoc getIntegerSetting(final SecuritySession securitySession,
125             final String JavaDoc name,
126             final UserDO userDO)
127         throws SystemException;
128
129     /**
130      * <p>Get a setting for a given user. The class of the returned object will
131      * depend on the <code>type</code> field of the EJB with this name and can
132      * be one of:</br/>
133      * <ul>
134      * <li><code>Integer</code></li>
135      * <li><code>String</code></li>
136      * <li><code>Boolean</code></li></p>
137      *
138      * @return the setting if set, or null if not
139      * @param name the name of the setting to return the value for
140      * @param userName the user to search for. If null is specified, the
141      * default setting is searched for and returned if found.
142      * @return a setting with the setting name provided. The type of the
143      * returned object depends on the <code>type</code> field of the
144      * setting.
145      * @see #getIntegerSetting
146      * @see #getStringSetting
147      * @see #getBooleanSetting
148      * @throws SettingNullException if this setting does not exist.
149      */

150     Object JavaDoc getSetting(final SecuritySession securitySession,
151             final String JavaDoc name,
152             final UserDO userDO)
153         throws SystemException;
154
155     /**
156      * <p>Get the type of a setting</p>
157      * @param name the name of the setting
158      * @return one of the static fields of <code>SettingConstants</code>
159      * @throws SettingNullException if this setting does not exist.
160      */

161     int getSettingType(final SecuritySession securitySession,
162             final String JavaDoc name)
163         throws SystemException;
164
165     /**
166      * <p>Get a setting of class String.</p>
167      *
168      * @return the setting if set, or null if not
169      * @param name the name of the setting to return the value for
170      * @param userName the user to search for. If null is specified, the
171      * default setting is searched for and returned if found.
172      * @exception SettingsDataTypeException if the setting has any class other
173      * than String
174      * @return a setting of class <code>String</code> for the setting
175      * name provided.
176      * @see #getSetting
177      * @see #getIntegerSetting
178      * @see #getBooleanSetting
179      * @throws SettingNullException if this setting does not exist.
180      */

181     String JavaDoc getStringSetting(final SecuritySession securitySession,
182             final String JavaDoc name,
183             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 JavaDoc
198         name)
199         throws SystemException;
200
201     /**
202      * <p>
203      * Revert a user setting back to the general value.
204      * </p>
205      *
206      * @param name the name of the setting to revert
207      * @param user the setting for this user is reverted
208      */

209     void revertSetting(final SecuritySession securitySession,
210             final String JavaDoc name,
211             final UserDO user)
212             throws SystemException;
213
214     /**
215      * <p>Confirm all of the settings passed are correct.</p>
216      *
217      * @param settings a <code>Map</code> with setting names as keys and setting
218      * values as values
219      * @param the <code>Locale</code> to get localised error messages
220      * @param settingType one of the constants in <code>SettingConstants</code>:
221      * <code>SETTING_USER</code> or <code>SETTING_SYSTEM</code>
222      * @return a collection of validation errors if any of the settings contains
223      * invalid value.
224      */

225     ValidationErrors validate(final SecuritySession securitySession,
226             final Map JavaDoc settings,
227             final Locale JavaDoc locale,
228             final int settingType)
229         throws SystemException;
230 }
Popular Tags