mirror of
https://github.com/yacy/yacy_search_server.git
synced 2025-09-15 17:06:13 -04:00
This is a complete re-design of the serverObjects data structure which holds all data that is submitted during http post requests to YaCy. Before the change, post attributes had been stored to Strings which cannot be larger than 2GB. Furthermore, byte[] uploads had been encoded to b64 Strings to fit into this data structure. Those strings are now replaced by a new data structure, ChunkedBytes which is an object that can hold more than 2GB data using a list of byte[] objects. All required streaming functions are implemented and streaming from http post upload into this data structure works. The b64 encoding has been removed. The ZIM and WARC reader make use of the new data structure.
80 lines
2.8 KiB
Java
80 lines
2.8 KiB
Java
// mediawiki.java
|
|
// (C) 2007 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
|
|
// first published 2007 on http://yacy.net
|
|
//
|
|
// This is a part of YaCy, a peer-to-peer based web search engine
|
|
//
|
|
// $LastChangedDate$
|
|
// $LastChangedRevision$
|
|
// $LastChangedBy$
|
|
//
|
|
// 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
|
|
|
|
package net.yacy.htroot;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
|
|
import net.yacy.cora.document.encoding.UTF8;
|
|
import net.yacy.cora.protocol.RequestHeader;
|
|
import net.yacy.document.importer.MediawikiImporter;
|
|
import net.yacy.search.Switchboard;
|
|
import net.yacy.server.serverObjects;
|
|
import net.yacy.server.serverSwitch;
|
|
|
|
public class mediawiki_p {
|
|
|
|
//http://localhost:8090/mediawiki_p.html?dump=wikipedia.de.xml&title=Kartoffel
|
|
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) throws IOException {
|
|
final Switchboard sb = (Switchboard) env;
|
|
final serverObjects prop = new serverObjects();
|
|
prop.put("title", "");
|
|
prop.put("page", "");
|
|
|
|
if (post == null) {
|
|
return post;
|
|
}
|
|
|
|
final String dump = post.get("dump", "");
|
|
final String title = post.get("title", "");
|
|
if (dump.length() == 0 || title.length() == 0) return post;
|
|
|
|
|
|
final File dumpFile = new File(sb.getDataPath(), "DATA/HTCACHE/mediawiki/" + dump);
|
|
if (!dumpFile.exists()) return post;
|
|
MediawikiImporter.checkIndex(dumpFile);
|
|
final MediawikiImporter.wikisourcerecord w = MediawikiImporter.find(title.replaceAll(" ", "_"), MediawikiImporter.idxFromMediawikiXML(dumpFile));
|
|
if (w == null) {
|
|
return post;
|
|
}
|
|
String page = UTF8.String(MediawikiImporter.read(dumpFile, w.start, (int) (w.end - w.start)));
|
|
int p = page.indexOf("<text",0);
|
|
if (p < 0) return prop;
|
|
p = page.indexOf('>', p);
|
|
if (p < 0) return prop;
|
|
p++;
|
|
final int q = page.lastIndexOf("</text>");
|
|
if (q < 0) return prop;
|
|
page = page.substring(p, q);
|
|
|
|
prop.putHTML("title", title);
|
|
prop.putWiki("page", page);
|
|
|
|
return prop;
|
|
}
|
|
}
|