Source Code Cross Referenced for JwmaSettings.java in  » Web-Mail » Jwma » dtw » webmail » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Mail » Jwma » dtw.webmail.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /***
0002:         * jwma Java WebMail
0003:         * Copyright (c) 2000-2003 jwma team
0004:         *
0005:         * jwma is free software; you can distribute and use this source
0006:         * under the terms of the BSD-style license received along with
0007:         * the distribution.
0008:         ***/package dtw.webmail.util;
0009:
0010:        import java.io.*;
0011:        import java.net.*;
0012:        import java.util.*;
0013:
0014:        import org.apache.log4j.Logger;
0015:
0016:        //import dtw.webmail.JwmaKernel;
0017:        import dtw.webmail.model.*;
0018:        import dtw.webmail.util.StringUtil;
0019:
0020:        /**
0021:         * Class implementing a wrapper for jwma's settings.
0022:         *
0023:         * @author Dieter Wimberger
0024:         * @version 0.9.7 07/02/2003
0025:         */
0026:        public class JwmaSettings {
0027:
0028:            //logging
0029:            private static Logger log = Logger.getLogger(JwmaSettings.class);
0030:
0031:            //instance attributes
0032:            private String m_WebInfDir;
0033:            private File m_PropFile;
0034:            private Properties m_Properties;
0035:
0036:            /**
0037:             * Constructs a new <tt>JwmaSettings</tt> instance.
0038:             * The given path should point to the persistent settings
0039:             * file.
0040:             * At the moment the file is a standard properties file.
0041:             *
0042:             * @param path the full path of the persistent settings file.
0043:             */
0044:            protected JwmaSettings(String path) {
0045:                m_WebInfDir = path;
0046:            }//constructor
0047:
0048:            /*** Account related *************************************************/
0049:
0050:            /**
0051:             * Tests if creation of accounts is enabled.
0052:             *
0053:             * @return true if account creation is enabled, false otherwise.
0054:             */
0055:            public boolean isAccountCreationEnabled() {
0056:                return (new Boolean(m_Properties
0057:                        .getProperty("jwma.account.creation.enabled"))
0058:                        .booleanValue());
0059:            }//isAccountCreationEnabled
0060:
0061:            /**
0062:             * Sets the flag that controls if the automatic creation of
0063:             * accounts is enabled.
0064:             *
0065:             * @param true if account creation is enabled, false otherwise.
0066:             */
0067:            public void setAccountCreationEnabled(boolean enabled) {
0068:                m_Properties.setProperty("jwma.account.creation.enabled",
0069:                        new Boolean(enabled).toString());
0070:            }//setAccountCreationEnabled
0071:
0072:            /**
0073:             * Returns a <tt>String</tt> representing a JwmaKernel
0074:             * view constant, denoting the view to be presented on
0075:             * account creation.
0076:             *
0077:             * @return the account creation view key as <tt>String</tt>.
0078:             */
0079:            public String getAccountCreationView() {
0080:                return m_Properties.getProperty("jwma.account.creation.view");
0081:            }//getAccountCreationView
0082:
0083:            /**
0084:             * Sets the view key constant of the view to be presented to
0085:             * the user on account creation.
0086:             *
0087:             * @param view the view key as <tt>String</tt>.
0088:             */
0089:            public void setAccountCreationView(String view) {
0090:                m_Properties.setProperty("jwma.account.creation.view", view);
0091:            }//setAccountCreationView
0092:
0093:            /*** End Account related *********************************************/
0094:
0095:            /*** Admin related ***************************************************/
0096:
0097:            /**
0098:             * Returns a <tt>String</tt> representing a list
0099:             * of usernames that have administrative rights.
0100:             *
0101:             * @return the list of admin's usernames as <tt>String</tt>.
0102:             */
0103:            public String[] getAdminUsernames() {
0104:                return StringUtil.split(m_Properties
0105:                        .getProperty("jwma.admin.usernames"), ",");
0106:            }//getAdminUsernames
0107:
0108:            /**
0109:             * Sets the admin's usernames.
0110:             *
0111:             * @param admins the admin's usernames as <tt>String[]</tt>.
0112:             */
0113:            public void setAdminUsernames(String[] admins) {
0114:                m_Properties.setProperty("jwma.admin.usernames", StringUtil
0115:                        .join(admins, ","));
0116:            }//setAdminUsername
0117:
0118:            /**
0119:             * Tests if accessing the system's administration is enabled.
0120:             *
0121:             * @return true if administration is enabled, false otherwise.
0122:             */
0123:            public boolean isAdminEnabled() {
0124:                return (new Boolean(m_Properties
0125:                        .getProperty("jwma.admin.enabled")).booleanValue());
0126:            }//isAdminEnabled
0127:
0128:            /**
0129:             * Sets the flag that controls if the system's adminstration is
0130:             * enabled.
0131:             *
0132:             * @param true if administration is enabled, false otherwise.
0133:             */
0134:            public void setAdminEnabled(boolean enabled) {
0135:                m_Properties.setProperty("jwma.admin.enabled", new Boolean(
0136:                        enabled).toString());
0137:            }//setAdminEnabled
0138:
0139:            /*** End admin related ***********************************************/
0140:
0141:            /*** Controllers related *********************************************/
0142:
0143:            /**
0144:             * Returns a <tt>String</tt> representing the prefix
0145:             * for the controllers.
0146:             *
0147:             * @return the prefix for the controllers as <tt>String</tt>.
0148:             */
0149:            public String getControllerPrefix() {
0150:                return m_Properties.getProperty("jwma.controller.prefix");
0151:            }//getControllerPrefix
0152:
0153:            /**
0154:             * Sets the prefix for the controllers.
0155:             *
0156:             * @param prefix the prefix for the controllers as <tt>String</tt>.
0157:             */
0158:            public void setControllerPrefix(String prefix) {
0159:                m_Properties.setProperty("jwma.controller.prefix", prefix);
0160:            }//setControllerPrefix
0161:
0162:            /**
0163:             * Returns a <tt>String</tt> representing the main
0164:             * controller alias.
0165:             *
0166:             * @return the alias of the main controller as <tt>String</tt>.
0167:             */
0168:            public String getMainControllerAlias() {
0169:                return m_Properties.getProperty("jwma.controller.main");
0170:            }//getMainControllerAlias
0171:
0172:            /**
0173:             * Sets the alias for the main controller.
0174:             *
0175:             * @param alias the alias for the main controller as <tt>String</tt>.
0176:             */
0177:            public void setMainControllerAlias(String alias) {
0178:                m_Properties.setProperty("jwma.controller.main", alias);
0179:            }//setMainControllerAlias
0180:
0181:            /**
0182:             * Returns a <tt>String</tt> representing the mailing
0183:             * controller alias.
0184:             *
0185:             * @return the alias of the mailing controller as <tt>String</tt>.
0186:             */
0187:            public String getMailingControllerAlias() {
0188:                return m_Properties.getProperty("jwma.controller.mailing");
0189:            }//getMailingControllerAlias
0190:
0191:            /**
0192:             * Sets the alias for the mailing controller.
0193:             *
0194:             * @param alias the alias for the mailing controller as <tt>String</tt>.
0195:             */
0196:            public void setMailingControllerAlias(String alias) {
0197:                m_Properties.setProperty("jwma.controller.mailing", alias);
0198:            }//setMailingControllerAlias
0199:
0200:            /**
0201:             * Returns a <tt>String</tt> representing the admin
0202:             * controller alias.
0203:             *
0204:             * @return the alias of the admin controller as <tt>String</tt>.
0205:             */
0206:            public String getAdminControllerAlias() {
0207:                return m_Properties.getProperty("jwma.controller.admin");
0208:            }//getAdminControllerAlias
0209:
0210:            /**
0211:             * Sets the alias for the admin controller.
0212:             *
0213:             * @param alias the alias for the admin controller as <tt>String</tt>.
0214:             */
0215:            public void setAdminControllerAlias(String alias) {
0216:                m_Properties.setProperty("jwma.controller.admin", alias);
0217:            }//setAdminControllerAlias
0218:
0219:            /**
0220:             * Returns a <tt>String</tt> representing the contacts
0221:             * controller alias.
0222:             *
0223:             * @return the alias of the contacts controller as <tt>String</tt>.
0224:             */
0225:            public String getContactsControllerAlias() {
0226:                return m_Properties.getProperty("jwma.controller.contacts");
0227:            }//getContactsControllerAlias
0228:
0229:            /**
0230:             * Sets the alias for the contacts controller.
0231:             *
0232:             * @param alias the alias for the contacts controller as <tt>String</tt>.
0233:             */
0234:            public void setContactsControllerAlias(String alias) {
0235:                m_Properties.setProperty("jwma.controller.contacts", alias);
0236:            }//setContactsControllerAlias
0237:
0238:            /*** END Controllers related *****************************************/
0239:
0240:            /*** Postoffice related **********************************************/
0241:
0242:            /**
0243:             * Returns a <tt>String</tt> representing the post office
0244:             * protocol name.
0245:             *
0246:             * @return the postoffice protocol name as <tt>String</tt>.
0247:             */
0248:            public String getPostOfficeProtocol() {
0249:                return m_Properties.getProperty("jwma.postoffice.protocol");
0250:            }//getPostOfficeProtocol
0251:
0252:            /**
0253:             * Sets the name of the postoffice protocol.
0254:             *
0255:             * @param protocol the name of the postoffice protocol as <tt>String</tt>.
0256:             */
0257:            public void setPostOfficeProtocol(String protocol) {
0258:                m_Properties.setProperty("jwma.postoffice.protocol", protocol);
0259:            }//setPostOfficeProtocol
0260:
0261:            /**
0262:             * Returns a <tt>String</tt> representing the postoffice's
0263:             * hostname.
0264:             *
0265:             * @return the postoffice hostname as <tt>String</tt>.
0266:             */
0267:            public String getPostOfficeHost() {
0268:                return m_Properties.getProperty("jwma.postoffice.host");
0269:            }//getPostOfficeHost
0270:
0271:            /**
0272:             * Sets the host name of the postoffice.
0273:             *
0274:             * @param host the hostname of the postoffice as <tt>String</tt>.
0275:             */
0276:            public void setPostOfficeHost(String host) {
0277:                m_Properties.setProperty("jwma.postoffice.host", host);
0278:            }//setPostOfficeHost
0279:
0280:            /**
0281:             * Returns an <tt>int</tt> representing the port
0282:             * the postoffice is running on.
0283:             *
0284:             * @return the port number as <tt>int</tt>.
0285:             */
0286:            public int getPostOfficePort() {
0287:                return new Integer(m_Properties
0288:                        .getProperty("jwma.postoffice.port")).intValue();
0289:            }//getPostOfficePort
0290:
0291:            /**
0292:             * Sets the port the postoffice is running on.
0293:             *
0294:             * @param the port number as <tt>int</tt>.
0295:             */
0296:            public void setPostOfficePort(int num) {
0297:                m_Properties.setProperty("jwma.postoffice.port", new Integer(
0298:                        num).toString());
0299:            }//setPostOfficePort
0300:
0301:            /**
0302:             * Returns a <tt>String</tt> representing the postoffice's
0303:             * type.
0304:             * <ul>
0305:             * <li>mixed: folders in the store can hold folders and files.</li>
0306:             * <li>plain: folders in the store can hold only folders or messages.</li>
0307:             * <li>auto: folder types are checked by jwma</li>
0308:             * <ul>
0309:             * Note that in jwma terminology the folder that can only hold messages
0310:             * is called a <tt>mailbox</tt>
0311:             *
0312:             * @return the postoffice type as <tt>String</tt>.
0313:             */
0314:            public String getPostOfficeType() {
0315:                return m_Properties.getProperty("jwma.postoffice.type");
0316:            }//getPostOfficeType
0317:
0318:            /**
0319:             * Sets the type of the postoffice.
0320:             *
0321:             * @param type the type of the postoffice as <tt>String</tt>.
0322:             */
0323:            public void setPostOfficeType(String type) {
0324:                m_Properties.setProperty("jwma.postoffice.type", type);
0325:            }//setPostOfficeType
0326:
0327:            /**
0328:             * Tests if overriding the system's set postoffice is allowed.
0329:             *
0330:             * @return true if overriding is allowed, false otherwise.
0331:             */
0332:            public boolean getPostOfficeAllowOverride() {
0333:                return (new Boolean(m_Properties
0334:                        .getProperty("jwma.postoffice.allowoverride"))
0335:                        .booleanValue());
0336:            }//getPostOfficeAllowOverride
0337:
0338:            /**
0339:             * Sets the flag that controls if overriding the system's set postoffice
0340:             * is allowed or not.
0341:             *
0342:             * @param true if the overriding is to be allowed, false otherwise.
0343:             */
0344:            public void setPostOfficeAllowOverride(boolean allowoverride) {
0345:                m_Properties.setProperty("jwma.postoffice.allowoverride",
0346:                        new Boolean(allowoverride).toString());
0347:            }//setPostOfficeAllowOverride
0348:
0349:            /**
0350:             * Tests if the connection to the postoffice should be secure.
0351:             *
0352:             * @return true if secure, false otherwise.
0353:             */
0354:            public boolean isPostOfficeSecure() {
0355:                return (new Boolean(m_Properties
0356:                        .getProperty("jwma.postoffice.secure")).booleanValue());
0357:            }//isPostOfficeSecure
0358:
0359:            /**
0360:             * Sets the flag that controls if connections to the MTA
0361:             * should be secure.
0362:             *
0363:             * @param true if secure, false otherwise.
0364:             */
0365:            public void setPostOfficeSecure(boolean b) {
0366:                m_Properties.setProperty("jwma.postoffice.secure", new Boolean(
0367:                        b).toString());
0368:            }//setPostOfficeSecure
0369:
0370:            /**
0371:             * Returns a <tt>String</tt> representing the
0372:             * fully qualified class name of the secure socket factory
0373:             * to be used for secure connections to the postoffice.
0374:             *
0375:             * @return the secure socket factory classname as <tt>String</tt>.
0376:             */
0377:            public String getPostOfficeSecureSocketFactory() {
0378:                return m_Properties
0379:                        .getProperty("jwma.postoffice.securesocketfactory");
0380:            }//getPostOfficeSecureSocketFactory
0381:
0382:            /**
0383:             * Sets the fully qualified class name of the secure socket
0384:             * factory to be used for secure connections to the postoffice.
0385:             *
0386:             * @param classname of the factory as <tt>String</tt>.
0387:             */
0388:            public void setPostSecureFactory(String factory) {
0389:                m_Properties.setProperty("jwma.postoffice.securesocketfactory",
0390:                        factory);
0391:            }//setPostOfficeSecureSocketFactory
0392:
0393:            /*** END Postoffice related ******************************************/
0394:
0395:            /*** Mail transport related ******************************************/
0396:
0397:            /**
0398:             * Returns a <tt>String</tt> representing the mail transport
0399:             * protocol name.
0400:             *
0401:             * @return the mail transport protocol name as <tt>String</tt>.
0402:             */
0403:            public String getMailTransportProtocol() {
0404:                return m_Properties.getProperty("jwma.mailtransport.protocol");
0405:            }//getMailTransportProtocol
0406:
0407:            /**
0408:             * Sets the name of the mail transport protocol.
0409:             *
0410:             * @param protocol the name of the mail transport protocol
0411:             *		  as <tt>String</tt>.
0412:             */
0413:            public void setMailTransportProtocol(String protocol) {
0414:                m_Properties.setProperty("jwma.mailtransport.protocol",
0415:                        protocol);
0416:            }//setMailTransportProtocol
0417:
0418:            /**
0419:             * Returns a <tt>String</tt> representing the MTA's
0420:             * hostname.
0421:             *
0422:             * @return the MTA's hostname as <tt>String</tt>.
0423:             */
0424:            public String getMailTransportHost() {
0425:                return m_Properties.getProperty("jwma.mailtransport.host");
0426:            }//getMailTransportHost
0427:
0428:            /**
0429:             * Sets the host name of the MTA.
0430:             *
0431:             * @param host the hostname of the MTA as <tt>String</tt>.
0432:             */
0433:            public void setMailTransportHost(String host) {
0434:                m_Properties.setProperty("jwma.mailtransport.host", host);
0435:            }//setMailTransportHost
0436:
0437:            /**
0438:             * Returns an <tt>int</tt> representing the port
0439:             * the MTA is running on.
0440:             *
0441:             * @return the port number as <tt>int</tt>.
0442:             */
0443:            public int getMailTransportPort() {
0444:                return new Integer(m_Properties
0445:                        .getProperty("jwma.mailtransport.port")).intValue();
0446:            }//getMailTransportPort
0447:
0448:            /**
0449:             * Sets the port the MTA is running on.
0450:             *
0451:             * @param the port number as <tt>int</tt>.
0452:             */
0453:            public void setMailTransportPort(int num) {
0454:                m_Properties.setProperty("jwma.mailtransport.port",
0455:                        new Integer(num).toString());
0456:            }//setMailTransportPort
0457:
0458:            /**
0459:             * Tests if the connection to the MTA should be authenticated.
0460:             *
0461:             * @return true if authentication required, false otherwise.
0462:             */
0463:            public boolean isMailTransportAuthenticated() {
0464:                return (new Boolean(m_Properties
0465:                        .getProperty("jwma.mailtransport.authenticated"))
0466:                        .booleanValue());
0467:            }//isMailTransportAuthenticated
0468:
0469:            /**
0470:             * Sets the flag that controls if connections to the MTA
0471:             * should be authenticated.
0472:             *
0473:             * @param true if authentication required, false otherwise.
0474:             */
0475:            public void setMailTransportAuthenticated(boolean auth) {
0476:                m_Properties.setProperty("jwma.mailtransport.authenticated",
0477:                        new Boolean(auth).toString());
0478:            }//setMailTransportAuthenticated
0479:
0480:            /**
0481:             * Returns an <tt>int</tt> representing the maximum
0482:             * size in kB's allowed for a message to be transported.
0483:             *
0484:             * @return maximum size of a message in kB's as <tt>int</tt>.
0485:             */
0486:            public int getMailTransportLimit() {
0487:                return new Integer(m_Properties
0488:                        .getProperty("jwma.mailtransport.maxsize")).intValue();
0489:            }//getMailTransportLimit
0490:
0491:            /**
0492:             * Sets the transport size limitation.
0493:             *
0494:             * @param size the number of kB's a message can reach at maximum
0495:             *        as <tt>int</tt>.
0496:             */
0497:            public void setMailTransportLimit(int size) {
0498:                m_Properties.setProperty("jwma.mailtransport.maxsize",
0499:                        new Integer(size).toString());
0500:            }//setMailTransportLimit
0501:
0502:            /*** END Mail transport related **************************************/
0503:
0504:            /*** File related ****************************************************/
0505:
0506:            /**
0507:             * Returns a <tt>String</tt> representing filename of the
0508:             * mapping file used for XML serialization.
0509:             *
0510:             * @return the filename of the mapping file as <tt>String</tt>.
0511:             */
0512:            public String getMappingFilename() {
0513:                //fix for simplicity
0514:                return "jwma_mapping.xml";
0515:            }//getMappingFilename
0516:
0517:            /**
0518:             * Sets the the filename of the mapping file used for XML
0519:             * serialization.<p>
0520:             * There should not be any path appended to this filename,
0521:             * because the path is constructed from different settings.
0522:             *
0523:             * @param name the filename of the mapping file as <tt>String</tt>.
0524:             */
0525:            public void setMappingFilename(String name) {
0526:                //fix for simplicity
0527:                return;
0528:            }//setMappingFilename
0529:
0530:            /**
0531:             * Returns a <tt>String</tt> representing filename of the
0532:             * site's settings template file.
0533:             * <p>
0534:             * This file represents a serialized JwmaPreferences instance
0535:             * that is used for cloning new user's settings.
0536:             *
0537:             * @return the filename of the site's settings template file
0538:             *         as <tt>String</tt>.
0539:             */
0540:            public String getTemplateFilename() {
0541:                //fix for simplicity
0542:                return "site_template.xml";
0543:            }//getTemplateFilename
0544:
0545:            /**
0546:             * Sets the the filename of the site's settings template file.
0547:             * <p>
0548:             * This file represents a serialized JwmaPreferences instance
0549:             * that is used for cloning new user's settings.
0550:             * There should not be any path appended to this filename,
0551:             * because the path is constructed from different settings.
0552:             *
0553:             * @param name the filename of the site's settings template file
0554:             *        as <tt>String</tt>.
0555:             */
0556:            public void setTemplateFilename(String name) {
0557:                //fix for simplicity
0558:                return;
0559:            }//setTemplateFilename
0560:
0561:            /*** END File related ************************************************/
0562:
0563:            /*** Log related *****************************************************/
0564:
0565:            /**
0566:             * Returns a <tt>String</tt> representing filename of the
0567:             * log4j properties file.
0568:             *
0569:             * @return the filename of the log4j properties as <tt>String</tt>.
0570:             */
0571:            public String getLogPropertiesFilename() {
0572:                return m_Properties.getProperty("jwma.log4j.properties");
0573:            }//getSyslogFilename
0574:
0575:            /**
0576:             * Sets the the filename of the log4j properties file.
0577:             *
0578:             * @param name the filename of the log4j properties as <tt>String</tt>.
0579:             */
0580:            public void setLogPropertiesFilename(String name) {
0581:                m_Properties.setProperty("jwma.log4j.properties", name);
0582:            }//setLogPropertiesFilename
0583:
0584:            /*** END Log related *************************************************/
0585:
0586:            /*** Processing related **********************************************/
0587:
0588:            /**
0589:             * Returns a <tt>String</tt> representing filename of the
0590:             * text processing properties.
0591:             *
0592:             * @return the filename of the text processing properties
0593:             *         as <tt>String</tt>.
0594:             */
0595:            public String getTextProcFilename() {
0596:                return m_Properties.getProperty("jwma.processing.properties");
0597:            }//getTextProcFileName
0598:
0599:            /**
0600:             * Sets the filename of the text processing properties.
0601:             *
0602:             * @param the filename of the text processing properties
0603:             *         as <tt>String</tt>.
0604:             */
0605:            public void setTextProcFilename(String name) {
0606:                m_Properties.setProperty("jwma.processing.properties", name);
0607:            }//getTextProcFileName
0608:
0609:            /**
0610:             * Returns a <tt>String</tt> representing the name of the default
0611:             * message processing pipe.
0612:             *
0613:             * @return the name of the default message processing pipe as
0614:             *         <tt>String</tt>.
0615:             */
0616:            public String getDefaultMessageProcessingPipe() {
0617:                return m_Properties.getProperty("jwma.processing.defaultpipe");
0618:            }//getDefaultMessageProcessingPipe
0619:
0620:            /**
0621:             * Returns a <tt>String</tt> representing the name of the default
0622:             * message processing pipe.
0623:             *
0624:             * @return the name of the default message processing pipe as
0625:             *         <tt>String</tt>.
0626:             */
0627:            public void setDefaultMessageProcessingPipe(String name) {
0628:                m_Properties.setProperty("jwma.processing.defaultpipe", name);
0629:            }//setDefaultMessageProcessingPipe
0630:
0631:            /*** END Processing related ******************************************/
0632:
0633:            /*** Views related ***************************************************/
0634:
0635:            /**
0636:             * Returns a <tt>String</tt> representing the prefix
0637:             * for the views.
0638:             *
0639:             * @return the prefix for the views as <tt>String</tt>.
0640:             */
0641:            public String getViewPrefix() {
0642:                return m_Properties.getProperty("jwma.view.prefix");
0643:            }//getViewPrefix
0644:
0645:            /**
0646:             * Sets the prefix for the views.
0647:             *
0648:             * @param prefix the prefix for the views as <tt>String</tt>.
0649:             */
0650:            public void setViewPrefix(String prefix) {
0651:                m_Properties.setProperty("jwma.view.prefix", prefix);
0652:            }//setViewPrefix
0653:
0654:            /**
0655:             * Returns a <tt>String</tt> representing the error view
0656:             * filename/URL ending.
0657:             *
0658:             * @return the error view filename/URL ending as <tt>String</tt>.
0659:             */
0660:            public String getErrorView() {
0661:                return m_Properties.getProperty("jwma.view.error");
0662:            }//getErrorView
0663:
0664:            /**
0665:             * Sets the filename/URL ending for the error view.
0666:             *
0667:             * @param name the error view filename/URL ending as <tt>String</tt>.
0668:             */
0669:            public void setErrorView(String name) {
0670:                m_Properties.setProperty("jwma.view.error", name);
0671:            }//setErrorView
0672:
0673:            /**
0674:             * Returns a <tt>String</tt> representing the login view
0675:             * filename/URL ending.
0676:             *
0677:             * @return the login view filename/URL ending as <tt>String</tt>.
0678:             */
0679:            public String getLoginView() {
0680:                return m_Properties.getProperty("jwma.view.login");
0681:            }//getLoginView
0682:
0683:            /**
0684:             * Sets the filename/URL ending for the login view.
0685:             *
0686:             * @param name the login view filename/URL ending as <tt>String</tt>.
0687:             */
0688:            public void setLoginView(String name) {
0689:                m_Properties.setProperty("jwma.view.login", name);
0690:            }//setLoginView
0691:
0692:            /**
0693:             * Returns a <tt>String</tt> representing the logout view
0694:             * filename/URL ending.
0695:             *
0696:             * @return the logout view filename/URL ending as <tt>String</tt>.
0697:             */
0698:            public String getLogoutView() {
0699:                return m_Properties.getProperty("jwma.view.logout");
0700:            }//getLogoutView
0701:
0702:            /**
0703:             * Sets the filename/URL ending for the logout view.
0704:             *
0705:             * @param name the logout view filename/URL ending as <tt>String</tt>.
0706:             */
0707:            public void setLogoutView(String name) {
0708:                m_Properties.setProperty("jwma.view.logout", name);
0709:            }//setLogoutView
0710:
0711:            /**
0712:             * Returns a <tt>String</tt> representing the folder view
0713:             * filename/URL ending.
0714:             *
0715:             * @return the folder view filename/URL ending as <tt>String</tt>.
0716:             */
0717:            public String getFolderView() {
0718:                return m_Properties.getProperty("jwma.view.folder");
0719:            }//getFolderView
0720:
0721:            /**
0722:             * Sets the filename/URL ending for the folder view.
0723:             *
0724:             * @param name the folder view filename/URL ending as <tt>String</tt>.
0725:             */
0726:            public void setFolderView(String name) {
0727:                m_Properties.setProperty("jwma.view.folder", name);
0728:            }//setFolderView
0729:
0730:            /**
0731:             * Returns a <tt>String</tt> representing the mailbox view
0732:             * filename/URL ending.
0733:             *
0734:             * @return the mailbox view filename/URL ending as <tt>String</tt>.
0735:             */
0736:            public String getMailboxView() {
0737:                return m_Properties.getProperty("jwma.view.mailbox");
0738:            }//getMailboxView
0739:
0740:            /**
0741:             * Sets the filename/URL ending for the mailbox view.
0742:             *
0743:             * @param name the mailbox view filename/URL ending as <tt>String</tt>.
0744:             */
0745:            public void setMailboxView(String name) {
0746:                m_Properties.setProperty("jwma.view.mailbox", name);
0747:            }//setMailboxView
0748:
0749:            /**
0750:             * Returns a <tt>String</tt> representing the message view
0751:             * filename/URL ending.
0752:             *
0753:             * @return the message view filename/URL ending as <tt>String</tt>.
0754:             */
0755:            public String getMessageView() {
0756:                return m_Properties.getProperty("jwma.view.message");
0757:            }//getMessageView
0758:
0759:            /**
0760:             * Sets the filename/URL ending for the message view.
0761:             *
0762:             * @param name the message view filename/URL ending as <tt>String</tt>.
0763:             */
0764:            public void setMessageView(String name) {
0765:                m_Properties.setProperty("jwma.view.message", name);
0766:            }//setMessageView
0767:
0768:            /**
0769:             * Returns a <tt>String</tt> representing the compose view
0770:             * filename/URL ending.
0771:             *
0772:             * @return the compose view filename/URL ending as <tt>String</tt>.
0773:             */
0774:            public String getComposeView() {
0775:                return m_Properties.getProperty("jwma.view.compose");
0776:            }//getComposeView
0777:
0778:            /**
0779:             * Sets the filename/URL ending for the compose view.
0780:             *
0781:             * @param name the compose view filename/URL ending as <tt>String</tt>.
0782:             */
0783:            public void setComposeView(String name) {
0784:                m_Properties.setProperty("jwma.view.compose", name);
0785:            }//setComposeView
0786:
0787:            /**
0788:             * Returns a <tt>String</tt> representing the preferences view
0789:             * filename/URL ending.
0790:             *
0791:             * @return the preferences view filename/URL ending as <tt>String</tt>.
0792:             */
0793:            public String getPreferencesView() {
0794:                return m_Properties.getProperty("jwma.view.preferences");
0795:            }//getPreferencesView
0796:
0797:            /**
0798:             * Sets the filename/URL ending for the preferences view.
0799:             *
0800:             * @param name the preferences view filename/URL ending as <tt>String</tt>.
0801:             */
0802:            public void setPreferencesView(String name) {
0803:                m_Properties.setProperty("jwma.view.preferences", name);
0804:            }//setPreferencesView
0805:
0806:            /**
0807:             * Returns a <tt>String</tt> representing the firsttime view
0808:             * filename/URL ending.
0809:             *
0810:             * @return the firsttime view filename/URL ending as <tt>String</tt>.
0811:             */
0812:            public String getFirsttimeView() {
0813:                return m_Properties.getProperty("jwma.view.firsttime");
0814:            }//getFirsttimeView
0815:
0816:            /**
0817:             * Sets the filename/URL ending for the firsttime view.
0818:             *
0819:             * @param name the firsttime view filename/URL ending as <tt>String</tt>.
0820:             */
0821:            public void setFirsttimeView(String name) {
0822:                m_Properties.setProperty("jwma.view.firsttime", name);
0823:            }//setFirsttimeView
0824:
0825:            /**
0826:             * Returns a <tt>String</tt> representing the contacts view
0827:             * filename/URL ending.
0828:             *
0829:             * @return the contacts view filename/URL ending as <tt>String</tt>.
0830:             */
0831:            public String getContactsView() {
0832:                return m_Properties.getProperty("jwma.view.contacts");
0833:            }//getContactsView
0834:
0835:            /**
0836:             * Sets the filename/URL ending for the contacts view.
0837:             *
0838:             * @param name the contacts view filename/URL ending as <tt>String</tt>.
0839:             */
0840:            public void setContactsView(String name) {
0841:                m_Properties.setProperty("jwma.view.contacts", name);
0842:            }//setContactsView
0843:
0844:            /**
0845:             * Returns a <tt>String</tt> representing the contact view
0846:             * filename/URL ending.
0847:             *
0848:             * @return the contact view filename/URL ending as <tt>String</tt>.
0849:             */
0850:            public String getContactView() {
0851:                return m_Properties.getProperty("jwma.view.contact");
0852:            }//getContactView
0853:
0854:            /**
0855:             * Sets the filename/URL ending for the contact view.
0856:             *
0857:             * @param name the contact view filename/URL ending as <tt>String</tt>.
0858:             */
0859:            public void setContactView(String name) {
0860:                m_Properties.setProperty("jwma.view.contact", name);
0861:            }//setContactView
0862:
0863:            /**
0864:             * Returns a <tt>String</tt> representing the contact edit view
0865:             * filename/URL ending.
0866:             *
0867:             * @return the contact edit view filename/URL ending as <tt>String</tt>.
0868:             */
0869:            public String getContactEditView() {
0870:                return m_Properties.getProperty("jwma.view.contactedit");
0871:            }//getContactEditView
0872:
0873:            /**
0874:             * Sets the filename/URL ending for the contact edit view.
0875:             *
0876:             * @param name the contact edit view filename/URL ending as <tt>String</tt>.
0877:             */
0878:            public void setContactEditView(String name) {
0879:                m_Properties.setProperty("jwma.view.contactedit", name);
0880:            }//setContactEditView
0881:
0882:            /**
0883:             * Returns a <tt>String</tt> representing the contact group view
0884:             * filename/URL ending.
0885:             *
0886:             * @return the contact group view filename/URL ending as <tt>String</tt>.
0887:             */
0888:            public String getContactGroupView() {
0889:                return m_Properties.getProperty("jwma.view.contactgroup");
0890:            }//getContactGroupView
0891:
0892:            /**
0893:             * Sets the filename/URL ending for the contact group view.
0894:             *
0895:             * @param name the contact group view filename/URL ending as <tt>String</tt>.
0896:             */
0897:            public void setContactGroupView(String name) {
0898:                m_Properties.setProperty("jwma.view.contactgroup", name);
0899:            }//setContactGroupView
0900:
0901:            /**
0902:             * Returns a <tt>String</tt> representing the contact group edit view
0903:             * filename/URL ending.
0904:             *
0905:             * @return the contact group edit view filename/URL ending as <tt>String</tt>.
0906:             */
0907:            public String getContactGroupEditView() {
0908:                return m_Properties.getProperty("jwma.view.contactgroupedit");
0909:            }//getContactGroupEditView
0910:
0911:            /**
0912:             * Sets the filename/URL ending for the contact group edit view.
0913:             *
0914:             * @param name the contact group edit view filename/URL ending as <tt>String</tt>.
0915:             */
0916:            public void setContactGroupEditView(String name) {
0917:                m_Properties.setProperty("jwma.view.contactgroupedit", name);
0918:            }//setContactGroupEditView
0919:
0920:            /**
0921:             * Returns a <tt>String</tt> representing the admin preferences view
0922:             * filename/URL ending.
0923:             *
0924:             * @return the admin preferences view filename/URL ending as <tt>String</tt>.
0925:             */
0926:            public String getAdminPreferencesView() {
0927:                return m_Properties.getProperty("jwma.view.admin.preferences");
0928:            }//getAdminPreferencesView
0929:
0930:            /**
0931:             * Sets the filename/URL ending for the admin preferences view.
0932:             *
0933:             * @param name the preferences view filename/URL ending as <tt>String</tt>.
0934:             */
0935:            public void setAdminPreferencesView(String name) {
0936:                m_Properties.setProperty("jwma.view.admin.preferences", name);
0937:            }//setAdminPreferencesView
0938:
0939:            /**
0940:             * Returns a <tt>String</tt> representing the admin settings view
0941:             * filename/URL ending.
0942:             *
0943:             * @return the admin settings view filename/URL ending as <tt>String</tt>.
0944:             */
0945:            public String getAdminSettingsView() {
0946:                return m_Properties.getProperty("jwma.view.admin.settings");
0947:            }//getAdminSettingsView
0948:
0949:            /**
0950:             * Sets the filename/URL ending for the admin settings view.
0951:             *
0952:             * @param name the admin settings view filename/URL ending as <tt>String</tt>.
0953:             */
0954:            public void setAdminSettingsView(String name) {
0955:                m_Properties.setProperty("jwma.view.admin.settings", name);
0956:            }//setAdminSettingsView
0957:
0958:            /**
0959:             * Returns a <tt>String</tt> representing the admin login view
0960:             * filename/URL ending.
0961:             *
0962:             * @return the admin login view filename/URL ending as <tt>String</tt>.
0963:             */
0964:            public String getAdminLoginView() {
0965:                return m_Properties.getProperty("jwma.view.admin.login");
0966:            }//getAdminLoginView
0967:
0968:            /**
0969:             * Sets the filename/URL ending for the admin login view.
0970:             *
0971:             * @param name the admin login view filename/URL ending as <tt>String</tt>.
0972:             */
0973:            public void setAdminLoginView(String name) {
0974:                m_Properties.setProperty("jwma.view.admin.login", name);
0975:            }//setAdminLoginView
0976:
0977:            /**
0978:             * Returns a <tt>String</tt> representing the admin status view
0979:             * filename/URL ending.
0980:             *
0981:             * @return the admin status view filename/URL ending as <tt>String</tt>.
0982:             */
0983:            public String getAdminStatusView() {
0984:                return m_Properties.getProperty("jwma.view.admin.status");
0985:            }//getAdminStatusView
0986:
0987:            /**
0988:             * Sets the filename/URL ending for the admin status view.
0989:             *
0990:             * @param name the admin status view filename/URL ending as <tt>String</tt>.
0991:             */
0992:            public void setAdminStatusView(String name) {
0993:                m_Properties.setProperty("jwma.view.admin.status", name);
0994:            }//setAdminStatusView
0995:
0996:            /**
0997:             * Returns a <tt>String</tt> representing the admin menu view
0998:             * filename/URL ending.
0999:             *
1000:             * @return the admin menu view filename/URL ending as <tt>String</tt>.
1001:             */
1002:            public String getAdminMenuView() {
1003:                return m_Properties.getProperty("jwma.view.admin.menu");
1004:            }//getAdminMenuView
1005:
1006:            /**
1007:             * Sets the filename/URL ending for the admin menu view.
1008:             *
1009:             * @param name the admin menu view filename/URL ending as <tt>String</tt>.
1010:             */
1011:            public void setAdminMenuView(String name) {
1012:                m_Properties.setProperty("jwma.view.admin.menu", name);
1013:            }//setAdminMenuView
1014:
1015:            /**
1016:             * Returns a <tt>String</tt> representing the admin error view
1017:             * filename/URL ending.
1018:             *
1019:             * @return the admin error view filename/URL ending as <tt>String</tt>.
1020:             */
1021:            public String getAdminErrorView() {
1022:                return m_Properties.getProperty("jwma.view.admin.error");
1023:            }//getAdminErrorView
1024:
1025:            /**
1026:             * Sets the filename/URL ending for the admin error view.
1027:             *
1028:             * @param name the admin error view filename/URL ending as <tt>String</tt>.
1029:             */
1030:            public void setAdminErrorView(String name) {
1031:                m_Properties.setProperty("jwma.view.admin.error", name);
1032:            }//setAdminErrorView
1033:
1034:            /*** END Views related ***********************************************/
1035:
1036:            /*** i18n related ****************************************************/
1037:
1038:            public String getSystemLanguage() {
1039:                return m_Properties.getProperty("jwma.i18n.systemlanguage");
1040:            }//getSystemLanguage
1041:
1042:            public void setSystemLanguage(String language) {
1043:                m_Properties.setProperty("jwma.i18n.systemlanguage", language);
1044:            }//setLanguageList
1045:
1046:            public String[] getLanguageList() {
1047:                return StringUtil.split(m_Properties
1048:                        .getProperty("jwma.i18n.languages"), ",");
1049:            }//getLanguageList
1050:
1051:            public void setLanguageList(String[] languages) {
1052:                m_Properties.setProperty("jwma.i18n.languages", StringUtil
1053:                        .join(languages, ","));
1054:            }//setLanguageList
1055:
1056:            /*** END i18n related ************************************************/
1057:
1058:            public String getPrefPersistencePluginClassName() {
1059:                return m_Properties
1060:                        .getProperty("jwma.plugin.preferencespersistence");
1061:            }//getPrefPersistencePluginClassName
1062:
1063:            public void setPrefPersistencePluginClassName(String classname) {
1064:                m_Properties.setProperty("jwma.plugin.preferencespersistence",
1065:                        classname);
1066:            }//setPrefPersistencePluginClassName
1067:
1068:            public String getContactManagementPluginClassName() {
1069:                return m_Properties
1070:                        .getProperty("jwma.plugin.contactmanagement");
1071:            }//getContactManagementPluginClassName
1072:
1073:            public void setContactManagementPluginClassName(String classname) {
1074:                m_Properties.setProperty("jwma.plugin.contactmanagement",
1075:                        classname);
1076:            }//setContactManagementPluginClassName
1077:
1078:            public String getRandomAppendPluginClassName() {
1079:                return m_Properties.getProperty("jwma.plugin.randomappend");
1080:            }//getRandomAppendPluginClassName
1081:
1082:            public void setRandomAppendPluginClassName(String classname) {
1083:                m_Properties.setProperty("jwma.plugin.randomappend", classname);
1084:            }//setRandomApendPluginClassName
1085:
1086:            public String[] getCategories() {
1087:                return StringUtil.split(m_Properties
1088:                        .getProperty("jwma.contacts.categories"), ",");
1089:            }//getCategories
1090:
1091:            public void setCategories(String[] cats) {
1092:                m_Properties.setProperty("jwma.contacts.categories", StringUtil
1093:                        .join(cats, ","));
1094:            }//setCategories
1095:
1096:            /**
1097:             * Loads the properties file containing jwma's settings.
1098:             */
1099:            public void load() throws JwmaException {
1100:
1101:                try {
1102:                    FileInputStream in = new FileInputStream(m_PropFile);
1103:                    m_Properties.load(in);
1104:                } catch (Exception ex) {
1105:                    throw new JwmaException("jwma.settings.load.failed")
1106:                            .setException(ex);
1107:                }
1108:            }//load
1109:
1110:            /**
1111:             * Saves the properties file containing jwma's settings.
1112:             */
1113:            public void save() throws JwmaException {
1114:
1115:                try {
1116:                    FileOutputStream out = new FileOutputStream(m_PropFile);
1117:                    //FIXME: Modification line as string for saving
1118:                    m_Properties.store(out, "");
1119:                } catch (Exception ex) {
1120:                    throw new JwmaException("jwma.settings.save.failed")
1121:                            .setException(ex);
1122:                }
1123:            }//save
1124:
1125:            /**
1126:             * Returns a <tt>String</tt> representing the settings file's
1127:             * path.
1128:             *
1129:             * @return the settings file path as <tt>String</tt>.
1130:             */
1131:            public String getPath() {
1132:                return (m_WebInfDir + File.separator + ETC_DIR + File.separator + serviceproperties);
1133:            }//getPath
1134:
1135:            /**
1136:             * Returns a <tt>String</tt> representing the settings file's
1137:             * path.
1138:             *
1139:             * @return the settings file path as <tt>String</tt>.
1140:             */
1141:            public String getDump() {
1142:                StringWriter dump = new StringWriter();
1143:                m_Properties.list(new PrintWriter(dump));
1144:                return dump.toString();
1145:            }//getDump
1146:
1147:            /**
1148:             * Prepares for loading/saving the properties file
1149:             * containing jwma's settings.
1150:             */
1151:            private void prepare() throws JwmaException {
1152:
1153:                try {
1154:                    m_PropFile = new File(m_WebInfDir + File.separator
1155:                            + ETC_DIR + File.separator + serviceproperties);
1156:                    m_Properties = new Properties();
1157:                    m_PropFile.exists();
1158:                } catch (Exception ex) {
1159:                    throw new JwmaException("jwma.settings.load.prepare")
1160:                            .setException(ex);
1161:                }
1162:            }//prepare
1163:
1164:            /**
1165:             * Creates a <tt>JwmaSettings</tt> instance.
1166:             * <p>
1167:             * Requires the path to the directory where jwma's files and
1168:             * folders reside. For the WAR the path should represent
1169:             * the "WEB-INF" directory.
1170:             *
1171:             * @param path the path to the directory where jwma's files
1172:             *        and folders reside.
1173:             */
1174:            public static JwmaSettings createJwmaSettings(String path)
1175:                    throws JwmaException {
1176:
1177:                //create instance
1178:                JwmaSettings settings = new JwmaSettings(path);
1179:                settings.prepare();
1180:                settings.load();
1181:
1182:                return settings;
1183:            }//createJwmaSettings
1184:
1185:            /**
1186:             * Defines a name of the static jwma direcory architecture.
1187:             */
1188:            public static final String LOG_DIR = "logs";
1189:            public static final String ETC_DIR = "etc";
1190:            public static final String DATA_DIR = "data";
1191:            public static final String I18N_DIR = "i18n";
1192:
1193:            /**
1194:             * Defines the name of jwma's user visible error messages file.
1195:             */
1196:            public static final String ERROR_DESCRIPTION_FILE = "errormessages.properties";
1197:
1198:            /**
1199:             * Defines the name of jwma's properties file.
1200:             */
1201:            private static final String serviceproperties = "jwma.properties";
1202:
1203:        }//class JwmaSettingsImpl
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.