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