1 18 package net.sf.drftpd.remotefile; 19 import java.io.FileNotFoundException ; 20 import java.io.Reader ; 21 import java.util.List ; 22 23 import net.sf.drftpd.FatalException; 24 import net.sf.drftpd.master.ConnectionManager; 25 26 import org.apache.log4j.Level; 27 import org.apache.log4j.Logger; 28 import org.jdom.Document; 29 import org.jdom.Element; 30 import org.jdom.input.SAXBuilder; 31 32 36 public class JDOMSerialize { 37 private static final Logger logger = Logger.getLogger(JDOMSerialize.class); 38 39 public static LinkedRemoteFileInterface unserialize(ConnectionManager cm, Reader in, List rslaves) throws FileNotFoundException { 40 LinkedRemoteFileInterface root; 41 try { 42 Document doc = new SAXBuilder().build(in); 43 JDOMRemoteFile xmlroot = 44 new JDOMRemoteFile(doc.getRootElement(), rslaves); 45 root = 46 new LinkedRemoteFile( 47 xmlroot, 48 cm == null ? null : cm.getConfig()); 49 } catch (FileNotFoundException ex) { 50 throw ex; 51 } catch (Exception ex) { 52 logger.log(Level.FATAL, "Error loading \"files.xml\"", ex); 53 throw new FatalException(ex); 54 } 55 return root; 56 } 57 public static Element serialize(LinkedRemoteFileInterface file) { 58 throw new UnsupportedOperationException ("JDOMSerialize is deprecated"); 59 } 60 } 61 | Popular Tags |