📄 pageproperties_engine.java
字号:
// $Id: PageProperties_Engine.java,v 1.6 2002/05/03 16:52:21 pmartin Exp $////// ____.// __/\ ______| |__/\. _______// __ .____| | \ | +----+ \// _______| /--| | | - \ _ | : - \_________// \\______: :---| : : | : | \________>// |__\---\_____________:______: :____|____:_____\// /_____|//// . . . i n j a h i a w e t r u s t . . .////// PageProperties_Engine// EV 10.02.20001//// getInstance()// authoriseRender()// renderLink()// needsJahiaData()// handleActions()//package org.jahia.engines.pages;import java.util.*; // HashMapimport javax.servlet.http.*; // HttpSessionimport org.jahia.exceptions.JahiaException;import org.jahia.exceptions.JahiaUpdateLockException;import org.jahia.exceptions.JahiaSessionExpirationException;import org.jahia.exceptions.JahiaForbiddenAccessException;import org.jahia.utils.*; // JahiaConsoleimport org.jahia.utils.pagination.*; // PaginatablePrebuiltListimport org.jahia.data.*; // JahiaDataimport org.jahia.services.pages.*;import org.jahia.data.fields.*; // JahiaField, FieldTypesimport org.jahia.data.containers.*; // JahiaContainerimport org.jahia.params.*; // ParamBeanimport org.jahia.registries.*; // ServicesRegistryimport org.jahia.engines.*; // JahiaEngine interfaceimport org.jahia.engines.shared.*; // SmallText, BigText, etc.import org.jahia.data.events.*; // JahiaEventimport org.jahia.engines.rights.*; // ViewRightsimport org.jahia.services.acl.*;import org.jahia.services.usermanager.*; // JahiaUserimport org.jahia.services.audit.*; // LoggingEventListenerpublic class PageProperties_Engine implements JahiaEngine { private static final String CLASS_NAME = PageProperties_Engine.class.getName(); private static final String TEMPLATE_JSP = "page_properties"; private static PageProperties_Engine theObject = null; private String engineName = "pageproperties"; private EngineToolBox toolBox; private final String MSG_INTERNAL_ERROR = new String ("Pages Properties Engine internal error"); // references to needed services. private JahiaAuditLogManagerService mAuditLogManager = null; /*** * constructor * */ private PageProperties_Engine() { // JahiaConsole.println( "Engine", // "***** Starting PageProperties Engine *****" ); toolBox = EngineToolBox.getInstance(); } // end constructor /*** * returns a single instance of the object * */ public static synchronized PageProperties_Engine getInstance() { if (theObject == null) { theObject = new PageProperties_Engine(); } return theObject; } // end getInstance /*** * authoriseRender * */ public boolean authoriseRender( ParamBean jParams ) { return toolBox.authoriseRender( jParams ); } // end authoriseRender /*** * renderLink * */ public String renderLink( ParamBean jParams, Object theObj ) throws JahiaException { String params = "";// params += "&mode=display"; params += "?mode=display"; return jParams.composeEngineUrl( engineName, params ); } // end renderLink /*** * needsJahiaData * */ public boolean needsJahiaData( ParamBean jParams ) { return true; } // end needsJahiaData /*** * handles the engine actions * * @param jParams a ParamBean object * @param jData a JahiaData object (not mandatory) * */ public void handleActions (ParamBean jParams, JahiaData jData) throws JahiaException, JahiaUpdateLockException, JahiaForbiddenAccessException { JahiaPage thePage = jParams.getPage(); JahiaUser theUser = jParams.getUser(); /////////////////////////////////////////////////////////////////////////////////////////// // FIXME -Fulco- // // Has been disabled until full implementation of the objectlocking. // /////////////////////////////////////////////////////////////////////////////////////////// //if (thePage.getUpdateLock (theUser)) { // initalizes the hashmap HashMap engineMap = initEngineMap (jData); // checks if the user has the right to display the engine thePage = (JahiaPage)engineMap.get ("thePage"); if (thePage.checkAdminAccess (theUser)) { engineMap.put( "adminAccess", Boolean.TRUE); engineMap.put( "writeAccess", Boolean.TRUE); } else if (thePage.checkWriteAccess (theUser)) { engineMap.put( "writeAccess", Boolean.TRUE); } if (engineMap.get ("writeAccess") != null) { processLastScreen (jData.params(), engineMap); processCurrentScreen (jData.params(), engineMap); } else { throw new JahiaForbiddenAccessException (); } // displays the screen toolBox.displayScreen( jData.params(), engineMap ); //} else { // throw new JahiaUpdateLockException (thePage); //} } // end handleActions /*** * processes the last screen sent by the user * * @param jParams a ParamBean object * */ public void processLastScreen (ParamBean jParams, HashMap engineMap) throws JahiaException, JahiaForbiddenAccessException { // Sets the page JahiaPage thePage = (JahiaPage) engineMap.get( "thePage" ); // gets the last screen // lastscreen = edit, rights, logs String lastScreen = jParams.getRequest().getParameter( "lastscreen" ); if (lastScreen == null) { return; //lastScreen = "edit"; } // indicates to sub engines that we are processing last screen int mode = JahiaEngine.UPDATE_MODE; // dispatches to the appropriate sub engine if (lastScreen.equals( "edit" )) { if (!updatePageData( jParams, engineMap )) { // if there was an error, come back to last screen engineMap.put( "screen", lastScreen ); engineMap.put( "jspSource", TEMPLATE_JSP ); } } else if (lastScreen.equals("rightsMgmt")) { if (engineMap.get("adminAccess") != null) { ManageRights.getInstance().handleActions( jParams, mode, engineMap, thePage.getAclID() ); } else { throw new JahiaForbiddenAccessException(); } } } // end processLastScreen /*** * prepares the screen requested by the user * * @param jParams a ParamBean object * */ public void processCurrentScreen (ParamBean jParams, HashMap engineMap) throws JahiaException, JahiaForbiddenAccessException { // Sets the actual field JahiaPage thePage = (JahiaPage) engineMap.get ("thePage"); // gets the current screen // screen = edit, rights, logs String theScreen = (String) engineMap.get ("screen"); // indicates to sub engines that we are processing last screen int mode = JahiaEngine.LOAD_MODE; // dispatches to the appropriate sub engine if (theScreen.equals ("edit")) { loadPageData( jParams, engineMap ); } else if (theScreen.equals ("logs")) { toolBox.loadLogData( jParams, LoggingEventListener.PAGE_TYPE, engineMap ); } else if (theScreen.equals ("rightsMgmt")) { if (engineMap.get ("adminAccess") != null) { ManageRights.getInstance().handleActions (jParams, mode, engineMap, thePage.getAclID());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -