Examples of RestletException


Examples of org.geoserver.rest.RestletException

        }
       
        if ( namespace != null ) {
            //ensure it exists
            if ( !"default".equals( namespace ) && catalog.getNamespaceByPrefix( namespace ) == null ) {
                throw new RestletException( "No such namespace: " + namespace, Status.CLIENT_ERROR_NOT_FOUND );
            }
        }
       
        return new NamespaceResource( null, request, response, catalog );
    }
View Full Code Here

Examples of org.geoserver.rest.RestletException

                scriptDirectory = resourceLoader.find(scriptPath);
            } catch (IOException ioe) {
                // no, it's cool. we might have to handle a null return anyway.
            }

            if (scriptDirectory == null) throw new RestletException(
                "No script directory", Status.CLIENT_ERROR_NOT_FOUND
            );

            StringBuilder out = new StringBuilder();
            for (String script : scriptDirectory.list(new FilenameFilter() {
                public boolean accept(File f, String name) {
                    return name.endsWith(".js");
                }
            })) {
                out.append(script.substring(0, script.length() - 3))
                   .append(", ");
            }
            response.setEntity(new StringRepresentation(out.toString()));
        } else {
            File script;
            try {
                script = resourceLoader.find(scriptPath, scriptName + ".js");
            } catch (IOException ioe) {
                throw new RestletException(
                    "Requested script [" + scriptName + "] does not exist",
                    Status.CLIENT_ERROR_NOT_FOUND
                );
            }

            Context cx = Context.enter();
            try {
                Scriptable scope = cx.initStandardObjects();
                FileReader reader = new FileReader(script);

                Object wrappedRequest = Context.javaToJS(request, scope);
                Object wrappedResponse = Context.javaToJS(response, scope);
                Object wrappedCatalog = Context.javaToJS(catalog, scope);

                ScriptableObject.putProperty(scope, "request", wrappedRequest);
                ScriptableObject
                    .putProperty(scope, "response", wrappedResponse);
                ScriptableObject.putProperty(scope, "catalog", wrappedCatalog);

                cx.evaluateReader(scope, reader, script.getName(), 1, null);
            } catch (IOException e) {
                throw new RestletException(
                    "I/O error while loading script...",
                    Status.SERVER_ERROR_INTERNAL
                );
            } finally {
                Context.exit();
View Full Code Here

Examples of org.geowebcache.rest.RestletException

                } else if (met.equals(Method.PUT)) {
                    doPut(request, response);
                } else if (met.equals(Method.DELETE)) {
                    doDelete(request, response);
                } else {
                    throw new RestletException("Method not allowed",
                        Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
                }
               
                layerDispatcher.reInit();
            }
View Full Code Here

Examples of org.geowebcache.rest.RestletException

        if(formatExtension.equalsIgnoreCase("xml")) {
            return getXMLRepresentation(tl);
        } else if(formatExtension.equalsIgnoreCase("json")) {
            return getJsonRepresentation(tl);
        } else {
            throw new RestletException("Unknown or missing format extension : " + formatExtension,
                    Status.CLIENT_ERROR_BAD_REQUEST);
        }
    }
View Full Code Here

Examples of org.geowebcache.rest.RestletException

     */
    private void doPost(Request req, Response resp)
    throws RestletException, IOException, GeoWebCacheException {
        TileLayer tl = deserializeAndCheckLayer(req, resp, false);
        if( ! xmlConfig.modifyLayer(tl) ) {
            throw new RestletException("Layer " + tl.getName() + " is not known by the configuration."
                    + "Maybe it was loaded from another source, or you're trying to add a new "
                    + "layer and need to do an HTTP PUT ?", Status.CLIENT_ERROR_BAD_REQUEST);
        }
        layerDispatcher.reInit();
    }
View Full Code Here

Examples of org.geowebcache.rest.RestletException

        }
       
        if(testtl == null) {
            xmlConfig.addLayer(tl);
        } else {
            throw new RestletException(
            "Layer with name " + tl.getName() + " already exists, "
            +"use POST if you want to replace it.", Status.CLIENT_ERROR_BAD_REQUEST );
        }
        layerDispatcher.reInit();
    }
View Full Code Here

Examples of org.geowebcache.rest.RestletException

            new HierarchicalStreamCopier().copy(
                    hsr, new PrettyPrintWriter(writer));
            writer.close();
            newLayer = (WMSLayer) xs.fromXML(writer.toString());
        } else {
            throw new RestletException("Unknown or missing format extension: "
                    + formatExtension, Status.CLIENT_ERROR_BAD_REQUEST);
        }

        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);
        }
View Full Code Here

Examples of org.geowebcache.rest.RestletException

                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

Examples of org.geowebcache.rest.RestletException

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

        response.setEntity(makeFormPage(tl), MediaType.TEXT_HTML);
    }
View Full Code Here

Examples of org.geowebcache.rest.RestletException

        }

        Form form = req.getEntityAsForm();

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

        // String layerName = form.getFirst("layerName").getValue();

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

        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) {
            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
TOP
Copyright © 2018 www.massapi.com. 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.