Beispiel #1
0
 private void handleExternalSld(
     File file,
     String namedLayer,
     String layerName,
     Map<String, String> map,
     Map<String, Pair<File, URL>> legends,
     Map<String, Boolean> glgUrls)
     throws Throwable {
   LOG.info("Parsing SLD style file unavailable from style stores.");
   XMLInputFactory fac = XMLInputFactory.newInstance();
   FileInputStream is = new FileInputStream(file);
   try {
     XMLStreamReader in = fac.createXMLStreamReader(file.toURI().toURL().toString(), is);
     Pair<LinkedList<Filter>, LinkedList<StyleRef>> parsedStyles = getStyles(in, namedLayer, map);
     for (StyleRef s : parsedStyles.second) {
       if (!s.isResolved()) {
         continue;
       }
       registry.put(layerName, s.getStyle(), false);
       Pair<File, URL> p = legends.get(s.getName());
       if (p != null && p.first != null) {
         s.getStyle().setLegendFile(p.first);
       } else if (p != null) {
         s.getStyle().setLegendURL(p.second);
       }
       s.getStyle()
           .setPrefersGetLegendGraphicUrl(
               glgUrls.get(s.getStyle().getName()) != null && glgUrls.get(s.getStyle().getName()));
     }
   } finally {
     closeQuietly(is);
   }
 }
Beispiel #2
0
 private void assertStyleApplicableForAtLeastOneLayer(
     List<Layer> layers, StyleRef style, String name) throws OWSException {
   for (Layer layer : layers) {
     if (layer.isStyleApplicable(style)) {
       return;
     }
   }
   throw new OWSException(
       "Style " + style.getName() + " is not defined for layer " + name + ".",
       "StyleNotDefined",
       "styles");
 }