Author: anil.saldhana(a)jboss.com
Date: 2011-08-09 17:40:00 -0400 (Tue, 09 Aug 2011)
New Revision: 1167
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/IDFedLSInputResolver.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/JAXPValidationUtil.java
Log:
add trace on LSInput
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/IDFedLSInputResolver.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/IDFedLSInputResolver.java 2011-08-09
21:39:34 UTC (rev 1166)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/IDFedLSInputResolver.java 2011-08-09
21:40:00 UTC (rev 1167)
@@ -44,6 +44,8 @@
{
protected static Logger log = Logger.getLogger(IDFedLSInputResolver.class);
+ protected static boolean trace = log.isTraceEnabled();
+
private static Map<String, LSInput> lsmap = new HashMap<String,
LSInput>();
private static Map<String, String> schemaLocationMap = new
LinkedHashMap<String, String>();
@@ -116,104 +118,137 @@
public LSInput resolveResource(String type, String namespaceURI, final String
publicId, final String systemId,
final String baseURI)
{
+ LSInput lsi = null;
if (systemId == null)
throw new RuntimeException(ErrorCodes.NULL_VALUE + "systemid");
- LSInput lsi = lsmap.get(systemId);
+ if (StringUtil.isNotNull(systemId) && systemId.endsWith("dtd")
&& StringUtil.isNotNull(baseURI))
+ {
+ lsi = lsmap.get(baseURI);
+ }
if (lsi == null)
+ lsi = lsmap.get(systemId);
+ if (lsi == null)
{
final String loc = schemaLocationMap.get(systemId);
if (loc == null)
return null;
- lsi = new LSInput()
- {
- public String getBaseURI()
- {
- return baseURI;
- }
+ lsi = new PicketLinkLSInput(baseURI, loc, publicId, systemId);
- public InputStream getByteStream()
- {
- URL url = SecurityActions.loadResource(getClass(), loc);
- InputStream is;
- try
- {
- is = url.openStream();
- }
- catch (IOException e)
- {
- throw new RuntimeException(ErrorCodes.CLASS_NOT_LOADED + loc);
- }
- if (is == null)
- throw new RuntimeException(ErrorCodes.NULL_VALUE + "inputstream is
null for " + loc);
- return is;
- }
+ if (trace)
+ log.trace("Loaded:" + lsi);
+ lsmap.put(systemId, lsi);
+ }
+ return lsi;
+ }
- public boolean getCertifiedText()
- {
- return false;
- }
+ public static class PicketLinkLSInput implements LSInput
+ {
+ private final String baseURI;
- public Reader getCharacterStream()
- {
- return null;
- }
+ private final String loc;
- public String getEncoding()
- {
- return null;
- }
+ private final String publicId;
- public String getPublicId()
- {
- return publicId;
- }
+ private final String systemId;
- public String getStringData()
- {
- return null;
- }
+ public PicketLinkLSInput(String baseURI, String loc, String publicID, String
systemID)
+ {
+ this.baseURI = baseURI;
+ this.loc = loc;
+ this.publicId = publicID;
+ this.systemId = systemID;
+ }
- public String getSystemId()
- {
- return systemId;
- }
+ public String getBaseURI()
+ {
+ return baseURI;
+ }
- public void setBaseURI(String baseURI)
- {
- }
+ public InputStream getByteStream()
+ {
+ URL url = SecurityActions.loadResource(getClass(), loc);
+ InputStream is;
+ try
+ {
+ is = url.openStream();
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(ErrorCodes.CLASS_NOT_LOADED + loc);
+ }
+ if (is == null)
+ throw new RuntimeException(ErrorCodes.NULL_VALUE + "inputstream is null
for " + loc);
+ return is;
+ }
- public void setByteStream(InputStream byteStream)
- {
- }
+ public boolean getCertifiedText()
+ {
+ return false;
+ }
- public void setCertifiedText(boolean certifiedText)
- {
- }
+ public Reader getCharacterStream()
+ {
+ return null;
+ }
- public void setCharacterStream(Reader characterStream)
- {
- }
+ public String getEncoding()
+ {
+ return null;
+ }
- public void setEncoding(String encoding)
- {
- }
+ public String getPublicId()
+ {
+ return publicId;
+ }
- public void setPublicId(String publicId)
- {
- }
+ public String getStringData()
+ {
+ return null;
+ }
- public void setStringData(String stringData)
- {
- }
+ public String getSystemId()
+ {
+ return systemId;
+ }
- public void setSystemId(String systemId)
- {
- }
- };
+ public void setBaseURI(String baseURI)
+ {
+ }
- lsmap.put(systemId, lsi);
+ public void setByteStream(InputStream byteStream)
+ {
}
- return lsi;
+
+ public void setCertifiedText(boolean certifiedText)
+ {
+ }
+
+ public void setCharacterStream(Reader characterStream)
+ {
+ }
+
+ public void setEncoding(String encoding)
+ {
+ }
+
+ public void setPublicId(String publicId)
+ {
+ }
+
+ public void setStringData(String stringData)
+ {
+ }
+
+ public void setSystemId(String systemId)
+ {
+ }
+
+ @Override
+ public String toString()
+ {
+ return "PicketLinkLSInput [baseURI=" + baseURI + ", loc=" +
loc + ", publicId=" + publicId + ", systemId="
+ + systemId + "]";
+ }
}
}
\ No newline at end of file
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/JAXPValidationUtil.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/JAXPValidationUtil.java 2011-08-09
21:39:34 UTC (rev 1166)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/JAXPValidationUtil.java 2011-08-09
21:40:00 UTC (rev 1167)
@@ -132,7 +132,7 @@
{
URL url = SecurityActions.loadResource(JAXPValidationUtil.class, schema);
if (url == null)
- throw new RuntimeException(ErrorCodes.NULL_VALUE + "schema url");
+ throw new RuntimeException(ErrorCodes.NULL_VALUE + "schema url:" +
schema);
sourceArr[i++] = new StreamSource(url.openStream());
}
return sourceArr;
@@ -166,7 +166,10 @@
if (trace)
{
-
builder.append("[").append(sax.getLineNumber()).append(",").append(sax.getColumnNumber()).append("]");
+
builder.append("[line:").append(sax.getLineNumber()).append(",").append("::col=")
+ .append(sax.getColumnNumber()).append("]");
+
builder.append("[publicID:").append(sax.getPublicId()).append(",systemId=").append(sax.getSystemId())
+ .append("]");
builder.append(":").append(sax.getLocalizedMessage());
log.trace(builder.toString());
}
Show replies by date