/**
   * 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));
    }
  }
コード例 #2
0
ファイル: XMLFactory.java プロジェクト: camptocamp/secureOWS
  /**
   * Appends the DOM representation of the {@link ServiceIdentification} section to the passed
   * {@link Element}.
   *
   * @param root
   * @param serviceIdentification
   */
  protected static void appendServiceIdentification(
      Element root, ServiceIdentification serviceIdentification) {

    // 'ServiceIdentification'-element
    Element serviceIdentificationNode =
        XMLTools.appendElement(root, OWSNS, "ows:ServiceIdentification");

    // 'ServiceType'-element
    XMLTools.appendElement(
        serviceIdentificationNode,
        OWSNS,
        "ows:ServiceType",
        serviceIdentification.getServiceType().getCode());

    // 'ServiceTypeVersion'-elements
    String[] versions = serviceIdentification.getServiceTypeVersions();
    for (int i = 0; i < versions.length; i++) {
      XMLTools.appendElement(
          serviceIdentificationNode, OWSNS, "ows:ServiceTypeVersion", versions[i]);
    }

    // 'Fees'-element
    XMLTools.appendElement(
        serviceIdentificationNode, OWSNS, "ows:Fees", serviceIdentification.getFees());

    // 'AccessConstraints'-element
    String[] constraints = serviceIdentification.getAccessConstraints();
    if (constraints != null) {
      for (int i = 0; i < constraints.length; i++) {
        XMLTools.appendElement(
            serviceIdentificationNode, OWSNS, "ows:AccessConstraints", constraints[i]);
      }
    }
  }
コード例 #3
0
  /**
   * parses a Delete element contained in a CS-W Transaction.
   *
   * @param element
   * @return the Delete class parsed from the given Delete element.
   * @throws XMLParsingException
   * @throws MissingParameterValueException
   * @throws InvalidParameterValueException
   */
  private Delete parseDelete(Element element)
      throws XMLParsingException, MissingParameterValueException, InvalidParameterValueException {

    LOG.logDebug("parsing CS-W Transaction-Delete");

    String handle = XMLTools.getNodeAsString(element, "@handle", nsContext, null);
    String tmp = XMLTools.getNodeAsString(element, "@typeName", nsContext, null);
    URI typeName = null;
    if (tmp != null) {
      // part of the corrected CS-W 2.0 spec
      try {
        typeName = new URI(tmp);
      } catch (Exception e) {
        throw new XMLParsingException("if defined attribute 'typeName' must be a valid URI");
      }
    }

    Element elem = (Element) XMLTools.getRequiredNode(element, "./csw202:Constraint", nsContext);
    String ver = XMLTools.getNodeAsString(elem, "@version", nsContext, null);
    if (ver == null) {
      String s = Messages.getMessage("CSW_MISSING_CONSTRAINT_VERSION");
      throw new MissingParameterValueException(s);
    }
    if (!"1.0.0".equals(ver) && !"1.1.0".equals(ver)) {
      String s = Messages.getMessage("CSW_INVALID_CONSTRAINT_VERSION", ver);
      throw new InvalidParameterValueException(s);
    }

    elem = (Element) XMLTools.getRequiredNode(elem, "./ogc:Filter", nsContext);

    Filter constraint = AbstractFilter.buildFromDOM(elem, "1.0.0".equals(ver));
    return new Delete(handle, typeName, constraint);
  }
