Package org.geowebcache.rest

Examples of org.geowebcache.rest.RestletException


        String layerName = (String) req.getAttributes().get("layer");
        findTileLayer(layerName, layerDispatcher);
        try {
            Configuration configuration = layerDispatcher.removeLayer(layerName);
            if (configuration == null) {
                throw new RestletException("Configuration to remove layer not found",
                        Status.SERVER_ERROR_INTERNAL);
            }
            configuration.save();
        } catch (IOException e) {
            throw new RestletException(e.getMessage(), Status.SERVER_ERROR_INTERNAL, e);
        }
    }
View Full Code Here


                StringWriter writer = new StringWriter();
                new HierarchicalStreamCopier().copy(hsr, new PrettyPrintWriter(writer));
                writer.close();
                newLayer = (TileLayer) xs.fromXML(writer.toString());
            } else {
                throw new RestletException("Unknown or missing format extension: "
                        + formatExtension, Status.CLIENT_ERROR_BAD_REQUEST);
            }
        } catch (ConversionException xstreamExceptionWrapper) {
            Throwable cause = xstreamExceptionWrapper.getCause();
            if (cause instanceof Error) {
                throw (Error) cause;
            }
            if (cause instanceof RuntimeException) {
                throw (RuntimeException) cause;
            }
            if (cause!=null){
                throw new RestletException(cause.getMessage(), Status.SERVER_ERROR_INTERNAL,
                        (Exception) cause);
            } else {
                throw new RestletException(xstreamExceptionWrapper.getMessage(),
                    Status.SERVER_ERROR_INTERNAL, xstreamExceptionWrapper);
            }
        }

        if (!newLayer.getName().equals(layerName)) {
            throw new RestletException("There is a mismatch between the name of the "
                    + " layer in the submission and the URL you specified.",
                    Status.CLIENT_ERROR_BAD_REQUEST);
        }

        // Check that the parameter filters deserialized correctly
        if(newLayer.getParameterFilters()!=null) {
            try {
                for(@SuppressWarnings("unused")
                ParameterFilter filter: newLayer.getParameterFilters()){
                    // Don't actually need to do anything here.  Just iterate over the elements
                    // casting them into ParameterFilter
                }
            } catch (ClassCastException ex) {
                // By this point it has already been turned into a POJO, so the XML is no longer
                // available.  Otherwise it would be helpful to include in the error message.
                throw new RestletException("parameterFilters contains an element that is not "+
                        "a known ParameterFilter", Status.CLIENT_ERROR_BAD_REQUEST);
            }
        }
       
        return newLayer;
View Full Code Here

                doGet(request, response);
            } else if (met.equals(Method.POST)) {
                try {
                    doPost(request, response);
                } catch (GeoWebCacheException e) {
                    throw new RestletException(e.getMessage(), Status.CLIENT_ERROR_BAD_REQUEST);
                }
            } 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

        TileLayer tl;
        try {
            tl = seeder.findTileLayer(layerName);
        } catch (GeoWebCacheException e) {
            throw new RestletException(e.getMessage(), Status.CLIENT_ERROR_BAD_REQUEST);
        }

        handleDoGet(response, tl, false);
    }
View Full Code Here

                    throw new RuntimeException(uee);
                }
                try {
                    tl = seeder.findTileLayer(layerName);
                } catch (GeoWebCacheException e) {
                    throw new RestletException(e.getMessage(), Status.CLIENT_ERROR_BAD_REQUEST);
                }
            } else {
                tl = null;
            }
        }

        Form form = req.getEntityAsForm();

        if (form == null) {
            throw new RestletException("Unable to parse form result.",
                    Status.CLIENT_ERROR_BAD_REQUEST);
        }

        if (form.getFirst("list") != null) {
            if (tl == null) {
                throw new RestletException("No layer specified", Status.CLIENT_ERROR_BAD_REQUEST);
            }
            boolean listAllTasks = "all".equals(form.getFirst("list").getValue());
            handleDoGet(resp, tl, listAllTasks);
        } else if (form.getFirst("kill_thread") != null) {
            handleKillThreadPost(form, tl, resp);
        } else if (form.getFirst("kill_all") != null) {
            handleKillAllThreadsPost(form, tl, resp);
        } else if (form.getFirst("minX") != null) {
            if (tl == null) {
                throw new RestletException("No layer specified", Status.CLIENT_ERROR_BAD_REQUEST);
            }
            handleDoSeedPost(form, tl, resp);
        } else {
            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

        } else if ("pending".equalsIgnoreCase(killCode)) {
            tasks = seeder.getPendingTasks();
        } else if ("all".equalsIgnoreCase(killCode)) {
            tasks = seeder.getRunningAndPendingTasks();
        } else {
            throw new RestletException("Unknown kill_all code: '" + killCode
                    + "'. One of all|running|pending is expected.", Status.CLIENT_ERROR_BAD_REQUEST);
        }

        List<GWCTask> terminatedTasks = new LinkedList<GWCTask>();
        List<GWCTask> nonTerminatedTasks = new LinkedList<GWCTask>();
View Full Code Here

        GWCTask[] tasks;
        try {
            tasks = seeder.createTasks(tr, tl, sr.getType(), sr.getThreadCount(),
                    sr.getFilterUpdate());
        } catch (GeoWebCacheException e) {
            throw new RestletException(e.getMessage(), Status.SERVER_ERROR_INTERNAL);
        }

        seeder.dispatchTasks(tasks);

        // Give the thread executor a chance to run
View Full Code Here

    }

    private static double parseDouble(Form form, String key) throws RestletException {
        String value = form.getFirst(key).getValue();
        if (value == null || value.length() == 0)
            throw new RestletException("Missing value for " + key, Status.CLIENT_ERROR_BAD_REQUEST);
        try {
            return Double.parseDouble(value);
        } catch (NumberFormatException nfe) {
            throw new RestletException("Value for " + key + " is not a double",
                    Status.CLIENT_ERROR_BAD_REQUEST);
        }
    }
View Full Code Here

            if (met.equals(Method.GET)) {
                doGet(request, response);
            } else 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

        if (formatExtension==null || formatExtension.equalsIgnoreCase("xml")) {
            obj = xs.fromXML(req.getEntity().getStream());
        } else if (formatExtension.equalsIgnoreCase("json")) {
            obj = xs.fromXML(convertJson(req.getEntity().getText()));
        } else {
            throw new RestletException("Format extension unknown or not specified: "
                    + formatExtension, Status.CLIENT_ERROR_BAD_REQUEST);
        }

        handleRequest(req, resp, obj);
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.