1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.ken.util; |
17 | |
|
18 | |
import java.io.IOException; |
19 | |
import java.io.StringReader; |
20 | |
|
21 | |
import org.kuali.rice.ken.bo.NotificationContentType; |
22 | |
import org.kuali.rice.ken.service.NotificationContentTypeService; |
23 | |
import org.xml.sax.EntityResolver; |
24 | |
import org.xml.sax.InputSource; |
25 | |
import org.xml.sax.SAXException; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
public class ContentTypeEntityResolver extends ContentTypeResourceResolver implements EntityResolver { |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
public ContentTypeEntityResolver(NotificationContentTypeService notificationContentTypeService) { |
38 | 0 | super(notificationContentTypeService); |
39 | 0 | } |
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { |
45 | 0 | LOG.debug("Resolving '" + publicId + "' / '" + systemId + "'"); |
46 | 0 | if (!systemId.startsWith(CONTENT_TYPE_PREFIX)) { |
47 | 0 | LOG.warn("Cannot resolve non-ContentType resources"); |
48 | 0 | return null; |
49 | |
} |
50 | 0 | NotificationContentType notificationContentType = resolveContentType(systemId); |
51 | 0 | if (notificationContentType == null) { |
52 | 0 | LOG.error("Unable to resolve system id '" + systemId + "' locally...delegating to default resolution strategy."); |
53 | 0 | return null; |
54 | |
} |
55 | 0 | LOG.debug("Resolved '" + systemId + "' to " + notificationContentType.getXsd()); |
56 | 0 | return new InputSource(new StringReader(notificationContentType.getXsd())); |
57 | |
} |
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
public String toString() { |
63 | 0 | return "[ContentTypeEntityResolver]"; |
64 | |
} |
65 | |
} |