1 5 package org.exoplatform.portlets.backup.component; 6 7 import java.util.* ; 8 import org.exoplatform.faces.core.component.UICommandNode; 9 import org.exoplatform.faces.core.event.*; 10 import org.exoplatform.services.backup.BackupService; 11 15 public class UIExportData extends UICommandNode { 16 17 private BackupService service_ ; 18 private List importersExporters_ ; 19 private boolean adminRole_ ; 20 21 public UIExportData(BackupService service) { 22 setId("UIExportData") ; 23 setRendererType("ExportDataRenderer") ; 24 setName("Export Data"); 25 service_ = service ; 26 importersExporters_ = service_.getImportersExporters() ; 27 addActionListener(ExportAllActionListener.class , "exportAll") ; 28 addActionListener(ExportDataActionListener.class, "exportData") ; 29 adminRole_ = hasRole("admin") ; 30 } 31 32 public boolean hasAdminRole() { return adminRole_ ; } 33 34 public List getImportersExporters() { return importersExporters_ ; } 35 36 public String getFamily() { 37 return "org.exoplatform.portlets.backup.component.UIExportData" ; 38 } 39 40 static public class ExportAllActionListener extends ExoActionListener { 41 public ExportAllActionListener() { 42 addInterceptor(new CheckRoleInterceptor("admin")) ; 43 } 44 45 public void execute(ExoActionEvent event) throws Exception { 46 UIExportData uiComp = (UIExportData) event.getSource() ; 47 uiComp.service_.exportUserData() ; 48 uiComp.service_.exportServiceData() ; 49 } 50 } 51 52 static public class ExportDataActionListener extends ExoActionListener { 53 public ExportDataActionListener() { 54 addInterceptor(new CheckRoleInterceptor("admin")) ; 55 } 56 57 public void execute(ExoActionEvent event) throws Exception { 58 UIExportData uiComp = (UIExportData) event.getSource() ; 59 String name = event.getParameter("name") ; 60 uiComp.service_.exportServiceData(name) ; 61 } 62 } 63 } | Popular Tags |