01: //yacySeedUploadFile.java
02: //-------------------------------------
03: //part of YACY
04: //(C) by Michael Peter Christen; mc@anomic.de
05: //first published on http://www.anomic.de
06: //Frankfurt, Germany, 2004
07: //
08: //This file ist contributed by Martin Thelian
09: //last major change: $LastChangedDate: 2006-01-23 15:08:39 +0000 (Mo, 23 Jan 2006) $ by $LastChangedBy: rramthun $
10: //Revision: $LastChangedRevision: 1417 $
11: //
12: //This program is free software; you can redistribute it and/or modify
13: //it under the terms of the GNU General Public License as published by
14: //the Free Software Foundation; either version 2 of the License, or
15: //(at your option) any later version.
16: //
17: //This program is distributed in the hope that it will be useful,
18: //but WITHOUT ANY WARRANTY; without even the implied warranty of
19: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20: //GNU General Public License for more details.
21: //
22: //You should have received a copy of the GNU General Public License
23: //along with this program; if not, write to the Free Software
24: //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25: //
26: //Using this software in any meaning (reading, learning, copying, compiling,
27: //running) means that you agree that the Author(s) is (are) not responsible
28: //for cost, loss of data or any harm that may be caused directly or indirectly
29: //by usage of this softare or this documentation. The usage of this software
30: //is on your own risk. The installation and usage (starting/running) of this
31: //software may allow other people or application to access your computer and
32: //any attached devices and is highly dependent on the configuration of the
33: //software which must be done by the user of the software; the author(s) is
34: //(are) also not responsible for proper configuration and usage of the
35: //software, even if provoked by documentation provided together with
36: //the software.
37: //
38: //Any changes to this file according to the GPL as documented in the file
39: //gpl.txt aside this file in the shipment you received can be done to the
40: //lines that follows this copyright notice here, but changes must not be
41: //done inside the copyright notive above. A re-distribution must contain
42: //the intact and unchanged copyright notice.
43: //Contributions and changes to the program code must be marked as such.
44:
45: package de.anomic.yacy.seedUpload;
46:
47: import java.io.File;
48:
49: import de.anomic.server.serverFileUtils;
50: import de.anomic.server.serverSwitch;
51: import de.anomic.yacy.yacySeedDB;
52: import de.anomic.yacy.yacySeedUploader;
53:
54: public class yacySeedUploadFile implements yacySeedUploader {
55:
56: public static final String CONFIG_FILE_PATH = "seedFilePath";
57:
58: public String uploadSeedFile(serverSwitch sb, yacySeedDB seedDB,
59: File seedFile) throws Exception {
60:
61: String seedFilePath = "";
62: try {
63: seedFilePath = sb.getConfig(CONFIG_FILE_PATH, "");
64: if (seedFilePath.length() == 0)
65: throw new Exception(
66: "Path to seed file is not configured properly");
67:
68: File publicSeedFile = new File(seedFilePath);
69: serverFileUtils.copy(seedFile, publicSeedFile);
70:
71: return "Seed-List file stored successfully";
72: } catch (Exception e) {
73: throw new Exception(
74: "Unable to store the seed-list file into the filesystem using path '"
75: + seedFilePath + "'. " + e.getMessage());
76: }
77: }
78:
79: public String[] getConfigurationOptions() {
80: return new String[] { CONFIG_FILE_PATH };
81: }
82:
83: public String[] getLibxDependencies() {
84: return new String[] {};
85: }
86: }
|