📄 jahiahomepagenew.java
字号:
//// ____.// __/\ ______| |__/\. _______// __ .____| | \ | +----+ \// _______| /--| | | - \ _ | : - \_________// \\______: :---| : : | : | \________>// |__\---\_____________:______: :____|____:_____\// /_____|//// . . . i n j a h i a w e t r u s t . . .////// NK - 17 Dec. 2001 ://package org.jahia.services.homepages;import java.util.Hashtable;import java.util.Enumeration;import org.jahia.exceptions.JahiaException;import org.jahia.utils.JahiaConsole;/** * A JahiaHomepageNew holds information used to define homepage of type New. * Home page definition of this type holds extra information like the template to use for the page to create, * the parent page id ( where to insert the new page ), and default right setting. * * @author Khue ng * @see HomepagesTypes.HOMEPAGE_NEW * @version 1.0 */public final class JahiaHomepageNew extends JahiaHomepage{ private static String CLASS_NAME = JahiaHomepageNew.class.getName(); // template to use private static final String TEMPLATE = "template"; // where to insert the new page ( or subtree ) private static final String PARENT_PAGEID = "parent_pageid"; private JahiaHomepagesPersistance hpp; /** * Constructor, subclass must have exact constructor signature. * * @param Integer id, the unique identifier * @param String name, the name * @param String descr, the descr * @param Integer type, the type * @param String sitekey, the site key * @param Hashtable props, the properties * @param Integer aclID, the acl */ JahiaHomepageNew( Integer id, String name, String descr, Integer type, String siteKey, Hashtable props, Integer aclID ){ super(id,name,descr,type,siteKey,props,aclID); } //------------------------------------------------------------------------- /** * Return the id of the page to use as parent for the new homepage. * * @return int the parent page id, -1 if not defined. */ public int getParentPageID(){ Integer id = (Integer)props.get(PARENT_PAGEID); if ( id == null ){ return -1; } return id.intValue(); } //------------------------------------------------------------------------- /** * Set the parent page ID * * @param int the parent page id */ public void setParentPageID(int pageID) throws JahiaException{ props.put(PARENT_PAGEID,new Integer(pageID)); } //------------------------------------------------------------------------- /** * Return the id of the template to use when creating the page. * * @return int the template id, -1 if not defined. */ public int getTemplateID(){ Integer id = (Integer)props.get(TEMPLATE); if ( id == null ){ return -1; } return id.intValue(); } //------------------------------------------------------------------------- /** * Set the template ID * * @param int the template id */ public void setTemplateID(int id) throws JahiaException{ props.put(TEMPLATE,new Integer(id)); } //-------------------------------------------------------------------------- /** * Save its state. * */ void save() throws JahiaException { hpp.getInstance().save(this); saveProperties(); } //-------------------------------------------------------------------------- /** * Delete. * */ void delete() throws JahiaException { hpp.getInstance().delete(getID()); deleteProperties(); } //------------------------------------------------------------------------- /** * Load extra properties from storage * */ void loadProperties() throws JahiaException{ if ( props == null ) props = new Hashtable(); String value = null; value = hpp.getInstance().getProperty(this,TEMPLATE); if ( value != null ){ try { props.put(TEMPLATE,new Integer(value)); } catch ( Throwable t ){ t.printStackTrace(); } } value = hpp.getInstance().getProperty(this,PARENT_PAGEID); if ( value != null ){ try { props.put(PARENT_PAGEID,new Integer(value)); } catch ( Throwable t ){ t.printStackTrace(); } } } //------------------------------------------------------------------------- /** * Save extra properties in storage * */ void saveProperties() throws JahiaException{ deleteProperties(); String value = null; value = Integer.toString(getTemplateID()); if ( value != null ) hpp.getInstance().addProperty(this,TEMPLATE,value); value = Integer.toString(getParentPageID()); if ( value != null ) hpp.getInstance().addProperty(this,PARENT_PAGEID,value); } //------------------------------------------------------------------------- /** * Delete extra properties in storage * */ void deleteProperties() throws JahiaException{ hpp.getInstance().deleteProperties(this); } //-------------------------------------------------------------------------- /** * Return a string representation of the home page and it's internal state. * * @return A string representation of this home page. */ public String toString (){ StringBuffer buff= new StringBuffer("String rep. of a "); buff.append(CLASS_NAME); buff.append(" bean :\n"); buff.append(" id :"); buff.append(getID()); // TODO . complete return buff.toString(); } //-------------------------------------------------------------------------- /** * Return a clone. * * @return JahiaHomepage, the clone. */ public Object clone (){ Hashtable hash = null; if ( getProperties() != null ){ hash = new Hashtable(); if ( props.get(PARENT_PAGEID) != null ) hash.put(PARENT_PAGEID,new Integer(getParentPageID())); if ( props.get(TEMPLATE) != null ) hash.put(TEMPLATE,new Integer(getTemplateID())); } JahiaHomepageNew clone = new JahiaHomepageNew( new Integer(getID()), getName(), getDescr(), new Integer(getType()), getSiteKey(), hash, new Integer(getAclID()) ); return clone; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -