You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by rg...@apache.org on 2009/04/13 06:06:06 UTC
svn commit: r764356 [8/11] - in /commons/proper/vfs/trunk: ./
core/src/main/java/org/apache/commons/vfs/
core/src/main/java/org/apache/commons/vfs/auth/
core/src/main/java/org/apache/commons/vfs/cache/
core/src/main/java/org/apache/commons/vfs/events/ ...
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpClientFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpClientFactory.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpClientFactory.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpClientFactory.java Mon Apr 13 04:06:01 2009
@@ -62,46 +62,46 @@
String key = FtpFileSystemConfigBuilder.getInstance().getEntryParser(fileSystemOptions);
if (key != null)
{
- FTPClientConfig config = new FTPClientConfig(key);
-
- String serverLanguageCode = FtpFileSystemConfigBuilder.getInstance().getServerLanguageCode(fileSystemOptions);
- if (serverLanguageCode != null)
- {
- config.setServerLanguageCode(serverLanguageCode);
- }
- String defaultDateFormat = FtpFileSystemConfigBuilder.getInstance().getDefaultDateFormat(fileSystemOptions);
- if (defaultDateFormat != null)
- {
- config.setDefaultDateFormatStr(defaultDateFormat);
- }
- String recentDateFormat = FtpFileSystemConfigBuilder.getInstance().getRecentDateFormat(fileSystemOptions);
- if (recentDateFormat != null)
- {
- config.setRecentDateFormatStr(recentDateFormat);
- }
- String serverTimeZoneId = FtpFileSystemConfigBuilder.getInstance().getServerTimeZoneId(fileSystemOptions);
- if (serverTimeZoneId != null)
- {
- config.setServerTimeZoneId(serverTimeZoneId);
- }
- String[] shortMonthNames = FtpFileSystemConfigBuilder.getInstance().getShortMonthNames(fileSystemOptions);
- if (shortMonthNames != null)
- {
- StringBuffer shortMonthNamesStr = new StringBuffer(40);
- for (int i = 0; i<shortMonthNames.length; i++)
- {
- if (shortMonthNamesStr.length()>0)
- {
- shortMonthNamesStr.append("|");
- }
- shortMonthNamesStr.append(shortMonthNames[i]);
- }
- config.setShortMonthNames(shortMonthNamesStr.toString());
- }
-
- client.configure(config);
+ FTPClientConfig config = new FTPClientConfig(key);
+
+ String serverLanguageCode = FtpFileSystemConfigBuilder.getInstance().getServerLanguageCode(fileSystemOptions);
+ if (serverLanguageCode != null)
+ {
+ config.setServerLanguageCode(serverLanguageCode);
+ }
+ String defaultDateFormat = FtpFileSystemConfigBuilder.getInstance().getDefaultDateFormat(fileSystemOptions);
+ if (defaultDateFormat != null)
+ {
+ config.setDefaultDateFormatStr(defaultDateFormat);
+ }
+ String recentDateFormat = FtpFileSystemConfigBuilder.getInstance().getRecentDateFormat(fileSystemOptions);
+ if (recentDateFormat != null)
+ {
+ config.setRecentDateFormatStr(recentDateFormat);
+ }
+ String serverTimeZoneId = FtpFileSystemConfigBuilder.getInstance().getServerTimeZoneId(fileSystemOptions);
+ if (serverTimeZoneId != null)
+ {
+ config.setServerTimeZoneId(serverTimeZoneId);
+ }
+ String[] shortMonthNames = FtpFileSystemConfigBuilder.getInstance().getShortMonthNames(fileSystemOptions);
+ if (shortMonthNames != null)
+ {
+ StringBuffer shortMonthNamesStr = new StringBuffer(40);
+ for (int i = 0; i<shortMonthNames.length; i++)
+ {
+ if (shortMonthNamesStr.length()>0)
+ {
+ shortMonthNamesStr.append("|");
+ }
+ shortMonthNamesStr.append(shortMonthNames[i]);
+ }
+ config.setShortMonthNames(shortMonthNamesStr.toString());
+ }
+
+ client.configure(config);
}
-
+
FTPFileEntryParserFactory myFactory = FtpFileSystemConfigBuilder.getInstance().getEntryParserFactory(fileSystemOptions);
if (myFactory != null)
{
@@ -120,8 +120,8 @@
// Login
if (!client.login(
- UserAuthenticatorUtils.toString(username),
- UserAuthenticatorUtils.toString(password)))
+ UserAuthenticatorUtils.toString(username),
+ UserAuthenticatorUtils.toString(password)))
{
throw new FileSystemException("vfs.provider.ftp/login.error", new Object[]{hostname, UserAuthenticatorUtils.toString(username)}, null);
}
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java Mon Apr 13 04:06:01 2009
@@ -50,65 +50,65 @@
* @version $Revision$ $Date$
*/
public class FtpFileObject
- extends AbstractFileObject
+ extends AbstractFileObject
{
- private Log log = LogFactory.getLog(FtpFileObject.class);
+ private Log log = LogFactory.getLog(FtpFileObject.class);
- private static final Map EMPTY_FTP_FILE_MAP = Collections.unmodifiableMap(new TreeMap());
+ private static final Map EMPTY_FTP_FILE_MAP = Collections.unmodifiableMap(new TreeMap());
- private final FtpFileSystem ftpFs;
- private final String relPath;
+ private final FtpFileSystem ftpFs;
+ private final String relPath;
- // Cached info
+ // Cached info
private final static FTPFile UNKNOWN = new FTPFile();
private FTPFile fileInfo;
- private Map children;
- private FileObject linkDestination;
+ private Map children;
+ private FileObject linkDestination;
- private boolean inRefresh = false;
+ private boolean inRefresh = false;
- protected FtpFileObject(final FileName name,
- final FtpFileSystem fileSystem,
- final FileName rootName)
- throws FileSystemException
- {
- super(name, fileSystem);
- ftpFs = fileSystem;
- String relPath = UriParser.decode(rootName.getRelativeName(name));
- if (".".equals(relPath))
- {
- // do not use the "." as path against the ftp-server
- // e.g. the uu.net ftp-server do a recursive listing then
- // this.relPath = UriParser.decode(rootName.getPath());
- // this.relPath = ".";
- this.relPath = null;
- }
- else
- {
- this.relPath = relPath;
- }
- }
-
- /**
- * Called by child file objects, to locate their ftp file info.
- *
- * @param name the filename in its native form ie. without uri stuff (%nn)
- * @param flush recreate children cache
- */
- private FTPFile getChildFile(final String name, final boolean flush) throws IOException
- {
- /* If we should flush cached children, clear our children map unless
- * we're in the middle of a refresh in which case we've just recently
- * refreshed our children. No need to do it again when our children are
- * refresh()ed, calling getChildFile() for themselves from within
- * getInfo(). See getChildren(). */
- if (flush && !inRefresh)
- {
- children = null;
- }
+ protected FtpFileObject(final FileName name,
+ final FtpFileSystem fileSystem,
+ final FileName rootName)
+ throws FileSystemException
+ {
+ super(name, fileSystem);
+ ftpFs = fileSystem;
+ String relPath = UriParser.decode(rootName.getRelativeName(name));
+ if (".".equals(relPath))
+ {
+ // do not use the "." as path against the ftp-server
+ // e.g. the uu.net ftp-server do a recursive listing then
+ // this.relPath = UriParser.decode(rootName.getPath());
+ // this.relPath = ".";
+ this.relPath = null;
+ }
+ else
+ {
+ this.relPath = relPath;
+ }
+ }
- // List the children of this file
- doGetChildren();
+ /**
+ * Called by child file objects, to locate their ftp file info.
+ *
+ * @param name the filename in its native form ie. without uri stuff (%nn)
+ * @param flush recreate children cache
+ */
+ private FTPFile getChildFile(final String name, final boolean flush) throws IOException
+ {
+ /* If we should flush cached children, clear our children map unless
+ * we're in the middle of a refresh in which case we've just recently
+ * refreshed our children. No need to do it again when our children are
+ * refresh()ed, calling getChildFile() for themselves from within
+ * getInfo(). See getChildren(). */
+ if (flush && !inRefresh)
+ {
+ children = null;
+ }
+
+ // List the children of this file
+ doGetChildren();
// VFS-210
if (children == null)
@@ -117,90 +117,90 @@
}
// Look for the requested child
- FTPFile ftpFile = (FTPFile) children.get(name);
- return ftpFile;
- }
-
- /**
- * Fetches the children of this file, if not already cached.
- */
- private void doGetChildren() throws IOException
- {
- if (children != null)
- {
- return;
- }
-
- final FtpClient client = ftpFs.getClient();
- try
- {
+ FTPFile ftpFile = (FTPFile) children.get(name);
+ return ftpFile;
+ }
+
+ /**
+ * Fetches the children of this file, if not already cached.
+ */
+ private void doGetChildren() throws IOException
+ {
+ if (children != null)
+ {
+ return;
+ }
+
+ final FtpClient client = ftpFs.getClient();
+ try
+ {
final String path = fileInfo != null && fileInfo.isSymbolicLink() ? getFileSystem().getFileSystemManager().resolveName(getParent().getName(), fileInfo.getLink() ).getPath() : relPath;
final FTPFile[] tmpChildren = client.listFiles(path);
- if (tmpChildren == null || tmpChildren.length == 0)
- {
- children = EMPTY_FTP_FILE_MAP;
- }
- else
- {
- children = new TreeMap();
-
- // Remove '.' and '..' elements
- for (int i = 0; i < tmpChildren.length; i++)
- {
- final FTPFile child = tmpChildren[i];
- if (child == null)
- {
- if (log.isDebugEnabled())
- {
- log.debug(Messages.getString("vfs.provider.ftp/invalid-directory-entry.debug",
- new Object[]
- {
- new Integer(i), relPath
- }));
- }
- continue;
- }
- if (!".".equals(child.getName())
- && !"..".equals(child.getName()))
- {
- children.put(child.getName(), child);
- }
- }
- }
- }
- finally
- {
- ftpFs.putClient(client);
- }
- }
-
- /**
- * Attaches this file object to its file resource.
- */
- protected void doAttach()
- throws IOException
- {
- // Get the parent folder to find the info for this file
- // VFS-210 getInfo(false);
- }
-
- /**
- * Fetches the info for this file.
- */
- private void getInfo(boolean flush) throws IOException
- {
+ if (tmpChildren == null || tmpChildren.length == 0)
+ {
+ children = EMPTY_FTP_FILE_MAP;
+ }
+ else
+ {
+ children = new TreeMap();
+
+ // Remove '.' and '..' elements
+ for (int i = 0; i < tmpChildren.length; i++)
+ {
+ final FTPFile child = tmpChildren[i];
+ if (child == null)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug(Messages.getString("vfs.provider.ftp/invalid-directory-entry.debug",
+ new Object[]
+ {
+ new Integer(i), relPath
+ }));
+ }
+ continue;
+ }
+ if (!".".equals(child.getName())
+ && !"..".equals(child.getName()))
+ {
+ children.put(child.getName(), child);
+ }
+ }
+ }
+ }
+ finally
+ {
+ ftpFs.putClient(client);
+ }
+ }
+
+ /**
+ * Attaches this file object to its file resource.
+ */
+ protected void doAttach()
+ throws IOException
+ {
+ // Get the parent folder to find the info for this file
+ // VFS-210 getInfo(false);
+ }
+
+ /**
+ * Fetches the info for this file.
+ */
+ private void getInfo(boolean flush) throws IOException
+ {
final FtpFileObject parent = (FtpFileObject) FileObjectUtils.getAbstractFileObject(getParent());
- FTPFile newFileInfo;
- if (parent != null)
- {
- newFileInfo = parent.getChildFile(UriParser.decode(getName().getBaseName()), flush);
- }
- else
- {
- // Assume the root is a directory and exists
- newFileInfo = new FTPFile();
- newFileInfo.setType(FTPFile.DIRECTORY_TYPE);
- }
+ FTPFile newFileInfo;
+ if (parent != null)
+ {
+ newFileInfo = parent.getChildFile(UriParser.decode(getName().getBaseName()), flush);
+ }
+ else
+ {
+ // Assume the root is a directory and exists
+ newFileInfo = new FTPFile();
+ newFileInfo.setType(FTPFile.DIRECTORY_TYPE);
+ }
if (newFileInfo == null)
{
@@ -212,17 +212,17 @@
}
}
- /**
- * @throws FileSystemException
- */
- public void refresh() throws FileSystemException
- {
- if (!inRefresh)
- {
- try
- {
- inRefresh = true;
- super.refresh();
+ /**
+ * @throws FileSystemException
+ */
+ public void refresh() throws FileSystemException
+ {
+ if (!inRefresh)
+ {
+ try
+ {
+ inRefresh = true;
+ super.refresh();
synchronized (getFileSystem())
{
@@ -231,86 +231,86 @@
/* VFS-210
try
- {
- // this will tell the parent to recreate its children collection
- getInfo(true);
- }
- catch (IOException e)
- {
- throw new FileSystemException(e);
- }
- */
- }
- finally
- {
- inRefresh = false;
- }
- }
- }
-
- /**
- * Detaches this file object from its file resource.
- */
- protected void doDetach()
- {
+ {
+ // this will tell the parent to recreate its children collection
+ getInfo(true);
+ }
+ catch (IOException e)
+ {
+ throw new FileSystemException(e);
+ }
+ */
+ }
+ finally
+ {
+ inRefresh = false;
+ }
+ }
+ }
+
+ /**
+ * Detaches this file object from its file resource.
+ */
+ protected void doDetach()
+ {
synchronized (getFileSystem())
{
- this.fileInfo = null;
+ this.fileInfo = null;
+ children = null;
+ }
+ }
+
+ /**
+ * Called when the children of this file change.
+ */
+ protected void onChildrenChanged(FileName child, FileType newType)
+ {
+ if (children != null && newType.equals(FileType.IMAGINARY))
+ {
+ try
+ {
+ children.remove(UriParser.decode(child.getBaseName()));
+ }
+ catch (FileSystemException e)
+ {
+ throw new RuntimeException(e.getMessage());
+ }
+ }
+ else
+ {
+ // if child was added we have to rescan the children
+ // TODO - get rid of this
children = null;
}
- }
+ }
+
+ /**
+ * Called when the type or content of this file changes.
+ */
+ protected void onChange() throws IOException
+ {
+ children = null;
- /**
- * Called when the children of this file change.
- */
- protected void onChildrenChanged(FileName child, FileType newType)
- {
- if (children != null && newType.equals(FileType.IMAGINARY))
- {
- try
- {
- children.remove(UriParser.decode(child.getBaseName()));
- }
- catch (FileSystemException e)
- {
- throw new RuntimeException(e.getMessage());
- }
- }
- else
- {
- // if child was added we have to rescan the children
- // TODO - get rid of this
- children = null;
- }
- }
-
- /**
- * Called when the type or content of this file changes.
- */
- protected void onChange() throws IOException
- {
- children = null;
-
- if (getType().equals(FileType.IMAGINARY))
- {
- // file is deleted, avoid server lookup
+ if (getType().equals(FileType.IMAGINARY))
+ {
+ // file is deleted, avoid server lookup
synchronized (getFileSystem())
{
- this.fileInfo = UNKNOWN;
+ this.fileInfo = UNKNOWN;
}
return;
- }
+ }
- getInfo(true);
- }
+ getInfo(true);
+ }
- /**
- * Determines the type of the file, returns null if the file does not
- * exist.
- */
- protected FileType doGetType()
- throws Exception
- {
+ /**
+ * Determines the type of the file, returns null if the file does not
+ * exist.
+ */
+ protected FileType doGetType()
+ throws Exception
+ {
// VFS-210
synchronized (getFileSystem())
{
@@ -338,31 +338,31 @@
}
throw new FileSystemException("vfs.provider.ftp/get-type.error", getName());
- }
+ }
- private FileObject getLinkDestination() throws FileSystemException
- {
- if (linkDestination == null)
- {
+ private FileObject getLinkDestination() throws FileSystemException
+ {
+ if (linkDestination == null)
+ {
final String path;
synchronized (getFileSystem())
{
- path = this.fileInfo.getLink();
+ path = this.fileInfo.getLink();
}
FileName relativeTo = getName().getParent();
- if (relativeTo == null)
- {
- relativeTo = getName();
- }
- FileName linkDestinationName = getFileSystem().getFileSystemManager().resolveName(relativeTo, path);
- linkDestination = getFileSystem().resolveFile(linkDestinationName);
- }
+ if (relativeTo == null)
+ {
+ relativeTo = getName();
+ }
+ FileName linkDestinationName = getFileSystem().getFileSystemManager().resolveName(relativeTo, path);
+ linkDestination = getFileSystem().resolveFile(linkDestinationName);
+ }
- return linkDestination;
- }
+ return linkDestination;
+ }
- protected FileObject[] doListChildrenResolved() throws Exception
- {
+ protected FileObject[] doListChildrenResolved() throws Exception
+ {
synchronized (getFileSystem())
{
if (this.fileInfo != null && this.fileInfo.isSymbolicLink())
@@ -372,18 +372,18 @@
}
return null;
- }
+ }
- /**
- * Returns the file's list of children.
- *
- * @return The list of children
- * @throws FileSystemException If there was a problem listing children
- * @see AbstractFileObject#getChildren()
- * @since 1.0
- */
- public FileObject[] getChildren() throws FileSystemException
- {
+ /**
+ * Returns the file's list of children.
+ *
+ * @return The list of children
+ * @throws FileSystemException If there was a problem listing children
+ * @see AbstractFileObject#getChildren()
+ * @since 1.0
+ */
+ public FileObject[] getChildren() throws FileSystemException
+ {
try
{
if (doGetType() != FileType.FOLDER)
@@ -398,31 +398,31 @@
try
- {
- /* Wrap our parent implementation, noting that we're refreshing so
- * that we don't refresh() ourselves and each of our parents for
- * each children. Note that refresh() will list children. Meaning,
- * if if this file has C children, P parents, there will be (C * P)
- * listings made with (C * (P + 1)) refreshes, when there should
- * really only be 1 listing and C refreshes. */
-
- this.inRefresh = true;
- return super.getChildren();
- }
- finally
- {
- this.inRefresh = false;
- }
- }
-
- /**
- * Lists the children of the file.
- */
- protected String[] doListChildren()
- throws Exception
- {
- // List the children of this file
- doGetChildren();
+ {
+ /* Wrap our parent implementation, noting that we're refreshing so
+ * that we don't refresh() ourselves and each of our parents for
+ * each children. Note that refresh() will list children. Meaning,
+ * if if this file has C children, P parents, there will be (C * P)
+ * listings made with (C * (P + 1)) refreshes, when there should
+ * really only be 1 listing and C refreshes. */
+
+ this.inRefresh = true;
+ return super.getChildren();
+ }
+ finally
+ {
+ this.inRefresh = false;
+ }
+ }
+
+ /**
+ * Lists the children of the file.
+ */
+ protected String[] doListChildren()
+ throws Exception
+ {
+ // List the children of this file
+ doGetChildren();
// VFS-210
if (children == null)
@@ -431,24 +431,24 @@
}
// TODO - get rid of this children stuff
- final String[] childNames = new String[children.size()];
- int childNum = -1;
- Iterator iterChildren = children.values().iterator();
- while (iterChildren.hasNext())
- {
- childNum++;
- final FTPFile child = (FTPFile) iterChildren.next();
- childNames[childNum] = child.getName();
- }
-
- return UriParser.encode(childNames);
- }
-
- /**
- * Deletes the file.
- */
- protected void doDelete() throws Exception
- {
+ final String[] childNames = new String[children.size()];
+ int childNum = -1;
+ Iterator iterChildren = children.values().iterator();
+ while (iterChildren.hasNext())
+ {
+ childNum++;
+ final FTPFile child = (FTPFile) iterChildren.next();
+ childNames[childNum] = child.getName();
+ }
+
+ return UriParser.encode(childNames);
+ }
+
+ /**
+ * Deletes the file.
+ */
+ protected void doDelete() throws Exception
+ {
synchronized (getFileSystem())
{
final boolean ok;
@@ -478,11 +478,11 @@
}
}
- /**
- * Renames the file
- */
- protected void doRename(FileObject newfile) throws Exception
- {
+ /**
+ * Renames the file
+ */
+ protected void doRename(FileObject newfile) throws Exception
+ {
synchronized (getFileSystem())
{
final boolean ok;
@@ -507,34 +507,34 @@
}
}
- /**
- * Creates this file as a folder.
- */
- protected void doCreateFolder()
- throws Exception
- {
- final boolean ok;
- final FtpClient client = ftpFs.getClient();
- try
- {
- ok = client.makeDirectory(relPath);
- }
- finally
- {
- ftpFs.putClient(client);
- }
-
- if (!ok)
- {
- throw new FileSystemException("vfs.provider.ftp/create-folder.error", getName());
- }
- }
-
- /**
- * Returns the size of the file content (in bytes).
- */
- protected long doGetContentSize() throws Exception
- {
+ /**
+ * Creates this file as a folder.
+ */
+ protected void doCreateFolder()
+ throws Exception
+ {
+ final boolean ok;
+ final FtpClient client = ftpFs.getClient();
+ try
+ {
+ ok = client.makeDirectory(relPath);
+ }
+ finally
+ {
+ ftpFs.putClient(client);
+ }
+
+ if (!ok)
+ {
+ throw new FileSystemException("vfs.provider.ftp/create-folder.error", getName());
+ }
+ }
+
+ /**
+ * Returns the size of the file content (in bytes).
+ */
+ protected long doGetContentSize() throws Exception
+ {
synchronized (getFileSystem())
{
if (this.fileInfo.isSymbolicLink())
@@ -548,13 +548,13 @@
}
}
- /**
- * get the last modified time on an ftp file
- *
- * @see org.apache.commons.vfs.provider.AbstractFileObject#doGetLastModifiedTime()
- */
- protected long doGetLastModifiedTime() throws Exception
- {
+ /**
+ * get the last modified time on an ftp file
+ *
+ * @see org.apache.commons.vfs.provider.AbstractFileObject#doGetLastModifiedTime()
+ */
+ protected long doGetLastModifiedTime() throws Exception
+ {
synchronized (getFileSystem())
{
if (this.fileInfo.isSymbolicLink())
@@ -576,150 +576,150 @@
}
}
- /**
- * Creates an input stream to read the file content from.
- */
- protected InputStream doGetInputStream() throws Exception
- {
- final FtpClient client = ftpFs.getClient();
- final InputStream instr = client.retrieveFileStream(relPath);
+ /**
+ * Creates an input stream to read the file content from.
+ */
+ protected InputStream doGetInputStream() throws Exception
+ {
+ final FtpClient client = ftpFs.getClient();
+ final InputStream instr = client.retrieveFileStream(relPath);
// VFS-210
if (instr == null)
{
throw new FileNotFoundException(getName().toString());
}
return new FtpInputStream(client, instr);
- }
+ }
- protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception
- {
- return new FtpRandomAccessContent(this, mode);
- }
-
- /**
- * Creates an output stream to write the file content to.
- */
- protected OutputStream doGetOutputStream(boolean bAppend)
- throws Exception
- {
- final FtpClient client = ftpFs.getClient();
- OutputStream out = null;
- if (bAppend)
- {
- out = client.appendFileStream(relPath);
- }
- else
- {
- out = client.storeFileStream(relPath);
- }
-
- if (out == null)
- {
- throw new FileSystemException("vfs.provider.ftp/output-error.debug", new Object[]
- {
- this.getName(),
- client.getReplyString()
- });
- }
-
- return new FtpOutputStream(client, out);
- }
-
- String getRelPath()
- {
- return relPath;
- }
-
- FtpInputStream getInputStream(long filePointer) throws IOException
- {
- final FtpClient client = ftpFs.getClient();
- final InputStream instr = client.retrieveFileStream(relPath, filePointer);
- if (instr == null)
- {
- throw new FileSystemException("vfs.provider.ftp/input-error.debug", new Object[]
- {
- this.getName(),
- client.getReplyString()
- });
- }
- return new FtpInputStream(client, instr);
- }
-
- /**
- * An InputStream that monitors for end-of-file.
- */
- class FtpInputStream
- extends MonitorInputStream
- {
- private final FtpClient client;
-
- public FtpInputStream(final FtpClient client, final InputStream in)
- {
- super(in);
- this.client = client;
- }
-
- void abort() throws IOException
- {
- client.abort();
- close();
- }
-
- /**
- * Called after the stream has been closed.
- */
- protected void onClose() throws IOException
- {
- final boolean ok;
- try
- {
- ok = client.completePendingCommand();
- }
- finally
- {
- ftpFs.putClient(client);
- }
-
- if (!ok)
- {
- throw new FileSystemException("vfs.provider.ftp/finish-get.error", getName());
- }
- }
- }
-
- /**
- * An OutputStream that monitors for end-of-file.
- */
- private class FtpOutputStream
- extends MonitorOutputStream
- {
- private final FtpClient client;
-
- public FtpOutputStream(final FtpClient client, final OutputStream outstr)
- {
- super(outstr);
- this.client = client;
- }
-
- /**
- * Called after this stream is closed.
- */
- protected void onClose() throws IOException
- {
- final boolean ok;
- try
- {
- ok = client.completePendingCommand();
- }
- finally
- {
- ftpFs.putClient(client);
- }
-
- if (!ok)
- {
- throw new FileSystemException("vfs.provider.ftp/finish-put.error", getName());
- }
- }
- }
+ protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception
+ {
+ return new FtpRandomAccessContent(this, mode);
+ }
+
+ /**
+ * Creates an output stream to write the file content to.
+ */
+ protected OutputStream doGetOutputStream(boolean bAppend)
+ throws Exception
+ {
+ final FtpClient client = ftpFs.getClient();
+ OutputStream out = null;
+ if (bAppend)
+ {
+ out = client.appendFileStream(relPath);
+ }
+ else
+ {
+ out = client.storeFileStream(relPath);
+ }
+
+ if (out == null)
+ {
+ throw new FileSystemException("vfs.provider.ftp/output-error.debug", new Object[]
+ {
+ this.getName(),
+ client.getReplyString()
+ });
+ }
+
+ return new FtpOutputStream(client, out);
+ }
+
+ String getRelPath()
+ {
+ return relPath;
+ }
+
+ FtpInputStream getInputStream(long filePointer) throws IOException
+ {
+ final FtpClient client = ftpFs.getClient();
+ final InputStream instr = client.retrieveFileStream(relPath, filePointer);
+ if (instr == null)
+ {
+ throw new FileSystemException("vfs.provider.ftp/input-error.debug", new Object[]
+ {
+ this.getName(),
+ client.getReplyString()
+ });
+ }
+ return new FtpInputStream(client, instr);
+ }
+
+ /**
+ * An InputStream that monitors for end-of-file.
+ */
+ class FtpInputStream
+ extends MonitorInputStream
+ {
+ private final FtpClient client;
+
+ public FtpInputStream(final FtpClient client, final InputStream in)
+ {
+ super(in);
+ this.client = client;
+ }
+
+ void abort() throws IOException
+ {
+ client.abort();
+ close();
+ }
+
+ /**
+ * Called after the stream has been closed.
+ */
+ protected void onClose() throws IOException
+ {
+ final boolean ok;
+ try
+ {
+ ok = client.completePendingCommand();
+ }
+ finally
+ {
+ ftpFs.putClient(client);
+ }
+
+ if (!ok)
+ {
+ throw new FileSystemException("vfs.provider.ftp/finish-get.error", getName());
+ }
+ }
+ }
+
+ /**
+ * An OutputStream that monitors for end-of-file.
+ */
+ private class FtpOutputStream
+ extends MonitorOutputStream
+ {
+ private final FtpClient client;
+
+ public FtpOutputStream(final FtpClient client, final OutputStream outstr)
+ {
+ super(outstr);
+ this.client = client;
+ }
+
+ /**
+ * Called after this stream is closed.
+ */
+ protected void onClose() throws IOException
+ {
+ final boolean ok;
+ try
+ {
+ ok = client.completePendingCommand();
+ }
+ finally
+ {
+ ftpFs.putClient(client);
+ }
+
+ if (!ok)
+ {
+ throw new FileSystemException("vfs.provider.ftp/finish-put.error", getName());
+ }
+ }
+ }
}
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileProvider.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileProvider.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileProvider.java Mon Apr 13 04:06:01 2009
@@ -56,12 +56,12 @@
Capability.RANDOM_ACCESS_READ,
}));
- public final static UserAuthenticationData.Type[] AUTHENTICATOR_TYPES = new UserAuthenticationData.Type[]
- {
- UserAuthenticationData.USERNAME, UserAuthenticationData.PASSWORD
- };
+ public final static UserAuthenticationData.Type[] AUTHENTICATOR_TYPES = new UserAuthenticationData.Type[]
+ {
+ UserAuthenticationData.USERNAME, UserAuthenticationData.PASSWORD
+ };
- public FtpFileProvider()
+ public FtpFileProvider()
{
super();
setFileNameParser(FtpFileNameParser.getInstance());
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystem.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystem.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystem.java Mon Apr 13 04:06:01 2009
@@ -104,9 +104,9 @@
{
if (idleClient == null || !idleClient.isConnected())
{
- idleClient = null;
+ idleClient = null;
- FtpClient ftpClient = new FTPClientWrapper((GenericFileName) getRoot().getName(), getFileSystemOptions());
+ FtpClient ftpClient = new FTPClientWrapper((GenericFileName) getRoot().getName(), getFileSystemOptions());
return ftpClient;
/*
final GenericFileName rootName = (GenericFileName) getRoot().getName();
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java Mon Apr 13 04:06:01 2009
@@ -242,13 +242,13 @@
*/
public void setShortMonthNames(FileSystemOptions opts, String[] shortMonthNames)
{
- String[] clone = null;
- if (shortMonthNames != null)
- {
- clone = new String[shortMonthNames.length];
- System.arraycopy(shortMonthNames, 0, clone, 0, shortMonthNames.length);
- }
-
+ String[] clone = null;
+ if (shortMonthNames != null)
+ {
+ clone = new String[shortMonthNames.length];
+ System.arraycopy(shortMonthNames, 0, clone, 0, shortMonthNames.length);
+ }
+
setParam(opts, SHORT_MONTH_NAMES, clone);
}
}
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpRandomAccessContent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpRandomAccessContent.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpRandomAccessContent.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpRandomAccessContent.java Mon Apr 13 04:06:01 2009
@@ -69,8 +69,8 @@
filePointer = pos;
}
- protected DataInputStream getDataInputStream() throws IOException
- {
+ protected DataInputStream getDataInputStream() throws IOException
+ {
if (dis != null)
{
return dis;
@@ -116,8 +116,8 @@
}
});
- return dis;
- }
+ return dis;
+ }
public void close() throws IOException
Added: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/gzip/package.html
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/gzip/package.html?rev=764356&view=auto
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/gzip/package.html (added)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/gzip/package.html Mon Apr 13 04:06:01 2009
@@ -0,0 +1,19 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<body>
+<p>The GZIP File Provider</p>
+</body>
\ No newline at end of file
Propchange: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/gzip/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/gzip/package.html
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/gzip/package.html
------------------------------------------------------------------------------
svn:mime-type = text/html
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpClientFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpClientFactory.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpClientFactory.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpClientFactory.java Mon Apr 13 04:06:01 2009
@@ -65,9 +65,9 @@
HttpConnectionManagerParams connectionMgrParams = mgr.getParams();
client = new HttpClient(mgr);
- //client = new HttpClient(new ThreadLocalHttpConnectionManager());
+ //client = new HttpClient(new ThreadLocalHttpConnectionManager());
- final HostConfiguration config = new HostConfiguration();
+ final HostConfiguration config = new HostConfiguration();
config.setHost(hostname, port, scheme);
connectionMgrParams.setMaxConnectionsPerHost(config, builder.getMaxConnectionsPerHost(fileSystemOptions));
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileContentInfoFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileContentInfoFactory.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileContentInfoFactory.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileContentInfoFactory.java Mon Apr 13 04:06:01 2009
@@ -27,7 +27,7 @@
/**
* Description
- *
+ *
* @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
* @version $Revision$ $Date$
*/
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileProvider.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileProvider.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileProvider.java Mon Apr 13 04:06:01 2009
@@ -53,12 +53,12 @@
Capability.DIRECTORY_READ_CONTENT,
}));
- public final static UserAuthenticationData.Type[] AUTHENTICATOR_TYPES = new UserAuthenticationData.Type[]
- {
- UserAuthenticationData.USERNAME, UserAuthenticationData.PASSWORD
- };
+ public final static UserAuthenticationData.Type[] AUTHENTICATOR_TYPES = new UserAuthenticationData.Type[]
+ {
+ UserAuthenticationData.USERNAME, UserAuthenticationData.PASSWORD
+ };
- public HttpFileProvider()
+ public HttpFileProvider()
{
super();
setFileNameParser(HttpFileNameParser.getInstance());
@@ -73,26 +73,26 @@
// Create the file system
final GenericFileName rootName = (GenericFileName) name;
- UserAuthenticationData authData = null;
- HttpClient httpClient;
- try
- {
- authData = UserAuthenticatorUtils.authenticate(fileSystemOptions, AUTHENTICATOR_TYPES);
+ UserAuthenticationData authData = null;
+ HttpClient httpClient;
+ try
+ {
+ authData = UserAuthenticatorUtils.authenticate(fileSystemOptions, AUTHENTICATOR_TYPES);
- httpClient = HttpClientFactory.createConnection(
+ httpClient = HttpClientFactory.createConnection(
rootName.getScheme(),
rootName.getHostName(),
- rootName.getPort(),
- UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData, UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(rootName.getUserName()))),
- UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(rootName.getPassword()))),
- fileSystemOptions);
- }
- finally
- {
- UserAuthenticatorUtils.cleanup(authData);
- }
+ rootName.getPort(),
+ UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData, UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(rootName.getUserName()))),
+ UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(rootName.getPassword()))),
+ fileSystemOptions);
+ }
+ finally
+ {
+ UserAuthenticatorUtils.cleanup(authData);
+ }
- return new HttpFileSystem(rootName, httpClient, fileSystemOptions);
+ return new HttpFileSystem(rootName, httpClient, fileSystemOptions);
}
public FileSystemConfigBuilder getConfigBuilder()
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystem.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystem.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystem.java Mon Apr 13 04:06:01 2009
@@ -59,23 +59,23 @@
return client;
}
- public void closeCommunicationLink()
- {
- if (getClient() != null)
- {
- HttpConnectionManager mgr = getClient().getHttpConnectionManager();
- if (mgr instanceof ThreadLocalHttpConnectionManager)
- {
- ((ThreadLocalHttpConnectionManager) mgr).releaseLocalConnection();
- }
+ public void closeCommunicationLink()
+ {
+ if (getClient() != null)
+ {
+ HttpConnectionManager mgr = getClient().getHttpConnectionManager();
+ if (mgr instanceof ThreadLocalHttpConnectionManager)
+ {
+ ((ThreadLocalHttpConnectionManager) mgr).releaseLocalConnection();
+ }
if (mgr instanceof MultiThreadedHttpConnectionManager)
{
((MultiThreadedHttpConnectionManager) mgr).shutdown();
}
}
- }
+ }
- /**
+ /**
* Creates a file object. This method is called only if the requested
* file is not cached.
*/
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystemConfigBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystemConfigBuilder.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystemConfigBuilder.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystemConfigBuilder.java Mon Apr 13 04:06:01 2009
@@ -24,7 +24,7 @@
/**
* Configuration options for HTTP
- *
+ *
* @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
* @version $Revision$ $Date$
*/
@@ -186,7 +186,7 @@
{
return getInteger(opts, HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, DEFAULT_MAX_HOST_CONNECTIONS);
}
-
+
protected Class getConfigClass()
{
return HttpFileSystem.class;
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpRandomAccesContent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpRandomAccesContent.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpRandomAccesContent.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/HttpRandomAccesContent.java Mon Apr 13 04:06:01 2009
@@ -73,8 +73,8 @@
filePointer = pos;
}
- protected DataInputStream getDataInputStream() throws IOException
- {
+ protected DataInputStream getDataInputStream() throws IOException
+ {
if (dis != null)
{
return dis;
@@ -132,8 +132,8 @@
}
});
- return dis;
- }
+ return dis;
+ }
public void close() throws IOException
Added: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/package.html
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/package.html?rev=764356&view=auto
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/package.html (added)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/package.html Mon Apr 13 04:06:01 2009
@@ -0,0 +1,19 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<body>
+<p>The HTTP File Provider</p>
+</body>
\ No newline at end of file
Propchange: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/package.html
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/http/package.html
------------------------------------------------------------------------------
svn:mime-type = text/html
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/https/HttpsFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/https/HttpsFileProvider.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/https/HttpsFileProvider.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/https/HttpsFileProvider.java Mon Apr 13 04:06:01 2009
@@ -27,7 +27,7 @@
public class HttpsFileProvider
extends HttpFileProvider
{
- public HttpsFileProvider()
+ public HttpsFileProvider()
{
super();
setFileNameParser(HttpsFileNameParser.getInstance());
Added: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/https/package.html
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/https/package.html?rev=764356&view=auto
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/https/package.html (added)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/https/package.html Mon Apr 13 04:06:01 2009
@@ -0,0 +1,19 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<body>
+<p>The HTTPS File Provider</p>
+</body>
\ No newline at end of file
Propchange: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/https/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/https/package.html
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/https/package.html
------------------------------------------------------------------------------
svn:mime-type = text/html
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/jar/JarURLConnectionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/jar/JarURLConnectionImpl.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/jar/JarURLConnectionImpl.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/jar/JarURLConnectionImpl.java Mon Apr 13 04:06:01 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/local/GenericFileNameParser.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/local/GenericFileNameParser.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/local/GenericFileNameParser.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/local/GenericFileNameParser.java Mon Apr 13 04:06:01 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFile.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFile.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFile.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFile.java Mon Apr 13 04:06:01 2009
@@ -89,7 +89,7 @@
protected FileType doGetType()
throws Exception
{
- // JDK BUG: 6192331
+ // JDK BUG: 6192331
// if (!file.exists())
if (!file.exists() && file.length() < 1)
{
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileNameParser.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileNameParser.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileNameParser.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileNameParser.java Mon Apr 13 04:06:01 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -73,7 +73,7 @@
UriParser.canonicalizePath(name, 0, name.length(), this);
UriParser.fixSeparators(name);
-
+
// Extract the root prefix
final String rootFile = extractRootPrefix(filename, name);
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileRandomAccessContent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileRandomAccessContent.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileRandomAccessContent.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileRandomAccessContent.java Mon Apr 13 04:06:01 2009
@@ -81,17 +81,17 @@
return raf.read(b, off, len);
}
- public int available() throws IOException
- {
- long available = raf.length() - raf.getFilePointer();
- if (available > Integer.MAX_VALUE)
- {
- return Integer.MAX_VALUE;
- }
-
- return (int) available;
- }
- };
+ public int available() throws IOException
+ {
+ long available = raf.length() - raf.getFilePointer();
+ if (available > Integer.MAX_VALUE)
+ {
+ return Integer.MAX_VALUE;
+ }
+
+ return (int) available;
+ }
+ };
}
catch (FileNotFoundException e)
{
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java Mon Apr 13 04:06:01 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -114,7 +114,7 @@
String prefix = name.substring(0, 2);
name.delete(0, 2);
-
+
return prefix.intern();
}
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileData.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileData.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileData.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileData.java Mon Apr 13 04:06:01 2009
@@ -30,243 +30,243 @@
*/
class RamFileData implements Serializable
{
- /**
- * File Name
- */
- private FileName name;
-
- /**
- * File Type
- */
- private FileType type;
-
- /**
- * Bytes
- */
- private byte[] buffer;
-
- /**
- * Last modified time
- */
- private long lastModified;
-
- /**
- * Children
- */
- private Collection children;
-
- /**
- * Constructor
- */
- public RamFileData(FileName name)
- {
- super();
- this.clear();
- if (name == null)
- {
- throw new IllegalArgumentException("name can not be null");
- }
- this.name = name;
- }
-
- /**
- * @return Returns the buffer.
- */
- byte[] getBuffer()
- {
- return buffer;
- }
-
- /**
- * @param buffer
- */
- void setBuffer(byte[] buffer)
- {
- updateLastModified();
- this.buffer = buffer;
- }
-
- /**
- * @return Returns the lastModified.
- */
- long getLastModified()
- {
- return lastModified;
- }
-
- /**
- * @param lastModified
- * The lastModified to set.
- */
- void setLastModified(long lastModified)
- {
- this.lastModified = lastModified;
- }
-
- /**
- * @return Returns the type.
- */
- FileType getType()
- {
- return type;
- }
-
- /**
- * @param type
- * The type to set.
- */
- void setType(FileType type)
- {
- this.type = type;
- }
-
- /**
- *
- */
- void clear()
- {
- this.buffer = new byte[0];
- updateLastModified();
- this.type = FileType.IMAGINARY;
- this.children = Collections.synchronizedCollection(new ArrayList());
- this.name = null;
- }
-
- void updateLastModified()
- {
- this.lastModified = System.currentTimeMillis();
- }
-
- /**
- * @return Returns the name.
- */
- FileName getName()
- {
- return name;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- public String toString()
- {
- return this.name.toString();
- }
-
- /**
- * Add a child
- *
- * @param data
- */
- void addChild(RamFileData data) throws FileSystemException
- {
- if (!this.getType().hasChildren())
- {
- throw new FileSystemException(
- "A child can only be added in a folder");
- }
-
- if (data == null)
- {
- throw new FileSystemException("No child can be null");
- }
-
- if (this.children.contains(data))
- {
- throw new FileSystemException("Child already exists. " + data);
- }
-
- this.children.add(data);
- updateLastModified();
- }
-
- /**
- * Remove a child
- *
- * @param data
- * @throws FileSystemException
- */
- void removeChild(RamFileData data) throws FileSystemException
- {
- if (!this.getType().hasChildren())
- {
- throw new FileSystemException(
- "A child can only be removed from a folder");
- }
- if (!this.children.contains(data))
- {
- throw new FileSystemException("Child not found. " + data);
- }
- this.children.remove(data);
- updateLastModified();
- }
-
- /**
- * @return Returns the children.
- */
- Collection getChildren()
- {
- if (name == null)
- {
- throw new IllegalStateException("Data is clear");
- }
- return children;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object o)
- {
- if (this == o) {
- return true;
- }
- if (!(o instanceof RamFileData)){
- return false;
- }
- RamFileData data = (RamFileData) o;
- return this.getName().equals(data.getName());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- public int hashCode()
- {
- return this.getName().hashCode();
- }
-
- boolean hasChildren(RamFileData data)
- {
- return this.children.contains(data);
- }
-
- /**
- * @return Returns the size of the buffer
- */
- int size()
- {
- return buffer.length;
- }
-
- /**
- * Resize the buffer
- *
- * @param newSize
- */
- void resize(int newSize)
- {
- int size = this.size();
- byte[] newBuf = new byte[newSize];
- System.arraycopy(this.buffer, 0, newBuf, 0, size);
- this.buffer = newBuf;
- updateLastModified();
- }
+ /**
+ * File Name
+ */
+ private FileName name;
+
+ /**
+ * File Type
+ */
+ private FileType type;
+
+ /**
+ * Bytes
+ */
+ private byte[] buffer;
+
+ /**
+ * Last modified time
+ */
+ private long lastModified;
+
+ /**
+ * Children
+ */
+ private Collection children;
+
+ /**
+ * Constructor
+ */
+ public RamFileData(FileName name)
+ {
+ super();
+ this.clear();
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name can not be null");
+ }
+ this.name = name;
+ }
+
+ /**
+ * @return Returns the buffer.
+ */
+ byte[] getBuffer()
+ {
+ return buffer;
+ }
+
+ /**
+ * @param buffer
+ */
+ void setBuffer(byte[] buffer)
+ {
+ updateLastModified();
+ this.buffer = buffer;
+ }
+
+ /**
+ * @return Returns the lastModified.
+ */
+ long getLastModified()
+ {
+ return lastModified;
+ }
+
+ /**
+ * @param lastModified
+ * The lastModified to set.
+ */
+ void setLastModified(long lastModified)
+ {
+ this.lastModified = lastModified;
+ }
+
+ /**
+ * @return Returns the type.
+ */
+ FileType getType()
+ {
+ return type;
+ }
+
+ /**
+ * @param type
+ * The type to set.
+ */
+ void setType(FileType type)
+ {
+ this.type = type;
+ }
+
+ /**
+ *
+ */
+ void clear()
+ {
+ this.buffer = new byte[0];
+ updateLastModified();
+ this.type = FileType.IMAGINARY;
+ this.children = Collections.synchronizedCollection(new ArrayList());
+ this.name = null;
+ }
+
+ void updateLastModified()
+ {
+ this.lastModified = System.currentTimeMillis();
+ }
+
+ /**
+ * @return Returns the name.
+ */
+ FileName getName()
+ {
+ return name;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ public String toString()
+ {
+ return this.name.toString();
+ }
+
+ /**
+ * Add a child
+ *
+ * @param data
+ */
+ void addChild(RamFileData data) throws FileSystemException
+ {
+ if (!this.getType().hasChildren())
+ {
+ throw new FileSystemException(
+ "A child can only be added in a folder");
+ }
+
+ if (data == null)
+ {
+ throw new FileSystemException("No child can be null");
+ }
+
+ if (this.children.contains(data))
+ {
+ throw new FileSystemException("Child already exists. " + data);
+ }
+
+ this.children.add(data);
+ updateLastModified();
+ }
+
+ /**
+ * Remove a child
+ *
+ * @param data
+ * @throws FileSystemException
+ */
+ void removeChild(RamFileData data) throws FileSystemException
+ {
+ if (!this.getType().hasChildren())
+ {
+ throw new FileSystemException(
+ "A child can only be removed from a folder");
+ }
+ if (!this.children.contains(data))
+ {
+ throw new FileSystemException("Child not found. " + data);
+ }
+ this.children.remove(data);
+ updateLastModified();
+ }
+
+ /**
+ * @return Returns the children.
+ */
+ Collection getChildren()
+ {
+ if (name == null)
+ {
+ throw new IllegalStateException("Data is clear");
+ }
+ return children;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object o)
+ {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof RamFileData)){
+ return false;
+ }
+ RamFileData data = (RamFileData) o;
+ return this.getName().equals(data.getName());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode()
+ {
+ return this.getName().hashCode();
+ }
+
+ boolean hasChildren(RamFileData data)
+ {
+ return this.children.contains(data);
+ }
+
+ /**
+ * @return Returns the size of the buffer
+ */
+ int size()
+ {
+ return buffer.length;
+ }
+
+ /**
+ * Resize the buffer
+ *
+ * @param newSize
+ */
+ void resize(int newSize)
+ {
+ int size = this.size();
+ byte[] newBuf = new byte[newSize];
+ System.arraycopy(this.buffer, 0, newBuf, 0, size);
+ this.buffer = newBuf;
+ updateLastModified();
+ }
}
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileObject.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileObject.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileObject.java Mon Apr 13 04:06:01 2009
@@ -35,69 +35,69 @@
*/
public class RamFileObject extends AbstractFileObject implements FileObject
{
- /**
- * File System
- */
- RamFileSystem fs;
-
- /**
- * RAM File Object Data
- */
- private RamFileData data;
-
- private void save() throws FileSystemException
- {
- this.fs.save(this);
- }
-
- /**
- * @param name
- * @param fs
- */
- protected RamFileObject(FileName name, RamFileSystem fs)
- {
- super(name, fs);
- this.fs = fs;
- this.fs.attach(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.commons.vfs.provider.AbstractFileObject#doGetType()
- */
- protected FileType doGetType() throws Exception
- {
- return data.getType();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.commons.vfs.provider.AbstractFileObject#doListChildren()
- */
- protected String[] doListChildren() throws Exception
- {
- return this.fs.listChildren(this.getName());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.commons.vfs.provider.AbstractFileObject#doGetContentSize()
- */
- protected long doGetContentSize() throws Exception
- {
- return this.data.getBuffer().length;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.commons.vfs.provider.AbstractFileObject#doGetInputStream()
- */
- protected InputStream doGetInputStream() throws Exception
- {
+ /**
+ * File System
+ */
+ RamFileSystem fs;
+
+ /**
+ * RAM File Object Data
+ */
+ private RamFileData data;
+
+ private void save() throws FileSystemException
+ {
+ this.fs.save(this);
+ }
+
+ /**
+ * @param name
+ * @param fs
+ */
+ protected RamFileObject(FileName name, RamFileSystem fs)
+ {
+ super(name, fs);
+ this.fs = fs;
+ this.fs.attach(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.commons.vfs.provider.AbstractFileObject#doGetType()
+ */
+ protected FileType doGetType() throws Exception
+ {
+ return data.getType();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.commons.vfs.provider.AbstractFileObject#doListChildren()
+ */
+ protected String[] doListChildren() throws Exception
+ {
+ return this.fs.listChildren(this.getName());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.commons.vfs.provider.AbstractFileObject#doGetContentSize()
+ */
+ protected long doGetContentSize() throws Exception
+ {
+ return this.data.getBuffer().length;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.commons.vfs.provider.AbstractFileObject#doGetInputStream()
+ */
+ protected InputStream doGetInputStream() throws Exception
+ {
// VFS-210: ram allows to gather an input stream even from a directory. So we need to check the type anyway.
if (!getType().hasContent())
{
@@ -105,164 +105,164 @@
}
return new ByteArrayInputStream(this.data.getBuffer());
- }
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.apache.commons.vfs.provider.AbstractFileObject#doGetOutputStream(boolean)
- */
- protected OutputStream doGetOutputStream(boolean bAppend) throws Exception
- {
- if (!bAppend)
- {
- this.data.setBuffer(new byte[0]);
- }
- return new RamFileOutputStream(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.commons.vfs.provider.AbstractFileObject#doDelete()
- */
- protected void doDelete() throws Exception
- {
- fs.delete(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.commons.vfs.provider.AbstractFileObject#doGetLastModifiedTime()
- */
- protected long doGetLastModifiedTime() throws Exception
- {
- return data.getLastModified();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.commons.vfs.provider.AbstractFileObject#doSetLastModifiedTime(long)
- */
- protected boolean doSetLastModTime(long modtime) throws Exception
- {
- data.setLastModified(modtime);
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.commons.vfs.provider.AbstractFileObject#doCreateFolder()
- */
- protected void doCreateFolder() throws Exception
- {
- this.injectType(FileType.FOLDER);
- this.save();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.commons.vfs.provider.AbstractFileObject#doRename(org.apache.commons.vfs.FileObject)
- */
- protected void doRename(FileObject newfile) throws Exception
- {
- fs.rename(this, (RamFileObject) newfile);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.commons.vfs.provider.AbstractFileObject#doGetRandomAccessContent(org.apache.commons.vfs.util.RandomAccessMode)
- */
- protected RandomAccessContent doGetRandomAccessContent(RandomAccessMode mode)
- throws Exception
- {
- return new RamFileRandomAccessContent(this, mode);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.commons.vfs.provider.AbstractFileObject#doAttach()
- */
- protected void doAttach() throws Exception
- {
- this.fs.attach(this);
- }
-
- /**
- * @return Returns the data.
- */
- RamFileData getData()
- {
- return data;
- }
-
- /**
- * @param data
- * The data to set.
- */
- void setData(RamFileData data)
- {
- this.data = data;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.commons.vfs.provider.AbstractFileObject#injectType(org.apache.commons.vfs.FileType)
- */
- protected void injectType(FileType fileType)
- {
- this.data.setType(fileType);
- super.injectType(fileType);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.commons.vfs.provider.AbstractFileObject#endOutput()
- */
- protected void endOutput() throws Exception
- {
- super.endOutput();
- this.save();
- }
-
- /**
- * @return Returns the size of the RAMFileData
- */
- int size()
- {
- if (data == null)
- {
- return 0;
- }
- return data.size();
- }
-
- /**
- * @param newSize
- * @throws IOException
- * if the new size exceeds the limit
- */
- synchronized void resize(int newSize) throws IOException
- {
- if (fs.getFileSystemOptions() != null)
- {
- int maxSize = RamFileSystemConfigBuilder.getInstance().getMaxSize(
- fs.getFileSystemOptions());
- if (fs.size() + newSize - this.size() > maxSize)
- {
- throw new IOException("FileSystem capacity (" + maxSize
- + ") exceeded.");
- }
- }
- this.data.resize(newSize);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.commons.vfs.provider.AbstractFileObject#doGetOutputStream(boolean)
+ */
+ protected OutputStream doGetOutputStream(boolean bAppend) throws Exception
+ {
+ if (!bAppend)
+ {
+ this.data.setBuffer(new byte[0]);
+ }
+ return new RamFileOutputStream(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.commons.vfs.provider.AbstractFileObject#doDelete()
+ */
+ protected void doDelete() throws Exception
+ {
+ fs.delete(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.commons.vfs.provider.AbstractFileObject#doGetLastModifiedTime()
+ */
+ protected long doGetLastModifiedTime() throws Exception
+ {
+ return data.getLastModified();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.commons.vfs.provider.AbstractFileObject#doSetLastModifiedTime(long)
+ */
+ protected boolean doSetLastModTime(long modtime) throws Exception
+ {
+ data.setLastModified(modtime);
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.commons.vfs.provider.AbstractFileObject#doCreateFolder()
+ */
+ protected void doCreateFolder() throws Exception
+ {
+ this.injectType(FileType.FOLDER);
+ this.save();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.commons.vfs.provider.AbstractFileObject#doRename(org.apache.commons.vfs.FileObject)
+ */
+ protected void doRename(FileObject newfile) throws Exception
+ {
+ fs.rename(this, (RamFileObject) newfile);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.commons.vfs.provider.AbstractFileObject#doGetRandomAccessContent(org.apache.commons.vfs.util.RandomAccessMode)
+ */
+ protected RandomAccessContent doGetRandomAccessContent(RandomAccessMode mode)
+ throws Exception
+ {
+ return new RamFileRandomAccessContent(this, mode);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.commons.vfs.provider.AbstractFileObject#doAttach()
+ */
+ protected void doAttach() throws Exception
+ {
+ this.fs.attach(this);
+ }
+
+ /**
+ * @return Returns the data.
+ */
+ RamFileData getData()
+ {
+ return data;
+ }
+
+ /**
+ * @param data
+ * The data to set.
+ */
+ void setData(RamFileData data)
+ {
+ this.data = data;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.commons.vfs.provider.AbstractFileObject#injectType(org.apache.commons.vfs.FileType)
+ */
+ protected void injectType(FileType fileType)
+ {
+ this.data.setType(fileType);
+ super.injectType(fileType);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.commons.vfs.provider.AbstractFileObject#endOutput()
+ */
+ protected void endOutput() throws Exception
+ {
+ super.endOutput();
+ this.save();
+ }
+
+ /**
+ * @return Returns the size of the RAMFileData
+ */
+ int size()
+ {
+ if (data == null)
+ {
+ return 0;
+ }
+ return data.size();
+ }
+
+ /**
+ * @param newSize
+ * @throws IOException
+ * if the new size exceeds the limit
+ */
+ synchronized void resize(int newSize) throws IOException
+ {
+ if (fs.getFileSystemOptions() != null)
+ {
+ int maxSize = RamFileSystemConfigBuilder.getInstance().getMaxSize(
+ fs.getFileSystemOptions());
+ if (fs.size() + newSize - this.size() > maxSize)
+ {
+ throw new IOException("FileSystem capacity (" + maxSize
+ + ") exceeded.");
+ }
+ }
+ this.data.resize(newSize);
+ }
}
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileOutputStream.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileOutputStream.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileOutputStream.java Mon Apr 13 04:06:01 2009
@@ -27,87 +27,87 @@
public class RamFileOutputStream extends OutputStream
{
- /**
- * File
- */
- protected RamFileObject file;
-
- /**
- * buffer
- */
- protected byte buffer1[] = new byte[1];
-
- protected boolean closed = false;
-
- private IOException exc;
-
- /**
- * @param file
- */
- public RamFileOutputStream(RamFileObject file)
- {
- super();
- this.file = file;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.DataOutput#write(byte[], int, int)
- */
- public void write(byte[] b, int off, int len) throws IOException
- {
- int size = this.file.getData().size();
- int newSize = this.file.getData().size() + len;
- // Store the Exception in order to notify the client again on close()
- try
- {
- this.file.resize(newSize);
- }
- catch (IOException e)
- {
- this.exc = e;
- throw e;
- }
- System.arraycopy(b, off, this.file.getData().getBuffer(), size, len);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.DataOutput#write(int)
- */
- public void write(int b) throws IOException
- {
- buffer1[0] = (byte) b;
- this.write(buffer1);
- }
-
- public void flush() throws IOException
- {
- }
-
- public void close() throws IOException
- {
- if (closed)
- {
- return;
- }
- // Notify on close that there was an IOException while writing
- if (exc != null)
- {
- throw exc;
- }
- try
- {
- this.closed = true;
- // Close the
- this.file.endOutput();
- }
- catch (Exception e)
- {
- throw new FileSystemException(e);
- }
- }
+ /**
+ * File
+ */
+ protected RamFileObject file;
+
+ /**
+ * buffer
+ */
+ protected byte buffer1[] = new byte[1];
+
+ protected boolean closed = false;
+
+ private IOException exc;
+
+ /**
+ * @param file
+ */
+ public RamFileOutputStream(RamFileObject file)
+ {
+ super();
+ this.file = file;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.io.DataOutput#write(byte[], int, int)
+ */
+ public void write(byte[] b, int off, int len) throws IOException
+ {
+ int size = this.file.getData().size();
+ int newSize = this.file.getData().size() + len;
+ // Store the Exception in order to notify the client again on close()
+ try
+ {
+ this.file.resize(newSize);
+ }
+ catch (IOException e)
+ {
+ this.exc = e;
+ throw e;
+ }
+ System.arraycopy(b, off, this.file.getData().getBuffer(), size, len);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.io.DataOutput#write(int)
+ */
+ public void write(int b) throws IOException
+ {
+ buffer1[0] = (byte) b;
+ this.write(buffer1);
+ }
+
+ public void flush() throws IOException
+ {
+ }
+
+ public void close() throws IOException
+ {
+ if (closed)
+ {
+ return;
+ }
+ // Notify on close that there was an IOException while writing
+ if (exc != null)
+ {
+ throw exc;
+ }
+ try
+ {
+ this.closed = true;
+ // Close the
+ this.file.endOutput();
+ }
+ catch (Exception e)
+ {
+ throw new FileSystemException(e);
+ }
+ }
}
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileProvider.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileProvider.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileProvider.java Mon Apr 13 04:06:01 2009
@@ -32,47 +32,47 @@
* RAM File Provider
*/
public class RamFileProvider extends AbstractOriginatingFileProvider implements
- FileProvider
+ FileProvider
{
- public final static Collection capabilities = Collections
- .unmodifiableCollection(Arrays.asList(new Capability[]
- { Capability.CREATE, Capability.DELETE, Capability.RENAME,
- Capability.GET_TYPE, Capability.GET_LAST_MODIFIED,
- Capability.SET_LAST_MODIFIED_FILE,
- Capability.SET_LAST_MODIFIED_FOLDER,
- Capability.LIST_CHILDREN, Capability.READ_CONTENT,
- Capability.URI, Capability.WRITE_CONTENT,
- Capability.APPEND_CONTENT, Capability.RANDOM_ACCESS_READ,
- Capability.RANDOM_ACCESS_WRITE }));
+ public final static Collection capabilities = Collections
+ .unmodifiableCollection(Arrays.asList(new Capability[]
+ { Capability.CREATE, Capability.DELETE, Capability.RENAME,
+ Capability.GET_TYPE, Capability.GET_LAST_MODIFIED,
+ Capability.SET_LAST_MODIFIED_FILE,
+ Capability.SET_LAST_MODIFIED_FOLDER,
+ Capability.LIST_CHILDREN, Capability.READ_CONTENT,
+ Capability.URI, Capability.WRITE_CONTENT,
+ Capability.APPEND_CONTENT, Capability.RANDOM_ACCESS_READ,
+ Capability.RANDOM_ACCESS_WRITE }));
- /**
- * Constructor
- */
- public RamFileProvider()
- {
- super();
- }
+ /**
+ * Constructor
+ */
+ public RamFileProvider()
+ {
+ super();
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.apache.commons.vfs.provider.AbstractOriginatingFileProvider#doCreateFileSystem(org.apache.commons.vfs.FileName,
- * org.apache.commons.vfs.FileSystemOptions)
- */
- protected FileSystem doCreateFileSystem(FileName name,
- FileSystemOptions fileSystemOptions) throws FileSystemException
- {
- return new RamFileSystem(name, fileSystemOptions);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.commons.vfs.provider.AbstractOriginatingFileProvider#doCreateFileSystem(org.apache.commons.vfs.FileName,
+ * org.apache.commons.vfs.FileSystemOptions)
+ */
+ protected FileSystem doCreateFileSystem(FileName name,
+ FileSystemOptions fileSystemOptions) throws FileSystemException
+ {
+ return new RamFileSystem(name, fileSystemOptions);
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.apache.commons.vfs.provider.FileProvider#getCapabilities()
- */
- public Collection getCapabilities()
- {
- return capabilities;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.commons.vfs.provider.FileProvider#getCapabilities()
+ */
+ public Collection getCapabilities()
+ {
+ return capabilities;
+ }
}