Package org.vfny.geoserver.wms

Examples of org.vfny.geoserver.wms.WmsException


            renderer.paint(g, new Rectangle(g.getSVGCanvasSize()), getRenderingArea(), getRenderingTransform());
     
      // check if too many errors occurred
            if(errorChecker.exceedsMaxErrors()) {
                throw new WmsException("More than " + maxErrors + " rendering errors occurred, bailing out.",
                        "internalError", errorChecker.getLastException());
            }

            //check if a non ignorable error occurred
            if(nonIgnorableExceptionListener.exceptionOccurred()){
                Exception renderError = nonIgnorableExceptionListener.getException();
                throw new WmsException("Rendering process failed", "internalError", renderError);
            }
           
      // This method of output does not output the DOCTYPE definiition
      // TODO: make a config option that toggles wether doctype is
      // written out.
      OutputFormat format = new OutputFormat();
      XMLSerializer serializer = new XMLSerializer(
          new OutputStreamWriter(out, "UTF-8"), format);

            // this method does output the DOCTYPE def
             g.stream(new OutputStreamWriter(out,"UTF-8"));
      } catch(ParserConfigurationException e) {
          throw new WmsException("Unexpected exception", "internalError", e);
        } finally {
            // free up memory
            renderer = null;
        }
    }
View Full Code Here


                Rectangle container,
                Dimension dim,
                Point o) {

            if (p == null || container == null || dim == null || o == null) {
                throw new WmsException("Bad params for decoration sizing.");
            }

            int x = 0, y = 0;
            int height = dim.height, width = dim.width;
View Full Code Here

   * @throws WmsException
   *             DOCUMENT ME!
   */
  public void produceMap() throws WmsException {
    if (mapContext == null) {
      throw new WmsException("The map context is not set");
    }

    this.svgEncoder = new EncodeSVG(mapContext);
  }
View Full Code Here

      }

      template.setOutputEncoding("UTF-8");
      template.process(map, new OutputStreamWriter(out, Charset.forName("UTF-8")));
    } catch (TemplateException e) {
      throw new WmsException(e);
    }

    mapContext = null;
    template = null;
  }
View Full Code Here

                        if (LOGGER.isLoggable(Level.SEVERE)) {
                            LOGGER.log(Level.SEVERE, new StringBuffer("Getting feature source: ")
                                    .append(exp.getMessage()).toString(), exp);
                        }

                        throw new WmsException("Internal error", "", exp);
                    }

                    layer = new FeatureSourceMapLayer(source, layerStyle);
                    layer.setTitle(layers[i].getFeature().getName());

                    final DefaultQuery definitionQuery = new DefaultQuery(source.getSchema()
                            .getName().getLocalPart());
                    definitionQuery.setVersion(featureVersion);
                    definitionQuery.setFilter(layerFilter);

                    // check for startIndex + offset
                    final Integer startIndex = request.getStartIndex();
                    if (startIndex != null) {
                        QueryCapabilities queryCapabilities = source.getQueryCapabilities();
                        if (queryCapabilities.isOffsetSupported()) {
                            // fsource is required to support
                            // SortBy.NATURAL_ORDER so we don't bother checking
                            definitionQuery.setStartIndex(startIndex);
                        } else {
                            // source = new PagingFeatureSource(source,
                            // request.getStartIndex(), limit);
                            throw new WmsException("startIndex is not supported for the "
                                    + layers[i].getName() + " layer");
                        }
                    }

                    int maxFeatures = request.getMaxFeatures() != null ? request.getMaxFeatures()
                            : Integer.MAX_VALUE;
                    definitionQuery.setMaxFeatures(maxFeatures);

                    layer.setQuery(definitionQuery);
                    map.addLayer(layer);
                } else if (layers[i].getType() == MapLayerInfo.TYPE_RASTER) {
                    // /////////////////////////////////////////////////////////
                    //
                    // Adding a coverage layer
                    //
                    // /////////////////////////////////////////////////////////
                    AbstractGridCoverage2DReader reader;
                    reader = (AbstractGridCoverage2DReader) layers[i].getCoverageReader();
                    if (reader != null) {
                        // /////////////////////////////////////////////////////////
                        //
                        // Setting coverage reading params.
                        //
                        // /////////////////////////////////////////////////////////

                        /*
                         * Test if the parameter "TIME" is present in the WMS
                         * request, and by the way in the reading parameters. If
                         * it is the case, one can adds it to the request. If an
                         * exception is thrown, we have nothing to do.
                         */
                        try {
                            ParameterValue time = reader.getFormat().getReadParameters().parameter(
                                    "TIME");
                            if (time != null && request.getTime() != null) {
                                time.setValue(request.getTime());
                            }
                        } catch (ParameterNotFoundException p) {
                        }

                        // uncomment when the DIM_RANGE vendor parameter will be
                        // enabled
                        // try {
                        // ParameterValue dimRange =
                        // reader.getFormat().getReadParameters()
                        // .parameter("DIM_RANGE");
                        // if (dimRange != null && request.getDimRange() !=
                        // null) {
                        // dimRange.setValue(request.getDimRange());
                        // }
                        // } catch (ParameterNotFoundException p) {
                        // }

                        try {
                            ParameterValue elevation = reader.getFormat().getReadParameters()
                                    .parameter("ELEVATION");
                            if (elevation != null && request.getElevation() != null) {
                                elevation.setValue(request.getElevation().intValue());
                            }
                        } catch (ParameterNotFoundException p) {
                            //ignore?
                        }

                        try {
                            final ParameterValueGroup params = reader.getFormat()
                                    .getReadParameters();

                            layer = new DefaultMapLayer(FeatureUtilities.wrapGridCoverageReader(
                                    reader, CoverageUtils.getParameters(params, layers[i]
                                            .getCoverage().getParameters())), layerStyle);

                            layer.setTitle(layers[i].getCoverage().getName());
                            layer.setQuery(Query.ALL);
                            map.addLayer(layer);
                        } catch (IllegalArgumentException e) {
                            if (LOGGER.isLoggable(Level.SEVERE)) {
                                LOGGER.log(Level.SEVERE, new StringBuffer(
                                        "Wrapping GC in feature source: ").append(
                                        e.getLocalizedMessage()).toString(), e);
                            }

                            throw new WmsException(
                                    null,
                                    new StringBuffer(
                                            "Internal error : unable to get reader for this coverage layer ")
                                            .append(layers[i].toString()).toString());
                        }
                    } else {
                        throw new WmsException(null, new StringBuffer(
                                "Internal error : unable to get reader for this coverage layer ")
                                .append(layers[i].toString()).toString());
                    }
                }
            }
           
            // setup the SLD variable substitution environment
            EnvFunction.setLocalValues(request.getEnv());

            // /////////////////////////////////////////////////////////
            //
            // Producing the map in the requested format.
            //
            // /////////////////////////////////////////////////////////
            this.delegate.produceMap();

            if (cachingPossible) {
                if(responseHeaders == null){
                    responseHeaders = new HashMap();
                }
                responseHeaders.put("Cache-Control", "max-age=" + maxAge + ", must-revalidate");
               
                Date expires = new Date();
                expires.setTime(expires.getTime() + maxAge * 1000);
                DateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
                format.setTimeZone(TimeZone.getTimeZone("GMT"));
                responseHeaders.put("Expires", format.format(expires));
            }

            final String contentDisposition = this.delegate.getContentDisposition();
            if (contentDisposition != null) {
                this.headerContentDisposition = contentDisposition;
            }
        } catch (Exception e) {
            clearMapContext();
            throw new WmsException(e, "Internal error ", "");
        } finally {
            EnvFunction.clearLocalValues();
        }
    }
