Ejemplo n.º 1
0
  /**
   * Filter the metadata if process parameter is set and corresponding XSL transformation exists.
   *
   * @param ri
   * @param md
   * @return
   */
  private Element processMetadata(RecordInfo ri, Element md) {
    // process metadata
    if (!params.xslfilter.equals("")) {
      MetadataSchema metadataSchema = dataMan.getSchema(ri.schema);

      String filePath = metadataSchema.getSchemaDir() + "/process/" + processName + ".xsl";
      File xslProcessing = new File(filePath);
      if (!xslProcessing.exists()) {
        log.info(
            "     processing instruction not found for "
                + ri.schema
                + " schema. metadata not filtered.");
      } else {
        Element processedMetadata = null;
        try {
          processedMetadata = Xml.transform(md, filePath, processParams);
          if (log.isDebugEnabled()) log.debug("     metadata filtered.");
          md = processedMetadata;
        } catch (Exception e) {
          log.warning("     processing error (" + params.xslfilter + "): " + e.getMessage());
        }
      }
    }
    return md;
  }
  /**
   * Retrieves namespaces based on metadata schema
   *
   * @param mdSchema
   * @return
   * @throws NoApplicableCodeEx
   */
  private Map<String, String> retrieveNamepacesForSchema(MetadataSchema mdSchema)
      throws NoApplicableCodeEx {
    Map<String, String> mapNs = new HashMap<String, String>();

    List<Namespace> schemaNsList = mdSchema.getSchemaNS();

    for (Namespace ns : schemaNsList) {
      mapNs.put(ns.getPrefix(), ns.getURI());
    }

    return mapNs;
  }