KickJava   Java API By Example, From Geeks To Geeks.

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


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
20 import java.io.FileNotFoundException JavaDoc;
21 import java.io.FileReader JavaDoc;
22 import java.io.IOException JavaDoc;
23 import java.util.List JavaDoc;
24
25 import net.sf.drftpd.master.ConnectionManager;
26 import net.sf.drftpd.master.SlaveManagerImpl;
27 import net.sf.drftpd.util.SafeFileWriter;
28
29 import org.apache.log4j.BasicConfigurator;
30
31 /**
32  * @author mog
33  *
34  * @version $Id: FileListConverter.java,v 1.9 2004/02/23 01:14:40 mog Exp $
35  */

36 public class FileListConverter {
37     public static void main(String JavaDoc[] args) throws IOException JavaDoc {
38         BasicConfigurator.configure();
39         if(args.length != 0) {
40             System.out.println("Converts from files.xml to files.mlst");
41             return;
42         }
43         System.out.println("Converting files.xml to files.mlst");
44         System.out.println("This might take a while for large filelists and/or slow servers, have patience...");
45         LinkedRemoteFileInterface root = FileListConverter.loadJDOMFileDatabase(SlaveManagerImpl.loadRSlaves(), null);
46         MLSTSerialize.serialize(root, new SafeFileWriter("files.mlst"));
47         System.out.println("Completed, have a nice day");
48     }
49
50     public static LinkedRemoteFileInterface loadJDOMFileDatabase(
51         List JavaDoc rslaves,
52         ConnectionManager cm)
53         throws FileNotFoundException JavaDoc {
54         return JDOMSerialize.unserialize(
55             cm,
56             new FileReader JavaDoc("files.xml"),
57             rslaves);
58     }
59 }
60
Popular Tags