Source Code Cross Referenced for SuperviseServlet.java in  » Content-Management-System » dspace » org » dspace » app » webui » servlet » admin » 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.webui.servlet.admin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * SuperviseServlet.java
003:         *
004:         * Version: $Revision: 1520 $
005:         *
006:         * Date: $Date: 2006-05-26 09:14:03 -0500 (Fri, 26 May 2006) $
007:         *
008:         * Copyright (c) 2002-2005, 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:
041:        package org.dspace.app.webui.servlet.admin;
042:
043:        import java.io.IOException;
044:        import java.lang.StringBuffer;
045:        import java.sql.SQLException;
046:        import java.util.ArrayList;
047:        import java.util.List;
048:        import javax.servlet.ServletException;
049:        import javax.servlet.http.HttpServletRequest;
050:        import javax.servlet.http.HttpServletResponse;
051:
052:        import org.apache.log4j.Logger;
053:
054:        import org.dspace.app.webui.util.JSPManager;
055:        import org.dspace.app.webui.util.UIUtil;
056:        import org.dspace.authorize.AuthorizeException;
057:        import org.dspace.content.SupervisedItem;
058:        import org.dspace.content.WorkspaceItem;
059:        import org.dspace.core.Context;
060:        import org.dspace.core.LogManager;
061:        import org.dspace.eperson.Group;
062:        import org.dspace.eperson.Supervisor;
063:        import org.dspace.storage.rdbms.TableRow;
064:        import org.dspace.storage.rdbms.TableRowIterator;
065:
066:        /**
067:         * Servlet to handle administration of the supervisory system
068:         *
069:         * @author Richard Jones
070:         * @version  $Revision: 1520 $
071:         */
072:        public class SuperviseServlet extends
073:                org.dspace.app.webui.servlet.DSpaceServlet {
074:
075:            /** log4j category */
076:            private static Logger log = Logger
077:                    .getLogger(SuperviseServlet.class);
078:
079:            protected void doDSGet(Context c, HttpServletRequest request,
080:                    HttpServletResponse response) throws ServletException,
081:                    IOException, SQLException, AuthorizeException {
082:                // pass all requests to the same place for simplicity
083:                doDSPost(c, request, response);
084:            }
085:
086:            protected void doDSPost(Context c, HttpServletRequest request,
087:                    HttpServletResponse response) throws ServletException,
088:                    IOException, SQLException, AuthorizeException {
089:
090:                String button = UIUtil.getSubmitButton(request, "submit_base");
091:
092:                //direct the request to the relevant set of methods
093:                if (button.equals("submit_add")) {
094:                    showLinkPage(c, request, response);
095:                } else if (button.equals("submit_view")) {
096:                    showListPage(c, request, response);
097:                } else if (button.equals("submit_base")) {
098:                    showMainPage(c, request, response);
099:                } else if (button.equals("submit_link")) {
100:                    // do form validation before anything else
101:                    if (validateAddForm(c, request, response)) {
102:                        addSupervisionOrder(c, request, response);
103:                        showMainPage(c, request, response);
104:                    }
105:                } else if (button.equals("submit_remove")) {
106:                    showConfirmRemovePage(c, request, response);
107:                } else if (button.equals("submit_doremove")) {
108:                    removeSupervisionOrder(c, request, response);
109:                    showMainPage(c, request, response);
110:                } else if (button.equals("submit_clean")) {
111:                    cleanSupervisorDatabase(c, request, response);
112:                    showMainPage(c, request, response);
113:                }
114:            }
115:
116:            //**********************************************************************
117:            //****************** Methods for Page display **************************
118:            //**********************************************************************
119:
120:            /**
121:             * Confirms the removal of a supervision order
122:             *
123:             * @param context the context of the request
124:             * @param request the servlet request
125:             * @param response the servlet response
126:             */
127:            private void showConfirmRemovePage(Context context,
128:                    HttpServletRequest request, HttpServletResponse response)
129:                    throws ServletException, IOException, SQLException,
130:                    AuthorizeException {
131:                // get the values from the request
132:                int wsItemID = UIUtil.getIntParameter(request, "siID");
133:                int groupID = UIUtil.getIntParameter(request, "gID");
134:
135:                // get the workspace item and the group from the request values
136:                WorkspaceItem wsItem = WorkspaceItem.find(context, wsItemID);
137:                Group group = Group.find(context, groupID);
138:
139:                // set the attributes for the JSP
140:                request.setAttribute("wsItem", wsItem);
141:                request.setAttribute("group", group);
142:
143:                JSPManager.showJSP(request, response,
144:                        "/dspace-admin/supervise-confirm-remove.jsp");
145:
146:            }
147:
148:            /**
149:             * Displays the form to link groups to workspace items
150:             *
151:             * @param context the context of the request
152:             * @param request the servlet request
153:             * @param response the servlet response
154:             */
155:            private void showLinkPage(Context context,
156:                    HttpServletRequest request, HttpServletResponse response)
157:                    throws ServletException, IOException, SQLException,
158:                    AuthorizeException {
159:                // get all the groups
160:                Group[] groups = Group.findAll(context, 1);
161:
162:                // get all the workspace items
163:                WorkspaceItem[] wsItems = WorkspaceItem.findAll(context);
164:
165:                // set the attributes for the JSP
166:                request.setAttribute("groups", groups);
167:                request.setAttribute("wsItems", wsItems);
168:
169:                JSPManager.showJSP(request, response,
170:                        "/dspace-admin/supervise-link.jsp");
171:
172:            }
173:
174:            /**
175:             * Displays the options you have in the supervisor admin area
176:             *
177:             * @param context the context of the request
178:             * @param request the servlet request
179:             * @param response the servlet response
180:             */
181:            private void showMainPage(Context context,
182:                    HttpServletRequest request, HttpServletResponse response)
183:                    throws ServletException, IOException, SQLException,
184:                    AuthorizeException {
185:                JSPManager.showJSP(request, response,
186:                        "/dspace-admin/supervise-main.jsp");
187:            }
188:
189:            /**
190:             * Displays the list of current settings for supervisors
191:             *
192:             * @param context the context of the request
193:             * @param request the servlet request
194:             * @param response the servlet response
195:             */
196:            private void showListPage(Context context,
197:                    HttpServletRequest request, HttpServletResponse response)
198:                    throws ServletException, IOException, SQLException,
199:                    AuthorizeException {
200:                // get all the supervised items
201:                SupervisedItem[] si = SupervisedItem.getAll(context);
202:
203:                // set the attributes for the JSP
204:                request.setAttribute("supervised", si);
205:
206:                JSPManager.showJSP(request, response,
207:                        "/dspace-admin/supervise-list.jsp");
208:            }
209:
210:            //**********************************************************************
211:            //*************** Methods for data manipulation ************************
212:            //**********************************************************************
213:
214:            /**
215:             * Adds supervisory settings to the database
216:             *
217:             * @param context the context of the request
218:             * @param request the servlet request
219:             * @param response the servlet response
220:             */
221:            void addSupervisionOrder(Context context,
222:                    HttpServletRequest request, HttpServletResponse response)
223:                    throws SQLException, AuthorizeException, ServletException,
224:                    IOException {
225:
226:                // get the values from the request
227:                int groupID = UIUtil.getIntParameter(request, "TargetGroup");
228:                int wsItemID = UIUtil.getIntParameter(request, "TargetWSItem");
229:                int policyType = UIUtil.getIntParameter(request, "PolicyType");
230:
231:                Supervisor.add(context, groupID, wsItemID, policyType);
232:
233:                log.info(LogManager.getHeader(context, "Supervision Order Set",
234:                        "workspace_item_id=" + wsItemID + ",eperson_group_id="
235:                                + groupID));
236:
237:                context.complete();
238:            }
239:
240:            /**
241:             * Maintains integrity of the supervisory database.  Should be more closely
242:             * integrated into the workspace code, perhaps
243:             *
244:             * @param context the context of the request
245:             * @param request the servlet request
246:             * @param response the servlet response
247:             */
248:            private void cleanSupervisorDatabase(Context context,
249:                    HttpServletRequest request, HttpServletResponse response)
250:                    throws ServletException, IOException, SQLException,
251:                    AuthorizeException {
252:                // ditch any supervision orders that are no longer relevant
253:                Supervisor.removeRedundant(context);
254:
255:                context.complete();
256:            }
257:
258:            /**
259:             * Remove the supervisory group and its policies from the database
260:             *
261:             * @param context the context of the request
262:             * @param request the servlet request
263:             * @param response the servlet response
264:             */
265:            void removeSupervisionOrder(Context context,
266:                    HttpServletRequest request, HttpServletResponse response)
267:                    throws SQLException, AuthorizeException, ServletException,
268:                    IOException {
269:
270:                // get the values from the request
271:                int wsItemID = UIUtil.getIntParameter(request, "siID");
272:                int groupID = UIUtil.getIntParameter(request, "gID");
273:
274:                Supervisor.remove(context, wsItemID, groupID);
275:
276:                log.info(LogManager.getHeader(context,
277:                        "Supervision Order Removed", "workspace_item_id="
278:                                + wsItemID + ",eperson_group_id=" + groupID));
279:
280:                context.complete();
281:            }
282:
283:            /**
284:             * validate the submitted form to ensure that there is not a supervision
285:             * order for this already.
286:             *
287:             * @param context the context of the request
288:             * @param request the servlet request
289:             * @param response the servlet response
290:             */
291:            private boolean validateAddForm(Context context,
292:                    HttpServletRequest request, HttpServletResponse response)
293:                    throws ServletException, IOException, SQLException,
294:                    AuthorizeException {
295:                int groupID = UIUtil.getIntParameter(request, "TargetGroup");
296:                int wsItemID = UIUtil.getIntParameter(request, "TargetWSItem");
297:
298:                boolean invalid = Supervisor
299:                        .isOrder(context, wsItemID, groupID);
300:
301:                if (invalid) {
302:                    JSPManager.showJSP(request, response,
303:                            "/dspace-admin/supervise-duplicate.jsp");
304:                    return false;
305:                } else {
306:                    return true;
307:                }
308:            }
309:
310:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.