📄 applications_engine.java
字号:
.lookupGroup(0, appID + "_" + fieldID + "_" + role); if ( grp != null ){ Enumeration enum = grp.members(); Principal p = null; while( enum.hasMoreElements() ){ p = (Principal)enum.nextElement(); if (p instanceof JahiaUser) { authUsersVec.add((JahiaUser)p); } } } authMembers = authUsersVec; } engineMap.put( "authUsers" + role, authUsersVec ); } engineMap.put( "allUsers", allUsers ); // all user having membership on this site engineMap.put( "authUsers", authMembers ); // authorized users from session } else { JahiaConsole.println("Applications_Engine.handleDisplayRoles","in groups mode"); // build authorized groups for the new role Vector groups = GroupsTools.getGroups(jParams.getSiteID(),false); // FIXME_MULTISITE -Hollis- appli group role are attached to site ????, // actually it is the case , better to attach them to site 0 ? Vector authGroupsVec = new Vector(); JahiaGroup grp = null; if ( role != null && !role.equals("") ){ if ( engineMap.get( "authGroups" + role ) != null ){ JahiaConsole.println("Applications_Engine.handleDisplayRoles","get authGroups from session"); authMembers = (Vector)engineMap.get( "authGroups" + role ); } else { JahiaConsole.println("Applications_Engine.handleDisplayRoles","get authGroups from db"); grp = ServicesRegistry.getInstance() .getJahiaGroupManagerService() .lookupGroup(0, appID + "_" + fieldID + "_" + role); // HOLLIS all group roles are of site 0 !!!! if ( grp != null ){ JahiaConsole.println("Applications_Engine.handleDisplayRoles", " group " + appID + "_" + fieldID + "_" + role + " is not null "); Enumeration enum = grp.members(); Principal p = null; while( enum.hasMoreElements() ){ p = (Principal)enum.nextElement(); JahiaConsole.println("Applications_Engine.handleDisplayRoles"," principal grp=" + p.getName()) ; if (p instanceof Group) { authGroupsVec.add((JahiaGroup)p); } } } authMembers = authGroupsVec; } engineMap.put( "authGroups" + role, authMembers ); } //engineMap.put( "authMembers", authGroupsVec.elements() ); // authorized groups from storage engineMap.put( "allGroups", groups ); // all groups of this sites engineMap.put( "authGroups", authMembers ); // autorized groups from session } // prepare for output engineMap.put( "appID", new Integer(appID) ); engineMap.put( "fieldID", new Integer(fieldID) ); engineMap.put( "role", role ); engineMap.put( "jspSource", TEMPLATE_JSP ); } private void handleSaveRoles( ParamBean jParams, HashMap engineMap) throws JahiaException { int fieldID = Integer.parseInt(jParams.getRequest().getParameter("fid")); int appID = Integer.parseInt(jParams.getParameter("appid")); engineMap.put( "flushApp", new Boolean(true) ); JahiaConsole.println("Applications_Engine.handleSaveRoles","fieldID=" + fieldID + " appID=" + appID); // get the application's roles list ApplicationContext appContext = ServicesRegistry.getInstance() .getJahiaApplicationContextService() .getApplicationContext(appID); Enumeration roles = appContext.getRoles().elements(); // get the mode ( users or groups ) String switchUG = jParams.getRequest().getParameter("switchug"); String prevSwitchUG = jParams.getRequest().getParameter("prevswitchug"); if ( switchUG != null && prevSwitchUG != null ){ Vector authMembers = new Vector(); // handle the current role // save change for current role String currentRole = ""; if ( jParams.getParameter("currentRole") != null ){ String[] memberKeys = null; currentRole = (String)jParams.getParameter("currentRole"); memberKeys = (String[])jParams.getRequest().getParameterValues("authMembers"); if ( memberKeys != null ){ // check the previous mode if ( prevSwitchUG.equals("users") ){ JahiaUser user = null; for ( int i=0 ; i<memberKeys.length ; i++ ){ user = ServicesRegistry.getInstance() .getJahiaUserManagerService() .lookupUser(memberKeys[i]); if ( user != null ){ authMembers.add(user); JahiaConsole.println("Applications_Engine.handleSaveRoles", "in users mode, added member= " + user.getUsername()); } } } else if ( prevSwitchUG.equals("groups") ){ JahiaGroup grp = null; for ( int i=0 ; i<memberKeys.length ; i++ ){ grp = ServicesRegistry.getInstance() .getJahiaGroupManagerService() .lookupGroup(memberKeys[i]); if ( grp != null ){ authMembers.add(grp); } } } } if ( prevSwitchUG.equals("users") ){ engineMap.put( "authUsers" + currentRole, authMembers ); } else { engineMap.put( "authGroups" + currentRole, authMembers ); } } StringBuffer strVal = new StringBuffer(); // Now Handle all changes String role = ""; if ( roles != null ){ while (roles.hasMoreElements()){ role = (String)roles.nextElement(); JahiaGroup grp = ServicesRegistry.getInstance() .getJahiaGroupManagerService() .lookupGroup(0, appID + "_" + fieldID + "_" + role); // Hollis all app group roles are in site 0 if ( grp != null ){ // Handle users if ( engineMap.get( "authUsers" + role ) != null ){ authMembers = (Vector)engineMap.get( "authUsers" + role ); } else { Vector authUsersVec = new Vector(); JahiaUser user = null; Principal p = null; Enumeration enum = grp.members(); while( enum.hasMoreElements() ){ p = (Principal)enum.nextElement(); if (p instanceof JahiaUser) { authUsersVec.add((JahiaUser)p); } } authMembers = authUsersVec; } engineMap.put( "authUsers" + role, authMembers ); // reset content authMembers = null; // Handle groups if ( engineMap.get( "authGroups" + role ) != null ){ authMembers = (Vector)engineMap.get( "authGroups" + role ); } else { Principal p = null; Vector authGroupsVec = new Vector(); Enumeration enum = grp.members(); while( enum.hasMoreElements() ){ p = (Principal)enum.nextElement(); if (p instanceof Group) { authGroupsVec.add((JahiaGroup)p); } } authMembers = authGroupsVec; } engineMap.put( "authGroups" + role, authMembers ); } } } } // prepare for output engineMap.put( "fieldID", new Integer(fieldID) ); engineMap.put( "jspSource", CLOSE_JSP ); } /*** * 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 { JahiaConsole.println ("Applications_Engine.initEngineMap","Entering... "); String theScreen = jParams.getRequest().getParameter( "screen" ); JahiaConsole.println ("Applications_Engine.initEngineMap","the screen is " + theScreen); // gets session values HttpSession theSession = jParams.getSession (); HashMap engineMap = null; engineMap = (HashMap) theSession.getAttribute( "jahia_session_engineMap" ); if ( engineMap == null ){ JahiaConsole.println ("Applications_Engine.initEngineMap","engine map is null"); engineMap = new HashMap(); } // init engine map engineMap.put( "jParams", jParams ); engineMap.put( "renderType", new Integer(JahiaEngine.RENDERTYPE_FORWARD) ); engineMap.put( "engineName", engineName ); theSession.setAttribute( "jahia_session_engineMap", engineMap ); // build the applications Engine url String applicationManagerUrl = renderLink(jParams, null); engineMap.put("applicationManagerUrl", applicationManagerUrl); // init map engineMap.put( "screen", theScreen ); return engineMap; } // end initEngineMap} // end Applications_Engine
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -