1 5 package org.exoplatform.services.communication.forum.hibernate; 6 7 import java.io.InputStream ; 8 import java.io.OutputStream ; 9 import java.util.jar.JarEntry ; 10 import java.util.jar.JarFile ; 11 import java.util.jar.JarOutputStream ; 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 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 getName() { return "forum" ;} 37 38 public String getDescription() { 39 return "Export categories, forums , topics , posts" ; 40 } 41 42 public void exportUserData(String userName, Object transaction, 43 OutputStream out, JarEntry entry) throws Exception { 44 out.write("N/A".getBytes()) ; 45 } 46 47 public void importUserData(String userName, Object transaction, 48 InputStream is, JarEntry entry) throws Exception { 49 } 50 51 public void exportServiceData(Object transaction, JarOutputStream out) throws Exception { 52 Session session = (Session) transaction ; 53 ForumExporter exporter = new ForumExporter(session, out, xstream_) ; 54 exporter.export() ; 55 } 56 57 public void importServiceData(Object transaction, JarFile jar) throws Exception { 58 Session session = (Session) transaction ; 59 ForumImporter importer = new ForumImporter(session,jar, xstream_) ; 60 importer.importData() ; 61 } 62 } | Popular Tags |