KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > web > config > ClientConfigElement


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.web.config;
18
19 import org.alfresco.config.ConfigElement;
20 import org.alfresco.config.element.ConfigElementAdapter;
21
22 /**
23  * Custom config element that represents config values for the client
24  *
25  * @author Kevin Roast
26  */

27 public class ClientConfigElement extends ConfigElementAdapter
28 {
29    public static final String JavaDoc CONFIG_ELEMENT_ID = "client";
30    
31    private String JavaDoc fromEmailAddress = "alfresco@alfresco.org";
32    private String JavaDoc errorPage = null;
33    private String JavaDoc loginPage = null;
34    private int recentSpacesItems = 6;
35    private boolean shelfVisible = true;
36    private int searchMinimum = 3;
37    private boolean forceAndTerms = false;
38    private int searchMaxResults = -1;
39    private String JavaDoc helpUrl = null;
40    private String JavaDoc editLinkType = null;
41    private String JavaDoc homeSpacePermission = null;
42    
43    /**
44     * Default Constructor
45     */

46    public ClientConfigElement()
47    {
48       super(CONFIG_ELEMENT_ID);
49    }
50    
51    /**
52     * Constructor
53     *
54     * @param name Name of the element this config element represents
55     */

56    public ClientConfigElement(String JavaDoc name)
57    {
58       super(name);
59    }
60
61    /**
62     * @see org.alfresco.config.element.ConfigElementAdapter#combine(org.alfresco.config.ConfigElement)
63     */

64    public ConfigElement combine(ConfigElement configElement)
65    {
66       ClientConfigElement existingElement = (ClientConfigElement)configElement;
67       ClientConfigElement newElement = new ClientConfigElement();
68       
69       // set those values that have changed
70
if (existingElement.getEditLinkType() == null)
71       {
72          newElement.setEditLinkType(this.editLinkType);
73       }
74       else
75       {
76          newElement.setEditLinkType(existingElement.getEditLinkType());
77       }
78       
79       if (existingElement.getErrorPage() == null)
80       {
81          newElement.setErrorPage(this.errorPage);
82       }
83       else
84       {
85          newElement.setErrorPage(existingElement.getErrorPage());
86       }
87       
88       if (existingElement.getLoginPage() == null)
89       {
90          newElement.setLoginPage(this.loginPage);
91       }
92       else
93       {
94          newElement.setLoginPage(existingElement.getLoginPage());
95       }
96       
97       if (existingElement.getHelpUrl() == null )
98       {
99          newElement.setHelpUrl(this.helpUrl);
100       }
101       else
102       {
103          newElement.setHelpUrl(existingElement.getHelpUrl());
104       }
105       
106       if (existingElement.getHomeSpacePermission() == null)
107       {
108          newElement.setHomeSpacePermission(this.homeSpacePermission);
109       }
110       else
111       {
112          newElement.setHomeSpacePermission(existingElement.getHomeSpacePermission());
113       }
114       
115       // override default values if they have changed
116
if (existingElement.getRecentSpacesItems() != newElement.getRecentSpacesItems())
117       {
118          newElement.setRecentSpacesItems(existingElement.getRecentSpacesItems());
119       }
120       
121       if (existingElement.getSearchMinimum() != newElement.getSearchMinimum())
122       {
123          newElement.setSearchMinimum(existingElement.getSearchMinimum());
124       }
125       
126       if (existingElement.getForceAndTerms() != newElement.getForceAndTerms())
127       {
128          newElement.setForceAndTerms(existingElement.getForceAndTerms());
129       }
130       
131       if (existingElement.getSearchMaxResults() != newElement.getSearchMaxResults())
132       {
133          newElement.setSearchMaxResults(existingElement.getSearchMaxResults());
134       }
135       
136       if (existingElement.isShelfVisible() != newElement.isShelfVisible())
137       {
138          newElement.setShelfVisible(existingElement.isShelfVisible());
139       }
140       
141       if (existingElement.getFromEmailAddress() != null &&
142           (existingElement.getFromEmailAddress().equals(newElement.getFromEmailAddress()) == false))
143       {
144          newElement.setFromEmailAddress(existingElement.getFromEmailAddress());
145       }
146       
147       return newElement;
148    }
149    
150    /**
151     * @return Returns the recentSpacesItems.
152     */

153    public int getRecentSpacesItems()
154    {
155       return this.recentSpacesItems;
156    }
157
158    /**
159     * @param recentSpacesItems The recentSpacesItems to set.
160     */

161    /*package*/ void setRecentSpacesItems(int recentSpacesItems)
162    {
163       this.recentSpacesItems = recentSpacesItems;
164    }
165    
166    /**
167     * @return Returns if the shelf component is visible by default.
168     */

169    public boolean isShelfVisible()
170    {
171       return this.shelfVisible;
172    }
173
174    /**
175     * @param shelfVisible True if the shelf component is visible by default.
176     */

177    /*package*/ void setShelfVisible(boolean shelfVisible)
178    {
179       this.shelfVisible = shelfVisible;
180    }
181
182    /**
183     * @return The error page the application should use
184     */

185    public String JavaDoc getErrorPage()
186    {
187       return this.errorPage;
188    }
189
190    /**
191     * @param errorPage Sets the error page
192     */

193    /*package*/ void setErrorPage(String JavaDoc errorPage)
194    {
195       this.errorPage = errorPage;
196    }
197    
198    /**
199     * @return Returns the login Page.
200     */

201    public String JavaDoc getLoginPage()
202    {
203       return this.loginPage;
204    }
205    
206    /**
207     * @param loginPage The login Page to set.
208     */

209    /*package*/ void setLoginPage(String JavaDoc loginPage)
210    {
211       this.loginPage = loginPage;
212    }
213    
214    /**
215     * @return Returns the help Url.
216     */

217    public String JavaDoc getHelpUrl()
218    {
219       return this.helpUrl;
220    }
221
222    /**
223     * @param helpUrl The help Url to set.
224     */

225    /*package*/ void setHelpUrl(String JavaDoc helpUrl)
226    {
227       this.helpUrl = helpUrl;
228    }
229    
230    /**
231     * @return Returns the from email address, if one has not been set
232     * alfresco@alfresco.org will be returned
233     */

234    public String JavaDoc getFromEmailAddress()
235    {
236       return this.fromEmailAddress;
237    }
238
239    /**
240     * @param fromEmailAddress The from email address to set
241     */

242    /*package*/ void setFromEmailAddress(String JavaDoc fromEmailAddress)
243    {
244       this.fromEmailAddress = fromEmailAddress;
245    }
246    
247    /**
248     * @return Returns the edit link type.
249     */

250    public String JavaDoc getEditLinkType()
251    {
252       return this.editLinkType;
253    }
254
255    /**
256     * @param editLinkType The edit link type to set.
257     */

258    /*package*/ void setEditLinkType(String JavaDoc editLinkType)
259    {
260       this.editLinkType = editLinkType;
261    }
262
263    /**
264     * @return Returns the search minimum number of characters.
265     */

266    public int getSearchMinimum()
267    {
268       return this.searchMinimum;
269    }
270
271    /**
272     * @param searchMinimum The searchMinimum to set.
273     */

274    /*package*/ void setSearchMinimum(int searchMinimum)
275    {
276       this.searchMinimum = searchMinimum;
277    }
278    
279    /**
280     * @return If true enables AND text terms for simple/advanced search by default.
281     */

282    public boolean getForceAndTerms()
283    {
284       return this.forceAndTerms;
285    }
286
287    /**
288     * @param forceAndTerms True to enable AND text terms for simple/advanced search by default.
289     */

290    /*package*/ void setForceAndTerms(boolean forceAndTerms)
291    {
292       this.forceAndTerms = forceAndTerms;
293    }
294
295    /**
296     * If positive, this will limit the size of the result set from the search.
297     *
298     * @return
299     */

300    
301    public int getSearchMaxResults()
302    {
303        return searchMaxResults;
304    }
305
306    /**
307     * Set if the the result set from a search will be of limited size.
308     * If negative it is unlimited, by convention, this is set to -1.
309     *
310     * @param searchMaxResults
311     */

312    /*package*/ void setSearchMaxResults(int searchMaxResults)
313    {
314        this.searchMaxResults = searchMaxResults;
315    }
316
317    /**
318     * @return Returns the default Home Space permissions.
319     */

320    public String JavaDoc getHomeSpacePermission()
321    {
322       return this.homeSpacePermission;
323    }
324
325    /**
326     * @param homeSpacePermission The default Home Space permission to set.
327     */

328    /*package*/ void setHomeSpacePermission(String JavaDoc homeSpacePermission)
329    {
330       this.homeSpacePermission = homeSpacePermission;
331    }
332 }
333
Popular Tags