Package org.geowebcache.conveyor

Examples of org.geowebcache.conveyor.ConveyorTile


            gridSubset.checkCoverage(tileIndex);
        } catch (OutsideCoverageException e) {

        }

        ConveyorTile convTile = new ConveyorTile(sb, layer, gridSubset.getName(), tileIndex,
                mimeType, fullParameters, request, response);

        convTile.setTileLayer(tileLayer);

        return convTile;
    }
View Full Code Here


        return convTile;
    }

    public void handleRequest(Conveyor conv) throws OWSException {

        ConveyorTile tile = (ConveyorTile) conv;

        if (tile.getHint() != null) {
            if (tile.getHint().equals("getcapabilities")) {
                WMTSGetCapabilities wmsGC = new WMTSGetCapabilities(tld, gsb, tile.servletReq);
                wmsGC.writeResponse(tile.servletResp, stats);

            } else if (tile.getHint().equals("getfeatureinfo")) {
                ConveyorTile convTile = (ConveyorTile) conv;
                WMTSGetFeatureInfo wmsGFI = new WMTSGetFeatureInfo(convTile);
                wmsGFI.writeResponse(stats);
            }
        }
    }
View Full Code Here

        request.setupAddParameter("y", "0");

        GMapsConverter converter = new GMapsConverter(sb, tld, gsb);

        try {
            ConveyorTile conveyorTile = converter.getConveyor(request, response);
            Map<String, String> parameters = conveyorTile.getParameters();
            assertNotNull(parameters);
            // assertTrue(parameters.contains(URLEncoder.encode(CQL_FILTER_PARAMETER_VALUE,"UTF8")));
            assertEquals(CQL_FILTER_PARAMETER_VALUE,
                    URLDecoder.decode(parameters.get(CQL_FILTER_PARAMETER_NAME), "UTF8"));
        } catch (ServiceException e) {
View Full Code Here

       
        int paramsLength = params.length;
       
        if(params.length < 4) {
            // Not a tile request, lets pass it back out
            ConveyorTile tile = new ConveyorTile(sb, null, request, response);
            tile.setRequestHandler(ConveyorTile.RequestHandler.SERVICE);
            return tile;
        }
       
        long[] gridLoc = new long[3];
       
        String[] yExt = params[paramsLength - 1].split("\\.");
       
        try {
            gridLoc[0] = Integer.parseInt(params[paramsLength - 2]);
            gridLoc[1] = Integer.parseInt(yExt[0]);
            gridLoc[2] = Integer.parseInt(params[paramsLength - 3]);
        } catch (NumberFormatException nfe) {
            throw new ServiceException("Unable to parse number " + nfe.getMessage() + " from " + pathInfo);
        }

        String layerId;
        String gridSetId;
       
        // For backwards compatibility, we'll look for @s and use defaults if not found
        String layerNameAndSRS = params[2];
        String[] lsf = ServletUtils.URLDecode(layerNameAndSRS, request.getCharacterEncoding()).split("@");
        if(lsf.length < 3) {
            layerId = lsf[0];
            TileLayer layer = tld.getTileLayer(layerId);
            gridSetId = layer.getGridSubsets().values().iterator().next().getName();
        } else {
           layerId = lsf[0];
           gridSetId = lsf[1];
           // We don't actually care about the format, we'll pick it from the extension
        }

        MimeType mimeType = null;
        try {
            mimeType = MimeType.createFromExtension(yExt[1]);
        } catch (MimeException me) {
            throw new ServiceException("Unable to determine requested format based on extension " + yExt[1]);
        }

        ConveyorTile ret = new ConveyorTile(sb, layerId, gridSetId, gridLoc, mimeType, null, request, response);
       
        return ret;
    }
