[java-opensaml] 03/04: Refactor new expired metadata logging for cyclomatic complexity.

Brent Putman putmanb at georgetown.edu
Wed May 10 19:39:47 EDT 2017


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

putmanb pushed a commit to branch master
in repository java-opensaml.

View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=f7bf1a8f5961fb0e09034bf8f1ab94739784a079

commit f7bf1a8f5961fb0e09034bf8f1ab94739784a079
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Wed May 10 19:08:41 2017 -0400

    Refactor new expired metadata logging for cyclomatic complexity.
---
 .../impl/AbstractReloadingMetadataResolver.java    | 47 +++++++++++++---------
 1 file changed, 29 insertions(+), 18 deletions(-)

diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractReloadingMetadataResolver.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractReloadingMetadataResolver.java
index a4acb57..4c2f666 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractReloadingMetadataResolver.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractReloadingMetadataResolver.java
@@ -24,6 +24,7 @@ import java.io.InputStream;
 import java.util.Timer;
 import java.util.TimerTask;
 
+import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import net.shibboleth.utilities.java.support.annotation.Duration;
@@ -359,24 +360,7 @@ public abstract class AbstractReloadingMetadataResolver extends AbstractBatchMet
                         t.getClass().getName(), t.getMessage()));
             }
         } finally {
-            final XMLObject cached = getBackingStore().getCachedOriginalMetadata();
-            if (cached != null && !isValid(cached)) {
-                log.warn("{} Metadata root from '{}' currently live (post-refresh) is expired or otherwise invalid", 
-                        getLogPrefix(), mdId);
-            } else if (cached instanceof TimeBoundSAMLObject) {
-                final TimeBoundSAMLObject timebound = (TimeBoundSAMLObject) cached;
-                if (isRequireValidMetadata() && timebound.getValidUntil()  != null) {
-                    if (timebound.getValidUntil().isBefore(now.plus(getExpirationWarningThreshold()))) {
-                        log.warn("{} Metadata root from '{}' currently live (post-refresh) will expire " 
-                                + "within the configured threshhold at '{}'", 
-                                getLogPrefix(), mdId, timebound.getValidUntil());
-                    } else if (timebound.getValidUntil().isBefore(nextRefresh)) {
-                        log.warn("{} Metadata root from '{}' currently live (post-refresh) will expire " 
-                                + "at '{}' before the next refresh scheduled for {}'", 
-                                getLogPrefix(), mdId, timebound.getValidUntil(), nextRefresh);
-                    }
-                }
-            }
+            logCachedMetadataExpiration(now);
             
             if (trackRefreshSuccess) {
                 wasLastRefreshSuccess = true;
@@ -396,6 +380,33 @@ public abstract class AbstractReloadingMetadataResolver extends AbstractBatchMet
     }
 
     /**
+     * Check cached metadata for expiration or pending expiration and log appropriately.
+     *
+     * @param now the current date/time
+     */
+    private void logCachedMetadataExpiration(@Nonnull final DateTime now) {
+        final String mdId = getMetadataIdentifier();
+        final XMLObject cached = getBackingStore().getCachedOriginalMetadata();
+        if (cached != null && !isValid(cached)) {
+            log.warn("{} Metadata root from '{}' currently live (post-refresh) is expired or otherwise invalid",
+                    getLogPrefix(), mdId);
+        } else if (cached instanceof TimeBoundSAMLObject) {
+            final TimeBoundSAMLObject timebound = (TimeBoundSAMLObject) cached;
+            if (isRequireValidMetadata() && timebound.getValidUntil() != null) {
+                if (timebound.getValidUntil().isBefore(now.plus(getExpirationWarningThreshold()))) {
+                    log.warn("{} Metadata root from '{}' currently live (post-refresh) will expire "
+                            + "within the configured threshhold at '{}'",
+                            getLogPrefix(), mdId, timebound.getValidUntil());
+                } else if (timebound.getValidUntil().isBefore(nextRefresh)) {
+                    log.warn("{} Metadata root from '{}' currently live (post-refresh) will expire "
+                            + "at '{}' before the next refresh scheduled for {}'",
+                            getLogPrefix(), mdId, timebound.getValidUntil(), nextRefresh);
+                }
+            }
+        }
+    }
+
+    /**
      * Gets an identifier which may be used to distinguish this metadata in logging statements.
      * 
      * @return identifier which may be used to distinguish this metadata in logging statements

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


More information about the commits mailing list