jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Guggisberg" <stefan.guggisb...@gmail.com>
Subject Re: getOutputStream method of the org.apache.jackrabbit.core.fs.mem.MemoryFileSystem question
Date Mon, 25 Feb 2008 13:00:34 GMT
hi denis

On Sat, Feb 23, 2008 at 5:08 PM, Denis Linine <linine@freesurf.ch> wrote:
> Hello,
>
>  I had a look at the getOutputStream method of the
>  org.apache.jackrabbit.core.fs.mem.MemoryFileSystem class, its code is
>  presented below:
>
>  public OutputStream getOutputStream(String filePath) throws
>  FileSystemException
>  {
>         String folderPath = filePath;
>         if (filePath.lastIndexOf(FileSystem.SEPARATOR) > 0)
>         {
>             folderPath = filePath.substring(0, filePath.lastIndexOf("/"));
>         }
>         else
>         {
>             folderPath = "/";
>         }
>         assertIsFolder(folderPath);
>
>         final MemoryFile file = new MemoryFile();
>         entries.put(filePath, file);
>
>         return new FilterOutputStream(new ByteArrayOutputStream())
>         {
>             public void close() throws IOException
>             {
>                 out.close();
>                 file.setData(((ByteArrayOutputStream) out).toByteArray());
>             }
>         };
>     }
>
>  I might be wrong, but it seems that if the filePath passed points to an
>  existing folder and not to a file - the folder will be replaced with a
>  newly created file. Unfortunately, at the moment being I do not have JR
>  build environment set up to test practically whether this is really the
>  case. Might be some check whether the path passed really points to a
>  file should be added.

you're right. the implementation should check whether the specified
path points to a folder and throw an exception if that's the case.

could you please create a jira issue?

thanks!
stefan
>
>  Best regards
>  Denis Linine
>

Mime
View raw message