[java-identity-provider] branch master updated: IDP-1177 - Centralize deprecation warnings through dedicated function

Scott Cantor cantor.2 at osu.edu
Fri Jun 2 17:01:05 EDT 2017


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

scantor pushed a commit to branch master
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=98572b74a88a78ec289618787f89c58e6aba5c90

The following commit(s) were added to refs/heads/master by this push:
       new  98572b7   IDP-1177 - Centralize deprecation warnings through dedicated function
98572b7 is described below

commit 98572b74a88a78ec289618787f89c58e6aba5c90
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Fri Jun 2 17:01:02 2017 -0400

    IDP-1177 - Centralize deprecation warnings through dedicated function
    
    https://issues.shibboleth.net/jira/browse/IDP-1177
    
    Replace earlier deprecation warnings.
---
 .../spring/impl/AbstractWarningFilterParser.java   | 38 ++++------------------
 1 file changed, 7 insertions(+), 31 deletions(-)

diff --git a/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/impl/AbstractWarningFilterParser.java b/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/impl/AbstractWarningFilterParser.java
index 4ac5c1e..0e56d4d 100644
--- a/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/impl/AbstractWarningFilterParser.java
+++ b/idp-attribute-filter-spring/src/main/java/net/shibboleth/idp/attribute/filter/spring/impl/AbstractWarningFilterParser.java
@@ -23,10 +23,10 @@ import javax.xml.namespace.QName;
 import net.shibboleth.idp.attribute.filter.spring.BaseFilterParser;
 import net.shibboleth.idp.attribute.filter.spring.basic.impl.AttributeFilterBasicNamespaceHandler;
 import net.shibboleth.idp.attribute.filter.spring.saml.impl.AttributeFilterSAMLNamespaceHandler;
+import net.shibboleth.utilities.java.support.primitive.DeprecationSupport;
+import net.shibboleth.utilities.java.support.primitive.DeprecationSupport.ObjectType;
 import net.shibboleth.utilities.java.support.xml.DOMTypeSupport;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 import org.springframework.beans.factory.xml.ParserContext;
 import org.w3c.dom.Element;
@@ -38,39 +38,14 @@ import org.w3c.dom.Element;
  */
 public abstract class AbstractWarningFilterParser extends BaseFilterParser {
 
-    /**
-     * Whether we have ever warned because of saml: content.
-     */
-    private static boolean warnedSAML;
-
-    /**
-     * Whether we have ever warned because of basic: content.
-     */
-    private static boolean warnedBasic;
-
-    /** Class logger. */
-    private final Logger log = LoggerFactory.getLogger(AbstractWarningFilterParser.class);
-
     /** {@inheritDoc} */
     @Override protected void doParse(@Nonnull final Element element, @Nonnull final ParserContext parserContext,
             @Nonnull final BeanDefinitionBuilder builder) {
 
         final QName suppliedQname = DOMTypeSupport.getXSIType(element);
-        if (AttributeFilterSAMLNamespaceHandler.NAMESPACE.equals(suppliedQname.getNamespaceURI())) {
-            if (!warnedSAML) {
-                warnedSAML = true;
-                log.warn("Configuration contains at least one element in the deprecated '{}' namespace.",
-                        AttributeFilterSAMLNamespaceHandler.NAMESPACE);
-            }
-            log.debug("saml: Namespace element {} in {}, consider using {}", suppliedQname.toString(),
-                    parserContext.getReaderContext().getResource().getDescription(), getAFPName().toString());
-        } else if (AttributeFilterBasicNamespaceHandler.NAMESPACE.equals(suppliedQname.getNamespaceURI())) {
-            if (!warnedBasic) {
-                warnedBasic = true;
-                log.warn("Configuration contains at least one element in the deprecated '{}' namespace.",
-                        AttributeFilterBasicNamespaceHandler.NAMESPACE);
-            }
-            log.debug("basic: Namespace element {} in {}, consider using {}", suppliedQname.toString(),
+        if (AttributeFilterSAMLNamespaceHandler.NAMESPACE.equals(suppliedQname.getNamespaceURI())
+                || AttributeFilterBasicNamespaceHandler.NAMESPACE.equals(suppliedQname.getNamespaceURI())) {
+            DeprecationSupport.warnOnce(ObjectType.XSITYPE, suppliedQname.toString(),
                     parserContext.getReaderContext().getResource().getDescription(), getAFPName().toString());
         }
 
@@ -83,4 +58,5 @@ public abstract class AbstractWarningFilterParser extends BaseFilterParser {
      * @return the "new" type.
      */
     protected abstract QName getAFPName();
-}
+
+}
\ 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