Source Code Cross Referenced for AclImpl.java in  » Content-Management-System » daisy » org » outerj » daisy » repository » commonimpl » 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 » daisy » org.outerj.daisy.repository.commonimpl.acl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004 Outerthought bvba and Schaubroeck nv
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.outerj.daisy.repository.commonimpl.acl;
017:
018:        import org.outerj.daisy.repository.acl.*;
019:        import org.outerj.daisy.repository.acl.AclPermission;
020:        import org.outerj.daisy.repository.commonimpl.AuthenticatedUser;
021:        import org.outerj.daisy.repository.RepositoryException;
022:        import org.outerx.daisy.x10.*;
023:
024:        import java.util.*;
025:
026:        public final class AclImpl implements  Acl {
027:            private List<AclObjectImpl> objects = new ArrayList<AclObjectImpl>();
028:            private boolean readOnly = false;
029:            private AclStrategy aclStrategy;
030:            private Date lastModified;
031:            private long lastModifier = -1;
032:            private long id;
033:            private AuthenticatedUser currentModifier;
034:            private long updateCount = 0;
035:            private IntimateAccess intimateAccess = new IntimateAccess();
036:            protected static final String READ_ONLY_MESSAGE = "This ACL cannot be modified.";
037:
038:            public AclImpl(AclStrategy aclStrategy, Date lastModified,
039:                    long lastModifier, long id,
040:                    AuthenticatedUser currentModifier, long updateCount) {
041:                this .aclStrategy = aclStrategy;
042:                this .lastModified = lastModified;
043:                this .lastModifier = lastModifier;
044:                this .id = id;
045:                this .currentModifier = currentModifier;
046:                this .updateCount = updateCount;
047:            }
048:
049:            public IntimateAccess getIntimateAccess(AclStrategy aclStrategy) {
050:                if (aclStrategy == this .aclStrategy)
051:                    return intimateAccess;
052:                else
053:                    return null;
054:            }
055:
056:            public AclObject createNewObject(String objectExpression) {
057:                if (readOnly)
058:                    throw new RuntimeException(READ_ONLY_MESSAGE);
059:
060:                return new AclObjectImpl(this , aclStrategy, objectExpression);
061:            }
062:
063:            public boolean isReadOnly() {
064:                return readOnly;
065:            }
066:
067:            public void makeReadOnly() {
068:                this .readOnly = true;
069:            }
070:
071:            public AclObject get(int index) {
072:                return objects.get(index);
073:            }
074:
075:            public void remove(int index) {
076:                if (readOnly)
077:                    throw new RuntimeException(READ_ONLY_MESSAGE);
078:
079:                objects.remove(index).setIsAdded(false);
080:            }
081:
082:            public void add(AclObject aclObject) {
083:                preAddChecks(aclObject);
084:                AclObjectImpl aclObjectImpl = (AclObjectImpl) aclObject;
085:                aclObjectImpl.setIsAdded(true);
086:                objects.add(aclObjectImpl);
087:            }
088:
089:            public void add(int index, AclObject aclObject) {
090:                preAddChecks(aclObject);
091:                AclObjectImpl aclObjectImpl = (AclObjectImpl) aclObject;
092:                aclObjectImpl.setIsAdded(true);
093:                objects.add(index, aclObjectImpl);
094:            }
095:
096:            private void preAddChecks(AclObject aclObject) {
097:                if (readOnly)
098:                    throw new RuntimeException(READ_ONLY_MESSAGE);
099:
100:                if (aclObject == null)
101:                    throw new NullPointerException(
102:                            "null AclObject not allowed.");
103:
104:                if (!(aclObject instanceof  AclObjectImpl))
105:                    throw new RuntimeException(
106:                            "Incorrect AclObject implementation provided, only the ones obtained using createNewObject() on this AclObject may be used.");
107:
108:                AclObjectImpl aclObjectImpl = (AclObjectImpl) aclObject;
109:
110:                if (aclObjectImpl.getOwner() != this )
111:                    throw new RuntimeException(
112:                            "The specified AclObject belongs to a different Acl, it cannot be added to this Acl.");
113:
114:                if (aclObjectImpl.isAdded())
115:                    throw new RuntimeException(
116:                            "The specified AclObject is already added to the ACL.");
117:            }
118:
119:            public void clear() {
120:                if (readOnly)
121:                    throw new RuntimeException(READ_ONLY_MESSAGE);
122:
123:                for (AclObjectImpl object : objects) {
124:                    object.setIsAdded(false);
125:                }
126:
127:                objects.clear();
128:            }
129:
130:            public int size() {
131:                return objects.size();
132:            }
133:
134:            public Date getLastModified() {
135:                if (lastModified != null)
136:                    return (Date) lastModified.clone();
137:                else
138:                    return null;
139:            }
140:
141:            public long getLastModifier() {
142:                return lastModifier;
143:            }
144:
145:            public void save() throws RepositoryException {
146:                aclStrategy.storeAcl(this );
147:            }
148:
149:            public AclDocument getXml() {
150:                AclDocument aclDocument = AclDocument.Factory.newInstance();
151:                AclDocument.Acl aclXml = aclDocument.addNewAcl();
152:
153:                aclXml.setId(id);
154:                GregorianCalendar lastModifiedCalendar = new GregorianCalendar();
155:                lastModifiedCalendar.setTime(lastModified);
156:                aclXml.setLastModified(lastModifiedCalendar);
157:                aclXml.setLastModifier(lastModifier);
158:                aclXml.setUpdateCount(updateCount);
159:
160:                AclObjectDocument.AclObject[] aclObjectsXml = new AclObjectDocument.AclObject[objects
161:                        .size()];
162:                for (int i = 0; i < aclObjectsXml.length; i++) {
163:                    AclObject aclObject = objects.get(i);
164:                    aclObjectsXml[i] = aclObject.getXml().getAclObject();
165:                }
166:
167:                aclXml.setAclObjectArray(aclObjectsXml);
168:
169:                return aclDocument;
170:            }
171:
172:            public void setFromXml(AclDocument.Acl aclXml) {
173:                if (readOnly)
174:                    throw new RuntimeException(READ_ONLY_MESSAGE);
175:
176:                clear();
177:
178:                for (AclObjectDocument.AclObject objectXml : aclXml
179:                        .getAclObjectList()) {
180:                    AclObject object = createNewObject(objectXml
181:                            .getExpression());
182:
183:                    for (AclEntryDocument.AclEntry entryXml : objectXml
184:                            .getAclEntryList()) {
185:                        AclSubjectType subjectType = AclSubjectType
186:                                .fromString(entryXml.getSubjectType()
187:                                        .toString());
188:                        AclEntry entry = object.createNewEntry(subjectType,
189:                                entryXml.getSubjectValue());
190:
191:                        for (PermissionsDocument.Permissions.Permission permissionXml : entryXml
192:                                .getPermissions().getPermissionList()) {
193:                            AclPermission permission = AclPermission
194:                                    .fromString(permissionXml.getType()
195:                                            .toString());
196:                            AclActionType actionType = AclActionType
197:                                    .fromString(permissionXml.getAction()
198:                                            .toString());
199:
200:                            AccessDetails details = null;
201:                            if (permissionXml.isSetAccessDetails()) {
202:                                details = new AccessDetailsImpl(this );
203:                                details.setFromXml(permissionXml
204:                                        .getAccessDetails());
205:                            }
206:                            entry.set(permission, actionType, details);
207:                        }
208:
209:                        object.add(entry);
210:                    }
211:
212:                    add(object);
213:                }
214:            }
215:
216:            public long getUpdateCount() {
217:                return updateCount;
218:            }
219:
220:            public class IntimateAccess {
221:                private IntimateAccess() {
222:                }
223:
224:                public long getId() {
225:                    return id;
226:                }
227:
228:                public void setId(long id) {
229:                    if (readOnly)
230:                        throw new RuntimeException(READ_ONLY_MESSAGE);
231:
232:                    AclImpl.this .id = id;
233:                }
234:
235:                public AuthenticatedUser getCurrentModifier() {
236:                    return currentModifier;
237:                }
238:
239:                public void setLastModified(Date lastModified) {
240:                    if (readOnly)
241:                        throw new RuntimeException(READ_ONLY_MESSAGE);
242:
243:                    AclImpl.this .lastModified = lastModified;
244:                }
245:
246:                public void setLastModifier(long lastModifier) {
247:                    if (readOnly)
248:                        throw new RuntimeException(READ_ONLY_MESSAGE);
249:
250:                    AclImpl.this .lastModifier = lastModifier;
251:                }
252:
253:                public void setUpdateCount(long updateCount) {
254:                    if (readOnly)
255:                        throw new RuntimeException(READ_ONLY_MESSAGE);
256:
257:                    AclImpl.this .updateCount = updateCount;
258:                }
259:
260:                public List<AclObjectImpl> getObjects() {
261:                    return objects;
262:                }
263:            }
264:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.