public static void addAutoStyleParameterFilter( final LayerInfo layer, GeoServerTileLayerInfo layerInfo) { StyleParameterFilter filter = new StyleParameterFilter(); filter.setLayer(layer); layerInfo.removeParameterFilter("STYLES"); layerInfo.getParameterFilters().add(filter); }
/** * Set the styles which should be cached on a layer * * @param info * @param defaultStyle * @param cachedStyles */ public static void setCachedStyles( GeoServerTileLayerInfo info, String defaultStyle, Set<String> cachedStyles) { StyleParameterFilter filter = (StyleParameterFilter) info.getParameterFilter("STYLES"); if (filter == null) filter = new StyleParameterFilter(); filter.setDefaultValue(defaultStyle); filter.setStyles(cachedStyles); info.addParameterFilter(filter); }
/** * If the layer is configured for automatic style updates of its Style parameter filter, do so. * * @param layer The GeoServer layer group * @param layerInfo The GeoWebCache layer */ public static void checkAutomaticStyles( final LayerGroupInfo layer, GeoServerTileLayerInfo layerInfo) { ParameterFilter filter = layerInfo.getParameterFilter("STYLES"); // Remove the filter as groups shouldn't have auto-updating styles if (filter != null && filter instanceof StyleParameterFilter) { layerInfo.removeParameterFilter("STYLES"); } }
/** * Add a {@link FloatParameterFilter} set accept anything, replacing any existing filter for the * same parameter. * * @param tileLayerInfo layer to update the filter on * @param paramKey key for the parameter * @param createParam create a new filter if there is none to replace for the specified key */ public static void updateAcceptAllFloatParameterFilter( final GeoServerTileLayerInfo tileLayerInfo, final String paramKey, boolean createParam) { createParam |= tileLayerInfo.removeParameterFilter(paramKey); if (createParam) { FloatParameterFilter filter = new FloatParameterFilter(); filter.setKey(paramKey); filter.setDefaultValue(""); tileLayerInfo.addParameterFilter(filter); } }
/** * If the layer is configured for automatic style updates of its Style parameter filter, do so. * * @param layer The GeoServer layer * @param layerInfo The GeoWebCache layer */ public static void checkAutomaticStyles(final LayerInfo layer, GeoServerTileLayerInfo layerInfo) { ParameterFilter filter = layerInfo.getParameterFilter("STYLES"); // Update the filter with the latest available styles if it's a style filter if (filter != null && filter instanceof StyleParameterFilter) { ((StyleParameterFilter) filter).setLayer(layer); } }
/** * Add a {@link StringParameterFilter} to the layer, replacing any existing filter for the same * parameter. * * @param tileLayerInfo layer to update the filter on * @param paramKey key for the parameter * @param createParam create a new filter if there is none to replace for the specified key * @param defaultValue default value * @param allowedValues legal values for the parameter */ public static void updateStringParameterFilter( final GeoServerTileLayerInfo tileLayerInfo, final String paramKey, boolean createParam, final String defaultValue, final Set<String> allowedValues) { createParam |= tileLayerInfo.removeParameterFilter(paramKey); if (createParam && allowedValues != null && allowedValues.size() > 0) { // make sure default value is among the list of allowed values Set<String> values = new TreeSet<String>(allowedValues); StringParameterFilter stringListFilter = new StringParameterFilter(); stringListFilter.setKey(paramKey); stringListFilter.setDefaultValue(defaultValue == null ? "" : defaultValue); values.addAll(stringListFilter.getValues()); stringListFilter.setValues(new ArrayList<String>(values)); tileLayerInfo.addParameterFilter(stringListFilter); } }
/** * Remove a parameter filter from a layer * * @param tileLayerInfo the layer * @param paramKey the key of the parameter filter * @return true if a parameter matched and was removed, false otherwise * @deprecated */ public static boolean removeParameterFilter( final GeoServerTileLayerInfo tileLayerInfo, final String paramKey) { return tileLayerInfo.removeParameterFilter(paramKey); }