Package org.geoserver.gwc

Examples of org.geoserver.gwc.GWC


        final IModel<DiskQuotaConfig> diskQuotaModel = new LoadableDetachableModel<DiskQuotaConfig>() {
            private static final long serialVersionUID = 1L;

            @Override
            protected DiskQuotaConfig load() {
                final GWC gwc = getGWC();
                DiskQuotaConfig quotaConfig = gwc.getDisQuotaConfig();
                if (quotaConfig == null) {
                    quotaConfig = new DiskQuotaConfig();// fake
                    quotaConfig.setDefaults();
                }
                return quotaConfig;
            }
        };

        final IModel<GWC> gwcModel = new LoadableDetachableModel<GWC>() {

            private static final long serialVersionUID = 1L;

            @Override
            protected GWC load() {
                return getGWC();
            }
        };

        PropertyModel<MetadataMap> metadataModel = new PropertyModel<MetadataMap>(wmsInfoModel,
                "metadata");
        IModel<Boolean> wmsIntegrationEnabledModel = new MapModel(metadataModel,
                GWC.WMS_INTEGRATION_ENABLED_KEY);

        CheckBox wmsIntegration = checkbox("enableWMSIntegration", wmsIntegrationEnabledModel,
                "GWCSettingsPage.enableWMSIntegration.title");
        form.add(wmsIntegration);

        final DiskQuotaConfig diskQuotaConfig = diskQuotaModel.getObject();
        Quota globalQuota = diskQuotaConfig.getGlobalQuota();
        if (globalQuota == null) {
            LOGGER.info("There's no GWC global disk quota configured, setting a default of 100MiB");
            globalQuota = new Quota(100, StorageUnit.MiB);
            diskQuotaConfig.setGlobalQuota(globalQuota);
        }

        // use this two payload models to let the user configure the global
        // quota as a decimal value
        // plus a storage unit. Then at form sumbission we'll transform them
        // back to a BigInteger
        // representing the quota byte count
        BigInteger bytes = globalQuota.getBytes();
        StorageUnit bestRepresentedUnit = StorageUnit.bestFit(bytes);
        BigDecimal transformedQuota = StorageUnit.B.convertTo(new BigDecimal(bytes),
                bestRepresentedUnit);
        final IModel<Double> configQuotaValueModel = new Model<Double>(
                transformedQuota.doubleValue());
        final IModel<StorageUnit> configQuotaUnitModel = new Model<StorageUnit>(bestRepresentedUnit);

        DiskQuotaConfigPanel diskQuotaConfigPanel = new DiskQuotaConfigPanel(
                "diskQuotaConfigPanel", form, diskQuotaModel, gwcModel, configQuotaValueModel,
                configQuotaUnitModel);
        if (diskQuotaDisabled) {
            diskQuotaConfigPanel.setVisible(false);
        }
        form.add(diskQuotaConfigPanel);

        form.add(new Button("submit") {
            private static final long serialVersionUID = 1L;

            @Override
            public void onSubmit() {
                GeoServer gs = getGeoServer();
                WMSInfo wmsInfo = wmsInfoModel.getObject();
                gs.save(wmsInfo);
                if (diskQuotaDisabled) {
                    setResponsePage(GeoServerHomePage.class);
                    return;
                }
                GWC gwc = getGWC();
                StorageUnit chosenUnit = configQuotaUnitModel.getObject();
                // REVISIT: it seems Wicket is sending back a plain string
                // instead of a BigDecimal
                String chosenQuotaStr = String.valueOf(configQuotaValueModel.getObject());
                Double chosenQuota;
                try {
                    chosenQuota = Double.valueOf(chosenQuotaStr);
                } catch (NumberFormatException e) {
                    form.error(chosenQuotaStr + " is not a valid floating point number");// TODO:
                                                                                         // localize
                    return;
                }
                if (chosenQuota.doubleValue() <= 0D) {
                    form.error("Quota has to be > 0");
                    return;
                }
                gwc.getGlobalQuota().setValue(chosenQuota.doubleValue(), chosenUnit);
                gwc.saveDiskQuotaConfig();

                setResponsePage(GeoServerHomePage.class);
            }
        });
        form.add(new Button("cancel") {
View Full Code Here


        });

    }

    private GWC getGWC() {
        final GWC gwc = (GWC) getGeoServerApplication().getBean("gwcFacade");
        return gwc;
    }
View Full Code Here

        final IModel<Quota> globalQuotaModel = new LoadableDetachableModel<Quota>() {
            private static final long serialVersionUID = 1L;

            @Override
            protected Quota load() {
                GWC gwc = getGWC();
                if(null == gwc.getDisQuotaConfig()){
                    return new Quota();
                }
                return gwc.getGlobalQuota();
            }
        };
        final IModel<Quota> globalUsedQuotaModel = new LoadableDetachableModel<Quota>() {
            private static final long serialVersionUID = 1L;

            @Override
            protected Quota load() {
                GWC gwc = getGWC();
                if(null == gwc.getDisQuotaConfig()){
                    return new Quota();
                }
                return getGWC().getGlobalUsedQuota();
            }
        };
