⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 applicationstate.java

📁 电子地图服务器,搭建自己的地图服务
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * <ul>
     * <li>[0] -  The first block represtents the application state at the time
     *            of data creation. Use to test whether the array needs to be
     *            reloaded.</li>
     * <li>[1-3] - wfs (working, broken, disabled) percentages</li>
     * <li>[4-6] - wms (working, broken, disabled) percentages</li>
     * <li>[7-9] - data (working, broken, disabled) percentages</li>
     * </ul>
     * </p>
     */
    private void loadStatus() {
        // what does isGeoServerChanged() have to do with this
        // and why don't you use (isGeoServerChanged() ? 3 : 0)
        //
        // or are you trying to indicate a bit mask:
        // bit 1: isGeoServerChanged
        // bit 2: isConfigChanged
        //
        // And all this madness is a cut and paste mistake?
        geoserverStatus[0] = (isAppChanged() ? 1 : 0) + (isConfigChanged() ? 2 : 0)
            + (isValidationChanged() ? 4 : 0);

        // setup geoserverNSErrors
        geoserverNSErrors = data.statusNamespaces();

        // setup geoserverDSErrors
        geoserverDSErrors = data.statusDataStores();

        // setup geoserverVPErrors
        Map tmpVP = validator.getErrors();

        int g = 0;
        int b = 0;
        int d = 0;
        Iterator i = null;

        //featuretypes
        i = geoserverNSErrors.keySet().iterator();

        while (i.hasNext()) {
            Object key = i.next();
            Object o = geoserverNSErrors.get(key);

            if (o.equals(Boolean.TRUE)) {
                g++;
                i.remove();

                //geoserverNSErrors.remove(key);
            } else {
                if (o.equals(Boolean.FALSE)) {
                    d++;
                    i.remove();

                    //geoserverNSErrors.remove(key);
                } else {
                    b++;
                }
            }
        }

        if ((g + b + d) == 0) {
            geoserverStatus[7] = 100;
            geoserverStatus[8] = 0;
            geoserverStatus[9] = 0;
        } else {
            geoserverStatus[7] = (int) ((100.0 * g) / (g + b + d));
            geoserverStatus[8] = (int) ((100.0 * b) / (g + b + d));
            geoserverStatus[9] = (int) ((100.0 * d) / (g + b + d));
        }

        //datastores
        i = geoserverDSErrors.keySet().iterator();
        g = 0;
        b = 0;
        d = 0;

        while (i.hasNext()) {
            Object key = i.next();
            Object o = geoserverDSErrors.get(key);

            if (o.equals(Boolean.TRUE)) {
                g++;
                i.remove();

                //geoserverDSErrors.remove(key);
            } else {
                if (o.equals(Boolean.FALSE)) {
                    d++;
                    i.remove();

                    //geoserverDSErrors.remove(key);
                } else {
                    b++;
                }
            }
        }

        if ((g + b + d) == 0) {
            geoserverStatus[1] = geoserverStatus[4] = 100;
            geoserverStatus[2] = geoserverStatus[5] = 0;
            geoserverStatus[3] = geoserverStatus[6] = 0;
        } else {
            geoserverStatus[1] = geoserverStatus[4] = (int) ((100.0 * g) / (g + b + d));
            geoserverStatus[2] = geoserverStatus[5] = (int) ((100.0 * b) / (g + b + d));
            geoserverStatus[3] = geoserverStatus[6] = (int) ((100.0 * d) / (g + b + d));
        }

        //validation
        // DJB: noticed that you can have no loaded validation plugins, so this can be null)
        g = 0;
        b = 0;
        d = 0;

        if (tmpVP != null) {
            i = tmpVP.keySet().iterator();

            while (i.hasNext()) {
                Object key = i.next();
                Object o = tmpVP.get(key);

                if (o.equals(Boolean.TRUE)) {
                    g++;
                    i.remove();

                    //geoserverDSErrors.remove(key);
                } else {
                    if (o.equals(Boolean.FALSE)) {
                        d++;
                        i.remove();

                        //geoserverDSErrors.remove(key);
                    } else {
                        b++;
                    }
                }
            }
        }

        if ((g + b + d) == 0) {
            geoserverStatus[10] = 100;
            geoserverStatus[11] = 0;
            geoserverStatus[12] = 0;
        } else {
            geoserverStatus[10] = (int) ((100.0 * g) / (g + b + d));
            geoserverStatus[11] = (int) ((100.0 * b) / (g + b + d));
            geoserverStatus[12] = (int) ((100.0 * d) / (g + b + d));
        }

        geoserverVPErrors = new HashMap();

        if (tmpVP != null) //DJB: protection for no validation services
         {
            i = tmpVP.entrySet().iterator();

            while (i.hasNext()) {
                Map.Entry e = (Map.Entry) i.next();
                Object dto = e.getKey();

                if (dto instanceof PlugInDTO) {
                    geoserverVPErrors.put("PlugIn:" + ((PlugInDTO) dto).getName(), e.getValue());
                } else {
                    if (dto instanceof TestDTO) {
                        geoserverVPErrors.put("Test:" + ((TestDTO) dto).getName(), e.getValue());
                    } else {
                        if (dto instanceof TestSuiteDTO) {
                            geoserverVPErrors.put("TestSuite:" + ((TestSuiteDTO) dto).getName(),
                                e.getValue());
                        }
                    }
                }
            }
        }
    }

    public Exception getDataStoreError(String key) {
        return (Exception) getDataStoreErrors().get(key);
    }

    public Exception getNameSpaceError(String key) {
        return (Exception) getNameSpaceErrors().get(key);
    }

    public Exception getWFSError(String key) {
        return (Exception) getNameSpaceErrors().get(key);
    }

    public Exception getWMSError(String key) {
        return (Exception) getNameSpaceErrors().get(key);
    }

    public Exception getValidationError(String key) {
        return (Exception) getValidationErrors().get(key);
    }

    /**
     * Namespace Exceptions by prefix:typeName.
     * <p>
     * This only includes problems! If this map is null or isEmpty
     * status is "ready".
     * </p>
     * @return
     */
    public Map getNameSpaceErrors() {
        if ((geoserverNSErrors == null)
                || (geoserverStatus[0] == ((isAppChanged() ? 1 : 0) + (isConfigChanged() ? 2 : 0)
                + (isValidationChanged() ? 4 : 0)))) {
            loadStatus();
        }

        return geoserverNSErrors;
    }

    /** Flattened for your JSP pleasure */
    public List getNameSpaceErrorKeys() {
        return new LinkedList(getNameSpaceErrors().keySet());
    }

    /** Flattened for your JSP pleasure */
    public List getNameSpaceErrorValues() {
        return new LinkedList(getNameSpaceErrors().values());
    }

    /**
     * DataStore Exceptions by dataStoreId:typeName
     * <p>
     * This only includes problems! If this map is null or isEmpty
     * status is "ready".
     * </p>
     * @return
     */
    public Map getDataStoreErrors() {
        if ((geoserverDSErrors == null)
                || (geoserverStatus[0] == ((isConfigChanged() ? 1 : 0) + (isAppChanged() ? 2 : 0)
                + (isValidationChanged() ? 4 : 0)))) {
            loadStatus();
        }

        return geoserverDSErrors;
    }

    /** Flattened for your JSP pleasure */
    public List getDataStoreErrorKeys() {
        return new LinkedList(getDataStoreErrors().keySet());
    }

    /** Flattened for your JSP pleasure */
    public List getDataStoreErrorValues() {
        return new LinkedList(getDataStoreErrors().values());
    }

    /**
     * Validation Exceptions by obejct type : name where object type is one of TestSuite, Test, PlugIn
     * <p>
     * This only includes problems! If this map is null or isEmpty
     * status is "ready".
     * </p>
     * @return
     */
    public Map getValidationErrors() {
        if ((geoserverNSErrors == null)
                || (geoserverStatus[0] == ((isAppChanged() ? 1 : 0) + (isConfigChanged() ? 2 : 0)
                + (isValidationChanged() ? 4 : 0)))) {
            loadStatus();
        }

        return geoserverVPErrors;
    }

    /** Flattened for your JSP pleasure */
    public List getValidationErrorKeys() {
        return new LinkedList(getValidationErrors().keySet());
    }

    /** Flattened for your JSP pleasure */
    public List getValidationErrorValues() {
        return new LinkedList(getValidationErrors().values());
    }

    public Map getWCSErrors() {
        return getNameSpaceErrors();
    }

    public List getWCSErrorKeys() {
        return getNameSpaceErrorKeys();
    }

    public Map getWFSErrors() {
        return getNameSpaceErrors();
    }

    public List getWFSErrorKeys() {
        return getNameSpaceErrorKeys();
    }

    public Map getWMSErrors() {
        return getNameSpaceErrors();
    }

    public List getWMSErrorKeys() {
        return getNameSpaceErrorKeys();
    }

    /**
     * Access appTimestamp property.
     *
     * @return Returns the appTimestamp.
     */
    public Date getAppTimestamp() {
        return appTimestamp;
    }

    /**
     * Access configTimestamp property.
     *
     * @return Returns the configTimestamp.
     */
    public Date getConfigTimestamp() {
        return configTimestamp;
    }

    /**
     * Access xmlTimestamp property.
     *
     * @return Returns the xmlTimestamp.
     */
    public Date getXmlTimestamp() {
        if (xmlTimestamp == null) {
            //DJB: changed for geoserver_data_dir
            File dataDir = config.dataDirectory();
            boolean inDataDir = GeoserverDataDirectory.isTrueDataDir();

            //We're just checking if it's actually a data_dir, not trying to
            //to do backwards compatibility.  So if an old data_dir is made in
            //the old way, on save it'll come to the new way. -ch
            File serviceDir = dataDir;
            File serviceFile;

            try {
                serviceFile = WriterUtils.initWriteFile(new File(serviceDir, "services.xml"), false);
            } catch (ConfigurationException confE) {
                throw new RuntimeException(confE);
            }

            xmlTimestamp = new Date(serviceFile.lastModified());
        }

        return xmlTimestamp;
    }

    private void resetXMLTimestamp() {
        xmlTimestamp = null;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -