Package org.geoserver.rest

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


                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

                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);
                Object wrappedLoader = Context.javaToJS(resourceLoader, scope);

                ScriptableObject.putProperty(scope, "request", wrappedRequest);
                ScriptableObject
                    .putProperty(scope, "response", wrappedResponse);
                ScriptableObject.putProperty(scope, "loader", wrappedLoader);
                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

        }
        else {
            //return the individual
            RequestData data = monitor.getDAO().getRequest(Long.parseLong(req));
            if (data == null) {
                throw new RestletException("No such request" + req, Status.CLIENT_ERROR_NOT_FOUND);
            }
            return data;
        }
    }
View Full Code Here

       
        if ( layer != null) {
            return new ClassifierResource(getContext(),request,response,catalog);
        }
       
        throw new RestletException( "No such layer: " + layer, Status.CLIENT_ERROR_NOT_FOUND );
    }
View Full Code Here

       
        if ( layer != null) {
            return new RasterizerResource(getContext(),request,response,catalog);
        }
       
        throw new RestletException( "No such layer: " + layer, Status.CLIENT_ERROR_NOT_FOUND );
    }
View Full Code Here

       
        if ( layer != null && request.getMethod() == Method.GET ) {
            return new ListAttributesResource(getContext(),request,response,catalog);
        }
       
        throw new RestletException( "No such layer: " + layer, Status.CLIENT_ERROR_NOT_FOUND );
    }
View Full Code Here

        jsonRules = generateRulesList(layer, getRequest(), rules);

      if (jsonRules != null) {
        return jsonRules;
      } else {
        throw new RestletException("Error generating Classification!", Status.CLIENT_ERROR_BAD_REQUEST);
      }
    }
   
    return new ArrayList();
  }
View Full Code Here

          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

       
        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);
       
        //check the format, if specified as sld, return the sld itself
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.