1 40 41 package org.dspace.app.webui.servlet; 42 43 import java.io.IOException ; 44 import javax.servlet.ServletException ; 45 import javax.servlet.http.HttpServletRequest ; 46 import javax.servlet.http.HttpServletResponse ; 47 import java.sql.SQLException ; 48 49 import org.apache.log4j.Logger; 50 51 import org.dspace.authorize.AuthorizeException; 52 import org.dspace.authorize.AuthorizeManager; 53 import org.dspace.app.webui.util.JSPManager; 54 import org.dspace.app.webui.util.UIUtil; 55 import org.dspace.core.Constants; 56 import org.dspace.core.Context; 57 import org.dspace.core.LogManager; 58 import org.dspace.content.Collection; 59 import org.dspace.content.Item; 60 import org.dspace.content.WorkspaceItem; 61 62 69 public class ViewWorkspaceItemServlet 70 extends DSpaceServlet 71 { 72 73 74 private static Logger log = Logger.getLogger(ViewWorkspaceItemServlet.class); 75 76 protected void doDSGet(Context c, 77 HttpServletRequest request, HttpServletResponse response) 78 throws ServletException , IOException , SQLException , AuthorizeException 79 { 80 doDSPost(c, request, response); 82 } 83 84 protected void doDSPost(Context c, 85 HttpServletRequest request, HttpServletResponse response) 86 throws ServletException , IOException , SQLException , AuthorizeException 87 { 88 String button = UIUtil.getSubmitButton(request, "submit_error"); 89 90 if (button.equals("submit_view") 91 || button.equals("submit_full") 92 || button.equals("submit_simple")) 93 { 94 showMainPage(c, request, response); 95 } else { 96 showErrorPage(c, request, response); 97 } 98 99 } 100 101 108 private void showMainPage(Context c, 109 HttpServletRequest request, HttpServletResponse response) 110 throws ServletException , IOException , SQLException , AuthorizeException 111 { 112 int wsItemID = UIUtil.getIntParameter(request,"workspace_id"); 114 115 WorkspaceItem wsItem = WorkspaceItem.find(c, wsItemID); 117 Item item = wsItem.getItem(); 118 Collection[] collections = {wsItem.getCollection()}; 120 121 AuthorizeManager.authorizeAction(c, item, Constants.READ); 123 124 log.info(LogManager.getHeader(c, 125 "View Workspace Item Metadata", 126 "workspace_item_id="+wsItemID)); 127 128 boolean displayAll = false; 130 String button = UIUtil.getSubmitButton(request, "submit_simple"); 131 if (button.equalsIgnoreCase("submit_full")) 132 { 133 displayAll = true; 134 } 135 136 request.setAttribute("display.all", new Boolean (displayAll)); 141 request.setAttribute("item", item); 142 request.setAttribute("collections", collections); 143 request.setAttribute("workspace_id", new Integer (wsItem.getID())); 144 145 JSPManager.showJSP(request, response, "/display-item.jsp"); 146 } 147 148 155 private void showErrorPage(Context context, 156 HttpServletRequest request, HttpServletResponse response) 157 throws ServletException , IOException , SQLException , AuthorizeException 158 { 159 int wsItemID = UIUtil.getIntParameter(request,"workspace_id"); 160 161 log.error(LogManager.getHeader(context, 162 "View Workspace Item Metadata Failed", 163 "workspace_item_id="+wsItemID)); 164 165 JSPManager.showJSP(request, response, "/workspace/wsv-error.jsp"); 166 } 167 } 168 | Popular Tags |