Source Code Cross Referenced for Navigation.java in  » Content-Management-System » dspace » org » dspace » app » xmlui » aspect » administrative » 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 » dspace » org.dspace.app.xmlui.aspect.administrative 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Navigation.java
003:         *
004:         * Version: $Revision: 1.3 $
005:         *
006:         * Date: $Date: 2006/07/13 23:20:54 $
007:         *
008:         * Copyright (c) 2002, Hewlett-Packard Company and Massachusetts
009:         * Institute of Technology.  All rights reserved.
010:         *
011:         * Redistribution and use in source and binary forms, with or without
012:         * modification, are permitted provided that the following conditions are
013:         * met:
014:         *
015:         * - Redistributions of source code must retain the above copyright
016:         * notice, this list of conditions and the following disclaimer.
017:         *
018:         * - Redistributions in binary form must reproduce the above copyright
019:         * notice, this list of conditions and the following disclaimer in the
020:         * documentation and/or other materials provided with the distribution.
021:         *
022:         * - Neither the name of the Hewlett-Packard Company nor the name of the
023:         * Massachusetts Institute of Technology nor the names of their
024:         * contributors may be used to endorse or promote products derived from
025:         * this software without specific prior written permission.
026:         *
027:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
028:         * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
029:         * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
030:         * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
031:         * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
032:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
033:         * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
034:         * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
035:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
036:         * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
037:         * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
038:         * DAMAGE.
039:         */
040:        package org.dspace.app.xmlui.aspect.administrative;
041:
042:        import java.io.IOException;
043:        import java.io.Serializable;
044:        import java.sql.SQLException;
045:
046:        import org.apache.cocoon.caching.CacheableProcessingComponent;
047:        import org.apache.cocoon.environment.ObjectModelHelper;
048:        import org.apache.cocoon.environment.Request;
049:        import org.apache.cocoon.util.HashUtil;
050:        import org.apache.excalibur.source.SourceValidity;
051:        import org.apache.excalibur.source.impl.validity.NOPValidity;
052:        import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
053:        import org.dspace.app.xmlui.utils.DSpaceValidity;
054:        import org.dspace.app.xmlui.utils.HandleUtil;
055:        import org.dspace.app.xmlui.utils.UIException;
056:        import org.dspace.app.xmlui.wing.Message;
057:        import org.dspace.app.xmlui.wing.WingException;
058:        import org.dspace.app.xmlui.wing.element.List;
059:        import org.dspace.app.xmlui.wing.element.Options;
060:        import org.dspace.authorize.AuthorizeException;
061:        import org.dspace.authorize.AuthorizeManager;
062:        import org.dspace.content.Collection;
063:        import org.dspace.content.Community;
064:        import org.dspace.content.DSpaceObject;
065:        import org.dspace.content.Item;
066:        import org.dspace.core.Constants;
067:        import org.dspace.eperson.Group;
068:        import org.xml.sax.SAXException;
069:
070:        /**
071:         * 
072:         * Create the navigation options for everything in the administrative aspects. This includes 
073:         * Epeople, group, item, access control, and registry management.
074:         * 
075:         * @author Scott Phillips
076:         * @author Afonso Araujo Neto (internationalization)
077:         * @author Alexey Maslov
078:         */
079:        public class Navigation extends AbstractDSpaceTransformer implements 
080:                CacheableProcessingComponent {
081:            private static final Message T_context_head = message("xmlui.administrative.Navigation.context_head");
082:            private static final Message T_context_edit_item = message("xmlui.administrative.Navigation.context_edit_item");
083:            private static final Message T_context_edit_collection = message("xmlui.administrative.Navigation.context_edit_collection");
084:            private static final Message T_context_item_mapper = message("xmlui.administrative.Navigation.context_item_mapper");
085:            private static final Message T_context_edit_community = message("xmlui.administrative.Navigation.context_edit_community");
086:            private static final Message T_context_create_collection = message("xmlui.administrative.Navigation.context_create_collection");
087:            private static final Message T_context_create_subcommunity = message("xmlui.administrative.Navigation.context_create_subcommunity");
088:            private static final Message T_context_create_community = message("xmlui.administrative.Navigation.context_create_community");
089:
090:            private static final Message T_administrative_head = message("xmlui.administrative.Navigation.administrative_head");
091:            private static final Message T_administrative_access_control = message("xmlui.administrative.Navigation.administrative_access_control");
092:            private static final Message T_administrative_people = message("xmlui.administrative.Navigation.administrative_people");
093:            private static final Message T_administrative_groups = message("xmlui.administrative.Navigation.administrative_groups");
094:            private static final Message T_administrative_authorizations = message("xmlui.administrative.Navigation.administrative_authorizations");
095:            private static final Message T_administrative_registries = message("xmlui.administrative.Navigation.administrative_registries");
096:            private static final Message T_administrative_metadata = message("xmlui.administrative.Navigation.administrative_metadata");
097:            private static final Message T_administrative_format = message("xmlui.administrative.Navigation.administrative_format");
098:            private static final Message T_administrative_items = message("xmlui.administrative.Navigation.administrative_items");
099:            private static final Message T_administrative_withdrawn = message("xmlui.administrative.Navigation.administrative_withdrawn");
100:            private static final Message T_administrative_control_panel = message("xmlui.administrative.Navigation.administrative_control_panel");
101:
102:            /** Cached validity object */
103:            private SourceValidity validity;
104:
105:            /**
106:             * Generate the unique cache key.
107:             *
108:             * @return The generated key hashes the src
109:             */
110:            public Serializable getKey() {
111:                Request request = ObjectModelHelper.getRequest(objectModel);
112:
113:                // Special case, don't cache anything if the user is logging 
114:                // in. The problem occures because of timming, this cache key
115:                // is generated before we know whether the operation has 
116:                // succeded or failed. So we don't know whether to cache this 
117:                // under the user's specific cache or under the anonymous user.
118:                if (request.getParameter("login_email") != null
119:                        || request.getParameter("login_password") != null
120:                        || request.getParameter("login_realm") != null) {
121:                    return "0";
122:                }
123:
124:                String key;
125:                if (context.getCurrentUser() != null)
126:                    key = context.getCurrentUser().getEmail();
127:                else
128:                    key = "anonymous";
129:
130:                return HashUtil.hash(key);
131:            }
132:
133:            /**
134:             * Generate the validity object.
135:             *
136:             * @return The generated validity object or <code>null</code> if the
137:             *         component is currently not cacheable.
138:             */
139:            public SourceValidity getValidity() {
140:                if (this .validity == null) {
141:                    // Only use the DSpaceValidity object is someone is logged in.
142:                    if (context.getCurrentUser() != null) {
143:                        try {
144:                            DSpaceValidity validity = new DSpaceValidity();
145:
146:                            validity.add(eperson);
147:
148:                            Group[] groups = Group.allMemberGroups(context,
149:                                    eperson);
150:                            for (Group group : groups) {
151:                                validity.add(group);
152:                            }
153:
154:                            this .validity = validity.complete();
155:                        } catch (SQLException sqle) {
156:                            // Just ignore it and return invalid.
157:                        }
158:                    } else {
159:                        this .validity = NOPValidity.SHARED_INSTANCE;
160:                    }
161:                }
162:                return this .validity;
163:            }
164:
165:            public void addOptions(Options options) throws SAXException,
166:                    WingException, UIException, SQLException, IOException,
167:                    AuthorizeException {
168:                /* Create skeleton menu structure to ensure consistent order between aspects,
169:                 * even if they are never used 
170:                 */
171:                options.addList("browse");
172:                options.addList("account");
173:                List context = options.addList("context");
174:                List admin = options.addList("administrative");
175:
176:                // Context Administrative options
177:                DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
178:                if (dso instanceof  Item) {
179:
180:                    Item item = (Item) dso;
181:                    if (item.canEdit()) {
182:                        context.setHead(T_context_head);
183:                        context.addItem().addXref(
184:                                contextPath + "/admin/item?itemID="
185:                                        + item.getID(), T_context_edit_item);
186:                    }
187:                } else if (dso instanceof  Collection) {
188:                    Collection collection = (Collection) dso;
189:
190:                    // can they admin this collection?
191:                    if (AuthorizeManager.authorizeActionBoolean(this .context,
192:                            collection, Constants.COLLECTION_ADMIN)) {
193:                        context.setHead(T_context_head);
194:                        context
195:                                .addItemXref(contextPath
196:                                        + "/admin/collection?collectionID="
197:                                        + collection.getID(),
198:                                        T_context_edit_collection);
199:                        context.addItemXref(contextPath
200:                                + "/admin/mapper?collectionID="
201:                                + collection.getID(), T_context_item_mapper);
202:                    }
203:                } else if (dso instanceof  Community) {
204:                    Community community = (Community) dso;
205:
206:                    // can they admin this collection?
207:                    if (community.canEditBoolean()) {
208:                        context.setHead(T_context_head);
209:                        context.addItemXref(contextPath
210:                                + "/admin/community?communityID="
211:                                + community.getID(), T_context_edit_community);
212:                    }
213:
214:                    // can they add to this community?
215:                    if (AuthorizeManager.authorizeActionBoolean(this .context,
216:                            community, Constants.ADD)) {
217:                        context.setHead(T_context_head);
218:                        context.addItemXref(contextPath
219:                                + "/admin/collection?createNew&communityID="
220:                                + community.getID(),
221:                                T_context_create_collection);
222:                    }
223:
224:                    // Only administrators can create communities
225:                    if (AuthorizeManager.isAdmin(this .context)) {
226:                        context.setHead(T_context_head);
227:                        context.addItemXref(contextPath
228:                                + "/admin/community?createNew&communityID="
229:                                + community.getID(),
230:                                T_context_create_subcommunity);
231:                    }
232:                }
233:
234:                if ("community-list".equals(this .sitemapURI)) {
235:                    if (AuthorizeManager.isAdmin(this .context)) {
236:                        context.setHead(T_context_head);
237:                        context.addItemXref(contextPath
238:                                + "/admin/community?createNew",
239:                                T_context_create_community);
240:                    }
241:                }
242:
243:                // System Administrator options!
244:                if (AuthorizeManager.isAdmin(this .context)) {
245:                    admin.setHead(T_administrative_head);
246:
247:                    List epeople = admin.addList("epeople");
248:                    List registries = admin.addList("registries");
249:
250:                    epeople.setHead(T_administrative_access_control);
251:                    epeople.addItemXref(contextPath + "/admin/epeople",
252:                            T_administrative_people);
253:                    epeople.addItemXref(contextPath + "/admin/groups",
254:                            T_administrative_groups);
255:                    epeople.addItemXref(contextPath + "/admin/authorize",
256:                            T_administrative_authorizations);
257:
258:                    registries.setHead(T_administrative_registries);
259:                    registries.addItemXref(contextPath
260:                            + "/admin/metadata-registry",
261:                            T_administrative_metadata);
262:                    registries
263:                            .addItemXref(
264:                                    contextPath + "/admin/format-registry",
265:                                    T_administrative_format);
266:
267:                    admin.addItemXref(contextPath + "/admin/item",
268:                            T_administrative_items);
269:                    admin.addItemXref(contextPath + "/admin/withdrawn",
270:                            T_administrative_withdrawn);
271:                    admin.addItemXref(contextPath + "/admin/panel",
272:                            T_administrative_control_panel);
273:                }
274:            }
275:
276:            public int addContextualOptions(List context) throws SQLException,
277:                    WingException {
278:                // How many options were added.
279:                int options = 0;
280:
281:                DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
282:
283:                if (dso instanceof  Item) {
284:                    Item item = (Item) dso;
285:                    if (item.canEdit()) {
286:                        context.addItem().addXref(
287:                                contextPath + "/admin/item?itemID="
288:                                        + item.getID(), T_context_edit_item);
289:                        options++;
290:                    }
291:                } else if (dso instanceof  Collection) {
292:                    Collection collection = (Collection) dso;
293:
294:                    // can they admin this collection?
295:                    if (AuthorizeManager.authorizeActionBoolean(this .context,
296:                            collection, Constants.COLLECTION_ADMIN)) {
297:                        context
298:                                .addItemXref(contextPath
299:                                        + "/admin/collection?collectionID="
300:                                        + collection.getID(),
301:                                        T_context_edit_collection);
302:                        context.addItemXref(contextPath
303:                                + "/admin/mapper?collectionID="
304:                                + collection.getID(), T_context_item_mapper);
305:                        options++;
306:                    }
307:                } else if (dso instanceof  Community) {
308:                    Community community = (Community) dso;
309:
310:                    // can they admin this collection?
311:                    if (community.canEditBoolean()) {
312:                        context.addItemXref(contextPath
313:                                + "/admin/community?communityID="
314:                                + community.getID(), T_context_edit_community);
315:                        options++;
316:                    }
317:
318:                    // can they add to this community?
319:                    if (AuthorizeManager.authorizeActionBoolean(this .context,
320:                            community, Constants.ADD)) {
321:                        context.addItemXref(contextPath
322:                                + "/admin/collection?createNew&communityID="
323:                                + community.getID(),
324:                                T_context_create_collection);
325:                        context.addItemXref(contextPath
326:                                + "/admin/community?createNew&communityID="
327:                                + community.getID(),
328:                                T_context_create_subcommunity);
329:                        options++;
330:                    }
331:                }
332:
333:                if ("community-list".equals(this .sitemapURI)) {
334:                    if (AuthorizeManager.isAdmin(this .context)) {
335:                        context.addItemXref(contextPath
336:                                + "/admin/community?createNew",
337:                                T_context_create_community);
338:                        options++;
339:                    }
340:                }
341:
342:                return options;
343:            }
344:
345:            /**
346:             * recycle
347:             */
348:            public void recycle() {
349:                this.validity = null;
350:                super.recycle();
351:            }
352:
353:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.