Package org.geowebcache.io

Examples of org.geowebcache.io.Resource


     */
    @Override
    public ConveyorTile getTile(final ConveyorTile tile) throws GeoWebCacheException, IOException,
            OutsideCoverageException {

        Resource tileContent = null;

        if (storageFormat.equals(CacheStorageInfo.COMPACT_FORMAT_CODE)) {
            final long[] tileIndex = tile.getTileIndex();
            final String gridSetId = tile.getGridSetId();
            final GridSubset gridSubset = this.getGridSubset(gridSetId);
View Full Code Here


        URL url = getClass().getResource("/compactcache/_alllayers/");
        ArcGISCompactCache cache = new ArcGISCompactCache(url.toURI().getPath());

        assertNotNull(cache);

        Resource resource = cache.getBundleFileResource(5, 0, 0);
        assertNotNull(resource);

        resource = cache.getBundleFileResource(5, 12, 7);
        assertNotNull(resource);
        assertEquals(6342, resource.getSize());

        File f = new File("5_12_7.jpg");
        FileOutputStream fos = new FileOutputStream(f);
        resource.transferTo(fos.getChannel());
        fos.close();

        assertTrue(startsWithJPEGHeader(f));

        f.delete();

        resource = cache.getBundleFileResource(6, 25, 17);
        assertNotNull(resource);
        assertEquals(6308, resource.getSize());

        f = new File("6_25_17.jpg");
        fos = new FileOutputStream(f);
        resource.transferTo(fos.getChannel());
        fos.close();

        assertTrue(startsWithJPEGHeader(f));

        f.delete();
View Full Code Here

        writeTileResponse(conv, writeExpiration, null, null);
    }
   
    protected static void writeTileResponse(ConveyorTile conv, boolean writeExpiration, RuntimeStats stats, String mimeTypeOverride) {
        HttpServletResponse response = conv.servletResp;
        Resource data = conv.getBlob();

        String mimeStr;
        if(mimeTypeOverride == null){
            mimeStr = conv.getMimeType().getMimeType();
        }else{
            mimeStr = mimeTypeOverride;
        }
       
        response.setCharacterEncoding("utf-8");

        response.setStatus((int) conv.getStatus());

        TileLayer layer = conv.getLayer();
        if (layer != null) {
            layer.setExpirationHeader(conv.servletResp, (int) conv.getTileIndex()[2]);
        }

        if (writeExpiration) {
            conv.getLayer().setExpirationHeader(response, (int) conv.getTileIndex()[2]);
        }

        response.setContentType(mimeStr);

        int size = (int)data.getSize();
        response.setContentLength(size);

        try {
            OutputStream os = response.getOutputStream();
            WritableByteChannel channel = Channels.newChannel(os);
            data.transferTo(channel);
           
            if(stats != null) {
                stats.log(size, conv.getCacheResult());
            }
        } catch (IOException ioe) {
View Full Code Here

    private boolean setLayerBlankTile(ConveyorTile tile) {
        // TODO cache result
        String layerPath = getLayerPath().append(File.separatorChar).toString();
        File png = new File(layerPath + "blank.png");
        Resource blank = null;
        try {
            if (png.exists()) {
                blank = readFile(png);
                tile.setBlob(blank);
                tile.setMimeType(MimeType.createFromFormat("image/png"));
View Full Code Here

    private Resource readFile(File fh) {
        if (!fh.exists()) {
            return null;
        }
        Resource res = new FileResource(fh);
        return res;
    }
View Full Code Here

        // Should we do mime type checks?

        // note: not using getImageBuffer() here cause this method is not called during seeding, so
        // there's no gain
        Resource buffer = new ByteArrayResource(2048);
        sourceHelper.makeRequest(tile, buffer);
        tile.setBlob(buffer);

        return tile;
    }
View Full Code Here

                    continue;
                }

                layer.getTile(tile);
                // Selection of the resource input stream
                Resource blob = tile.getBlob();
                // Extraction of the image associated with the defined MimeType
                String formatName = srcFormat.getMimeType();
                BufferedImage tileImg = decoderMap.decode(formatName, blob,
                        decoderMap.isAggressiveInputStreamSupported(formatName), null);
View Full Code Here

        } catch (NumberFormatException nfe) {
            throw new GeoWebCacheException(
                    "The parameters for height and width must both be positive integers.");
        }

        Resource data = tl.getFeatureInfo(gfiConv, bbox, height, width, x, y);

        try {
            tile.servletResp.setContentType(mimeType.getMimeType());
            ServletOutputStream outputStream = tile.servletResp.getOutputStream();
            data.transferTo(Channels.newChannel(outputStream));
            outputStream.flush();
        } catch (IOException ioe) {
            tile.servletResp.setStatus(500);
            log.error(ioe.getMessage());
        }
View Full Code Here

        return new ByteArrayResource(green);
    }

   
    public Resource getResponse() {
        Resource ret = greenTile;
        if (ret == null) {
            synchronized (GreenTileException.class) {
                ret = greenTile;
                if (greenTile == null) {
                    greenTile = ret = getGreenTile();
View Full Code Here

    public static final String TEST_BLOB_DIR_NAME = "gwcTestBlobs";

    public void testTile() throws Exception {
        FileBlobStore fbs = setup();

        Resource bytes = new ByteArrayResource("1 2 3 4 5 6 test".getBytes());
        long[] xyz = { 1L, 2L, 3L };
        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put("a", "x");
        parameters.put("b", "ø");
        TileObject to = TileObject.createCompleteTileObject("test:123123 112", xyz, "EPSG:4326",
View Full Code Here

TOP

Related Classes of org.geowebcache.io.Resource

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.