Was using old manual parser code, but parser wasn't initalized.
authorcantor <cantor@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Sun, 18 Apr 2004 00:39:27 +0000 (00:39 +0000)
committercantor <cantor@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Sun, 18 Apr 2004 00:39:27 +0000 (00:39 +0000)
Switched to SAML parser.

git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@1000 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/metadata/provider/XMLMetadataLoadWrapper.java

index 7059823..b0f3418 100644 (file)
@@ -28,11 +28,9 @@ package edu.internet2.middleware.shibboleth.metadata.provider;
 
 import java.io.IOException;
 import org.apache.log4j.Logger;
-import org.apache.xerces.parsers.DOMParser;
 import org.opensaml.SAMLException;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
-import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 import edu.internet2.middleware.shibboleth.common.ResourceWatchdog;
 import edu.internet2.middleware.shibboleth.common.ResourceWatchdogExecutionException;
@@ -50,7 +48,6 @@ public class XMLMetadataLoadWrapper extends ResourceWatchdog implements Metadata
 
        private static Logger   log     = Logger.getLogger(XMLMetadataLoadWrapper.class.getName());
        private Metadata                currentMeta;
-       private DOMParser               parser;
 
        public XMLMetadataLoadWrapper(Element configuration) throws MetadataException, ResourceNotAvailableException {
                this(configuration.getAttribute("uri"));
@@ -85,6 +82,7 @@ public class XMLMetadataLoadWrapper extends ResourceWatchdog implements Metadata
        }
 
        protected void doOnChange() throws ResourceWatchdogExecutionException {
+        Document newDoc = null;
                //Log
                try {
                        log.info("Detected a change in the federation metadata.  Reloading from (" + resource.getURL().toString()
@@ -96,7 +94,10 @@ public class XMLMetadataLoadWrapper extends ResourceWatchdog implements Metadata
 
                //Load new, but keep the old in place
                try {
-                       parser.parse(new InputSource(resource.getInputStream()));
+            newDoc = org.opensaml.XML.parserPool.parse(resource.getInputStream());
+        } catch (SAMLException e) {
+            log.error("Encountered an error parsing updated federation metadata, continuing to use stale copy.");
+            return;
                } catch (SAXException e) {
                        log.error("Encountered an error parsing updated federation metadata, continuing to use stale copy.");
                        return;
@@ -108,7 +109,7 @@ public class XMLMetadataLoadWrapper extends ResourceWatchdog implements Metadata
                //If things went well, replace the live copy
                Metadata newMeta = null;
                try {
-                       newMeta = new XMLMetadata(parser.getDocument().getDocumentElement());
+                       newMeta = new XMLMetadata(newDoc.getDocumentElement());
                } catch (MetadataException e1) {
                        log.error("Encountered an error loading updated federation metadata, continuing to use stale copy.");
                        return;