KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > acl > eventhandler > ACGroupEditEventHandler


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 /**
13 Displays a form for changing the definition of a group
14  * @author $Author: sebastian $
15  * @version $Revision: 1.4 $
16  */

17 public class ACGroupEditEventHandler extends DefaultEventHandler implements ParameterTypes, DatabaseDefaults, FrameConstants
18 {
19     /** empty constructor */
20     private ACGroupEditEventHandler() {}
21
22     /** static initialisation */
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 JavaDoc editPage = evt.getParameter( PARAMETER, "EDIT_PAGE");
38             String JavaDoc groupId = evt.getParameter( PARAMETER, "GROUP_ID" );
39             if (groupId != null)
40             {
41                 Profile theGroup = ProfileFactory.getInstance().getProfile(new Integer JavaDoc(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                     // add list of my users
48
TKVector userVector = ACConvenience.makeUserList(UserFactory.getInstance().getUsers(), theGroup);
49                     t.setListIterator(new TKStandardPluginIterator("AC_USER_LIST", null, userVector, true, t.getListIterator()));
50
51                     // add list of profiles
52
TKVector profileVector = ACConvenience.makeGroupList(ProfileFactory.getInstance().getProfiles(), theGroup);
53                     t.setListIterator(new TKStandardPluginIterator("AC_GROUP_LIST", null, profileVector, true, t.getListIterator()));
54                     
55                     // add list of Contexts
56
TKVector contextVector = ACConvenience.makeContextList( ContextFactory.getInstance().
57                                                 getContexts());
58                     t.setListIterator(new TKStandardPluginIterator("AC_CONTEXT_LIST", null, contextVector,
59                                                true, t.getListIterator()));
60                     
61                     // add list of Roles
62
TKVector roleVector = ACConvenience.makeRoleList( RoleFactory.getInstance().getRoles() );
63                     t.setListIterator(new TKStandardPluginIterator("AC_ROLE_LIST", null, roleVector,
64                                                true, t.getListIterator()));
65                     // add list of global rights
66
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 JavaDoc 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