Package org.geoserver.rest

Examples of org.geoserver.rest.RestletException


            contentType = req.getEntity().getMediaType().toString();
        }

        if (uploadFilter.filter(contentType, temp)) {
            if (!temp.renameTo(f)) {
                throw new RestletException(
                        "Unable to rename temp file to persisted file in upload restlet",
                        Status.SERVER_ERROR_INTERNAL);
            }
        } else {
            resp.setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
View Full Code Here


    }

    private void doUpload(String contentType, File content, Request req, Response resp)
    throws IOException {
        if (!rootPath.exists() && !rootPath.mkdirs()) {
            throw new RestletException(
                    "Unable to create storage directory for uploaded files",
                    Status.SERVER_ERROR_INTERNAL);
        }

        List<String> l = fileStorage.handleUpload(contentType, content, myIDGenerator, rootPath);
View Full Code Here

    } catch(RestletException e){
      hadRestletException = true;
    }
    assertTrue("getContext did not fail with RestletException when given bogus namespace and type",hadRestletException);
   
    RestletException re = null;
    try{
      context = lap.getContext("sf", "badType", request);
    } catch(RestletException e){
      re = e;
    }
    assertNotNull("getContext should fail when given bogus namespace but good type", re);
        assertEquals("the error code should be a 404", Status.CLIENT_ERROR_NOT_FOUND, re.getStatus());
   

        getFeatureTypeInfo(MockData.GENERICENTITY).getMetadata().put("indexingEnabled", true);
    context = lap.getContext("sf", "GenericEntity", request);   
View Full Code Here

            }

            if (f.delete()) {
                resp.setStatus(Status.SUCCESS_OK);
            } else {
                throw new RestletException("Unable to delete file on server",
                        Status.SERVER_ERROR_INTERNAL);
            }
    }
View Full Code Here

   
    SimpleHash getContext(String namespace, String layer, Request request){
      FeatureTypeInfo info = lookupType(namespace, layer);
        
        if (!(Boolean)info.getMetadata().get("indexingEnabled")) {
            throw new RestletException(
                    "Layer indexing disabled",
                    Status.CLIENT_ERROR_FORBIDDEN
                    );
        }
     
View Full Code Here

    }

    private FeatureTypeInfo lookupType(String namespace, String layer){
        NamespaceInfo ns = catalog.getNamespaceByPrefix(namespace);
        if (ns == null) {
            throw new RestletException(
                    "No such namespace: " + namespace,
                    Status.CLIENT_ERROR_NOT_FOUND
                    );
        }

        FeatureTypeInfo featureType = null;
        try {
            featureType = catalog.getFeatureTypeByName(ns, layer);
        } catch(Exception e) {
            throw new RestletException(
                "No such featuretype: " + namespace + ":" + layer,
                 Status.CLIENT_ERROR_NOT_FOUND
            );
        }

        if (featureType == null) {
            throw new RestletException(
                    "No such featuretype: " + namespace + ":" + layer,
                     Status.CLIENT_ERROR_NOT_FOUND
                    );
        }
View Full Code Here

            regionateAttr = form.getFirstValue("regionateAttr", true);

            NamespaceInfo ns = catalog.getNamespaceByPrefix(namespace);
            if (ns == null) {
                throw new RestletException("No such namespace:" + namespace,
                        Status.CLIENT_ERROR_NOT_FOUND);
            }

            FeatureTypeInfo featureType = null;
            try {
                featureType = catalog.getFeatureTypeByName(ns, layer);
            } catch (NoSuchElementException e) {
                // ignore, handled later
            }

            if (featureType == null) {
                throw new RestletException("No such layer:" + layer,
                        Status.CLIENT_ERROR_NOT_FOUND);
            }

            if (!(Boolean)featureType.getMetadata().get("indexingEnabled")) {
                throw new RestletException("Layer not indexable: " + layer,
                        Status.CLIENT_ERROR_FORBIDDEN);
            }

            // create some kvp and pass through to GetMapKvpreader
            KvpMap raw = new KvpMap();
View Full Code Here

        String namespace = (String)req.getAttributes().get("namespace");
        String feature = (String)req.getAttributes().get("feature");
       
        NamespaceInfo ns = myCatalog.getNamespaceByPrefix(namespace);
        if ( ns == null ) {
            throw new RestletException(
                    "No such namespace:" + namespace,
                    Status.CLIENT_ERROR_NOT_FOUND
                    );
        }

        FeatureTypeInfo featureType = null;
        try {
            featureType = myCatalog.getFeatureTypeByName(ns, layer);
        } catch (NoSuchElementException e) {
            throw new RestletException(
                e.getMessage(),
                Status.CLIENT_ERROR_NOT_FOUND
            );
        }

        if (!(Boolean)featureType.getMetadata().get("indexingEnabled")){
            throw new RestletException(
                "Indexing is disabled for this layer (" + ns + ":" + layer + ") "
                + featureType.getMetadata().get("indexingEnabled"),
                Status.CLIENT_ERROR_FORBIDDEN
                );
        }

        DefaultQuery q = new DefaultQuery();
        FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);

        q.setFilter(ff.id(Collections.singleton(ff.featureId(feature))));

        FeatureCollection col = null;
        try {
            col = featureType.getFeatureSource(null, null).getFeatures(q);
        } catch (IOException e) {
            throw new RestletException(
                    e.getMessage(),
                    Status.SERVER_ERROR_INTERNAL
                    );
        }

        if (col.size() != 1) {
            throw new RestletException(
                "Unexpected results from data query, "
                + "should be exactly one feature with given ID",
                Status.SERVER_ERROR_INTERNAL
            );
        }
