1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.core.impl.style;
17
18 import java.io.StringReader;
19
20 import javax.xml.transform.Source;
21 import javax.xml.transform.URIResolver;
22 import javax.xml.transform.stream.StreamSource;
23
24 import org.apache.log4j.Logger;
25 import org.kuali.rice.core.api.style.Style;
26 import org.kuali.rice.core.api.style.StyleService;
27
28
29
30
31
32
33
34
35 class StyleUriResolver implements URIResolver {
36
37 private static final Logger LOG = Logger.getLogger(StyleUriResolver.class);
38
39 private final StyleService styleService;
40
41 StyleUriResolver(StyleService styleService) {
42 if (styleService == null) {
43 throw new IllegalArgumentException("styleService cannot be null");
44 }
45 this.styleService = styleService;
46 }
47
48 public Source resolve(String href, String base) {
49
50 try {
51 Style style = styleService.getStyle(href);
52 return new StreamSource(new StringReader(style.getXmlContent()));
53
54 } catch (Exception e) {
55 LOG.error("Error ocurred getting style " + href, e);
56 }
57 return null;
58 }
59
60 }