View Javadoc

1   /*
2    * $HeadURL: $
3    * $Date: $
4    * $Revision: $
5    * $Author: $
6    * 
7    * Copyright (c) 2005 MindTree Consulting Ltd. 
8    * 
9    * This file is part of Insight.
10   * 
11   * Insight is free software: you can redistribute it and/or modify it under the 
12   * terms of the GNU General Public License as published by the Free Software 
13   * Foundation, either version 3 of the License, or (at your option) any later 
14   * version.
15   * 
16   * Insight is distributed in the hope that it will be useful, but 
17   * WITHOUT ANY WARRANTY; without even the implied warranty of 
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General 
19   * Public License for more details.
20   * 
21   * You should have received a copy of the GNU General Public License along with 
22   * Insight.  If not, see <http://www.gnu.org/licenses/>.
23   */
24  
25  package com.mindtree.techworks.insight.preferences.util;
26  
27  import java.util.ArrayList;
28  import java.util.Collections;
29  import java.util.Iterator;
30  import java.util.List;
31  
32  import com.mindtree.techworks.insight.InsightConstants;
33  import com.mindtree.techworks.insight.download.FTPFileset;
34  import com.mindtree.techworks.insight.download.Fileset;
35  import com.mindtree.techworks.insight.download.HTTPFileset;
36  import com.mindtree.techworks.insight.download.ProxyInfo;
37  import com.mindtree.techworks.insight.download.SFTPFileset;
38  import com.mindtree.techworks.insight.preferences.PreferenceManager;
39  import com.mindtree.techworks.insight.preferences.model.Preference;
40  import com.mindtree.techworks.insight.preferences.model.PreferenceAttribute;
41  
42  /**
43   * The <code>PreferenceInterpreter</code> class is a utility that has static
44   * methods to interpret Preference instances and return data relevant to the
45   * client using the preference
46   * 
47   * @author Regunath B
48   * @version 1.0, 05/03/30
49   */
50  public class PreferenceInterpreter {
51  
52  	/**
53  	 * Constant for 'true' boolean value
54  	 */
55  	private static final String TRUE = "true";
56  
57  	//
58  	// Constants for Preference ids
59  	//
60  
61  	/**
62  	 * Preference containing the event columns
63  	 */
64  	private static final String DISPLAY_COLUMN = "eventcolumnpreference";
65  
66  	/**
67  	 * Preference containing the file sets
68  	 */
69  	private static final String FILESET = "fileset";
70  
71  	/**
72  	 * Preference containing the local filesets
73  	 */
74  	private static final String LOCAL_FILESETS = "local";
75  
76  	/**
77  	 * Preference containing the ftp filesets
78  	 */
79  	private static final String FTP_FILESETS = "ftpfiles";
80  
81  	/**
82  	 * Preference containing the ftp filesets
83  	 */
84  	private static final String SFTP_FILESETS = "sftpfiles";
85  	
86  	/**
87  	 * Preference containing the http filesets
88  	 */
89  	private static final String HTTP_FILESETS = "remote";
90  
91  	/**
92  	 * Preference containing the proxy information
93  	 */
94  	private static final String PROXY = "proxy";
95  
96  	//
97  	// Constants for PreferenceAttribute ids
98  	//
99  
100 	/**
101 	 * Preference Attribute for the load behaiviour
102 	 */
103 	private static final String SHOW_FILESETS = "showFilesetsOnLoad";
104 
105 	/**
106 	 * Preference Attribute for the Preferred fileset type
107 	 */
108 	private static final String PREFERRED_FILSET_TYPE = "filesetType";
109 
110 	// Attributes for FTP Fileset
111 
112 	/**
113 	 * Preference Attribute for the host name
114 	 */
115 	private static final String FTP_FILESET_HOSTNAME = "hostname";
116 
117 	/**
118 	 * Preference Attribute for the port
119 	 */
120 	private static final String FTP_FILESET_PORTNO = "portno";
121 
122 	/**
123 	 * Preference Attribute for the home directory
124 	 */
125 	private static final String FTP_FILESET_HOMEDIR = "homedir";
126 
127 	/**
128 	 * Preference Attribute for identifying if authentication is required
129 	 */
130 	private static final String FTP_FILESET_AUTHENTICATION = "authentication";
131 
132 	/**
133 	 * Preference Attribute for the username
134 	 */
135 	private static final String FTP_FILESET_USERNAME = "username";
136 
137 	/**
138 	 * Preference Attribute for the password
139 	 */
140 	private static final String FTP_FILESET_PASSWORD = "password";
141 
142 	/**
143 	 * All file ids start with...
144 	 */
145 	private static final String FTP_FILESET_FILE_PREFIX = "urlId";
146 
147 	// Attributes for SFTP Fileset
148 
149 	/**
150 	 * Preference Attribute for the host name
151 	 */
152 	private static final String SFTP_FILESET_HOSTNAME = "hostname";
153 
154 	/**
155 	 * Preference Attribute for the port
156 	 */
157 	private static final String SFTP_FILESET_PORTNO = "portno";
158 
159 	/**
160 	 * Preference Attribute for the home directory
161 	 */
162 	private static final String SFTP_FILESET_HOMEDIR = "homedir";
163 
164 	/**
165 	 * Preference Attribute for identifying if authentication is required
166 	 */
167 	private static final String SFTP_FILESET_AUTHENTICATION = "authentication";
168 
169 	/**
170 	 * Preference Attribute for the username
171 	 */
172 	private static final String SFTP_FILESET_USERNAME = "username";
173 
174 	/**
175 	 * Preference Attribute for the password
176 	 */
177 	private static final String SFTP_FILESET_PASSWORD = "password";
178 
179 	/**
180 	 * Preference Attribute for Tailing Option 
181 	 */
182 	private static final String TAILING_OPTION = "tailOption";
183 	/**
184 	 * All file ids start with...
185 	 */
186 	private static final String SFTP_FILESET_FILE_PREFIX = "urlId";
187 	
188 	// Attributes for http filesets
189 
190 	/**
191 	 * If authentication is required on the host
192 	 */
193 	private static final String HTTP_AUTHENTICATION_REQUIRED = "authentication";
194 
195 	/**
196 	 * Username to authenticate users
197 	 */
198 	private static final String HTTP_AUTHENTICATION_USERNAME = "username";
199 
200 	/**
201 	 * Password to authenticate users
202 	 */
203 	private static final String HTTP_AUTHENTICATION_PASSWORD = "password";
204 
205 	/**
206 	 * If proxy is to be ignored for this fileset
207 	 */
208 	private static final String HTTP_IGNORE_PROXY = "ignoreProxy";
209 
210 	/**
211 	 * All url ids start with...
212 	 */
213 	private static final String HTTP_FILESET_URL_PREFIX = "urlId";
214 
215 	// Attributes for proxy information
216 
217 	/**
218 	 * HTTP Proxy host
219 	 */
220 	private static final String HTTP_PROXY_HOST = "http.proxy.host";
221 
222 	/**
223 	 * HTTP Proxy port
224 	 */
225 	private static final String HTTP_PROXY_PORT = "http.proxy.port";
226 
227 	/**
228 	 * FTP Proxy host
229 	 */
230 	private static final String FTP_PROXY_HOST = "ftp.proxy.host";
231 
232 	/**
233 	 * FTP Proxy port
234 	 */
235 	private static final String FTP_PROXY_PORT = "ftp.proxy.port";
236 
237 	/**
238 	 * SOCKS Proxy host
239 	 */
240 	private static final String SOCKS_PROXY_HOST = "socks.proxy.host";
241 
242 	/**
243 	 * SOCKS Proxy port
244 	 */
245 	private static final String SOCKS_PROXY_PORT = "socks.proxy.port";
246 
247 	/**
248 	 * If Proxy requires authentication
249 	 */
250 	private static final String PROXY_REQUIRES_AUTHENTICATION = "authentication";
251 
252 	/**
253 	 * Proxy authentication user
254 	 */
255 	private static final String PROXY_AUTH_USER = "user";
256 
257 	/**
258 	 * Proxy authentication password
259 	 */
260 	private static final String PROXY_AUTH_PASSWORD = "password";
261 	
262 	/**
263 	 * The preference of the remote protocol
264 	 */
265 	private static final String REMOTE_PREFERENCE = "remoteProtocol";
266 	
267 	/**
268 	 * The port of the listener
269 	 */
270 	private static final String REMOTE_PORT = "port";
271 	
272 	/**
273 	 * Cache configuration preference and preference attribute Ids
274 	 */
275 	private static final String CACHE_CONFIG = "cacheConfig";
276 	private static final String PAGE_SIZE = "pageSize";
277 	
278 	//
279 	// Static methods
280 	//
281 
282 	/**
283 	 * Returns an array of column identifiers for the event list display
284 	 * Presentation. The colum ids are valid constants defined in
285 	 * LogEventTableModel
286 	 * 
287 	 * @see com.mindtree.techworks.insight.model.LogEventTableModel
288 	 * @return int array containing valid table column identifiers
289 	 */
290 	public static int [] getConfiguredColumnsForDisplay () {
291 
292 		ArrayList configuredColumns = new ArrayList();
293 		Preference preference = PreferenceManager.getInstance().getPreference(
294 				DISPLAY_COLUMN);
295 		Iterator iterator = preference.iteratePreferenceAttributeIds();
296 		while (iterator.hasNext()) {
297 			String id = (String) iterator.next();
298 			configuredColumns.add(id);
299 		}
300 		// sort the ids in their natural order
301 		Collections.sort(configuredColumns);
302 		int [] columns = new int [configuredColumns.size()];
303 		for (int i = 0; i < configuredColumns.size(); i++ ) {
304 			columns[i] = Integer.parseInt(preference
305 					.getPreferenceAttributeById(
306 							(String) configuredColumns.get(i)).getValue());
307 		}
308 		return columns;
309 	}
310 
311 	/**
312 	 * Returns the preference for displaying filesets on load
313 	 * 
314 	 * @return true if configured filesets need to be shown, false otherwise
315 	 */
316 	public static boolean getShowFilesetOnLoad () {
317 
318 		Preference preference = PreferenceManager.getInstance().getPreference(
319 				FILESET);
320 		return preference.getPreferenceAttributeById(SHOW_FILESETS).getValue()
321 				.equals(TRUE);
322 	}
323 
324 	/**
325 	 * Returns the preferred fileset type to be displayed. This information is
326 	 * read from
327 	 * 
328 	 * <pre>
329 	 * fileset_filesetType
330 	 * </pre>
331 	 * 
332 	 * @return A number identifying the preferred fileset type.
333 	 */
334 	public static int getPreferredFilesetType () {
335 
336 		Preference preference = PreferenceManager.getInstance().getPreference(
337 				FILESET);
338 		return Integer.parseInt(preference.getPreferenceAttributeById(
339 				PREFERRED_FILSET_TYPE).getValue());
340 	}
341 
342 	/**
343 	 * Loads and returns all the Local filesets configured under
344 	 * 
345 	 * <pre>
346 	 * fileset$local
347 	 * </pre>
348 	 * 
349 	 * @return A list of {@link com.mindtree.techworks.insight.download.Fileset Fileset}
350 	 *         objects.
351 	 */
352 	public static List getLocalFilesets () {
353 
354 		Preference preference = PreferenceManager.getInstance().getPreference(
355 				FILESET).getPreferenceById(LOCAL_FILESETS);
356 		List localFilesets = new ArrayList();
357 		for (Iterator filesetPrefItr = preference.iterateChildPreferences(); filesetPrefItr
358 				.hasNext();) {
359 			Preference localFilesetPref = (Preference) filesetPrefItr.next();
360 			Fileset localFileSet = new Fileset(localFilesetPref.getName(),
361 					Fileset.LOCAL_FILESET);
362 			for (Iterator fileItr = localFilesetPref
363 					.iteratePreferenceAttributes(); fileItr.hasNext();) {
364 				localFileSet.addFile(((PreferenceAttribute) fileItr.next())
365 						.getValue());
366 			}
367 			localFilesets.add(localFileSet);
368 		}
369 		return localFilesets;
370 	}
371 
372 	/**
373 	 * Loads and returns all the FTP filesets configured under:
374 	 * 
375 	 * <pre>
376 	 * fileset$ftpfiles
377 	 * </pre>
378 	 * 
379 	 * @return A list of
380 	 *         {@link com.mindtree.techworks.insight.download.FTPFileset FTPFileset}
381 	 *         objects.
382 	 */
383 	public static List getFTPFilesets () {
384 
385 		Preference preference = PreferenceManager.getInstance().getPreference(
386 				FILESET).getPreferenceById(FTP_FILESETS);
387 		List ftpFilesets = new ArrayList();
388 		for (Iterator ftpFilesetPrefItr = preference.iterateChildPreferences(); ftpFilesetPrefItr
389 				.hasNext();) {
390 			Preference ftpFilesetPref = (Preference) ftpFilesetPrefItr.next();
391 			FTPFileset ftpFileSet = new FTPFileset(ftpFilesetPref.getName());
392 
393 			// Load the host information
394 			ftpFileSet.setHost(ftpFilesetPref.getPreferenceAttributeById(
395 					FTP_FILESET_HOSTNAME).getValue());
396 			String portNo = ftpFilesetPref.getPreferenceAttributeById(
397 					FTP_FILESET_PORTNO).getValue();
398 			if (null != portNo && portNo.length() > 0) {
399 				ftpFileSet.setPort(Integer.parseInt(portNo));
400 			}
401 			ftpFileSet
402 					.setDefaultDirectory(ftpFilesetPref
403 							.getPreferenceAttributeById(FTP_FILESET_HOMEDIR)
404 							.getValue());
405 
406 			// Load the Authentication information
407 			boolean requiresAuthentication = ftpFilesetPref
408 					.getPreferenceAttributeById(FTP_FILESET_AUTHENTICATION)
409 					.getValue().equals(TRUE);
410 			ftpFileSet.setAuthenticationRequired(requiresAuthentication);
411 			if (requiresAuthentication) {
412 				ftpFileSet.setUserName(ftpFilesetPref
413 						.getPreferenceAttributeById(FTP_FILESET_USERNAME)
414 						.getValue());
415 				ftpFileSet.setPassword(ftpFilesetPref
416 						.getPreferenceAttributeById(FTP_FILESET_PASSWORD)
417 						.getValue());
418 			}
419 
420 			// TODO Add proxy information
421 
422 			// Load the files
423 			for (Iterator fileItr = ftpFilesetPref
424 					.iteratePreferenceAttributes(); fileItr.hasNext();) {
425 				PreferenceAttribute fileAttribute = (PreferenceAttribute) fileItr
426 						.next();
427 				if (fileAttribute.getId().startsWith(FTP_FILESET_FILE_PREFIX)) {
428 					ftpFileSet.addFile(fileAttribute.getValue());
429 				}
430 			}
431 
432 			// All done... add the fileset to the list
433 			ftpFilesets.add(ftpFileSet);
434 		}
435 		return ftpFilesets;
436 	}
437 	
438 	/**
439 	 * Loads and returns all the SFTP filesets configured under:
440 	 * 
441 	 * <pre>
442 	 * fileset$sftpfiles
443 	 * </pre>
444 	 * 
445 	 * @return A list of
446 	 *         {@link com.mindtree.techworks.insight.download.SFTPFileset SFTPFileset}
447 	 *         objects.
448 	 */
449 	public static List getSFTPFilesets () {
450 
451 		Preference preference = PreferenceManager.getInstance().getPreference(
452 				FILESET).getPreferenceById(SFTP_FILESETS);
453 		List sftpFilesets = new ArrayList();
454 		for (Iterator sftpFilesetPrefItr = preference.iterateChildPreferences(); sftpFilesetPrefItr
455 				.hasNext();) {
456 			Preference sftpFilesetPref = (Preference) sftpFilesetPrefItr.next();
457 			SFTPFileset sftpFileSet = new SFTPFileset(sftpFilesetPref.getName());
458 
459 			// Load the host information
460 			sftpFileSet.setHost(sftpFilesetPref.getPreferenceAttributeById(
461 					SFTP_FILESET_HOSTNAME).getValue());
462 			String portNo = sftpFilesetPref.getPreferenceAttributeById(
463 					SFTP_FILESET_PORTNO).getValue();
464 			if (null != portNo && portNo.length() > 0) {
465 				sftpFileSet.setPort(Integer.parseInt(portNo));
466 			}
467 			sftpFileSet
468 					.setDefaultDirectory(sftpFilesetPref
469 							.getPreferenceAttributeById(SFTP_FILESET_HOMEDIR)
470 							.getValue());
471 
472 			// Load the Authentication information
473 			boolean requiresAuthentication = sftpFilesetPref
474 					.getPreferenceAttributeById(SFTP_FILESET_AUTHENTICATION)
475 					.getValue().equals(TRUE);
476 			sftpFileSet.setAuthenticationRequired(requiresAuthentication);
477 			if (requiresAuthentication) {
478 				sftpFileSet.setUserName(sftpFilesetPref
479 						.getPreferenceAttributeById(SFTP_FILESET_USERNAME)
480 						.getValue());
481 				sftpFileSet.setPassword(sftpFilesetPref
482 						.getPreferenceAttributeById(SFTP_FILESET_PASSWORD)
483 						.getValue());
484 			}
485 
486 			// TODO Add proxy information
487 
488 			// Load the files
489 			for (Iterator fileItr = sftpFilesetPref
490 					.iteratePreferenceAttributes(); fileItr.hasNext();) {
491 				PreferenceAttribute fileAttribute = (PreferenceAttribute) fileItr
492 						.next();
493 				if (fileAttribute.getId().startsWith(SFTP_FILESET_FILE_PREFIX)) {
494 					sftpFileSet.addFile(fileAttribute.getValue());
495 				}
496 			}
497 
498 			// All done... add the fileset to the list
499 			sftpFilesets.add(sftpFileSet);
500 		}
501 		return sftpFilesets;
502 	}
503 	
504 
505 	/**
506 	 * Loads and returns all the HTTP filesets configured under:
507 	 * 
508 	 * <pre>
509 	 * fileset$remote
510 	 * </pre>
511 	 * 
512 	 * @return A list of
513 	 *         {@link com.mindtree.techworks.insight.download.FTPFileset FTPFileset}
514 	 *         objects.
515 	 */
516 	public static List getHttpFilesets () {
517 
518 		Preference preference = PreferenceManager.getInstance().getPreference(
519 				FILESET).getPreferenceById(HTTP_FILESETS);
520 		List httpFilesets = new ArrayList();
521 
522 		// Loop through the filesets
523 		for (Iterator httpFilesetPrefItr = preference.iterateChildPreferences(); httpFilesetPrefItr
524 				.hasNext();) {
525 			Preference httpFilesetPref = (Preference) httpFilesetPrefItr.next();
526 			HTTPFileset httpFileSet = new HTTPFileset(httpFilesetPref.getName());
527 
528 			// Authentication information
529 			boolean requiresAuthentication = httpFilesetPref
530 					.getPreferenceAttributeById(HTTP_AUTHENTICATION_REQUIRED)
531 					.getValue().equals(TRUE);
532 			httpFileSet.setAuthenticationRequired(requiresAuthentication);
533 			if (requiresAuthentication) {
534 				httpFileSet.setUserName(httpFilesetPref
535 						.getPreferenceAttributeById(
536 								HTTP_AUTHENTICATION_USERNAME).getValue());
537 				httpFileSet.setPassword(httpFilesetPref
538 						.getPreferenceAttributeById(
539 								HTTP_AUTHENTICATION_PASSWORD).getValue());
540 			}
541 
542 			httpFileSet.setIgnoreProxy(httpFilesetPref
543 					.getPreferenceAttributeById(HTTP_IGNORE_PROXY).getValue()
544 					.equals(TRUE));
545 
546 			// Load the urls
547 			for (Iterator urlItr = httpFilesetPref
548 					.iteratePreferenceAttributes(); urlItr.hasNext();) {
549 				PreferenceAttribute fileAttribute = (PreferenceAttribute) urlItr
550 						.next();
551 				if (fileAttribute.getId().startsWith(HTTP_FILESET_URL_PREFIX)) {
552 					httpFileSet.addFile(fileAttribute.getValue());
553 				}
554 			}
555 
556 			// All done.. add this to the list
557 			httpFilesets.add(httpFileSet);
558 		}
559 
560 		return httpFilesets;
561 	}
562 
563 	/**
564 	 * Loads the proxy information from the preferences and returns that as a
565 	 * ProxyInfo object.
566 	 * 
567 	 * @return <code>ProxyInfo</code> object containing proxy information.
568 	 */
569 	public static ProxyInfo getProxyInfo () {
570 
571 		Preference preference = PreferenceManager.getInstance().getPreference(
572 				PROXY);
573 		ProxyInfo proxyInfo = new ProxyInfo();
574 		String host = null;
575 		String port = null;
576 
577 		// Load the http proxy
578 		host = preference.getPreferenceAttributeById(HTTP_PROXY_HOST)
579 				.getValue();
580 		port = preference.getPreferenceAttributeById(HTTP_PROXY_PORT)
581 				.getValue();
582 		if (host != null && port != null && host.length() > 0
583 				&& port.length() > 0) {
584 			proxyInfo.setHttpProxyInfo(host, Integer.parseInt(port));
585 		}
586 
587 		// Load the ftp proxy
588 		host = preference.getPreferenceAttributeById(FTP_PROXY_HOST).getValue();
589 		port = preference.getPreferenceAttributeById(FTP_PROXY_PORT).getValue();
590 		if (host != null && port != null && host.length() > 0
591 				&& port.length() > 0) {
592 			proxyInfo.setFtpProxyInfo(host, Integer.parseInt(port));
593 		}
594 
595 		// Load the socks proxy
596 		host = preference.getPreferenceAttributeById(SOCKS_PROXY_HOST)
597 				.getValue();
598 		port = preference.getPreferenceAttributeById(SOCKS_PROXY_PORT)
599 				.getValue();
600 		if (host != null && port != null && host.length() > 0
601 				&& port.length() > 0) {
602 			proxyInfo.setSocksProxyInfo(host, Integer.parseInt(port));
603 		}
604 
605 		proxyInfo.setAuthenticationRequired(preference
606 				.getPreferenceAttributeById(PROXY_REQUIRES_AUTHENTICATION)
607 				.getValue().equals(TRUE));
608 		if (proxyInfo.isAuthenticationRequired()) {
609 			proxyInfo.setPasswordInformation(preference
610 					.getPreferenceAttributeById(PROXY_AUTH_USER).getValue(),
611 					preference.getPreferenceAttributeById(PROXY_AUTH_PASSWORD)
612 							.getValue());
613 		}
614 
615 		return proxyInfo;
616 	}
617 
618 	/**
619 	 * Loads the tailing option information from the preferences and returns that as a
620 	 *  booelan.
621 	 * 
622 	 * @return <code>boolean</code> value representing the tailing information which 
623 	 * is being persisted as part of preferences.
624 	 */
625 
626 	public static boolean getTailingStatus(){
627 		Preference pref = PreferenceManager.getInstance().getPreference(FILESET);
628 		if(pref!=null){
629 			PreferenceAttribute prefAttribute = pref.getPreferenceAttributeById(TAILING_OPTION);
630 			if(prefAttribute!=null){
631 				return prefAttribute.getValue().equalsIgnoreCase(TRUE);
632 			}
633 		}
634 		return false;
635 	}
636 	
637 	/**
638 	 * Loads the default port value for the Remote Protocol Listener. If the
639 	 * preference cannot be found or it does not contain an integer value, the
640 	 * {@link InsightConstants#REMOTE_PORT_DEFAULT_VALUE default value} is returned.
641 	 * 
642 	 * @return The value on which the listener will linked.
643 	 */
644 	public static int getRemoteProtocolListenerPort () {
645 
646 		Preference pref = PreferenceManager.getInstance ()
647 				.getPreference (REMOTE_PREFERENCE);
648 		if (null != pref) {
649 			PreferenceAttribute preferenceAttribute = pref
650 					.getPreferenceAttributeById (REMOTE_PORT);
651 			if (null != preferenceAttribute) {
652 				try {
653 					return Integer.valueOf (preferenceAttribute.getValue ())
654 							.intValue ();
655 				} catch (NumberFormatException nfe) {
656 					// Do nothing with the exception, just return the default
657 					// and set that to the preference
658 					preferenceAttribute.setValue (String
659 							.valueOf (InsightConstants.REMOTE_PORT_DEFAULT_VALUE));
660 					return InsightConstants.REMOTE_PORT_DEFAULT_VALUE;
661 				}
662 			}
663 		}
664 		return InsightConstants.REMOTE_PORT_DEFAULT_VALUE;
665 	}
666 	
667 	/**
668 	 * Returns the configured cache page size of the default value defined in 
669 	 * InsightConstants if no configuration is defined
670 	 * @return the configured page size or the default value
671 	 */
672 	public static int getCachePageSize() {
673 		Preference pref = PreferenceManager.getInstance ()
674 		.getPreference (CACHE_CONFIG);
675 		if (null != pref) {
676 			PreferenceAttribute preferenceAttribute = pref
677 					.getPreferenceAttributeById (PAGE_SIZE);
678 			if (null != preferenceAttribute) {
679 				try {
680 					return Integer.valueOf (preferenceAttribute.getValue ())
681 							.intValue ();
682 				} catch (NumberFormatException nfe) {
683 					// Do nothing with the exception, just return the default
684 					// and set that to the preference
685 					preferenceAttribute.setValue (String
686 							.valueOf (InsightConstants.DEFAULT_PAGE_SIZE));
687 					return InsightConstants.DEFAULT_PAGE_SIZE;
688 				}
689 			}
690 		}
691 		return InsightConstants.DEFAULT_PAGE_SIZE;		
692 	}
693 }