yacy_search_server/htroot/ContentIntegrationPHPBB3_p.java

160 lines
7.3 KiB
Java
Raw Normal View History

// 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
//
// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
// $LastChangedRevision: 1986 $
// $LastChangedBy: orbiter $
//
// LICENSE
//
// 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
import java.io.File;
import de.anomic.content.dao.Dao;
import de.anomic.content.dao.ImportDump;
import de.anomic.content.dao.PhpBB3Dao;
import de.anomic.http.httpRequestHeader;
import de.anomic.kelondro.util.DateFormatter;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
public class ContentIntegrationPHPBB3_p {
removed the indexing queue. This queue was superfluous since the introduction of the blocking queues last year, where documents are parsed, analysed and stored in the index with concurrency. - The indexing queue was a historic data structure that was introduced at the very beginning at the project as a part of the switchboard organisation object structure. Without the indexing queue the switchboard queue becomes also superfluous. It has been removed as well. - Removing the switchboard queue requires that all servlets are called without a opaque generic ('<?>'). That caused that all serlets had to be modified. - Many servlets displayed the indexing queue or the size of that queue. In the past months the indexer was so fast that mostly the indexing queue appeared empty, so there was no use of it any more. Because the queue has been removed, the display in the servlets had also to be removed. - The surrogate work task had been a part of the indexing queue control structure. Without the indexing queue the surrogates needed its own task management. That has been integrated here. - Because the indexing queue had a special queue entry object and properties attached to this object, the propterties had to be moved to the queue entry object which is part of the new indexing queue withing the blocking queue, the Response Object. That object has now also the new properties of the removed indexing queue entry object. git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6225 6c8d7289-2bf4-0310-a012-ef5d649a1542
2009-07-17 15:59:21 +02:00
public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch env) {
final serverObjects prop = new serverObjects();
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
prop.put("check", 0);
prop.put("export", 0);
prop.put("import", 0);
if (post != null) {
String urlstub = post.get("content.phpbb3.urlstub", "");
String dbtype = post.get("content.phpbb3.dbtype", "");
String dbhost = post.get("content.phpbb3.dbhost", "");
int dbport = post.getInt("content.phpbb3.dbport", 3306);
String dbname = post.get("content.phpbb3.dbname", "");
String prefix = post.get("content.phpbb3.tableprefix", "");
String dbuser = post.get("content.phpbb3.dbuser", "");
String dbpw = post.get("content.phpbb3.dbpw", "");
int ppf = post.getInt("content.phpbb3.ppf", 1000);
String dumpfile = post.get("content.phpbb3.dumpfile", "");
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);
sb.setConfig("content.phpbb3.tableprefix", prefix);
sb.setConfig("content.phpbb3.dbuser", dbuser);
sb.setConfig("content.phpbb3.dbpw", dbpw);
sb.setConfig("content.phpbb3.ppf", ppf);
sb.setConfig("content.phpbb3.dumpfile", dumpfile);
if (post.containsKey("check")) {
try {
Dao db = new PhpBB3Dao(
urlstub,
dbtype,
dbhost,
dbport,
dbname,
prefix,
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();
} catch (Exception e) {
e.printStackTrace();
prop.put("check", 2);
prop.put("check_error", e.getMessage());
}
}
if (post.containsKey("export")) {
try {
Dao db = new PhpBB3Dao(
urlstub,
dbtype,
dbhost,
dbport,
dbname,
prefix,
dbuser,
dbpw
);
int files = db.writeSurrogates(db.query(0, -1, 100), sb.surrogatesInPath, "fullexport-" + DateFormatter.formatShortSecond(), ppf);
prop.put("export", 1);
prop.put("export_files", files);
db.close();
} catch (Exception e) {
e.printStackTrace();
prop.put("export", 2);
prop.put("export_error", e.getMessage());
}
}
if (post.containsKey("import")) {
File f = new File(dumpfile);
if (!f.exists()) {
prop.put("import", 2);
prop.put("import_error", "file " + dumpfile + " does not exist");
} else try {
ImportDump importer = new ImportDump(
dbtype,
dbhost,
dbport,
dbname,
dbuser,
dbpw
);
importer.imp(f);
prop.put("import", 1);
importer.close();
} catch (Exception e) {
e.printStackTrace();
prop.put("import", 2);
prop.put("import_error", e.getMessage());
}
}
}
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", ""));
prop.putHTML("content.phpbb3.tableprefix", sb.getConfig("content.phpbb3.tableprefix", ""));
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", ""));
prop.putHTML("content.phpbb3.dumpfile", sb.getConfig("content.phpbb3.dumpfile", ""));
return prop;
}
}