1 /*
2 * Copyright 2000-2001,2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.apache.jetspeed.xml;
18
19 import java.io.*;
20 //Jetspeed cache
21 import org.apache.jetspeed.cache.disk.*;
22
23 import org.xml.sax.*;
24
25
26 /***
27 * an entity resolver which tries to lookup DTD files
28 * through the URL Manager.
29 *
30 * TODO: Should be a singleton.
31 *
32 *@author <A HREF="mailto:christian.sell@netcologne.de">Christian Sell</A>
33 *@author <A HREF="mailto:sgala@hisitech.com">Santiago Gala</A>
34 *@version $Id: JetspeedXMLEntityResolver.java,v 1.8 2004/02/23 03:14:43 jford Exp $
35 *
36 **/
37 public class JetspeedXMLEntityResolver implements EntityResolver
38 {
39 public InputSource resolveEntity (String publicId, String systemId)
40 {
41 try {
42 //access Jetspeed cache and get a java.io.Reader
43 Reader rdr = JetspeedDiskCache.getInstance().
44 getEntry(systemId).getReader();
45 InputSource is = new InputSource(rdr);
46 is.setPublicId( publicId );
47 is.setSystemId( systemId );
48 return is;
49 } catch(IOException x)
50 {
51 System.err.println("JER: ( " + publicId +
52 " Taking " + systemId + " from cache throwed Exception: " + x);
53
54 }
55 return null;
56 }
57 }