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 ACRoleUpdateEventHandler extends DefaultEventHandler implements ParameterTypes, DatabaseDefaults, FrameConstants 18 { 19 20 private ACRoleUpdateEventHandler() {} 21 22 private static ACRoleUpdateEventHandler instance = new ACRoleUpdateEventHandler(); 23 24 public static ACRoleUpdateEventHandler getInstance() 25 { 26 return instance; 27 } 28 29 public void handleEvent(TKEvent evt) throws TKException 30 { 31 try { 32 WebManEvent.checkEvent(evt.getRemoteUser(), evt.getName(), ContextConstants.ACCESS_CONTROL); 33 String roleId = evt.getParameter( PARAMETER, "ROLE_ID"); 34 String roleName = evt.getParameter(PARAMETER, "ROLE_NAME"); 35 checkParameter(roleName, "Name"); 36 Role theRole = null; 37 if (roleId == null) 38 { 39 theRole = RoleFactory.getInstance().createRole(roleName); 40 } 41 else 42 { 43 theRole = RoleFactory.getInstance().getRole(new Integer (roleId)); 44 if (theRole != null) 45 { 46 theRole.setName(roleName); 47 RoleFactory.getInstance().modifyRole(theRole); 48 } 49 } 50 51 TKHTMLTemplate t = evt.getPrepHTMLTemplate( "f_ac_role.tmpl" ); 52 HTMLUtils.fillFrameSet( t, HTMLUtils.LEFT_FRAME_WIDTH, "AC_ROLE_LIST", "EMPTY" ); 53 String editPage = evt.getParameter(PARAMETER, "EDIT_PAGE"); 54 t.set("EDIT_PAGE", (editPage == null ? "1" : editPage)); 55 WebManEvent.fillEventsIntoTemplate(evt.getRemoteUser(), t, ACCESS_CONTROL); 56 evt.finishTemplate( t ); 57 } catch (Throwable e) { 58 throw WebmanExceptionHandler.getException(e); 59 } 60 } 61 62 public boolean isHandler(TKEvent evt) 63 { 64 return evt.getName().equalsIgnoreCase( "AC_ROLE_UPDATE" ); 65 } 66 67 } 68 | Popular Tags |