01: package de.webman.acl.eventhandler;
02:
03: import com.teamkonzept.web.*;
04: import com.teamkonzept.webman.*;
05: import com.teamkonzept.webman.db.TKWebmanDBManager;
06: import com.teamkonzept.webman.mainint.*;
07: import com.teamkonzept.webman.mainint.db.*;
08:
09: import com.teamkonzept.webman.mainint.db.queries.*;
10: import com.teamkonzept.webman.mainint.events.*;
11: import com.teamkonzept.lib.*;
12: import com.teamkonzept.field.*;
13: import com.teamkonzept.field.db.*;
14: import com.teamkonzept.db.*;
15: import com.teamkonzept.publishing.markups.*;
16: import de.webman.acl.*;
17: import java.sql.*;
18: import java.io.*;
19:
20: /**
21: * Displays all Rights for a Contentnode for a given User<br>
22: * TK_EV[AC_CE_RIGHTS]<br>
23: * TK_PAR[]<br>
24: * @author $Author: sebastian $
25: * @version $Revision: 1.5 $
26: */
27:
28: public class ACCERightsEventHandler extends DefaultEventHandler
29: implements ParameterTypes, FrameConstants, DatabaseDefaults {
30: /** empty constructor */
31: private ACCERightsEventHandler() {
32: }
33:
34: /** static initialisation */
35: private static ACCERightsEventHandler instance = new ACCERightsEventHandler();
36:
37: public static ACCERightsEventHandler getInstance() {
38: return instance;
39: }
40:
41: public void handleEvent(TKEvent evt) throws TKException {
42: try {
43: WebManEvent.checkEvent(evt.getRemoteUser(), evt.getName(),
44: ContextConstants.ACCESS_CONTROL);
45:
46: TKHTMLTemplate t = evt
47: .getPrepHTMLTemplate("ac_ce_rights.tmpl");
48:
49: String nodeId = evt.getParameter(PARAMETER,
50: "CONTENT_NODE_ID");
51: String uId = evt.getParameter(PARAMETER, "LOGIN_ID");
52:
53: if (uId != null && uId.length() > 0 && nodeId != null
54: && nodeId.length() > 0) {
55: Login l = LoginFactory.getInstance().getLogin(
56: new Integer(uId));
57: if (l != null) {
58: t.set("LOGIN_NAME", l.getName());
59: t
60: .set((l.isProfile() ? "IS_GROUP"
61: : "IS_USER"), "1");
62: TKVector policies = new TKVector();
63: ACConvenience.getNodePolicies(l, CONTENT_EDIT,
64: new Integer(nodeId), policies, null);
65: if (policies == null || policies.size() == 0)
66: t.set("NO_NODE_POLICIES", "TRUE");
67: t.setListIterator(new TKStandardPluginIterator(
68: "NODE_POLICIES", null, policies, true, t
69: .getListIterator()));
70:
71: TKVector roleList = ACConvenience
72: .makeRoleList(RoleFactory.getInstance()
73: .getRoles());
74: t.setListIterator(new TKStandardPluginIterator(
75: "ROLE_LIST", null, roleList, true, t
76: .getListIterator()));
77: }
78: }
79:
80: t.set(evt.getParams().getClass(PARAMETER));
81: TreeUtils.keepOpenNodes(evt, t);
82:
83: t.set("CONTEXT_ID", CONTENT_EDIT.toString());
84: WebManEvent.fillEventsIntoTemplate(evt.getRemoteUser(), t,
85: ACCESS_CONTROL);
86: evt.finishTemplate(t);
87: } catch (Throwable e) {
88: // TO DO : Analyze Exception !
89: throw WebmanExceptionHandler.getException(e);
90: }
91: }
92:
93: public boolean isHandler(TKEvent evt) {
94: return evt.getName().equalsIgnoreCase("AC_CE_RIGHTS");
95: }
96: }
|