Source Code Cross Referenced for DataSourcePrivilegesLoader.java in  » Web-Framework » JAT » com » jat » business » privileges » 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 » Web Framework » JAT » com.jat.business.privileges 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.jat.business.privileges;
002:
003:        import com.jat.business.JatUser;
004:        import com.jat.business.BusinessException;
005:        import com.jat.integration.DataSource;
006:        import com.jat.business.BusinessObjectFactory;
007:        import com.jat.business.BusinessObjectList;
008:        import com.jat.business.BusinessObjectPropertyList;
009:        import com.jat.core.config.Config;
010:        import com.jat.integration.*;
011:        import java.util.Vector;
012:        import com.jat.business.BusinessObjectProperties;
013:        import java.util.Enumeration;
014:        import com.jat.business.BusinessObject;
015:        import com.jat.business.MultiBusinessObjectProperties;
016:        import com.jat.core.log.LogManager;
017:
018:        /**
019:         * <p>Title: JAT</p>
020:         * <p>Description: </p>
021:         * <p>Copyright: Copyright (c) 2004 -2005 Stefano Fratini (stefano.fratini@gmail.com)</p>
022:         * <p>Distributed under the terms of the GNU Lesser General Public License, v2.1 or later</p> * @author stf
023:         * @version 1.0
024:         * @since 1.2
025:         */
026:
027:        public class DataSourcePrivilegesLoader extends BusinessObjectFactory
028:                implements  PrivilegesLoader {
029:
030:            public final static String SECTION = "data_source_privileges_loader";
031:            public final static String DATA_SOURCE = "data_source";
032:            public final static String OPERATION_LOAD_PROFILES = "load_profiles_operation";
033:            public final static String OPERATION_LOAD_PRIVILEGES = "load_privileges_operation";
034:            public final static String OPERATION_INSERT_PROFILE = "insert_profile_operation";
035:            public final static String OPERATION_INSERT_PRIVILEGES = "insert_privileges_operation";
036:            public final static String OPERATION_REMOVE_PRIVILEGES = "remove_privileges_operation";
037:            public final static String OPERATION_REMOVE_PROFILE = "remove_profile_operation";
038:
039:            public DataSourcePrivilegesLoader() throws BusinessException {
040:                try {
041:                    dataSource = Config.getCurrent().getValue(SECTION,
042:                            DATA_SOURCE);
043:                    loadPrivilegesOperation = Config.getCurrent().getValue(
044:                            SECTION, OPERATION_LOAD_PROFILES);
045:                    loadProfilesOperation = Config.getCurrent().getValue(
046:                            SECTION, OPERATION_LOAD_PROFILES);
047:                    insertProfileOperation = Config.getCurrent().getValue(
048:                            SECTION, OPERATION_INSERT_PROFILE);
049:                    insertPrivilegesOperation = Config.getCurrent().getValue(
050:                            SECTION, OPERATION_INSERT_PRIVILEGES);
051:                    removePrivilegesOperation = Config.getCurrent().getValue(
052:                            SECTION, OPERATION_REMOVE_PRIVILEGES);
053:                    removeProfileOperation = Config.getCurrent().getValue(
054:                            SECTION, OPERATION_REMOVE_PROFILE);
055:                } catch (Exception ex) {
056:                    throw new BusinessException(ex);
057:                }
058:            }
059:
060:            public String getDataSource() {
061:                return this .dataSource;
062:            }
063:
064:            public PrivilegeList getPrivileges(JatUser user)
065:                    throws BusinessException {
066:                try {
067:                    return (PrivilegeList) super .getBusinessObjectList(
068:                            dataSource, this .loadPrivilegesOperation, user
069:                                    .getProperties());
070:                } catch (IntegrationException ex) {
071:                    throw new BusinessException(ex);
072:                }
073:            }
074:
075:            public PrivilegeList getPrivileges(String profile)
076:                    throws BusinessException {
077:                BusinessObjectProperties bop = new BusinessObjectProperties();
078:                bop.put("PROFILE", profile);
079:                try {
080:                    return (PrivilegeList) super .getBusinessObjectList(
081:                            dataSource, this .loadPrivilegesOperation, bop);
082:                } catch (IntegrationException ex) {
083:                    throw new BusinessException(ex);
084:                }
085:
086:            }
087:
088:            public Vector profiles() throws BusinessException {
089:                try {
090:                    BusinessObjectList bol = super .getBusinessObjectList(
091:                            dataSource, this .loadProfilesOperation);
092:                    Vector ret = new Vector();
093:                    for (Enumeration e = bol.elements(); e.hasMoreElements();)
094:                        ret.addElement(((BusinessObject) e.nextElement())
095:                                .getField("PROFILE"));
096:                    return ret;
097:                } catch (IntegrationException ex) {
098:                    throw new BusinessException(ex);
099:                }
100:            }
101:
102:            public void persist() {
103:                // nothing to do
104:            }
105:
106:            public void remove(Profile profile) throws Exception {
107:                LogManager.sendDebug(this .getClass().getName()
108:                        + "::remove: start for profile: " + profile);
109:                this .removePrivileges(profile);
110:                BusinessObjectProperties bop = new BusinessObjectProperties();
111:                bop.put("PROFILE", profile.getName());
112:                DataSourceFactory.getFactory().getDataSource(this .dataSource)
113:                        .execute(this .removeProfileOperation, bop);
114:                LogManager.sendDebug(this .getClass().getName()
115:                        + "::remove: end");
116:            }
117:
118:            public void update(Profile profile) throws Exception {
119:                LogManager.sendDebug(this .getClass().getName()
120:                        + "::update: start for profile: " + profile);
121:                this .removePrivileges(profile);
122:                this .insertPrivileges(profile);
123:                LogManager.sendDebug(this .getClass().getName()
124:                        + "::update: end");
125:            }
126:
127:            public void insert(Profile profile) throws IntegrationException {
128:                LogManager.sendDebug(this .getClass().getName()
129:                        + "::insert: start for profile: " + profile);
130:                BusinessObjectProperties bop = new BusinessObjectProperties();
131:                bop.put("PROFILE", profile.getName());
132:                DataSourceFactory.getFactory().getDataSource(this .dataSource)
133:                        .execute(this .insertProfileOperation, bop);
134:                this .insertPrivileges(profile);
135:                LogManager.sendDebug(this .getClass().getName()
136:                        + "::insert: end");
137:            }
138:
139:            protected void insertPrivileges(Profile profile)
140:                    throws IntegrationException {
141:                MultiBusinessObjectProperties multi = new MultiBusinessObjectProperties();
142:                for (Enumeration e = profile.getPrivileges().elements(); e
143:                        .hasMoreElements();) {
144:                    Privilege priv = (Privilege) e.nextElement();
145:                    priv.putField("PROFILE", profile.getName());
146:                    multi.put(this .insertPrivilegesOperation, priv);
147:                }
148:                DataSourceFactory.getFactory().getDataSource(this .dataSource)
149:                        .execute(multi);
150:            }
151:
152:            protected void removePrivileges(Profile profile)
153:                    throws IntegrationException {
154:                BusinessObjectProperties bop = new BusinessObjectProperties();
155:                bop.put("PROFILE", profile.getName());
156:                DataSourceFactory.getFactory().getDataSource(this .dataSource)
157:                        .execute(this .removePrivilegesOperation, bop);
158:            }
159:
160:            protected BusinessObjectList getBusinessObjectList(
161:                    String dataSourceName, BusinessObjectPropertyList properties) {
162:                return new PrivilegeList(dataSourceName, properties);
163:            }
164:
165:            private String dataSource;
166:
167:            private String loadPrivilegesOperation;
168:            private String loadProfilesOperation;
169:            private String insertProfileOperation;
170:            private String insertPrivilegesOperation;
171:            private String removePrivilegesOperation;
172:            private String removeProfileOperation;
173:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.