1 5 package org.exoplatform.portlets.portletregistery.component; 6 7 import org.exoplatform.faces.core.event.CheckRoleInterceptor; 8 import org.exoplatform.faces.core.event.ExoActionEvent; 9 import org.exoplatform.faces.core.event.ExoActionListener; 10 import org.exoplatform.services.portletcontainer.monitor.PortletContainerMonitor; 11 import org.exoplatform.services.portletregistery.PortletRegisteryService; 12 13 import java.util.* ; 14 19 public class UIPortletCategories extends org.exoplatform.portal.faces.component.UIPortletCategories { 20 public static final String CREATE_CATEGORY = "createCategory"; 21 public static final String IMPORT_PORTLETS = "importPortets"; 22 public static final String CLEAN_ALL = "cleanAll"; 23 24 public static final String PORTLET_CATEGORY_NAME_PARAM = "portletCategoryName"; 25 public static final String PORTLET_NAME_PARAM = "portletName"; 26 27 private PortletContainerMonitor portletContainerMonitor_ ; 28 29 public UIPortletCategories(PortletRegisteryService portletRegisteryService, 30 PortletContainerMonitor portletContainerMonitor, 31 UIPortletCategory uiPortletCategory, 32 UIPortletInfo uiPortletInfo) throws Exception { 33 super(portletRegisteryService, uiPortletCategory, uiPortletInfo) ; 34 portletContainerMonitor_ = portletContainerMonitor ; 35 addActionListener(CreateActionListener.class, CREATE_CATEGORY); 36 addActionListener(ImportActionListener.class, IMPORT_PORTLETS); 37 addActionListener(CleanAllActionListener.class, CLEAN_ALL); 38 } 39 40 public String getFamily() { 41 return "org.exoplatform.portlets.portletregistery.component.UIPortletCategories" ; 42 } 43 44 public static class CreateActionListener extends ExoActionListener { 45 public CreateActionListener() { 46 addInterceptor(new CheckRoleInterceptor("admin")) ; 47 } 48 49 public void execute(ExoActionEvent event) throws Exception { 50 UIPortletRegistry uiPortlet = 51 (UIPortletRegistry) event.getComponent().getParent(); 52 UIPortletCategoryForm uiForm = 53 (UIPortletCategoryForm)uiPortlet.getChildComponentOfType(UIPortletCategoryForm.class) ; 54 uiForm.setPortletCategoryData(null) ; 55 uiPortlet.setRenderedComponent(UIPortletCategoryForm.class); 56 } 57 } 58 59 static public class ImportActionListener extends ExoActionListener { 60 public ImportActionListener() { 61 addInterceptor(new CheckRoleInterceptor("admin")) ; 62 } 63 64 public void execute(ExoActionEvent event) throws Exception { 65 UIPortletCategories uiCategories = (UIPortletCategories) event.getComponent(); 66 Collection portletDatas = 67 uiCategories.portletContainerMonitor_.getPortletRuntimeDataMap().values(); 68 uiCategories.portletRegisteryService.importPortlets(portletDatas); 69 uiCategories.reset(); 70 } 71 } 72 73 static public class CleanAllActionListener extends ExoActionListener { 74 public CleanAllActionListener() { 75 addInterceptor(new CheckRoleInterceptor("admin")) ; 76 } 77 78 public void execute(ExoActionEvent event) throws Exception { 79 UIPortletCategories uiCategories = (UIPortletCategories) event.getComponent(); 80 uiCategories.portletRegisteryService.clearRepository(); 81 uiCategories.reset(); 82 } 83 } 84 } | Popular Tags |