1 5 package org.exoplatform.portlets.backup.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.backup.BackupService; 11 15 public class UIImportUserData extends UIImportData { 16 17 public UIImportUserData(BackupService service) { 18 super(service) ; 19 setId("UIImportUserData") ; 20 setDirectory(service_.getUserDataDirectory()) ; 21 populateImportData() ; 22 23 addActionListener(RefreshActionListener.class, "refresh") ; 24 addActionListener(ViewDataActionListener.class, "viewData") ; 25 addActionListener(ImportUserActionListener.class, "importData") ; 26 addActionListener(ImportAllActionListener.class,"importAll") ; 27 adminRole_ = hasRole("admin") ; 28 } 29 30 static public class ImportUserActionListener extends ExoActionListener { 31 public ImportUserActionListener() { 32 addInterceptor(new CheckRoleInterceptor("admin")) ; 33 } 34 35 public void execute(ExoActionEvent event) throws Exception { 36 UIImportUserData component = (UIImportUserData)event.getComponent() ; 37 String dataName = event.getParameter("dataName") ; 38 int idx = dataName.indexOf('.') ; 39 String userName = dataName.substring(0, idx) ; 40 component.getBackupService().importUserData(userName) ; 41 } 42 } 43 44 static public class ImportAllActionListener extends ExoActionListener { 45 public ImportAllActionListener() { 46 addInterceptor(new CheckRoleInterceptor("admin")) ; 47 } 48 49 public void execute(ExoActionEvent event) throws Exception { 50 UIImportUserData component = (UIImportUserData)event.getComponent() ; 51 component.getBackupService().importUserData() ; 52 } 53 } 54 } | Popular Tags |