You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
163 lines
7.3 KiB
163 lines
7.3 KiB
16 years ago
|
// ContentIntegrationPHPBB3_p.java
|
||
|
// (C) 2009 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
|
||
|
// first published 27.05.2009 on http://yacy.net
|
||
|
//
|
||
15 years ago
|
// $LastChangedDate$
|
||
|
// $LastChangedRevision$
|
||
|
// $LastChangedBy$
|
||
16 years ago
|
//
|
||
|
// LICENSE
|
||
13 years ago
|
//
|
||
16 years ago
|
// This program is free software; you can redistribute it and/or modify
|
||
|
// it under the terms of the GNU General Public License as published by
|
||
|
// the Free Software Foundation; either version 2 of the License, or
|
||
|
// (at your option) any later version.
|
||
|
//
|
||
|
// This program is distributed in the hope that it will be useful,
|
||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
// GNU General Public License for more details.
|
||
|
//
|
||
|
// You should have received a copy of the GNU General Public License
|
||
|
// along with this program; if not, write to the Free Software
|
||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
|
|
||
2 years ago
|
package net.yacy.htroot;
|
||
|
|
||
16 years ago
|
import java.io.File;
|
||
13 years ago
|
|
||
14 years ago
|
import net.yacy.cora.date.GenericFormatter;
|
||
14 years ago
|
import net.yacy.cora.protocol.RequestHeader;
|
||
12 years ago
|
import net.yacy.cora.util.ConcurrentLog;
|
||
15 years ago
|
import net.yacy.document.content.dao.Dao;
|
||
|
import net.yacy.document.content.dao.ImportDump;
|
||
|
import net.yacy.document.content.dao.PhpBB3Dao;
|
||
13 years ago
|
import net.yacy.search.Switchboard;
|
||
12 years ago
|
import net.yacy.server.serverObjects;
|
||
|
import net.yacy.server.serverSwitch;
|
||
16 years ago
|
|
||
|
public class ContentIntegrationPHPBB3_p {
|
||
|
|
||
13 years ago
|
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) {
|
||
16 years ago
|
final serverObjects prop = new serverObjects();
|
||
16 years ago
|
final Switchboard sb = (Switchboard) env;
|
||
13 years ago
|
|
||
16 years ago
|
prop.put("check", 0);
|
||
|
prop.put("export", 0);
|
||
16 years ago
|
prop.put("import", 0);
|
||
13 years ago
|
|
||
16 years ago
|
if (post != null) {
|
||
13 years ago
|
|
||
2 years ago
|
final String urlstub = post.get("content.phpbb3.urlstub", "");
|
||
|
final String dbtype = post.get("content.phpbb3.dbtype", "");
|
||
|
final String dbhost = post.get("content.phpbb3.dbhost", "");
|
||
|
final int dbport = post.getInt("content.phpbb3.dbport", 3306);
|
||
|
final String dbname = post.get("content.phpbb3.dbname", "");
|
||
|
final String prefix = post.get("content.phpbb3.tableprefix", "");
|
||
|
final String dbuser = post.get("content.phpbb3.dbuser", "");
|
||
|
final String dbpw = post.get("content.phpbb3.dbpw", "");
|
||
|
final int ppf = post.getInt("content.phpbb3.ppf", 1000);
|
||
|
final String dumpfile = post.get("content.phpbb3.dumpfile", "");
|
||
13 years ago
|
|
||
|
|
||
16 years ago
|
sb.setConfig("content.phpbb3.urlstub", urlstub);
|
||
|
sb.setConfig("content.phpbb3.dbtype", dbtype);
|
||
|
sb.setConfig("content.phpbb3.dbhost", dbhost);
|
||
|
sb.setConfig("content.phpbb3.dbport", dbport);
|
||
|
sb.setConfig("content.phpbb3.dbname", dbname);
|
||
16 years ago
|
sb.setConfig("content.phpbb3.tableprefix", prefix);
|
||
16 years ago
|
sb.setConfig("content.phpbb3.dbuser", dbuser);
|
||
|
sb.setConfig("content.phpbb3.dbpw", dbpw);
|
||
|
sb.setConfig("content.phpbb3.ppf", ppf);
|
||
16 years ago
|
sb.setConfig("content.phpbb3.dumpfile", dumpfile);
|
||
13 years ago
|
|
||
16 years ago
|
if (post.containsKey("check")) {
|
||
|
try {
|
||
2 years ago
|
final Dao db = new PhpBB3Dao(
|
||
16 years ago
|
urlstub,
|
||
|
dbtype,
|
||
|
dbhost,
|
||
|
dbport,
|
||
|
dbname,
|
||
16 years ago
|
prefix,
|
||
16 years ago
|
dbuser,
|
||
|
dbpw
|
||
|
);
|
||
|
prop.put("check", 1);
|
||
|
prop.put("check_posts", db.size());
|
||
|
prop.putHTML("check_first", db.first().toString());
|
||
|
prop.putHTML("check_last", db.latest().toString());
|
||
|
db.close();
|
||
11 years ago
|
} catch (final Exception e) {
|
||
12 years ago
|
ConcurrentLog.logException(e);
|
||
16 years ago
|
prop.put("check", 2);
|
||
|
prop.put("check_error", e.getMessage());
|
||
|
}
|
||
|
}
|
||
13 years ago
|
|
||
16 years ago
|
if (post.containsKey("export")) {
|
||
|
try {
|
||
2 years ago
|
final Dao db = new PhpBB3Dao(
|
||
16 years ago
|
urlstub,
|
||
|
dbtype,
|
||
|
dbhost,
|
||
|
dbport,
|
||
|
dbname,
|
||
16 years ago
|
prefix,
|
||
16 years ago
|
dbuser,
|
||
|
dbpw
|
||
|
);
|
||
13 years ago
|
|
||
2 years ago
|
final int files = db.writeSurrogates(db.query(0, -1, 100), sb.surrogatesInPath, "fullexport-" + GenericFormatter.SHORT_SECOND_FORMATTER.format(), ppf);
|
||
16 years ago
|
prop.put("export", 1);
|
||
|
prop.put("export_files", files);
|
||
|
db.close();
|
||
11 years ago
|
} catch (final Exception e) {
|
||
12 years ago
|
ConcurrentLog.logException(e);
|
||
16 years ago
|
prop.put("export", 2);
|
||
|
prop.put("export_error", e.getMessage());
|
||
|
}
|
||
|
}
|
||
13 years ago
|
|
||
16 years ago
|
if (post.containsKey("import")) {
|
||
2 years ago
|
final File f = new File(dumpfile);
|
||
16 years ago
|
if (!f.exists()) {
|
||
|
prop.put("import", 2);
|
||
|
prop.put("import_error", "file " + dumpfile + " does not exist");
|
||
|
} else try {
|
||
2 years ago
|
final ImportDump importer = new ImportDump(
|
||
16 years ago
|
dbtype,
|
||
|
dbhost,
|
||
|
dbport,
|
||
|
dbname,
|
||
|
dbuser,
|
||
|
dbpw
|
||
|
);
|
||
13 years ago
|
|
||
16 years ago
|
importer.imp(f);
|
||
|
prop.put("import", 1);
|
||
|
importer.close();
|
||
11 years ago
|
} catch (final Exception e) {
|
||
12 years ago
|
ConcurrentLog.logException(e);
|
||
16 years ago
|
prop.put("import", 2);
|
||
|
prop.put("import_error", e.getMessage());
|
||
|
}
|
||
|
}
|
||
|
|
||
16 years ago
|
}
|
||
|
|
||
|
prop.putHTML("content.phpbb3.urlstub", sb.getConfig("content.phpbb3.urlstub", ""));
|
||
|
prop.putHTML("content.phpbb3.dbtype", sb.getConfig("content.phpbb3.dbtype", ""));
|
||
|
prop.putHTML("content.phpbb3.dbhost", sb.getConfig("content.phpbb3.dbhost", ""));
|
||
|
prop.putHTML("content.phpbb3.dbport", sb.getConfig("content.phpbb3.dbport", ""));
|
||
|
prop.putHTML("content.phpbb3.dbname", sb.getConfig("content.phpbb3.dbname", ""));
|
||
16 years ago
|
prop.putHTML("content.phpbb3.tableprefix", sb.getConfig("content.phpbb3.tableprefix", ""));
|
||
16 years ago
|
prop.putHTML("content.phpbb3.dbuser", sb.getConfig("content.phpbb3.dbuser", ""));
|
||
|
prop.putHTML("content.phpbb3.dbpw", sb.getConfig("content.phpbb3.dbpw", ""));
|
||
|
prop.putHTML("content.phpbb3.ppf", sb.getConfig("content.phpbb3.ppf", ""));
|
||
16 years ago
|
prop.putHTML("content.phpbb3.dumpfile", sb.getConfig("content.phpbb3.dumpfile", ""));
|
||
16 years ago
|
|
||
|
return prop;
|
||
|
}
|
||
|
}
|