xlawrence    2004/12/22 12:00:36 CET

  Modified files:
    src/java/org/jahia/suite/calendar/calServer 
                                                UwCalConnector.java 
    src/java/org/jahia/suite/calendar/sync4jModule 
                                                   
CalendarSyncSourceOutlook.java 
    src/java/org/jahia/suite/calendar/syncClients 
                                                  CalendarFileManager.java 
                                                  SyncClient.java 
    src/java/org/jahia/suite/calendar/test 
                                           DummyCalendarServer.java 
  Log:
  Bug correction: Wrong String encoding resulted in 2 equal Strings were not 
declared as equal.
  
  Revision  Changes    Path
  1.8       +24 -5     
uwcal_JSR168/src/java/org/jahia/suite/calendar/calServer/UwCalConnector.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/org/jahia/suite/calendar/calServer/UwCalConnector.java.diff?r1=1.7&r2=1.8&f=h
  1.2       +5 -5      
uwcal_JSR168/src/java/org/jahia/suite/calendar/sync4jModule/CalendarSyncSourceOutlook.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/org/jahia/suite/calendar/sync4jModule/CalendarSyncSourceOutlook.java.diff?r1=1.1&r2=1.2&f=h
  1.8       +7 -7      
uwcal_JSR168/src/java/org/jahia/suite/calendar/syncClients/CalendarFileManager.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/org/jahia/suite/calendar/syncClients/CalendarFileManager.java.diff?r1=1.7&r2=1.8&f=h
  1.12      +12 -5     
uwcal_JSR168/src/java/org/jahia/suite/calendar/syncClients/SyncClient.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/org/jahia/suite/calendar/syncClients/SyncClient.java.diff?r1=1.11&r2=1.12&f=h
  1.10      +32 -32    
uwcal_JSR168/src/java/org/jahia/suite/calendar/test/DummyCalendarServer.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/org/jahia/suite/calendar/test/DummyCalendarServer.java.diff?r1=1.9&r2=1.10&f=h
  
  
  
  Index: UwCalConnector.java
  ===================================================================
  RCS file: 
