1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.coreservice.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.coreservice.api.style.Style;
26 import org.kuali.rice.coreservice.api.style.StyleService;
27
28
29
30
31
32
33
34 class StyleUriResolver implements URIResolver {
35
36 private static final Logger LOG = Logger.getLogger(StyleUriResolver.class);
37
38 private final StyleService styleService;
39
40 StyleUriResolver(StyleService styleService) {
41 if (styleService == null) {
42 throw new IllegalArgumentException("styleService cannot be null");
43 }
44 this.styleService = styleService;
45 }
46
47 public Source resolve(String href, String base) {
48
49 try {
50 Style style = styleService.getStyle(href);
51 return new StreamSource(new StringReader(style.getXmlContent()));
52
53 } catch (Exception e) {
54 LOG.error("Error ocurred getting style " + href, e);
55 }
56 return null;
57 }
58
59 }