📄 containerlistproperties_engine.java
字号:
// use the first val = (String)engineMap.get("fieldAclDefaultField"); } if ( val != null ){ // store for JSP engineMap.put("aclfieldname",val); engineMap.put("fieldAclDefaultField",val); I = (Integer)acls.get(val); if ( I != null ){ JahiaConsole.println(CLASS_NAME+".processCurrentScreen","Step3"); ManageRights.getInstance().handleActions( jParams, mode, engineMap, I.intValue() ); } } else { engineMap.put("aclfieldname", ""); return; } } } else { throw new JahiaForbiddenAccessException(); } } else if (theScreen.equals("save") || theScreen.equals ("apply")) { mode = JahiaEngine.SAVE_MODE; // save the page info int clParentID = theContainerList.getParentEntryID(); ServicesRegistry.getInstance().getJahiaContainersService(). saveContainerListInfo(theContainerList, 0); if (engineMap.get("lastscreen") != null && engineMap.get("lastscreen").equals("edit")) { // save container's rank saveContainersRank(jParams, engineMap); } // save rights Integer aclID = null; if (engineMap.get("adminAccess") != null) { // save container list ACLs if ("ctneditview_rights".equals(engineMap.get("lastscreen"))) { String aclfieldname = jParams.getRequest().getParameter("aclfieldname"); JahiaConsole.println(CLASS_NAME+".processCurrentScreen", "Save container list field ACL : " + aclfieldname); // save container list field acl HashMap acls = (HashMap)engineMap.get("fieldAcls"); if (acls != null) { aclID = (Integer)acls.get(aclfieldname); ManageRights.getInstance().handleActions(jParams, mode, engineMap, aclID.intValue()); } } else { //ViewRights.getInstance().handleActions( jParams, mode, engineMap, ManageRights.getInstance().handleActions(jParams, mode, engineMap, theContainerList.getAclID()); } } // 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 (theContainerList != null) { Set containerPageRefs = ContainerListsXRefManager.getInstance(). getAbsoluteContainerListPageIDs(jParams.getSiteKey(), theContainerList.getDefinition().getName(), theContainerList.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 ?"); } // since we updated properties on this container list, let's flush // the cache for the page this container list is on... ServicesRegistry.getInstance().getCacheServerService(). removeEntry(Integer.toString(jParams.getPageID())); // fire event JahiaEvent theEvent = new JahiaEvent( this, jParams, theContainerList ); ServicesRegistry.getInstance().getJahiaEventService(). fireSetContainerListProperties(theEvent); if (theScreen.equals("apply")) { engineMap.put( "screen", (String)jParams.getRequest().getParameter("lastscreen")); String lastScreen = (String)engineMap.get("lastscreen"); if ("ctneditview_rights".equals(lastScreen)) { ManageRights.getInstance().handleActions(jParams, JahiaEngine.LOAD_MODE, engineMap, aclID.intValue()); } else if ("rightsMgmt".equals(lastScreen)) { ManageRights.getInstance().handleActions(jParams, JahiaEngine.LOAD_MODE, engineMap, theContainerList.getAclID()); } } JahiaConsole.println(CLASS_NAME + ".processCurrentScreen", "Container list saved"); } } // end processCurrentScreen /*** * inits the engine map * * The vector "containers" contains * all the containers of the container list. * The vector "fieldInfoToDisplay" contains * the fields values on which the sort is done. * a value in "fieldInfoToDisplay" correspond to * the container at the same index into "containers". * * @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 { HashMap engineMap = new HashMap(); JahiaContainerList theContainerList = null; String theScreen = jParams.getRequest().getParameter( "screen" ); String cListIDStr = jParams.getRequest().getParameter( "clid" ); int cListID = 0; try { cListID = Integer.parseInt( cListIDStr ); } catch (Exception e) { throw new JahiaException( "Error in parameters", "ContainerListProperties_Engine : error in parameters", JahiaException.PARAMETER_ERROR, JahiaException.CRITICAL ); } // 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" ); /////////////////////////////////////////////////////////////////////////////////////// // 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 (); } theContainerList = (JahiaContainerList) engineMap.get( "theContainerList" ); } else { theScreen = "edit"; // init engine map engineMap = new HashMap(); theContainerList = ServicesRegistry.getInstance(). getJahiaContainersService().loadContainerList( cListID, LoadFlags.NOTHING, jParams ); engineMap.put( "theContainerList", theContainerList ); // print out container list properties Properties props = theContainerList.getProperties(); Enumeration enum = props.propertyNames(); String p = ""; while ( enum.hasMoreElements() ){ p = (String)enum.nextElement(); JahiaConsole.println(CLASS_NAME+".initEngineMap","Properties : " + props.getProperty(p)); } engineMap.put( "jParams", jParams ); // the ordered list of containers Vector containers = new Vector(); Enumeration containerList = theContainerList.getContainers(); JahiaContainer theContainer = null; // the info displayed to make the difference between containers Vector fieldInfoToDisplay = new Vector(); String fieldInfo = ""; // the date in millisecond (the vector is empty if the field is not a date) Vector sortInfo4Date = new Vector(); String sortInfo = ""; int cnt = 0; while ( containerList.hasMoreElements() ) { cnt++; theContainer = (JahiaContainer) containerList.nextElement(); // let's order the container fields in the exact order in which they are decrared in the template // ( not as in the order in which they are stored in db ) theContainer.fieldsStructureCheck(jParams); containers.add(theContainer); fieldInfo = getFieldInfoToDisplay(0,theContainer,jParams); if (fieldInfo.equals("")) { fieldInfo = "-- Item "+cnt+" --"; } fieldInfoToDisplay.add( fieldInfo ); sortInfo = getSortInfo4Date(0,theContainer,jParams); if (sortInfo != null) { sortInfo4Date.add(sortInfo); } } JahiaField theField = null; Enumeration fieldsList = null; Vector fields = null; if (theContainer != null) { fieldsList = theContainer.getFields(); fields = new Vector(); while ( fieldsList.hasMoreElements() ) { theField = (JahiaField)fieldsList.nextElement(); fields.add(theField); } } engineMap.put("containers", containers); engineMap.put("fields", fields); String fieldDefIDStr = ""; engineMap.put("cursorField", new Integer( 0 )); engineMap.put("fieldInfoToDisplay", fieldInfoToDisplay); engineMap.put("containerSelected", new Integer(0)); // build container list field acl HashMap fieldAcls = buildFieldDefAcls( theContainerList, jParams, engineMap ); engineMap.put("fieldAcls",fieldAcls); } if (theContainerList == null) { throw new JahiaException( "ContainerList not found", "ContainerListProperties_Engine : ContainerList not found", JahiaException.PARAMETER_ERROR, JahiaException.CRITICAL ); } Properties extraParams = new Properties(); String containerListName = theContainerList.getDefinition().getName(); String scrollStr = jParams.getParameter("ctnscroll_" + containerListName); if (scrollStr !=null) { if (scrollStr.length() > 0) { extraParams.setProperty("ctnscroll_" + containerListName, scrollStr); } } engineMap.put( "renderType", new Integer(JahiaEngine.RENDERTYPE_FORWARD) ); engineMap.put( "engineName", engineName ); engineMap.put( "engineUrl", jParams.composeEngineUrl( engineName, extraParams, "&clid=" + theContainerList.getID() ) ); theSession.setAttribute( "jahia_session_engineMap", engineMap ); // sets screen engineMap.put( "screen", theScreen ); if (theScreen.equals ("save")) { engineMap.put( "jspSource", "close" ); } else if (theScreen.equals ("apply")) { engineMap.put( "jspSource", "apply" ); } else if (theScreen.equals ("cancel")) { engineMap.put( "jspSource", "close" ); } else { engineMap.put( "jspSource", TEMPLATE_JSP ); } /* // sets screen engineMap.put( "screen", theScreen ); if (theScreen.equals("cancel")) { engineMap.put( "jspSource", "close" ); } else if (theScreen.equals("save")) { engineMap.put( "jspSource", "close" ); } else if (theScreen.equals ("apply")) { String lastScreen = (String)engineMap.get("lastscreen"); if (!"ctneditview_rights".equals(lastScreen)) { engineMap.put( "jspSource", "apply" ); } } else { engineMap.put( "jspSource", TEMPLATE_JSP ); } */ engineMap.put("doAddEditViewRight", new Boolean(true)); // sets engineMap for JSPs jParams.getRequest().setAttribute( "engineTitle", "Container List Settings" ); jParams.getRequest().setAttribute( "org.jahia.engines.EngineHashMap", engineMap ); return engineMap; } // end initEngineMap /*** * loads container list data for the JSP file * * @param jParams a ParamBean object * (with request and response)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -