Esempio n. 1
0
  protected static Pair<Filter, ConstraintLanguage> parseConstraint(
      XMLAdapter adapter, OMElement omQueryElement) {
    Pair<Filter, ConstraintLanguage> pc = null;
    if (omQueryElement != null
        && new QName(CSWConstants.CSW_202_NS, "Constraint").equals(omQueryElement.getQName())) {
      Version versionConstraint =
          adapter.getRequiredNodeAsVersion(omQueryElement, new XPath("@version", nsContext));

      OMElement filterEl = omQueryElement.getFirstChildWithName(new QName(OGCNS, "Filter"));
      OMElement cqlTextEl = omQueryElement.getFirstChildWithName(new QName("", "CQLTEXT"));
      if ((filterEl != null) && (cqlTextEl == null)) {

        ConstraintLanguage constraintLanguage = ConstraintLanguage.FILTER;
        Filter constraint;
        try {
          // TODO remove usage of wrapper (necessary at the moment to work around problems
          // with AXIOM's

          XMLStreamReader xmlStream =
              new XMLStreamReaderWrapper(filterEl.getXMLStreamReaderWithoutCaching(), null);
          // skip START_DOCUMENT
          xmlStream.nextTag();

          if (versionConstraint.equals(new Version(1, 1, 0))) {

            constraint = Filter110XMLDecoder.parse(xmlStream);

          } else if (versionConstraint.equals(new Version(1, 0, 0))) {
            constraint = Filter100XMLDecoder.parse(xmlStream);
          } else {
            String msg =
                Messages.get(
                    "CSW_FILTER_VERSION_NOT_SPECIFIED",
                    versionConstraint,
                    Version.getVersionsString(new Version(1, 1, 0)),
                    Version.getVersionsString(new Version(1, 0, 0)));
            LOG.info(msg);
            throw new InvalidParameterValueException(msg);
          }
        } catch (XMLStreamException e) {
          String msg =
              "FilterParsingException: There went something wrong while parsing the filter expression, so please check this!";
          LOG.debug(msg);
          throw new XMLParsingException(adapter, filterEl, e.getMessage());
        }
        pc = new Pair<Filter, CSWConstants.ConstraintLanguage>(constraint, constraintLanguage);
      } else if ((filterEl == null) && (cqlTextEl != null)) {
        String msg = Messages.get("CSW_UNSUPPORTED_CQL_FILTER");
        LOG.info(msg);
        throw new NotImplementedError(msg);
      } else {
        String msg = Messages.get("CSW_MISSING_FILTER_OR_CQL");
        LOG.debug(msg);
        throw new InvalidParameterValueException(msg);
      }
    }
    return pc;
  }
  public DescribeRecord parse(Version version) {

    if (version == null) {
      version =
          Version.parseVersion(
              getRequiredNodeAsString(rootElement, new XPath("@version", nsContext)));
    }

    DescribeRecord result = null;

    if (VERSION_202.equals(version)) {
      result = parse202();
    } else {
      String msg =
          Messages.get("UNSUPPORTED_VERSION", version, Version.getVersionsString(VERSION_202));
      throw new InvalidParameterValueException(msg);
    }

    return result;
  }
Esempio n. 3
0
  /**
   * Parses a normalized KVP-map as a WFS {@link GetFeature} request.
   *
   * @param kvpParams normalized KVP-map; keys must be uppercase, each key only has one associated
   *     value
   * @param nsMap only for 1.0.0 version; the prefix-namespace map given in the NamespaceHints in
   *     the configuration
   * @return parsed {@link GetFeature} request
   * @throws Exception
   */
  public static GetFeature parse(Map<String, String> kvpParams, Map<String, String> nsMap)
      throws Exception {

    Version version = Version.parseVersion(KVPUtils.getRequired(kvpParams, "VERSION"));

    GetFeature result = null;
    if (VERSION_100.equals(version)) {
      result = parse100(kvpParams, nsMap);
    } else if (VERSION_110.equals(version)) {
      result = parse110(kvpParams);
    } else if (VERSION_200.equals(version)) {
      result = parse200(kvpParams);
    } else {
      String msg =
          Messages.get(
              "UNSUPPORTED_VERSION",
              version,
              Version.getVersionsString(VERSION_100, VERSION_110, VERSION_200));
      throw new InvalidParameterValueException(msg);
    }
    return result;
  }