Examples of GWC


Examples of org.geoserver.gwc.GWC

                    @Override
                    protected Component getContents(final String id) {
                        final String layerName = getDefaultModelObjectAsString();

                        // show a confirmation panel for all the objects we have to remove
                        final GWC gwcFacade = GWC.get();
                        Quota usedQuota = gwcFacade.getUsedQuota(layerName);
                        if (usedQuota == null) {
                            usedQuota = new Quota();
                        }
                        final String usedQuotaStr = usedQuota.toNiceString();
                        IModel<String> model = new ParamResourceModel(
                                "CachedLayersPage.confirmTruncateMessage", CachedLayersPage.this,
                                layerName, usedQuotaStr);
                        Label confirmLabel = new Label(id, model);
                        confirmLabel.setEscapeModelStrings(false);// allow some html inside, like
                                                                  // <b></b>, etc
                        return confirmLabel;
                    }

                    @Override
                    protected boolean onSubmit(final AjaxRequestTarget target,
                            final Component contents) {
                        final String layerName = getDefaultModelObjectAsString();
                        GWC facade = GWC.get();
                        facade.truncate(layerName);
                        return true;
                    }

                    @Override
                    public void onClose(final AjaxRequestTarget target) {
View Full Code Here

Examples of org.geoserver.gwc.GWC

        super(id);
        checkArgument(tileLayerModel instanceof GeoServerTileLayerInfoModel);
        this.layerModel = layerModel;
        setModel(tileLayerModel);

        final GWC mediator = GWC.get();
        final IModel<String> createTileLayerLabelModel;

        final CatalogInfo info = layerModel.getObject();
        final GeoServerTileLayerInfo tileLayerInfo = tileLayerModel.getObject();

        if (info instanceof LayerInfo) {
            createTileLayerLabelModel = new ResourceModel("createTileLayerForLayer");
            ResourceInfo resource = ((LayerInfo) info).getResource();
            // we need the _current_ name, regardless of it's name is being changed
            resource = ModificationProxy.unwrap(resource);
            originalLayerName = resource.getPrefixedName();
        } else if (info instanceof LayerGroupInfo) {
            createTileLayerLabelModel = new ResourceModel("createTileLayerForLayerGroup");
            // we need the _current_ name, regardless of if it's name is being changed
            LayerGroupInfo lgi = ModificationProxy.unwrap((LayerGroupInfo) info);
            originalLayerName = tileLayerName(lgi);
        } else {
            throw new IllegalArgumentException(
                    "Provided model does not target a LayerInfo nor a LayerGroupInfo: " + info);
        }

        TileLayer tileLayer = null;
        if (originalLayerName != null) {
            try {
                tileLayer = mediator.getTileLayerByName(originalLayerName);
            } catch (IllegalArgumentException notFound) {
                //
            }
        }
        cachedLayerExistedInitially = tileLayer != null;

        // UI construction phase
        add(confirmRemovalDialog = new GeoServerDialog("confirmRemovalDialog"));
        confirmRemovalDialog.setInitialWidth(360);
        confirmRemovalDialog.setInitialHeight(180);

        add(new Label("createTileLayerLabel", createTileLayerLabelModel));

        boolean doCreateTileLayer;
        if (tileLayerInfo.getId() != null) {
            doCreateTileLayer = true;
        } else if (isNew() && mediator.getConfig().isCacheLayersByDefault()) {
            doCreateTileLayer = true;
        } else {
            doCreateTileLayer = false;
        }
        add(createLayer = new CheckBox("createTileLayer", new Model<Boolean>(doCreateTileLayer)));
View Full Code Here

Examples of org.geoserver.gwc.GWC

        GeoServerTileLayerInfoModel model = (GeoServerTileLayerInfoModel) super.getModel();
        return model.isNew();
    }

    public void save() {
        final GWC gwc = GWC.get();

        final CatalogInfo layer = layerModel.getObject();
        final GeoServerTileLayerInfo tileLayerInfo = getModelObject();
        final boolean tileLayerExists = gwc.hasTileLayer(layer);
        final boolean createLayer = this.createLayer.getModelObject().booleanValue();

        if (!createLayer) {
            if (tileLayerExists) {
                String tileLayerName = tileLayerInfo.getName();
                gwc.removeTileLayers(Arrays.asList(tileLayerName));
            }
            return;
        }

        // if we're creating a new layer, at this point the layer has already been created and hence
        // has an id
        Preconditions.checkState(layer.getId() != null);
        tileLayerInfo.setId(layer.getId());

        final String name;
        final GridSetBroker gridsets = gwc.getGridSetBroker();
        GeoServerTileLayer tileLayer;
        if (layer instanceof LayerGroupInfo) {
            LayerGroupInfo groupInfo = (LayerGroupInfo) layer;
            name = tileLayerName(groupInfo);
            tileLayer = new GeoServerTileLayer(groupInfo, gridsets, tileLayerInfo);
        } else {
            LayerInfo layerInfo = (LayerInfo) layer;
            name = tileLayerName(layerInfo);
            tileLayer = new GeoServerTileLayer(layerInfo, gridsets, tileLayerInfo);
        }

        tileLayerInfo.setName(name);

        if (tileLayerExists) {
            gwc.save(tileLayer);
        } else {
            gwc.add(tileLayer);
        }
    }
View Full Code Here

Examples of org.geoserver.gwc.GWC

            private static final long serialVersionUID = 1L;

            @Override
            protected Component getContents(final String id) {
                // show a confirmation panel for all the objects we have to remove
                GWC gwc = GWC.get();
                Quota usedQuota = gwc.getUsedQuota(originalLayerName);
                if (usedQuota == null) {
                    usedQuota = new Quota();
                }
                String usedQuotaStr = usedQuota.toNiceString();
                return new Label(id, new ParamResourceModel("confirmTileLayerRemoval",
View Full Code Here

Examples of org.geoserver.gwc.GWC

            if (gridSubsets == null || gridSubsets.size() == 0) {
                error(validatable, "GridSubsetsEditor.validation.empty");
                return;
            }

            final GWC gwc = GWC.get();
            for (XMLGridSubset subset : gridSubsets) {
                final String gridSetName = subset.getGridSetName();
                final Integer zoomStart = subset.getZoomStart();
                final Integer zoomStop = subset.getZoomStop();
                final BoundingBox extent = subset.getExtent();

                if (gridSetName == null) {
                    throw new IllegalStateException("GridSet name is null");
                }

                if (zoomStart != null && zoomStop != null) {
                    if (zoomStart.intValue() > zoomStop.intValue()) {
                        error(validatable, "GridSubsetsEditor.validation.zoomLevelsError");
                        return;
                    }
                }

                final GridSetBroker gridSetBroker = gwc.getGridSetBroker();
                final GridSet gridSet = gridSetBroker.get(gridSetName);

                if (null == gridSet) {
                    error(validatable, "GridSubsetsEditor.validation.gridSetNotFound", gridSetName);
                    return;
View Full Code Here

Examples of org.geoserver.gwc.GWC

            // could go wrong, and if the user accepts, let's delete what's needed
            dialog.showOkCancel(target, new GeoServerDialog.DialogDelegate() {

                @Override
                protected Component getContents(final String id) {
                    final GWC gwc = GWC.get();

                    final int count = selectedGridsetIds.size();

                    Quota totalQuota = new Quota();

                    for (String gridsetId : selectedGridsetIds) {
                        Quota usedQuotaByGridSet = gwc.getUsedQuotaByGridSet(gridsetId);
                        if (usedQuotaByGridSet != null) {
                            totalQuota.add(usedQuotaByGridSet);
                        }
                    }

                    final Set<String> affectedLayers = gwc
                            .getLayerNamesForGridSets(selectedGridsetIds);

                    IModel<String> confirmModel = new ParamResourceModel(
                            "GridSetsPage.confirmGridsetsDelete", GridSetsPage.this, String
                                    .valueOf(count), String.valueOf(affectedLayers.size()),
                            totalQuota.toNiceString());

                    Label confirmMessage = new Label(id, confirmModel);
                    confirmMessage.setEscapeModelStrings(false);// allow some html markup
                    return confirmMessage;
                }

                @Override
                protected boolean onSubmit(AjaxRequestTarget target, Component contents) {
                    // cascade delete the whole selection
                    GWC gwc = GWC.get();
                    try {
                        gwc.removeGridSets(selectedGridsetIds);
                    } catch (Exception e) {
                        getPage().error(e.getMessage());
                        LOGGER.log(Level.WARNING, e.getMessage(), e);
                    }
                    gridsets.clearSelection();
View Full Code Here

Examples of org.geoserver.gwc.GWC

        coordSys = (CoordinateReferenceSystem) crs.getModelObject();
        if (coordSys == null) {
            bounds.error(new ResourceModel("AbstractGridsetPage.computeBounds.crsNotSet"));
            return;
        }
        GWC mediator = GWC.get();
        ReferencedEnvelope aov = mediator.getAreaOfValidity(coordSys);
        if (aov == null) {
            bounds.error(new ResourceModel("AbstractGridsetPage.computeBounds.aovNotSet"));
        } else {
            bounds.setModelObject(aov);
        }
View Full Code Here

Examples of org.geoserver.gwc.GWC

import org.geowebcache.diskquota.storage.StorageUnit;

public class DiskQuotaSettingsPage extends GeoServerSecuredPage {

    public DiskQuotaSettingsPage() throws Exception {
        GWC gwc = getGWC();

        final boolean diskQuotaModuleDisabled = gwc.getDiskQuotaConfig() == null;
       
        // get the quota store config, show an error message in case the quota
        // store loading failed
        ConfigurableQuotaStoreProvider provider = GeoServerApplication.get().getBeanOfType(ConfigurableQuotaStoreProvider.class);
        if(provider.getException() != null) {
            ParamResourceModel rm = new ParamResourceModel("GWC.diskQuotaLoadFailed", null, provider.getException().getMessage());
            error(rm.getString());
        }

        // use a dettached copy of dq config to support the tabbed pane
        final DiskQuotaConfig diskQuotaConfig;
        if (diskQuotaModuleDisabled) {
            diskQuotaConfig = new DiskQuotaConfig(); // fake
            diskQuotaConfig.setDefaults();
        } else {
            diskQuotaConfig = gwc.getDiskQuotaConfig().clone();
        }
       
        // same as above, but we don't need to create a copy of the JDBC quota config since
        // that config is just used to instantiate the quota store, and then gets promptly discarted
        final JDBCConfiguration jdbcQuotaConfiguration;
        if(gwc.getJDBCDiskQuotaConfig() == null) {
            jdbcQuotaConfiguration = new JDBCConfiguration();
            JDBCConfiguration.ConnectionPoolConfiguration configuration = new JDBCConfiguration.ConnectionPoolConfiguration();
            configuration.setMinConnections(1);
            configuration.setMaxConnections(10);
            configuration.setConnectionTimeout(10000);
            configuration.setMaxOpenPreparedStatements(50);
            jdbcQuotaConfiguration.setConnectionPool(configuration);
        } else {
            jdbcQuotaConfiguration = gwc.getJDBCDiskQuotaConfig();
        }

        final Form<Map<String, Serializable>> form;
        form = new Form<Map<String, Serializable>>("form");
        add(form);

        final IModel<DiskQuotaConfig> diskQuotaModel = new Model<DiskQuotaConfig>(diskQuotaConfig);
        final IModel<JDBCConfiguration> jdbcQuotaModel = new Model<JDBCConfiguration>(jdbcQuotaConfiguration);

        final DiskQuotaConfigPanel diskQuotaConfigPanel = new DiskQuotaConfigPanel(
                "diskQuotaPanel", diskQuotaModel, jdbcQuotaModel);
       
        if (diskQuotaModuleDisabled) {
            diskQuotaConfigPanel.setEnabled(false);
            super.warn(new ResourceModel("DiskQuotaSettingsPage.disabledWarning").getObject());
        }
       
        form.add(diskQuotaConfigPanel);

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

            @Override
            public void onSubmit() {
                GWC gwc = getGWC();
                if (!diskQuotaModuleDisabled) {
                    StorageUnit chosenUnit = diskQuotaConfigPanel.getStorageUnit();
                    // REVISIT: it seems Wicket is sending back a plain string instead of a
                    String chosenQuotaStr = String.valueOf(diskQuotaConfigPanel.getQuotaValue());
                    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;
                    }
                    DiskQuotaConfig dqConfig = diskQuotaModel.getObject();
                    JDBCConfiguration jdbcConfig = jdbcQuotaModel.getObject();
                    if(dqConfig.getQuotaStore() != null && dqConfig.getQuotaStore().equals("JDBC")) {
                        try {
                            gwc.testQuotaConfiguration(jdbcConfig);
                        } catch(Exception e) {
                            LOGGER.log(Level.SEVERE, "Error instantiating the JDBC configuration", e);
                            error("Failure occurred while saving the JDBC configuration"
                                    + e.getMessage() + " (see the logs for a full stack trace)");
                            return;
                        }
                    }
                   
                    dqConfig.getGlobalQuota().setValue(chosenQuota.doubleValue(), chosenUnit);
                    try {
                        gwc.saveDiskQuotaConfig(dqConfig, jdbcConfig);
                    } catch(Exception e) {
                        LOGGER.log(Level.SEVERE, "Failed to save the JDBC configuration", e);
                        error("Failure occurred while saving the JDBC configuration"
                                + e.getMessage() + " (see the logs for a full stack trace)");
                        return;
View Full Code Here

Examples of org.geoserver.gwc.GWC

            super.warn(warningMsg);
        }
    }

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

Examples of org.geoserver.gwc.GWC

            target.addComponent(form);
            return;
        }

        try {
            GWC gwc = GWC.get();
            gwc.addGridSet(gridset);
            doReturn(GridSetsPage.class);
        } catch (Exception e) {
            form.error(e.getMessage());
            target.addComponent(form);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.