1 | |
package org.kuali.core.db.torque; |
2 | |
|
3 | |
import java.io.IOException; |
4 | |
|
5 | |
import org.apache.torque.engine.database.transform.DTDResolver; |
6 | |
import org.springframework.core.io.DefaultResourceLoader; |
7 | |
import org.springframework.core.io.Resource; |
8 | |
import org.springframework.core.io.ResourceLoader; |
9 | |
import org.xml.sax.InputSource; |
10 | |
import org.xml.sax.SAXException; |
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
public class ImpexDTDResolver extends DTDResolver { |
22 | |
public static final String DTD_NAME = "database.dtd"; |
23 | |
public static final String DTD_LOCATION = "http://www.kuali.org/dtd/" + DTD_NAME; |
24 | |
|
25 | |
public ImpexDTDResolver() throws SAXException { |
26 | 0 | super(); |
27 | 0 | } |
28 | |
|
29 | |
@Override |
30 | |
public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException { |
31 | 0 | if (DTD_LOCATION.equals(systemId)) { |
32 | 0 | ResourceLoader loader = new DefaultResourceLoader(); |
33 | 0 | Resource resource = loader.getResource("classpath:" + DTD_NAME); |
34 | 0 | return new InputSource(resource.getInputStream()); |
35 | |
} else { |
36 | 0 | return super.resolveEntity(publicId, systemId); |
37 | |
} |
38 | |
} |
39 | |
|
40 | |
} |