[java-shib-shared] branch main updated: Add isFile method to our Resource interface.

Scott Cantor cantor.2 at osu.edu
Thu Jun 15 18:01:57 UTC 2023


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository java-shib-shared.

View the commit online:
http://git.shibboleth.net/view/?p=java-shib-shared.git;a=commit;h=9cbe17488abc9e7c0b88b61dc0f7cbb8542e7852

The following commit(s) were added to refs/heads/main by this push:
     new 9cbe1748 Add isFile method to our Resource interface.
9cbe1748 is described below

commit 9cbe17488abc9e7c0b88b61dc0f7cbb8542e7852
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Jun 15 14:01:54 2023 -0400

    Add isFile method to our Resource interface.
---
 .../shared/spring/resource/ConditionalResource.java  |  7 +++++++
 .../shared/spring/resource/ResourceHelper.java       |  5 +++++
 .../net/shibboleth/shared/resource/Resource.java     | 20 ++++++++++++++++++--
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/shib-spring/src/main/java/net/shibboleth/shared/spring/resource/ConditionalResource.java b/shib-spring/src/main/java/net/shibboleth/shared/spring/resource/ConditionalResource.java
index e4c096e2..83cd5bd6 100644
--- a/shib-spring/src/main/java/net/shibboleth/shared/spring/resource/ConditionalResource.java
+++ b/shib-spring/src/main/java/net/shibboleth/shared/spring/resource/ConditionalResource.java
@@ -145,6 +145,13 @@ public class ConditionalResource extends AbstractIdentifiedInitializableComponen
         return true;
     }
 
+    /** {@inheritDoc} */
+    public boolean isFile() {
+        checkComponentActive();
+        
+        return wrappedResource.isFile();
+    }
+
     /** {@inheritDoc} */
     public boolean isReadable() {
         checkComponentActive();
diff --git a/shib-spring/src/main/java/net/shibboleth/shared/spring/resource/ResourceHelper.java b/shib-spring/src/main/java/net/shibboleth/shared/spring/resource/ResourceHelper.java
index eeb59775..74bf58aa 100644
--- a/shib-spring/src/main/java/net/shibboleth/shared/spring/resource/ResourceHelper.java
+++ b/shib-spring/src/main/java/net/shibboleth/shared/spring/resource/ResourceHelper.java
@@ -75,6 +75,11 @@ public final class ResourceHelper implements net.shibboleth.shared.resource.Reso
         return springResource.exists();
     }
 
+    /** {@inheritDoc} */
+    public boolean isFile() {
+        return springResource.isFile();
+    }
+
     /** {@inheritDoc} */
     public boolean isReadable() {
         return springResource.isReadable();
diff --git a/shib-support/src/main/java/net/shibboleth/shared/resource/Resource.java b/shib-support/src/main/java/net/shibboleth/shared/resource/Resource.java
index 4371feb8..22d4aa27 100644
--- a/shib-support/src/main/java/net/shibboleth/shared/resource/Resource.java
+++ b/shib-support/src/main/java/net/shibboleth/shared/resource/Resource.java
@@ -48,6 +48,22 @@ public interface Resource {
      */
     boolean exists();
 
+    /**
+     * Determine whether this resource represents a file in a file system.
+     * 
+     * <p>A value of {@code true} strongly suggests (but does not guarantee)
+     * that a {@link #getFile()} call will succeed.</p>
+     * 
+     * <p>This is conservatively {@code false} by default.</p>
+     * 
+     * @return true iff this resource represents a file in a file system
+     * 
+     * @since 9.0.0
+     */
+    default boolean isFile() {
+        return false;
+    }
+    
     /**
      * Return whether the contents of this resource can be read, e.g. via {@link #getInputStream()} or
      * {@link #getFile()}.
@@ -87,7 +103,7 @@ public interface Resource {
      * @return a URI handle for this resource.
      */
     @Nonnull URI getURI() throws IOException;
-
+    
     /**
      * Return a File handle for this resource.
      * 
@@ -157,4 +173,4 @@ public interface Resource {
      */
     @Nonnull  String getDescription();
 
-}
+}
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list