View Full Code Here

            //connection
            connection.setRequestMethod(request.getMethod().toString());

            /*Check if this request is permitted to be forwarded*/
            if (checkPermission(resolved, connection.getContentType()) != true) {
                throw new RestletException("Request for nonpermitted content type or hostname",
                        Status.CLIENT_ERROR_BAD_REQUEST);
            }
               
            /*Appropriately forward the message*/
            if (request.getMethod().equals(Method.PUT)
                    || request.getMethod().equals(Method.POST)) {
                //connection.setDoOutput(true);
                copyStream(request.getEntity().getStream(), connection.getOutputStream());
            }
               
            response.setEntity(new StreamRepresentation(new MediaType(connection
                    .getContentType())) {
                @Override
                public void write(OutputStream out) throws IOException {
                    copyStream(connection.getInputStream(), out);
                }

                @Override
                public InputStream getStream() throws IOException {
                    throw new UnsupportedOperationException();
                }
            });
        /*If the request is broken, offer appropriate notice*/
        } catch (MalformedURLException e) {
            LOGGER.log(Level.WARNING, "Invalid proxy request. ", e);
            throw new RestletException("Invalid proxy request", Status.CLIENT_ERROR_BAD_REQUEST);
        } catch (IOException e) {
            LOGGER.log(Level.WARNING, "Couldn't connect to proxied service", e);
            throw new RestletException("Couldn't connect to proxied service",
                    Status.SERVER_ERROR_BAD_GATEWAY);
        }
    }
View Full Code Here

    protected String handleObjectPost(Object object) throws Exception {
        LayerGroupInfo lg = (LayerGroupInfo) object;
        LOGGER.info( "POST layer group " + lg.getName() );
       
        if ( lg.getLayers().isEmpty() ) {
            throw new RestletException( "layer group must not be empty", Status.CLIENT_ERROR_BAD_REQUEST );
        }
      
        if ( lg.getBounds() == null ) {
            LOGGER.fine( "Auto calculating layer group bounds");
            new CatalogBuilder( catalog ).calculateLayerGroupBounds(lg);
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.