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 ACUserUpdateEventHandler extends DefaultEventHandler implements ParameterTypes, DatabaseDefaults, FrameConstants 18 { 19 20 private ACUserUpdateEventHandler() {} 21 22 private static ACUserUpdateEventHandler instance = new ACUserUpdateEventHandler(); 23 24 public static ACUserUpdateEventHandler 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 34 String userId = evt.getParameter( PARAMETER, "USER_ID" ); 35 String userName = evt.getParameter( PARAMETER, "USER_NAME" ); 36 String userLogin = evt.getParameter( PARAMETER, "USER_LOGIN" ); 37 User theUser = null; 39 40 checkParameter(userName, "Name"); 41 checkParameter(userLogin, "Login"); 42 43 if (userId == null) 44 { 45 if (ACUtils.checkLoginExistance(userLogin)) 46 throw new TKUserException("An object with the given attributes already exists.", 47 UserCodes.DUPLICATE_OBJECT, 48 ErrorCodes.USER_SEVERITY, 49 true, 50 null); 51 theUser = UserFactory.getInstance().createUser(userLogin, userName); 52 } 53 else 54 { 55 if (ACUtils.checkLoginExistance(userLogin, new Integer (userId))) 56 throw new TKUserException("An object with the given attributes already exists.", 57 UserCodes.DUPLICATE_OBJECT, 58 ErrorCodes.USER_SEVERITY, 59 true, 60 null); 61 theUser = UserFactory.getInstance().getUser(new Integer (userId)); 62 63 } 64 65 if (theUser != null) { 66 67 theUser.setName( userName ); 69 theUser.setLogin( userLogin ); 70 71 106 UserFactory.getInstance().modifyUser(theUser); 107 } 108 TKHTMLTemplate t = evt.getPrepHTMLTemplate( "f_ac_user.tmpl" ); 109 String editPage = evt.getParameter(PARAMETER, "EDIT_PAGE"); 110 t.set("EDIT_PAGE", (editPage == null ? "1" : editPage)); 111 if (userId != null) { 112 HTMLUtils.fillFrameSet( t, HTMLUtils.LEFT_FRAME_WIDTH, "AC_USER_LIST", "AC_USER_EDIT" ); 113 t.set("USER_ID", userId); 114 } 115 else 116 HTMLUtils.fillFrameSet( t, HTMLUtils.LEFT_FRAME_WIDTH, "AC_USER_LIST", "EMPTY" ); 117 118 WebManEvent.fillEventsIntoTemplate(evt.getRemoteUser(), t, ACCESS_CONTROL); 119 evt.finishTemplate( t ); 120 } catch (Throwable e) { 121 throw WebmanExceptionHandler.getException(e); 122 } 123 } 124 125 public boolean isHandler(TKEvent evt) 126 { 127 return evt.getName().equalsIgnoreCase( "AC_USER_UPDATE" ); 128 } 129 130 } 131 | Popular Tags |