📄 jahiapageinfo.java
字号:
// $Id: JahiaPageInfo.java,v 1.1.1.1 2002/02/07 15:09:16 loom Exp $////// ____.// __/\ ______| |__/\. _______// __ .____| | \ | +----+ \// _______| /--| | | - \ _ | : - \_________// \\______: :---| : : | : | \________>// |__\---\_____________:______: :____|____:_____\// /_____|//// . . . i n j a h i a w e t r u s t . . .//package org.jahia.services.pages;import org.jahia.data.JahiaEditableContent;import org.jahia.services.pages.JahiaPagesDB;import org.jahia.services.pages.PageInfoInterface;import org.jahia.exceptions.JahiaException;/** * This class is used internally in Jahia to keep the page information stored * in the database. Each time a page is loaded it's information are stored * into the cache using this class.<br/> * <br/> * This class knows how to save it's content, but it's not an automatic process * to avoid one database access for each little change made to the page data. * Therefore a call to the {@link #commitChanges commitChanges()} method is * needed to save the update information to the database. * * @author Fulco Houkes * @version 1.0 */class JahiaPageInfo extends JahiaEditableContent implements PageInfoInterface{ private int mID; // page unique identification number private int mSiteID; // site unique identification number private int mParentID; // parent page ID private int mPageType; // page type private String mTitle; // page title private int mPageTemplateID; // page definition ID private String mRemoteURL; // external URL (not a jahia internal link) private int mPageLinkID; // if the page is an internal link, hold the page ID private String mCreator; // creator's user name private String mDoc; // date of creation private int mCounter; // page access counter private int mAclID; // access control list ID // these variables are private int mTempParentID; // temporary, parent page ID private int mTempPageType; // temporary, page type private String mTempTitle; // temporary, page title private int mTempPageTemplateID; // temporary, page definition ID private String mTempRemoteURL; // temporary, external URL (not a jahia internal link) private int mTempPageLinkID; // temporary, if the page is an internal link, hold the page ID private boolean mDataChanged = false; // true if the internal state of the page // has been changed with a setxxxx method. private static JahiaPagesDB mPageDB = JahiaPagesDB.getInstance (); //------------------------------------------------------------------------- /** * constructor */ protected JahiaPageInfo (int ID, int jahiaID, int parentID, int pageType, String title, int pageTemplateID, String remoteURL, int pageLinkID, String creator, String doc, int counter, int aclID) { mID = ID; mSiteID = jahiaID; mParentID = parentID; mTitle = title; mCreator = creator; mDoc = doc; mCounter = counter; mAclID = aclID; mPageType = pageType; mPageTemplateID = pageTemplateID; if ( remoteURL == null ) { mRemoteURL = NO_REMOTE_URL; } else { mRemoteURL = remoteURL; } mPageLinkID = pageLinkID; // temporary variables mTempParentID = mParentID; mTempPageType = mPageType; mTempTitle = mTitle; mTempPageTemplateID = pageTemplateID; mTempRemoteURL = mRemoteURL; mTempPageLinkID = mPageLinkID; mDataChanged = false; } // end constructor //------------------------------------------------------------------------- /** Return the page's unique identification number. * * @return Return the page ID. */ public int getID () { int result = mID; return result; } //------------------------------------------------------------------------- /** Return the site ID in which the page is located. * * @return Return the page site ID. */ public int getJahiaID () { int result = mSiteID; return result; } //------------------------------------------------------------------------- /** Return the parent page unique identification number. * * @return Return the parent page ID. */ public int getParentID () { int result = mParentID; return result; } //------------------------------------------------------------------------- /** Return the page definition ID. * * @return Return the page definition ID. */ public int getPageTemplateID () { int result = mPageTemplateID; return result; } //------------------------------------------------------------------------- /** Return the page title. * * @return Return the page title. */ public String getTitle () { String result = mTitle; return result; } //------------------------------------------------------------------------- /** Return the user nickname who created the page. This nickname is the * user name used internally by Jahia. * * @return Return the creator nickname. */ public String getCreator () { String result = mCreator; return result; } //------------------------------------------------------------------------- /** Return the page's date of creation in ms from 1975. * * @return Return the date of creation. */ public String getDoc () { String result = mDoc; return result; } //------------------------------------------------------------------------- /** Return the page's hit counter. * * @return Return the page counter. */ public int getCounter () { int result = mCounter; return result; } //------------------------------------------------------------------------- /** Return the ACL unique identification number. * * @return Return the ACL ID. */ public int getAclID () { int result = mAclID; return result; } //------------------------------------------------------------------------- /** Return the page type * * @return Return the page type */ public int getPageType () { int result = mPageType; return result; } //------------------------------------------------------------------------- /** Return the remote URL in case the page is an external reference (a non * Jahia page. If the page is not an external URL, "<no url>" is returned. * * @return Return the remote URL. */ public String getRemoteURL () { String result = mRemoteURL; return result; } //------------------------------------------------------------------------- /** Return the internal jahia page ID in case the page is an internal * jahia link. * * @return Return the page link ID. */ public int getPageLinkID () { int result = mPageLinkID; return result; } //------------------------------------------------------------------------- /** Change the page title. * * @param value String holding the new page title. */ public synchronized void setTitle (String value) { mTempTitle = value; mDataChanged = true; } //------------------------------------------------------------------------- /** Change the page type. By changing this information, be aware to change * also the according remote URL or page link ID information. See the * methods {@link #setPageLinkID setPageLinkID()} and * {@link #setRemoteURL setRemoteURL()}. * * @param pageType The new page type. */ public synchronized void setPageType (int value) { mTempPageType = value; switch (value) { case TYPE_LINK : // the page in a link to an internal page. Disable the // remote URL. mTempRemoteURL = NO_REMOTE_URL; break; case TYPE_URL : // the page is an extenal URL, disable the internal page link. mTempPageLinkID = TERMINATION_PAGE_ID; break; case TYPE_DIRECT : // the page is a REAL page, disable the internal and external // links. mTempRemoteURL = NO_REMOTE_URL; mTempPageLinkID = TERMINATION_PAGE_ID; break; } mDataChanged = true; } //------------------------------------------------------------------------- /** Set the parent ID, which must point to an existing page. * * @param value The new parent ID. */ public synchronized void setParentID (int value) { mTempParentID = value; mDataChanged = true; } //------------------------------------------------------------------------- /** Set the new remote URL. The page type will change accordingly. * * @param value The new remoteURL. */ public synchronized void setRemoteURL (String value) { mTempRemoteURL = value; mTempPageType = TYPE_URL; mTempPageLinkID = TERMINATION_PAGE_ID; mDataChanged = true; } //------------------------------------------------------------------------- /** Set the new internal link ID. This ID must be an existing page ID. * * @param value The new page link ID. */ public synchronized void setPageLinkID (int value) { mTempPageLinkID = value; mTempPageType = TYPE_LINK; mTempRemoteURL = NO_REMOTE_URL; mDataChanged = true; } //------------------------------------------------------------------------- /** Set the new page defintion ID. The ID must point to a existing page * definition. * * @param value The new page defintion ID. */ public synchronized final void setPageTemplateID (int value) { mTempPageTemplateID = value; mDataChanged = true; } //------------------------------------------------------------------------- /** Commit into the database all the previous changes on the page. * * @exception JahiaException Throws a JahiaException if the data could not * be saved successfully into the database. */ public synchronized void commitChanges () throws JahiaException { // commit only if the data has really changed if (mDataChanged) { // get the write access. getWriteLock(); // commit the modified changes. mParentID = mTempParentID; mPageType = mTempPageType; mTitle = mTempTitle; mPageTemplateID = mTempPageTemplateID; mRemoteURL = mTempRemoteURL; mPageLinkID = mTempPageLinkID; // commit the changes into the database. mPageDB.updatePageInfo (this); mDataChanged = false; // release the write access. releaseWriteLock(); } } //------------------------------------------------------------------------- /** Disable the changes. */ public synchronized void disableChanges () { if (mDataChanged) { mTempParentID = mParentID; mTempPageType = mPageType; mTempTitle = mTitle; mTempPageTemplateID = mPageTemplateID; mTempRemoteURL = mRemoteURL; mTempPageLinkID = mPageLinkID; mDataChanged = false; } } //------------------------------------------------------------------------- /** * Increment by one unit the page hit counter. */ public synchronized void incrementCounter () { mCounter++; mDataChanged = true; } //------------------------------------------------------------------------- /** Release the update access lock. */ public synchronized void releaseUpdateLock () throws JahiaException { disableChanges (); super.releaseUpdateLock (); } //------------------------------------------------------------------------- /** clone page info * * @param aclID int The id to asociate to the cloned page * @param newParentID int The id of the parent. * if newParentID = -1, get the parent ID of the page to clone. * @param pageID int the new id of the cloned page. * @param dateOfCreation String the current date. * * @return Return the cloned JahiaPageInfo */ protected JahiaPageInfo clonePageInfo (int aclID, int newParentID, int pageID, String dateOfCreation) { if (newParentID == -1) { newParentID = mParentID; } // String Title = "clonedTitle"; return new JahiaPageInfo (pageID, mSiteID, newParentID, mPageType, mTitle, mPageTemplateID, mRemoteURL, mPageLinkID, mCreator, dateOfCreation, mCounter, aclID); }} // end JahiaPage
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -