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

📄 cmsloginnew.java

📁 cms是开源的框架
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            // no user logged in, no call to "login()" JavaScript
            if (DEBUG > 1) System.err.println("CmsLoginNew: no login or logout, displaying template");            
            xmlTemplateDocument.setData("onload", "onload='init();'");
        }

        long id = System.currentTimeMillis();
        xmlTemplateDocument.setData("windowId", new Long(id).toString());
        xmlTemplateDocument.setData("startTaskId", startTaskId);
        xmlTemplateDocument.setData("startProjectId", startProjectId);

        if (DEBUG > 1) System.err.println("CmsLoginNew: Login process finished");

        // process the selected template
        return startProcessing(cms, xmlTemplateDocument, "", parameters, templateSelector);
    }

    /**
     * Sets the startup project to the one read from the user
     * preferences or the one from the request parameters.
     * 
     * @param cms the initialized CmsObject
     * @param session the initialized user session 
     * @param startProjectId the id value of the request parameter (might be null)
     * @throws CmsException in case of issues reading the registry
     */
    private void setStartProjectId(CmsObject cms, I_CmsSession session, String startProjectId) 
    throws CmsException {
        // set current project to the default online project or to 
        // project specified in the users preferences
        int currentProject = CmsProject.ONLINE_PROJECT_ID;
        
        if ((startProjectId != null) && (! "".equals(startProjectId))) {
            // try to set project to id from parameters
            try {
                currentProject = (new Integer(startProjectId)).intValue();
            } catch (NumberFormatException e) {
                // currentProject will still have online project value
            }            
        } else {    
            // check out the user information if a default project is stored there.
            CmsUserSettings settings = new CmsUserSettings(cms);
            try {
                CmsProject project = cms.readProject(settings.getStartProject());
                currentProject = project.getId();
            } catch (CmsDbEntryNotFoundException e) {
                // the project does not exist, maybe it was deleted
                // set ID to online project
                currentProject = CmsProject.ONLINE_PROJECT_ID;
            }           
        }

        // try to set the current project
        try {
            CmsProject project = cms.readProject(currentProject);
            if (! cms.getAllAccessibleProjects().contains(project)) {
                // user has no (more) access to the project
                currentProject = CmsProject.ONLINE_PROJECT_ID;
            }
        } catch (Exception e) {
            // project will default to online project
            currentProject = CmsProject.ONLINE_PROJECT_ID;
        }
        
        // set the current project id
        cms.getRequestContext().setCurrentProject(cms.readProject(currentProject));
    }

    /**
     * Sets the startup view to display the selected start task.
     * 
     * @param session the initialized user session 
     * @param startTaskId the id of the task to display
     */
    private void setStartTaskId(I_CmsSession session, String startTaskId) {
        if ((startTaskId == null) || ("".equals(startTaskId))) { 
            return;
        }
        String link = "";
        Iterator i = OpenCms.getWorkplaceManager().getViews().iterator();
        while (i.hasNext()) {
            CmsWorkplaceView view = (CmsWorkplaceView)i.next();
            if (view.getKey().equals("${key.select.tasks}")) {
                link = view.getUri();
                break;
            }            
        }
        session.putValue(CmsWorkplaceDefault.C_PARA_STARTTASKID, startTaskId);
        session.putValue(CmsWorkplaceDefault.C_PARA_VIEW, link);
    }

    private CmsMessages m_messages;

    /**
     * Sets the default preferences for the current user if those values are not available.
     * @return Hashtable with default preferences.
     */

    private Hashtable getDefaultPreferences() {
        Hashtable pref = new Hashtable();
        // set the default columns in the filelist
        int filelist = 4095 + 512;
        pref.put(CmsWorkplaceDefault.C_USERPREF_FILELIST, new Integer(filelist));
        return pref;
    }

    /**
     * Customized <code>getTitle()</code> method for adding the current 
     * version information to the title of the login screen.
     *
     * @param cms for accessing system resources
     * @param tagcontent (unused)
     * @param doc reference to the A_CmsXmlContent object of the initiating XML document.
     * @param userObject must ba a <code>java.util.Hashtable</code> with request parameters
     * @return String with customized title information
     * @throws CmsException in case of errors processing the template
     */
    public Object getTitle(CmsObject cms, String tagcontent, A_CmsXmlContent doc, Object userObject) 
    throws CmsException {
        String title = (String)super.getTitle(cms, tagcontent, doc, userObject);
        if (title == null) title = "";
        title += " - " + OpenCms.getSystemInfo().getVersionName();
        return title;
    }

    /**
     * Returns a String with the version information of this OpenCms instance
     *
     * @param cms for accessing system resources
     * @param tagcontent (unused)
     * @param doc reference to the A_CmsXmlContent object of the initiating XML document.
     * @param userObject must ba a <code>java.util.Hashtable</code> with request parameters
     * @return String with the version information of this OpenCms instance
     * @throws CmsException in case of errors processing the template
     */
    public Object version(CmsObject cms, String tagcontent, A_CmsXmlContent doc, Object userObject) 
    throws CmsException {
        return OpenCms.getSystemInfo().getVersionName();
    }

    /**
     * Returns a localized String for the key value given as <code>tagcontent</code> 
     * parameter.
     *
     * @param cms for accessing system resources
     * @param tagcontent key value for the resource bundle
     * @param doc reference to the A_CmsXmlContent object of the initiating XML document.
     * @param userObject must ba a <code>java.util.Hashtable</code> with request parameters
     * @return String with the version information of this OpenCms instance
     * @throws CmsException in case of errors processing the template
     */
    public Object message(CmsObject cms, String tagcontent, A_CmsXmlContent doc, Object userObject) 
    throws CmsException {
        return m_messages.key(tagcontent);
    }
    
    /**
     * Returns the path to the workplace top level uri.<p>
     *
     * @param cms for accessing system resources
     * @param tagcontent key value for the resource bundle
     * @param doc reference to the A_CmsXmlContent object of the initiating XML document.
     * @param userObject must ba a <code>java.util.Hashtable</code> with request parameters
     * @return String with the version information of this OpenCms instance
     * @throws CmsException in case of errors processing the template
     */
    public Object workplaceUri(CmsObject cms, String tagcontent, A_CmsXmlContent doc, Object userObject) 
    throws CmsException {
        try {
            cms.readResource(CmsFrameset.JSP_WORKPLACE_URI);
            return OpenCms.getLinkManager().substituteLink(cms, CmsFrameset.JSP_WORKPLACE_URI);
        } catch (CmsSecurityException se) {
            return OpenCms.getLinkManager().substituteLink(cms, CmsFrameset.JSP_WORKPLACE_URI);
        } catch (CmsException ce) {
            // return default xml uri
        }
        return OpenCms.getLinkManager().substituteLink(cms, CmsWorkplaceAction.XML_WORKPLACE_URI);
    }    

    /**
     * Prevent caching of this template
     *
     * @param cms for accessing system resources
     * @param templateFile filename of the template file
     * @param elementName element name of this template in our parent template.
     * @param parameters hash with all template class parameters
     * @param templateSelector template section that should be processed
     * @return false
     */
    public boolean isCacheable(CmsObject cms, String templateFile, String elementName,
            Hashtable parameters, String templateSelector) {
        return false;
    }
    
    /**
     * Prevent caching of this template in the element cache
     *
     * @param cms for accessing system resources
     * @param templateFile filename of the template file
     * @param elementName element name of this template in our parent template.
     * @param parameters hash with all template class parameters
     * @param templateSelector template section that should be processed
     * @return <code>new CmsCacheDirectives(false)</code>
     */
    public CmsCacheDirectives getCacheDirectives(CmsObject cms, String templateFile, String elementName, Hashtable parameters, String templateSelector) {
        return new CmsCacheDirectives(false);
    }    
}

⌨️ 快捷键说明

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