- some code-cleanup (no more syntax-warnings here)

- added deletion from loadedURLs of URLs to be blacklisted in IndexControl_p

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3404 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
karlchenofhell 18 years ago
parent 32867580ee
commit 6fbe31425a

@ -173,7 +173,7 @@ public class BlacklistCleaner_p {
r.add(entry.getValue());
}
}
System.err.println("for " + prefix + "(" + useKeys + "): " + r.size());
return (String[])r.toArray(new String[r.size()]);
}
@ -309,43 +309,4 @@ public class BlacklistCleaner_p {
}
return newE.length;
}
/*
private static int alterEntries(String blacklistToUse, String[] supportedBlacklistTypes, String[] entries, String[] newEntries) {
// load blacklist data from file
ArrayList list = listManager.getListArray(new File(listManager.listsPath, blacklistToUse));
// delete the old entry from file
String s, t, host, path;
for (int i=0; i<entries.length; i++) {
s = entries[i];
t = newEntries[i];
if (t.indexOf("/") == -1) {
host = t;
path = "/.*";
} else {
host = t.substring(0, t.indexOf("/"));
path = t.substring(t.indexOf("/"));
}
System.err.println("attempting to remove '" + );
if (list != null && list.contains(s)) {
System.err.println("done");
list.remove(s);
list.add(t);
}
// remove the entry from the running blacklist engine
for (int blTypes=0; blTypes < supportedBlacklistTypes.length; blTypes++) {
if (listManager.ListInListslist(supportedBlacklistTypes[blTypes] + ".BlackLists", blacklistToUse)) {
plasmaSwitchboard.urlBlacklist.remove(supportedBlacklistTypes[blTypes],
(s.indexOf("/") == -1) ? s : s.substring(0, s.indexOf("/")),
(s.indexOf("/") == -1) ? ".*" : s.substring(s.indexOf("/") + 1));
plasmaSwitchboard.urlBlacklist.add(supportedBlacklistTypes[blTypes], host, path);
}
}
}
if (list != null) listManager.writeList(new File(listManager.listsPath, blacklistToUse), (String[])list.toArray(new String[list.size()]));
return entries.length;
}*/
}

