org.apache.xmlgraphics.io.Resource Java Examples
The following examples show how to use
org.apache.xmlgraphics.io.Resource.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MCRFoFormatterFOP.java From mycore with GNU General Public License v3.0 | 5 votes |
public Resource getResource(URI uri) throws IOException { MCRContent content; try { content = MCRSourceContent.getInstance(uri.toString()); return new Resource(uri.getScheme(), content.getInputStream()); } catch (TransformerException e) { LOGGER.error("Error while resolving uri: {}", uri); } return null; }
Example #2
Source File: FopThemeResourceResolver.java From yes-cart with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public Resource getResource(final URI uri) throws IOException { final Long shopId = shop != null ? shop.getShopId() : null; if (shop != null) { final String curi = shop.getCode().concat("_report_").concat(contentSuffix != null ? contentSuffix : uri.toString()); final String content = contentService.getContentBody(curi, language); if (StringUtils.isNotBlank(content)) { LOG.debug("Using shop specific report template file {}", curi); return new Resource(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))); } final Long contentObjId = contentService.findContentIdBySeoUri(curi); if (contentObjId != null && contentObjId > 0L) { final Content contentObj = contentService.getById(contentObjId); if (contentObj != null) { final byte[] localeSpecificImage = getImageAsBytes(contentObj, AttributeNamesKeys.Category.CATEGORY_IMAGE + "_" + language, curi); if (localeSpecificImage != null && localeSpecificImage.length > 0) { return new Resource(new ByteArrayInputStream(localeSpecificImage)); } final byte[] defaultImage = getImageAsBytes(contentObj, AttributeNamesKeys.Category.CATEGORY_IMAGE, curi); if (defaultImage != null && defaultImage.length > 0) { return new Resource(new ByteArrayInputStream(defaultImage)); } } } } final List<String> chain = themeService.getReportsTemplateChainByShopId(shopId); for (final String path : chain) { final String configFile = path + (fileSuffix != null ? fileSuffix : uri.toString()); try { final InputStream stream = servletContext.getResourceAsStream(configFile); if (stream != null) { LOG.debug("Using theme specific report template file {}", configFile); return new Resource(stream); } } catch (Exception mue) { LOG.error("Unable to load report template file " + configFile, mue); } } LOG.debug("No report template for {}", uri); return null; }
Example #3
Source File: FopThemeResourceResolver.java From yes-cart with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public Resource getResource(final String id) throws IOException { throw new IOException("tmp:// resources are not supported"); }
Example #4
Source File: AbstractFopReportGeneratorTest.java From yes-cart with Apache License 2.0 | 4 votes |
@Override public Resource getResource(URI uri) throws IOException { return new Resource(new FileInputStream(BASE + uri.toString())); }
Example #5
Source File: AbstractFopReportGeneratorTest.java From yes-cart with Apache License 2.0 | 4 votes |
@Override public Resource getResource(final String id) throws IOException { throw new IOException("Not supported"); }
Example #6
Source File: PDFExportService.java From sakai with Educational Community License v2.0 | 4 votes |
@Override public Resource getResource(URI uri) throws IOException { InputStream inputStream = getClass().getResourceAsStream(uri.getPath()); return new Resource(inputStream); }
Example #7
Source File: PDFExportService.java From sakai with Educational Community License v2.0 | 4 votes |
@Override public Resource getResource(URI uri) throws IOException { InputStream inputStream = getClass().getResourceAsStream(uri.getPath()); return new Resource(inputStream); }