Package org.geowebcache

Examples of org.geowebcache.GeoWebCacheException


                            } else {
                                tileProto.getStorageBroker().put(tile);
                            }
                            tileProto.getStorageObject().setCreated(tile.getCreated());
                        } catch (StorageException e) {
                            throw new GeoWebCacheException(e);
                        }
                    }
                } catch (IOException ioe) {
                    log.error("Unable to write image tile to " + "ByteArrayOutputStream: "
                            + ioe.getMessage());
View Full Code Here


            TileLayer layer = configuration.getTileLayer(layerName);
            if (layer != null) {
                return layer;
            }
        }
        throw new GeoWebCacheException("Thread " + Thread.currentThread().getId()
                + " Unknown layer " + layerName + ". Check the logfiles,"
                + " it may not have loaded properly.");
    }
View Full Code Here

        long[] gridRect = gridSubset.getCoverageBestFit();
        String networkLinks = null;

        // Check whether we need two tiles for world bounds or not
        if (gridRect[4] > 0 && (gridRect[2] != gridRect[0] || gridRect[3] != gridRect[1])) {
            throw new GeoWebCacheException(layer.getName() + " (" + bbox.toString()
                    + ") is too big for the sub grid set for " + gridSubset.getName()
                    + ", allow for smaller zoom levels.");
        } else if (gridRect[0] != gridRect[2]) {
            long[] gridLocWest = { 0, 0, 0 };
            long[] gridLocEast = { 1, 0, 0 };
View Full Code Here

                    // If it's a 204 it means no content -> don't link to it
                    if (tile.getStatus() == 204) {
                        linkGridLocs[i][2] = -1;
                    } else if (tile.getStatus() != 200) {
                        throw new GeoWebCacheException(
                                "Unexpected response code from server "
                                + tile.getStatus());
                    }
                }
            }
View Full Code Here

        TMSDocumentFactory tdf = new TMSDocumentFactory(tld, gsb, servletBase, context, urlMangler, encoding);
       
        String ret = null;
       
        if(paramsLength < 2) {
            throw new GeoWebCacheException("Path is too short to be a valid TMS path");
        } else if(paramsLength == 2) {
            String version = params[1];
            if(! version.equals("1.0.0")) {
                throw new GeoWebCacheException("Unknown version " + version + ", only 1.0.0 is supported.");
            } else {
                ret = tdf.getTileMapServiceDoc();
            }
        } else {
            String layerNameAndSRS = params[2];
View Full Code Here

                    count++;
                }
               
                // verify we managed to get the FS lock
                if(count >= maxLockAttempts) {
                    throw new GeoWebCacheException("Failed to get a lock on key " + lockKey + " after " + count + " attempts");
                }

                if(LOGGER.isDebugEnabled()) {
                    LOGGER.debug("Lock " + lockKey + " acquired by thread " + Thread.currentThread().getId() + " on file " + file);
                }
               
                // store the results in a final variable for the inner class to use
                final FileOutputStream fos = currFos;
                final FileLock lock = currLock;

                // nullify so that we don't close them, the locking occurred as expected
                currFos = null;
                currLock = null;
               
                final File lockFile = file;
                return new LockProvider.Lock() {
                   
                    boolean released;

                    public void release() throws GeoWebCacheException {
                        if(released) {
                            return;
                        }
                       
                        try {
                            released = true;
                            if (!lock.isValid()) {
                                // do not crap out, locks usage in GWC is only there to prevent duplication of work
                                if(LOGGER.isDebugEnabled()) {
                                    LOGGER.debug("Lock key " + lockKey + " for releasing lock is unkonwn, it means " +
                                            "this lock was never acquired, or was released twice. " +
                                            "Current thread is: " + Thread.currentThread().getId() + ". " +
                                             "Are you running two GWC instances in the same JVM using NIO locks? " +
                                             "This case is not supported and will generate exactly this error message");
                                    return;
                                }
                            }
                            try {
                                lock.release();
                                IOUtils.closeQuietly(fos);
                                lockFile.delete();
                               
                                if(LOGGER.isDebugEnabled()) {
                                    LOGGER.debug("Lock " + lockKey + " released by thread " + Thread.currentThread().getId());
                                }
                            } catch (IOException e) {
                                throw new GeoWebCacheException("Failure while trying to release lock for key "
                                        + lockKey, e);
                            }
                        } finally {
                            memoryLock.release();
                        }
                       
                    }
                };
            } finally {
                try {
                    if (currLock != null) {
                        currLock.release();
                    }
                    IOUtils.closeQuietly(currFos);
                    file.delete();
                } finally {
                    memoryLock.release();
                }
            }
        } catch (IOException e) {
            throw new GeoWebCacheException("Failure while trying to get lock for key " + lockKey, e);
        }

    }
