Source Code Cross Referenced for ApptCond.java in  » Project-Management » borg » net » sf » borg » apptconduit » 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 » Project Management » borg » net.sf.borg.apptconduit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sf.borg.apptconduit;
002:
003:        import java.io.FileInputStream;
004:        import java.io.IOException;
005:        import java.util.Properties;
006:
007:        import net.sf.borg.common.Errmsg;
008:        import net.sf.borg.common.J13Helper;
009:        import net.sf.borg.common.SocketClient;
010:        import net.sf.borg.model.AppointmentModel;
011:        import net.sf.borg.model.db.remote.IRemoteProxy;
012:        import net.sf.borg.model.db.remote.IRemoteProxyProvider;
013:        import net.sf.borg.model.db.remote.RemoteProxyHome;
014:        import net.sf.borg.model.db.remote.socket.SocketProxy;
015:        import palm.conduit.Conduit;
016:        import palm.conduit.ConfigureConduitInfo;
017:        import palm.conduit.Log;
018:        import palm.conduit.SyncManager;
019:        import palm.conduit.SyncProperties;
020:
021:        //"Portions copyright (c) 1996-2002 PalmSource, Inc. or its affiliates.  All rights reserved."
022:        public class ApptCond implements  Conduit {
023:
024:            /**
025:             * Name of the conduit to be displayed on the dialog
026:             */
027:            static final String NAME = "BORG Appt Conduit";
028:
029:            static private int port;
030:
031:            static public void log(String s) {
032:                Log.out(s);
033:                String s2 = J13Helper.replace(s, "\n", "%NL%");
034:                try {
035:                    SocketClient.sendMsg("localhost", port, "lock:" + s2);
036:                } catch (IOException e) {
037:
038:                }
039:            }
040:
041:            public void open(SyncProperties props) {
042:
043:                ApptRecordManager recordMgr;
044:                TodoRecordManager trecordMgr;
045:                AppointmentModel apptModel;
046:                //TaskModel taskModel;
047:
048:                Errmsg.console(true);
049:
050:                // Tell the log we are starting
051:                Log.startSync();
052:
053:                try {
054:                    if (props.syncType == SyncProperties.SYNC_DO_NOTHING) {
055:
056:                        Log.out("OK ApptCond Do Nothing");
057:                        Log.endSync();
058:                    } else {
059:                        // read the pc records on the PC
060:                        String loc = props.localName;
061:                        String dbdir = props.pathName;
062:                        String user = props.userName;
063:                        Log.out("dbdir=" + dbdir);
064:                        Log.out("user=" + user);
065:                        Log.out("localName=" + loc);
066:
067:                        if (loc.indexOf(':') != -1) {
068:                            dbdir = loc;
069:                        }
070:
071:                        // check for properties file
072:                        String propfile = dbdir + "/db.properties";
073:                        try {
074:                            FileInputStream is = new FileInputStream(propfile);
075:                            Properties dbprops = new Properties();
076:                            dbprops.load(is);
077:                            dbdir = dbprops.getProperty("dburl");
078:                            user = dbprops.getProperty("user");
079:                            port = Integer
080:                                    .parseInt(dbprops.getProperty("port"));
081:                        } catch (Exception e) {
082:                            Log.out("Properties exception: " + e.toString());
083:                        }
084:
085:                        // If we're doing remote stuff, use SocketProxy
086:                        RemoteProxyHome.getInstance().setProxyProvider(
087:                                new IRemoteProxyProvider() {
088:                                    public final IRemoteProxy createProxy(
089:                                            String url) {
090:                                        // No synchronization needed - we're
091:                                        // single-threaded.
092:                                        if (proxy == null)
093:                                            proxy = new SocketProxy(url, port);
094:                                        return proxy;
095:                                    }
096:
097:                                    public final Credentials getCredentials() {
098:                                        return new Credentials("$default",
099:                                                "$default");
100:                                    }
101:
102:                                    // private //
103:                                    private IRemoteProxy proxy = null;
104:                                });
105:
106:                        // shutdown the app - unless we are using a remote socket
107:                        // interface
108:                        if (!dbdir.startsWith("remote:")) {
109:                            try {
110:                                SocketClient.sendMsg("localhost", port,
111:                                        "shutdown");
112:                            } catch (Exception e) {
113:                            }
114:                        } else {
115:                            try {
116:                                SocketClient
117:                                        .sendMsg("localhost", port,
118:                                                "lock:Appointment HotSync In Progress...Please wait");
119:                            } catch (Exception e) {
120:                            }
121:                        }
122:
123:                        log("dbdir=" + dbdir);
124:                        log("user=" + user);
125:                        apptModel = AppointmentModel.create();
126:                        apptModel.open_db(dbdir, user, false);
127:                        /*
128:                         taskModel = TaskModel.create();
129:                         try{
130:                         taskModel.open_db(dbdir, user, false, false);
131:                         }
132:                         catch( Exception e)
133:                         {
134:                         //ignore exception for subtasks no supported
135:                         }*/
136:                        // have to get todo data into BORG, then get appt data, then
137:                        // sync back
138:                        // appt data and finally overwrite Todo data.
139:                        if (props.syncType != SyncProperties.SYNC_DO_NOTHING) {
140:                            log("Sync Todos from Palm to Borg");
141:                            int tododb = SyncManager.openDB("ToDoDB", 0,
142:                                    SyncManager.OPEN_READ
143:                                            | SyncManager.OPEN_WRITE
144:                                            | SyncManager.OPEN_EXCLUSIVE);
145:                            trecordMgr = new net.sf.borg.apptconduit.TodoRecordManager(
146:                                    props, tododb);
147:                            trecordMgr.SyncData();
148:                            SyncManager.closeDB(tododb);
149:                        }
150:
151:                        int apptdb = SyncManager.openDB("DatebookDB", 0,
152:                                SyncManager.OPEN_READ | SyncManager.OPEN_WRITE
153:                                        | SyncManager.OPEN_EXCLUSIVE);
154:                        recordMgr = new net.sf.borg.apptconduit.ApptRecordManager(
155:                                props, apptdb);
156:                        int numrecs = SyncManager.getDBRecordCount(apptdb);
157:
158:                        // send ALL records to HH if wipe option set by user OR is HH db
159:                        // is empty
160:                        if (props.syncType == SyncProperties.SYNC_PC_TO_HH
161:                                || numrecs == 0) {
162:                            log("Wipe Palm/Sync Appts");
163:                            recordMgr.WipeData();
164:                        } else if (props.syncType == SyncProperties.SYNC_HH_TO_PC) {
165:                            recordMgr.quickSyncAndWipe();
166:                        } else {
167:                            log("Sync Appts");
168:                            recordMgr.SyncData();
169:                        }
170:
171:                        SyncManager.closeDB(apptdb);
172:
173:                        if (props.syncType != SyncProperties.SYNC_DO_NOTHING) {
174:                            int tododb = SyncManager.openDB("ToDoDB", 0,
175:                                    SyncManager.OPEN_READ
176:                                            | SyncManager.OPEN_WRITE
177:                                            | SyncManager.OPEN_EXCLUSIVE);
178:                            trecordMgr = new net.sf.borg.apptconduit.TodoRecordManager(
179:                                    props, tododb);
180:                            log("Wipe Todos and load Palm from BORG");
181:                            trecordMgr.WipeData();
182:                            SyncManager.closeDB(tododb);
183:                        }
184:
185:                        // Close DB
186:                        apptModel.close_db();
187:                        //taskModel.close_db();
188:                        // Single Log we are successful
189:                        log("OK ApptCond Conduit");
190:                        Log.endSync();
191:                        if (dbdir.startsWith("remote:")) {
192:                            try {
193:                                SocketClient.sendMsg("localhost", port, "sync");
194:                                SocketClient.sendMsg("localhost", port,
195:                                        "lock:Appointment HotSync Completed");
196:                                SocketClient.sendMsg("localhost", port,
197:                                        "unlock");
198:                            } catch (Exception e) {
199:                            }
200:                        }
201:                    }
202:
203:                } catch (Throwable t) {
204:
205:                    // If there was an error, dump the stack trace
206:                    // and tell the log the conduit failed
207:
208:                    t.printStackTrace();
209:                    Log.abortSync();
210:                }
211:            }
212:
213:            /**
214:             * Returns a String representation of the conduit name.
215:             */
216:            public String name() {
217:                return NAME;
218:            }
219:
220:            public int configure(ConfigureConduitInfo info) {
221:                ConduitConfigure config = new ConduitConfigure(info, NAME);
222:                config.createDialog();
223:
224:                if (config.dataChanged) {
225:                    int propsValue = SyncProperties.SYNC_DO_NOTHING; // default
226:                    propsValue = config.saveState;
227:
228:                    if (config.setDefault) {
229:                        info.syncPermanent = propsValue;
230:                        info.syncPref = ConfigureConduitInfo.PREF_PERMANENT;
231:                    }
232:                    info.syncNew = propsValue;
233:                }
234:
235:                return 0;
236:            }
237:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.