/**
   * Creates a class representation of the <code>deegreeParams</code>- section.
   *
   * @return
   * @throws InvalidConfigurationException
   */
  public CatalogueDeegreeParams getDeegreeParams() throws InvalidConfigurationException {

    CatalogueDeegreeParams deegreeParams = null;

    try {
      Node root = this.getRootElement();
      Element element = XMLTools.getRequiredChildElement("deegreeParams", DEEGREECSW, root);

      // 'deegreecsw:DefaultOnlineResource'-element (mandatory)
      OnlineResource defaultOnlineResource =
          parseOnLineResource(
              XMLTools.getRequiredChildElement("DefaultOnlineResource", DEEGREECSW, element));

      // 'deegreecsw:CacheSize'-element (optional, default: 100)
      int cacheSize = XMLTools.getNodeAsInt(element, "./deegreecsw:CacheSize", nsContext, 100);

      // 'deegreecsw:RequestTimeLimit'-element (optional, default: 2)
      int requestTimeLimit =
          XMLTools.getNodeAsInt(element, "./deegreecsw:RequestTimeLimit", nsContext, 2);

      // 'deegreecsw:Encoding'-element (optional, default: UTF-8)
      String characterSet = XMLTools.getStringValue("Encoding", DEEGREECSW, element, "UTF-8");

      // default output schema used by a catalogue
      String defaultOutputSchema =
          XMLTools.getStringValue("DefaultOutputSchema", DEEGREECSW, element, "OGCCORE");

      // 'deegreecsw:WFSResource'-element (mandatory)
      SimpleLink wfsResource =
          parseSimpleLink(XMLTools.getRequiredChildElement("WFSResource", DEEGREECSW, element));

      // 'deegreecsw:CatalogAddresses'-element (optional)
      Element catalogAddressesElement =
          XMLTools.getChildElement("CatalogAddresses", DEEGREECSW, element);
      OnlineResource[] catalogAddresses = new OnlineResource[0];
      if (catalogAddressesElement != null) {
        // 'deegreecsw:CatalogAddresses'-element (optional)
        ElementList el =
            XMLTools.getChildElements("CatalogAddress", DEEGREECSW, catalogAddressesElement);
        catalogAddresses = new OnlineResource[el.getLength()];
        for (int i = 0; i < catalogAddresses.length; i++) {
          catalogAddresses[i] = parseOnLineResource(el.item(i));
        }
      }

      OnlineResource transInXslt = null;
      Element elem = (Element) XMLTools.getNode(element, "deegreecsw:TransactionInputXSLT", nsc);
      if (elem != null) {
        transInXslt = parseOnLineResource(elem);
      }
      OnlineResource transOutXslt = null;
      elem = (Element) XMLTools.getNode(element, "deegreecsw:TransactionOutputXSLT", nsc);
      if (elem != null) {
        transOutXslt = parseOnLineResource(elem);
      }
      if ((transInXslt != null && transOutXslt == null)
          || (transInXslt == null && transOutXslt != null)) {
        throw new InvalidConfigurationException(
            "if CSW-deegreeParam "
                + "'TransactionInputXSLT' is defined 'TransactionOutputXSLT' must "
                + "be defined too and vice versa!");
      }

      // 'deegreecsw:HarvestRepository'-element (optional)
      Element harvestRepositoryElement =
          XMLTools.getChildElement("HarvestRepository", DEEGREECSW, element);
      JDBCConnection harvestRepository = null;
      if (harvestRepositoryElement != null) {
        // 'deegreecsw:Connection'-element (optional)
        Element connectionElement =
            XMLTools.getChildElement("Connection", DEEGREECSW, harvestRepositoryElement);
        if (connectionElement != null) {
          harvestRepository =
              new JDBCConnection(
                  XMLTools.getRequiredStringValue("Driver", DEEGREECSW, connectionElement),
                  XMLTools.getRequiredStringValue("Logon", DEEGREECSW, connectionElement),
                  XMLTools.getRequiredStringValue("User", DEEGREECSW, connectionElement),
                  XMLTools.getRequiredStringValue("Password", DEEGREECSW, connectionElement),
                  null,
                  null,
                  null);
        }
      }
      deegreeParams =
          new CatalogueDeegreeParams(
              defaultOnlineResource,
              cacheSize,
              requestTimeLimit,
              characterSet,
              wfsResource,
              catalogAddresses,
              harvestRepository,
              defaultOutputSchema,
              transInXslt,
              transOutXslt);
    } catch (XMLParsingException e) {
      throw new InvalidConfigurationException(
          "Error parsing the deegreeParams "
              + "section of the CSW configuration: \n"
              + e.getMessage()
              + StringTools.stackTraceToString(e));
    }
    return deegreeParams;
  }
  /**
   * returns the layers offered by the WMPS
   *
   * @param layerElem
   * @param parent
   * @return Layer
   * @throws XMLParsingException
   * @throws UnknownCRSException
   */
  protected Layer parseLayers(Element layerElem, Layer parent)
      throws XMLParsingException, UnknownCRSException {
    LOG.entering();

    boolean queryable = XMLTools.getNodeAsBoolean(layerElem, "./@queryable", nsContext, false);

    int cascaded = XMLTools.getNodeAsInt(layerElem, "./@cascaded", nsContext, 0);
    boolean opaque = XMLTools.getNodeAsBoolean(layerElem, "./@opaque", nsContext, false);
    boolean noSubsets = XMLTools.getNodeAsBoolean(layerElem, "./@noSubsets", nsContext, false);
    int fixedWidth = XMLTools.getNodeAsInt(layerElem, "./@fixedWidth", nsContext, 0);
    int fixedHeight = XMLTools.getNodeAsInt(layerElem, "./@fixedHeight", nsContext, 0);
    String name = XMLTools.getNodeAsString(layerElem, "./Name", nsContext, null);
    String title = XMLTools.getRequiredNodeAsString(layerElem, "./Title", nsContext);
    String layerAbstract = XMLTools.getNodeAsString(layerElem, "./Abstract", nsContext, null);
    String[] keywords = XMLTools.getNodesAsStrings(layerElem, "./KeywordList/Keyword", nsContext);
    String[] srs = XMLTools.getNodesAsStrings(layerElem, "./SRS", nsContext);

    List nl = XMLTools.getNodes(layerElem, "./BoundingBox", nsContext);
    // TODO substitue with Envelope
    LayerBoundingBox[] bboxes = null;
    if (nl.size() == 0 && parent != null) {
      // inherit BoundingBoxes from parent layer
      bboxes = parent.getBoundingBoxes();
    } else {
      bboxes = parseLayerBoundingBoxes(nl);
    }

    Element llBox = (Element) XMLTools.getNode(layerElem, "./LatLonBoundingBox", nsContext);
    Envelope llBoundingBox = null;

    if (llBox == null && parent != null) {
      // inherit LatLonBoundingBox parent layer
      llBoundingBox = parent.getLatLonBoundingBox();
    } else if (llBox != null) {
      llBoundingBox = parseLatLonBoundingBox(llBox);
    } else {
      /** Default crs = EPSG:4326 */
      CoordinateSystem crs = CRSFactory.create("EPSG:4326");
      llBoundingBox = GeometryFactory.createEnvelope(-180, -90, 180, 90, crs);
    }

    Dimension[] dimensions = parseDimensions(layerElem);

    Extent[] extents = parseExtents(layerElem);

    Attribution attribution = parseAttribution(layerElem);

    AuthorityURL[] authorityURLs = parseAuthorityURLs(layerElem);

    MetadataURL[] metadataURLs = parseMetadataURLs(layerElem);

    DataURL[] dataURLs = parseDataURL(layerElem);

    Identifier[] identifiers = parseIdentifiers(layerElem);

    FeatureListURL[] featureListURLs = parseFeatureListURL(layerElem);

    Style[] styles = parseStyles(layerElem);

    ScaleHint scaleHint = parseScaleHint(layerElem);

    Layer layer =
        new Layer(
            queryable,
            cascaded,
            opaque,
            noSubsets,
            fixedWidth,
            fixedHeight,
            name,
            title,
            layerAbstract,
            llBoundingBox,
            attribution,
            scaleHint,
            keywords,
            srs,
            bboxes,
            dimensions,
            extents,
            authorityURLs,
            identifiers,
            metadataURLs,
            dataURLs,
            featureListURLs,
            styles,
            null,
            null,
            parent);

    // get Child layers
    nl = XMLTools.getNodes(layerElem, "./Layer", nsContext);
    Layer[] layers = new Layer[nl.size()];
    for (int i = 0; i < layers.length; i++) {
      layers[i] = parseLayers((Element) nl.get(i), layer);
    }

    // set child layers
    layer.setLayer(layers);

    LOG.exiting();
    return layer;
  }