Source Code Cross Referenced for ScarabDBSecurityService.java in  » Issue-Tracking » scarab-0.21 » org » tigris » scarab » services » security » 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 » Issue Tracking » scarab 0.21 » org.tigris.scarab.services.security 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.tigris.scarab.services.security;
002:
003:        /* ================================================================
004:         * Copyright (c) 2000-2002 CollabNet.  All rights reserved.
005:         * 
006:         * Redistribution and use in source and binary forms, with or without
007:         * modification, are permitted provided that the following conditions are
008:         * met:
009:         * 
010:         * 1. Redistributions of source code must retain the above copyright
011:         * notice, this list of conditions and the following disclaimer.
012:         * 
013:         * 2. Redistributions in binary form must reproduce the above copyright
014:         * notice, this list of conditions and the following disclaimer in the
015:         * documentation and/or other materials provided with the distribution.
016:         * 
017:         * 3. The end-user documentation included with the redistribution, if
018:         * any, must include the following acknowlegement: "This product includes
019:         * software developed by Collab.Net <http://www.Collab.Net/>."
020:         * Alternately, this acknowlegement may appear in the software itself, if
021:         * and wherever such third-party acknowlegements normally appear.
022:         * 
023:         * 4. The hosted project names must not be used to endorse or promote
024:         * products derived from this software without prior written
025:         * permission. For written permission, please contact info@collab.net.
026:         * 
027:         * 5. Products derived from this software may not use the "Tigris" or 
028:         * "Scarab" names nor may "Tigris" or "Scarab" appear in their names without 
029:         * prior written permission of Collab.Net.
030:         * 
031:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
032:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
033:         * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
034:         * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
035:         * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
036:         * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
037:         * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
038:         * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
039:         * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
040:         * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
041:         * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
042:         *
043:         * ====================================================================
044:         * 
045:         * This software consists of voluntary contributions made by many
046:         * individuals on behalf of Collab.Net.
047:         */
048:
049:        import java.util.ArrayList;
050:        import java.util.List;
051:
052:        import org.apache.fulcrum.security.impl.db.DBSecurityService;
053:
054:        import org.apache.fulcrum.security.entity.Group;
055:
056:        import org.apache.fulcrum.security.util.GroupSet;
057:        import org.apache.fulcrum.security.util.DataBackendException;
058:        import org.apache.fulcrum.security.util.EntityExistsException;
059:        import org.apache.fulcrum.security.util.UnknownEntityException;
060:
061:        import org.apache.torque.om.Persistent;
062:        import org.apache.torque.util.Criteria;
063:
064:        import org.tigris.scarab.om.ScarabModulePeer;
065:        import org.tigris.scarab.om.Module;
066:        import org.tigris.scarab.util.Log;
067:
068:        /**
069:         * Implementation of turbine's SecurityService to account for the ScarabModule
070:         * being the Group implementation.
071:         *
072:         * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
073:         * @version $Id: ScarabDBSecurityService.java 9104 2004-05-10 21:04:51Z dabbous $
074:         */
075:        public class ScarabDBSecurityService extends DBSecurityService {
076:            /**
077:             * Retrieve a set of Groups that meet the specified Criteria.
078:             *
079:             * @param a <code>Criteria</code> of Group selection.
080:             * @return a set of Groups that meet the specified Criteria.
081:             */
082:            public GroupSet getGroups(Criteria criteria)
083:                    throws DataBackendException {
084:                List groups = null;
085:                try {
086:                    groups = ScarabModulePeer.doSelect(criteria);
087:                } catch (Exception e) {
088:                    throw new DataBackendException(
089:                            "getGroups(Criteria) failed", e); //EXCEPTION
090:                }
091:                if (groups == null) {
092:                    groups = new ArrayList(0);
093:                }
094:                return new GroupSet(groups);
095:            }
096:
097:            /**
098:             * Stores Group's attributes. The Groups is required to exist in the system.
099:             *
100:             * @param group The Group to be stored.
101:             * @throws DataBackendException if there was an error accessing the data backend.
102:             * @throws UnknownEntityException if the group does not exist.
103:             */
104:            public void saveGroup(Group group) throws DataBackendException,
105:                    UnknownEntityException {
106:                try {
107:                    if (!((Persistent) group).isNew()) {
108:                        group.save();
109:                    }
110:                } catch (Exception e) {
111:                    throw new DataBackendException("saveGroup(Group) failed", e); //EXCEPTION
112:                }
113:                throw new UnknownEntityException("Unknown group '" + group
114:                        + "'"); //EXCEPTION
115:            }
116:
117:            /**
118:             * Creates a new group with specified attributes.
119:             *
120:             * @param group the object describing the group to be created.
121:             * @return a new Group object that has id set up properly.
122:             * @throws DataBackendException if there was an error accessing the data backend.
123:             * @throws EntityExistsException if the group already exists.
124:             */
125:            public synchronized Group addGroup(Group group)
126:                    throws DataBackendException, EntityExistsException {
127:                try {
128:                    lockExclusive();
129:                    if (((Persistent) group).isNew()) {
130:                        group.save();
131:                        // add the group to system-wide cache
132:                        getAllGroups().add(group);
133:                        return group;
134:                    }
135:                } catch (Exception e) {
136:                    throw new DataBackendException("addGroup(Group) failed", e); //EXCEPTION
137:                } finally {
138:                    unlockExclusive();
139:                }
140:                // the only way we could get here without return/throw tirggered
141:                // is that the groupExists was true.
142:                throw new EntityExistsException("Group '" + group
143:                        + "' already exists"); //EXCEPTION
144:            }
145:
146:            /**
147:             * Removes a Group from the system.
148:             *
149:             * @param group the object describing group to be removed.
150:             * @throws DataBackendException if there was an error accessing the 
151:             * data backend.
152:             * @throws UnknownEntityException if the group does not exist.
153:             */
154:            public synchronized void removeGroup(Group group)
155:                    throws DataBackendException, UnknownEntityException {
156:                try {
157:                    lockExclusive();
158:                    if (!((Persistent) group).isNew()) {
159:                        ((Module) group).setDeleted(true);
160:                        group.save();
161:                        getAllGroups().remove(group);
162:                    }
163:                } catch (Exception e) {
164:                    Log.get().error("Failed to delete a Group");
165:                    Log.get().error(e);
166:                    throw new DataBackendException("removeGroup(Group) failed",
167:                            e); //EXCEPTION
168:                } finally {
169:                    unlockExclusive();
170:                }
171:                throw new UnknownEntityException("Unknown group '" + group
172:                        + "'"); //EXCEPTION
173:            }
174:
175:            /**
176:             * Renames an existing Group.
177:             *
178:             * @param group the object describing the group to be renamed.
179:             * @param name the new name for the group.
180:             * @throws DataBackendException if there was an error accessing the 
181:             * data backend.
182:             * @throws UnknownEntityException if the group does not exist.
183:             */
184:            public synchronized void renameGroup(Group group, String name)
185:                    throws DataBackendException, UnknownEntityException {
186:                throw new DataBackendException("rename is not supported"); //EXCEPTION
187:
188:                /* this stuff is cut-n-paste
189:                boolean groupExists = false;
190:                try
191:                {
192:                    lockExclusive();
193:                    groupExists = checkExists(group);
194:                    if(groupExists)
195:                    {
196:                        ((SecurityObject)group).setName(name);
197:                        Criteria criteria = GroupPeer.buildCriteria(group);
198:                        GroupPeer.doUpdate(criteria);
199:                        return;
200:                    }
201:                }
202:                catch(Exception e)
203:                {
204:                    throw new DataBackendException("renameGroup(Group,String)" ,e);
205:                }
206:                finally
207:                {
208:                    unlockExclusive();
209:                }
210:                throw new UnknownEntityException("Unknown group '" + group + "'");
211:                 */
212:            }
213:
214:            /**
215:             * Determines if the <code>Group</code> exists in the security system.
216:             *
217:             * @param group a <code>Group</code> value
218:             * @return true if the group exists in the system, false otherwise
219:             * @throws DataBackendException when more than one Group with 
220:             *         the same name exists.
221:             * @throws Exception a generic exception.
222:             */
223:            protected boolean checkExists(Group group)
224:                    throws DataBackendException, Exception {
225:                return ScarabModulePeer.checkExists(group);
226:            }
227:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.