use of net.sf.jasperreports.repo.PersistenceService in project mapfish-print by mapfish.
the class MapfishPrintRepositoryService method getResource.
@Override
public <K extends Resource> K getResource(final String uri, final Class<K> resourceType) {
try {
if (resourceType.isAssignableFrom(InputStreamResource.class)) {
final InputStream inputStream = getInputStream(uri);
if (inputStream != null) {
final InputStreamResource resource = new InputStreamResource();
resource.setInputStream(inputStream);
return resourceType.cast(resource);
}
}
final PersistenceUtil persistenceUtil = PersistenceUtil.getInstance(this.jasperReportsContext);
PersistenceService persistenceService = persistenceUtil.getService(FileRepositoryService.class, resourceType);
if (persistenceService != null) {
return resourceType.cast(persistenceService.load(uri, this));
}
} catch (IllegalStateException e) {
LOGGER.info("Resource not found {} ({}).", uri, e.toString());
} catch (Exception e) {
LOGGER.trace("Error on getting resource {}", uri, e);
}
return null;
}
Aggregations