private void logSevereProblem(String message, Exception e) { if (commandLineArgs.isStackTraceDump()) { commandLineContext.getLogger().log(Level.SEVERE, message, e); } else { commandLineContext.getLogger().severe(message); } }
private void initializeJAI() { long tileCacheCapacity = commandLineArgs.getTileCacheCapacity(); int tileSchedulerParallelism = commandLineArgs.getTileSchedulerParallelism(); if (tileCacheCapacity > 0) { JAI.enableDefaultTileCache(); JAI.getDefaultInstance().getTileCache().setMemoryCapacity(tileCacheCapacity); } else { JAI.getDefaultInstance().getTileCache().setMemoryCapacity(0L); JAI.disableDefaultTileCache(); } if (tileSchedulerParallelism > 0) { JAI.getDefaultInstance().getTileScheduler().setParallelism(tileSchedulerParallelism); } final long tileCacheSize = JAI.getDefaultInstance().getTileCache().getMemoryCapacity() / (1024L * 1024L); commandLineContext .getLogger() .info(MessageFormat.format("JAI tile cache size is {0} MB", tileCacheSize)); final int schedulerParallelism = JAI.getDefaultInstance().getTileScheduler().getParallelism(); commandLineContext .getLogger() .info(MessageFormat.format("JAI tile scheduler parallelism is {0}", schedulerParallelism)); }
private void runVelocityTemplates() { String velocityDirPath = commandLineArgs.getVelocityTemplateDirPath(); File velocityDir; if (velocityDirPath != null) { velocityDir = new File(velocityDirPath); } else { velocityDir = new File(CommandLineArgs.DEFAULT_VELOCITY_TEMPLATE_DIRPATH); } String[] templateNames = velocityDir.list( new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(CommandLineArgs.VELOCITY_TEMPLATE_EXTENSION); } }); Logger logger = commandLineContext.getLogger(); if (templateNames == null) { String msgPattern = "Velocity template directory '%s' does not exist or inaccessible"; logger.severe(String.format(msgPattern, velocityDir)); return; } if (templateNames.length == 0) { String msgPattern = "Velocity template directory '%s' does not contain any templates (*.vm)"; logger.warning(String.format(msgPattern, velocityDir)); return; } // It can happen that we have no target file when the operator implements the Output interface if (!commandLineContext.isFile(commandLineArgs.getTargetFilePath())) { String msgPattern = "Target file '%s' does not exist, but is required to process velocity templates"; logger.warning(String.format(msgPattern, commandLineArgs.getTargetFilePath())); return; } for (String templateName : templateNames) { try { metadataResourceEngine.writeRelatedResource( velocityDir + "/" + templateName, commandLineArgs.getTargetFilePath()); } catch (IOException e) { String msgPattern = "Can't write related resource using template file '%s': %s"; logSevereProblem(String.format(msgPattern, templateName, e.getMessage()), e); } } }
private void readMetadata(String path, boolean fail) throws Exception { try { metadataResourceEngine.readResource("metadata", path); } catch (Exception e) { if (fail) { throw e; } final String message = String.format("Failed to read metadata file '%s': %s", path, e.getMessage()); if (commandLineContext.fileExists(path)) { logSevereProblem(message, e); } else { commandLineContext.getLogger().warning(message); } } }