1 40 41 package org.dspace.app.webui.servlet; 42 43 import java.io.IOException ; 44 import java.sql.SQLException ; 45 import java.util.Date ; 46 import javax.servlet.ServletException ; 47 import javax.servlet.http.HttpServletRequest ; 48 import javax.servlet.http.HttpServletResponse ; 49 50 import org.apache.log4j.Logger; 51 52 import org.dspace.app.webui.util.JSPManager; 53 import org.dspace.app.webui.util.UIUtil; 54 import org.dspace.authorize.AuthorizeException; 55 import org.dspace.authorize.AuthorizeManager; 56 import org.dspace.content.Item; 57 import org.dspace.content.WorkspaceItem; 58 import org.dspace.core.Constants; 59 import org.dspace.core.Context; 60 import org.dspace.core.LogManager; 61 import org.dspace.storage.rdbms.TableRow; 62 63 69 public class WorkspaceServlet extends DSpaceServlet 70 { 71 72 73 private static Logger log = Logger.getLogger(WorkspaceServlet.class); 74 75 protected void doDSGet(Context c, 76 HttpServletRequest request, HttpServletResponse response) 77 throws ServletException , IOException , SQLException , AuthorizeException 78 { 79 doDSPost(c, request, response); 81 } 82 83 protected void doDSPost(Context c, 84 HttpServletRequest request, HttpServletResponse response) 85 throws ServletException , IOException , SQLException , AuthorizeException 86 { 87 88 String button = UIUtil.getSubmitButton(request, "submit_error"); 89 90 if (button.equals("submit_open")) 92 { 93 showMainPage(c, request, response); 94 } 95 else if (button.equals("submit_cancel")) 96 { 97 goToMyDSpace(c, request, response); 98 } 99 else if (button.equals("submit_error")) 100 { 101 showErrorPage(c, request, response); 102 } 103 } 104 105 106 113 private void showErrorPage(Context context, 114 HttpServletRequest request, HttpServletResponse response) 115 throws ServletException , IOException , SQLException , AuthorizeException 116 { 117 int wsItemID = UIUtil.getIntParameter(request, "workspace_id"); 118 119 log.error(LogManager.getHeader(context, 120 "Workspace Item View Failed", 121 "workspace_item_id="+wsItemID)); 122 123 JSPManager.showJSP(request, response, "/workspace/ws-error.jsp"); 124 } 125 126 133 private void goToMyDSpace(Context context, 134 HttpServletRequest request, HttpServletResponse response) 135 throws ServletException , IOException , SQLException , AuthorizeException 136 { 137 response.sendRedirect(response.encodeRedirectURL( 138 request.getContextPath() + "/mydspace")); 139 } 140 141 142 149 private void showMainPage(Context context, 150 HttpServletRequest request, HttpServletResponse response) 151 throws ServletException , IOException , SQLException , AuthorizeException 152 { 153 int wsItemID = UIUtil.getIntParameter(request, "workspace_id"); 155 156 WorkspaceItem wsItem = WorkspaceItem.find(context, wsItemID); 158 159 Item item = wsItem.getItem(); 161 AuthorizeManager.authorizeAction(context, item, Constants.READ); 162 163 log.info(LogManager.getHeader(context, 164 "View Workspace Item", 165 "workspace_item_id="+wsItemID)); 166 167 request.setAttribute("wsItem", wsItem); 169 170 JSPManager.showJSP(request, response, "/workspace/ws-main.jsp"); 171 } 172 173 } 174 | Popular Tags |