Source Code Cross Referenced for CastorXMLContactManagement.java in  » Web-Mail » Jwma » dtw » webmail » plugin » std » 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.plugin.std 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /***
002:         * jwma Java WebMail
003:         * Copyright (c) 2000-2003 jwma team
004:         *
005:         * jwma is free software; you can distribute and use this source
006:         * under the terms of the BSD-style license received along with
007:         * the distribution.
008:         ***/package dtw.webmail.plugin.std;
009:
010:        import dtw.webmail.JwmaKernel;
011:        import dtw.webmail.model.JwmaContact;
012:        import dtw.webmail.model.JwmaContacts;
013:        import dtw.webmail.model.JwmaContactsImpl;
014:        import dtw.webmail.model.JwmaException;
015:        import dtw.webmail.plugin.ContactManagementPlugin;
016:        import dtw.webmail.util.CastorDatabasePool;
017:        import dtw.webmail.util.JwmaSettings;
018:        import org.apache.log4j.Logger;
019:
020:        import java.io.*;
021:
022:        /**
023:         * A <tt>ContactManagementPlugin</tt> implementation
024:         * based on Castor XML marshalling/unmarshalling.
025:         * <p>
026:         * Stores the contacts as XML files.
027:         *
028:         * @author Dieter Wimberger
029:         * @version 0.9.7 07/02/2003
030:         */
031:        public class CastorXMLContactManagement implements 
032:                ContactManagementPlugin {
033:
034:            //logging
035:            private static Logger log = Logger
036:                    .getLogger(CastorXMLContactManagement.class);
037:
038:            private CastorPreferences m_PreferencesTemplate;
039:            private CastorDatabasePool m_DBPool;
040:            private String m_DataDir;
041:
042:            public JwmaContactsImpl loadContacts(String cuid)
043:                    throws JwmaException {
044:
045:                log.debug("loadContacts(" + cuid + ")");
046:                CastorContacts cts = null;
047:
048:                try {
049:
050:                    FileReader reader = new FileReader(getFilename(cuid));
051:                    log.debug("have file reader");
052:                    cts = (CastorContacts) CastorHelper.getReference()
053:                            .unmarshal(reader);
054:                    log.debug("unmarshalled from reader");
055:                    reader.close();
056:                } catch (Exception ex) {
057:                    log.debug("loadContacts():", ex);
058:                    if (ex instanceof  JwmaException) {
059:                        throw (JwmaException) ex;
060:                    } else {
061:                        throw new JwmaException("jwma.plugin.std", true)
062:                                .setException(ex);
063:                    }
064:                }
065:                return cts;
066:            }//loadContacts
067:
068:            public void saveContacts(JwmaContactsImpl contacts)
069:                    throws JwmaException {
070:
071:                try {
072:                    FileWriter writer = new FileWriter(getFilename(contacts
073:                            .getUID()));
074:                    CastorHelper.getReference().marshal(contacts, writer);
075:                    writer.close();
076:                } catch (Exception ex) {
077:                    if (ex instanceof  JwmaException) {
078:                        throw (JwmaException) ex;
079:                    } else {
080:                        throw new JwmaException("").setException(ex);
081:                    }
082:                }
083:            }//saveContacts
084:
085:            public boolean isPersistent(String cuid) throws JwmaException {
086:                try {
087:                    return new File(getFilename(cuid)).exists();
088:                } catch (Exception ex) {
089:                    throw new JwmaException("").setException(ex);
090:                }
091:            }//isPersistent
092:
093:            public JwmaContactsImpl createContacts() {
094:                return new CastorContacts();
095:            }//createContacts
096:
097:            public void activate() throws JwmaException {
098:                JwmaKernel kernel = JwmaKernel.getReference();
099:                try {
100:                    String etc = kernel.getDirectoryPath(JwmaKernel.ETC_DIR);
101:
102:                    //String m_MappingFile = etc + settings.getMappingFilename();
103:
104:                    m_DataDir = kernel.getDirectoryPath(JwmaKernel.DATA_DIR);
105:
106:                    //Setup castor helper
107:                    CastorHelper helper = CastorHelper.getReference();
108:
109:                    //load mapping
110:                    //helper.loadMapping(m_MappingFile);
111:
112:                    log.info(JwmaKernel.getReference().getLogMessage(
113:                            "jwma.plugin.activation"));
114:                } catch (Exception ex) {
115:                    log.info(JwmaKernel.getReference().getLogMessage(
116:                            "jwma.plugin.failedactivation"));
117:                    throw new JwmaException("").setException(ex);
118:                }
119:            }//activate
120:
121:            public void deactivate() {
122:                //FIXME: shut down pool, close down connections?
123:            }//deactivate
124:
125:            public String exportContact(JwmaContact contact, String TYPE)
126:                    throws JwmaException {
127:                return "";
128:                /*
129:                if(TYPE.equals(TYPE_VCARD3)) {
130:                  ByteArrayOutputStream bout=new ByteArrayOutputStream();
131:
132:                  m_vCardMarshaller.marshallContact(bout,((JpimContact)contact).getContact());
133:                  return new String(bout.toByteArray());
134:                } else {
135:                  return "";
136:                }
137:                 */
138:            }//export
139:
140:            public JwmaContact importContact(InputStream in, String TYPE)
141:                    throws JwmaException {
142:                return null;
143:                /*
144:                if(TYPE.equals(TYPE_VCARD3) || TYPE.equals(TYPE_VCARD2)) {
145:                  try {
146:                    return new JpimContact(
147:                      new vCardUnmarshaller()
148:                             .unmarshallContact(in)
149:                    );
150:                  } catch (Exception ex) {
151:                    log.error("importContact():",ex);
152:                    return null;
153:                  }
154:                } else {
155:                  return null;
156:                }
157:                 */
158:            }//importContact
159:
160:            public JwmaContact[] importDatabase(InputStream in, String TYPE)
161:                    throws JwmaException {
162:                return null;
163:            }//importDatabase
164:
165:            public void exportDatabase(OutputStream out, JwmaContacts db,
166:                    String TYPE) throws JwmaException {
167:                return;
168:            }//exportDatabase
169:
170:            public String[] getSupportedTypes(int IMEX_TYPE) {
171:                switch (IMEX_TYPE) {
172:                case CONTACT_IMPORT:
173:                    return CONTACT_IMPORT_TYPES;
174:                case CONTACT_EXPORT:
175:                    return CONTACT_EXPORT_TYPES;
176:                case DATABASE_EXPORT:
177:                    return DATABASE_EXPORT_TYPES;
178:                case DATABASE_IMPORT:
179:                    return DATABASE_IMPORT_TYPES;
180:                default:
181:                    return NO_TYPES;
182:                }
183:            }//getSupportedTypes
184:
185:            public boolean isSupportedContactImportType(String type) {
186:                for (int i = 0; i < CONTACT_IMPORT_TYPES.length; i++) {
187:                    if (type.equalsIgnoreCase(CONTACT_IMPORT_TYPES[i])) {
188:                        return true;
189:                    }
190:                }
191:                return false;
192:            }//isSupportedContactImportType
193:
194:            private String getFilename(String uid) {
195:                return m_DataDir + uid + ".xml";
196:            }//getFileName
197:
198:            public static final String TYPE_VCARD3 = "text/directory";
199:            public static final String TYPE_VCARD2 = "application/directory";
200:            private static final String[] NO_TYPES = new String[0];
201:
202:            private static final String[] CONTACT_IMPORT_TYPES = NO_TYPES;
203:            private static final String[] CONTACT_EXPORT_TYPES = NO_TYPES;
204:            private static final String[] DATABASE_EXPORT_TYPES = NO_TYPES;
205:            private static final String[] DATABASE_IMPORT_TYPES = NO_TYPES;
206:
207:        }//class CastorContactManagement
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.