View Full Code Here

        URL wmsBackendUrl = null;

        final Integer backendTimeout = layer.getBackendTimeout();
        int backendTries = 0; // keep track of how many backends we have tried
        GeoWebCacheException fetchException = null;
        while (target.getSize() == 0 && backendTries < layer.getWMSurl().length) {
            String requestUrl = layer.nextWmsURL();

            try {
                wmsBackendUrl = new URL(requestUrl);
            } catch (MalformedURLException maue) {
                throw new GeoWebCacheException("Malformed URL: " + requestUrl + " "
                        + maue.getMessage());
            }
            try {
                connectAndCheckHeaders(tileRespRecv, wmsBackendUrl, wmsParams, expectedMimeType,
                        backendTimeout, target);
            } catch (GeoWebCacheException e) {
                fetchException = e;
            }

            backendTries++;
        }

        if (target.getSize() == 0) {
            String msg = "All backends (" + backendTries + ") failed.";
            if (fetchException != null) {
                msg += " Reason: " + fetchException.getMessage() + ". ";
            }
            msg += " Last request: '"
                    + wmsBackendUrl.toString()
                    + "'. "
                    + (tileRespRecv.getErrorMessage() == null ? "" : tileRespRecv.getErrorMessage());

            tileRespRecv.setError();
            tileRespRecv.setErrorMessage(msg);
            throw new GeoWebCacheException(msg);
        }
    }
View Full Code Here

            } catch (IOException ce) {
                if (log.isDebugEnabled()) {
                    String message = "Error forwarding request " + wmsBackendUrl.toString();
                    log.debug(message, ce);
                }
                throw new GeoWebCacheException(ce);
            }
            // Check that the response code is okay
            tileRespRecv.setStatus(responseCode);
            if (responseCode != 200 && responseCode != 204) {
                tileRespRecv.setError();
                throw new ServiceException("Unexpected response code from backend: " + responseCode
                        + " for " + wmsBackendUrl.toString());
            }

            // Check that we're not getting an error MIME back.
            String responseMime = getMethod.getResponseHeader("Content-Type").getValue();
            if (responseCode != 204 && responseMime != null
                    && !mimeStringCheck(requestMime, responseMime)) {
                String message = null;
                if (responseMime.equalsIgnoreCase(ErrorMime.vnd_ogc_se_inimage.getFormat())) {
                    // TODO: revisit: I don't understand why it's trying to create a String message
                    // out of an ogc_se_inimage response?
                    InputStream stream = null;
                    try {
                        stream = getMethod.getResponseBodyAsStream();
                        byte[] error = IOUtils.toByteArray(stream);
                        message = new String(error);
                    } catch (IOException ioe) {
                        // Do nothing
                    } finally {
                        IOUtils.closeQuietly(stream);
                    }
                } else if (responseMime != null
                        && responseMime.toLowerCase().startsWith("application/vnd.ogc.se_xml")) {
                    InputStream stream = null;
                    try {
                        stream = getMethod.getResponseBodyAsStream();
                        message = IOUtils.toString(stream);
                    } catch (IOException e) {
                        //
                    } finally {
                        IOUtils.closeQuietly(stream);
                    }
                }
                String msg = "MimeType mismatch, expected " + requestMime + " but got "
                        + responseMime + " from " + wmsBackendUrl.toString()
                        + (message == null ? "" : (":\n" + message));
                tileRespRecv.setError();
                tileRespRecv.setErrorMessage(msg);
                log.warn(msg);
            }

            // Everything looks okay, try to save expiration
            if (tileRespRecv.getExpiresHeader() == GWCVars.CACHE_USE_WMS_BACKEND_VALUE) {
                String expireValue = getMethod.getResponseHeader("Expires").getValue();
                long expire = ServletUtils.parseExpiresHeader(expireValue);
                if (expire != -1) {
                    tileRespRecv.setExpiresHeader(expire / 1000);
                }
            }

            // Read the actual data
            if (responseCode != 204) {
                try {
                    InputStream inStream = getMethod.getResponseBodyAsStream();
                    if( inStream == null ){
                      String uri = getMethod.getURI().getURI();
                      log.error( "No response for "+getMethod.getName() +" " + uri );
                    }
                    else {
                      ReadableByteChannel channel = Channels.newChannel(inStream);
                      try {
                          target.transferFrom(channel);
                      } finally {
                          channel.close();
                      }
                    }
                    if (responseLength > 0) {
                        int readAccu = (int) target.getSize();
                        if (readAccu != responseLength) {
                            tileRespRecv.setError();
                            throw new GeoWebCacheException("Responseheader advertised "
                                    + responseLength + " bytes, but only received " + readAccu
                                    + " from " + wmsBackendUrl.toString());
                        }
                    }
                } catch (IOException ioe) {
View Full Code Here

       
        long[] gridRect = gridSubset.getCoverageBestFit();
       
        // Check whether we need two tiles for world bounds or not
        if(gridRect[4] > 0 && (gridRect[2] != gridRect[0] || gridRect[3] != gridRect[1])) {
            throw new GeoWebCacheException(
                    layer.getName() + " is too big for the sub grid set for "
                    + gridSubset.getName() + ", allow for smaller zoom levels.");
        } else if(gridRect[0] != gridRect[2]) {
            long[] gridLocWest = {0,0,0};
            long[] gridLocEast = {1,0,0};
View Full Code Here

        if (mime == null) {
            mime = this.formats.get(0);
        }

        if (!formats.contains(mime)) {
            throw new GeoWebCacheException(mime.getFormat() + " is not a supported format for "
                    + name);
        }

        String tileGridSetId = tile.getGridSetId();
View Full Code Here

TOP

Related Classes of org.geowebcache.GeoWebCacheException

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.