Package org.geoserver.rest

Examples of org.geoserver.rest.RestletException


            //importer.prep(context);
            //context.updated();
        } catch (ValidationException ve) {
            throw ImportJSONWriter.badRequest(ve.getMessage());
        } catch (IOException e) {
            throw new RestletException("Error updating context", Status.SERVER_ERROR_INTERNAL, e);
        }

        if (!newTasks.isEmpty()) {
            Object result = newTasks;
            if (newTasks.size() == 1) {
View Full Code Here


        }
   
        try {
            return Directory.createNew(importer.getUploadRoot());
        } catch (IOException ioe) {
            throw new RestletException("File upload failed", Status.SERVER_ERROR_INTERNAL, ioe);
        }
    }
View Full Code Here

        Directory directory = findOrCreateDirectory(context);

        try {
            directory.accept(getAttribute("task"),getRequest().getEntity().getStream());
        } catch (IOException e) {
            throw new RestletException("Error unpacking file",
                Status.SERVER_ERROR_INTERNAL, e);
        }
       
        return directory;
    }
View Full Code Here

        RestletFileUpload upload = new RestletFileUpload(factory);
        List<FileItem> items = null;
        try {
            items = upload.parseRequest(getRequest());
        } catch (FileUploadException e) {
            throw new RestletException("File upload failed", Status.SERVER_ERROR_INTERNAL, e);
        }

        //look for a directory to hold the files
        Directory directory = findOrCreateDirectory(context);

        //unpack all the files
        for (FileItem item : items) {
            if (item.getName() == null) {
                continue;
            }
            try {
                directory.accept(item);
            } catch (Exception ex) {
                throw new RestletException("Error writing file " + item.getName(), Status.SERVER_ERROR_INTERNAL, ex);
            }
        }
        return directory;
    }
View Full Code Here

        if (task == null) {
            if (allowAll) {
                return context().getTasks();
            }
            throw new RestletException("No task specified", Status.CLIENT_ERROR_BAD_REQUEST);       
        }
        return task;
    }
View Full Code Here

            orig.setTransform(chain);
            change = true;
        }

        if (!change) {
            throw new RestletException("Unknown representation", Status.CLIENT_ERROR_BAD_REQUEST);
        } else {
            importer.changed(orig);
            getResponse().setStatus(Status.SUCCESS_NO_CONTENT);
        }
    }
View Full Code Here

   
    private ImportData handleFormPost() {
        Form form = getRequest().getEntityAsForm();
        String url = form.getFirstValue("url", null);
        if (url == null) {
            throw new RestletException("Invalid request", Status.CLIENT_ERROR_BAD_REQUEST);
        }
        URL location = null;
        try {
            location = new URL(url);
        } catch (MalformedURLException ex) {
            getLogger().warning("invalid URL specified in upload : " + url);
        }
        // @todo handling remote URL implies asynchronous processing at this stage
        if (location == null || !location.getProtocol().equalsIgnoreCase("file")) {
            throw new RestletException("Invalid url in request", Status.CLIENT_ERROR_BAD_REQUEST);
        }
        FileData file;
        try {
            file = FileData.createFromFile(new File(location.toURI().getPath()));
        } catch (Exception ex) {
            throw new RuntimeException("Unexpected exception", ex);
        }

        if (file instanceof Directory) {
            try {
                file.prepare();
            } catch (IOException ioe) {
                String msg = "Error processing file: " + file.getFile().getAbsolutePath();
                getLogger().log(Level.WARNING, msg, ioe);
                throw new RestletException(msg, Status.SERVER_ERROR_INTERNAL);
            }
        }

        return file;
    }
View Full Code Here

                        progress.put("message", task.getError().getMessage());
                    }
                }
            }
        } catch (JSONException jex) {
            throw new RestletException("Internal Error", Status.SERVER_ERROR_INTERNAL, jex);
        }
        return new JSONRepresentation(progress);
    }
View Full Code Here

       
        StyleInfo defaultStyle = layerInfo.getDefaultStyle();
        RasterSymbolizer rasterSymbolizer = getRasterSymbolizer(defaultStyle);
       
        if (rasterSymbolizer == null) {
          throw new RestletException( "RasterSymbolizer SLD expected!", Status.CLIENT_ERROR_EXPECTATION_FAILED);
        }
       
        Style rasterized = remapStyle(defaultStyle, rasterSymbolizer, min, max, classes, ramp, layer, digits, colormapType);
       
        //check the format, if specified as sld, return the sld itself
View Full Code Here

            if (path.contains(":")) {
                path = path.replace(":","/");
            }
            script = scriptMgr.findScriptFile(path);
        } catch (IOException e) {
            throw new RestletException(format("Error looking up script %s", path),
                Status.SERVER_ERROR_INTERNAL, e);
        }
        if (script == null) {
            throw new RestletException(format("Could not find script %s", path),
                Status.CLIENT_ERROR_NOT_FOUND);
        }

        //TODO: set different content type?
        //TODO: not sure about this time to live parameter... 
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.