/home/cvs/repository/uwcal_JSR168/src/java/org/jahia/suite/calendar/calServer/UwCalConnector.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- UwCalConnector.java       21 Dec 2004 15:36:14 -0000      1.7
  +++ UwCalConnector.java       22 Dec 2004 11:00:35 -0000      1.8
  @@ -43,7 +43,12 @@
   import org.jahia.suite.calendar.framework.model.SyncOperation;
   
   import edu.rpi.cct.uwcal.synch.common.Synch;
  +import net.fortuna.ical4j.model.Component;
  +import net.fortuna.ical4j.model.Calendar;
   import net.fortuna.ical4j.model.component.VEvent;
  +import net.fortuna.ical4j.data.CalendarBuilder;
  +
  +import java.io.StringReader;
   
   /**
    * This class implements the Storable interface. An object of this class will
  @@ -98,13 +103,27 @@
                   String type = temp.getType();
                   if (SyncOperation.ADD.equals(type) || 
SyncOperation.MODIFY.equals(type)) {
                       
  -                    // build a VEvent from the SyncEvent String
  -                    VEvent event = new VEvent();
  -                   
  +                    String eventString = "BEGIN:VEVENT...";
  +                    
  +                    StringBuffer buffer = new StringBuffer();
  +                    buffer.append(Calendar.BEGIN);
  +                    buffer.append(':');
  +                    buffer.append(Calendar.VCALENDAR);
  +                    buffer.append("\r\n");
  +                    buffer.append(eventString);
  +                    buffer.append(Calendar.END);
  +                    buffer.append(':');
  +                    buffer.append(Calendar.VCALENDAR);
  +                    buffer.append("\r\n");
  +                    
  +                    CalendarBuilder builder = new CalendarBuilder();
  +                    Calendar calendar = builder.build(new 
StringReader(buffer.toString()));
  +                    
  +                    VEvent vEvent = 
(VEvent)calendar.getComponents().iterator().next();
  +                    calServer.updateEvent(vEvent);
                       
                   } else if (SyncOperation.DELETE.equals(type)) {
                       // delete the event
  -
                       
                   } else {
                       throw new SyncException("Unknown operation type: "+type);
  @@ -151,5 +170,5 @@
           } catch (Exception e) {
               throw new SyncException(e.getMessage(), e);
           }
  -    }  
  +    }
   }
  
  
  
  Index: CalendarSyncSourceOutlook.java
  ===================================================================
  RCS file: 
/home/cvs/repository/uwcal_JSR168/src/java/org/jahia/suite/calendar/sync4jModule/CalendarSyncSourceOutlook.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CalendarSyncSourceOutlook.java    17 Dec 2004 15:45:39 -0000      1.1
  +++ CalendarSyncSourceOutlook.java    22 Dec 2004 11:00:35 -0000      1.2
  @@ -180,12 +180,12 @@
           try {            
               // Converting the i-cal item into a Calendar object           
               String content = 
  -            "BEGIN:VCALENDAR\n" +           
  -            "PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN\n" +
  -            "VERSION:2.0\n" +
  -            "METHOD:PUBLISH\n" + 
  +            "BEGIN:VCALENDAR\r\n" +           
  +            "PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN\r\n" +
  +            "VERSION:2.0\r\n" +
  +            "METHOD:PUBLISH\r\n" + 
               new String(byteContent) +
  -            "\nEND:VCALENDAR";
  +            "\r\nEND:VCALENDAR";
               
   //            log.debug("content: "+content);
               
  
  
  
  Index: CalendarFileManager.java
  ===================================================================
  RCS file: 
/home/cvs/repository/uwcal_JSR168/src/java/org/jahia/suite/calendar/syncClients/CalendarFileManager.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CalendarFileManager.java  22 Dec 2004 08:19:40 -0000      1.7
  +++ CalendarFileManager.java  22 Dec 2004 11:00:35 -0000      1.8
  @@ -177,17 +177,17 @@
       public void writeCalendarItems(String fileName, String[] items) throws
       FileNotFoundException, IOException, ValidationException, ParserException 
{
           StringBuffer calendar = new StringBuffer();
  -        calendar.append("BEGIN:VCALENDAR\n");
  +        calendar.append("BEGIN:VCALENDAR\r\n");
           for (int i=0; i<items.length; i++) {
               if (i==0 && items[i].startsWith("BEGIN")) {
                   // before writing the first VEVENT, we need to
                   // write the calendar properties
                   calendar.append(
  -                "PRODID:-//Jahia Solutions//iCalendar SyncClient 1.0 
MIMEDIR//EN\n" +
  -                "VERSION:2.0\n" +
  -                "METHOD:PUBLISH\n");
  +                "PRODID:-//Jahia Solutions//iCalendar SyncClient 1.0 
MIMEDIR//EN\r\n" +
  +                "VERSION:2.0\r\n" +
  +                "METHOD:PUBLISH\r\n");
               }
  -            calendar.append(items[i]+"\n");
  +            calendar.append(items[i]+"\r\n");
           }
           calendar.append("END:VCALENDAR");
           writeCalendarItems(fileName, calendar.toString());
  @@ -206,14 +206,14 @@
       public void writeCalendarItems(String fileName, String items) throws
       FileNotFoundException, IOException, ValidationException, ParserException 
{
           
  -        final String utfItems = new String(items.getBytes("ISO-8859-1"));
  +        final String utfItems = new String(items.getBytes());
           BufferedReader reader = new BufferedReader(new 
StringReader(utfItems));
           
           String input, concat = "";       
           while ((input = reader.readLine()) != null) {
               // remove eventual empty lines from the String Object
               if (input.trim().length() > 3) {
  -                concat += input + '\n';
  +                concat += input + "\r\n";
               }
           }       
           
  
  
  
  Index: SyncClient.java
  ===================================================================
  RCS file: 
/home/cvs/repository/uwcal_JSR168/src/java/org/jahia/suite/calendar/syncClients/SyncClient.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SyncClient.java   20 Dec 2004 14:44:24 -0000      1.11
  +++ SyncClient.java   22 Dec 2004 11:00:35 -0000      1.12
  @@ -94,6 +94,8 @@
       protected void generateSyncItemFile(File file, String content)
       throws IOException, FileNotFoundException {      
           
  +        content = new String(content.getBytes());
  +        
           // new file for a new item
           if (!file.exists()) {
               file.createNewFile();
  @@ -109,7 +111,7 @@
               currentContent = new String(currentContent.getBytes());
               
               // If the content has not changed between 2 syncs...
  -            if (currentContent.startsWith(content)) {
  +            if (currentContent.equals(content)) {
                   // ... do nothing
                   log.debug("Content has not changed for item: 
"+file.getName());
                   return;
  @@ -180,6 +182,11 @@
       public void sync(String fileName) throws FileNotFoundException, 
IOException,
       SyncException, DMException, ParserException, ValidationException {
           
  +        File dbDir = new File(DB_DIRECTORY);
  +        if (!dbDir.exists()) {
  +            dbDir.mkdir();
  +        }
  +        
           // Get the Sync Items from the iCalendar file
           String[] items = calManager.getCalendarItems(fileName);
           syncClientGUI.log("File is valid. Preparing Sync data...");
  @@ -200,15 +207,15 @@
               generateSyncItemFile(f, items[i].trim());
           }
           
  -        String[] files = dir.list();
  -        if (files == null) files = new String[0];
  +        File[] files = dir.listFiles();
  +        if (files == null) files = new File[0];
           log.debug("files.length: "+files.length + ", items.length: "+ 
items.length);
           if (files.length > items.length) {
               // There are more files in the directory than sync items
               // -> delete unecessary files <-
               for (int i=items.length; i<files.length; i++) {
  -                File f = new File(dbDirectoryName +"/"+ i);
  -                log.debug("Deleted File: "+ i);
  +                File f = files[i];
  +                log.debug("Deleted File: "+ f.getName());
                   f.delete();
               }
           }
  
  
  
  Index: DummyCalendarServer.java
  ===================================================================
  RCS file: 
/home/cvs/repository/uwcal_JSR168/src/java/org/jahia/suite/calendar/test/DummyCalendarServer.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DummyCalendarServer.java  20 Dec 2004 10:16:57 -0000      1.9
  +++ DummyCalendarServer.java  22 Dec 2004 11:00:35 -0000      1.10
  @@ -79,48 +79,48 @@
       private boolean outlook;
       
       private final String contentOutlook =
  -    "BEGIN:VEVENT\n"+
  -    "DTSTART;VALUE=DATE:20041116\n"+
  -    "DTEND;VALUE=DATE:20041116\n"+
  -    "SUMMARY:Dummy SyncItem 0 (data0)\n"+
  -    "UID:DUMMY-SYNC-ITEM-20-FOR-TESTING\n"+
  -    "DTSTAMP:20040707T140415Z\n"+
  +    "BEGIN:VEVENT\r\n"+
  +    "DTSTART;VALUE=DATE:20041116\r\n"+
  +    "DTEND;VALUE=DATE:20041116\r\n"+
  +    "SUMMARY:Dummy SyncItem 0 (data0)\r\n"+
  +    "UID:DUMMY-SYNC-ITEM-20-FOR-TESTING\r\n"+
  +    "DTSTAMP:20040707T140415Z\r\n"+
       "END:VEVENT";
       
       private final String contentIcal =
  -    "VERSION:2.0\n"+
  -    "X-WR-CALNAME:UK Holidays\n"+
  -    "PRODID:-//Apple Computer\\, Inc//iCal 1.5//EN\n"+
  -    "X-WR-RELCALID:9DE52D32-D020-11D8-9530-000A958A3252\n"+
  -    "X-WR-TIMEZONE:Europe/Paris\n"+
  -    "CALSCALE:GREGORIAN\n"+
  +    "VERSION:2.0\r\n"+
  +    "X-WR-CALNAME:UK Holidays\r\n"+
  +    "PRODID:-//Apple Computer\\, Inc//iCal 1.5//EN\r\n"+
  +    "X-WR-RELCALID:9DE52D32-D020-11D8-9530-000A958A3252\r\n"+
  +    "X-WR-TIMEZONE:Europe/Paris\r\n"+
  +    "CALSCALE:GREGORIAN\r\n"+
       "METHOD:PUBLISH";   
       
       private final String data1 =
  -    "BEGIN:VEVENT\n"+
  -    "DTSTART;VALUE=DATE:20041116\n"+
  -    "DTEND;VALUE=DATE:20041116\n"+
  -    "SUMMARY:Dummy SyncItem 1 (data1)\n"+
  -    "UID:DUMMY-SYNC-ITEM-20-FOR-TESTING\n"+
  -    "DTSTAMP:20040707T140415Z\n"+
  +    "BEGIN:VEVENT\r\n"+
  +    "DTSTART;VALUE=DATE:20041116\r\n"+
  +    "DTEND;VALUE=DATE:20041116\r\n"+
  +    "SUMMARY:Dummy SyncItem 1 (data1)\r\n"+
  +    "UID:DUMMY-SYNC-ITEM-20-FOR-TESTING\r\n"+
  +    "DTSTAMP:20040707T140415Z\r\n"+
       "END:VEVENT";
       
       private final String data2 =
  -    "BEGIN:VEVENT\n"+
  -    "DTSTART;VALUE=DATE:20041217\n"+
  -    "DTEND;VALUE=DATE:20041218\n"+
  -    "SUMMARY:Dummy SyncItem 2 (data2)\n"+
  -    "UID:DUMMY-SYNC-ITEM-30-FOR-TESTING\n"+
  -    "DTSTAMP:20040707T140415Z\n"+
  +    "BEGIN:VEVENT\r\n"+
  +    "DTSTART;VALUE=DATE:20041217\r\n"+
  +    "DTEND;VALUE=DATE:20041218\r\n"+
  +    "SUMMARY:Dummy SyncItem 2 (data2)\r\n"+
  +    "UID:DUMMY-SYNC-ITEM-30-FOR-TESTING\r\n"+
  +    "DTSTAMP:20040707T140415Z\r\n"+
       "END:VEVENT";
       
       private final String data3 =
  -    "BEGIN:VEVENT\n"+
  -    "DTSTART;VALUE=DATE:20041215\n"+
  -    "DTEND;VALUE=DATE:20041216\n"+
  -    "SUMMARY:Dummy SyncItem 3 (data3)\n"+
  -    "UID:9DE4B99A-D020-11D8-9530-000A958A3252\n"+
  -    "DTSTAMP:20040707T140415Z\n"+
  +    "BEGIN:VEVENT\r\n"+
  +    "DTSTART;VALUE=DATE:20041215\r\n"+
  +    "DTEND;VALUE=DATE:20041216\r\n"+
  +    "SUMMARY:Dummy SyncItem 3 (data3)\r\n"+
  +    "UID:9DE4B99A-D020-11D8-9530-000A958A3252\r\n"+
  +    "DTSTAMP:20040707T140415Z\r\n"+
       "END:VEVENT";
       
       /**
  @@ -278,8 +278,8 @@
               log.info("Starting server...");
               DummyCalServerGUI.setLookAndFeel();
               if (JOptionPane.showConfirmDialog(null,
  -            "Are you testing the MS-Outlook SyncSource ?\n\n" +
  -            "Note: you cannot test the MS-Outlook SyncSource and the\n" + 
  +            "Are you testing the MS-Outlook SyncSource ?\r\n\r\n" +
  +            "Note: you cannot test the MS-Outlook SyncSource and the\r\n" + 
               "iCalandar SyncSource together !", "SyncSource Selection",
               JOptionPane.YES_NO_OPTION,
               JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
  

Reply via email to