KickJava   Java API By Example, From Geeks To Geeks.

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


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

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 JavaDoc 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 JavaDoc {
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 JavaDoc {
58       UIExportData uiComp = (UIExportData) event.getSource() ;
59         String JavaDoc name = event.getParameter("name") ;
60         uiComp.service_.exportServiceData(name) ;
61     }
62   }
63 }
Popular Tags