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

📄 pageproperties_engine.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            } else {                throw new JahiaForbiddenAccessException ();            }        } else if (theScreen.equals ("save") || theScreen.equals ("apply")) {            mode = JahiaEngine.SAVE_MODE;            String  pageTitle       = (String)engineMap.get ("dataPageTitle");            Integer pageTemplateID  = (Integer)engineMap.get ("dataPageTemplateID");            thePage.setTitle (pageTitle);            thePage.setPageTemplateID (pageTemplateID.intValue());            thePage.commitChanges(true);            // save rights            if (engineMap.get ("adminAccess") != null) {                engineMap.put ("logObjectType", Integer.toString (LoggingEventListener.PAGE_TYPE));                engineMap.put ("logObject", thePage);                //ViewRights.getInstance().handleActions (jParams, mode, engineMap, thePage.getAclID());                ManageRights.getInstance().handleActions (jParams, mode, engineMap, thePage.getAclID());            }            String lastScreen = jParams.getRequest().getParameter( "lastscreen" );            if (lastScreen != null) {                JahiaConsole.println("PageProperties_Engine.processCurrentScreen", "lastScreen=" + lastScreen);                if(lastScreen.equals("edit")) {                    // since we cannot efficiently determine all the references                    // to this page we do an entire cache flush.                    /** @todo is there a better way to do this ? */                    ServicesRegistry.getInstance().getCacheServerService().flushCache();                    // fire event                    JahiaEvent theEvent = new JahiaEvent( this, jParams, thePage );                    ServicesRegistry.getInstance().getJahiaEventService().                                fireSetPageProperties( theEvent );                }            }            if (theScreen.equals ("apply")) {                engineMap.put( "screen", (String)jParams.getRequest().getParameter("lastscreen"));            }            ///////////////////////////////////////////////////////////////////////////////////////            // FIXME -Fulco-            //            //  Has been disabled until full implementation of the objectlocking.            //            ///////////////////////////////////////////////////////////////////////////////////////            // release the lock            //thePage.releaseUpdateLock (jParams.getUser());            ///////////////////////////////////////////////////////////////////////////////////////        } else if (theScreen.equals ("cancel")) {            mode = JahiaEngine.CANCEL_MODE;            ///////////////////////////////////////////////////////////////////////////////////////            // FIXME -Fulco-            //            //  Has been disabled until full implementation of the objectlocking.            //            ///////////////////////////////////////////////////////////////////////////////////////            // release the lock            //thePage.releaseUpdateLock (jParams.getUser());            ///////////////////////////////////////////////////////////////////////////////////////        }    } // end processCurrentScreen    //-------------------------------------------------------------------------    /***        * inits the engine map        *        * @param        jParams             a ParamBean object        *                                   (with request and response)        * @return       a HashMap object containing all the basic values        *               needed by an engine        *        */    private HashMap initEngineMap( JahiaData jData )        throws  JahiaException,                JahiaSessionExpirationException    {        HashMap engineMap = new HashMap();        ParamBean jParams = jData.params();        String theScreen    = jParams.getRequest().getParameter ("screen");        // gets session values        //HttpSession theSession = jParams.getRequest().getSession( true );        HttpSession theSession = jParams.getSession ();        if (theScreen != null) {            // if no, load the container value from the session            engineMap   = (HashMap) theSession.getAttribute( "jahia_session_engineMap" );            //thePage     = (JahiaPage) engineMap.get( "thePage" );            ///////////////////////////////////////////////////////////////////////////////////////            // FIXME -Fulco-            //            //      This is a quick hack, engineMap should not be null if the session didn't            //      expired. Maybe there are other cases where the engineMap can be null, I didn't            //      checked them at all.            ///////////////////////////////////////////////////////////////////////////////////////            if (engineMap == null) {                throw new JahiaSessionExpirationException ();            }        } else {            JahiaPage thePage = jParams.getPage();            theScreen = "edit";            // init engine map            engineMap = new HashMap();            engineMap.put ("jParams", jParams);            engineMap.put ("jData", jData);            engineMap.put ("thePage", thePage);            engineMap.put ("dataPageTitle", thePage.getTitle());            engineMap.put ("dataPageTemplateID", new Integer (thePage.getPageTemplateID()));        }        engineMap.put ("renderType", new Integer(JahiaEngine.RENDERTYPE_FORWARD));        engineMap.put ("engineName", engineName);        engineMap.put ("engineUrl", jParams.composeEngineUrl( engineName, "" ));        theSession.setAttribute ("jahia_session_engineMap", engineMap);        // sets screen        engineMap.put ("screen", theScreen);        if (theScreen.equals ("save")) {            engineMap.put( "jspSource", "close" );        } else if (theScreen.equals ("cancel")) {            engineMap.put( "jspSource", "close" );        } else if (theScreen.equals ("apply")) {            engineMap.put( "jspSource", "apply" );        } else {            engineMap.put( "jspSource", TEMPLATE_JSP );        }        // sets engineMap for JSPs        jParams.getRequest().setAttribute( "engineTitle", "Page properties" );        jParams.getRequest().setAttribute( "org.jahia.engines.EngineHashMap", engineMap );        return engineMap;    } // end initEngineMap    //-------------------------------------------------------------------------    /***        * loads data for the JSP file        *        * @param        jParams             a ParamBean object        *                                   (with request and response)        * @param        engineMap           then engine map, to be forwarded        *                                   to the JSP file        *        */    private void loadPageData (ParamBean jParams, HashMap engineMap)        throws JahiaException    {        JahiaPage thePage = (JahiaPage) engineMap.get ("thePage");        JahiaUser theUser = null;        if (jParams != null)            theUser = jParams.getUser();        // get only visibles templates        Enumeration enum = ServicesRegistry.getInstance().                getJahiaPageTemplateService().                getPageTemplates (thePage.getJahiaID(), true);        // get the current page's template too even though it is desactivated        JahiaPageDefinition pDef = thePage.getPageTemplate();        Vector vec = new Vector();        while( enum.hasMoreElements() ){            vec.add( (JahiaPageDefinition)enum.nextElement() );        }        if ( pDef != null && !pDef.isAvailable()){            vec.add(pDef);            // sort it            Collections.sort(vec,pDef);        }        engineMap.put ("templateList", vec.elements());        // existing pages, for move... not used yet        Enumeration pageTree = ServicesRegistry.getInstance().                getJahiaPageService().                getAllPages (thePage.getJahiaID(), PageLoadFlags.DIRECT,                        jParams, theUser);        engineMap.put ("pageTree", pageTree);    } // end loadPageData    /***        * gets POST form data from the JSP file        *        * @param        jParams             a ParamBean object        *                                   (with request and response)        * @param        engineMap           then engine map, to be forwarded        *                                   to the JSP file        * @return       true if everything went okay, false if not        *        */    private boolean updatePageData( ParamBean jParams, HashMap engineMap )    throws JahiaException    {        boolean result = false;        String pageTitle    = jParams.getRequest().getParameter( "pageTitle" );        String pageDef      = jParams.getRequest().getParameter( "pageTemplate" );        if ((pageTitle != null) && (pageDef != null)) {            try {                int pageTemplateID = Integer.parseInt (pageDef);                engineMap.put ("dataPageTitle", pageTitle);                engineMap.put ("dataPageTemplateID", new Integer(pageTemplateID));                result = true;            }            catch (NumberFormatException ex) {            }        }        return result;    }    private void DisplayEngineMap (HashMap engineMap)    {        StringBuffer output = new StringBuffer ("Detail of engineMap :\n");        Set keys = engineMap.keySet();        Iterator iter = keys.iterator ();        while (iter.hasNext()) {            String name = (String)iter.next();            Object object = engineMap.get (name);            output.append ("-" + name + " = ["+object.toString()+"]\n");        }        //System.out.println (output.toString());    }}

⌨️ 快捷键说明

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