1 31 package org.blojsom.plugin.admin; 32 33 import org.apache.commons.logging.Log; 34 import org.apache.commons.logging.LogFactory; 35 import org.blojsom.blog.Blog; 36 import org.blojsom.blog.Entry; 37 import org.blojsom.plugin.PluginException; 38 import org.blojsom.util.BlojsomConstants; 39 import org.blojsom.util.BlojsomUtils; 40 import org.springframework.context.ApplicationContext; 41 42 import javax.servlet.http.HttpServletRequest ; 43 import javax.servlet.http.HttpServletResponse ; 44 import java.util.HashMap ; 45 import java.util.Map ; 46 import java.util.TreeMap ; 47 48 55 public class ListWebAdminPluginsPlugin extends BaseAdminPlugin { 56 57 private static Log _logger = LogFactory.getLog(ListWebAdminPluginsPlugin.class); 58 59 private static final String BLOJSOM_PLUGIN_WEB_ADMIN_PLUGINS_LIST = "BLOJSOM_PLUGIN_WEB_ADMIN_PLUGINS_LIST"; 60 private static final String LIST_WEB_ADMIN_PLUGINS_PAGE = "/org/blojsom/plugin/admin/templates/admin-list-web-admin-plugins"; 61 62 65 public ListWebAdminPluginsPlugin() { 66 } 67 68 79 public Entry[] process(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Blog blog, Map context, Entry[] entries) throws PluginException { 80 entries = super.process(httpServletRequest, httpServletResponse, blog, context, entries); 81 82 String page = BlojsomUtils.getRequestValue(BlojsomConstants.PAGE_PARAM, httpServletRequest); 83 84 if (ADMIN_LOGIN_PAGE.equals(page)) { 85 return entries; 86 } else { 87 Map plugins = new HashMap (); 88 ApplicationContext applicationContext = (ApplicationContext) _servletConfig.getServletContext().getAttribute(BlojsomConstants.BLOJSOM_APPLICATION_CONTEXT); 89 if (applicationContext != null) { 90 plugins = new TreeMap (applicationContext.getBeansOfType(WebAdminPlugin.class)); 91 } 92 93 httpServletRequest.setAttribute(BlojsomConstants.PAGE_PARAM, LIST_WEB_ADMIN_PLUGINS_PAGE); 94 context.put(BLOJSOM_PLUGIN_WEB_ADMIN_PLUGINS_LIST, plugins); 95 } 96 97 return entries; 98 } 99 } | Popular Tags |