1 package de.webman.acl.eventhandler; 2 3 import java.util.*; 4 5 import com.teamkonzept.web.*; 6 import com.teamkonzept.lib.*; 7 import com.teamkonzept.webman.*; 8 import com.teamkonzept.webman.mainint.*; 9 import com.teamkonzept.webman.mainint.events.*; 10 import de.webman.acl.*; 11 12 17 public class ACGroupEditEventHandler extends DefaultEventHandler implements ParameterTypes, DatabaseDefaults, FrameConstants 18 { 19 20 private ACGroupEditEventHandler() {} 21 22 23 private static ACGroupEditEventHandler instance = new ACGroupEditEventHandler(); 24 25 public static ACGroupEditEventHandler getInstance() 26 { 27 return instance; 28 } 29 30 public void handleEvent(TKEvent evt) throws TKException 31 { 32 try 33 { 34 WebManEvent.checkEvent(evt.getRemoteUser(), evt.getName(), ContextConstants.ACCESS_CONTROL); 35 36 TKHTMLTemplate t = evt.getPrepHTMLTemplate( "ac_groupedit.tmpl" ); 37 String editPage = evt.getParameter( PARAMETER, "EDIT_PAGE"); 38 String groupId = evt.getParameter( PARAMETER, "GROUP_ID" ); 39 if (groupId != null) 40 { 41 Profile theGroup = ProfileFactory.getInstance().getProfile(new Integer (groupId)); 42 if (theGroup != null) 43 { 44 t.set("GROUP_ID", theGroup.getID()); 45 t.set("GROUP_NAME", theGroup.getName()); 46 t.set("GROUP_LOGIN", theGroup.getLogin()); 47 TKVector userVector = ACConvenience.makeUserList(UserFactory.getInstance().getUsers(), theGroup); 49 t.setListIterator(new TKStandardPluginIterator("AC_USER_LIST", null, userVector, true, t.getListIterator())); 50 51 TKVector profileVector = ACConvenience.makeGroupList(ProfileFactory.getInstance().getProfiles(), theGroup); 53 t.setListIterator(new TKStandardPluginIterator("AC_GROUP_LIST", null, profileVector, true, t.getListIterator())); 54 55 TKVector contextVector = ACConvenience.makeContextList( ContextFactory.getInstance(). 57 getContexts()); 58 t.setListIterator(new TKStandardPluginIterator("AC_CONTEXT_LIST", null, contextVector, 59 true, t.getListIterator())); 60 61 TKVector roleVector = ACConvenience.makeRoleList( RoleFactory.getInstance().getRoles() ); 63 t.setListIterator(new TKStandardPluginIterator("AC_ROLE_LIST", null, roleVector, 64 true, t.getListIterator())); 65 TKVector globalRights = ACConvenience.makeGlobalRightsList( theGroup.getPolicies() ); 67 if (globalRights == null || globalRights.size() == 0) t.set("NO_USER_GLOBAL_RIGHTS", "TRUE"); 68 t.setListIterator(new TKStandardPluginIterator("USER_GLOBAL_RIGHTS", null, globalRights, 69 true, t.getListIterator())); 70 } 71 } 72 t.set("EDIT_PAGE", (editPage == null ? "1" : editPage)); 73 WebManEvent.fillEventsIntoTemplate(evt.getRemoteUser(), t, ACCESS_CONTROL); 74 evt.finishTemplate( t ); 75 } 76 catch (Throwable e) 77 { 78 throw WebmanExceptionHandler.getException(e); 79 } 80 } 81 82 public boolean isHandler(TKEvent evt) 83 { 84 return evt.getName().equalsIgnoreCase( "AC_GROUP_EDIT" ); 85 } 86 87 } 88 | Popular Tags |