You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2012/06/27 17:00:24 UTC
svn commit: r1354565 - in /commons/proper/vfs/trunk:
core/src/main/java/org/apache/commons/vfs2/
core/src/main/java/org/apache/commons/vfs2/cache/
core/src/main/java/org/apache/commons/vfs2/impl/
core/src/main/java/org/apache/commons/vfs2/provider/ cor...
Author: ggregory
Date: Wed Jun 27 15:00:21 2012
New Revision: 1354565
URL: http://svn.apache.org/viewvc?rev=1354565&view=rev
Log:
[VFS-425] Add API FileObject.isExecutable().
Added:
commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/local/test/PermissionsTests.java (with props)
Modified:
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/FileObject.java
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/Resources.properties
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/cache/OnCallRefreshFileObject.java
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/impl/DecoratedFileObject.java
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/DelegateFileObject.java
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/local/LocalFile.java
commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/local/test/LocalProviderTestCase.java
commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/webdav/test/WebdavVersioningTests.java
commons/proper/vfs/trunk/src/changes/changes.xml
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/FileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/FileObject.java?rev=1354565&r1=1354564&r2=1354565&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/FileObject.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/FileObject.java Wed Jun 27 15:00:21 2012
@@ -102,6 +102,14 @@ public interface FileObject extends Comp
boolean exists() throws FileSystemException;
/**
+ * Determines if this file is executable.
+ *
+ * @return <code>true</code> if this file is executable, <code>false</code> if not.
+ * @throws FileSystemException On error determining if this file exists.
+ */
+ boolean isExecutable() throws FileSystemException;
+
+ /**
* Determines if this file is hidden.
*
* @return <code>true</code> if this file is hidden, <code>false</code> if not.
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/Resources.properties
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/Resources.properties?rev=1354565&r1=1354564&r2=1354565&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/Resources.properties (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/Resources.properties Wed Jun 27 15:00:21 2012
@@ -53,6 +53,7 @@ vfs.provider/rename-filename.error=You c
vfs.provider/copy-read-only.error=Could not copy {0} "{1}" to "{2}" because the destination file is read-only.
vfs.provider/copy-missing-file.error=Could not copy "{0}" because it does not exist.
vfs.provider/find-files.error=Could not find files in "{0}".
+vfs.provider/check-is-executable.error=Could not determine if file "{0}" is executable.
vfs.provider/check-is-hidden.error=Could not determine if file "{0}" is hidden.
vfs.provider/check-is-writeable.error=Could not determine if file "{0}" is writeable.
vfs.provider/check-is-readable.error=Could not determine if file "{0}" is readable.
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/cache/OnCallRefreshFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/cache/OnCallRefreshFileObject.java?rev=1354565&r1=1354564&r2=1354565&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/cache/OnCallRefreshFileObject.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/cache/OnCallRefreshFileObject.java Wed Jun 27 15:00:21 2012
@@ -129,6 +129,13 @@ public class OnCallRefreshFileObject ext
}
@Override
+ public boolean isExecutable() throws FileSystemException
+ {
+ refresh();
+ return super.isExecutable();
+ }
+
+ @Override
public boolean isHidden() throws FileSystemException
{
refresh();
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/impl/DecoratedFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/impl/DecoratedFileObject.java?rev=1354565&r1=1354564&r2=1354565&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/impl/DecoratedFileObject.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/impl/DecoratedFileObject.java Wed Jun 27 15:00:21 2012
@@ -144,6 +144,11 @@ public class DecoratedFileObject impleme
return decoratedFileObject.getURL();
}
+ public boolean isExecutable() throws FileSystemException
+ {
+ return decoratedFileObject.isExecutable();
+ }
+
public boolean isHidden() throws FileSystemException
{
return decoratedFileObject.isHidden();
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java?rev=1354565&r1=1354564&r2=1354565&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java Wed Jun 27 15:00:21 2012
@@ -137,6 +137,19 @@ public abstract class AbstractFileObject
protected abstract FileType doGetType() throws Exception;
/**
+ * Determines if this file is executable. Is only called if {@link #doGetType}
+ * does not return {@link FileType#IMAGINARY}.
+ * <p/>
+ * This implementation always returns false.
+ * @return true if the file is executable, false otherwise.
+ * @throws Exception if an error occurs.
+ */
+ protected boolean doIsExecutable() throws Exception
+ {
+ return false;
+ }
+
+ /**
* Determines if this file is hidden. Is only called if {@link #doGetType}
* does not return {@link FileType#IMAGINARY}.
* <p/>
@@ -537,6 +550,29 @@ public abstract class AbstractFileObject
}
/**
+ * Determines if this file is executable.
+ *
+ * @return <code>true</code> if this file is executable, <code>false</code> if not.
+ * @throws FileSystemException On error determining if this file exists.
+ */
+ public boolean isExecutable() throws FileSystemException
+ {
+ try
+ {
+ if (exists())
+ {
+ return doIsExecutable();
+ } else
+ {
+ return false;
+ }
+ } catch (final Exception exc)
+ {
+ throw new FileSystemException("vfs.provider/check-is-executable.error", name, exc);
+ }
+ }
+
+ /**
* Determines if this file can be read.
* @return true if the file is a hidden file, false otherwise.
* @throws FileSystemException if an error occurs.
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/DelegateFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/DelegateFileObject.java?rev=1354565&r1=1354564&r2=1354565&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/DelegateFileObject.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/DelegateFileObject.java Wed Jun 27 15:00:21 2012
@@ -174,6 +174,22 @@ public class DelegateFileObject extends
}
/**
+ * Determines if this file is executable.
+ */
+ @Override
+ protected boolean doIsExecutable() throws FileSystemException
+ {
+ if (file != null)
+ {
+ return file.isExecutable();
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
* Determines if this file is hidden.
*/
@Override
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/local/LocalFile.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/local/LocalFile.java?rev=1354565&r1=1354564&r2=1354565&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/local/LocalFile.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/local/LocalFile.java Wed Jun 27 15:00:21 2012
@@ -165,6 +165,15 @@ public class LocalFile extends AbstractF
* Determines if this file is hidden.
*/
@Override
+ protected boolean doIsExecutable()
+ {
+ return file.canExecute();
+ }
+
+ /**
+ * Determines if this file is hidden.
+ */
+ @Override
protected boolean doIsHidden()
{
return file.isHidden();
Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/local/test/LocalProviderTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/local/test/LocalProviderTestCase.java?rev=1354565&r1=1354564&r2=1354565&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/local/test/LocalProviderTestCase.java (original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/local/test/LocalProviderTestCase.java Wed Jun 27 15:00:21 2012
@@ -40,10 +40,11 @@ public class LocalProviderTestCase
public static Test suite() throws Exception
{
final ProviderTestSuite testSuite = new ProviderTestSuite(new LocalProviderTestCase());
+
testSuite.addTests(FileNameTests.class);
-
// VFS-325
testSuite.addTests(UrlTests.class);
+ testSuite.addTests(PermissionsTests.class);
return testSuite;
}
Added: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/local/test/PermissionsTests.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/local/test/PermissionsTests.java?rev=1354565&view=auto
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/local/test/PermissionsTests.java (added)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/local/test/PermissionsTests.java Wed Jun 27 15:00:21 2012
@@ -0,0 +1,38 @@
+/*
+ * 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.vfs2.provider.local.test;
+
+import junit.framework.Assert;
+
+import org.apache.commons.vfs2.FileObject;
+import org.apache.commons.vfs2.test.AbstractProviderTestCase;
+
+/**
+ * Additional naming tests for local file system.
+ */
+public class PermissionsTests extends AbstractProviderTestCase
+{
+ /**
+ * Tests that test read folder is executable.
+ */
+ public void testFolderIsExecutable() throws Exception
+ {
+ final FileObject folder = this.getReadFolder().resolveFile("file1.txt");
+ Assert.assertTrue(folder.isExecutable());
+ }
+
+}
Propchange: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/local/test/PermissionsTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/local/test/PermissionsTests.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/webdav/test/WebdavVersioningTests.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/webdav/test/WebdavVersioningTests.java?rev=1354565&r1=1354564&r2=1354565&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/webdav/test/WebdavVersioningTests.java (original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/webdav/test/WebdavVersioningTests.java Wed Jun 27 15:00:21 2012
@@ -53,6 +53,7 @@ public class WebdavVersioningTests exten
assertSame(FileType.FILE, file.getType());
assertTrue(file.isFile());
assertEquals(0, file.getContent().getSize());
+ assertFalse(file.isExecutable());
assertFalse(file.isHidden());
assertTrue(file.isReadable());
assertTrue(file.isWriteable());
@@ -107,6 +108,7 @@ public class WebdavVersioningTests exten
assertSame(FileType.FILE, file.getType());
assertTrue(file.isFile());
assertEquals(0, file.getContent().getSize());
+ assertFalse(file.isExecutable());
assertFalse(file.isHidden());
assertTrue(file.isReadable());
assertTrue(file.isWriteable());
Modified: commons/proper/vfs/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/src/changes/changes.xml?rev=1354565&r1=1354564&r2=1354565&view=diff
==============================================================================
--- commons/proper/vfs/trunk/src/changes/changes.xml (original)
+++ commons/proper/vfs/trunk/src/changes/changes.xml Wed Jun 27 15:00:21 2012
@@ -22,7 +22,10 @@
</properties>
<body>
- <release version="2.1" date="TBD" description="">
+ <release version="2.1" date="TBD" description="New features and bug fix release.">
+ <action issue="VFS-425" dev="ggregory" type="add" due-to="ggregory">
+ Add API FileObject.isExecutable().
+ </action>
<action issue="VFS-421" dev="ggregory" type="add" due-to="bpiwowar">
[SFTP] Configure a custom Identity Repository.
</action>