/** Locates an encoder for a specific GetCoverage results output format */ public CoverageResponseDelegate encoderFor(String outputFormat) { // lookup the encoders dynamically (the list returned might be subject to dynamic extension // filters, so we don't cache it) List<CoverageResponseDelegate> delegates = GeoServerExtensions.extensions(CoverageResponseDelegate.class, applicationContext); for (CoverageResponseDelegate delegate : delegates) { if (delegate.isAvailable() && delegate.canProduce(outputFormat)) { return delegate; } } return null; }
/** * Checks if the supported format string list contains the specified format, doing a case * insensitive search. If found the declared output format name is returned, otherwise null is * returned. * * @param supportedFormats * @param format */ private String getDeclaredFormat(List<String> supportedFormats, String format) { // supported formats may be setup using old style formats, first scan // the configured list for (String sf : supportedFormats) { if (sf.equalsIgnoreCase(format.trim())) { return sf; } else { CoverageResponseDelegate delegate = responseFactory.encoderFor(sf); if (delegate != null && delegate.canProduce(format)) return sf; } } return null; }
/** * Checks if the supported format string list contains the specified format, doing a case * insensitive search. If found the declared output format name is returned, otherwise null is * returned. * * @param supportedFormats * @param format */ private String getDeclaredFormat(List supportedFormats, String format) { // supported formats may be setup using old style formats, first scan // the // configured list for (Iterator it = supportedFormats.iterator(); it.hasNext(); ) { String sf = (String) it.next(); if (sf.equalsIgnoreCase(format)) { return sf; } else { CoverageResponseDelegate delegate = responseFactory.encoderFor(sf); if (delegate != null && delegate.canProduce(format)) return sf; } } return null; }
@Override public boolean canHandle(Operation operation) { if (!(operation.getParameters()[0] instanceof GetCoverageType)) return false; GetCoverageType getCoverage = (GetCoverageType) operation.getParameters()[0]; String outputFormat = getCoverage.getOutput().getFormat().getValue(); CoverageResponseDelegate delegate = getResponseDelegate(outputFormat); return delegate.canProduce(outputFormat); }