Package org.geoserver.rest

Examples of org.geoserver.rest.RestletException


          attributes = fTpInfo.getFeatureType().getDescriptors();
          for (PropertyDescriptor attr : attributes) {
            out.addAttribute(attr.getName().getLocalPart(), attr.getType().getBinding().getSimpleName());
          }
        } catch (IOException e) {
          throw new RestletException("Error generating Attributes List!", Status.CLIENT_ERROR_BAD_REQUEST);
        }

        return out;
      }
    }
View Full Code Here


        PythonInterpreter pi = python.interpreter();
        pi.execfile(appFile.getAbsolutePath());
       
        PyObject app = pi.get("app");
        if (app == null) {
            throw new RestletException("'app' function not found", Status.SERVER_ERROR_INTERNAL);
        }
        if (!(app instanceof PyFunction)) {
            throw new RestletException("'app' must be a function", Status.SERVER_ERROR_INTERNAL);
        }
       
        PyFunction appf = (PyFunction) app;
        PyFunction start_response = createStartResponse();
       
View Full Code Here

    @Override
    public void handlePost() {
        String ext = (String) getRequest().getAttributes().get("ext");
        ScriptSession session = scriptMgr.createNewSession(ext);
        if (session == null) {
            throw new RestletException("Unable to create session", Status.SERVER_ERROR_INTERNAL);
        }

        PageInfo page = (PageInfo) getRequest().getAttributes().get(PageInfo.KEY);

        getResponse().redirectSeeOther(page.pageURI(String.valueOf(session.getId())));
View Full Code Here

                }
            }
            w.flush();
        }
        catch(IOException e) {
            throw new RestletException("i/o error", Status.SERVER_ERROR_INTERNAL, e);
        }
       
        getResponse().setEntity(new OutputRepresentation(MediaType.TEXT_PLAIN) {
            @Override
            public void write(OutputStream outputStream) throws IOException {
View Full Code Here

    @Override
    protected Resource doFindTarget(Request request, Response response) {
        if (request.getAttributes().containsKey("ext")) {
            String ext = (String) request.getAttributes().get("ext");
            if (!scriptMgr.hasEngineForExtension(ext)) {
                throw new RestletException(
                    "Unsupported language: " + ext, Status.CLIENT_ERROR_NOT_FOUND);
            }
        }
        if (request.getAttributes().containsKey("sessson")) {
            try {
                long session = Long.valueOf((String)request.getAttributes().get("session"));
                if (scriptMgr.findSession(session) == null) {
                    throw new RestletException(
                        "No such session: " + session, Status.CLIENT_ERROR_NOT_FOUND);
                }
            }
            catch(NumberFormatException e) {
                throw new RestletException(
                    "Session must be numeric", Status.CLIENT_ERROR_NOT_FOUND, e);
            }
        }
        return new SessionResource(scriptMgr, request, response);
    }
View Full Code Here

        File appDir;
        try {
            appDir = scriptMgr.findAppDir(app);
        } catch (IOException e) {
            throw new RestletException(format("Error looking up app directory %s", app),
                Status.SERVER_ERROR_INTERNAL, e);
        }

        if (appDir == null) {
            throw new RestletException(format("No such app %s", app), Status.CLIENT_ERROR_NOT_FOUND);
        }

        //look for main script
        File main = scriptMgr.findAppMainScript(appDir);
        if (main == null) {
            throw new RestletException(format("No main file for app %s", app), Status.CLIENT_ERROR_NOT_FOUND);
        }

        return new AppResource(main, scriptMgr, request, response);
    }
View Full Code Here

    public void handleGet() {
        File appRoot;
        try {
            appRoot = scriptMgr.getAppRoot();
        } catch (IOException e) {
            throw new RestletException("Error looking up apps", Status.SERVER_ERROR_INTERNAL, e);
        }

        File[] apps = appRoot.listFiles(new FileFilter() {
            @Override
            public boolean accept(File pathname) {
View Full Code Here

    @Override
    public void handleGet() {
        try {
            ScriptEngine eng = scriptMgr.createNewEngine(script);
            if (eng == null) {
                throw new RestletException(format("Script engine for %s not found", script.getName()),
                    Status.CLIENT_ERROR_BAD_REQUEST);
            }

            //look up the app hook
            AppHook hook = scriptMgr.lookupAppHook(script);
            if (hook == null) {
                //TODO: fall back on default
                throw new RestletException(format("No hook found for %s", script.getPath()),
                    Status.SERVER_ERROR_INTERNAL);
            }

            Reader in = new BufferedReader(new FileReader(script));
            try {
                eng.eval(in);
                hook.run(getRequest(), getResponse(), eng);
            }
            finally {
                in.close();
            }
        }
        catch (Exception e) {
            LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e);
            throw new RestletException("Error executing script " + script.getName(),
                Status.SERVER_ERROR_INTERNAL, e);
        }
    }
View Full Code Here

    @Override
    protected Object handleObjectGet() throws Exception {
        String transform = RESTUtils.getAttribute(getRequest(), "transform");
        if (transform == null) {
            throw new RestletException("Failed to locate transformation " + transform,
                    Status.CLIENT_ERROR_NOT_FOUND);
        }

        TransformInfo info = repository.getTransformInfo(transform);
        DataFormat format = getFormatGet();
View Full Code Here

        return info.getName();
    }

    private void validate(TransformInfo info) {
        if (info.getSourceFormat() == null) {
            throw new RestletException("The transformation must have a source format",
                    Status.CLIENT_ERROR_BAD_REQUEST);
        }
        if (info.getOutputFormat() == null) {
            throw new RestletException("The transformation must have an output format",
                    Status.CLIENT_ERROR_BAD_REQUEST);
        }
    }
View Full Code Here

TOP

Related Classes of org.geoserver.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.