コード例 #4
0
ファイル: XMLFactory.java プロジェクト: camptocamp/secureOWS
  /**
   * Appends the XML representation of the given <code>OutputFormatType</code> (as FormatType[]) to
   * the passed <code>Element</code>.
   *
   * @param root
   * @param formats
   */
  public static void appendOutputFormats(Element root, FormatType[] formats) {
    LOG.entering();

    Element outputFormatsNode = XMLTools.appendElement(root, WFS, "wfs:OutputFormats");
    for (int i = 0; i < formats.length; i++) {
      Element formatNode =
          XMLTools.appendElement(outputFormatsNode, WFS, "wfs:Format", formats[i].getValue());
      if (formats[i].getInFilter() != null) {
        formatNode.setAttributeNS(
            DEEGREEWFS.toString(), "deegree:inFilter", formats[i].getInFilter().toString());
      }
      if (formats[i].getOutFilter() != null) {
        formatNode.setAttributeNS(
            DEEGREEWFS.toString(), "deegree:outFilter", formats[i].getOutFilter().toString());
      }
      if (formats[i].getSchemaLocation() != null) {
        formatNode.setAttributeNS(
            DEEGREEWFS.toString(),
            "deegree:schemaLocation",
            formats[i].getSchemaLocation().toString());
      }
    }

    LOG.exiting();
  }
コード例 #5
0
ファイル: XMLFactory.java プロジェクト: camptocamp/secureOWS
  /**
   * Appends the XML representation of the <code>wfs:GMLObjectTypeType</code>- element to the passed
   * <code>Element</code>.
   *
   * @param root
   * @param gmlObjectType
   */
  public static void appendGMLObjectTypeType(Element root, GMLObject gmlObjectType) {
    LOG.entering();
    Element gmlObjectTypeNode = XMLTools.appendElement(root, WFS, "wfs:GMLObjectType");

    if (gmlObjectType.getName().getPrefix() != null) {
      XMLTools.appendNSBinding(
          gmlObjectTypeNode,
          gmlObjectType.getName().getPrefix(),
          gmlObjectType.getName().getNamespace());
    }
    XMLTools.appendElement(
        gmlObjectTypeNode, WFS, "wfs:Name", gmlObjectType.getName().getAsString());
    if (gmlObjectType.getTitle() != null) {
      XMLTools.appendElement(gmlObjectTypeNode, WFS, "wfs:Title", gmlObjectType.getTitle());
    }
    String abstract_ = gmlObjectType.getAbstract();
    if (abstract_ != null) {
      XMLTools.appendElement(gmlObjectTypeNode, WFS, "wfs:Abstract", gmlObjectType.getAbstract());
    }
    Keywords[] keywords = gmlObjectType.getKeywords();
    if (keywords != null) {
      appendOWSKeywords(gmlObjectTypeNode, keywords);
    }
    FormatType[] formats = gmlObjectType.getOutputFormats();
    if (formats != null) {
      appendOutputFormats(gmlObjectTypeNode, formats);
    }
    LOG.exiting();
  }
コード例 #6
0
ファイル: XMLFactory.java プロジェクト: camptocamp/secureOWS
  /**
   * Adds the XML representation of an <code>Update</code> operation to the given element.
   *
   * <p>Respects the deegree-specific extension to the Update operation: instead of specifying
   * properties and their values, it's also possible to only specify just one feature that replaces
   * the matched feature.
   *
   * @param root
   * @param update
   * @throws SAXException
   * @throws IOException
   * @throws FeatureException
   */
  private static void appendUpdate(Element root, Update update)
      throws FeatureException, IOException, SAXException {

    Element el = XMLTools.appendElement(root, WFS, "Update");
    if (update.getHandle() != null) {
      el.setAttribute("handle", update.getHandle());
    }
    // TODO What about the namespace binding here?
    el.setAttribute("typeName", update.getTypeName().getAsString());

    Feature replacement = update.getFeature();
    if (replacement != null) {
      GMLFeatureAdapter adapter = new GMLFeatureAdapter();
      adapter.append(root, replacement);
    } else {
      Map<PropertyPath, Node> replaces = update.getRawProperties();
      for (PropertyPath propertyName : replaces.keySet()) {
        Element propElement = XMLTools.appendElement(el, WFS, "Property");
        Element nameElement = XMLTools.appendElement(propElement, WFS, "Name");
        org.deegree.ogcbase.XMLFactory.appendPropertyPath(nameElement, propertyName);
        Element valueElement = XMLTools.appendElement(propElement, WFS, "Value");
        Node value = replaces.get(propertyName);
        Node imported = valueElement.getOwnerDocument().importNode(value, true);
        valueElement.appendChild(imported);
      }
    }

    Filter filter = update.getFilter();
    if (filter != null) {
      org.deegree.model.filterencoding.XMLFactory.appendFilter(el, filter);
    }
    root.appendChild(el);
  }
