Package org.geoserver.ows.util

Examples of org.geoserver.ows.util.CaseInsensitiveMap


    @Test
    public void testDispatchGetMapWithMatchingParameterFilters() throws Exception {
        GetMapRequest request = new GetMapRequest();

        @SuppressWarnings("unchecked")
        Map<String, String> rawKvp = new CaseInsensitiveMap(new HashMap<String, String>());
        request.setRawKvp(rawKvp);
        request.setFormat("image/png");
        request.setSRS("EPSG:900913");
        request.setWidth(256);
        request.setHeight(256);
        rawKvp.put("layers", tileLayer.getName());

        // tileLayer = mockTileLayer("mockLayer", ImmutableList.of("EPSG:900913", "EPSG:4326"));

        // make the request match a tile in the expected gridset
        BoundingBox bounds;
View Full Code Here


                // multipart form upload
                ServletFileUpload up = new ServletFileUpload();
                up.setFileItemFactory(new DiskFileItemFactory());

                // treat regular form fields as additional kvp parameters
                Map<String,FileItem> kvpFileItems = new CaseInsensitiveMap(new LinkedHashMap());
                try {
                    for (FileItem item : (List<FileItem>) up.parseRequest(httpRequest)) {
                        if (item.isFormField()) {
                            kvpFileItems.put(item.getFieldName(), item);
                        }
                        else {
                            request.setInput(fileItemReader(item));
                        }
                    }
                } catch (Exception e) {
                    throw new ServiceException("Error handling multipart/form-data content", e);
                }

                // if no file fields were found, look for one named "body"
                if (request.getInput() == null) {
                    FileItem body = kvpFileItems.get("body");
                    if (body != null) {
                        request.setInput(fileItemReader(body));
                        kvpFileItems.remove("body");
                    }
                }

                Map<String,String> kvpItems = new LinkedHashMap();
                for (Map.Entry<String,FileItem> e : kvpFileItems.entrySet()) {
                    kvpItems.put(e.getKey(), e.getValue().toString());
                }

                request.setOrAppendKvp(parseKVP(request, kvpFileItems));
            }
View Full Code Here

        return false;
    }

    void encodeKMLLink(Folder container, Layer layer, String name, int drawOrder, Envelope box) {
        // copy the format options
        CaseInsensitiveMap fo = new CaseInsensitiveMap(new HashMap());
        fo.putAll(mapContent.getRequest().getFormatOptions());

        // we want to pass through format options except for superoverlay, we need to
        // turn it off so we get actual placemarks back, and not more links
        fo.remove("superoverlay");

        // get the regionate mode
        String overlayMode = (String) fo.get("overlayMode");

        if ("overview".equalsIgnoreCase(overlayMode)) {
            // overview mode, turn off regionation
            fo.remove("regionateBy");
        } else {
            // specify regionateBy=auto if not specified
            if (!fo.containsKey("regionateBy")) {
                fo.put("regionateBy", "auto");
            }

        }
        String foEncoded = WMSRequests.encodeFormatOptions(fo);
View Full Code Here

        this.applicationContext = applicationContext;
    }

    public Object parse(String value) throws Exception {
        List parsers = GeoServerExtensions.extensions(KvpParser.class, applicationContext);
        Map formatOptions = new CaseInsensitiveMap(new TreeMap());

        List<String> kvps = KvpUtils.escapedTokens(value, ';');
       
        for (String kvp : kvps) {
            List<String> kv = KvpUtils.escapedTokens(kvp, ':', 2);
            String key = kv.get(0);
            String raw = kv.size() == 1 ? "true" : KvpUtils.unescape(kv.get(1));
              
            Object parsed = null;

            for (Iterator p = parsers.iterator(); p.hasNext();) {
                KvpParser parser = (KvpParser) p.next();
                if ( key.equalsIgnoreCase( parser.getKey() ) ) {
                    parsed = parser.parse( raw );
                    if ( parsed != null ) {

                        break;
                    }
                }
            }

            if (parsed == null) {
                if(LOGGER.isLoggable(Level.FINER))
                    LOGGER.finer( "Could not find kvp parser for: '" + key + "'. Storing as raw string.");
                parsed = raw;
            }

            formatOptions.put(key, parsed);
        }

        return formatOptions;
    }
View Full Code Here

        this.applicationContext = applicationContext;
    }

    public Object parse(String value) throws Exception {
        List parsers = GeoServerExtensions.extensions(KvpParser.class, applicationContext);
        Map formatOptions = new CaseInsensitiveMap(new HashMap());

        List<String> kvps = KvpUtils.escapedTokens(value, ';');
       
        for (String kvp : kvps) {
           
            List<String> kv = KvpUtils.escapedTokens(kvp, ':');
            if (kv.size() > 2) {
                throw new IllegalArgumentException("Invalid key-value pair length (" + kv.size() + " elements).");
            }
            String key = kv.get(0);
            String raw = kv.size() == 1 ? "true" : KvpUtils.unescape(kv.get(1));
              
            Object parsed = null;

            for (Iterator p = parsers.iterator(); p.hasNext();) {
                KvpParser parser = (KvpParser) p.next();
                if ( key.equalsIgnoreCase( parser.getKey() ) ) {
                    parsed = parser.parse( raw );
                    if ( parsed != null ) {

                        break;
                    }
                }
            }

            if (parsed == null) {
                if(LOGGER.isLoggable(Level.FINER))
                    LOGGER.finer( "Could not find kvp parser for: '" + key + "'. Storing as raw string.");
                parsed = raw;
            }

            formatOptions.put(key, parsed);
        }

        return formatOptions;
    }
View Full Code Here

TOP

Related Classes of org.geoserver.ows.util.CaseInsensitiveMap

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.