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/09/13 08:26:24 UTC
svn commit: r814264 [2/2] - in /commons/proper/vfs/branches/VFS281: ./
core/src/main/java/org/apache/commons/vfs/
core/src/main/java/org/apache/commons/vfs/impl/
core/src/main/java/org/apache/commons/vfs/provider/
core/src/main/java/org/apache/commons/...
Added: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystemOptions.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystemOptions.java?rev=814264&view=auto
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystemOptions.java (added)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystemOptions.java Sun Sep 13 06:26:23 2009
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ */
+package org.apache.commons.vfs.provider.ram;
+
+import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.DefaultFileSystemOptions;
+
+/**
+ * RAM File System Options
+ * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
+ */
+public class RamFileSystemOptions extends DefaultFileSystemOptions
+{
+ /** max size key */
+ private static final String MAX_SIZE_KEY = "maxsize";
+
+ public RamFileSystemOptions()
+ {
+ this("ram.");
+ }
+
+ protected RamFileSystemOptions(String scheme)
+ {
+ super(scheme);
+ }
+
+ public static RamFileSystemOptions getInstance(FileSystemOptions opts)
+ {
+ return FileSystemOptions.makeSpecific(RamFileSystemOptions.class, opts);
+ }
+
+ /**
+ * @return The maximum size of the file system.
+ * @see #setMaxSize
+ */
+ public int getMaxSize()
+ {
+ return getInteger(MAX_SIZE_KEY, Integer.MAX_VALUE);
+ }
+
+ /**
+ * Sets the maximum size of the file system
+ *
+ * @param sizeInBytes The maximum size.
+ */
+ public void setMaxSize(int sizeInBytes)
+ {
+ setParam(MAX_SIZE_KEY, new Integer(sizeInBytes));
+ }
+}
\ No newline at end of file
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/res/ResourceFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/res/ResourceFileProvider.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/res/ResourceFileProvider.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/res/ResourceFileProvider.java Sun Sep 13 06:26:23 2009
@@ -59,8 +59,14 @@
StringBuffer buf = new StringBuffer(80);
UriParser.extractScheme(uri, buf);
String resourceName = buf.toString();
+ ClassLoader cl = null;
+ if (fileSystemOptions != null)
+ {
+ ResourceFileSystemOptions options =
+ ResourceFileSystemOptions.makeSpecific(ResourceFileSystemOptions.class, fileSystemOptions);
- ClassLoader cl = ResourceFileSystemConfigBuilder.getInstance().getClassLoader(fileSystemOptions);
+ cl = options.getClassLoader();
+ }
if (cl == null)
{
cl = getClass().getClassLoader();
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/res/ResourceFileSystemConfigBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/res/ResourceFileSystemConfigBuilder.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/res/ResourceFileSystemConfigBuilder.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/res/ResourceFileSystemConfigBuilder.java Sun Sep 13 06:26:23 2009
@@ -25,6 +25,7 @@
*
* @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
* @version $Revision$ $Date$
+ * @deprecated Use ResourceFileSystemOptions.
*/
public class ResourceFileSystemConfigBuilder extends FileSystemConfigBuilder
{
@@ -42,12 +43,12 @@
public void setClassLoader(FileSystemOptions opts, ClassLoader classLoader)
{
- setParam(opts, ClassLoader.class.getName(), classLoader);
+ ResourceFileSystemOptions.getInstance(opts).setClassLoader(classLoader);
}
public ClassLoader getClassLoader(FileSystemOptions opts)
{
- return (ClassLoader) getParam(opts, ClassLoader.class.getName());
+ return ResourceFileSystemOptions.getInstance(opts).getClassLoader();
}
protected Class getConfigClass()
Added: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/res/ResourceFileSystemOptions.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/res/ResourceFileSystemOptions.java?rev=814264&view=auto
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/res/ResourceFileSystemOptions.java (added)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/res/ResourceFileSystemOptions.java Sun Sep 13 06:26:23 2009
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+package org.apache.commons.vfs.provider.res;
+
+import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.DefaultFileSystemOptions;
+import org.apache.commons.vfs.provider.ram.RamFileSystemOptions;
+
+/**
+ * RAM File System Options
+ * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
+ */
+public class ResourceFileSystemOptions extends DefaultFileSystemOptions
+{
+ public ResourceFileSystemOptions()
+ {
+ this("resource.");
+ }
+
+ protected ResourceFileSystemOptions(String scheme)
+ {
+ super(scheme);
+ }
+
+ public static ResourceFileSystemOptions getInstance(FileSystemOptions opts)
+ {
+ return FileSystemOptions.makeSpecific(ResourceFileSystemOptions.class, opts);
+ }
+
+ /**
+ * Set the class loader.
+ * @param classLoader The class loader.
+ */
+ public void setClassLoader(ClassLoader classLoader)
+ {
+ setParam(ClassLoader.class.getName(), classLoader);
+ }
+
+ /**
+ * Retrieve the class loader.
+ * @return The class loader.
+ */
+ public ClassLoader getClassLoader()
+ {
+ return (ClassLoader) getParam(ClassLoader.class.getName());
+ }
+}
\ No newline at end of file
Added: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/ProxyType.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/ProxyType.java?rev=814264&view=auto
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/ProxyType.java (added)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/ProxyType.java Sun Sep 13 06:26:23 2009
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+package org.apache.commons.vfs.provider.sftp;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
+ * @version $Revision: $
+ */
+public class ProxyType implements Serializable, Comparable
+{
+ private final String proxyType;
+
+ ProxyType(final String proxyType)
+ {
+ this.proxyType = proxyType;
+ }
+
+ public int compareTo(Object o)
+ {
+ return proxyType.compareTo(((ProxyType) o).proxyType);
+ }
+
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ ProxyType proxyType1 = (ProxyType) o;
+
+ if (proxyType != null ? !proxyType.equals(proxyType1.proxyType) : proxyType1.proxyType != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+}
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpClientFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpClientFactory.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpClientFactory.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpClientFactory.java Sun Sep 13 06:26:23 2009
@@ -52,10 +52,11 @@
JSch jsch = new JSch();
File sshDir = null;
+ SftpFileSystemOptions options = FileSystemOptions.makeSpecific(SftpFileSystemOptions.class, fileSystemOptions);
// new style - user passed
- File knownHostsFile = SftpFileSystemConfigBuilder.getInstance().getKnownHosts(fileSystemOptions);
- File[] identities = SftpFileSystemConfigBuilder.getInstance().getIdentities(fileSystemOptions);
+ File knownHostsFile = options.getKnownHosts();
+ File[] identities = options.getIdentities();
if (knownHostsFile != null)
{
@@ -137,13 +138,13 @@
session.setPassword(new String(password));
}
- Integer timeout = SftpFileSystemConfigBuilder.getInstance().getTimeout(fileSystemOptions);
+ Integer timeout = options.getTimeout();
if (timeout != null)
{
session.setTimeout(timeout.intValue());
}
- UserInfo userInfo = SftpFileSystemConfigBuilder.getInstance().getUserInfo(fileSystemOptions);
+ UserInfo userInfo = options.getUserInfo();
if (userInfo != null)
{
session.setUserInfo(userInfo);
@@ -152,27 +153,27 @@
Properties config = new Properties();
//set StrictHostKeyChecking property
- String strictHostKeyChecking = SftpFileSystemConfigBuilder.getInstance().getStrictHostKeyChecking(fileSystemOptions);
+ String strictHostKeyChecking = options.getStrictHostKeyChecking();
if (strictHostKeyChecking != null)
{
config.setProperty("StrictHostKeyChecking", strictHostKeyChecking);
}
//set compression property
- String compression = SftpFileSystemConfigBuilder.getInstance().getCompression(fileSystemOptions);
+ String compression = options.getCompression();
if (compression != null)
{
config.setProperty("compression.s2c", compression);
config.setProperty("compression.c2s", compression);
}
- String proxyHost = SftpFileSystemConfigBuilder.getInstance().getProxyHost(fileSystemOptions);
+ String proxyHost = options.getProxyHost();
if (proxyHost != null)
{
- int proxyPort = SftpFileSystemConfigBuilder.getInstance().getProxyPort(fileSystemOptions);
- SftpFileSystemConfigBuilder.ProxyType proxyType = SftpFileSystemConfigBuilder.getInstance().getProxyType(fileSystemOptions);
+ int proxyPort = options.getProxyPort();
+ ProxyType proxyType = options.getProxyType();
Proxy proxy = null;
- if (SftpFileSystemConfigBuilder.PROXY_HTTP.equals(proxyType))
+ if (SftpFileSystemOptions.PROXY_HTTP.equals(proxyType))
{
if (proxyPort != 0)
{
@@ -183,7 +184,7 @@
proxy = new ProxyHTTP(proxyHost);
}
}
- else if (SftpFileSystemConfigBuilder.PROXY_SOCKS5.equals(proxyType))
+ else if (SftpFileSystemOptions.PROXY_SOCKS5.equals(proxyType))
{
if (proxyPort != 0)
{
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java Sun Sep 13 06:26:23 2009
@@ -63,12 +63,13 @@
UserAuthenticationData.USERNAME, UserAuthenticationData.PASSWORD
};
+ private static final Class<? extends FileSystemOptions> FSOPTIONS_CLASS = SftpFileSystemOptions.class;
+
// private JSch jSch = new JSch();
public SftpFileProvider()
{
- super();
- setFileNameParser(SftpFileNameParser.getInstance());
+ super(SftpFileNameParser.getInstance(), FSOPTIONS_CLASS);
}
/**
@@ -105,7 +106,7 @@
UserAuthenticatorUtils.cleanup(authData);
}
- return new SftpFileSystem(rootName, session, fileSystemOptions);
+ return new SftpFileSystem(rootName, session, fileSystemOptions, FSOPTIONS_CLASS);
}
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystem.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystem.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystem.java Sun Sep 13 06:26:23 2009
@@ -50,9 +50,10 @@
protected SftpFileSystem(final GenericFileName rootName,
final Session session,
- final FileSystemOptions fileSystemOptions)
+ final FileSystemOptions fileSystemOptions,
+ final Class<? extends FileSystemOptions> optionsClass)
{
- super(rootName, null, fileSystemOptions);
+ super(rootName, null, fileSystemOptions, optionsClass);
this.session = session;
}
@@ -124,7 +125,7 @@
channel = (ChannelSftp) session.openChannel("sftp");
channel.connect();
- Boolean userDirIsRoot = SftpFileSystemConfigBuilder.getInstance().getUserDirIsRoot(getFileSystemOptions());
+ Boolean userDirIsRoot = getFileSystemOptions().getUserDirIsRoot();
String workingDirectory = getRootName().getPath();
if (workingDirectory != null && (userDirIsRoot == null || !userDirIsRoot.booleanValue()))
{
@@ -195,4 +196,9 @@
{
return 1000L;
}
+
+ public SftpFileSystemOptions getFileSystemOptions()
+ {
+ return super.getOptions();
+ }
}
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemConfigBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemConfigBuilder.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemConfigBuilder.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemConfigBuilder.java Sun Sep 13 06:26:23 2009
@@ -29,54 +29,15 @@
*
* @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
* @version $Revision$ $Date$
+ * @deprecated Use SftpFileSystemOptions.
*/
public class SftpFileSystemConfigBuilder extends FileSystemConfigBuilder
{
private final static SftpFileSystemConfigBuilder builder = new SftpFileSystemConfigBuilder();
- private final static String USER_DIR_IS_ROOT = SftpFileSystemConfigBuilder.class.getName() + ".USER_DIR_IS_ROOT";
- private final static String TIMEOUT = SftpFileSystemConfigBuilder.class.getName() + ".TIMEOUT";
-
public final static ProxyType PROXY_HTTP = new ProxyType("http");
public final static ProxyType PROXY_SOCKS5 = new ProxyType("socks");
- public static class ProxyType implements Serializable, Comparable
- {
- private final String proxyType;
-
- private ProxyType(final String proxyType)
- {
- this.proxyType = proxyType;
- }
-
- public int compareTo(Object o)
- {
- return proxyType.compareTo(((ProxyType) o).proxyType);
- }
-
-
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- ProxyType proxyType1 = (ProxyType) o;
-
- if (proxyType != null ? !proxyType.equals(proxyType1.proxyType) : proxyType1.proxyType != null)
- {
- return false;
- }
-
- return true;
- }
- }
-
public static SftpFileSystemConfigBuilder getInstance()
{
return builder;
@@ -96,7 +57,7 @@
*/
public void setUserInfo(FileSystemOptions opts, UserInfo info)
{
- setParam(opts, UserInfo.class.getName(), info);
+ SftpFileSystemOptions.getInstance(opts).setUserInfo(info);
}
/**
@@ -105,7 +66,7 @@
*/
public UserInfo getUserInfo(FileSystemOptions opts)
{
- return (UserInfo) getParam(opts, UserInfo.class.getName());
+ return SftpFileSystemOptions.getInstance(opts).getUserInfo();
}
/**
@@ -117,7 +78,7 @@
*/
public void setKnownHosts(FileSystemOptions opts, File sshdir) throws FileSystemException
{
- setParam(opts, "knownHosts", sshdir);
+ SftpFileSystemOptions.getInstance(opts).setKnownHosts(sshdir);
}
/**
@@ -126,7 +87,7 @@
*/
public File getKnownHosts(FileSystemOptions opts)
{
- return (File) getParam(opts, "knownHosts");
+ return SftpFileSystemOptions.getInstance(opts).getKnownHosts();
}
/**
@@ -138,7 +99,7 @@
*/
public void setIdentities(FileSystemOptions opts, File[] identities) throws FileSystemException
{
- setParam(opts, "identities", identities);
+ SftpFileSystemOptions.getInstance(opts).setIdentities(identities);
}
/**
@@ -152,7 +113,7 @@
*/
public void setCompression(FileSystemOptions opts, String compression) throws FileSystemException
{
- setParam(opts, "compression", compression);
+ SftpFileSystemOptions.getInstance(opts).setCompression(compression);
}
/**
@@ -161,7 +122,7 @@
*/
public String getCompression(FileSystemOptions opts)
{
- return getString(opts, "compression");
+ return SftpFileSystemOptions.getInstance(opts).getCompression();
}
/**
@@ -170,7 +131,7 @@
*/
public File[] getIdentities(FileSystemOptions opts)
{
- return (File[]) getParam(opts, "identities");
+ return SftpFileSystemOptions.getInstance(opts).getIdentities();
}
/**
@@ -184,12 +145,7 @@
*/
public void setStrictHostKeyChecking(FileSystemOptions opts, String hostKeyChecking) throws FileSystemException
{
- if (hostKeyChecking == null || (!hostKeyChecking.equals("ask") && !hostKeyChecking.equals("no") && !hostKeyChecking.equals("yes")))
- {
- throw new FileSystemException("vfs.provider.sftp/StrictHostKeyChecking-arg.error", hostKeyChecking);
- }
-
- setParam(opts, "StrictHostKeyChecking", hostKeyChecking);
+ SftpFileSystemOptions.getInstance(opts).setStrictHostKeyChecking(hostKeyChecking);
}
/**
@@ -199,7 +155,7 @@
*/
public String getStrictHostKeyChecking(FileSystemOptions opts)
{
- return getString(opts, "StrictHostKeyChecking");
+ return SftpFileSystemOptions.getInstance(opts).getStrictHostKeyChecking();
}
/**
@@ -210,7 +166,7 @@
*/
public void setUserDirIsRoot(FileSystemOptions opts, boolean userDirIsRoot)
{
- setParam(opts, USER_DIR_IS_ROOT, userDirIsRoot ? Boolean.TRUE : Boolean.FALSE);
+ SftpFileSystemOptions.getInstance(opts).setUserDirIsRoot(userDirIsRoot);
}
/**
@@ -219,7 +175,7 @@
*/
public Boolean getUserDirIsRoot(FileSystemOptions opts)
{
- return getBoolean(opts, USER_DIR_IS_ROOT);
+ return SftpFileSystemOptions.getInstance(opts).getUserDirIsRoot();
}
/**
@@ -230,7 +186,7 @@
*/
public void setTimeout(FileSystemOptions opts, Integer timeout)
{
- setParam(opts, TIMEOUT, timeout);
+ SftpFileSystemOptions.getInstance(opts).setTimeout(timeout);
}
/**
@@ -239,7 +195,7 @@
*/
public Integer getTimeout(FileSystemOptions opts)
{
- return getInteger(opts, TIMEOUT);
+ return SftpFileSystemOptions.getInstance(opts).getTimeout();
}
protected Class getConfigClass()
@@ -256,7 +212,7 @@
*/
public void setProxyHost(FileSystemOptions opts, String proxyHost)
{
- setParam(opts, "proxyHost", proxyHost);
+ SftpFileSystemOptions.getInstance(opts).setProxyHost(proxyHost);
}
/**
@@ -268,7 +224,7 @@
*/
public void setProxyPort(FileSystemOptions opts, int proxyPort)
{
- setParam(opts, "proxyPort", new Integer(proxyPort));
+ SftpFileSystemOptions.getInstance(opts).setProxyPort(proxyPort);
}
/**
@@ -280,7 +236,7 @@
*/
public String getProxyHost(FileSystemOptions opts)
{
- return getString(opts, "proxyHost");
+ return SftpFileSystemOptions.getInstance(opts).getProxyHost();
}
/**
@@ -292,7 +248,7 @@
*/
public int getProxyPort(FileSystemOptions opts)
{
- return getInteger(opts, "proxyPort", 0);
+ return SftpFileSystemOptions.getInstance(opts).getProxyPort();
}
/**
@@ -300,7 +256,7 @@
*/
public void setProxyType(FileSystemOptions opts, ProxyType proxyType)
{
- setParam(opts, "proxyType", proxyType);
+ SftpFileSystemOptions.getInstance(opts).setProxyType(proxyType);
}
/**
@@ -308,6 +264,6 @@
*/
public ProxyType getProxyType(FileSystemOptions opts)
{
- return (ProxyType) getParam(opts, "proxyType");
+ return SftpFileSystemOptions.getInstance(opts).getProxyType();
}
}
Copied: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemOptions.java (from r812334, commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemConfigBuilder.java)
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemOptions.java?p2=commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemOptions.java&p1=commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemConfigBuilder.java&r1=812334&r2=814264&rev=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemConfigBuilder.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemOptions.java Sun Sep 13 06:26:23 2009
@@ -17,128 +17,94 @@
package org.apache.commons.vfs.provider.sftp;
import com.jcraft.jsch.UserInfo;
-import org.apache.commons.vfs.FileSystemConfigBuilder;
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.DefaultFileSystemOptions;
import java.io.File;
-import java.io.Serializable;
/**
* The config builder for various sftp configuration options
*
- * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
- * @version $Revision$ $Date$
+ * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
+ * @version $Revision$
*/
-public class SftpFileSystemConfigBuilder extends FileSystemConfigBuilder
+public class SftpFileSystemOptions extends DefaultFileSystemOptions
{
- private final static SftpFileSystemConfigBuilder builder = new SftpFileSystemConfigBuilder();
+ private final static SftpFileSystemOptions builder = new SftpFileSystemOptions();
- private final static String USER_DIR_IS_ROOT = SftpFileSystemConfigBuilder.class.getName() + ".USER_DIR_IS_ROOT";
- private final static String TIMEOUT = SftpFileSystemConfigBuilder.class.getName() + ".TIMEOUT";
+ private final static String USER_DIR_IS_ROOT = SftpFileSystemOptions.class.getName() + ".USER_DIR_IS_ROOT";
+ private final static String TIMEOUT = SftpFileSystemOptions.class.getName() + ".TIMEOUT";
public final static ProxyType PROXY_HTTP = new ProxyType("http");
public final static ProxyType PROXY_SOCKS5 = new ProxyType("socks");
- public static class ProxyType implements Serializable, Comparable
+ public SftpFileSystemOptions()
{
- private final String proxyType;
-
- private ProxyType(final String proxyType)
- {
- this.proxyType = proxyType;
- }
-
- public int compareTo(Object o)
- {
- return proxyType.compareTo(((ProxyType) o).proxyType);
- }
-
-
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- ProxyType proxyType1 = (ProxyType) o;
-
- if (proxyType != null ? !proxyType.equals(proxyType1.proxyType) : proxyType1.proxyType != null)
- {
- return false;
- }
-
- return true;
- }
+ this("sftp.");
}
- public static SftpFileSystemConfigBuilder getInstance()
+ protected SftpFileSystemOptions(String scheme)
{
- return builder;
+ super(scheme);
}
- private SftpFileSystemConfigBuilder()
+ public static SftpFileSystemOptions getInstance(FileSystemOptions opts)
{
- super("sftp.");
+ return FileSystemOptions.makeSpecific(SftpFileSystemOptions.class, opts);
}
/**
* Set the userinfo class to use if e.g. a password or a not known host
* will be contacted
*
- * @param opts
- * @param info
+ * @param info The UserInfo.
*/
- public void setUserInfo(FileSystemOptions opts, UserInfo info)
+ public void setUserInfo(UserInfo info)
{
- setParam(opts, UserInfo.class.getName(), info);
+ setParam(UserInfo.class.getName(), info);
}
/**
- * @param opts
* @see #setUserInfo
+ * @return The UserInfo.
*/
- public UserInfo getUserInfo(FileSystemOptions opts)
+ public UserInfo getUserInfo()
{
- return (UserInfo) getParam(opts, UserInfo.class.getName());
+ return (UserInfo) getParam(UserInfo.class.getName());
}
/**
* Set the known_hosts file. e.g. /home/user/.ssh/known_hosts2<br>
* Need to use a java.io.File as JSch cant deal with vfs FileObjects ;-)
*
- * @param opts
- * @param sshdir
+ * @param sshdir The location of the known_hosts file.
+ * @throws FileSystemException if an error occurs.
*/
- public void setKnownHosts(FileSystemOptions opts, File sshdir) throws FileSystemException
+ public void setKnownHosts(File sshdir) throws FileSystemException
{
- setParam(opts, "knownHosts", sshdir);
+ setParam("knownHosts", sshdir);
}
/**
- * @param opts
* @see #setKnownHosts
+ * @return the location of the known_hosts file.
*/
- public File getKnownHosts(FileSystemOptions opts)
+ public File getKnownHosts()
{
- return (File) getParam(opts, "knownHosts");
+ return (File) getParam("knownHosts");
}
/**
* Set the identity files (your private key files).<br>
* Need to use a java.io.File as JSch cant deal with vfs FileObjects ;-)
*
- * @param opts
- * @param identities
+ * @param identities The identity files.
+ * @throws FileSystemException if an error occurs.
*/
- public void setIdentities(FileSystemOptions opts, File[] identities) throws FileSystemException
+ public void setIdentities(File[] identities) throws FileSystemException
{
- setParam(opts, "identities", identities);
+ setParam("identities", identities);
}
/**
@@ -146,31 +112,30 @@
* e.g. pass "zlib,none" to enable the compression.<br>
* See the jsch documentation for details.
*
- * @param opts
- * @param compression
- * @throws FileSystemException
+ * @param compression The compression type.
+ * @throws FileSystemException if an error occurs.
*/
- public void setCompression(FileSystemOptions opts, String compression) throws FileSystemException
+ public void setCompression(String compression) throws FileSystemException
{
- setParam(opts, "compression", compression);
+ setParam("compression", compression);
}
/**
- * @param opts
* @see #setCompression
+ * @return the compression type.
*/
- public String getCompression(FileSystemOptions opts)
+ public String getCompression()
{
- return getString(opts, "compression");
+ return getString("compression");
}
/**
- * @param opts
* @see #setIdentities
+ * @return The identity files.
*/
- public File[] getIdentities(FileSystemOptions opts)
+ public File[] getIdentities()
{
- return (File[]) getParam(opts, "identities");
+ return (File[]) getParam("identities");
}
/**
@@ -178,68 +143,65 @@
* valid arguments are only yes, no and ask.<br>
* See the jsch documentation for details.
*
- * @param opts
- * @param hostKeyChecking
- * @throws FileSystemException
+ * @param hostKeyChecking The host key checking.
+ * @throws FileSystemException if an error occurs.
*/
- public void setStrictHostKeyChecking(FileSystemOptions opts, String hostKeyChecking) throws FileSystemException
+ public void setStrictHostKeyChecking(String hostKeyChecking) throws FileSystemException
{
- if (hostKeyChecking == null || (!hostKeyChecking.equals("ask") && !hostKeyChecking.equals("no") && !hostKeyChecking.equals("yes")))
+ if (hostKeyChecking == null || (!hostKeyChecking.equals("ask") && !hostKeyChecking.equals("no")
+ && !hostKeyChecking.equals("yes")))
{
throw new FileSystemException("vfs.provider.sftp/StrictHostKeyChecking-arg.error", hostKeyChecking);
}
- setParam(opts, "StrictHostKeyChecking", hostKeyChecking);
+ setParam("StrictHostKeyChecking", hostKeyChecking);
}
/**
- * @param opts
* @return the option value
- * @see #setStrictHostKeyChecking(FileSystemOptions, String)
+ * @see #setStrictHostKeyChecking(String)
*/
- public String getStrictHostKeyChecking(FileSystemOptions opts)
+ public String getStrictHostKeyChecking()
{
- return getString(opts, "StrictHostKeyChecking");
+ return getString("StrictHostKeyChecking");
}
/**
* use user directory as root (do not change to fs root)
*
- * @param opts
- * @param userDirIsRoot
+ * @param userDirIsRoot true if the user's diretory is the root directory.
*/
- public void setUserDirIsRoot(FileSystemOptions opts, boolean userDirIsRoot)
+ public void setUserDirIsRoot(boolean userDirIsRoot)
{
- setParam(opts, USER_DIR_IS_ROOT, userDirIsRoot ? Boolean.TRUE : Boolean.FALSE);
+ setParam(USER_DIR_IS_ROOT, userDirIsRoot ? Boolean.TRUE : Boolean.FALSE);
}
/**
- * @param opts
* @see #setUserDirIsRoot
+ * @return true if the user's directory is the root directory.
*/
- public Boolean getUserDirIsRoot(FileSystemOptions opts)
+ public Boolean getUserDirIsRoot()
{
- return getBoolean(opts, USER_DIR_IS_ROOT);
+ return getBoolean(USER_DIR_IS_ROOT);
}
/**
* set the timeout value on jsch session
*
- * @param opts
- * @param timeout
+ * @param timeout The timeout value.
*/
- public void setTimeout(FileSystemOptions opts, Integer timeout)
+ public void setTimeout(Integer timeout)
{
- setParam(opts, TIMEOUT, timeout);
+ setParam(TIMEOUT, timeout);
}
/**
- * @param opts
* @see #setTimeout
+ * @return the timeout value.
*/
- public Integer getTimeout(FileSystemOptions opts)
+ public Integer getTimeout()
{
- return getInteger(opts, TIMEOUT);
+ return getInteger(TIMEOUT);
}
protected Class getConfigClass()
@@ -254,9 +216,9 @@
* @param proxyHost the host
* @see #setProxyPort
*/
- public void setProxyHost(FileSystemOptions opts, String proxyHost)
+ public void setProxyHost(String proxyHost)
{
- setParam(opts, "proxyHost", proxyHost);
+ setParam("proxyHost", proxyHost);
}
/**
@@ -266,9 +228,9 @@
* @param proxyPort the port
* @see #setProxyHost
*/
- public void setProxyPort(FileSystemOptions opts, int proxyPort)
+ public void setProxyPort(int proxyPort)
{
- setParam(opts, "proxyPort", new Integer(proxyPort));
+ setParam("proxyPort", new Integer(proxyPort));
}
/**
@@ -278,9 +240,9 @@
* @return proxyHost
* @see #setProxyPort
*/
- public String getProxyHost(FileSystemOptions opts)
+ public String getProxyHost()
{
- return getString(opts, "proxyHost");
+ return getString("proxyHost");
}
/**
@@ -290,24 +252,26 @@
* @return proxyPort: the port number or 0 if it is not set
* @see #setProxyHost
*/
- public int getProxyPort(FileSystemOptions opts)
+ public int getProxyPort()
{
- return getInteger(opts, "proxyPort", 0);
+ return getInteger("proxyPort", 0);
}
/**
* Set the proxy type to use for sftp connection.
+ * @param proxyType the proxy type.
*/
- public void setProxyType(FileSystemOptions opts, ProxyType proxyType)
+ public void setProxyType(ProxyType proxyType)
{
- setParam(opts, "proxyType", proxyType);
+ setParam("proxyType", proxyType);
}
/**
* Get the proxy type to use for sftp connection.
+ * @return the proxy type.
*/
- public ProxyType getProxyType(FileSystemOptions opts)
+ public ProxyType getProxyType()
{
- return (ProxyType) getParam(opts, "proxyType");
+ return (ProxyType) getParam("proxyType");
}
-}
+}
\ No newline at end of file
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java Sun Sep 13 06:26:23 2009
@@ -85,15 +85,11 @@
private final WebdavFileSystem fileSystem;
private final String urlCharset;
- /** The FileSystemConfigBuilder */
- private final WebdavFileSystemConfigBuilder builder;
-
protected WebdavFileObject(final FileName name, final WebdavFileSystem fileSystem)
{
super(name, fileSystem);
this.fileSystem = fileSystem;
- builder = (WebdavFileSystemConfigBuilder) WebdavFileSystemConfigBuilder.getInstance();
- this.urlCharset = builder.getUrlCharset(getFileSystem().getFileSystemOptions());
+ this.urlCharset = fileSystem.getFileSystemOptions().getUrlCharset();
}
protected void configureMethod(HttpMethodBase httpMethod)
@@ -569,7 +565,8 @@
RequestEntity entity = new StringRequestEntity(out.toString());
URLFileName fileName = (URLFileName) getName();
String urlStr = urlString(fileName);
- if (builder.isVersioning(getFileSystem().getFileSystemOptions()))
+ WebdavFileSystemOptions opts = fileSystem.getFileSystemOptions();
+ if (opts.isVersioning())
{
DavPropertySet set = null;
boolean fileExists = true;
@@ -622,7 +619,7 @@
method.setRequestEntity(entity);
setupMethod(method);
execute(method);
- setUserName(fileName, urlStr);
+ setUserName(fileName, urlStr, opts);
}
catch (FileSystemException ex)
{
@@ -664,7 +661,7 @@
execute(method);
try
{
- setUserName(fileName, urlStr);
+ setUserName(fileName, urlStr, opts);
}
catch (IOException e)
{
@@ -674,11 +671,12 @@
((DefaultFileContent) this.file.getContent()).resetAttributes();
}
- private void setUserName(URLFileName fileName, String urlStr)
+ private void setUserName(URLFileName fileName, String urlStr, WebdavFileSystemOptions opts)
throws IOException
{
List list = new ArrayList();
- String name = builder.getCreatorName(getFileSystem().getFileSystemOptions());
+
+ String name = opts.getCreatorName();
String userName = fileName.getUserName();
if (name == null)
{
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileProvider.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileProvider.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileProvider.java Sun Sep 13 06:26:23 2009
@@ -17,13 +17,7 @@
package org.apache.commons.vfs.provider.webdav;
import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.vfs.Capability;
-import org.apache.commons.vfs.FileName;
-import org.apache.commons.vfs.FileSystem;
-import org.apache.commons.vfs.FileSystemException;
-import org.apache.commons.vfs.FileSystemOptions;
-import org.apache.commons.vfs.UserAuthenticationData;
-import org.apache.commons.vfs.FileSystemConfigBuilder;
+import org.apache.commons.vfs.*;
import org.apache.commons.vfs.util.UserAuthenticatorUtils;
import org.apache.commons.vfs.provider.GenericFileName;
import org.apache.commons.vfs.provider.http.HttpFileProvider;
@@ -39,8 +33,7 @@
* @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
* @version $Revision$ $Date$
*/
-public class WebdavFileProvider
- extends HttpFileProvider
+public class WebdavFileProvider extends HttpFileProvider
{
/** The authenticator types used by the WebDAV provider. */
public static final UserAuthenticationData.Type[] AUTHENTICATOR_TYPES = new UserAuthenticationData.Type[]
@@ -66,11 +59,11 @@
Capability.DIRECTORY_READ_CONTENT,
}));
+ private static final Class<? extends FileSystemOptions> FSOPTIONS_CLASS = WebdavFileSystemOptions.class;
+
public WebdavFileProvider()
{
- super();
-
- setFileNameParser(WebdavFileNameParser.getInstance());
+ super(WebdavFileNameParser.getInstance(), FSOPTIONS_CLASS);
}
/**
* Creates a {@link FileSystem}.
@@ -89,7 +82,6 @@
authData = UserAuthenticatorUtils.authenticate(fsOpts, AUTHENTICATOR_TYPES);
httpClient = HttpClientFactory.createConnection(
- WebdavFileSystemConfigBuilder.getInstance(),
"http",
rootName.getHostName(),
rootName.getPort(),
@@ -104,7 +96,7 @@
UserAuthenticatorUtils.cleanup(authData);
}
- return new WebdavFileSystem(rootName, httpClient, fsOpts);
+ return new WebdavFileSystem(rootName, httpClient, fsOpts, FSOPTIONS_CLASS);
}
public FileSystemConfigBuilder getConfigBuilder()
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystem.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystem.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystem.java Sun Sep 13 06:26:23 2009
@@ -37,9 +37,10 @@
public class WebdavFileSystem extends HttpFileSystem implements FileSystem
{
protected WebdavFileSystem(final GenericFileName rootName, final HttpClient client,
- final FileSystemOptions fileSystemOptions)
+ final FileSystemOptions fileSystemOptions,
+ final Class<? extends FileSystemOptions> optionsClass)
{
- super(rootName, client, fileSystemOptions);
+ super(rootName, client, fileSystemOptions, optionsClass);
}
protected HttpClient getClient()
@@ -76,4 +77,9 @@
{
return new DefaultURLStreamHandler(getContext(), getFileSystemOptions());
}
+
+ public WebdavFileSystemOptions getFileSystemOptions()
+ {
+ return super.getOptions();
+ }
}
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystemConfigBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystemConfigBuilder.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystemConfigBuilder.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystemConfigBuilder.java Sun Sep 13 06:26:23 2009
@@ -24,6 +24,7 @@
*
* @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
* @version $Revision$ $Date$
+ * @deprecated Use WebdavFileSystemOptions instead.
*/
public final class WebdavFileSystemConfigBuilder extends HttpFileSystemConfigBuilder
{
@@ -46,7 +47,7 @@
*/
public void setCreatorName(FileSystemOptions opts, String creatorName)
{
- setParam(opts, "creatorName", creatorName);
+ WebdavFileSystemOptions.getInstance(opts).setCreatorName(creatorName);
}
/**
@@ -56,7 +57,7 @@
*/
public String getCreatorName(FileSystemOptions opts)
{
- return getString(opts, "creatorName");
+ return WebdavFileSystemOptions.getInstance(opts).getCreatorName();
}
/**
@@ -66,7 +67,7 @@
*/
public void setVersioning(FileSystemOptions opts, boolean versioning)
{
- setParam(opts, "versioning", Boolean.valueOf(versioning));
+ WebdavFileSystemOptions.getInstance(opts).setVersioning(versioning);
}
/**
@@ -76,7 +77,7 @@
*/
public boolean isVersioning(FileSystemOptions opts)
{
- return getBoolean(opts, "versioning", false);
+ return WebdavFileSystemOptions.getInstance(opts).isVersioning();
}
/**
Added: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystemOptions.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystemOptions.java?rev=814264&view=auto
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystemOptions.java (added)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystemOptions.java Sun Sep 13 06:26:23 2009
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+package org.apache.commons.vfs.provider.webdav;
+
+import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.provider.http.HttpFileSystemOptions;
+
+/**
+ * Webdav File System Options
+ * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
+ */
+public class WebdavFileSystemOptions extends HttpFileSystemOptions
+{
+ public WebdavFileSystemOptions()
+ {
+ this("webdav.");
+ }
+
+ protected WebdavFileSystemOptions(String scheme)
+ {
+ super(scheme);
+ }
+
+ public static WebdavFileSystemOptions getInstance(FileSystemOptions opts)
+ {
+ return FileSystemOptions.makeSpecific(WebdavFileSystemOptions.class, opts);
+ }
+
+ /**
+ * The user name to be associated with changes to the file.
+ * @param creatorName The creator name to be associated with the file.
+ */
+ public void setCreatorName(String creatorName)
+ {
+ setParam("creatorName", creatorName);
+ }
+
+ /**
+ * Return the user name to be associated with changes to the file.
+ * @return The creatorName.
+ */
+ public String getCreatorName()
+ {
+ return getString("creatorName");
+ }
+
+ /**
+ * Whether to use versioning.
+ * @param versioning true if versioning should be enabled.
+ */
+ public void setVersioning(boolean versioning)
+ {
+ setParam("versioning", Boolean.valueOf(versioning));
+ }
+
+ /**
+ * The cookies to add to the request.
+ * @return true if versioning is enabled.
+ */
+ public boolean isVersioning()
+ {
+ return getBoolean("versioning", false);
+ }
+}
\ No newline at end of file
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/util/UserAuthenticatorUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/util/UserAuthenticatorUtils.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/util/UserAuthenticatorUtils.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/util/UserAuthenticatorUtils.java Sun Sep 13 06:26:23 2009
@@ -19,7 +19,7 @@
import org.apache.commons.vfs.UserAuthenticator;
import org.apache.commons.vfs.UserAuthenticationData;
import org.apache.commons.vfs.FileSystemOptions;
-import org.apache.commons.vfs.impl.DefaultFileSystemConfigBuilder;
+import org.apache.commons.vfs.DefaultFileSystemOptions;
/**
* Some helper methods used for authentication.
@@ -64,7 +64,7 @@
public static UserAuthenticationData authenticate(FileSystemOptions opts,
UserAuthenticationData.Type[] authenticatorTypes)
{
- UserAuthenticator auth = DefaultFileSystemConfigBuilder.getInstance().getUserAuthenticator(opts);
+ UserAuthenticator auth = ((DefaultFileSystemOptions) opts).getUserAuthenticator();
return authenticate(auth, authenticatorTypes);
}
Modified: commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/ftp/test/FtpProviderTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/ftp/test/FtpProviderTestCase.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/ftp/test/FtpProviderTestCase.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/ftp/test/FtpProviderTestCase.java Sun Sep 13 06:26:23 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.
@@ -20,10 +20,9 @@
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSystemManager;
-import org.apache.commons.vfs.FileSystemOptions;
import org.apache.commons.vfs.impl.DefaultFileSystemManager;
import org.apache.commons.vfs.provider.ftp.FtpFileProvider;
-import org.apache.commons.vfs.provider.ftp.FtpFileSystemConfigBuilder;
+import org.apache.commons.vfs.provider.ftp.FtpFileSystemOptions;
import org.apache.commons.vfs.test.AbstractProviderTestConfig;
import org.apache.commons.vfs.test.ProviderTestConfig;
import org.apache.commons.vfs.test.ProviderTestSuite;
@@ -67,8 +66,8 @@
public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception
{
final String uri = System.getProperty(TEST_URI);
- FileSystemOptions opts = new FileSystemOptions();
- FtpFileSystemConfigBuilder.getInstance().setPassiveMode(opts, true);
+ FtpFileSystemOptions opts = new FtpFileSystemOptions();
+ opts.setPassiveMode(true);
return manager.resolveFile(uri, opts);
}
}
Modified: commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/ram/test/CustomRamProviderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/ram/test/CustomRamProviderTest.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/ram/test/CustomRamProviderTest.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/ram/test/CustomRamProviderTest.java Sun Sep 13 06:26:23 2009
@@ -25,22 +25,22 @@
import org.apache.commons.vfs.FileSystemOptions;
import org.apache.commons.vfs.impl.DefaultFileSystemManager;
import org.apache.commons.vfs.provider.ram.RamFileProvider;
-import org.apache.commons.vfs.provider.ram.RamFileSystemConfigBuilder;
+import org.apache.commons.vfs.provider.ram.RamFileSystemOptions;
/**
* Custom tests
- *
+ *
* @author edgar poce
* @version
- *
+ *
*/
public class CustomRamProviderTest extends TestCase
{
DefaultFileSystemManager manager;
- FileSystemOptions zeroSized = new FileSystemOptions();
+ RamFileSystemOptions zeroSized = new RamFileSystemOptions();
- FileSystemOptions smallSized = new FileSystemOptions();
+ RamFileSystemOptions smallSized = new RamFileSystemOptions();
FileSystemOptions defaultRamFs = new FileSystemOptions();
@@ -53,8 +53,8 @@
manager.init();
// File Systems Options
- RamFileSystemConfigBuilder.getInstance().setMaxSize(zeroSized, 0);
- RamFileSystemConfigBuilder.getInstance().setMaxSize(smallSized, 10);
+ zeroSized.setMaxSize(0);
+ smallSized.setMaxSize(10);
}
protected void tearDown() throws Exception
@@ -107,9 +107,9 @@
}
/**
- *
+ *
* Checks root folder exists
- *
+ *
* @throws FileSystemException
*/
public void testRootFolderExists() throws FileSystemException {
@@ -120,10 +120,10 @@
root.delete();
fail();
} catch (FileSystemException e) {
-
+
}
}
-
+
}
Modified: commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/sftp/test/SftpProviderTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/sftp/test/SftpProviderTestCase.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/sftp/test/SftpProviderTestCase.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/sftp/test/SftpProviderTestCase.java Sun Sep 13 06:26:23 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.
@@ -19,11 +19,10 @@
import junit.framework.Test;
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSystemManager;
-import org.apache.commons.vfs.FileSystemOptions;
import org.apache.commons.vfs.impl.DefaultFileSystemManager;
import org.apache.commons.vfs.provider.sftp.SftpFileProvider;
-import org.apache.commons.vfs.provider.sftp.SftpFileSystemConfigBuilder;
import org.apache.commons.vfs.provider.sftp.TrustEveryoneUserInfo;
+import org.apache.commons.vfs.provider.sftp.SftpFileSystemOptions;
import org.apache.commons.vfs.test.AbstractProviderTestConfig;
import org.apache.commons.vfs.test.ProviderTestSuite;
@@ -65,9 +64,9 @@
{
final String uri = System.getProperty(TEST_URI);
- FileSystemOptions fileSystemOptions = new FileSystemOptions();
- SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(fileSystemOptions, "no");
- SftpFileSystemConfigBuilder.getInstance().setUserInfo(fileSystemOptions, new TrustEveryoneUserInfo());
+ SftpFileSystemOptions fileSystemOptions = new SftpFileSystemOptions();
+ fileSystemOptions.setStrictHostKeyChecking("no");
+ fileSystemOptions.setUserInfo(new TrustEveryoneUserInfo());
return manager.resolveFile(uri, fileSystemOptions);
}
Modified: commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/webdav/test/WebdavProviderTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/webdav/test/WebdavProviderTestCase.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/webdav/test/WebdavProviderTestCase.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/webdav/test/WebdavProviderTestCase.java Sun Sep 13 06:26:23 2009
@@ -19,11 +19,10 @@
import junit.framework.Test;
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSystemManager;
-import org.apache.commons.vfs.FileSystemOptions;
import org.apache.commons.vfs.impl.DefaultFileSystemManager;
import org.apache.commons.vfs.provider.temp.TemporaryFileProvider;
import org.apache.commons.vfs.provider.webdav.WebdavFileProvider;
-import org.apache.commons.vfs.provider.webdav.WebdavFileSystemConfigBuilder;
+import org.apache.commons.vfs.provider.webdav.WebdavFileSystemOptions;
import org.apache.commons.vfs.test.AbstractProviderTestConfig;
import org.apache.commons.vfs.test.ProviderTestSuite;
@@ -67,11 +66,9 @@
public FileObject getBaseTestFolder(final FileSystemManager manager)
throws Exception
{
- WebdavFileSystemConfigBuilder builder =
- (WebdavFileSystemConfigBuilder)manager.getFileSystemConfigBuilder("webdav");
final String uri = System.getProperty(TEST_URI);
- FileSystemOptions opts = new FileSystemOptions();
- builder.setRootURI(opts, uri);
+ WebdavFileSystemOptions opts = new WebdavFileSystemOptions();
+ opts.setRootURI(uri);
return manager.resolveFile(uri, opts);
}
}
Modified: commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/webdav/test/WebdavVersioningTests.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/webdav/test/WebdavVersioningTests.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/webdav/test/WebdavVersioningTests.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/webdav/test/WebdavVersioningTests.java Sun Sep 13 06:26:23 2009
@@ -23,7 +23,7 @@
import org.apache.commons.vfs.FileSystemOptions;
import org.apache.commons.vfs.FileType;
import org.apache.commons.vfs.Selectors;
-import org.apache.commons.vfs.provider.webdav.WebdavFileSystemConfigBuilder;
+import org.apache.commons.vfs.provider.webdav.WebdavFileSystemOptions;
import org.apache.commons.vfs.provider.URLFileName;
import org.apache.commons.vfs.test.AbstractProviderTestCase;
import org.apache.jackrabbit.webdav.version.DeltaVConstants;
@@ -40,14 +40,13 @@
public void testVersioning() throws Exception
{
FileObject scratchFolder = createScratchFolder();
- FileSystemOptions opts = scratchFolder.getFileSystem().getFileSystemOptions();
- WebdavFileSystemConfigBuilder builder =
- (WebdavFileSystemConfigBuilder)getManager().getFileSystemConfigBuilder("webdav");
- builder.setVersioning(opts, true);
+ WebdavFileSystemOptions opts =
+ WebdavFileSystemOptions.getInstance(scratchFolder.getFileSystem().getFileSystemOptions());
+ opts.setVersioning(true);
FileObject file = getManager().resolveFile(scratchFolder, "file1.txt", opts);
FileSystemOptions newOpts = file.getFileSystem().getFileSystemOptions();
assertTrue(opts == newOpts);
- assertTrue(builder.isVersioning(newOpts));
+ assertTrue(opts.isVersioning());
assertTrue(!file.exists());
file.createFile();
assertTrue(file.exists());
@@ -86,7 +85,7 @@
assertEquals(name, map.get(DeltaVConstants.CREATOR_DISPLAYNAME.toString()));
}
assertTrue(map.containsKey(VersionControlledResource.CHECKED_IN.toString()));
- builder.setVersioning(opts, false);
+ opts.setVersioning(false);
}
/**
*
@@ -94,15 +93,14 @@
public void testVersioningWithCreator() throws Exception
{
FileObject scratchFolder = createScratchFolder();
- FileSystemOptions opts = scratchFolder.getFileSystem().getFileSystemOptions();
- WebdavFileSystemConfigBuilder builder =
- (WebdavFileSystemConfigBuilder)getManager().getFileSystemConfigBuilder("webdav");
- builder.setVersioning(opts, true);
- builder.setCreatorName(opts, "testUser");
+ WebdavFileSystemOptions opts =
+ WebdavFileSystemOptions.getInstance(scratchFolder.getFileSystem().getFileSystemOptions());
+ opts.setVersioning(true);
+ opts.setCreatorName("testUser");
FileObject file = getManager().resolveFile(scratchFolder, "file1.txt", opts);
FileSystemOptions newOpts = file.getFileSystem().getFileSystemOptions();
assertTrue(opts == newOpts);
- assertTrue(builder.isVersioning(newOpts));
+ assertTrue(opts.isVersioning());
assertTrue(!file.exists());
file.createFile();
assertTrue(file.exists());
@@ -143,11 +141,11 @@
{
assertTrue(map.containsKey(DeltaVConstants.COMMENT.toString()));
assertEquals("Modified by user " + name, map.get(DeltaVConstants.COMMENT.toString()));
- }
+ }
assertTrue(map.containsKey(VersionControlledResource.CHECKED_IN.toString()));
- builder.setVersioning(opts, false);
- builder.setCreatorName(opts, null);
- }
+ opts.setVersioning(false);
+ opts.setCreatorName(null);
+ }
/**
* Sets up a scratch folder for the test to use.
*/
Modified: commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/util/DelegatingFileSystemOptionsBuilderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/util/DelegatingFileSystemOptionsBuilderTest.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/util/DelegatingFileSystemOptionsBuilderTest.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/util/DelegatingFileSystemOptionsBuilderTest.java Sun Sep 13 06:26:23 2009
@@ -21,15 +21,17 @@
import org.apache.commons.vfs.FileSystemOptions;
import org.apache.commons.vfs.impl.StandardFileSystemManager;
import org.apache.commons.vfs.provider.http.HttpFileSystemConfigBuilder;
+import org.apache.commons.vfs.provider.http.HttpFileSystemOptions;
import org.apache.commons.vfs.provider.sftp.SftpFileSystemConfigBuilder;
import org.apache.commons.vfs.provider.sftp.TrustEveryoneUserInfo;
+import org.apache.commons.vfs.provider.sftp.SftpFileSystemOptions;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
/**
* Some tests for the DelegatingFileSystemOptionsBuilder
- *
+ *
* @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
* @version $Revision$ $Date$
*/
@@ -59,35 +61,37 @@
public void testDelegatingGood() throws Throwable
{
- final String[] identityPaths = new String[]
+ final File[] identityPaths = new File[]
{
- "/file1",
- "/file2",
+ new File("/file1"),
+ new File("/file2"),
};
FileSystemOptions opts = new FileSystemOptions();
- DelegatingFileSystemOptionsBuilder delgate = new DelegatingFileSystemOptionsBuilder(fsm);
+ HttpFileSystemOptions httpOpts = HttpFileSystemOptions.getInstance(opts);
+ SftpFileSystemOptions sftpOpts = SftpFileSystemOptions.getInstance(opts);
- delgate.setConfigString(opts, "http", "proxyHost", "proxy");
- delgate.setConfigString(opts, "http", "proxyPort", "8080");
- delgate.setConfigClass(opts, "sftp", "userinfo", TrustEveryoneUserInfo.class);
- delgate.setConfigStrings(opts, "sftp", "identities", identityPaths);
-
- assertEquals("http.proxyHost", HttpFileSystemConfigBuilder.getInstance().getProxyHost(opts), "proxy");
- assertEquals("http.proxyPort", HttpFileSystemConfigBuilder.getInstance().getProxyPort(opts), 8080);
- assertEquals("sftp.userInfo", SftpFileSystemConfigBuilder.getInstance().getUserInfo(opts).getClass(), TrustEveryoneUserInfo.class);
+ httpOpts.setProxyHost("proxy");
+ httpOpts.setProxyPort(8080);
+ sftpOpts.setUserInfo(new TrustEveryoneUserInfo());
+ sftpOpts.setIdentities(identityPaths);
+
+ assertEquals("http.proxyHost", httpOpts.getProxyHost(), "proxy");
+ assertEquals("http.proxyPort", httpOpts.getProxyPort(), 8080);
+ assertEquals("sftp.userInfo", sftpOpts.getUserInfo().getClass(), TrustEveryoneUserInfo.class);
- File identities[] = SftpFileSystemConfigBuilder.getInstance().getIdentities(opts);
+ File identities[] = sftpOpts.getIdentities();
assertNotNull("sftp.identities", identities);
assertEquals("sftp.identities size", identities.length, identityPaths.length);
for (int iterIdentities = 0; iterIdentities < identities.length; iterIdentities++)
{
assertEquals("sftp.identities #" + iterIdentities,
identities[iterIdentities].getAbsolutePath(),
- new File(identityPaths[iterIdentities]).getAbsolutePath());
+ identityPaths[iterIdentities].getAbsolutePath());
}
}
+ /* Unnecessary when using FileSystem instances. This will be verified by the compiler.
public void testDelegatingBad() throws Throwable
{
FileSystemOptions opts = new FileSystemOptions();
@@ -95,6 +99,7 @@
try
{
+
delgate.setConfigString(opts, "http", "proxyPort", "wrong_port");
fail();
}
@@ -113,7 +118,7 @@
{
assertEquals(e.getCode(), "vfs.provider/config-value-invalid.error");
}
- }
+ } */
private static String[] schemes = new String[]
{
Modified: commons/proper/vfs/branches/VFS281/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/pom.xml?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/pom.xml (original)
+++ commons/proper/vfs/branches/VFS281/pom.xml Sun Sep 13 06:26:23 2009
@@ -123,8 +123,8 @@
<commons.binary.suffix></commons.binary.suffix>
<commons.jira.id>VFS</commons.jira.id>
<commons.jira.pid>12310495</commons.jira.pid>
- <maven.compile.source>1.4</maven.compile.source>
- <maven.compile.target>1.4</maven.compile.target>
+ <maven.compile.source>1.5</maven.compile.source>
+ <maven.compile.target>1.5</maven.compile.target>
</properties>
<build>