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

📄 updatecontainer_engine.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// $Id: UpdateContainer_Engine.java,v 1.17 2002/11/27 15:37:35 knguyen Exp $//////                                   ____.//                       __/\ ______|    |__/\.     _______//            __   .____|    |       \   |    +----+       \//    _______|  /--|    |    |    -   \  _    |    :    -   \_________//   \\______: :---|    :    :           |    :    |         \________>//           |__\---\_____________:______:    :____|____:_____\//                                      /_____|////                 . . . i n   j a h i a   w e   t r u s t . . .//////  UpdateContainer_Engine//  EV  10.01.20001//  NK  06.02.2002 Added Multiple fields edit at once support//  NK	05.02.2002 Version 2.0 Multiple field edit + customisable field ( read/write permission check )////////  getInstance()//  authoriseRender()//  renderLink()//  needsJahiaData()//  handleActions()//package org.jahia.engines.updatecontainer;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.data.*;                        // JahiaDataimport org.jahia.services.acl.*;import org.jahia.services.pages.JahiaPage;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.engines.addcontainer.AddContainer_Engine;import org.jahia.services.usermanager.*;        // JahiaUserimport org.jahia.services.audit.*;              // LoggingEventListenerimport org.jahia.content.*;/** * Display the popup that let the user update a container. * * @author EV * @author NK * @version 2.0 */public class UpdateContainer_Engine implements JahiaEngine {    private static final String CLASS_NAME = UpdateContainer_Engine.class.getName();    private static  final String TEMPLATE_JSP = "update_container";    private static          UpdateContainer_Engine theObject   		= null;    private                 String              engineName  		= "updatecontainer";    private                 EngineToolBox       toolBox;    private                 boolean             flagStayOnSameField = false;    // this session variable stores the fieldname of the last edit field.    private static final String SESSION_FIELD_DEF_NAME				= "UpdateContainer_Engine.lastFieldDefName";    /***        * constructor        *        */    private UpdateContainer_Engine()    {        // JahiaConsole.println( "Engine", "***** Starting UpdateContainer Engine *****" );        toolBox = EngineToolBox.getInstance();    } // end constructor    /***        * returns a single instance of the object        *        */    public static synchronized UpdateContainer_Engine getInstance()    {        if (theObject == null) {            theObject = new UpdateContainer_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    {        JahiaContainer theContainer = (JahiaContainer) theObj;        String params = "";        params += "?mode=display";        params += "&cid=" + theContainer.getID();        return jParams.composeEngineUrl( engineName, params );    } // end renderLink    /***        * needsJahiaData        *        */    public boolean needsJahiaData( ParamBean jParams )    {        return false;    } // 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    {        // initalizes the hashmap        HashMap engineMap = initEngineMap (jParams);        // init the flag        flagStayOnSameField = false;        // get the screen        String theScreen    = (String)      engineMap.get( "screen" );        // checks if the user has the right to display the engine        JahiaContainer  theContainer = (JahiaContainer)engineMap.get("theContainer");        JahiaUser       theUser = jParams.getUser();        // if the user has admin rights give him automaticaly also the write        // rights in order to avoid two recursions in the rights checking.        if (theContainer.checkAdminAccess (theUser)) {            engineMap.put ("adminAccess", Boolean.TRUE);            engineMap.put ("writeAccess", Boolean.TRUE);        } else if (theContainer.checkWriteAccess(theUser)) {            engineMap.put ("writeAccess", Boolean.TRUE);        }        if (engineMap.get ("writeAccess") != null)        {            if (!theScreen.equals("cancel"))            {                processLastScreen (jParams, engineMap);            }            processCurrentScreen (jParams,engineMap);        } else {            throw new JahiaForbiddenAccessException ();        }        // displays the screen        toolBox.displayScreen (jParams, engineMap);    } // end handleActions    /***        * processes the last screen sent by the user        *        * @param        jParams             a ParamBean object        *        */    public void processLastScreen (ParamBean jParams, HashMap engineMap)        throws  JahiaException,                JahiaUpdateLockException,                JahiaForbiddenAccessException    {        // JahiaConsole.println(CLASS_NAME+".processLastScreen","started");        // gets the last screen        // lastscreen   = edit, rights, logs        String lastScreen = jParams.getRequest().getParameter( "lastscreen" );        if (lastScreen == null) {            //lastScreen = "edit";            lastScreen = "";        }        // indicates to sub engines that we are processing last screen        int mode = JahiaEngine.UPDATE_MODE;        // Sets the last field        JahiaField theField = null;        JahiaContainer theContainer = (JahiaContainer) engineMap.get( "theContainer" );        String  lastFieldIDStr  = jParams.getRequest().getParameter( "lastfid" );        if (lastScreen.equals( "edit" ))  {            int     lastFieldID     = -1;            try {                lastFieldID = Integer.parseInt( lastFieldIDStr );            } catch (NumberFormatException nfe) {                return; //lastFieldID = SIMPLEFIELDS_ID;            }            // get the lists            Vector neighbourSimpleFields = AddContainer_Engine.getNeighbourSimpleFields(theContainer,lastFieldID,true,(HashMap)engineMap.get("ctnListVisibleFields"));            if ( neighbourSimpleFields.size()<=0 ){                // single field edit, we add the current field to the vector                neighbourSimpleFields.add(new Integer(lastFieldID));            }            // dispatches to the appropriate sub engine            int size = neighbourSimpleFields.size();            Integer I = null;            for ( int i=0 ; i<size ; i++ ){                I = (Integer) neighbourSimpleFields.get(i);                theField = theContainer.getField(I.intValue());                if ( theField != null ){                    JahiaConsole.print(CLASS_NAME+".processLastScreen",                                       "Update container field " + theField.getDefinition().getName() + "..." );                    engineMap.put( "theField", theField );                    engineMap.put( "isSelectedField", new Boolean(false) );                    boolean doUpdate = false;                    if ( theContainer.getListID()!=0 ){                        JahiaBaseACL acl = JahiaEngineTools.getCtnListFieldACL((HashMap)engineMap.get("ctnListFieldAcls"), theField.getID());                        if ( acl != null ){                            doUpdate = acl.getPermission(jParams.getUser(),JahiaBaseACL.WRITE_RIGHTS, jParams.getSiteID());                        }                    } else {                        doUpdate = true;                    }                    if (doUpdate && !toolBox.processFieldTypes( jParams, mode, engineMap )) {                        // if there was an error, come back to last screen                        engineMap.put( "screen", lastScreen );                        engineMap.put( "jspSource", TEMPLATE_JSP );                        // error on field, then stay on same field                        flagStayOnSameField = true;                        break;                    }                    // JahiaConsole.println(CLASS_NAME+".processLastScreen",                    //                      "the field value is now [" + theField.getValue() + "]");                }            }        } else if (lastScreen.equals("rightsMgmt")) {            if (engineMap.get("adminAccess") != null) {                ManageRights.getInstance().handleActions( jParams, mode, engineMap, theContainer.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,                JahiaUpdateLockException,                JahiaForbiddenAccessException    {        // JahiaConsole.println(CLASS_NAME+".processCurrentScreen","started");        // Sets the actual field        JahiaField theField = null;        JahiaContainer theContainer = (JahiaContainer) engineMap.get( "theContainer" );        // 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;        String  fieldIDStr;        if (flagStayOnSameField)        {            fieldIDStr  = jParams.getRequest().getParameter( "lastfid" );        }        else        {            fieldIDStr  = jParams.getRequest().getParameter( "fid" );        }

⌨️ 快捷键说明

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