コード例 #7
0
ファイル: XMLFactory.java プロジェクト: camptocamp/secureOWS
 /**
  * Appends a 'wfs:TransactionSummary' element to the given element.
  *
  * @param root
  * @param totalInserted
  * @param totalUpdated
  * @param totalDeleted
  */
 private static void appendTransactionSummary(
     Element root, int totalInserted, int totalUpdated, int totalDeleted) {
   Element taSummary = XMLTools.appendElement(root, WFS, "wfs:TransactionSummary");
   XMLTools.appendElement(taSummary, WFS, "wfs:totalInserted", "" + totalInserted);
   XMLTools.appendElement(taSummary, WFS, "wfs:totalUpdated", "" + totalUpdated);
   XMLTools.appendElement(taSummary, WFS, "wfs:totalDeleted", "" + totalDeleted);
 }
コード例 #8
0
  /**
   * returns WMPS contact informaion encapsulated within a <code>ServiceProvider</code> object
   *
   * @return ServiceProvider
   * @throws XMLParsingException
   */
  protected ServiceProvider parseServiceProvider() throws XMLParsingException {
    LOG.entering();

    SimpleLink sLink = retrieveOnlineResourceSimpleLink();

    LOG.logDebug("Parsing service provider parameter.");
    /**
     * according to WMPS (draft) specification this element is mandatory but there are several
     * services online which does not contain this element in its capabilities
     */
    Node contactInfo =
        XMLTools.getRequiredNode(getRootElement(), "./Service/ContactInformation", nsContext);

    String person =
        XMLTools.getRequiredNodeAsString(
            contactInfo, "./ContactPersonPrimary/ContactPerson", nsContext);
    String orga =
        XMLTools.getRequiredNodeAsString(
            contactInfo, "./ContactPersonPrimary/ContactOrganization", nsContext);
    String position = XMLTools.getRequiredNodeAsString(contactInfo, "./ContactPosition", nsContext);
    ContactInfo contact = parseContactInfo();

    ServiceProvider sp = new ServiceProvider(orga, sLink, person, position, contact, null);

    LOG.exiting();

    return sp;
  }
 /**
  * Creates an <tt>ExceptionFormat</tt> instance from the passed element.
  *
  * @param element
  * @return the new instance
  */
 protected ExceptionFormat getExceptionFormat(Element element, URI namespaceURI) {
   ElementList el = XMLTools.getChildElements("Format", namespaceURI, element);
   String[] formats = new String[el.getLength()];
   for (int i = 0; i < formats.length; i++) {
     formats[i] = XMLTools.getStringValue(el.item(i));
   }
   return new ExceptionFormat(formats);
 }
コード例 #10
0
  /**
   * Parse Contact Information
   *
   * @return ContactInfo
   * @throws XMLParsingException
   */
  protected ContactInfo parseContactInfo() throws XMLParsingException {
    LOG.entering();

    LOG.logDebug("Parsing contact information parameter.");
    Node contactInfo =
        XMLTools.getNode(getRootElement(), "./Service/ContactInformation", nsContext);
    String[] addr = XMLTools.getNodesAsStrings(contactInfo, "./ContactAddress/Address", nsContext);
    // String addrType = XMLTools.getNodeAsString( contactInfo, "./ContactAddress/AddressType",
    // nsContext, null );
    String city = XMLTools.getNodeAsString(contactInfo, "./ContactAddress/City", nsContext, null);
    String state =
        XMLTools.getNodeAsString(contactInfo, "./ContactAddress/StateOrProvince", nsContext, null);
    String pc = XMLTools.getNodeAsString(contactInfo, "./ContactAddress/PostCode", nsContext, null);
    String country =
        XMLTools.getNodeAsString(contactInfo, "./ContactAddress/Country", nsContext, null);
    String[] mail =
        XMLTools.getNodesAsStrings(contactInfo, "./ContactElectronicMailAddress", nsContext);
    Address address = new Address(state, city, country, addr, mail, pc);

    String[] phone = XMLTools.getNodesAsStrings(contactInfo, "./ContactVoiceTelephone", nsContext);
    String[] fax =
        XMLTools.getNodesAsStrings(contactInfo, "./ContactFacsimileTelephone", nsContext);

    Phone ph = new Phone(fax, phone);

    ContactInfo cont = new ContactInfo(address, null, null, null, ph);

    LOG.exiting();
    return cont;
  }
コード例 #11
0
ファイル: XMLFactory.java プロジェクト: camptocamp/secureOWS
 /**
  * Appends a 'wfs:Feature' element to the given element.
  *
  * @param root
  * @param results
  */
 private static void appendFeatureIds(Element root, InsertResults results) {
   Element featureElement = XMLTools.appendElement(root, WFS, "wfs:Feature");
   String handle = results.getHandle();
   if (handle != null) {
     featureElement.setAttribute("handle", handle);
   }
   Iterator<FeatureId> iter = results.getFeatureIDs().iterator();
   while (iter.hasNext()) {
     Element featureIdElement = XMLTools.appendElement(featureElement, OGCNS, "ogc:FeatureId");
     featureIdElement.setAttribute("fid", iter.next().getAsString());
   }
 }
コード例 #12
0
  /**
   * Parse Identifiers
   *
   * @param layerElem
   * @return Identifier[]
   * @throws XMLParsingException
   */
  protected Identifier[] parseIdentifiers(Element layerElem) throws XMLParsingException {
    LOG.entering();

    List nl = XMLTools.getNodes(layerElem, "./Identifier", nsContext);
    Identifier[] identifiers = new Identifier[nl.size()];
    for (int i = 0; i < identifiers.length; i++) {
      String value = XMLTools.getStringValue((Node) nl.get(i));
      String authority = XMLTools.getNodeAsString(layerElem, "./@authority", nsContext, null);
      identifiers[i] = new Identifier(value, authority);
    }

    LOG.exiting();
    return identifiers;
  }
コード例 #13
0
  /**
   * Parse Attribution
   *
   * @param layerElem
   * @return Attribution
   * @throws XMLParsingException
   */
  protected Attribution parseAttribution(Element layerElem) throws XMLParsingException {
    LOG.entering();

    Attribution attribution = null;
    Node node = XMLTools.getNode(layerElem, "./Attribution", nsContext);
    if (node != null) {
      String title = XMLTools.getRequiredNodeAsString(layerElem, "./Attribution/Title", nsContext);
      Node onlineR = XMLTools.getRequiredNode(node, "./OnlineResource", nsContext);
      OnlineResource onLineResource = parseOnLineResource((Element) onlineR);
      node = XMLTools.getNode(node, "./LogoURL", nsContext);
      LogoURL logoURL = null;
      if (node != null) {
        int width = XMLTools.getRequiredNodeAsInt(node, "./@width", nsContext);
        int height = XMLTools.getRequiredNodeAsInt(node, "./@height", nsContext);
        String format = XMLTools.getRequiredNodeAsString(node, "./Format", nsContext);
        onlineR = XMLTools.getRequiredNode(node, "./OnlineResource", nsContext);
        OnlineResource logoOR = parseOnLineResource((Element) onlineR);
        logoURL = new LogoURL(width, height, format, logoOR.getLinkage().getHref());
      }
      attribution = new Attribution(title, onLineResource.getLinkage().getHref(), logoURL);
    }

    LOG.exiting();
    return attribution;
  }
コード例 #14
0
ファイル: XMLFactory.java プロジェクト: camptocamp/secureOWS
 /**
  * Appends the XML representation of the given <code>Envelope</code> (as WGS84BoundingBoxType[])
  * to the passed <code>Element</code>.
  *
  * @param root
  * @param envelope
  */
 public static void appendWgs84BoundingBox(Element root, Envelope envelope) {
   LOG.entering();
   Element wgs84BoundingBoxElement = XMLTools.appendElement(root, OWS, "ows:WGS84BoundingBox");
   XMLTools.appendElement(
       wgs84BoundingBoxElement,
       OWS,
       "ows:LowerCorner",
       envelope.getMin().getX() + " " + envelope.getMin().getY());
   XMLTools.appendElement(
       wgs84BoundingBoxElement,
       OWS,
       "ows:UpperCorner",
       envelope.getMax().getX() + " " + envelope.getMax().getY());
   LOG.exiting();
 }
コード例 #15
0
  /**
   * Parse Lat Lon Bounding Box
   *
   * @param llBox
   * @return Envelope
   * @throws XMLParsingException
   * @throws UnknownCRSException
   */
  protected Envelope parseLatLonBoundingBox(Element llBox)
      throws XMLParsingException, UnknownCRSException {
    LOG.entering();

    double minx = XMLTools.getRequiredNodeAsDouble(llBox, "./@minx", nsContext);
    double maxx = XMLTools.getRequiredNodeAsDouble(llBox, "./@maxx", nsContext);
    double miny = XMLTools.getRequiredNodeAsDouble(llBox, "./@miny", nsContext);
    double maxy = XMLTools.getRequiredNodeAsDouble(llBox, "./@maxy", nsContext);
    /** default crs = EPSG:4326 */
    CoordinateSystem crs = CRSFactory.create("EPSG:4326");
    Envelope env = GeometryFactory.createEnvelope(minx, miny, maxx, maxy, crs);

    LOG.exiting();
    return env;
  }
コード例 #16
0
ファイル: XMLFactory.java プロジェクト: camptocamp/secureOWS
  /**
   * Appends the XML representation of the <code>WFSFeatureType</code> instance to the passed <code>
   * Element</code>.
   *
   * @param root
   * @param featureType
   */
  public static void appendWFSFeatureType(Element root, WFSFeatureType featureType) {
    LOG.entering();
    Element featureTypeNode = XMLTools.appendElement(root, WFS, "wfs:FeatureType");

    if (featureType.getName().getPrefix() != null) {
      XMLTools.appendNSBinding(
          featureTypeNode, featureType.getName().getPrefix(), featureType.getName().getNamespace());
    }
    XMLTools.appendElement(featureTypeNode, WFS, "wfs:Name", featureType.getName().getAsString());
    XMLTools.appendElement(featureTypeNode, WFS, "wfs:Title", featureType.getTitle());
    String abstract_ = featureType.getAbstract();
    if (abstract_ != null) {
      XMLTools.appendElement(featureTypeNode, WFS, "wfs:Abstract", featureType.getAbstract());
    }
    Keywords[] keywords = featureType.getKeywords();
    if (keywords != null) {
      appendOWSKeywords(featureTypeNode, keywords);
    }
    URI defaultSrs = featureType.getDefaultSRS();
    if (defaultSrs != null) {
      XMLTools.appendElement(featureTypeNode, WFS, "wfs:DefaultSRS", defaultSrs.toString());
      URI[] otherSrs = featureType.getOtherSrs();
      if (otherSrs != null) {
        for (int i = 0; i < otherSrs.length; i++) {
          XMLTools.appendElement(featureTypeNode, WFS, "wfs:OtherSRS", otherSrs[i].toString());
        }
      }
    } else {
      XMLTools.appendElement(featureTypeNode, WFS, "wfs:Title");
    }
    Operation[] operations = featureType.getOperations();
    if (operations != null) {
      Element operationsNode = XMLTools.appendElement(featureTypeNode, WFS, "wfs:Operations");
      for (int i = 0; i < operations.length; i++) {
        XMLTools.appendElement(operationsNode, WFS, "wfs:Operation", operations[i].getOperation());
      }
    }
    FormatType[] formats = featureType.getOutputFormats();
    if (formats != null) {
      appendOutputFormats(featureTypeNode, formats);
    }
    Envelope[] wgs84BoundingBoxes = featureType.getWgs84BoundingBoxes();
    for (int i = 0; i < wgs84BoundingBoxes.length; i++) {
      appendWgs84BoundingBox(featureTypeNode, wgs84BoundingBoxes[i]);
    }

    LOG.exiting();
  }
コード例 #17
0
  /**
   * Parse Dimensions
   *
   * @param layerElem
   * @return Dimension[]
   * @throws XMLParsingException
   */
  protected Dimension[] parseDimensions(Element layerElem) throws XMLParsingException {
    LOG.entering();

    List nl = XMLTools.getNodes(layerElem, "./Dimension", nsContext);
    Dimension[] dimensions = new Dimension[nl.size()];
    for (int i = 0; i < dimensions.length; i++) {
      String name = XMLTools.getNodeAsString((Node) nl.get(i), "./@name", nsContext, null);
      String units = XMLTools.getNodeAsString((Node) nl.get(i), "./@units", nsContext, null);
      String unitSymbol =
          XMLTools.getNodeAsString((Node) nl.get(i), "./@unitSymbol", nsContext, null);
      dimensions[i] = new Dimension(name, units, unitSymbol);
    }

    LOG.exiting();
    return dimensions;
  }
コード例 #18
0
  /**
   * Parse AuthorityURL
   *
   * @param layerElem
   * @return AuthorityURL[]
   * @throws XMLParsingException
   */
  protected AuthorityURL[] parseAuthorityURLs(Element layerElem) throws XMLParsingException {
    LOG.entering();

    List nl = XMLTools.getNodes(layerElem, "./AuthorityURL", nsContext);
    AuthorityURL[] authorityURLs = new AuthorityURL[nl.size()];
    for (int i = 0; i < authorityURLs.length; i++) {
      String name = XMLTools.getRequiredNodeAsString((Node) nl.get(i), "./@name", nsContext);
      Element tmp =
          (Element) XMLTools.getRequiredNode((Node) nl.get(i), "./OnlineResource", nsContext);
      OnlineResource olr = parseOnLineResource(tmp);
      authorityURLs[i] = new AuthorityURL(name, olr.getLinkage().getHref());
    }

    LOG.exiting();
    return authorityURLs;
  }
コード例 #19
0
  /**
   * Parse Style Sheet URL
   *
   * @param node
   * @return StyleSheetURL
   * @throws XMLParsingException
   */
  protected StyleSheetURL parseStyleSheetURL(Node node) throws XMLParsingException {
    LOG.entering();

    StyleSheetURL styleSheetURL = null;
    Node styleNode = XMLTools.getNode(node, "./StyleSheetURL", nsContext);

    if (styleNode != null) {
      String format = XMLTools.getRequiredNodeAsString(styleNode, "./Format", nsContext);
      Element tmp = (Element) XMLTools.getRequiredNode(styleNode, "./OnlineResource", nsContext);
      OnlineResource olr = parseOnLineResource(tmp);
      styleSheetURL = new StyleSheetURL(format, olr.getLinkage().getHref());
    }

    LOG.exiting();
    return styleSheetURL;
  }
コード例 #20
0
 /**
  * Creates a class representation of the whole document.
  *
  * @return class representation of the configuration document
  */
 public CatalogueConfiguration getConfiguration() throws InvalidConfigurationException {
   CatalogueConfiguration configuration = null;
   try {
     FilterCapabilities filterCapabilities = null;
     Element filterCapabilitiesElement =
         (Element) XMLTools.getNode(getRootElement(), "ogc:Filter_Capabilities", nsContext);
     if (filterCapabilitiesElement != null) {
       filterCapabilities =
           new FilterCapabilities100Fragment(filterCapabilitiesElement, getSystemId())
               .parseFilterCapabilities();
     }
     configuration =
         new CatalogueConfiguration(
             parseVersion(),
             parseUpdateSequence(),
             getServiceIdentification(),
             getServiceProvider(),
             getOperationsMetadata(),
             null,
             filterCapabilities,
             getDeegreeParams(),
             getSystemId());
   } catch (XMLParsingException e) {
     e.printStackTrace();
     throw new InvalidConfigurationException(
         "Class representation of the catalog configuration "
             + "document could not be generated: "
             + e.getMessage(),
         e);
   }
   return configuration;
 }
コード例 #21
0
 @Override
 public void createEmptyDocument() {
   Document doc = XMLTools.create();
   Element root =
       doc.createElementNS(CommonNamespaces.CSW202NS.toASCIIString(), "csw202:Transaction");
   setRootElement(root);
 }
コード例 #22
0
  /**
   * Returns the SimpleLink from the Online Resource node in the Service element.
   *
   * @return SimpleLink
   * @throws XMLParsingException
   */
  private SimpleLink retrieveOnlineResourceSimpleLink() throws XMLParsingException {

    LOG.entering();

    String simpleLink =
        XMLTools.getNodeAsString(
            getRootElement(), "./Service/OnlineResource/@xlink:href", nsContext, null);
    SimpleLink sLink = null;
    if (simpleLink != null) {
      try {
        sLink = new SimpleLink(new URI(simpleLink));
      } catch (URISyntaxException e) {
        throw new XMLParsingException("Error parsing service online resource", e);
      }
    } else {
      try {
        /**
         * use default if no online resource is contained in the capabilities (see comment above)
         */
        sLink = new SimpleLink(new URI("http://www.opengeospatial.org/"));
      } catch (URISyntaxException neverHappens) {
        neverHappens.printStackTrace();
      }
    }
    LOG.exiting();
    return sLink;
  }
コード例 #23
0
 /** Creates new document without namespace binding. */
 public void createEmptyDocument() {
   Document doc = XMLTools.create();
   // note: removed the namespace in order to ensure WMS 1.1.1 certifiability
   Element root = doc.createElement("ServiceExceptionReport");
   doc.appendChild(root);
   setRootElement(root);
 }
コード例 #24
0
  /*
   * (non-Javadoc)
   *
   * @see org.deegree.crs.configuration.gml.GMLResource#getAvailableCRSIds()
   */
  public List<String[]> getSortedAvailableCRSIds() {
    List<Element> crsIDs = new LinkedList<Element>();
    try {
      crsIDs.addAll(XMLTools.getElements(getRootElement(), ID_XPATH, nsContext));
    } catch (XMLParsingException e) {
      throw new CRSConfigurationException(
          Messages.getMessage("CRS_CONFIG_GET_ALL_ELEMENT_IDS", e.getMessage()), e);
    }

    List<String[]> result = new ArrayList<String[]>();
    for (Element crs : crsIDs) {
      if (crs != null) {
        result.add(new String[] {XMLTools.getStringValue(crs)});
      }
    }
    return result;
  }
コード例 #25
0
  /**
   * Parse Extents
   *
   * @param layerElem
   * @return Extent[]
   * @throws XMLParsingException
   */
  protected Extent[] parseExtents(Element layerElem) throws XMLParsingException {
    LOG.entering();

    List nl = XMLTools.getNodes(layerElem, "./Extent", nsContext);
    Extent[] extents = new Extent[nl.size()];
    for (int i = 0; i < extents.length; i++) {
      String name = XMLTools.getNodeAsString((Node) nl.get(i), "./@name", nsContext, null);
      String deflt = XMLTools.getNodeAsString((Node) nl.get(i), "./@default", nsContext, null);
      boolean nearestValue =
          XMLTools.getNodeAsBoolean((Node) nl.get(i), "./@nearestValue", nsContext, false);
      String value = XMLTools.getNodeAsString((Node) nl.get(i), ".", nsContext, "");
      extents[i] = new Extent(name, deflt, nearestValue, value);
    }

    LOG.exiting();
    return extents;
  }
