Source Code Cross Referenced for PolicyFactory.java in  » Content-Management-System » webman » de » webman » acl » 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 » de.webman.acl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package de.webman.acl;
002:
003:        import com.teamkonzept.lib.ConfigurationManager;
004:        import com.teamkonzept.lib.TKException;
005:        import com.teamkonzept.lib.TKVector;
006:        import de.webman.acl.db.*;
007:        import de.webman.acl.resolver.ResolverFactory;
008:        import com.teamkonzept.webman.mainint.WebmanExceptionHandler;
009:
010:        /**
011:         * Factory for policy objects.
012:         *
013:         * @version 1.0
014:         * @since 1.0
015:         * @author © 2001 Webman AG
016:         */
017:        public class PolicyFactory extends ObjectFactoryBase implements 
018:                ObjectFactory {
019:
020:            // $Header: /cvsroot/webman-cms/source/webman/de/webman/acl/PolicyFactory.java,v 1.1 2001/08/20 08:25:07 mischa Exp $
021:
022:            // Constants
023:
024:            /**
025:             * Singleton instance.
026:             */
027:            private static PolicyFactory SINGLETON = null;
028:
029:            // Constructors
030:
031:            /**
032:             * Inhibits instantiation from outside.
033:             */
034:            private PolicyFactory() {
035:                super ();
036:            }
037:
038:            // Instance
039:
040:            /**
041:             * Returns the singleton instance of the factory.
042:             *
043:             * @return the singleton instance of the factory.
044:             * @exception com.teamkonzept.lib.TKException if an error occured during initialization.
045:             */
046:            public static synchronized final PolicyFactory getInstance()
047:                    throws TKException {
048:                if (SINGLETON == null) {
049:                    SINGLETON = new PolicyFactory();
050:                    SINGLETON.configurationChanged();
051:                    ConfigurationManager.getInstance()
052:                            .registerConfigurationListener(SINGLETON,
053:                                    PROPERTY_GROUP_NAME);
054:                }
055:
056:                return SINGLETON;
057:            }
058:
059:            // Method implementations
060:
061:            /**
062:             * Returns the policy database interface.
063:             *
064:             * @return the policy database interface.
065:             */
066:            public final ObjectDBInterface getDBInterface() {
067:                return PolicyDBInterface.getInstance();
068:            }
069:
070:            /**
071:             * Returns a policy data wrapper.
072:             *
073:             * @param id the ID of the policy.
074:             * @return a policy data wrapper.
075:             */
076:            public final ObjectDBData getDBData(Integer id) {
077:                return new PolicyDBData(id, null, null, null, null, null, null);
078:            }
079:
080:            /**
081:             * Returns a policy data wrapper.
082:             *
083:             * @param object the policy.
084:             * @return a policy data wrapper.
085:             */
086:            public final ObjectDBData getDBData(WMObject object) {
087:                return new PolicyDBData((Policy) object);
088:            }
089:
090:            /**
091:             * Builds a concrete policy object.
092:             *
093:             * @param data the initial policy data.
094:             * @return a concrete policy object.
095:             */
096:            public final WMObject buildObject(ObjectDBData data) {
097:                return new Policy((PolicyDBData) data);
098:            }
099:
100:            // Convenience methods
101:
102:            /**
103:             * Retrieves the specified policy.
104:             *
105:             * @param id the ID of the policy.
106:             * @return the specified policy.
107:             * @exception com.teamkonzept.lib.TKException if an error occured during policy retrieval.
108:             */
109:            public final Policy getPolicy(Integer id) throws TKException {
110:                return (Policy) getObject(id);
111:            }
112:
113:            /**
114:             * Retrieves all known policies.
115:             *
116:             * @return all known policies.
117:             * @exception com.teamkonzept.lib.TKException if an error occured during policy retrieval.
118:             */
119:            public final TKVector getPolicies() throws TKException {
120:                return getObjects();
121:            }
122:
123:            /**
124:             * Retrieves all policy IDs referenced by the specified login.
125:             *
126:             * @param login the ID of the login (<I>required</I>).
127:             * @param context the ID of the context (<I>optional</I>).
128:             * @param type the object type (<I>optional</I>).
129:             * @param reference the object reference (<I>optional</I>).
130:             * @return all policy IDs referenced by the specified login.
131:             * @exception com.teamkonzept.lib.TKException if an error occured during policy retrieval.
132:             */
133:            public final TKVector getPolicyProxies(Integer login,
134:                    Integer context, Integer type, Integer reference)
135:                    throws TKException {
136:                TKVector proxies = null;
137:
138:                try {
139:                    // Create appropriate data.
140:                    PolicyDBData data = new PolicyDBData(null, login, null,
141:                            context, type, reference, null);
142:                    // Choose appropriate query.
143:                    Class choice = PolicyDBInterface.WM_POLICY_SELECT_BY_USER;
144:
145:                    if (context != null) {
146:                        choice = PolicyDBInterface.WM_POLICY_SELECT_BY_USER_CONTEXT;
147:
148:                        if (type != null) {
149:                            if (Policy.CONTENT_TREE_ID.equals(type)) {
150:                                choice = PolicyDBInterface.WM_POLICY_SELECT_BY_CONTENT_TREE;
151:                            } else if (Policy.SITE_TREE_ID.equals(type)) {
152:                                choice = PolicyDBInterface.WM_POLICY_SELECT_BY_SITE_TREE;
153:                            } else {
154:                                choice = PolicyDBInterface.WM_POLICY_SELECT_BY_USER_CONTEXT_TYPE;
155:
156:                                if (reference != null) {
157:                                    choice = PolicyDBInterface.WM_POLICY_SELECT_BY_USER_CONTEXT_TYPE_REFERENCE;
158:                                }
159:                            }
160:                        }
161:                    }
162:
163:                    data.setQuery(choice);
164:                    data.setPrototype(new ObjectCollectionDBData(null, null,
165:                            PolicyDBInterface.PRIMARY_KEY_NAME, null));
166:
167:                    // Database lookup.
168:                    proxies = getObjectIDs(data);
169:                } catch (Exception x) {
170:                    throw WebmanExceptionHandler.getException(x);
171:                }
172:
173:                return proxies;
174:            }
175:
176:            /**
177:             * Retrieves all policy IDs referenced by the specified event.
178:             *
179:             * @param event the ID of the event (<I>required</I>).
180:             * @param login the ID of the login (<I>required</I>).
181:             * @param context the ID of the context (<I>required</I>).
182:             * @param type the object type (<I>optional</I>).
183:             * @param reference the object reference (<I>optional</I>).
184:             * @param access the access mode of the policy.
185:             * @return all policy IDs referenced by the specified event.
186:             * @exception com.teamkonzept.lib.TKException if an error occured during policy retrieval.
187:             */
188:            public final TKVector getPolicyProxies(Integer event,
189:                    Integer login, Integer context, Integer type,
190:                    Integer reference, boolean access) throws TKException {
191:                TKVector proxies = null;
192:
193:                try {
194:                    // Create appropriate data.
195:                    PolicyDBData data = new PolicyDBData(null, login, null,
196:                            context, type, reference,
197:                            access ? PolicyDBInterface.MODE_ALLOW
198:                                    : PolicyDBInterface.MODE_DENY);
199:                    // Choose appropriate query.
200:                    Class choice = PolicyDBInterface.WM_POLICY_SELECT_BY_ATOMIC_EVENT;
201:
202:                    if (Policy.CONTENT_TREE_ID.equals(type)) {
203:                        choice = PolicyDBInterface.WM_POLICY_SELECT_BY_CONTENT_TREE_EVENT;
204:                    } else if (Policy.SITE_TREE_ID.equals(type)) {
205:                        choice = PolicyDBInterface.WM_POLICY_SELECT_BY_SITE_TREE_EVENT;
206:                    }
207:
208:                    data.setQuery(choice);
209:                    data.setPrototype(new ObjectCollectionDBData(
210:                            EventDBInterface.PRIMARY_KEY_NAME, event,
211:                            PolicyDBInterface.PRIMARY_KEY_NAME, null));
212:
213:                    // Database lookup.
214:                    proxies = getObjectIDs(data);
215:                } catch (Exception x) {
216:                    throw WebmanExceptionHandler.getException(x);
217:                }
218:
219:                return proxies;
220:            }
221:
222:            /**
223:             * Creates the specified policy.
224:             *
225:             * @param login the login of the policy.
226:             * @param role the role of the policy.
227:             * @param context the context of the policy.
228:             * @param type the object type of the policy.
229:             * @param reference the object reference of the policy.
230:             * @param access the access mode of the policy.
231:             * @return the specified policy.
232:             * @exception com.teamkonzept.lib.TKException if a policy with the specified
233:             * attributes already exists or an error occured during policy creation.
234:             */
235:            public final Policy createPolicy(Login login, Role role,
236:                    Context context, Integer type, Integer reference,
237:                    boolean access) throws TKException {
238:                return (Policy) createObject(new PolicyDBData(null, login
239:                        .getID(), role.getID(), context.getID(), type,
240:                        reference, access ? PolicyDBInterface.MODE_ALLOW
241:                                : PolicyDBInterface.MODE_DENY));
242:            }
243:
244:            /**
245:             * Modifies the given policy.
246:             *
247:             * @param policy the policy to be modified.
248:             * @exception com.teamkonzept.lib.TKException if an error occured during policy modification.
249:             */
250:            public final void modifyPolicy(Policy policy) throws TKException {
251:                if (policy.isModifiedAssociations()) {
252:                    ResolverFactory.getInstance().removeResolver(
253:                            policy.getLogin());
254:                }
255:
256:                modifyObject(policy);
257:            }
258:
259:            /**
260:             * Deletes the given policy.
261:             *
262:             * @param policy the policy to be deleted.
263:             * @exception com.teamkonzept.lib.TKException if an error occured during policy deletion.
264:             */
265:            public final void deletePolicy(Policy policy) throws TKException {
266:                ResolverFactory.getInstance().removeResolver(policy.getLogin());
267:
268:                deleteObject(policy);
269:            }
270:
271:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.