User: hr      
Date: 2007-08-03 09:52:22+0000
Modified:
   dba/reportdesign/java/com/sun/star/report/util/FileRepository.java

Log:
 INTEGRATION: CWS rpt23fix02 (1.2.4); FILE MERGED
 2007/07/24 17:19:27 tmorgner 1.2.4.1: Issue number:  #78502, #77039
 
 The formatted-text-layout controller did not look for the correct node,
 and therefore never found the expected 'office:value-type' attribute.
 This now fixes the #78502 bug, and possibly addresses the #77039 bug as
 well (although this bug might be connected to a writer-bug).
 
 Fixed the repositories so that the StorageRepository does no longer log
 exceptions whenever we test for an non-existing file. We expect the
 exception and can safely swallow it here.
 
 The FileRepository now maintains its own manifest for all files that
 are written. This class is needed for all test-runs outside of OpenOffice.

File Changes:

Directory: /dba/reportdesign/java/com/sun/star/report/util/
===========================================================

File [changed]: FileRepository.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/util/FileRepository.java?r1=1.2&r2=1.3
Delta lines:  +49 -27
---------------------
--- FileRepository.java 2007-07-09 11:56:13+0000        1.2
+++ FileRepository.java 2007-08-03 09:52:20+0000        1.3
@@ -37,12 +37,12 @@
 
 package com.sun.star.report.util;
 
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.OutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 
 import com.sun.star.report.InputRepository;
 import com.sun.star.report.OutputRepository;
@@ -50,73 +50,95 @@
 public class FileRepository implements InputRepository, OutputRepository
 {
   private File baseDirectory;
+  private ManifestWriter manifestWriter;
+  private boolean manifestDirty;
 
-  public FileRepository (final File baseDirectory)
+  public FileRepository(final File baseDirectory)
+  {
+    if (baseDirectory == null)
   {
-    if (baseDirectory == null) throw new NullPointerException();
+      throw new NullPointerException();
+    }
     this.baseDirectory = baseDirectory;
+    this.manifestWriter = new ManifestWriter();
   }
 
-  public InputStream createInputStream (String name)
+  public InputStream createInputStream(final String name)
           throws IOException
   {
-    return new FileInputStream (new File(baseDirectory, name));
+    return new FileInputStream(new File(baseDirectory, name));
   }
 
   /**
-   * Returns a unique identifier for this repository. Two repositories 
accessing the same
-   * location should return the same id. The identifier must never be null.
+   * Returns a unique identifier for this repository. Two repositories 
accessing the same location should return the
+   * same id. The identifier must never be null.
    *
    * @return the repository id
    */
-  public Object getId ()
+  public Object getId()
   {
     return baseDirectory;
   }
 
   /**
-   * This returns an version number for the given resource. Return zero, if 
the resource
-   * is not versionable, else return a unique number for each version. As rule 
of thumb:
-   * Increase the version number by at least one for each change made to the 
resource.
+   * This returns an version number for the given resource. Return zero, if 
the resource is not versionable, else return
+   * a unique number for each version. As rule of thumb: Increase the version 
number by at least one for each change
+   * made to the resource.
    *
    * @param name the name of the resource
    * @return the version number
    */
-  public long getVersion (String name)
+  public long getVersion(final String name)
   {
     return new File(baseDirectory, name).lastModified();
   }
 
   /**
-   * Creates an output stream for writing the data. If there is an entry with 
that name
-   * already contained in the repository, try to overwrite it.
+   * Creates an output stream for writing the data. If there is an entry with 
that name already contained in the
+   * repository, try to overwrite it.
    *
    * @param name
    * @return the outputstream
-   *
    * @throws java.io.IOException if opening the stream fails
    */
-  public synchronized OutputStream createOutputStream (final String name, 
final String mimeType)
+  public synchronized OutputStream createOutputStream(final String name, final 
String mimeType)
           throws IOException
   {
     final File file = new File(baseDirectory, name);
     final File parentFile = file.getParentFile();
     parentFile.mkdirs();
-    return new FileOutputStream (file);
+    manifestWriter.addEntry(name, mimeType);
+    manifestDirty = true;
+    return new FileOutputStream(file);
   }
 
-  public synchronized boolean exists (String name)
+  public synchronized boolean exists(final String name)
   {
     return new File(baseDirectory, name).exists();
   }
 
-  public boolean isWritable (String name)
+  public boolean isWritable(final String name)
   {
     return new File(baseDirectory, name).canWrite();
   }
 
-  public boolean isReadable (String name)
+  public boolean isReadable(final String name)
   {
     return new File(baseDirectory, name).canRead();
   }
+
+  public void initialize (final String contentType)
+  {
+    manifestWriter.addEntry("/", contentType);
+  }
+
+  public void close() throws IOException
+  {
+    // Write the manifest ...
+    if (manifestDirty)
+    {
+      manifestWriter.write(this);
+      manifestDirty = false;
+    }
+  }
 }




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to