Package org.geowebcache.service

Examples of org.geowebcache.service.ServiceException


            }
            // Check that the response code is okay
            tileRespRecv.setStatus(responseCode);
            if (responseCode != 200 && responseCode != 204) {
                tileRespRecv.setError();
                throw new ServiceException("Unexpected response code from backend: " + responseCode
                        + " for " + wmsBackendUrl.toString());
            }

            // Check that we're not getting an error MIME back.
            String responseMime = getMethod.getResponseHeader("Content-Type").getValue();
View Full Code Here


            tile.setHint(req.toLowerCase());
            tile.setRequestHandler(ConveyorTile.RequestHandler.SERVICE);
            return tile;
        }
        if (layers == null) {
            throw new ServiceException("Unable to parse layers parameter from request.");
        }

        // Check whether this request is missing tiled=true
        final boolean tiled = Boolean.valueOf(values.get("tiled"));
        if (proxyNonTiledRequests && tiled) {
            ConveyorTile tile = new ConveyorTile(sb, layers, request, response);
            tile.setHint(req);
            tile.setRequestHandler(Conveyor.RequestHandler.SERVICE);
            return tile;
        }

        TileLayer tileLayer = tld.getTileLayer(layers);

        String[] paramKeys = { "format", "srs", "bbox" };
        final Map<String, String> paramValues = ServletUtils.selectedStringsFromMap(
                requestParameterMap, encoding, paramKeys);

        final Map<String, String> fullParameters = tileLayer.getModifiableParameters(
                requestParameterMap, encoding);

        final MimeType mimeType;
        String format = paramValues.get("format");
        try {
            mimeType = MimeType.createFromFormat(format);
        } catch (MimeException me) {
            throw new ServiceException("Unable to determine requested format, " + format);
        }

        final SRS srs;
        {
            String requestSrs = paramValues.get("srs");
            if (requestSrs == null) {
                throw new ServiceException("No SRS specified");
            }
            srs = SRS.getSRS(requestSrs);
        }

        GridSubset gridSubset = tileLayer.getGridSubsetForSRS(srs);
        if (gridSubset == null) {
            throw new ServiceException("Unable to match requested SRS " + srs
                    + " to those supported by layer");
        }

        final BoundingBox bbox;
        {
            String requestBbox = paramValues.get("bbox");
            try {
                bbox = new BoundingBox(requestBbox);
                if (bbox == null || !bbox.isSane()) {
                    throw new ServiceException("The bounding box parameter (" + requestBbox
                            + ") is missing or not sane");
                }
            } catch (NumberFormatException nfe) {
                throw new ServiceException("The bounding box parameter (" + requestBbox
                        + ") is invalid");
            }
        }

        final int tileWidth = Integer.parseInt(values.get("width"));
View Full Code Here

        } catch (NumberFormatException nfe) {
            log.debug(nfe.getMessage());
        }

        if (bbox == null || !bbox.isSane()) {
            throw new ServiceException("The bounding box parameter (" + values.get("srs")
                    + ") is missing or not sane");
        }

        // long[] tileIndex = gridSubset.closestIndex(bbox);
View Full Code Here

        try {
            gridLoc[0] = Integer.parseInt(params[paramsLength - 2]);
            gridLoc[1] = Integer.parseInt(yExt[0]);
            gridLoc[2] = Integer.parseInt(params[paramsLength - 3]);
        } catch (NumberFormatException nfe) {
            throw new ServiceException("Unable to parse number " + nfe.getMessage() + " from " + pathInfo);
        }

        String layerId;
        String gridSetId;
       
        // For backwards compatibility, we'll look for @s and use defaults if not found
        String layerNameAndSRS = params[2];
        String[] lsf = ServletUtils.URLDecode(layerNameAndSRS, request.getCharacterEncoding()).split("@");
        if(lsf.length < 3) {
            layerId = lsf[0];
            TileLayer layer = tld.getTileLayer(layerId);
            gridSetId = layer.getGridSubsets().values().iterator().next().getName();
        } else {
           layerId = lsf[0];
           gridSetId = lsf[1];
           // We don't actually care about the format, we'll pick it from the extension
        }

        MimeType mimeType = null;
        try {
            mimeType = MimeType.createFromExtension(yExt[1]);
        } catch (MimeException me) {
            throw new ServiceException("Unable to determine requested format based on extension " + yExt[1]);
        }

        ConveyorTile ret = new ConveyorTile(sb, layerId, gridSetId, gridLoc, mimeType, null, request, response);
       
        return ret;
