001
014
015 package com.liferay.portal.kernel.portlet.configuration.icon;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.portal.kernel.util.Validator;
020
021 import java.io.IOException;
022
023 import javax.servlet.RequestDispatcher;
024 import javax.servlet.ServletContext;
025 import javax.servlet.ServletException;
026 import javax.servlet.http.HttpServletRequest;
027 import javax.servlet.http.HttpServletResponse;
028
029
032 public abstract class BaseJSPPortletConfigurationIconFactory
033 extends BasePortletConfigurationIconFactory {
034
035 public abstract String getJspPath();
036
037 @Override
038 public boolean include(
039 HttpServletRequest request, HttpServletResponse response)
040 throws IOException {
041
042 String jspPath = getJspPath();
043
044 if (Validator.isNull(jspPath)) {
045 return false;
046 }
047
048 RequestDispatcher requestDispatcher =
049 _servletContext.getRequestDispatcher(getJspPath());
050
051 try {
052 requestDispatcher.include(request, response);
053 }
054 catch (ServletException se) {
055 _log.error("Unable to include JSP " + getJspPath(), se);
056
057 return false;
058 }
059
060 return true;
061 }
062
063 public void setServletContext(ServletContext servletContext) {
064 _servletContext = servletContext;
065 }
066
067 private static final Log _log = LogFactoryUtil.getLog(
068 BaseJSPPortletConfigurationIconFactory.class);
069
070 private ServletContext _servletContext;
071
072 }