From 1641b16233ef67579034c27dad8933e2dc0ce157 Mon Sep 17 00:00:00 2001 From: Mathew McBride Date: Tue, 10 Feb 2009 20:37:39 +1100 Subject: [PATCH] Update Funambol PIM dependencies; some attendee work, also pass property maps direct to objectstore and test classes etc. --- pom.xml | 58 ++++++++++------------ .../funambol/datakit/funambol2ical4j.java | 1 + .../funambol/datakit/ical4j2funambol.java | 4 +- .../groupdav/calendar/CalendarSyncSource.java | 10 ++-- src/test/java/diagnostic/funambolCalParser.java | 27 +++++++++- .../java/diagnostic/funambolContactParser.java | 30 +++++++++-- .../calendar/CalendarSyncSourceAsTodoTest.java | 7 +-- .../groupdav/calendar/CalendarSyncSourceTest.java | 1 + .../calendar/CalendarSyncSourceWithTodoTest.java | 9 +--- .../groupdav/contacts/ContactSyncSourceTest.java | 9 ++-- 10 files changed, 96 insertions(+), 60 deletions(-) diff --git a/pom.xml b/pom.xml index ac2c041..bc9f620 100644 --- a/pom.xml +++ b/pom.xml @@ -16,10 +16,9 @@ false - true - bionicmessage @@ -34,8 +33,8 @@ bmessage-snapshots bionicmessage snapshots http://latest.bionicmessage.net/maven-snapshots-repo/ - - + + funambol @@ -43,7 +42,7 @@ http://m2.funambol.org/repositories/artifacts/ - + @@ -86,9 +85,16 @@ funambol pim-framework - 7.1.0-SNAPSHOT + 7.1.1-SNAPSHOT + compile + + + log4j + log4j + 1.2.5 compile + @@ -111,24 +117,19 @@ - - - - + + - - + - - + - - + @@ -141,16 +142,11 @@ process-resources - - - - - - - - - - + + + + + @@ -195,10 +191,10 @@ org.apache.maven.plugins maven-deploy-plugin - target/groupdav-2.3.s4j @@ -206,7 +202,7 @@ ftp://bionicmessage.net/www/latest/maven-snapshots-repo/ false - diff --git a/src/main/java/net/bionicmessage/funambol/datakit/funambol2ical4j.java b/src/main/java/net/bionicmessage/funambol/datakit/funambol2ical4j.java index 9bf22b2..9736d6c 100644 --- a/src/main/java/net/bionicmessage/funambol/datakit/funambol2ical4j.java +++ b/src/main/java/net/bionicmessage/funambol/datakit/funambol2ical4j.java @@ -457,4 +457,5 @@ public class funambol2ical4j { } return false; } + } diff --git a/src/main/java/net/bionicmessage/funambol/datakit/ical4j2funambol.java b/src/main/java/net/bionicmessage/funambol/datakit/ical4j2funambol.java index d35b8c3..7e34272 100644 --- a/src/main/java/net/bionicmessage/funambol/datakit/ical4j2funambol.java +++ b/src/main/java/net/bionicmessage/funambol/datakit/ical4j2funambol.java @@ -176,8 +176,6 @@ public class ical4j2funambol { dts.setDate(ds); attachAllDayDtStart(fnblcontent, dts.getValue(), clientType); attachAllDayDtEnd(fnblcontent, dte.getValue(), clientType); - } else { - fnblcontent.setAllDay(false); } if (comp.getProperty(Summary.SUMMARY) != null) { /* We need to consider text encodings for this. @@ -590,7 +588,7 @@ public class ical4j2funambol { Calendar ics = cbuild.build(fis); com.funambol.common.pim.calendar.Calendar fnblcal = ical4j2funambol.convertIcal4jToFunambolEvent(ics, "text/x-vcalendar"); - VCalendarConverter vcc = new VCalendarConverter(null, "UTF-8"); + VCalendarConverter vcc = new VCalendarConverter(null, "UTF-8",false); VCalendar vc = vcc.calendar2vcalendar(fnblcal, true); System.out.println(vc.toString()); } catch (Exception e) { diff --git a/src/main/java/net/bionicmessage/funambol/groupdav/calendar/CalendarSyncSource.java b/src/main/java/net/bionicmessage/funambol/groupdav/calendar/CalendarSyncSource.java index ea4fa44..0477a2b 100644 --- a/src/main/java/net/bionicmessage/funambol/groupdav/calendar/CalendarSyncSource.java +++ b/src/main/java/net/bionicmessage/funambol/groupdav/calendar/CalendarSyncSource.java @@ -222,6 +222,7 @@ public class CalendarSyncSource extends AbstractSyncSource implements LazyInitBe * @return */ public SyncItemKey[] getDeletedSyncItemKeys(java.sql.Timestamp sinceTs, java.sql.Timestamp untilTs) { + log.info("getDeletedSyncItemKeys()"); ArrayList deletedUIDS = so.getDeletedFromStoreUIDS(); SyncItemKey[] keys = new SyncItemKey[deletedUIDS.size()]; for (int i = 0; i < deletedUIDS.size(); i++) { @@ -232,9 +233,12 @@ public class CalendarSyncSource extends AbstractSyncSource implements LazyInitBe return keys; } - // - // #[regen=yes,id=DCE.EE4A388C-A94E-B384-EC8A-2E349EACBA40] - // + /** + * Obtain a list of new objects on server + * @param sinceTs From time, not applicable + * @param untilTs To time, not applicable + * @return + */ public SyncItemKey[] getNewSyncItemKeys(java.sql.Timestamp sinceTs, java.sql.Timestamp untilTs) { log.info("getNewSyncItemKeys()"); ArrayList newUIDS = so.getAddedToStoreUIDS(); diff --git a/src/test/java/diagnostic/funambolCalParser.java b/src/test/java/diagnostic/funambolCalParser.java index 847d214..ca3c5b0 100644 --- a/src/test/java/diagnostic/funambolCalParser.java +++ b/src/test/java/diagnostic/funambolCalParser.java @@ -29,6 +29,7 @@ import com.funambol.common.pim.model.VCalendar; import com.funambol.common.pim.xvcalendar.XVCalendarParser; import java.io.File; import java.io.FileInputStream; +import java.util.List; /** * @@ -64,7 +65,7 @@ public class funambolCalParser { VCalendar vc = vcp.XVCalendar(); VCalendarConverter vcf = new VCalendarConverter(null, "UTF-8"); Calendar cal = vcf.vcalendar2calendar(vc); - VCalendar blowback = vcf.calendar2vcalendar(cal, false); + VCalendar blowback = vcf.calendar2vcalendar(cal, true); String result = blowback.toString(); System.out.print(result); // } @@ -74,6 +75,28 @@ public class funambolCalParser { // } } - + @Test + public void testVcalAttendees() throws Exception { + // try { + File testFile = new File ("doc/testData/vcal1-attendees.vcs"); + FileInputStream fis = new FileInputStream(testFile); + XVCalendarParser vcp = new XVCalendarParser(fis); + VCalendar vc = vcp.XVCalendar(); + VCalendarConverter vcf = new VCalendarConverter(null, "UTF-8"); + Calendar cal = vcf.vcalendar2calendar(vc); + List attendees = cal.getCalendarContent().getAttendees(); + assertTrue("Attendees not in CalendarContent",(attendees.size() > 0)); + for(Attendee at : attendees) { + System.out.format("Attendee: %s %s\n", at.getName(), at.getEmail()).flush(); + } + VCalendar blowback = vcf.calendar2vcalendar(cal, true); + String result = blowback.toString(); + System.out.print(result); + // } + // catch (Exception e) { + // e.printStackTrace(); + + // } + } } \ No newline at end of file diff --git a/src/test/java/diagnostic/funambolContactParser.java b/src/test/java/diagnostic/funambolContactParser.java index ca92402..c1c2eb8 100644 --- a/src/test/java/diagnostic/funambolContactParser.java +++ b/src/test/java/diagnostic/funambolContactParser.java @@ -81,8 +81,32 @@ public class funambolContactParser { // } } - - - + @Test + public void testVCardAttendees() throws Exception { + // try { + //File testFile = new File ("doc/testData/vcal1-attendees.vcs"); + File testFile = new File ("/tmp/test.vcf"); + FileInputStream fis = new FileInputStream(testFile); + /* Fix problems with Citadel lowercase begin:vcard etc.. */ + byte[] data = new byte[fis.available()]; + fis.read(data); + String tofix = new String(data, "UTF-8"); + tofix = tofix.replace("begin:", "BEGIN:").replace("end:", "END:").replace("vcard", "VCARD"); + ByteArrayInputStream bis = new ByteArrayInputStream(tofix.getBytes("UTF-8")); + VcardParser vcp = new VcardParser(bis, null, "UTF-8"); + Contact vc = vcp.vCard(); + ContactToVcard convert = new ContactToVcard(null, "UTF-8"); + String converted = convert.convert(vc); + if (!converted.contains("Company INC.")) { + throw new Exception("Output does not contain organization"); + } + System.out.println(converted); + fis.close(); + // } + // catch (Exception e) { + // e.printStackTrace(); + + // } + } } \ No newline at end of file diff --git a/src/test/java/net/bionicmessage/funambol/groupdav/calendar/CalendarSyncSourceAsTodoTest.java b/src/test/java/net/bionicmessage/funambol/groupdav/calendar/CalendarSyncSourceAsTodoTest.java index ed7d496..cdd9703 100644 --- a/src/test/java/net/bionicmessage/funambol/groupdav/calendar/CalendarSyncSourceAsTodoTest.java +++ b/src/test/java/net/bionicmessage/funambol/groupdav/calendar/CalendarSyncSourceAsTodoTest.java @@ -82,11 +82,8 @@ public class CalendarSyncSourceAsTodoTest { testProps.load(new FileInputStream(testPropFile)); css = new CalendarSyncSource(); String storePath = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + "calendarsyncsourcetodo-test"; - Properties props = new Properties(); - props.setProperty(Constants.STOREDIR_PATH, storePath); - props.setProperty(Constants.SOURCE_LOCATION_BASE + "default", testProps.getProperty("connector.sources.default")); - props.setProperty(Constants.SERVER_HOST, testProps.getProperty("connector.serverhost")); - css.setConnectorProperties(props); + testProps.setProperty(Constants.STOREDIR_PATH, storePath); + css.setConnectorProperties(testProps); spp = Sync4jPrincipal.createPrincipal(testProps.getProperty("test.user"), "testid"); String passString = String.format("%s:%s", testProps.getProperty("test.user"), testProps.getProperty("test.password")); diff --git a/src/test/java/net/bionicmessage/funambol/groupdav/calendar/CalendarSyncSourceTest.java b/src/test/java/net/bionicmessage/funambol/groupdav/calendar/CalendarSyncSourceTest.java index 904daf1..7d422f3 100644 --- a/src/test/java/net/bionicmessage/funambol/groupdav/calendar/CalendarSyncSourceTest.java +++ b/src/test/java/net/bionicmessage/funambol/groupdav/calendar/CalendarSyncSourceTest.java @@ -80,6 +80,7 @@ public class CalendarSyncSourceTest { testProps.load(new FileInputStream(testPropsFile)); css = new CalendarSyncSource(); String storePath = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + "calendarsyncsource-test"; + testProps.setProperty(Constants.STOREDIR_PATH, storePath); css.setConnectorProperties(testProps); String testUser = testProps.getProperty("test.user"); spp = Sync4jPrincipal.createPrincipal(testProps.getProperty("test.user"), "testid"); diff --git a/src/test/java/net/bionicmessage/funambol/groupdav/calendar/CalendarSyncSourceWithTodoTest.java b/src/test/java/net/bionicmessage/funambol/groupdav/calendar/CalendarSyncSourceWithTodoTest.java index 2827ee9..5c2de8b 100644 --- a/src/test/java/net/bionicmessage/funambol/groupdav/calendar/CalendarSyncSourceWithTodoTest.java +++ b/src/test/java/net/bionicmessage/funambol/groupdav/calendar/CalendarSyncSourceWithTodoTest.java @@ -84,13 +84,8 @@ public class CalendarSyncSourceWithTodoTest { testProps.load(new FileInputStream(testPropFile)); css = new CalendarSyncSource(); String storePath = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + "calendarsyncsource-test"; - Properties props = new Properties(); - props.setProperty(Constants.STOREDIR_PATH, storePath); - props.setProperty(Constants.SOURCE_LOCATION_BASE + "default", testProps.getProperty("connector.sources.default")); - props.setProperty(Constants.SOURCE_LOCATION_BASE + "tasks", testProps.getProperty("connector.sources.tasks")); - props.setProperty(Constants.SERVER_HOST, testProps.getProperty("connector.serverhost")); - props.setProperty(Constants.MIXED_MODE, "true"); - css.setConnectorProperties(props); + testProps.setProperty(Constants.STOREDIR_PATH, storePath); + css.setConnectorProperties(testProps); String testUser = testProps.getProperty("test.user"); spp = Sync4jPrincipal.createPrincipal(testProps.getProperty("test.user"), "testid"); String passString = String.format("%s:%s", testProps.getProperty("test.user"), diff --git a/src/test/java/net/bionicmessage/funambol/groupdav/contacts/ContactSyncSourceTest.java b/src/test/java/net/bionicmessage/funambol/groupdav/contacts/ContactSyncSourceTest.java index 784fa9a..ea0c407 100644 --- a/src/test/java/net/bionicmessage/funambol/groupdav/contacts/ContactSyncSourceTest.java +++ b/src/test/java/net/bionicmessage/funambol/groupdav/contacts/ContactSyncSourceTest.java @@ -75,15 +75,12 @@ public class ContactSyncSourceTest { testProps.load(new FileInputStream(new File(testPropsPath))); css = new ContactSyncSource(); String storePath = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + "contactsyncsource-test"; - Properties props = new Properties(); - props.setProperty(Constants.STOREDIR_PATH, storePath); - props.setProperty(Constants.SOURCE_LOCATION_BASE + "default", "/groupdav/Contacts"); - props.setProperty(Constants.SERVER_HOST, "http://comalies.citadel.org:2000"); String authString = String.format("%s:%s", testProps.getProperty("test.user"), testProps.getProperty("test.password")); byte[] b64auth = Base64.encode(authString.getBytes("UTF-8")); - css.setConnectorProperties(props); + testProps.setProperty(Constants.STOREDIR_PATH, storePath); + css.setConnectorProperties(testProps); spp = Sync4jPrincipal.createPrincipal("testuser", "testid"); spp.setEncodedUserPwd(new String(b64auth)); ctx = new SyncContext(spp, 0, null, null, 0); @@ -146,7 +143,7 @@ public class ContactSyncSourceTest { ctx = new SyncContext(spp, 200, null, null, 0); css.setType("text/x-vcard"); css.beginSync(ctx); - File problemSample = new File("doc/problem-samples/complex-vcard.vcs"); + File problemSample = new File("doc/testData/s60-vcard.vcs"); FileInputStream fis = new FileInputStream(problemSample); byte[] data = new byte[fis.available()]; fis.read(data); -- 2.11.4.GIT