KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > backup > component > UIImportUserData


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

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 /**
12  * @email: tuan08@users.sourceforge.net
13  * @version: $Id: UIImportUserData.java,v 1.8 2004/09/21 00:16:11 tuan08 Exp $
14  */

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 JavaDoc {
36       UIImportUserData component = (UIImportUserData)event.getComponent() ;
37         String JavaDoc dataName = event.getParameter("dataName") ;
38         int idx = dataName.indexOf('.') ;
39         String JavaDoc 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 JavaDoc {
50       UIImportUserData component = (UIImportUserData)event.getComponent() ;
51         component.getBackupService().importUserData() ;
52     }
53   }
54 }
Popular Tags