void processMetadata() throws Exception {
    VelocityContext velocityContext = metadataResourceEngine.getVelocityContext();
    velocityContext.put(KEY_DATE_FORMAT, new SimpleDateFormat("yyyy-MM-dd"));
    velocityContext.put(KEY_DATE, new Date());

    HashMap<String, String> metadataPaths = cliHandler.fetchGlobalMetadataFiles();
    for (String key : metadataPaths.keySet()) {
      metadataResourceEngine.readResource(key, metadataPaths.get(key));
    }

    Map<String, String> sourcePaths = cliHandler.fetchSourceItemFiles();
    for (String key : sourcePaths.keySet()) {
      metadataResourceEngine.readRelatedResource(key, sourcePaths.get(key));
    }
    velocityContext.put(KEY_XPATH, new XPathHandler());
    velocityContext.put(KEY_SOURCES, sourcePaths);

    velocityContext.put(KEY_SYSTEM, System.getProperties());
    velocityContext.put(KEY_ARGS, Arrays.asList(cliHandler.fetchArguments()));

    Map<String, String> templatePaths = cliHandler.fetchTemplateFiles();
    String outputItemPath = cliHandler.fetchTargetItemFile();
    velocityContext.put(KEY_TARGET, outputItemPath);
    for (String templateKey : templatePaths.keySet()) {
      metadataResourceEngine.writeRelatedResource(templatePaths.get(templateKey), outputItemPath);
    }
  }
示例#2
0
 void readSourceMetadataFiles() {
   final SortedMap<String, String> sourceFilePathMap = commandLineArgs.getSourceFilePathMap();
   for (String sourceId : sourceFilePathMap.keySet()) {
     final String sourcePath = sourceFilePathMap.get(sourceId);
     try {
       metadataResourceEngine.readRelatedResource(sourceId, sourcePath);
     } catch (IOException e) {
       String msgPattern = "Failed to load metadata file associated with '%s = %s': %s";
       logSevereProblem(String.format(msgPattern, sourceId, sourcePath, e.getMessage()), e);
     }
   }
 }