From e21dd5249d5fa19c5619847922cf8cdea95e3145 Mon Sep 17 00:00:00 2001 From: wbauer Date: Thu, 25 Sep 2008 07:29:47 +0000 Subject: improved robustness of http binding processor git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@70 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../HTTPURLProtocolHandlerImpl.java | 3 ++- .../at/gv/egiz/idlink/IdentityLinkTransformer.java | 30 ++++++++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) (limited to 'utils/src/main') diff --git a/utils/src/main/java/at/gv/egiz/bku/utils/urldereferencer/HTTPURLProtocolHandlerImpl.java b/utils/src/main/java/at/gv/egiz/bku/utils/urldereferencer/HTTPURLProtocolHandlerImpl.java index 600e5605..8d01fad1 100644 --- a/utils/src/main/java/at/gv/egiz/bku/utils/urldereferencer/HTTPURLProtocolHandlerImpl.java +++ b/utils/src/main/java/at/gv/egiz/bku/utils/urldereferencer/HTTPURLProtocolHandlerImpl.java @@ -52,7 +52,8 @@ public class HTTPURLProtocolHandlerImpl implements URLProtocolHandler { protected StreamData dereferenceHTTP(URL url) throws IOException { log.debug("Dereferencing url: "+url); - HttpURLConnection httpConn = (HttpURLConnection) url.openConnection(); + HttpURLConnection httpConn = (HttpURLConnection) url.openConnection(); + log.trace("Successfully opened connection"); return new StreamData(url.toString(), httpConn.getContentType(), httpConn .getInputStream()); } diff --git a/utils/src/main/java/at/gv/egiz/idlink/IdentityLinkTransformer.java b/utils/src/main/java/at/gv/egiz/idlink/IdentityLinkTransformer.java index 060ccef5..98f8d1c1 100644 --- a/utils/src/main/java/at/gv/egiz/idlink/IdentityLinkTransformer.java +++ b/utils/src/main/java/at/gv/egiz/idlink/IdentityLinkTransformer.java @@ -35,13 +35,20 @@ import javax.xml.transform.TransformerException; import javax.xml.transform.sax.SAXTransformerFactory; import javax.xml.transform.stream.StreamSource; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Text; + +import at.gv.egiz.bku.utils.urldereferencer.StreamData; +import at.gv.egiz.bku.utils.urldereferencer.URLDereferencer; -public class IdentityLinkTransformer { +public class IdentityLinkTransformer { + + protected static Log log = LogFactory.getLog(IdentityLinkTransformer.class); private class IdLTransformer { @@ -101,11 +108,15 @@ public class IdentityLinkTransformer { if (!"http".equalsIgnoreCase(url.getProtocol()) && !"https".equalsIgnoreCase(url.getProtocol())) { throw new MalformedURLException("Protocol " + url.getProtocol() + " not supported for IssuerTemplate URL."); - } - StreamSource source = new StreamSource(url.openStream()); + } + + URLDereferencer dereferencer = URLDereferencer.getInstance(); + StreamData data = dereferencer.dereference(url.toExternalForm(), null); + StreamSource source = new StreamSource(data.getStream()); + log.trace("Trying to creating template from stylesheet"); templates = factory.newTemplates(source); - + log.trace("Successfully created stylesheet template"); initTime = System.currentTimeMillis() - created; } @@ -233,7 +244,7 @@ public class IdentityLinkTransformer { pool = new HashMap>(); } - private synchronized IdLTransformer getFreeTransfomer(String stylesheetURL) throws TransformerConfigurationException, IOException { + private IdLTransformer getFreeTransfomer(String stylesheetURL) throws TransformerConfigurationException, IOException { IdLTransformer transformer = null; @@ -260,9 +271,12 @@ public class IdentityLinkTransformer { } - public void transformIdLink(String stylesheetURL, Source source, Result result) throws IOException, TransformerException { - IdLTransformer transformer = getFreeTransfomer(stylesheetURL); - transformer.transform(source, result); + public void transformIdLink(String stylesheetURL, Source source, Result result) throws IOException, TransformerException { + log.trace("Trying to get free IdentityLinkTransformer for issuer template '" + stylesheetURL + "'."); + IdLTransformer transformer = getFreeTransfomer(stylesheetURL); + log.trace("Trying to transform IdentityLink."); + transformer.transform(source, result); + log.trace("IdentityLink transformed successfully. " + getStatistics()); } public String getStatistics() { -- cgit v1.2.3