public static String getImagePathForClass(final Class<?> cls, final ClassLoader classLoader) { final String iconPath = cls.getName().replaceAll("\\.", "/") + ".png"; final URL url = ResourceManager.get().getUrl(iconPath, classLoader); if (url == null) { return null; } return iconPath; }
public ImageServlet() { super(); _resourceManager = ResourceManager.get(); _fallbackImages = new ConcurrentHashMap<String, String>(); _fallbackImages.put("datastore", "org/eobjects/datacleaner/monitor/resources/datastore.png"); _fallbackImages.put("job", "org/eobjects/datacleaner/monitor/resources/job.png"); }
@Override public Image getWelcomeImage() { if (_arguments.getJobFile() != null) { if ("Kettle".equals(_embeddedClientName)) { try { final URL url = ResourceManager.get().getUrl("images/pdi_dc_banner.png"); return ImageIO.read(url); } catch (final Exception e) { logger.warn("Could not load PDI DC banner", e); } } } return null; } }
private DataCleanerConfiguration getConfigurationFromClasspath(final JaxbConfigurationReader configurationReader) { logger.info("Reading conf.xml from classpath"); try { return configurationReader.create(ResourceManager.get().getUrl("datacleaner-home/conf.xml").openStream()); } catch (final Exception e) { logger.warn("Unexpected error while reading conf.xml from classpath!", e); logger.warn("Creating a bare-minimum configuration because of previous errors!"); return new DataCleanerConfigurationImpl(); } }
private static Font createFont(final String path) { final URL url = ResourceManager.get().getUrl(path); if (url == null) { throw new IllegalArgumentException("Font resource not found: " + path); } InputStream in = null; try { in = url.openStream(); return Font.createFont(Font.TRUETYPE_FONT, in); } catch (final Exception e) { throw new IllegalStateException(e); } finally { FileHelper.safeClose(in); } }
private static FileObject overwriteFileWithDefaults(final FileObject targetDirectory, final String targetFilename) throws FileSystemException { final FileObject file = targetDirectory.resolveFile(targetFilename); final FileObject parentFile = file.getParent(); if (!parentFile.exists()) { parentFile.createFolder(); } final ResourceManager resourceManager = ResourceManager.get(); final URL url = resourceManager.getUrl("datacleaner-home/" + targetFilename); if (url == null) { return null; } InputStream in = null; OutputStream out = null; try { in = url.openStream(); out = file.getContent().getOutputStream(); FileHelper.copy(in, out); } catch (final IOException e) { throw new IllegalArgumentException(e); } finally { FileHelper.safeClose(in, out); } return file; }
private static FileObject copyIfNonExisting(final FileObject candidate, final FileSystemManager manager, final String filename) throws FileSystemException { final FileObject file = candidate.resolveFile(filename); if (file.exists()) { logger.info("File already exists in DATACLEANER_HOME: " + filename); return file; } final FileObject parentFile = file.getParent(); if (!parentFile.exists()) { parentFile.createFolder(); } final ResourceManager resourceManager = ResourceManager.get(); final URL url = resourceManager.getUrl("datacleaner-home/" + filename); if (url == null) { return null; } InputStream in = null; OutputStream out = null; try { in = url.openStream(); out = file.getContent().getOutputStream(); FileHelper.copy(in, out); } catch (final IOException e) { throw new IllegalArgumentException(e); } finally { FileHelper.safeClose(in, out); } return file; }