xlawrence    2004/12/20 15:44:25 CET

  Modified files:
    src/java/org/jahia/suite/calendar/syncClients SyncClient.java 
                                                  SyncClientFrame.java 
  Log:
  NPE bug correction
  
  Revision  Changes    Path
  1.11      +9 -11     
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.10&r2=1.11&f=h
  1.10      +1 -0      
uwcal_JSR168/src/java/org/jahia/suite/calendar/syncClients/SyncClientFrame.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/org/jahia/suite/calendar/syncClients/SyncClientFrame.java.diff?r1=1.9&r2=1.10&f=h
  
  
  
  Index: SyncClient.java
  ===================================================================
  RCS file: 
/home/cvs/repository/uwcal_JSR168/src/java/org/jahia/suite/calendar/syncClients/SyncClient.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SyncClient.java   13 Dec 2004 14:46:58 -0000      1.10
  +++ SyncClient.java   20 Dec 2004 14:44:24 -0000      1.11
  @@ -80,7 +80,6 @@
        * Creates a new instance of SyncClient
        */
       public SyncClient() {
  -        System.setProperty("file.encoding", "ISO-8859-1"); 
           syncClientGUI = new SyncClientFrame(this);
           calManager = new CalendarFileManager();
       }
  @@ -93,9 +92,7 @@
        * @throws FileNotFoundException If the file does not exist
        */
       protected void generateSyncItemFile(File file, String content)
  -    throws IOException, FileNotFoundException {
  -        
  -        final String contentUTF = new String(content.getBytes("ISO-8859-1"));
  +    throws IOException, FileNotFoundException {      
           
           // new file for a new item
           if (!file.exists()) {
  @@ -104,29 +101,29 @@
               // existing file for existing item
           } else {
               FileInputStream fin = new FileInputStream(file);
  -            InputStreamReader d = new InputStreamReader(fin, "ISO-8859-1");
  +            InputStreamReader d = new InputStreamReader(fin);
               char[] buf = new char[(int)file.length()];
               d.read(buf);
               d.close();
               String currentContent = new String(buf).trim();
  -            currentContent = new 
String(currentContent.getBytes("ISO-8859-1"));
  +            currentContent = new String(currentContent.getBytes());
               
               // If the content has not changed between 2 syncs...
  -            if (currentContent.equals(contentUTF)) {
  +            if (currentContent.startsWith(content)) {
                   // ... do nothing
                   log.debug("Content has not changed for item: 
"+file.getName());
                   return;
                   
               } else {
  -                log.debug(currentContent.length()+"-"+contentUTF.length());
  +                log.debug(currentContent.length()+"-"+content.length());
                   file.delete();
                   file.createNewFile();
               }
           }
           
           FileOutputStream fout = new FileOutputStream(file);
  -        OutputStreamWriter o = new OutputStreamWriter(fout, "ISO-8859-1");
  -        o.write(contentUTF);
  +        OutputStreamWriter o = new OutputStreamWriter(fout);
  +        o.write(content);
           o.flush();
           o.close();
       }
  @@ -160,7 +157,7 @@
                   continue;
               }
               FileInputStream fis = new FileInputStream(f);
  -            InputStreamReader d = new InputStreamReader(fis, "ISO-8859-1");
  +            InputStreamReader d = new InputStreamReader(fis);
               char[] content = new char[(int)f.length()];
               d.read(content);
               contents[i] = new String(content);
  @@ -204,6 +201,7 @@
           }
           
           String[] files = dir.list();
  +        if (files == null) files = new String[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
  
  
  
  Index: SyncClientFrame.java
  ===================================================================
  RCS file: 
/home/cvs/repository/uwcal_JSR168/src/java/org/jahia/suite/calendar/syncClients/SyncClientFrame.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SyncClientFrame.java      17 Dec 2004 15:47:00 -0000      1.9
  +++ SyncClientFrame.java      20 Dec 2004 14:44:24 -0000      1.10
  @@ -734,6 +734,7 @@
               log("\nSynchronization FAILED !");       
               
           } catch (Exception e) {
  +            e.printStackTrace();
               showError(e.getMessage());
               log("Error: "+e.getMessage());
               log("\nSynchronization FAILED !");
  

Reply via email to