View Full Code Here

        checkNotNull(newInfo.getName());
        checkNotNull(oldInfo.getId());
        checkNotNull(newInfo.getId());
        checkArgument(equal(oldInfo.getId(), newInfo.getId()));

        final GWC mediator = GWC.get();

        final String oldLayerName = oldInfo.getName();
        final String layerName = newInfo.getName();

        final boolean isRename = !equal(oldLayerName, layerName);
        if (isRename) {
            mediator.layerRenamed(oldLayerName, layerName);
        }
        // FIXME: There should be a way to ask GWC to "truncate redundant caches" rather than doing
        //         all this detective work.

        // First, remove the entire layer cache for any removed gridset
        Set<XMLGridSubset> oldGridSubsets = oldInfo.getGridSubsets();
        Set<XMLGridSubset> newGridSubsets = newInfo.getGridSubsets();

        Set<String> oldGridSubsetNames = gridsetNames(oldGridSubsets);
        Set<String> newGridSubsetNames = gridsetNames(newGridSubsets);

        Set<String> removedGridSets = new HashSet<String>(oldGridSubsetNames);
        removedGridSets.removeAll(newGridSubsetNames);
        for (String removedGridset : removedGridSets) {
            mediator.deleteCacheByGridSetId(layerName, removedGridset);
        }

        // then proceed with any removed cache format/style on the remaining gridsets
        Set<String> oldFormats = new HashSet<String>(oldInfo.getMimeFormats());
        Set<String> newFormats = new HashSet<String>(newInfo.getMimeFormats());
        if (!oldFormats.equals(newFormats)) {
            oldFormats.removeAll(newFormats);
            for (String removedFormat : oldFormats) {
                String styleName = null;
                String gridSetName = null;
                BoundingBox bounds = null;
                mediator.truncate(layerName, styleName, gridSetName, bounds, removedFormat);
            }
        }

        Set<String> oldStyles = oldInfo.cachedStyles();
        Set<String> newStyles = newInfo.cachedStyles();
       
        if (!newStyles.equals(oldStyles)) {
            oldStyles = new HashSet<String>(oldStyles);
            oldStyles.removeAll(newStyles);
            for (String removedStyle : oldStyles) {
                mediator.truncateByLayerAndStyle(layerName, removedStyle);
            }
        }
    }
View Full Code Here

public class CachedLayerProviderTest extends GeoServerTestSupport {

    @Test
    public void testQuotaEnabled() throws ConfigurationException, IOException, InterruptedException {
        GWC gwc = GWC.get();
        DiskQuotaConfig config = gwc.getDiskQuotaConfig();
        config.setEnabled(true);
        gwc.saveDiskQuotaConfig(config, null);
       
        CachedLayerProvider provider = new CachedLayerProvider();
        List<TileLayer> layers = provider.getItems();
        for (TileLayer tileLayer : layers) {
            // we are returning the values from the quota subsystem
View Full Code Here

        }
    }
   
    @Test
    public void testQuotaDisabled() throws ConfigurationException, IOException, InterruptedException {
        GWC gwc = GWC.get();
        DiskQuotaConfig config = gwc.getDiskQuotaConfig();
        config.setEnabled(false);
        gwc.saveDiskQuotaConfig(config, null);
       
        CachedLayerProvider provider = new CachedLayerProvider();
        List<TileLayer> layers = provider.getItems();
        for (TileLayer tileLayer : layers) {
            // we are not returning the values from the quota subsystem, they are not up to date anyways
View Full Code Here

            throw new IllegalArgumentException("Only RenderedImageMaps are supported so far: "
                    + metaTileMap.getClass().getName());
        }
        final RenderedImageMapResponse mapEncoder;
        {
            final GWC mediator = GWC.get();
            final Response responseEncoder = mediator.getResponseEncoder(responseFormat,
                    metaTileMap);
            mapEncoder = (RenderedImageMapResponse) responseEncoder;
        }

        RenderedImage tile = metaTileMap.getImage();
View Full Code Here

        // print(page, true, true);
    }
   
    @Before
    public void cleanup() throws IOException {
        GWC gwc = GWC.get();
        GWCConfig config = gwc.getConfig();
        config.setLockProviderName(null);
        gwc.saveConfig(config);
    }
View Full Code Here

        gwc.saveConfig(config);
    }

    @Test
    public void testEditDirectWMSIntegration() {
        GWC gwc = GWC.get();
        boolean directWMSIntegrationEnabled = gwc.getConfig().isDirectWMSIntegrationEnabled();
        testEditCheckboxOption("form:gwcServicesPanel:enableWMSIntegration",
                "gwcServicesPanel:enableWMSIntegration", directWMSIntegrationEnabled);

        assertEquals(!directWMSIntegrationEnabled, gwc.getConfig().isDirectWMSIntegrationEnabled());
    }
View Full Code Here

        assertEquals(!directWMSIntegrationEnabled, gwc.getConfig().isDirectWMSIntegrationEnabled());
    }

    @Test
    public void testEditEnableWMSC() {
        GWC gwc = GWC.get();
        boolean enabled = gwc.getConfig().isWMSCEnabled();
        testEditCheckboxOption("form:gwcServicesPanel:enableWMSC", "gwcServicesPanel:enableWMSC",
                enabled);
        assertEquals(!enabled, gwc.getConfig().isWMSCEnabled());
    }
View Full Code Here

TOP

Related Classes of org.geoserver.gwc.GWC

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.