/**
   * returns the service section of the configuration/capabilities. vendorspecific capabilities are
   * not supported yet
   *
   * @param namespaceURI
   * @return the service section of the configuration/capabilities. vendorspecific capabilities are
   *     not supported yet
   * @throws InvalidCapabilitiesException
   */
  public Capability getCapabilitySection(URI namespaceURI) throws InvalidCapabilitiesException {
    try {
      Node root = this.getRootElement();

      Element element = XMLTools.getRequiredChildElement("Capability", namespaceURI, root);
      Element elem = XMLTools.getRequiredChildElement("Request", namespaceURI, element);
      OperationsMetadata request = parseOperations(elem, namespaceURI);

      elem = XMLTools.getRequiredChildElement("Exception", namespaceURI, element);
      ExceptionFormat eFormat = getExceptionFormat(elem, namespaceURI);

      // vendorspecific capabilities are not supported yet
      // elem = XMLTools.getRequiredChildByName(
      // "VendorSpecificCapabilities", WCSNS, element);

      String version = element.getAttribute("version");
      if (version == null || version.equals("")) {
        version = this.parseVersion();
      }
      String updateSequence = element.getAttribute("updateSequence");
      if (updateSequence == null || updateSequence.equals("")) {
        updateSequence = this.getRootElement().getAttribute("updateSequence");
      }

      return new Capability(version, updateSequence, request, eFormat, null);

    } catch (XMLParsingException e) {
      String s = e.getMessage();
      throw new InvalidCapabilitiesException(
          "Error while parsing the Capability "
              + "Section of the capabilities\n"
              + s
              + StringTools.stackTraceToString(e));
    }
  }
  /**
   * Creates a <code>DCPType</code> object from the passed <code>DCPType</code> element.
   * <p>
   * NOTE: Currently the <code>OnlineResources</code> included in the <code>DCPType</code> are
   * just stored as simple <code>URLs</code> (not as <code>OnLineResource</code> instances)!
   * <p>
   * NOTE: In an <code>OGCStandardCapabilitiesDocument</code> the <code>XLinks</code> (the
   * <code>URLs</code>) are stored in separate elements (<code>OnlineResource</code>), in
   * an <code>OGCCommonCapabilitiesDocument</code> they are the
   * <code>Get<code>/<code>Post</code> elements themselves.
   *
   * @param element
   * @param namespaceURI
   * @return created <code>DCPType</code>
   * @throws XMLParsingException
   * @see org.deegree.owscommon.OWSCommonCapabilities
   */
  protected DCPType getDCPType(Element element, URI namespaceURI) throws XMLParsingException {
    try {
      Element elem = XMLTools.getRequiredChildElement("HTTP", namespaceURI, element);
      ElementList el = XMLTools.getChildElements("Get", namespaceURI, elem);

      URL[] get = new URL[el.getLength()];
      for (int i = 0; i < get.length; i++) {
        Element ell = XMLTools.getRequiredChildElement("OnlineResource", namespaceURI, el.item(i));
        String s = XMLTools.getRequiredAttrValue("href", XLNNS, ell);
        get[i] = new URL(s);
      }
      el = XMLTools.getChildElements("Post", namespaceURI, elem);

      URL[] post = new URL[el.getLength()];
      for (int i = 0; i < post.length; i++) {
        Element ell = XMLTools.getRequiredChildElement("OnlineResource", namespaceURI, el.item(i));
        String s = XMLTools.getRequiredAttrValue("href", XLNNS, ell);
        post[i] = new URL(s);
      }
      Protocol protocol = new HTTP(get, post);
      return new DCPType(protocol);
    } catch (MalformedURLException e) {
      throw new XMLParsingException(
          "Couldn't parse DCPType onlineresoure URL about\n" + StringTools.stackTraceToString(e));
    }
  }
  /**
   * 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;
  }