/** * @return all the {@link LayerInfo}s in the {@link Catalog} that somehow refer to the given * style */ public Iterable<LayerInfo> getLayerInfosFor(final StyleInfo style) { return getLayerInfosFor(style, true); }
/** * Options are: * <ul> * <li>A {@link LayerInfo} has {@code modifiedStyle} as either its default or style or as one of * its alternate styles * <li>A {@link LayerGroupInfo} contains a layer using {@code modifiedStyle} * <li>{@code modifiedStyle} is explicitly assigned to a {@link LayerGroupInfo} * </ul> * * @param modifiedStyle */ private void handleStyleChange(final StyleInfo modifiedStyle) { final String styleName = modifiedStyle.getName(); log.finer("Handling style modification: " + styleName); // First we collect all the layers that use this style for (LayerInfo affectedLayer : mediator.getLayerInfosFor(modifiedStyle)) { // If the style name changes, we need to update the layer's parameter filter String prefixedName = tileLayerName(affectedLayer); log.info("Truncating layer '" + prefixedName + "' due to a change in style '" + styleName + "'"); mediator.truncateByLayerAndStyle(prefixedName, styleName); } // Now we check for layer groups that are affected for (LayerGroupInfo layerGroup : mediator.getLayerGroupsFor(modifiedStyle)) { String layerGroupName = tileLayerName(layerGroup); log.info("Truncating layer group '" + layerGroupName + "' due to a change in style '" + styleName + "'"); mediator.truncate(layerGroupName); } }
@SuppressWarnings("unchecked") public void testLayerInfoDefaultOrAlternateStyleChanged() throws Exception { when(mockMediator.getLayerInfosFor(same(mockStyle))).thenReturn( Collections.singleton(mockLayerInfo)); when(mockMediator.getLayerGroupsFor(same(mockStyle))).thenReturn(Collections.EMPTY_LIST); CatalogPostModifyEventImpl postModifyEvent = new CatalogPostModifyEventImpl(); postModifyEvent.setSource(mockStyle); listener.handlePostModifyEvent(postModifyEvent); verify(mockMediator, times(1)).truncateByLayerAndStyle(eq(PREFIXED_RESOURCE_NAME), eq(STYLE_NAME)); }
@SuppressWarnings("unchecked") public void testLayerGroupInfoImplicitOrExplicitStyleChanged() throws Exception { LayerGroupInfo mockGroup = mock(LayerGroupInfo.class); when(GWC.tileLayerName(mockGroup)).thenReturn("mockGroup"); when(mockMediator.getLayerInfosFor(same(mockStyle))).thenReturn(Collections.EMPTY_LIST); when(mockMediator.getLayerGroupsFor(same(mockStyle))).thenReturn( Collections.singleton(mockGroup)); CatalogPostModifyEventImpl postModifyEvent = new CatalogPostModifyEventImpl(); postModifyEvent.setSource(mockStyle); listener.handlePostModifyEvent(postModifyEvent); verify(mockMediator, times(1)).truncate(eq("mockGroup")); } }
log.finer("Handling style modification: " + styleName); Iterable<LayerInfo> layers = mediator.getLayerInfosFor(modifiedStyle); for (LayerInfo affectedLayer : layers) {
Iterable<LayerInfo> layers = getLayerInfosFor(style);