Package org.geowebcache.rest

Examples of org.geowebcache.rest.RestletException


                list = seeder.getStatusList();
            } else {
                try {
                    seeder.findTileLayer(layerName);
                } catch (GeoWebCacheException e) {
                    throw new RestletException(e.getMessage(), Status.CLIENT_ERROR_BAD_REQUEST);
                }
                list = seeder.getStatusList(layerName);
            }
            obj = new JSONObject(xs.toXML(list));
View Full Code Here


        }

        try {
            seeder.seed(layerName, sr);
        } catch (IllegalArgumentException e) {
            throw new RestletException(e.getMessage(), Status.CLIENT_ERROR_BAD_REQUEST);
        } catch (GeoWebCacheException e) {
            throw new RestletException(e.getMessage(), Status.SERVER_ERROR_INTERNAL);
        }

    }
View Full Code Here

    protected void handleRequest(Request req, Response resp, Object obj) {
        MassTruncateRequest mtr = (MassTruncateRequest) obj;
        try {
            if(!mtr.doTruncate(broker, config)) {
                throw new RestletException("Truncation failed", Status.SERVER_ERROR_INTERNAL);
            }
        } catch (IllegalArgumentException e) {
            throw new RestletException(e.getMessage(), Status.CLIENT_ERROR_BAD_REQUEST);
        } catch (StorageException e) {
            throw new RestletException(e.getMessage(), Status.SERVER_ERROR_INTERNAL);
        }
    }
View Full Code Here

        Method met = request.getMethod();
        try {
            if (met.equals(Method.POST)) {
                doPost(request, response);
            } else {
                throw new RestletException("Method not allowed",
                        Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
            }
        } catch (RestletException re) {
            response.setEntity(re.getRepresentation());
            response.setStatus(re.getStatus());
View Full Code Here

    public void doPost(Request req, Response resp) throws RestletException {
        Form form = req.getEntityAsForm();

        if (form == null || form.getFirst("reload_configuration") == null) {
            throw new RestletException(
                    "Unknown or malformed request. Please try again, somtimes the form "
                    +"is not properly received. This frequently happens on the first POST "
                    +"after a restart. The POST was to " + req.getResourceRef().getPath(),
                    Status.CLIENT_ERROR_BAD_REQUEST );
        }
View Full Code Here

    int zoomStop;
   
   
    protected void runUpdate(RequestFilter filter, TileLayer tl) throws IOException, RestletException {
        if(! (filter instanceof WMSRasterFilter)) {
            throw new RestletException("The filter " + filter.getName() + " is not a WMSRasterFilter.",
                    Status.CLIENT_ERROR_BAD_REQUEST);
        }
       
        WMSRasterFilter wmsFilter = (WMSRasterFilter) filter;
       
        // Check that the SRS makes sense
        if (tl.getGridSubset(gridSetId) == null) {
            throw new RestletException("The filter " + wmsFilter.getName()
                    + " is associated with a layer that does not support "
                    + gridSetId, Status.CLIENT_ERROR_BAD_REQUEST);
        }

        // Run the actual update
        try {
            wmsFilter.update(tl, gridSetId, zoomStart, zoomStop);
        } catch (GeoWebCacheException e) {
            throw new RestletException("Error updating " + wmsFilter.getName()
                    + ": " + e.getMessage(), Status.SERVER_ERROR_INTERNAL);
        }
    }
View Full Code Here

            while (ze != null) {
                log.info("Reading " + ze.getName() + " (" + ze.getSize() + " bytes ) for " + filter.getName());
               
                if (ze.isDirectory()) {
                    throw new RestletException("Zip file cannot contain directories.",
                            Status.CLIENT_ERROR_BAD_REQUEST);
                }
               
                String[] parsedName = parseName(ze.getName());
               
                byte[] data = ServletUtils.readStream(zis, 16*1024, 1500, false);
               
                try {
                    filter.update(
                            data,
                            tl,
                            parsedName[0],
                            Integer.parseInt(parsedName[1]));
                   
                } catch (GeoWebCacheException e) {
                    throw new RestletException("Error updating " + filter.getName()
                            + ": " + e.getMessage(), Status.SERVER_ERROR_INTERNAL);
                }
               
                ze = zis.getNextEntry();
            }
           
           
        } catch (IOException ioe) {
            throw new RestletException("IOException while reading zip, " + ioe.getMessage(), Status.CLIENT_ERROR_BAD_REQUEST);
        } finally {
            try {
                is.close();
            } catch (IOException e) {
                // Ok at this point
View Full Code Here

    int zoomStop;
   
   
    protected void runUpdate(RequestFilter filter, TileLayer tl) throws IOException, RestletException {
        if(! (filter instanceof WMSRasterFilter)) {
            throw new RestletException("The filter " + filter.getName() + " is not a WMSRasterFilter.",
                    Status.CLIENT_ERROR_BAD_REQUEST);
        }
       
        WMSRasterFilter wmsFilter = (WMSRasterFilter) filter;
       
        // Check that the SRS makes sense
        if (tl.getGridSubset(gridSetId) == null) {
            throw new RestletException("The filter " + wmsFilter.getName()
                    + " is associated with a layer that does not support "
                    + gridSetId, Status.CLIENT_ERROR_BAD_REQUEST);
        }

        // Run the actual update
        try {
            for (int z = zoomStart; z <= zoomStop; z++) {
                wmsFilter.setMatrix(tl, gridSetId, z, true);
            }
        } catch (GeoWebCacheException e) {
            throw new RestletException("Error updating " + wmsFilter.getName()
                    + ": " + e.getMessage(), Status.SERVER_ERROR_INTERNAL);
        }
    }
View Full Code Here

        Method met = request.getMethod();
        try {
            if (met.equals(Method.POST)) {
                doPost(request, response);
            } else {
                throw new RestletException("Method not allowed",
                        Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
            }
        } catch (RestletException re) {
            response.setEntity(re.getRepresentation());
            response.setStatus(re.getStatus());
View Full Code Here

            }
        }

        // Check that we have found a filter and that it's the correct type
        if (filter == null) {
            throw new RestletException("No filter by the name " + filterName + " was found.",
                    Status.CLIENT_ERROR_BAD_REQUEST);
        }

        if (updateType.equalsIgnoreCase("xml")) {
            // Parse the input using XStream
            InputStream input = req.getEntity().getStream();
            XmlFilterUpdate fu = XMLConfiguration.parseXMLFilterUpdate(input);

            fu.runUpdate(filter, tl);

        } else if (updateType.equalsIgnoreCase("zip")) {
            ZipFilterUpdate fu = new ZipFilterUpdate(req.getEntity().getStream());

            fu.runUpdate(filter, tl);
        } else {
            throw new RestletException("Unknow update type " + updateType + "\n",
                    Status.CLIENT_ERROR_BAD_REQUEST);
        }

        resp.setEntity("Filter update completed, no problems encountered.\n", MediaType.TEXT_PLAIN);
        resp.setStatus(Status.SUCCESS_OK);
View Full Code Here

TOP

Related Classes of org.geowebcache.rest.RestletException

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.