KickJava   Java API By Example, From Geeks To Geeks.

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


1 package de.webman.acl.eventhandler;
2
3 import com.teamkonzept.web.*;
4 import com.teamkonzept.webman.*;
5 import com.teamkonzept.webman.db.TKWebmanDBManager;
6 import com.teamkonzept.webman.mainint.*;
7 import com.teamkonzept.webman.mainint.db.*;
8
9
10 import com.teamkonzept.webman.mainint.db.queries.*;
11 import com.teamkonzept.webman.mainint.events.*;
12 import com.teamkonzept.lib.*;
13 import com.teamkonzept.field.*;
14 import com.teamkonzept.field.db.*;
15 import com.teamkonzept.db.*;
16 import com.teamkonzept.publishing.markups.*;
17 import de.webman.acl.*;
18 import java.sql.*;
19 import java.io.*;
20
21 /**
22  * Displays all Rights for a Contentnode for a given User<br>
23  * TK_EV[AC_CE_RIGHTS]<br>
24  * TK_PAR[]<br>
25  * @author $Author: sebastian $
26  * @version $Revision: 1.5 $
27  */

28
29 public class ACCERightsEventHandler extends DefaultEventHandler implements ParameterTypes, FrameConstants, DatabaseDefaults
30 {
31     /** empty constructor */
32     private ACCERightsEventHandler()
33     {}
34     
35     /** static initialisation */
36     private static ACCERightsEventHandler instance = new ACCERightsEventHandler();
37     
38     public static ACCERightsEventHandler getInstance()
39     {
40         return instance;
41     }
42     
43     public void handleEvent(TKEvent evt) throws TKException
44     {
45         try
46         {
47             WebManEvent.checkEvent(evt.getRemoteUser(), evt.getName(), ContextConstants.ACCESS_CONTROL);
48
49             TKHTMLTemplate t = evt.getPrepHTMLTemplate( "ac_ce_rights.tmpl" );
50             
51             String JavaDoc nodeId = evt.getParameter( PARAMETER, "CONTENT_NODE_ID");
52             String JavaDoc uId = evt.getParameter( PARAMETER, "LOGIN_ID");
53
54             if (uId != null && uId.length() > 0 && nodeId != null && nodeId.length() > 0)
55             {
56                 Login l = LoginFactory.getInstance().getLogin(new Integer JavaDoc(uId));
57                 if (l != null)
58                 {
59                     t.set("LOGIN_NAME", l.getName());
60                     t.set((l.isProfile() ? "IS_GROUP" : "IS_USER"), "1");
61                     TKVector policies = new TKVector();
62                     ACConvenience.getNodePolicies(l, CONTENT_EDIT, new Integer JavaDoc(nodeId), policies, null);
63                     if (policies == null || policies.size() == 0) t.set("NO_NODE_POLICIES", "TRUE");
64                     t.setListIterator(new TKStandardPluginIterator("NODE_POLICIES", null, policies, true, t.getListIterator()));
65                     
66                     TKVector roleList = ACConvenience.makeRoleList( RoleFactory.getInstance().getRoles() );
67                     t.setListIterator(new TKStandardPluginIterator("ROLE_LIST", null, roleList, true, t.getListIterator()));
68                 }
69             }
70             
71             t.set( evt.getParams().getClass( PARAMETER ) );
72             TreeUtils.keepOpenNodes( evt, t );
73
74             t.set("CONTEXT_ID", CONTENT_EDIT.toString());
75             WebManEvent.fillEventsIntoTemplate(evt.getRemoteUser(), t, ACCESS_CONTROL);
76             evt.finishTemplate(t);
77         }
78         catch (Throwable JavaDoc e)
79         {
80             // TO DO : Analyze Exception !
81
throw WebmanExceptionHandler.getException(e);
82         }
83     }
84     
85     public boolean isHandler(TKEvent evt)
86     {
87         return evt.getName().equalsIgnoreCase("AC_CE_RIGHTS");
88     }
89 }
90
Popular Tags