View Full Code Here

        try {
            // TODO The container is supposed to handle the decoding prior
            // to returning but in Eclipse / Jetty this does not hold true
            parsed = parseRequest(URLDecoder.decode(request.getPathInfo(), "UTF-8"));
        } catch (Exception e) {
            throw new ServiceException("Unable to parse KML request : " + e.getMessage());
        }

        long[] gridLoc = { -1, -1, -1 };

        // Do we have a key for the grid location?
View Full Code Here

            layer = null;
        } else {
            layer = tld.getTileLayer(tile.getLayerId());

            if (layer == null) {
                throw new ServiceException("No layer provided, request parsed to: "
                        + tile.getLayerId());
            }
        }
        tile.setTileLayer(layer);
View Full Code Here

        try {
            ret[0] = Long.parseLong(key.substring(1, yloc));
            ret[1] = Long.parseLong(key.substring(yloc + 1, zloc));
            ret[2] = Long.parseLong(key.substring(zloc + 1, key.length()));
        } catch (NumberFormatException nfe) {
            throw new ServiceException("Unable to parse " + key);
        } catch (StringIndexOutOfBoundsException sobe) {
            throw new ServiceException("Unable to parse " + key);
        }
        return ret;
    }
View Full Code Here

                }
                tile.setWrapperMimeType(XMLMime.kmz);
            } catch (IOException ioe) {
                log.error(ioe.getMessage());
                ioe.printStackTrace();
                throw new ServiceException(ioe.getMessage());
            }

            byte[] zip = KMZHelper.createZippedKML(gridLocString(tile.getTileIndex()), tile
                    .getMimeType().getFileExtension(), overlayXml.getBytes(), tile.getBlob());
View Full Code Here

        try {
            gridLoc[0] = Integer.parseInt(params[paramsLength - 2]);
            gridLoc[1] = Integer.parseInt(yExt[0]);
            gridLoc[2] = Integer.parseInt(params[paramsLength - 3]);
        } catch (NumberFormatException nfe) {
            throw new ServiceException("Unable to parse number " + nfe.getMessage() + " from " + pathInfo);
        }

        String layerId;
        String gridSetId;
       
        // For backwards compatibility, we'll look for @s and use defaults if not found
        String layerNameAndSRS = params[2];
        String[] lsf = ServletUtils.URLDecode(layerNameAndSRS, request.getCharacterEncoding()).split("@");
        if(lsf.length < 3) {
            layerId = lsf[0];
            TileLayer layer = tld.getTileLayer(layerId);
            gridSetId = layer.getGridSubsets().iterator().next();
        } else {
           layerId = lsf[0];
           gridSetId = lsf[1];
           // We don't actually care about the format, we'll pick it from the extension
        }

        MimeType mimeType = null;
        try {
            mimeType = MimeType.createFromExtension(yExt[1]);
        } catch (MimeException me) {
            throw new ServiceException("Unable to determine requested format based on extension " + yExt[1]);
        }

        ConveyorTile ret = new ConveyorTile(sb, layerId, gridSetId, gridLoc, mimeType, null, request, response);
       
        return ret;
View Full Code Here

        ByteArrayOutputStream out = new ByteArrayOutputStream();
       
        try {
            writeZippedKML(namePfx, formatExtension, overlayXml, dataXml, out);
        } catch (IOException ioe) {
            throw new ServiceException(
                    "Encountered problem writing zip: " + ioe.getMessage());
        }
       
        return out.toByteArray();
    }
View Full Code Here

TOP

Related Classes of org.geowebcache.service.ServiceException

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.