This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git

commit aad49eb24f5f92141e6f60c7b8e82a795d549868
Author: Gary Gregory <gardgreg...@gmail.com>
AuthorDate: Thu Jul 30 10:52:22 2020 -0400

    Move test method as new PathUtils.getAclEntryList(Path).
---
 src/changes/changes.xml                               |  3 +++
 .../java/org/apache/commons/io/file/PathUtils.java    | 16 ++++++++++++++++
 .../io/FileUtilsCopyDirectoryToDirectoryTestCase.java | 19 ++-----------------
 3 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 14f3812..f0d59ea 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -86,6 +86,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action issue="IO-679" dev="ggregory" type="fix" due-to="proneel">
         input.AbstractCharacterFilterReader passes count of chars read #132.
       </action>
+      <action dev="ggregory" type="add" due-to="Gary Gregory">
+        Add PathUtils.getAclEntryList(Path).
+      </action>
       <action dev="ggregory" type="fix" due-to="Gary Gregory">
         Replace FindBugs with SpotBugs.
       </action>
diff --git a/src/main/java/org/apache/commons/io/file/PathUtils.java 
b/src/main/java/org/apache/commons/io/file/PathUtils.java
index 4789a7e..08ab40a 100644
--- a/src/main/java/org/apache/commons/io/file/PathUtils.java
+++ b/src/main/java/org/apache/commons/io/file/PathUtils.java
@@ -31,6 +31,8 @@ import java.nio.file.NotDirectoryException;
 import java.nio.file.OpenOption;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.nio.file.attribute.AclEntry;
+import java.nio.file.attribute.AclFileAttributeView;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -480,6 +482,20 @@ public final class PathUtils {
     }
 
     /**
+     * Reads the access control list from a file attribute view.
+     *
+     * @param sourcePath the path to the file.
+     * @return a file attribute view of the specified type, or null ifthe 
attribute view type is not available.
+     * @throws IOException if an I/O error occurs.
+     * @since 2.8.0
+     */
+    public static List<AclEntry> getAclEntryList(final Path sourcePath) throws 
IOException {
+        final AclFileAttributeView fileAttributeView = 
Files.getFileAttributeView(sourcePath,
+            AclFileAttributeView.class);
+        return fileAttributeView == null ? null : fileAttributeView.getAcl();
+    }
+
+    /**
      * Returns whether the given file or directory is empty.
      *
      * @param path the the given file or directory to query.
diff --git 
a/src/test/java/org/apache/commons/io/FileUtilsCopyDirectoryToDirectoryTestCase.java
 
b/src/test/java/org/apache/commons/io/FileUtilsCopyDirectoryToDirectoryTestCase.java
index 225082b..7811963 100644
--- 
a/src/test/java/org/apache/commons/io/FileUtilsCopyDirectoryToDirectoryTestCase.java
+++ 
b/src/test/java/org/apache/commons/io/FileUtilsCopyDirectoryToDirectoryTestCase.java
@@ -25,10 +25,8 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.StandardCopyOption;
-import java.nio.file.attribute.AclEntry;
-import java.nio.file.attribute.AclFileAttributeView;
-import java.util.List;
 
+import org.apache.commons.io.file.PathUtils;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.io.TempDir;
 
@@ -58,7 +56,7 @@ public class FileUtilsCopyDirectoryToDirectoryTestCase {
     public File temporaryFolder;
 
     private void assertAcl(final Path sourcePath, final Path destPath) throws 
IOException {
-        assertEquals(getAclEntryList(sourcePath), getAclEntryList(destPath));
+        assertEquals(PathUtils.getAclEntryList(sourcePath), 
PathUtils.getAclEntryList(destPath));
     }
 
     @Test
@@ -116,17 +114,4 @@ public class FileUtilsCopyDirectoryToDirectoryTestCase {
             StandardCopyOption.COPY_ATTRIBUTES);
         assertAcl(sourcePath, destPath);
     }
-
-    /**
-     * Gets a a file attribute view.
-     *
-     * @param sourcePath the path to the file.
-     * @return a file attribute view of the specified type, or null ifthe 
attribute view type is not available.
-     * @throws IOException if an I/O error occurs.
-     */
-    private List<AclEntry> getAclEntryList(final Path sourcePath) throws 
IOException {
-        final AclFileAttributeView fileAttributeView = 
Files.getFileAttributeView(sourcePath,
-            AclFileAttributeView.class);
-        return fileAttributeView == null ? null : fileAttributeView.getAcl();
-    }
 }

Reply via email to