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 ACGroupUpdateEventHandler extends DefaultEventHandler implements ParameterTypes, DatabaseDefaults, FrameConstants 18 { 19 20 private ACGroupUpdateEventHandler() {} 21 22 private static ACGroupUpdateEventHandler instance = new ACGroupUpdateEventHandler(); 23 24 public static ACGroupUpdateEventHandler 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 groupId = evt.getParameter( PARAMETER, "GROUP_ID"); 35 String groupName = evt.getParameter( PARAMETER, "GROUP_NAME"); 36 String groupLogin = evt.getParameter( PARAMETER, "GROUP_LOGIN"); 37 checkParameter(groupName, "Name"); 38 checkParameter(groupLogin, "Login"); 39 Profile theGroup = null; 40 if (groupId == null) 41 { 42 if (ACUtils.checkLoginExistance(groupLogin)) throw new TKUserException("An object with the given attributes already exists.", 44 UserCodes.DUPLICATE_OBJECT, 45 ErrorCodes.USER_SEVERITY, 46 true, 47 null); 48 theGroup = ProfileFactory.getInstance().createProfile(groupLogin, groupName); 49 } 50 else 51 { 52 theGroup = ProfileFactory.getInstance().getProfile(new Integer (groupId)); 53 54 if (theGroup != null) 55 { 56 if (ACUtils.checkLoginExistance(groupLogin, theGroup.getID())) 57 throw new TKUserException("An object with the given attributes already exists.", 58 UserCodes.DUPLICATE_OBJECT, 59 ErrorCodes.USER_SEVERITY, 60 true, 61 null); 62 theGroup.setName(groupName); 63 theGroup.setLogin(groupLogin); 64 65 ProfileFactory.getInstance().modifyProfile(theGroup); 66 } 67 } 68 69 TKHTMLTemplate t = evt.getPrepHTMLTemplate( "f_ac_group.tmpl" ); 70 HTMLUtils.fillFrameSet( t, HTMLUtils.LEFT_FRAME_WIDTH, "AC_GROUP_LIST", "EMPTY" ); 71 String editPage = evt.getParameter(PARAMETER, "EDIT_PAGE"); 72 t.set("EDIT_PAGE", (editPage == null ? "1" : editPage)); 73 WebManEvent.fillEventsIntoTemplate(evt.getRemoteUser(), t, ACCESS_CONTROL); 74 evt.finishTemplate( t ); 75 } catch (Throwable e) { 76 throw WebmanExceptionHandler.getException(e); 77 } 78 } 79 80 public boolean isHandler(TKEvent evt) 81 { 82 return evt.getName().equalsIgnoreCase( "AC_GROUP_UPDATE" ); 83 } 84 } 85 | Popular Tags |