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

📄 rollerrequest.java

📁 这个weblogging 设计得比较精巧
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        //------------------------------------------------------------------------    /**     * Gets the path-info specified by the request, or null.     * @return String     */    public String getPathInfo()    {        return mPathInfo;    }    //------------------------------------------------------------------------    /**     * Gets the page link name specified by the request, or null.     * @return String     */    public String getPageLink()    {        return mPageLink;    }    //------------------------------------------------------------------------    /**     * Gets the BookmarkData specified by the request, or null.     * @return BookmarkData     */    public BookmarkData getBookmark( )    {        if ( mBookmark == null )        {            String id = getFromRequest(BOOKMARKID_KEY);            if ( id != null )            {                try                {                    mBookmark =                         getRoller().getBookmarkManager().retrieveBookmark(id);                }                catch (RollerException e)                {                    mLogger.error("Getting bookmark from request",e);                }            }        }        return mBookmark;    }    //------------------------------------------------------------------------    /**     * Gets the WeblogCategoryData specified by the request, or null.     * @return      */    public WeblogCategoryData getWeblogCategory()    {        if ( mWeblogCategory == null )        {            String id = getFromRequest(WEBLOGCATEGORYID_KEY);            if ( id != null )            {                try                {                    mWeblogCategory =                         getRoller().getWeblogManager().retrieveWeblogCategory(id);                }                catch (RollerException e)                {                    mLogger.error("Getting weblog category by id from request",e);                }            }            else if (StringUtils.isNotEmpty(id = getFromRequest(WEBLOGCATEGORYNAME_KEY)))            {                try                {                    mWeblogCategory =                         getRoller().getWeblogManager().getWeblogCategoryByPath(                            getWebsite(), null, id);                }                catch (RollerException e)                {                    mLogger.error("Getting weblog category by name from request",e);                }            }        }        return mWeblogCategory;    }    //------------------------------------------------------------------------    /**     * Gets the FolderData specified by the request, or null.     * @return FolderData     */    public FolderData getFolder( )    {        FolderData folder = null;        //if ( folder == null )        //{            String id = getFromRequest(FOLDERID_KEY);            if ( id != null )            {                try                {                    folder =                         getRoller().getBookmarkManager().retrieveFolder(id);                }                catch (RollerException e)                {                    mLogger.error("Getting folder from request",e);                }            }        //}        return folder;    }    //------------------------------------------------------------------------    /**     * Gets the PageData specified by the request, or null.     * @return PageData     */    public PageData getPage()    {        if (mPage == null)        {            String id = getFromRequest(PAGEID_KEY);            if ( id != null )            {                try                {                    mPage = getRoller().getUserManager().retrievePage(id);                }                catch (RollerException e)                {                    mLogger.error("Getting page from request",e);                }            }        }        return mPage;    }        /**     * Allow comment servlet to inject page that it has chosen.     */    public void setPage(PageData page)     {        mPage = page;    }        //------------------------------------------------------------------------    /**     * Gets the Request URL specified by the request, or null.     * @return String     */    public String getRequestURL( )    {        return mRequest.getRequestURL().toString();    }        //------------------------------------------------------------------------        /**     * Gets the Referer URL specified by the request, or null.     * @return String     */    public String getRefererURL( )    {        return mRequest.getHeader("referer");    }        /**     * Gets the UserData specified by the request, or null.     * @return UserData     */    public UserData getUser()    {        if (mWebsite != null) return mWebsite.getUser();        return null;    }    /**     * Gets the WebsiteData specified by the request, or null.     * @return WeblogCategory     */    public WebsiteData getWebsite()    {        return mWebsite;    }    public void setWebsite(WebsiteData wd)    {        mWebsite = wd;    }    /**     * Gets the WeblogEntryData specified by the request, or null.     *      * Why is this done lazily in the parseRequestParameters() method?     *      * Because: that method is called from init(), which is called from     * a ServletFilter, and sometimes request parameters are not available     * in a ServletFiler. They ARE available when the URL points to a JSP,     * but they ARE NOT available when the URL points to the PageServlet.     * This may be a Tomcat bug, I'm not sure.     *      * @return WeblogEntryData     */    public WeblogEntryData getWeblogEntry( )    {        if ( mWeblogEntry == null )        {                    // Look for anchor or entry ID that identifies a specific entry             String anchor = mRequest.getParameter(ANCHOR_KEY);            if (anchor == null) anchor = mRequest.getParameter(ANCHOR_KEY_OLD);            String entryid = mRequest.getParameter(WEBLOGENTRYID_KEY);            if (entryid == null)             {                entryid = (String)mRequest.getAttribute(WEBLOGENTRYID_KEY);            }            try            {                if ( entryid != null )                {                    WeblogManager weblogMgr = getRoller().getWeblogManager();                    mWeblogEntry = weblogMgr.retrieveWeblogEntry(entryid);                                                    // We can use entry to find the website, if we don't have one                    if ( mWeblogEntry != null && mWebsite == null )                    {                        mWebsite = mWeblogEntry.getWebsite();                    }                }                 else if ( mWebsite != null && anchor != null )                {                    WeblogManager weblogMgr = getRoller().getWeblogManager();                    mWeblogEntry = weblogMgr.getWeblogEntryByAnchor(                        mWebsite,anchor);                }                                         }            catch (RollerException e)            {                mLogger.error("EXCEPTION getting weblog entry",e);                mLogger.error("user=" + mWebsite.getUser());                mLogger.error("anchor=" + anchor);                mLogger.error("entryid=" + entryid);            }        }                   return mWeblogEntry;    }    //------------------------------------------------------------------------    /** Get attribute from mRequest, and if that fails try session */    private String getFromRequest( String key )    {        String ret = (String)mRequest.getAttribute( key );        if ( ret == null )        {            ret = mRequest.getParameter( key );            if (ret == null && mRequest.getSession(false) != null)            {                ret = (String)mRequest.getSession().getAttribute( key );            }        }        return ret;    }    //------------------------------------------------------------------------    private Date parseDate( String dateString )    {        Date ret = null;                if (   dateString!=null             && dateString.length()==8            && StringUtils.isNumeric(dateString) )        {            ParsePosition pos = new ParsePosition(0);            ret = mFmt.parse( dateString, pos );                        // make sure the requested date is not in the future            Date today = getToday();            if (ret.after(today)) ret = today;                        // since a specific date was requested set time to end of day            ret = DateUtil.getEndOfDay(ret);        }        return ret;    }        //------------------------------------------------------------------------    public String toString()    {        StringBuffer sb = new StringBuffer();        sb.append("[");        sb.append(getRequestURL());        sb.append(", ");        sb.append(getRefererURL());        sb.append("]");        return sb.toString();    }    //------------------------------------------------------------------------    /**      * @see org.roller.pojos.ParsedRequest#isLinkbackEnabled()     */    public boolean isEnableLinkback()    {        return RollerRuntimeConfig.getBooleanProperty("site.linkbacks.enabled");    }}

⌨️ 快捷键说明

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