configuration.java

来自「jetspeed源代码」· Java 代码 · 共 497 行 · 第 1/2 页

JAVA
497
字号
        {
            String error = "Error updating configuration file " + ppath + e.toString();
            log.debug(error);
        }
        out = null;
    }

    /*
     * Refresh the configuration internal state from the properties persistent store.
     *
     */
    public void refresh()
    {
        String result = getInstance().getProperty(Configuration.KEY_WPS_DEBUG);
        if (null == result) 
        {
            debug = false;
        }
        else
        {
            debug = (result.equalsIgnoreCase(TRUE_VALUE));
        }

        sid = getInstance().getProperty(Configuration.KEY_WPS_SID);
        if (null == sid) 
        {
            sid = WPS_SID;
        }

        path = getInstance().getProperty(Configuration.KEY_WPS_PATH);
        if (null == path) 
            path = WPS_PATH;

        url = getInstance().getProperty(Configuration.KEY_WPS_URL);
        if (null == url) 
            url = WPS_URL;

        parser = getInstance().getProperty(Configuration.KEY_PARSER);
        if (null == parser) 
            parser = PARSER_SWING;

        result = getInstance().getProperty(Configuration.KEY_LOG_ENABLE);
        if (null == result) 
            enableContentLog = false;
        else
            enableContentLog = (result.equalsIgnoreCase(TRUE_VALUE));
    
        logLocation = getInstance().getProperty(Configuration.KEY_LOG_LOCATION);
        if (null == logLocation) 
            logLocation = WPS_LOG_LOCATION;
    
        result = getInstance().getProperty(Configuration.KEY_LOG_RESET);
        if (null == result) 
            resetContentLog = false;
        else
            resetContentLog = (result.equalsIgnoreCase(TRUE_VALUE));
    
        webapp = getInstance().getProperty(Configuration.KEY_WEBAPP);
        if (null == webapp) 
            webapp = WPS_WEBAPP;
    
        login = getInstance().getProperty(Configuration.KEY_LOGIN);
        if (null == login) 
             login = WPS_LOGIN;
    
        logout = getInstance().getProperty(Configuration.KEY_LOGOUT);
        if (null == logout) 
             login = WPS_LOGOUT;
    
        userSessionKey = getInstance().getProperty(Configuration.KEY_USER_SESSION);
        if (null == userSessionKey) 
             userSessionKey = WPS_USER_SESSION;

        userDefault = getInstance().getProperty(Configuration.KEY_USER_DEFAULT);
        if (null == userDefault) 
            userDefault = WPS_USER_DEFAULT;

        paramUser = getInstance().getProperty(Configuration.KEY_PARAM_USER);
        if (null == paramUser) 
            paramUser = WPS_PARAM_USER;

        paramPassword = getInstance().getProperty(Configuration.KEY_PARAM_PASSWORD);
        if (null == paramPassword) 
            paramPassword = WPS_PARAM_PASSWORD;

        paramPermissions = getInstance().getProperty(Configuration.KEY_PARAM_PERMISSIONS);
        if (null == paramPermissions) 
            paramPermissions = WPS_PARAM_PERMISSIONS;

        loginFailureString = getInstance().getProperty(Configuration.KEY_LOGIN_FAILURE);
        if (null == loginFailureString) 
            loginFailureString = WPS_LOGIN_FAILURE;

        loginSuccessString = getInstance().getProperty(Configuration.KEY_LOGIN_SUCCESS);
        if (null == loginSuccessString) 
            loginSuccessString = WPS_LOGIN_SUCCESS;

    }

    /*
     * Static accessors for convenient access to configuration state.
     *
     */
    public boolean getDebug()
    {
        return debug;
    }
    
    public String getSID()
    {
        return sid;
    }

    public String getPath()
    {
        return path;
    }

    public String getURL()
    {
        return url;
    }

    public String getParser()
    {
        return parser;
    }

    public boolean getEnableContentLog()
    {
        return enableContentLog;
    }

    public String getLogLocation()
    {
        return logLocation;
    }
    
    public boolean getResetContentLog()
    {
        return resetContentLog;
    }

    public String getWebapp()
    {
         return webapp;
    }

    public String getLogin()
    {
        return login;
    }

    public String getLogout()
    {
        return logout;
    }

    public String getUserSessionKey()
    {
        return userSessionKey;
    }

    public String getDefaultUser()
    {
        return userDefault;
    }

    public String getParamUser()
    {
        return paramUser;
    }

    public String getParamPassword()
    {
        return paramPassword;
    }

    public String getParamPermissions()
    {
        return paramPermissions;
    }

    public String getLoginFailureString()
    {
        return loginFailureString;
    }

    public String getLoginSuccessString()
    {
        return loginSuccessString;
    }

    /*
     * Create a go-between String using the format expected by the WPS.
     *
     * Example:
     *
     *  http://<ProxyHostAddess>/jetProxy?jaid=1.Element?japath=/somestuff/Controller.php
     *
     * @param proxyHost The base URL of the proxy server's host, i.e (http://localhost).
     * @param neid The unique network element id.
     * @param resource The resource to be proxied. This can be a combination of the relative
     *        path + the resource, or just solely the resource.
     * @param relativePath The relative path to the resource. Necessary for request-relative
     *        resources. Specify as null to disable this parameter.
     */
    public static String createProxyString(String proxyHost, 
                                           String neid,
                                           String resource,
                                           String relativePath)
    {
        String base = WebPageHelper.concatURLs(proxyHost, WPS_SERVLET);
        StringBuffer buffer = new StringBuffer(base);                    
        //
        // build the request string in proxy server expected format
        //
        // Example:
        //
        // http://<ProxyHostAddess>/jetProxy?jaid=1.Element?japath=/somestuff/Controller.php
        //
        buffer.append("?");
        buffer.append(getInstance().getSID());
        buffer.append("=");
        buffer.append(neid);  
        buffer.append("&");
        buffer.append(getInstance().getPath());
        buffer.append("=");

        //
        // Is it a request-relative or webapp-relative resource?
        // When the target resource starts with "/", then it is webapp-relative
        // otherwise it is request-relative. When request relative, use the
        // path from the original request to find the resource, otherwise take
        // the resource as is.
        //
        if (null != relativePath && !resource.startsWith("/"))
        {
            // its request-relative, use path from request
            buffer.append(relativePath);          
        }

        buffer.append(resource.replace('&', '@'));
        String proxiedPath = buffer.toString();                
        return proxiedPath;            
    }
}

⌨️ 快捷键说明

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