KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > communication > forum > hibernate > ForumImporterExporter


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.services.communication.forum.hibernate;
6
7 import java.io.InputStream JavaDoc;
8 import java.io.OutputStream JavaDoc;
9 import java.util.jar.JarEntry JavaDoc;
10 import java.util.jar.JarFile JavaDoc;
11 import java.util.jar.JarOutputStream JavaDoc;
12 import net.sf.hibernate.Session;
13 import org.exoplatform.services.backup.ImporterExporter;
14 import com.thoughtworks.xstream.XStream;
15 import com.thoughtworks.xstream.io.xml.XppDriver;
16 import com.thoughtworks.xstream.converters.extended.SqlTimestampConverter ;
17 /**
18  * May 27, 2004
19  * @author: Tuan Nguyen
20  * @email: tuan08@users.sourceforge.net
21  * @version: $ID$
22  **/

23 public class ForumImporterExporter implements ImporterExporter {
24   private XStream xstream_ ;
25
26   public ForumImporterExporter() {
27     xstream_ = new XStream(new XppDriver());
28     xstream_.alias("category", CategoryImpl.class);
29     xstream_.alias("forum", ForumImpl.class);
30     xstream_.alias("topic", TopicImpl.class);
31     xstream_.alias("forum-topic", TopicBackup.class);
32     xstream_.alias("post", PostImpl.class);
33     xstream_.registerConverter(new SqlTimestampConverter()) ;
34   }
35   
36   public String JavaDoc getName() { return "forum" ;}
37   
38   public String JavaDoc getDescription() {
39     return "Export categories, forums , topics , posts" ;
40   }
41
42   public void exportUserData(String JavaDoc userName, Object JavaDoc transaction,
43                              OutputStream JavaDoc out, JarEntry JavaDoc entry) throws Exception JavaDoc {
44     out.write("N/A".getBytes()) ;
45   }
46
47   public void importUserData(String JavaDoc userName, Object JavaDoc transaction,
48                              InputStream JavaDoc is, JarEntry JavaDoc entry) throws Exception JavaDoc {
49   }
50
51   public void exportServiceData(Object JavaDoc transaction, JarOutputStream JavaDoc out) throws Exception JavaDoc {
52     Session session = (Session) transaction ;
53     ForumExporter exporter = new ForumExporter(session, out, xstream_) ;
54     exporter.export() ;
55   }
56
57   public void importServiceData(Object JavaDoc transaction, JarFile JavaDoc jar) throws Exception JavaDoc {
58     Session session = (Session) transaction ;
59     ForumImporter importer = new ForumImporter(session,jar, xstream_) ;
60     importer.importData() ;
61   }
62 }
Popular Tags