Source Code Cross Referenced for StartEventHandler.java in  » Content-Management-System » webman » com » teamkonzept » webman » mainint » events » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » webman » com.teamkonzept.webman.mainint.events 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.teamkonzept.webman.mainint.events;
002:
003:        import java.util.*;
004:
005:        import com.teamkonzept.lib.*;
006:        import com.teamkonzept.web.*;
007:        import de.webman.acl.*;
008:        import com.teamkonzept.webman.mainint.WebmanExceptionHandler;
009:        import org.apache.log4j.Category;
010:
011:        /**
012:         * Displays the WebMan startmenu with only those
013:         * options which the user has a right to.
014:         * @author  $Author: mischa $
015:         * @version $Revision: 1.11 $
016:         */
017:        public class StartEventHandler extends DefaultEventHandler {
018:            /** Logging Context */
019:            private static Category cat = Category
020:                    .getInstance(StartEventHandler.class);
021:
022:            // Constants for handling of unknown logins
023:            private static String AUTO_USER = "AUTO_USER";
024:            private static String ACCEPT_UNKNOWN_LOGIN = "ACCEPT_UNKNOWN_LOGIN";
025:            private static String AUTO_DEFAULT_GROUP = "AUTO_DEFAULT_GROUP";
026:
027:            private StartEventHandler() {
028:            }
029:
030:            private static StartEventHandler instance = new StartEventHandler();
031:
032:            public static StartEventHandler getInstance() {
033:                return instance;
034:            }
035:
036:            public void handleEvent(TKEvent evt) throws TKException {
037:                Login login = null;
038:                String userLogin = evt.getRemoteUser();
039:                cat.debug(userLogin + " has entered ....");
040:
041:                try {
042:                    try {
043:                        login = LoginFactory.getInstance().getLogin(userLogin);
044:                    } catch (TKUserException userException) {
045:                        cat.debug(userLogin + " not existing ....");
046:                        // check in properties, if new user should be added
047:                        boolean acceptUser = false;
048:                        Integer defaultGroup = new Integer(1);
049:
050:                        try {
051:                            PropertyManager pman = PropertyManager
052:                                    .getPropertyManager(AUTO_USER);
053:                            acceptUser = pman.getValue(ACCEPT_UNKNOWN_LOGIN)
054:                                    .toUpperCase().equals("Y")
055:                                    || pman.getValue(ACCEPT_UNKNOWN_LOGIN)
056:                                            .toUpperCase().equals("J");
057:                            defaultGroup = new Integer(pman
058:                                    .getValue(AUTO_DEFAULT_GROUP));
059:                        } catch (Throwable e) {
060:                            // something happened while loading  properties
061:                            // das kann aber passieren und ist nicht schlimm -oder ? alex
062:                            cat.debug("Failed loading properties: " + e);
063:                        }
064:
065:                        if (acceptUser) {
066:                            // create new user
067:                            cat.debug("creating new User: " + userLogin
068:                                    + " ....");
069:                            login = UserFactory.getInstance().createUser(
070:                                    userLogin, userLogin);
071:
072:                            // add user to default group
073:                            Profile profile = ProfileFactory.getInstance()
074:                                    .getProfile(defaultGroup);
075:
076:                            cat.debug("adding " + userLogin
077:                                    + "to default group " + profile.getName()
078:                                    + " ....");
079:                            profile.addChild((User) login);
080:                            ProfileFactory.getInstance().modifyProfile(profile);
081:                        } else {
082:                            throw userException;
083:                        }
084:                    }
085:
086:                    TKHTMLTemplate t = evt
087:                            .getPrepHTMLTemplate("startmenu.tmpl");
088:                    TKVector ids = ContextFactory.getInstance().getObjectIDs();
089:                    Integer id = null;
090:                    TKVector events = null;
091:
092:                    // Resolve all global access rights.
093:                    for (int i = 0; i < ids.size(); i++) {
094:                        id = (Integer) ids.elementAt(i);
095:                        events = login.getAllowedEvents(id);
096:
097:                        if (events != null) {
098:                            for (int e = 0; e < events.size(); e++) {
099:                                t.set(((Event) events.elementAt(e)).getName(),
100:                                        "1");
101:                            }
102:                        }
103:                    }
104:
105:                    // Additionally resolve access right for the root of the content tree.
106:                    events = login.getAllowedEvents(CONTENT_EDIT,
107:                            Policy.CONTENT_TREE_ID, new Integer(1));
108:
109:                    if (events != null) {
110:                        for (int e = 0; e < events.size(); e++) {
111:                            t.set(((Event) events.elementAt(e)).getName(), "1");
112:                        }
113:                    }
114:
115:                    // Additionally resolve access right for the root of the site tree.
116:                    events = login.getAllowedEvents(SITE_TREE,
117:                            Policy.SITE_TREE_ID, new Integer(1));
118:
119:                    if (events != null) {
120:                        for (int e = 0; e < events.size(); e++) {
121:                            t.set(((Event) events.elementAt(e)).getName(), "1");
122:                        }
123:                    }
124:
125:                    // Set login name and finish template.
126:                    t.set("LOGIN", login.getName());
127:                    evt.finishTemplate(t);
128:                } catch (Throwable t) {
129:                    throw WebmanExceptionHandler.getException(t);
130:                }
131:            }
132:
133:            public boolean isHandler(TKEvent evt) {
134:                return evt.getName().equalsIgnoreCase("START");
135:            }
136:
137:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.