Package org.geowebcache.diskquota.storage

Examples of org.geowebcache.diskquota.storage.StorageUnit


            reader.moveDown();
            nodeName = reader.getNodeName();
            Assert.isTrue("units".equals(nodeName));

            nodevalue = reader.getValue();
            StorageUnit unit = StorageUnit.valueOf(nodevalue);
            reader.moveUp();

            quota.setValue(value, unit);
            return quota;
        }
View Full Code Here


         */
        public void marshal(Object source, HierarchicalStreamWriter writer,
                MarshallingContext context) {
            Quota quota = (Quota) source;
            BigInteger bytes = quota.getBytes();
            StorageUnit unit = StorageUnit.bestFit(bytes);
            BigDecimal value = unit.fromBytes(bytes);

            writer.startNode("value");
            writer.setValue(value.toString());
            writer.endNode();

            writer.startNode("units");
            writer.setValue(unit.toString());
            writer.endNode();
        }
View Full Code Here

        // 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 {
View Full Code Here

        Quota used = globalUsedQuotaModel.getObject();

        BigInteger limitValue = limit.getBytes();
        BigInteger usedValue = used.getBytes();

        StorageUnit bestUnitForLimit = StorageUnit.bestFit(limitValue);
        StorageUnit bestUnitForUsed = StorageUnit.bestFit(usedValue);

        StorageUnit biggerUnit = bestUnitForLimit.compareTo(bestUnitForUsed) > 0 ? bestUnitForLimit
                : bestUnitForUsed;

        BigDecimal showLimit = StorageUnit.B.convertTo(new BigDecimal(limitValue), biggerUnit);
        BigDecimal showUsed = StorageUnit.B.convertTo(new BigDecimal(usedValue), biggerUnit);
View Full Code Here

        // 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);
        configQuotaValueModel = new Model<Double>(transformedQuota.doubleValue());

        configQuotaUnitModel = new Model<StorageUnit>(bestRepresentedUnit);
View Full Code Here

        Quota used = globalUsedQuotaModel.getObject();

        BigInteger limitValue = limit.getBytes();
        BigInteger usedValue = used.getBytes();

        StorageUnit bestUnitForLimit = StorageUnit.bestFit(limitValue);
        StorageUnit bestUnitForUsed = StorageUnit.bestFit(usedValue);

        StorageUnit biggerUnit = bestUnitForLimit.compareTo(bestUnitForUsed) > 0 ? bestUnitForLimit
                : bestUnitForUsed;

        BigDecimal showLimit = StorageUnit.B.convertTo(new BigDecimal(limitValue), biggerUnit);
        BigDecimal showUsed = StorageUnit.B.convertTo(new BigDecimal(usedValue), biggerUnit);
View Full Code Here

            @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);
View Full Code Here

            reader.moveDown();
            nodeName = reader.getNodeName();
            Assert.isTrue("units".equals(nodeName));

            nodevalue = reader.getValue();
            StorageUnit unit = StorageUnit.valueOf(nodevalue);
            reader.moveUp();

            quota.setValue(value, unit);
            return quota;
        }
View Full Code Here

         */
        public void marshal(Object source, HierarchicalStreamWriter writer,
                MarshallingContext context) {
            Quota quota = (Quota) source;
            BigInteger bytes = quota.getBytes();
            StorageUnit unit = StorageUnit.bestFit(bytes);
            BigDecimal value = unit.fromBytes(bytes);

            writer.startNode("value");
            writer.setValue(value.toString());
            writer.endNode();

            writer.startNode("units");
            writer.setValue(unit.toString());
            writer.endNode();
        }
View Full Code Here

TOP

Related Classes of org.geowebcache.diskquota.storage.StorageUnit

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.