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

📄 addcontainer_engine.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                        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",                          "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,                JahiaForbiddenAccessException {        toDebug("=== AddContainer_Engine :: processCurrentScreen ===");        // 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" );        }        int fieldID = -1;        Integer fieldInt;        try {            fieldID = Integer.parseInt( fieldIDStr );        } catch (NumberFormatException nfe) {            try {                fieldID = (((Integer)engineMap.get( "field_id" ))).intValue();            } catch (Exception e) {                fieldID = -1;            }        }        // get first visible field        fieldID = getFirstVisibleField(theContainer,jParams,engineMap, jParams.getUser(),(HashMap)engineMap.get("ctnListFieldAcls"),fieldID);        if ( fieldID !=0 )            theField = theContainer.getField(fieldID);        JahiaField selectedField = theField;        engineMap.put( "field_id", new Integer(fieldID) );        if (theScreen.equals( "edit" ))  {            Vector neighbourSimpleFields = new Vector();            Vector fieldIDs = new Vector();            if ( theField != null ){                // at least one visible field                if ( theField instanceof JahiaSimpleField ) {                    // multiple simple field edit                    neighbourSimpleFields = getNeighbourSimpleFields(theContainer,fieldID,true,(HashMap)engineMap.get("ctnListVisibleFields"));                    // 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 ){                            engineMap.put("fieldForm",null); // reset field form                            HashMap map = (HashMap)engineMap.get("ctnListVisibleFields");                            if ( map == null )                                map = new HashMap();                            boolean visible = ( (theContainer.getListID()==0) || (map.get(new Integer(theField.getID()))!=null) );                            if ( visible ){                                JahiaConsole.println(CLASS_NAME+".processCurrentScreen",                                                 "The field value is now " + theField.getValue() );                                engineMap.put( "theField", theField );                                engineMap.put( "isSelectedField", new Boolean(theField.getID()==fieldID) );                                engineMap.put( "fieldID", new Integer(theField.getID()) );                                toolBox.processFieldTypes( jParams, mode, engineMap );                            }                            if ( engineMap.get("fieldForm") != null ){                                fieldIDs.add(new Integer(theField.getID()));                                Hashtable fieldForms = (Hashtable)engineMap.get("fieldForms");                                fieldForms.put(new Integer(theField.getID()),(String)engineMap.get("fieldForm"));                            }                        }                    }                } else {                    // single field edit                    JahiaConsole.println(CLASS_NAME+".processCurrentScreen",                                     "processCurrentScreen > the field value is now " + theField.getValue() );                    engineMap.put( "theField", theField );                    engineMap.put( "isSelectedField", new Boolean(theField.getID()==fieldID) );                    engineMap.put( "fieldID", new Integer(theField.getID()) );                    toolBox.processFieldTypes( jParams, mode, engineMap );                    if ( engineMap.get("fieldForm") != null ){                        fieldIDs.add(new Integer(theField.getID()));                        Hashtable fieldForms = (Hashtable)engineMap.get("fieldForms");                        fieldForms.put(new Integer(theField.getID()),(String)engineMap.get("fieldForm"));                    }                }            }            engineMap.put( "fieldID", new Integer(fieldID) );            engineMap.put( "theField", selectedField );            engineMap.put( "fieldIDs", fieldIDs );            engineMap.put( "simpleFieldIDs", neighbourSimpleFields );        // This test should replace the above        } else if (theScreen.equals("rightsMgmt")) {            if (engineMap.get("adminAccess") != null) {                ManageRights.getInstance().handleActions( jParams, mode, engineMap, theContainer.getAclID() );            } else {                throw new JahiaForbiddenAccessException();            }        } else if (theScreen.equals("save")) { //|| theScreen.equals("apply")) {            JahiaConsole.println(CLASS_NAME+".processCurrentScreen",                                 "processCurrentScreen > we are in save Mode" );            mode = JahiaEngine.SAVE_MODE;            // save the container info            int containerParentID = ((Integer)engineMap.get( "containerParentID" )).intValue();            int parentAclID = 0;            if (containerParentID != 0) {                parentAclID = ServicesRegistry.getInstance().getJahiaContainersService().                        loadContainerInfo (containerParentID).getAclID();            } else {                parentAclID = jParams.getPage().getAclID();            }            ServicesRegistry.getInstance().getJahiaContainersService().                        saveContainerInfo( theContainer, containerParentID, parentAclID, jParams );            // save fields, one by one            Enumeration fields = theContainer.getFields();            int fakeCounter = 1;            while (fields.hasMoreElements()) {                JahiaField containerField = (JahiaField) fields.nextElement();                JahiaConsole.println("AddContainer_Engine.processCurrentScreen",                                     "Saving container field " + containerField.getDefinition().getName() + "..." );                containerField.setID( 0 );                containerField.setctnid( theContainer.getID() );                //System.out.println ("%%%%%%%%%%%%%% counter = "+fakeCounter);                ServicesRegistry.getInstance().getJahiaFieldService().                        saveField( containerField, theContainer.getAclID(), jParams );                JahiaConsole.println("AddContainer_Engine.processCurrentScreen",                                     "Saving field..., containerField value is " + containerField.getValue());                engineMap.put( "theField", containerField );                toolBox.processFieldTypes( jParams, mode, engineMap );                fakeCounter++;            }            // save rights            if (engineMap.get("adminAccess") != null) {                //ViewRights.getInstance().handleActions( jParams, mode, engineMap, theContainer.getAclID() );                ManageRights.getInstance().handleActions( jParams, mode, engineMap, theContainer.getAclID() );            }            JahiaContainerList theList = ServicesRegistry.getInstance().                getJahiaContainersService().loadContainerListInfo( theContainer.getListID() );            // since we have made modifications concerning this page, let's flush            // the content cache for all the users and browsers as well as all            // pages that display this containerList...            if (theList != null) {                Set containerPageRefs = ContainerListsXRefManager.getInstance().                    getAbsoluteContainerListPageIDs(jParams.getSiteKey(),                                                    theList.getDefinition().getName(),                                                    theList.getPageID());                if (containerPageRefs != null) {                    Iterator pageRefIDs = containerPageRefs.iterator();                    while (pageRefIDs.hasNext()) {                        Integer curPageID = (Integer) pageRefIDs.next();                        ServicesRegistry.getInstance().getCacheServerService().                            removeEntry(curPageID.toString());                    }                } else {                    JahiaConsole.println("AddContainer_Engine.processCurrentScreen",                                         "Why is cross ref list empty ?");                }            } else {                JahiaConsole.println("AddContainer_Engine.processCurrentScreen",                                     "Couldn't retrieve parent containerList, why is that ?");            }            // this is still necessary in the case we are on the page itself            // and the containerList is not referenced in an absolute way.            ServicesRegistry.getInstance().getCacheServerService().                removeEntry(Integer.toString(jParams.getPageID()));            // fire event            JahiaEvent theEvent = new JahiaEvent( this, jParams, theContainer );            ServicesRegistry.getInstance().getJahiaEventService().                        fireAddContainer (theEvent);            // flag for subEngine: means that is a call from  AddContainer, reset the flag            jParams.getSession().setAttribute("AddContainer", "false");            //if (theScreen.equals ("apply")) {            //    engineMap.put("theContainer", theContainer);            //    engineMap.put("screen", (String)jParams.getRequest().getParameter("lastscreen"));            //    HashMap ctnListFieldAcls = getCtnListFieldAclMap(theContainer,jParams);            //    engineMap.put( "ctnListFieldAcls", ctnListFieldAcls );            //    engineMap.put( "ctnListVisibleFields", getCtnListVisibleFieldsMap(theContainer, jParams.getUser(), ctnListFieldAcls) );            //    engineMap.put( "engineUrl", jParams.composeEngineUrl("updatecontainer", "&cid=" + theContainer.getID()));            //    engineMap.put( "jspSource", "apply");            //}            JahiaConsole.println(CLASS_NAME+".processCurrentScreen", "Saving container !!" );        } else if (theScreen.equals("cancel")) {            // flag for subEngine: means that is a call from  AddContainer, reset the flag            jParams.getSession().setAttribute("AddContainer", "false");        }    } // 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(ParamBean jParams )        throws  JahiaException,                JahiaSessionExpirationException    {        toDebug("=== AddContainer_Engine :: initEngineMap ===");

⌨️ 快捷键说明

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