KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > drftpd > remotefile > JDOMSerialize


1 /*
2  * This file is part of DrFTPD, Distributed FTP Daemon.
3  *
4  * DrFTPD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * DrFTPD is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with DrFTPD; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18 package net.sf.drftpd.remotefile;
19 import java.io.FileNotFoundException JavaDoc;
20 import java.io.Reader JavaDoc;
21 import java.util.List JavaDoc;
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 /**
33  * @author mog
34  * @version $Id: JDOMSerialize.java,v 1.9 2004/05/12 00:45:10 mog Exp $
35  */

36 public class JDOMSerialize {
37     private static final Logger logger = Logger.getLogger(JDOMSerialize.class);
38
39     public static LinkedRemoteFileInterface unserialize(ConnectionManager cm, Reader JavaDoc in, List JavaDoc rslaves) throws FileNotFoundException JavaDoc {
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 JavaDoc ex) {
50             throw ex;
51         } catch (Exception JavaDoc 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 JavaDoc("JDOMSerialize is deprecated");
59     }
60 }
61
Popular Tags