コード例 #26
0
  /**
   * Parse MetadataURL
   *
   * @param layerElem
   * @return MetadataURL[]
   * @throws XMLParsingException
   */
  protected MetadataURL[] parseMetadataURLs(Element layerElem) throws XMLParsingException {
    LOG.entering();

    List nl = XMLTools.getNodes(layerElem, "./MetadataURL", nsContext);
    MetadataURL[] metadataURL = new MetadataURL[nl.size()];
    for (int i = 0; i < metadataURL.length; i++) {
      String type = XMLTools.getRequiredNodeAsString((Node) nl.get(i), "./@type", nsContext);
      String format = XMLTools.getRequiredNodeAsString((Node) nl.get(i), "./Format", nsContext);
      Element tmp =
          (Element) XMLTools.getRequiredNode((Node) nl.get(i), "./OnlineResource", nsContext);
      OnlineResource olr = parseOnLineResource(tmp);
      metadataURL[i] = new MetadataURL(type, format, olr.getLinkage().getHref());
    }

    LOG.exiting();
    return metadataURL;
  }
コード例 #27
0
  /**
   * Parse FeatureListURL
   *
   * @param layerElem
   * @return FeatureListURL[]
   * @throws XMLParsingException
   */
  protected FeatureListURL[] parseFeatureListURL(Element layerElem) throws XMLParsingException {
    LOG.entering();

    List nl = XMLTools.getNodes(layerElem, "./FeatureListURL", nsContext);
    FeatureListURL[] flURL = new FeatureListURL[nl.size()];
    for (int i = 0; i < flURL.length; i++) {

      String format = XMLTools.getRequiredNodeAsString((Node) nl.get(i), "./Format", nsContext);
      Element tmp =
          (Element) XMLTools.getRequiredNode((Node) nl.get(i), "./OnlineResource", nsContext);
      OnlineResource olr = parseOnLineResource(tmp);
      flURL[i] = new FeatureListURL(format, olr.getLinkage().getHref());
    }

    LOG.exiting();
    return flURL;
  }
コード例 #28
0
  /**
   * 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));
    }
  }
コード例 #29
0
ファイル: XMLFactory.java プロジェクト: camptocamp/secureOWS
 /**
  * Appends the XML representation of the <code>wfs:ServesGMLObjectTypeList</code>- section to the
  * passed <code>Element</code> as a new element with the given qualified name.
  *
  * @param root
  * @param elementNS
  * @param elementName
  * @param gmlObjectTypes
  */
 public static void appendGMLObjectTypeList(
     Element root, URI elementNS, String elementName, GMLObject[] gmlObjectTypes) {
   LOG.entering();
   Element gmlObjectTypeListNode = XMLTools.appendElement(root, elementNS, elementName);
   for (int i = 0; i < gmlObjectTypes.length; i++) {
     appendGMLObjectTypeType(gmlObjectTypeListNode, gmlObjectTypes[i]);
   }
   LOG.exiting();
 }
コード例 #30
0
ファイル: XMLFactory.java プロジェクト: camptocamp/secureOWS
 /**
  * Appends an 'wfs:InsertResults' element to the given element (only if necessary).
  *
  * @param root
  * @param insertResults
  */
 private static void appendInsertResults(Element root, Collection<InsertResults> insertResults) {
   if (insertResults.size() > 0) {
     Element insertResultsElement = XMLTools.appendElement(root, WFS, "wfs:InsertResults");
     Iterator<InsertResults> iter = insertResults.iterator();
     while (iter.hasNext()) {
       appendFeatureIds(insertResultsElement, iter.next());
     }
   }
 }