@ -389,6 +389,7 @@ public class IndexControl_p {
if (post.containsKey("blacklist")) {
String blacklist = post.get("blacklist", "");
Set urlHashes = new HashSet();
if (post.containsKey("blacklisturls")) {
PrintWriter pw;
try {
@ -396,7 +397,9 @@ public class IndexControl_p {
pw = new PrintWriter(new FileWriter(new File(listManager.listsPath, blacklist), true));
URL url;
for (int i=0; i<urlx.length; i++) {
urlHashes.add(urlx[i]);
indexURLEntry e = switchboard.wordIndex.loadedURL.load(urlx[i], null);
switchboard.wordIndex.loadedURL.remove(urlx[i]);
if (e != null) {
url = e.comp().url();
pw.println(url.getHost() + "/" + url.getFile());
@ -422,7 +425,9 @@ public class IndexControl_p {
pw = new PrintWriter(new FileWriter(new File(listManager.listsPath, blacklist), true));
URL url;
for (int i=0; i<urlx.length; i++) {
urlHashes.add(urlx[i]);
indexURLEntry e = switchboard.wordIndex.loadedURL.load(urlx[i], null);
switchboard.wordIndex.loadedURL.remove(urlx[i]);
if (e != null) {
url = e.comp().url();
pw.println(url.getHost() + "/.*");
@ -440,6 +445,7 @@ public class IndexControl_p {
} catch (IOException e) {
}
}
switchboard.wordIndex.removeEntries(keystring, urlHashes);
}
listHosts(prop, keyhash);

@ -67,10 +67,10 @@ public class QuickCrawlLink_p {
/**
* Example Javascript to call this servlet:
* <code>javascript:w = window.open('http://user:pwd@localhost:8080/QuickCrawlLink_p.html?indexText=on&indexMedia=on&crawlingQ=on&xdstopw=on&title=' + escape(document.title) + '&url=' + location.href,'_blank','height=150,width=500,resizable=yes,scrollbar=no,directory=no,menubar=no,location=no'); w.focus();</code>
* @param header
* @param post
* @param env
* @return
* @param header the complete HTTP header of the request
* @param post any arguments for this servlet, the request carried with (GET as well as POST)
* @param env the serverSwitch object holding all runtime-data
* @return the rewrite-properties for the template
*/
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {

@ -45,7 +45,6 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
@ -65,11 +64,10 @@ public class ScreenSaver {
/**
* Generates a proxy-autoconfig-file (application/x-ns-proxy-autoconfig)
* See: <a href="http://wp.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.html">Proxy Auto-Config File Format</a>
* @param header
* @param post
* @param env
* @return
* @throws IOException
* @param header the complete HTTP header of the request
* @param post any arguments for this servlet, the request carried with (GET as well as POST)
* @param env the serverSwitch object holding all runtime-data
* @return the rewrite-properties for the template
*/
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {

@ -51,10 +51,10 @@ import de.anomic.yacy.yacyCore;
public class YaCySearchPluginFF {
/**
* @param header
* @param post
* @param env
* @return
* @param header the complete HTTP header of the request
* @param post any arguments for this servlet, the request carried with (GET as well as POST)
* @param env the serverSwitch object holding all runtime-data
* @return the rewrite-properties for the template
*/
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {

@ -52,10 +52,10 @@ public class autoconfig {
/**
* Generates a proxy-autoconfig-file (application/x-ns-proxy-autoconfig)
* See: <a href="http://wp.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.html">Proxy Auto-Config File Format</a>
* @param header
* @param post
* @param env
* @return
* @param header the complete HTTP header of the request
* @param post any arguments for this servlet, the request carried with (GET as well as POST)
* @param env the serverSwitch object holding all runtime-data
* @return the rewrite-properties for the template
*/
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {

@ -604,8 +604,7 @@ public class bookmarksDB {
return tagHash;
}
/**
* get tag name, with all uppercase chars.
* @return
* @return the tag name, with all uppercase chars
*/
public String getFriendlyName(){
/*if(this.mem.containsKey(TAG_FRIENDLY_NAME)){

@ -57,6 +57,7 @@ import de.anomic.data.wiki.tokens.SimpleToken;
import de.anomic.data.wiki.tokens.TableToken;
import de.anomic.data.wiki.tokens.Token;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.yacy.yacyCore;
public class wikiParser {
@ -67,7 +68,7 @@ public class wikiParser {
tokens = new Token[] {
new SimpleToken('=', '=', new String[][] { null, { "h2" }, { "h3" }, { "h4" } }, true),
new SimpleToken('\'', '\'', new String[][] { null, { "i" }, { "b" }, null, { "b", "i" } }, false),
new LinkToken("localhost:8080"/*yacyCore.seedDB.mySeed.getAddress()*/, "Wiki.html?page=", sb),
new LinkToken(yacyCore.seedDB.mySeed.getAddress(), "Wiki.html?page=", sb),
new ListToken('*', "ul"),
new ListToken('#', "ol"),
new ListToken(':', "blockquote", null),

@ -830,8 +830,8 @@ public final class httpHeader extends TreeMap implements Map {
*/
//Since properties such as cookies can be multiple, we cannot use HashMap here. We have to use Vector.
private Vector cookies=new Vector();
/**
*
* Implementation of Map.Entry. Structure that hold two values - exactly what we need!
*/
class Entry implements Map.Entry
@ -847,13 +847,13 @@ public final class httpHeader extends TreeMap implements Map {
/**
* Sets Cookie on the client machine.
*
* @param name: Cookie name
* @param value: Cookie value
* @param expires: when should this cookie be autmatically deleted. If <b>null</b> - cookie will stay forever
* @param path: Path the cookie belongs to. Default - "/". Can be <b>null</b>.
* @param domain: Domain this cookie belongs to. Default - domain name. Can be <b>null</b>.
* @param secure: If true cookie will be send only over safe connection such as https
* Further documentation at <a href="http://docs.sun.com/source/816-6408-10/cookies.htm">docs.sun.com</a>
* @param name Cookie name
* @param value Cookie value
* @param expires when should this cookie be autmatically deleted. If <b>null</b> - cookie will stay forever
* @param path Path the cookie belongs to. Default - "/". Can be <b>null</b>.
* @param domain Domain this cookie belongs to. Default - domain name. Can be <b>null</b>.
* @param secure If true cookie will be send only over safe connection such as https
* @see further documentation: <a href="http://docs.sun.com/source/816-6408-10/cookies.htm">docs.sun.com</a>
*/
public void setCookie(String name, String value, String expires, String path, String domain, boolean secure)
{
@ -876,14 +876,14 @@ public final class httpHeader extends TreeMap implements Map {
/**
* Sets Cookie on the client machine.
*
* @param name: Cookie name
* @param value: Cookie value
* @param expires: when should this cookie be autmatically deleted. If <b>null</b> - cookie will stay forever
* @param path: Path the cookie belongs to. Default - "/". Can be <b>null</b>.
* @param domain: Domain this cookie belongs to. Default - domain name. Can be <b>null</b>.
* @param name Cookie name
* @param value Cookie value
* @param expires when should this cookie be autmatically deleted. If <b>null</b> - cookie will stay forever
* @param path Path the cookie belongs to. Default - "/". Can be <b>null</b>.
* @param domain Domain this cookie belongs to. Default - domain name. Can be <b>null</b>.
*
* Note: this cookie will be sent over each connection independend if it is safe connection or not.
* Further documentation at <a href="http://docs.sun.com/source/816-6408-10/cookies.htm">docs.sun.com</a>
* @see further documentation: <a href="http://docs.sun.com/source/816-6408-10/cookies.htm">docs.sun.com</a>
*/
public void setCookie(String name, String value, String expires, String path, String domain)
{
@ -892,13 +892,13 @@ public final class httpHeader extends TreeMap implements Map {
/**
* Sets Cookie on the client machine.
*
* @param name: Cookie name
* @param value: Cookie value
* @param expires: when should this cookie be autmatically deleted. If <b>null</b> - cookie will stay forever
* @param path: Path the cookie belongs to. Default - "/". Can be <b>null</b>.
* @param name Cookie name
* @param value Cookie value
* @param expires when should this cookie be autmatically deleted. If <b>null</b> - cookie will stay forever
* @param path Path the cookie belongs to. Default - "/". Can be <b>null</b>.
*
* Note: this cookie will be sent over each connection independend if it is safe connection or not.
* Further documentation at <a href="http://docs.sun.com/source/816-6408-10/cookies.htm">docs.sun.com</a>
* @see further documentation: <a href="http://docs.sun.com/source/816-6408-10/cookies.htm">docs.sun.com</a>
*/
public void setCookie(String name, String value, String expires, String path)
{
@ -907,12 +907,12 @@ public final class httpHeader extends TreeMap implements Map {
/**
* Sets Cookie on the client machine.
*
* @param name: Cookie name
* @param value: Cookie value
* @param expires: when should this cookie be autmatically deleted. If <b>null</b> - cookie will stay forever
* @param name Cookie name
* @param value Cookie value
* @param expires when should this cookie be autmatically deleted. If <b>null</b> - cookie will stay forever
*
* Note: this cookie will be sent over each connection independend if it is safe connection or not.
* Further documentation at <a href="http://docs.sun.com/source/816-6408-10/cookies.htm">docs.sun.com</a>
* @see further documentation: <a href="http://docs.sun.com/source/816-6408-10/cookies.htm">docs.sun.com</a>
*/
public void setCookie(String name, String value, String expires)
{
@ -921,11 +921,11 @@ public final class httpHeader extends TreeMap implements Map {
/**
* Sets Cookie on the client machine.
*
* @param name: Cookie name
* @param value: Cookie value
* @param name Cookie name
* @param value Cookie value
*
* Note: this cookie will be sent over each connection independend if it is safe connection or not. This cookie never expires
* Further documentation at <a href="http://docs.sun.com/source/816-6408-10/cookies.htm">docs.sun.com</a>
* @see further documentation: <a href="http://docs.sun.com/source/816-6408-10/cookies.htm">docs.sun.com</a>
*/
public void setCookie(String name, String value )
{
@ -953,17 +953,17 @@ public final class httpHeader extends TreeMap implements Map {
/**
* Returns an iterator within all properties can be reached.
* Is used mainly by httpd.
* @return iterator to read all request properties.
*
* Example:
*
* <p>Example:</p>
* <pre>
* Iterator it=serverObjects.getRequestProperties();
* while(it.hasNext())
* {
* java.util.Map.Entry e=(java.util.Map.Entry)it.next();
* String propertyName=e.getKey();
* String propertyValue=e.getValue();
* }
* }</pre>
* @return iterator to read all request properties.
*/
public Iterator getCookies()
{

@ -908,7 +908,7 @@ public final class httpc {
*
* @param path The path to the page which should be GET.
* @param requestHeader Prefilled httpHeader.
* @param return Instance of response with the content.
* @return Instance of response with the content.
* @throws IOException
*/
public response GET(String path, httpHeader requestHeader) throws IOException {
@ -929,7 +929,7 @@ public final class httpc {
*
* @param path The path to the page whose header should be get.
* @param requestHeader Prefilled httpHeader.
* @param return Instance of response with the content.
* @return Instance of response with the content.
* @throws IOException
*/
public response HEAD(String path, httpHeader requestHeader) throws IOException {
@ -949,7 +949,7 @@ public final class httpc {
* @param path The path to the page which the post is sent to.
* @param requestHeader Prefilled httpHeader.
* @param ins InputStream with the data to be posted to the server.
* @param return Instance of response with the content.
* @return Instance of response with the content.
* @throws IOException
*/
public response POST(String path, httpHeader requestHeader, InputStream ins) throws IOException {
@ -1815,12 +1815,12 @@ do upload
}
/**
* Returns a {@link InputStream} to read the response body. If the response was encoded using <code>Content-Encoding: gzip</code>
* If the response was encoded using <code>Content-Encoding: gzip</code>
* a {@link GZIPInputStream} is returned. If the <code>Content-Length</code> header was set,
* a {@link httpContentLengthInputStream} is returned which returns <code>-1</code> if the end of the
* response body was reached.
*
* @return
* @return a {@link InputStream} to read the response body
* @throws IOException
*/
public InputStream getContentInputStream() throws IOException {
@ -1836,10 +1836,10 @@ do upload
}
/**
* This method just output the found content into an byte-array and
* This method just outputs the found content into an byte-array and
* returns it.
*
* @return
* @return the found content
* @throws IOException
*/
public byte[] writeContent() throws IOException {
@ -1855,7 +1855,7 @@ do upload
* additionally outputs it to procOS.
*
* @param procOS
* @return
* @return the found content
* @throws IOException
*/
public byte[] writeContent(Object procOS, boolean returnByteArray) throws IOException {

@ -190,7 +190,7 @@ public class URL {
/**
* Escapes the following parts of the url, this object already contains:
* <ul>
* <li>path: see {@link: #escape(String)}</li>
* <li>path: see {@link #escape(String)}</li>
* <li>ref: same as above</li>
* <li>quest: same as above without the ampersand ("&amp;") and the equals symbol</li>
* </ul>

@ -59,14 +59,12 @@ import de.anomic.net.URL;
public interface IResourceInfo {
/**
* Return the resource information as map
* @return
* @return the resource information
*/
public Map getMap();
/**
* Returns the URL of this content
* @return
* @return the URL of this content
*/
public URL getUrl();
@ -95,28 +93,29 @@ public interface IResourceInfo {
public Date getModificationDate();
/**
* Returns the url hash of the content URL
* @return
* @return the url hash of the content URL
*/
public String getUrlHash();
/**
* Specifies if the resource was requested with a
* if modified since date
* @return
* @return the <code>Modified since</code>-header field or <code>null</code>
* if the request didn't contain this field
*/
public Date ifModifiedSince();
/**
* Specifies if the resource was requested with
* client specific information (e.g. cookies for http)
* @return
* @return whether additional client specific information were passed
* along the reuqest for this resource
*/
public boolean requestWithCookie();
/**
* Specifies if the request prohibits indexing
* @return
* @return whether indexing is proibited by this request
*/
public boolean requestProhibitsIndexing();

@ -251,7 +251,7 @@ public final class plasmaHTCache {
/**
* This method changes the HTCache size.<br>
* @param new cache size in bytes
* @param the new cache size in bytes
*/
public void setCacheSize(long newCacheSize) {
this.maxCacheSize = newCacheSize;
@ -1159,7 +1159,7 @@ public final class plasmaHTCache {
/**
* decide upon header information if a specific file should be taken from the cache or not
* @return
* @return whether the file should be taken from the cache
*/
public boolean shallUseCacheForProxy() {
// System.out.println("SHALL READ CACHE: requestHeader = " + requestHeader.toString() + ", responseHeader = " + responseHeader.toString());

@ -769,8 +769,9 @@ public final class plasmaParser {
/**
* This function is used to determine the parser class that should be used for a given
* mimetype ...
* @param mimeType
* @return
* @param mimeType MIME-Type of the resource
* @return the {@link Parser}-class that is supposed to parse the resource of
* the given MIME-Type
*/
private Parser getParser(String mimeType) {

@ -1018,7 +1018,7 @@ public final class serverCore extends serverAbstractThread implements serverThre
}
/**
* @return
* @return whether the {@link Thread} is currently running
*/
public boolean isRunning() {
return this.running;

@ -87,10 +87,10 @@ public final class serverFileUtils {
* @param count the total amount of bytes to copy
* @return Total number of bytes copied.
*
* @see copy(InputStream source, File dest)
* @see copyRange(File source, OutputStream dest, int start)
* @see copy(File source, OutputStream dest)
* @see copy(File source, File dest)
* @see #copy(InputStream source, File dest)
* @see #copyRange(File source, OutputStream dest, int start)
* @see #copy(File source, OutputStream dest)
* @see #copy(File source, File dest)
*/
public static long copy(InputStream source, OutputStream dest, long count) throws IOException {
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
@ -196,10 +196,10 @@ public final class serverFileUtils {
* @param source InputStream
* @param dest File
* @param the amount of bytes to copy
* @see copy(InputStream source, OutputStream dest)
* @see copyRange(File source, OutputStream dest, int start)
* @see copy(File source, OutputStream dest)
* @see copy(File source, File dest)
* @see #copy(InputStream source, OutputStream dest)
* @see #copyRange(File source, OutputStream dest, int start)
* @see #copy(File source, OutputStream dest)
* @see #copy(File source, File dest)
*/
public static void copy(InputStream source, File dest, long count) throws IOException {
FileOutputStream fos = null;
@ -216,10 +216,10 @@ public final class serverFileUtils {
* @param source File
* @param dest OutputStream
* @param start Number of bytes to skip from the beginning of the File
* @see copy(InputStream source, OutputStream dest)
* @see copy(InputStream source, File dest)
* @see copy(File source, OutputStream dest)
* @see copy(File source, File dest)
* @see #copy(InputStream source, OutputStream dest)
* @see #copy(InputStream source, File dest)
* @see #copy(File source, OutputStream dest)
* @see #copy(File source, File dest)
*/
public static void copyRange(File source, OutputStream dest, int start) throws IOException {
InputStream fis = null;
@ -237,10 +237,10 @@ public final class serverFileUtils {
* Copies a File to an OutputStream.
* @param source File
* @param dest OutputStream
* @see copy(InputStream source, OutputStream dest)
* @see copy(InputStream source, File dest)
* @see copyRange(File source, OutputStream dest, int start)
* @see copy(File source, File dest)
* @see #copy(InputStream source, OutputStream dest)
* @see #copy(InputStream source, File dest)
* @see #copyRange(File source, OutputStream dest, int start)
* @see #copy(File source, File dest)
*/
public static void copy(File source, OutputStream dest) throws IOException {
InputStream fis = null;
@ -261,10 +261,10 @@ public final class serverFileUtils {
* @param source File
* @param dest File
* @param count the amount of bytes to copy
* @see copy(InputStream source, OutputStream dest)
* @see copy(InputStream source, File dest)
* @see copyRange(File source, OutputStream dest, int start)
* @see copy(File source, OutputStream dest)
* @see #copy(InputStream source, OutputStream dest)
* @see #copy(InputStream source, File dest)
* @see #copyRange(File source, OutputStream dest, int start)
* @see #copy(File source, OutputStream dest)
*/
public static void copy(File source, File dest, long count) throws IOException {
FileInputStream fis = null;

@ -1,42 +1,42 @@
// serverObjects.java
// -----------------------
// (C) by Michael Peter Christen; mc@anomic.de
// first published on http://www.anomic.de
// Frankfurt, Germany, 2004
// last major change: 05.06.2004
//
// 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
//
// Using this software in any meaning (reading, learning, copying, compiling,
// running) means that you agree that the Author(s) is (are) not responsible
// for cost, loss of data or any harm that may be caused directly or indirectly
// by usage of this softare or this documentation. The usage of this software
// is on your own risk. The installation and usage (starting/running) of this
// software may allow other people or application to access your computer and
// any attached devices and is highly dependent on the configuration of the
// software which must be done by the user of the software; the author(s) is
// (are) also not responsible for proper configuration and usage of the
// software, even if provoked by documentation provided together with
// the software.
//
// Any changes to this file according to the GPL as documented in the file
// gpl.txt aside this file in the shipment you received can be done to the
// lines that follows this copyright notice here, but changes must not be
// done inside the copyright notive above. A re-distribution must contain
// the intact and unchanged copyright notice.
// Contributions and changes to the program code must be marked as such.
//serverObjects.java
//-----------------------
//(C) by Michael Peter Christen; mc@anomic.de
//first published on http://www.anomic.de
//Frankfurt, Germany, 2004
//last major change: 05.06.2004
//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
//Using this software in any meaning (reading, learning, copying, compiling,
//running) means that you agree that the Author(s) is (are) not responsible
//for cost, loss of data or any harm that may be caused directly or indirectly
//by usage of this softare or this documentation. The usage of this software
//is on your own risk. The installation and usage (starting/running) of this
//software may allow other people or application to access your computer and
//any attached devices and is highly dependent on the configuration of the
//software which must be done by the user of the software; the author(s) is
//(are) also not responsible for proper configuration and usage of the
//software, even if provoked by documentation provided together with
//the software.
//Any changes to this file according to the GPL as documented in the file
//gpl.txt aside this file in the shipment you received can be done to the
//lines that follows this copyright notice here, but changes must not be
//done inside the copyright notive above. A re-distribution must contain
//the intact and unchanged copyright notice.
//Contributions and changes to the program code must be marked as such.
/*
Why do we need this Class?
@ -53,7 +53,7 @@
It will also contain special methods that read data from internet-resources
in the background, while data can already be read out of the object.
This shall speed up usage when a slow internet connection is used (dial-up)
*/
*/
package de.anomic.server;
@ -72,68 +72,68 @@ import de.anomic.plasma.plasmaSwitchboard;
public class serverObjects extends Hashtable implements Cloneable {
private static final long serialVersionUID = 1L;
public serverObjects() {
public serverObjects() {
super();
}
public serverObjects(int initialCapacity) {
super(initialCapacity);
}
public serverObjects(Map input) {
super(input);
super(input);
}
/**
* like put, but it replaces any HTML special chars.
*/
public Object putSafeXML(Object key, String value){
return put(key, wikiCode.replaceXMLEntities(value));
return put(key, wikiCode.replaceXMLEntities(value));
}
// new put takes also null values
public Object put(Object key, Object value) {
if (key == null) {
// this does nothing
return null;
} else if (value == null) {
// assigning the null value creates the same effect like removing the element
return super.remove(key);
} else {
return super.put(key, value);
}
if (key == null) {
// this does nothing
return null;
} else if (value == null) {
// assigning the null value creates the same effect like removing the element
return super.remove(key);
} else {
return super.put(key, value);
}
}
// byte[] variant
public byte[] put(String key, byte[] value) {
return (byte[]) this.put((Object) key, (Object) value); //TODO: use wikiCode.replaceXMLEntities?!
return (byte[]) this.put((Object) key, (Object) value); //TODO: use wikiCode.replaceXMLEntities?!
}
// string variant
public String put(String key, String value) {
//return putASIS(key, value);
return (String)putSafeXML(key, value); //XSS Safe!
}
public byte[] putASIS(String key, byte[] value) {
return (byte[]) this.put((Object) key, (Object) value);
}
public byte[] putASIS(String key, byte[] value) {
return (byte[]) this.put((Object) key, (Object) value);
}
public String putASIS(Object key, String value) {
return (String) this.put(key, (Object) value);
}
public String putWiki(Object key, String wikiCode){
//XXX: This is ineffizient, if a lot of wikiCode is used on the same page.
//TODO: Cache the wikiCode Object?
return this.putASIS(key, (new wikiCode(plasmaSwitchboard.getSwitchboard())).transform(wikiCode));
}
public String putWiki(Object key, byte[] wikiCode){
return this.putASIS(key, (new wikiCode(plasmaSwitchboard.getSwitchboard())).transform(wikiCode));
}
}
public String putWiki(Object key, String wikiCode){
//XXX: This is ineffizient, if a lot of wikiCode is used on the same page.
//TODO: Cache the wikiCode Object?
return this.putASIS(key, (new wikiCode(plasmaSwitchboard.getSwitchboard())).transform(wikiCode));
}
public String putWiki(Object key, byte[] wikiCode){
return this.putASIS(key, (new wikiCode(plasmaSwitchboard.getSwitchboard())).transform(wikiCode));
}
// long variant
public long put(String key, long value) {
String result = this.put(key, Long.toString(value));
if (result == null) return 0; else try {
String result = this.put(key, Long.toString(value));
if (result == null) return 0; else try {
return Long.parseLong(result);
} catch (NumberFormatException e) {
return 0;
@ -142,26 +142,26 @@ public class serverObjects extends Hashtable implements Cloneable {
// inc variant: for counters
public long inc(String key) {
String c = (String) super.get(key);
if (c == null) c = "0";
long l = Long.parseLong(c) + 1;
super.put(key, Long.toString(l));
return l;
String c = (String) super.get(key);
if (c == null) c = "0";
long l = Long.parseLong(c) + 1;
super.put(key, Long.toString(l));
return l;
}
// new get with default objects
public Object get(String key, Object dflt) {
Object result = super.get(key);
if (result == null) return dflt; else return result;
Object result = super.get(key);
if (result == null) return dflt; else return result;
}
// string variant
public String get(String key, String dflt) {
return (String) this.get(key, (Object) dflt);
return (String) this.get(key, (Object) dflt);
}
public int getInt(String key, int dflt) {
String s = (String) super.get(key);
String s = (String) super.get(key);
if (s == null) return dflt;
try {
return Integer.parseInt(s);
@ -169,9 +169,9 @@ public class serverObjects extends Hashtable implements Cloneable {
return dflt;
}
}
public long getLong(String key, long dflt) {
String s = (String) super.get(key);
String s = (String) super.get(key);
if (s == null) return dflt;
try {
return Long.parseLong(s);
@ -179,18 +179,18 @@ public class serverObjects extends Hashtable implements Cloneable {
return dflt;
}
}
// returns a set of all values where their key mappes the keyMapper
public String[] getAll(String keyMapper) {
// the keyMapper may contain regular expressions as defined in String.matches
// this method is particulary useful when parsing the result of checkbox forms
ArrayList v = new ArrayList();
Enumeration e = keys();
String key;
while (e.hasMoreElements()) {
key = (String) e.nextElement();
Enumeration e = keys();
String key;
while (e.hasMoreElements()) {
key = (String) e.nextElement();
if (key.matches(keyMapper)) v.add(get(key));
}
}
// make a String[]
String[] result = new String[v.size()];
for (int i = 0; i < v.size(); i++) result[i] = (String) v.get(i);
@ -199,12 +199,12 @@ public class serverObjects extends Hashtable implements Cloneable {
// put all elements of another hastable into the own table
public void putAll(serverObjects add) {
Enumeration e = add.keys();
Object k;
while (e.hasMoreElements()) {
k = e.nextElement();
put(k, add.get(k));
}
Enumeration e = add.keys();
Object k;
while (e.hasMoreElements()) {
k = e.nextElement();
put(k, add.get(k));
}
}
// convenience methods for storing and loading to a file system
@ -230,7 +230,7 @@ public class serverObjects extends Hashtable implements Cloneable {
}
public Object clone() {
return super.clone();
return super.clone();
}
}

@ -118,7 +118,7 @@ public abstract class AbstractService {
*
* @param templateName
* @param args
* @return
* @return the output document
* @throws AxisFault
*/
protected byte[] writeTemplate(String templateName, serverObjects args) throws AxisFault {
@ -250,7 +250,8 @@ public abstract class AbstractService {
/**
* This method was copied from the {@link httpdFileHandler httpdFileHandler-class}
* @param template
* @return
* @return the .class-{@link File} belonging to the given template or <code>null</code>
* if no fitting .class-{@link File} does exist
*/
protected File rewriteClassFile(File template) {
try {
@ -270,7 +271,9 @@ public abstract class AbstractService {
/**
* This method was copied from the {@link httpdFileHandler httpdFileHandler-class}
* @param classFile
* @return
* @return the <code>resond({@link httpHeader}, {@link serverObjects}, {@link serverSwitch})</code>
* {@link Method} of the specified class file or <code>null</code> if this file doesn't contain
* such a method
*/
protected Method rewriteMethod(File classFile) {
Method m = null;
@ -279,9 +282,9 @@ public abstract class AbstractService {
//System.out.println("**DEBUG** loading class file " + classFile);
Class c = this.provider.loadClass(classFile);
Class[] params = new Class[] {
Class.forName("de.anomic.http.httpHeader"),
Class.forName("de.anomic.server.serverObjects"),
Class.forName("de.anomic.server.serverSwitch")};
httpHeader.class, // Class.forName("de.anomic.http.httpHeader"),
serverObjects.class, // Class.forName("de.anomic.server.serverObjects"),
serverSwitch.class }; // Class.forName("de.anomic.server.serverSwitch")};
m = c.getMethod("respond", params);
} catch (ClassNotFoundException e) {
System.out.println("INTERNAL ERROR: class " + classFile + " is missing:" + e.getMessage());
@ -290,7 +293,7 @@ public abstract class AbstractService {
}
//System.out.println("found method: " + m.toString());
return m;
}
}
protected Document convertContentToXML(String contentString) throws Exception {
return convertContentToXML(contentString.getBytes("UTF-8"));

@ -188,7 +188,7 @@ public class StatusService extends AbstractService {
/**
* Query status information about this peer
* @return
* @return the <code>status</code>-{@link Document}
* @throws Exception
*/
public Document getStatus() throws Exception {

@ -770,7 +770,7 @@ public final class yacySeedDB {
}
/**
* @deprecated: Function seems to be unused
* @deprecated Function seems to be unused
*/
public String copyCache(File seedFile, URL seedURL) {
if (seedURL == null) return "COPY - Error: URL not given";

Loading…
Cancel
Save