1 40 package org.dspace.app.webui.util; 41 42 import java.io.IOException ; 43 44 import javax.servlet.ServletException ; 45 import javax.servlet.http.HttpServletRequest ; 46 import javax.servlet.http.HttpServletResponse ; 47 48 import org.apache.log4j.Logger; 49 import org.dspace.authorize.AuthorizeException; 50 import org.dspace.core.Context; 51 import org.dspace.core.LogManager; 52 53 59 public class JSPManager 60 { 61 66 67 68 private static Logger log = Logger.getLogger(JSPManager.class); 69 70 80 public static void showJSP(HttpServletRequest request, 81 HttpServletResponse response, String jsp) throws ServletException , 82 IOException 83 { 84 if (log.isDebugEnabled()) 85 { 86 log.debug(LogManager.getHeader((Context) request 87 .getAttribute("dspace.context"), "view_jsp", jsp)); 88 } 89 90 request.getRequestDispatcher(jsp).forward(request, response); 92 } 93 94 102 public static void showInternalError(HttpServletRequest request, 103 HttpServletResponse response) throws ServletException , IOException 104 { 105 response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); 106 showJSP(request, response, "/error/internal.jsp"); 107 } 108 109 118 public static void showIntegrityError(HttpServletRequest request, 119 HttpServletResponse response) throws ServletException , IOException 120 { 121 response.setStatus(HttpServletResponse.SC_BAD_REQUEST); 122 showJSP(request, response, "/error/integrity.jsp"); 123 } 124 125 137 public static void showAuthorizeError(HttpServletRequest request, 138 HttpServletResponse response, AuthorizeException exception) 139 throws ServletException , IOException 140 { 141 response.setStatus(HttpServletResponse.SC_FORBIDDEN); 143 showJSP(request, response, "/error/authorize.jsp"); 144 } 145 146 162 public static void showInvalidIDError(HttpServletRequest request, 163 HttpServletResponse response, String badID, int type) 164 throws ServletException , IOException 165 { 166 request.setAttribute("bad.id", badID); 167 response.setStatus(HttpServletResponse.SC_NOT_FOUND); 168 169 if (type != -1) 170 { 171 request.setAttribute("bad.type", new Integer (type)); 172 } 173 174 showJSP(request, response, "/error/invalid-id.jsp"); 175 } 176 } 177 | Popular Tags |