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

📄 cmsflexcontroller.java

📁 cms是开源的框架
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            res.setDateHeader(CmsRequestUtil.HEADER_LAST_MODIFIED, System.currentTimeMillis());
        }
    }

    /**
     * Clears all data of this controller.<p>
     */
    public void clear() {

        if (m_flexRequestList != null) {
            m_flexRequestList.clear();
        }
        m_flexRequestList = null;
        if (m_flexResponseList != null) {
            m_flexResponseList.clear();
        }
        m_flexResponseList = null;
        if (m_req != null) {
            m_req.removeAttribute(ATTRIBUTE_NAME);
        }
        m_req = null;
        m_res = null;
        m_cmsObject = null;
        m_resource = null;
        m_cache = null;
        m_throwable = null;
    }

    /**
     * Returns the CmsFlexCache instance where all results from this request will be cached in.<p>
     * 
     * This is public so that pages like the Flex Cache Administration page
     * have a way to access the cache object.<p>
     *
     * @return the CmsFlexCache instance where all results from this request will be cached in
     */
    public CmsFlexCache getCmsCache() {

        return m_cache;
    }

    /**
     * Returns the wrapped CmsObject.<p>
     * 
     * @return the wrapped CmsObject
     */
    public CmsObject getCmsObject() {

        return m_cmsObject;
    }

    /** 
     * This method provides access to the top-level CmsResource of the request
     * which is of a type that supports the FlexCache,
     * i.e. usually the CmsFile that is identical to the file uri requested by the user,
     * not he current included element.<p>
     * 
     * @return the requested top-level CmsFile
     */
    public CmsResource getCmsResource() {

        return m_resource;
    }

    /**
     * Returns the current flex request.<p>
     * 
     * @return the current flex request
     */
    public CmsFlexRequest getCurrentRequest() {

        return (CmsFlexRequest)m_flexRequestList.get(m_flexRequestList.size() - 1);
    }

    /**
     * Returns the current flex response.<p>
     * 
     * @return the current flex response
     */
    public CmsFlexResponse getCurrentResponse() {

        return (CmsFlexResponse)m_flexResponseList.get(m_flexResponseList.size() - 1);
    }

    /**
     * Returns the combined "expires" date for all resources read during this request.<p>
     * 
     * @return the combined "expires" date for all resources read during this request
     */
    public long getDateExpires() {

        int pos = m_flexContextInfoList.size() - 1;
        if (pos < 0) {
            // ensure a valid position is used
            return CmsResource.DATE_EXPIRED_DEFAULT;
        }
        return ((CmsFlexRequestContextInfo)m_flexContextInfoList.get(pos)).getDateExpires();
    }

    /**
     * Returns the combined "last modified" date for all resources read during this request.<p>
     * 
     * @return the combined "last modified" date for all resources read during this request
     */
    public long getDateLastModified() {

        int pos = m_flexContextInfoList.size() - 1;
        if (pos < 0) {
            // ensure a valid position is used
            return CmsResource.DATE_RELEASED_DEFAULT;
        }
        return ((CmsFlexRequestContextInfo)m_flexContextInfoList.get(pos)).getDateLastModified();
    }

    /**
     * Returns the size of the response stack.<p>
     * 
     * @return the size of the response stack
     */
    public int getResponseStackSize() {

        return m_flexResponseList.size();
    }

    /**
     * Returns an exception (Throwable) that was caught during inclusion of sub elements, 
     * or null if no exceptions where thrown in sub elements.<p>
     * 
     * @return an exception (Throwable) that was caught during inclusion of sub elements
     */
    public Throwable getThrowable() {

        return m_throwable;
    }

    /**
     * Returns the URI of a VFS resource that caused the exception that was caught during inclusion of sub elements,
     * might return null if no URI information was available for the exception.<p>
     * 
     * @return the URI of a VFS resource that caused the exception that was caught during inclusion of sub elements
     */
    public String getThrowableResourceUri() {

        return m_throwableResourceUri;
    }

    /**
     * Returns the current http request.<p>
     * 
     * @return the current http request
     */
    public HttpServletRequest getTopRequest() {

        return m_req;
    }

    /**
     * Returns the current http response.<p>
     * 
     * @return the current http response
     */
    public HttpServletResponse getTopResponse() {

        return m_res;
    }

    /**
     * Returns <code>true</code> if the controller does not yet contain any requests.<p>
     * 
     * @return <code>true</code> if the controller does not yet contain any requests
     */
    public boolean isEmptyRequestList() {

        return (m_flexRequestList != null) && m_flexRequestList.isEmpty();
    }

    /**
     * Returns <code>true</code> if this controller is currently in "forward" mode.<p>
     *
     * @return <code>true</code> if this controller is currently in "forward" mode
     */
    public boolean isForwardMode() {

        return m_forwardMode;
    }

    /**
     * Returns <code>true</code> if the generated output of the response should 
     * be written to the stream directly.<p>
     * 
     * @return <code>true</code> if the generated output of the response should be written to the stream directly
     */
    public boolean isStreaming() {

        return m_streaming;
    }

    /**
     * Returns <code>true</code> if this controller was generated as top level controller.<p>
     * 
     * If a resource (e.g. a JSP) is processed and it's content is included in 
     * another resource, then this will be <code>false</code>.   
     * 
     * @return <code>true</code> if this controller was generated as top level controller
     * @see org.opencms.loader.I_CmsResourceLoader#dump(CmsObject, CmsResource, String, java.util.Locale, HttpServletRequest, HttpServletResponse)
     * @see org.opencms.jsp.CmsJspActionElement#getContent(String)
     */
    public boolean isTop() {

        return m_top;
    }

    /**
     * Removes the topmost request/response pair from the stack.<p>
     */
    public void pop() {

        if ((m_flexRequestList != null) && !m_flexRequestList.isEmpty()) {
            m_flexRequestList.remove(m_flexRequestList.size() - 1);
        }
        if ((m_flexResponseList != null) && !m_flexRequestList.isEmpty()) {
            m_flexResponseList.remove(m_flexResponseList.size() - 1);
        }
        if ((m_flexContextInfoList != null) && !m_flexContextInfoList.isEmpty()) {
            CmsFlexRequestContextInfo info = (CmsFlexRequestContextInfo)m_flexContextInfoList.remove(m_flexContextInfoList.size() - 1);
            if (m_flexContextInfoList.size() > 0) {
                ((CmsFlexRequestContextInfo)m_flexContextInfoList.get(0)).merge(info);
                updateRequestContextInfo();
            }
        }
    }

    /**
     * Adds another flex request/response pair to the stack.<p>
     * 
     * @param req the request to add
     * @param res the response to add
     */
    public void push(CmsFlexRequest req, CmsFlexResponse res) {

        m_flexRequestList.add(req);
        m_flexResponseList.add(res);
        m_flexContextInfoList.add(new CmsFlexRequestContextInfo());
        updateRequestContextInfo();
    }

    /**
     * Sets the value of the "forward mode" flag.<p>
     *
     * @param value the forward mode to set
     */
    public void setForwardMode(boolean value) {

        m_forwardMode = value;
    }

    /**
     * Sets an exception (Throwable) that was caught during inclusion of sub elements.<p>
     * 
     * If another exception is already set in this controller, then the additional exception
     * is ignored.
     * 
     * @param throwable the exception (Throwable) to set
     * @param resource the URI of the VFS resource the error occured on (might be null if unknown)
     * @return the exception stored in the contoller
     */
    public Throwable setThrowable(Throwable throwable, String resource) {

        if (m_throwable == null) {
            m_throwable = throwable;
            m_throwableResourceUri = resource;
        } else {
            if (LOG.isDebugEnabled()) {
                if (resource != null) {
                    LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXCONTROLLER_IGNORED_EXCEPTION_1, resource));
                } else {
                    LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXCONTROLLER_IGNORED_EXCEPTION_0));
                }
            }
        }
        return m_throwable;
    }

    /**
     * Puts the response in a suspended state.<p>  
     */
    public void suspendFlexResponse() {

        for (int i = 0; i < m_flexResponseList.size(); i++) {
            CmsFlexResponse res = (CmsFlexResponse)m_flexResponseList.get(i);
            res.setSuspended(true);
        }
    }

    /**
     * Updates the "last modified" date and the "expires" date 
     * for all resources read during this request with the given values.<p>
     * 
     * The currently stored value for "last modified" is only updated with the new value if
     * the new value is either larger (i.e. newer) then the stored value,
     * or if the new value is less then zero, which indicates that the "last modified"
     * optimization can not be used because the element is dynamic.<p>
     * 
     * The stored "expires" value is only updated if the new value is smaller
     * then the stored value.<p>
     * 
     * @param dateLastModified the value to update the "last modified" date with
     * @param dateExpires the value to update the "expires" date with
     */
    public void updateDates(long dateLastModified, long dateExpires) {

        int pos = m_flexContextInfoList.size() - 1;
        if (pos < 0) {
            // ensure a valid position is used
            return;
        }
        ((CmsFlexRequestContextInfo)m_flexContextInfoList.get(pos)).updateDates(dateLastModified, dateExpires);
    }

    /**
     * Updates the context info of the request context.<p>
     */
    private void updateRequestContextInfo() {

        if ((m_flexContextInfoList != null) && !m_flexContextInfoList.isEmpty()) {
            m_cmsObject.getRequestContext().setAttribute(
                CmsRequestUtil.HEADER_LAST_MODIFIED,
                m_flexContextInfoList.get(m_flexContextInfoList.size() - 1));
        }
    }
}

⌨️ 快捷键说明

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