/** * Convenience method for subclasses to look up the (URL-decoded)value of * an attribute from the request, ie {@link Request#getAttributes()}. * * @param attribute The name of the attribute to lookup. * * @return The value as a string, or null if the attribute does not exist * or cannot be url-decoded. */ protected String getAttribute(Request request, String attribute) { return RESTUtils.getAttribute(request, attribute); } //@Override
/** * Convenience method for subclasses to look up the (URL-decoded)value of * an attribute from the request, ie {@link Request#getAttributes()}. * * @param attribute The name of the attribute to lookup. * * @return The value as a string, or null if the attribute does not exist * or cannot be url-decoded. */ protected String getAttribute(String attribute) { return RESTUtils.getAttribute(getRequest(), attribute); }
public static String[] getDirectoryPath(Request request) { String workspace = RESTUtils.getAttribute(request, "workspace"); String datastore = RESTUtils.getAttribute(request, "datastore"); String featureType = RESTUtils.getAttribute(request, "featuretype"); String coveragestore = RESTUtils.getAttribute(request, "coveragestore"); String coverage = RESTUtils.getAttribute(request, "coverage"); List<String> path = new ArrayList<String>(); path.add("workspaces"); if (workspace != null) { path.add(workspace); if (datastore != null) { path.add(datastore); if (featureType != null) { path.add(featureType); } } else if (coveragestore != null) { path.add(coveragestore); if (coverage != null) { path.add(coverage); } } } return path.toArray(new String[] {}); } }
/** * Convenience method for subclasses to look up the (URL-decoded)value of * an attribute from the request, ie {@link Request#getAttributes()}. * * @param attribute THe name of the attribute to lookup. * * @return The value as a string, or null if the attribute does not exist * or cannot be url-decoded. */ protected String getAttribute(String attribute) { return RESTUtils.getAttribute(getRequest(), attribute); }
@Override public boolean allowPost() { return RESTUtils.getAttribute(getRequest(), "transform") == null; }
@Override protected void handleObjectDelete() throws Exception { String transform = RESTUtils.getAttribute(getRequest(), "transform"); TransformInfo info = repository.getTransformInfo(transform); repository.removeTransformInfo(info); }
@Override protected void handleObjectPut(Object object) throws Exception { String transform = RESTUtils.getAttribute(getRequest(), "transform"); if (object instanceof TransformInfo) { TransformInfo info = (TransformInfo) object; // force the right name info.setName(transform); repository.putTransformInfo(info); } else { TransformInfo info = repository.getTransformInfo(transform); repository.putTransformSheet(info, IOUtils.toInputStream((String) object)); } }
@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(); if (format instanceof XSLTDataFormat) { return repository.getTransformSheet(info); } else { return info; } }
@Override public Resource findTarget(Request request, Response response) { String layerName = RESTUtils.getAttribute(request, "layer"); LayerInfo layer = catalog.getLayerByName(layerName); // any of these conditions mean the layer is not currently // advertised in the capabilities document if(layer == null || !layer.isEnabled() || !(layer.getResource() instanceof FeatureTypeInfo)) { throw new RestletException( "No such layer: " + layerName, Status.CLIENT_ERROR_NOT_FOUND ); } final FeatureTypeInfo resource = (FeatureTypeInfo) layer.getResource(); return new DescribeResource(getContext(), request, response, resource); } }
private void applyFilter(Request request, SimpleFeatureType schema, Form form, Query query) { String fid = RESTUtils.getAttribute(request, "fid"); if (fid != null) { final Id fidFilter = FF.id(Collections.singleton(FF.featureId(fid)));
@Override public Resource findTarget(Request request, Response response) { String transform = RESTUtils.getAttribute(request, "transform"); // if it's not referencing a particular transform, return the list if (transform == null && request.getMethod() == Method.GET) { return new TransformListResource(getContext(), request, response, repository); } // ensure referenced transform exist try { if (transform != null && repository.getTransformInfo(transform) == null) { throw new RestletException("No such transform: " + transform, Status.CLIENT_ERROR_NOT_FOUND); } } catch (IOException e) { throw new RestletException("An error occurred while trying to locate the transform: " + transform, Status.SERVER_ERROR_INTERNAL, e); } // return the specific resource return new TransformResource(null, request, response, repository, catalog); }
/** * Build a query based on the * * @param request * @return */ private Query buildQuery(Request request, SimpleFeatureType schema) { // get the query string params as a form Form form = request.getResourceRef().getQueryAsForm(); Query query = new Query(); applyFilter(request, schema, form, query); applyAttributeSelection(schema, form, query); // the following apply only in feature collection mode String fid = RESTUtils.getAttribute(request, "fid"); if (fid == null) { applyMaxFeatures(form, query); applyOffset(form, query); applyOrderBy(schema, form, query); } return query; }
@Override public Resource findTarget(Request request, Response response) { String layerName = RESTUtils.getAttribute(request, "layer"); LayerInfo layer = catalog.getLayerByName(layerName);