View Full Code Here

            }
        } catch (MimeException me) {
            // not a GWC supported format
            return null;
        }
        ConveyorTile tileResp = null;

        try {
            HttpServletRequest servletReq = null;
            HttpServletResponse servletResp = null;
            final String gridSetId;
            long[] tileIndex;
            gridSetId = gridSubset.getName();
            Envelope bbox = request.getBbox();
            BoundingBox tileBounds = new BoundingBox(bbox.getMinX(), bbox.getMinY(),
                    bbox.getMaxX(), bbox.getMaxY());
            try {
                tileIndex = gridSubset.closestIndex(tileBounds);
            } catch (GridMismatchException e) {
                return null;
            }

            Map<String, String> fullParameters = null;
            Map<String, String> modifiedParameters = null;
            ConveyorTile tileReq;
            tileReq = new ConveyorTile(storageBroker, layerName, gridSetId, tileIndex, mimeType,
                    fullParameters, modifiedParameters, servletReq, servletResp);

            tileResp = tileLayer.getTile(tileReq);
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

        Assert.isInstanceOf(GetMapRequest.class, arguments[0]);

        final GetMapRequest request = (GetMapRequest) arguments[0];
        boolean tiled = request.isTiled();
        if (tiled) {
            ConveyorTile cachedTile = gwc.dispatch(request);
            if (cachedTile != null) {
                if (LOGGER.isLoggable(Level.FINEST)) {
                    LOGGER.finest("GetMap request intercepted, serving cached content: " + request);
                }
                // Handle Etags
                final String ifNoneMatch = request.getHttpRequestHeader("If-None-Match");
                final String hexTag = Long.toHexString(cachedTile.getTSCreated());
                if (hexTag.equals(ifNoneMatch)) {
                    // Client already has the current version
                    LOGGER.finer("ETag matches, returning 304");
                    throw new HttpErrorCodeException(HttpServletResponse.SC_NOT_MODIFIED);
                }

                LOGGER.finer("No matching ETag, returning cached tile");
                final byte[] mapContents = cachedTile.getContent();
                final String mimeType = cachedTile.getMimeType().getMimeType();
                RawMap map = new RawMap(null, mapContents, mimeType);
                map.setResponseHeader("Cache-Control", "no-cache");
                map.setResponseHeader("ETag", Long.toHexString(cachedTile.getTSCreated()));
                return map;
            }
        }

        return (WebMap) invocation.proceed();
View Full Code Here

        if (!tiled) {
            return (WebMap) invocation.proceed();
        }

        final StringBuilder requestMistmatchTarget = new StringBuilder();
        ConveyorTile cachedTile = gwc.dispatch(request, requestMistmatchTarget);

        if (cachedTile == null) {
            WebMap dynamicResult = (WebMap) invocation.proceed();
            dynamicResult.setResponseHeader("geowebcache-cache-result", MISS.toString());
            dynamicResult.setResponseHeader("geowebcache-miss-reason",
                    requestMistmatchTarget.toString());
            return dynamicResult;
        }
        checkState(cachedTile.getTileLayer() != null);
        final TileLayer layer = cachedTile.getTileLayer();

        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("GetMap request intercepted, serving cached content: " + request);
        }

        final byte[] tileBytes;
        {
            final Resource mapContents = cachedTile.getBlob();
            if (mapContents instanceof ByteArrayResource) {
                tileBytes = ((ByteArrayResource) mapContents).getContents();
            } else {
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                mapContents.transferTo(Channels.newChannel(out));
                tileBytes = out.toByteArray();
            }
        }

        // Handle Etags
        final String ifNoneMatch = request.getHttpRequestHeader("If-None-Match");
        final byte[] hash = MessageDigest.getInstance("MD5").digest(tileBytes);
        final String etag = toHexString(hash);
        if (etag.equals(ifNoneMatch)) {
            // Client already has the current version
            LOGGER.finer("ETag matches, returning 304");
            throw new HttpErrorCodeException(HttpServletResponse.SC_NOT_MODIFIED);
        }

        LOGGER.finer("No matching ETag, returning cached tile");
        final String mimeType = cachedTile.getMimeType().getMimeType();

        RawMap map = new RawMap(null, tileBytes, mimeType);

        map.setContentDispositionHeader(null, "." + cachedTile.getMimeType().getFileExtension(), false);

        Integer cacheAgeMax = getCacheAge(layer);
        LOGGER.log(Level.FINE, "Using cacheAgeMax {0}", cacheAgeMax);
        if (cacheAgeMax != null) {
            map.setResponseHeader("Cache-Control", "max-age=" + cacheAgeMax);
View Full Code Here

        if (!tileLayer.isEnabled()) {
            requestMistmatchTarget.append("tile layer disabled");
            return null;
        }

        ConveyorTile tileReq = prepareRequest(tileLayer, request, requestMistmatchTarget);
        if (null == tileReq) {
            return null;
        }
        ConveyorTile tileResp = null;
        try {
            tileResp = tileLayer.getTile(tileReq);
        } catch (Exception e) {
            log.log(Level.INFO, "Error dispatching tile request to GeoServer", e);
        }
View Full Code Here

                    .append(rootCause.getClass().getSimpleName()).append(": ")
                    .append(e.getMessage());
            return null;
        }

        ConveyorTile tileReq;
        final String gridSetId = gridSubset.getName();
        HttpServletRequest servletReq = null;
        HttpServletResponse servletResp = null;
        String layerName = tileLayer.getName();
        tileReq = new ConveyorTile(storageBroker, layerName, gridSetId, tileIndex, mimeType,
                fullParameters, servletReq, servletResp);
        return tileReq;
    }
View Full Code Here

    @SuppressWarnings({ "unchecked", "rawtypes" })
    public void testGetFeatureInfo() throws Exception {

        layerInfoTileLayer = new GeoServerTileLayer(layerInfo, defaults, gridSetBroker);

        ConveyorTile convTile = new ConveyorTile(null, null, null, null);
        convTile.setTileLayer(layerInfoTileLayer);
        convTile.setMimeType(MimeType.createFromFormat("image/png"));
        convTile.setGridSetId("EPSG:4326");
        convTile.servletReq = new MockHttpServletRequest();
        BoundingBox bbox = new BoundingBox(0, 0, 10, 10);

        Resource mockResult = mock(Resource.class);
        ArgumentCaptor<Map> argument = ArgumentCaptor.forClass(Map.class);
View Full Code Here

TOP

Related Classes of org.geowebcache.conveyor.ConveyorTile

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.