You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by im...@apache.org on 2005/08/02 22:09:53 UTC
svn commit: r227075 - in /jakarta/commons/proper/vfs/trunk: ./
src/java/org/apache/commons/vfs/provider/ftp/
src/java/org/apache/commons/vfs/provider/local/
Author: imario
Date: Tue Aug 2 13:09:42 2005
New Revision: 227075
URL: http://svn.apache.org/viewcvs?rev=227075&view=rev
Log:
ftp: configuration to use user-home as root
file: build windows filename according to the documentation. e.g. file:///c:/dir, file:////unchost/uncshare
Added:
jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileName.java (with props)
Modified:
jakarta/commons/proper/vfs/trunk/RELEASE_NOTES.txt
jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpClientFactory.java
jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java
jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileSystem.java
jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java
jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java
Modified: jakarta/commons/proper/vfs/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/RELEASE_NOTES.txt?rev=227075&r1=227074&r2=227075&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/RELEASE_NOTES.txt (original)
+++ jakarta/commons/proper/vfs/trunk/RELEASE_NOTES.txt Tue Aug 2 13:09:42 2005
@@ -1,4 +1,10 @@
-2005-Jul-11
+2005-
+
+ftp:
+configuration to use user-home as root
+
+file:
+build windows filename according to the documentation. e.g. file:///c:/dir, file:////unchost/uncshare
smb:
now uses NtlmPasswordAuthentication for credentials passing
Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpClientFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpClientFactory.java?rev=227075&r1=227074&r2=227075&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpClientFactory.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpClientFactory.java Tue Aug 2 13:09:42 2005
@@ -87,7 +87,9 @@
// Change to root by default
// All file operations a relative to the filesystem-root
// String root = getRoot().getName().getPath();
- if (workingDirectory != null)
+
+ Boolean userDirIsRoot = FtpFileSystemConfigBuilder.getInstance().getUserDirIsRoot(fileSystemOptions);
+ if (workingDirectory != null && (userDirIsRoot == null || !userDirIsRoot.booleanValue()))
{
if (!client.changeWorkingDirectory(workingDirectory))
{
Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java?rev=227075&r1=227074&r2=227075&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java Tue Aug 2 13:09:42 2005
@@ -66,7 +66,8 @@
{
// 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 = UriParser.decode(rootName.getPath());
+ this.relPath = "";
}
else
{
@@ -77,7 +78,7 @@
/**
* 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 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
@@ -477,6 +478,7 @@
client.abort();
close();
}
+
/**
* Called after the stream has been closed.
*/
Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileSystem.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileSystem.java?rev=227075&r1=227074&r2=227075&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileSystem.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileSystem.java Tue Aug 2 13:09:42 2005
@@ -46,7 +46,7 @@
// An idle client
private FtpClient idleClient;
- private Object idleClientSync = new Object();
+ private final Object idleClientSync = new Object();
protected FtpFileSystem(final GenericFileName rootName, final FtpClient ftpClient, final FileSystemOptions fileSystemOptions)
{
@@ -100,30 +100,30 @@
*/
public FtpClient getClient() throws FileSystemException
{
- synchronized(idleClientSync)
- {
- if (idleClient == null || !idleClient.isConnected())
- {
- FtpClient ftpClient = new FTPClientWrapper((GenericFileName) getRoot().getName(), getFileSystemOptions());
- return ftpClient;
- /*
- final GenericFileName rootName = (GenericFileName) getRoot().getName();
-
- return FtpClientFactory.createConnection(rootName.getHostName(),
- rootName.getPort(),
- rootName.getUserName(),
- rootName.getPassword(),
- rootName.getPath(),
- getFileSystemOptions());
- */
- }
- else
+ synchronized (idleClientSync)
{
- final FtpClient client = idleClient;
- idleClient = null;
- return client;
+ if (idleClient == null || !idleClient.isConnected())
+ {
+ FtpClient ftpClient = new FTPClientWrapper((GenericFileName) getRoot().getName(), getFileSystemOptions());
+ return ftpClient;
+ /*
+ final GenericFileName rootName = (GenericFileName) getRoot().getName();
+
+ return FtpClientFactory.createConnection(rootName.getHostName(),
+ rootName.getPort(),
+ rootName.getUserName(),
+ rootName.getPassword(),
+ rootName.getPath(),
+ getFileSystemOptions());
+ */
+ }
+ else
+ {
+ final FtpClient client = idleClient;
+ idleClient = null;
+ return client;
+ }
}
- }
}
/**
@@ -131,19 +131,19 @@
*/
public void putClient(final FtpClient client)
{
- synchronized(idleClientSync)
- {
- if (idleClient == null)
- {
- // Hang on to client for later
- idleClient = client;
- }
- else
+ synchronized (idleClientSync)
{
- // Close the client
- closeConnection(client);
+ if (idleClient == null)
+ {
+ // Hang on to client for later
+ idleClient = client;
+ }
+ else
+ {
+ // Close the client
+ closeConnection(client);
+ }
}
- }
}
/**
Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java?rev=227075&r1=227074&r2=227075&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java Tue Aug 2 13:09:42 2005
@@ -31,6 +31,7 @@
private final static String FACTORY_KEY = FTPFileEntryParserFactory.class.getName() + ".KEY";
private final static String PASSIVE_MODE = FTPFileEntryParserFactory.class.getName() + ".PASSIVE";
+ private final static String USER_DIR_IS_ROOT = FTPFileEntryParserFactory.class.getName() + ".USER_DIR_IS_ROOT";
public static FtpFileSystemConfigBuilder getInstance()
{
@@ -99,7 +100,7 @@
*/
public void setPassiveMode(FileSystemOptions opts, boolean passiveMode)
{
- setParam(opts, PASSIVE_MODE, passiveMode?Boolean.TRUE:Boolean.FALSE);
+ setParam(opts, PASSIVE_MODE, passiveMode ? Boolean.TRUE : Boolean.FALSE);
}
/**
@@ -110,5 +111,26 @@
public Boolean getPassiveMode(FileSystemOptions opts)
{
return (Boolean) getParam(opts, PASSIVE_MODE);
+ }
+
+ /**
+ * use user directory as root (do not change to fs root)
+ *
+ * @param opts
+ * @param userDirIsRoot
+ */
+ public void setUserDirIsRoot(FileSystemOptions opts, boolean userDirIsRoot)
+ {
+ setParam(opts, USER_DIR_IS_ROOT, userDirIsRoot ? Boolean.TRUE : Boolean.FALSE);
+ }
+
+ /**
+ * @param opts
+ * @return
+ * @see #setUserDirIsRoot
+ */
+ public Boolean getUserDirIsRoot(FileSystemOptions opts)
+ {
+ return (Boolean) getParam(opts, USER_DIR_IS_ROOT);
}
}
Added: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileName.java?rev=227075&view=auto
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileName.java (added)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileName.java Tue Aug 2 13:09:42 2005
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2002-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+package org.apache.commons.vfs.provider.local;
+
+import org.apache.commons.vfs.FileName;
+
+/**
+ * A local file URI.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision$ $Date$
+ */
+public class WindowsFileName extends LocalFileName
+{
+ protected WindowsFileName(final String scheme,
+ final String rootFile,
+ final String path)
+ {
+ super(scheme, rootFile, path);
+ }
+
+ /**
+ * Factory method for creating name instances.
+ */
+ public FileName createName(final String path)
+ {
+ return new WindowsFileName(getScheme(), getRootFile(), path);
+ }
+
+ /**
+ * Builds the root URI for this file name.
+ */
+ protected void appendRootUri(final StringBuffer buffer)
+ {
+ buffer.append(getScheme());
+ buffer.append("://");
+ if (getRootFile() != null && !getRootFile().startsWith("/"))
+ {
+ // next is drive-letter (else unc name)
+ buffer.append("/");
+ }
+ buffer.append(getRootFile());
+ }
+}
Propchange: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileName.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileName.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileName.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java?rev=227075&r1=227074&r2=227075&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java Tue Aug 2 13:09:42 2005
@@ -39,7 +39,7 @@
protected FileName createFileName(String scheme, final String rootFile, final String path)
{
- return new LocalFileName(scheme, rootFile, path);
+ return new WindowsFileName(scheme, rootFile, path);
}
/**
@@ -53,13 +53,13 @@
// ('/'){0, 3} <letter> ':' '/'
// ['/'] '//' <name> '/' <name> ( '/' | <end> )
- // Skip over first 3 leading '/' chars
+ // Skip over first 4 (unc) leading '/' chars
int startPos = 0;
- int maxlen = Math.min(3, name.length());
+ int maxlen = Math.min(4, name.length());
for (; startPos < maxlen && name.charAt(startPos) == '/'; startPos++)
{
}
- if (startPos == maxlen)
+ if (startPos == maxlen && name.length() > startPos && name.charAt(startPos + 1) == '/')
{
// Too many '/'
throw new FileSystemException("vfs.provider.local/not-absolute-file-name.error", uri);
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org