View Full Code Here

        // DJB: the WMS spec says that the request must not be 0 area
        // if it is, throw a service exception!
        final Envelope env = request.getBbox();
        if (env == null) {
            throw new WmsException("GetMap requests must include a BBOX parameter.", "MissingBBox");
        }
        if (env.isNull() || (env.getWidth() <= 0) || (env.getHeight() <= 0)) {
            throw new WmsException(new StringBuffer("The request bounding box has zero area: ")
                    .append(env).toString(), "InvalidBBox");
        }
    }
View Full Code Here

     */
    private GetMapProducer getDelegate(final String outputFormat) throws WmsException {
        final GetMapProducer producer = WMSExtensions.findMapProducer(outputFormat,
                availableProducers);
        if (producer == null) {
            WmsException e = new WmsException("There is no support for creating maps in "
                    + outputFormat + " format", "InvalidFormat");
            e.setCode("InvalidFormat");
            throw e;
        }
        // Tell the producer which of its output format names the
        // request
        // was made for, the producer may need it for its logic.
View Full Code Here

            regionatingStrategy = findStrategyByName(stratname);
           
            // if a strategy was specified but we did not find it, let the user
            // know
            if (regionatingStrategy == null)
                throw new WmsException("Unknown regionating strategy " + stratname);
        }

        // try to load less features by leveraging regionating strategy and the
        // SLD
        Filter regionatingFilter = Filter.INCLUDE;
View Full Code Here

        ByteArrayOutputStream out = new ByteArrayOutputStream();

        try {
            transformer.transform(this.request, out);
        } catch (TransformerException e) {
            throw new WmsException(e);
        }

        this.content = out.toByteArray();
    }
View Full Code Here

        String mode = caseInsensitiveParam(
                request.getHttpServletRequest().getParameterMap(),
                "mode", wmsConfiguration.getKmlReflectorMode());

        if (!MODES.containsKey(mode)){
            throw new WmsException("Unknown KML mode: " + mode);
        }

        Map modeOptions = new HashMap(MODES.get(mode));


        if ("superoverlay".equals(mode)){
            String submode = caseInsensitiveParam(
                request.getHttpServletRequest().getParameterMap(),
                "superoverlay_mode",
                wmsConfiguration.getKmlSuperoverlayMode()
                );

            if ("raster".equalsIgnoreCase(submode)) {
                modeOptions.put("overlaymode", "raster");
            } else if ("overview".equalsIgnoreCase(submode)) {
                modeOptions.put("overlaymode", "overview");
            } else if ("hybrid".equalsIgnoreCase(submode)) {
                modeOptions.put("overlaymode", "hybrid");
            } else if ("auto".equalsIgnoreCase(submode)) {
                modeOptions.put("overlaymode", "auto");
            } else {
                throw new WmsException("Unknown overlay mode: " + submode);
            }
        }

        //first set up some of the normal wms defaults
        if ( request.getWidth() < 1 ) {
View Full Code Here

TOP

Related Classes of org.vfny.geoserver.wms.WmsException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.