mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
reverted put-semantics back to as-usual in serverObjects and introduced
an add-method to put in several objects for the same key
This commit is contained in:
parent
0d888ff69e
commit
16d90859b7
|
@ -290,7 +290,7 @@ public class ViewFile {
|
|||
token = tokens.nextElement();
|
||||
if (token.length() > 0) {
|
||||
prop.put("viewMode_words_" + i + "_nr", i + 1);
|
||||
prop.put("viewMode_words_" + i + "_word", token);
|
||||
prop.put("viewMode_words_" + i + "_word", token.toString());
|
||||
prop.put("viewMode_words_" + i + "_dark", dark ? "1" : "0");
|
||||
dark = !dark;
|
||||
i++;
|
||||
|
|
|
@ -101,7 +101,7 @@ public class yacysearchitem {
|
|||
prop.put("remoteResourceSize", Formatter.number(theSearch.query.remote_stored.get(), true));
|
||||
prop.put("remoteIndexCount", Formatter.number(theSearch.query.remote_available.get(), true));
|
||||
prop.put("remotePeerCount", Formatter.number(theSearch.query.remote_peerCount.get(), true));
|
||||
prop.put("navurlBase", QueryParams.navurlBase("html", theSearch.query, null));
|
||||
prop.put("navurlBase", QueryParams.navurlBase("html", theSearch.query, null).toString());
|
||||
final String target_special_pattern = sb.getConfig(SwitchboardConstants.SEARCH_TARGET_SPECIAL_PATTERN, "");
|
||||
|
||||
if (theSearch.query.contentdom == Classification.ContentDomain.TEXT || theSearch.query.contentdom == Classification.ContentDomain.ALL) {
|
||||
|
|
|
@ -366,7 +366,7 @@ public final class HTTPDFileHandler {
|
|||
serverCore.bfHost.remove(conProp.get(HeaderFramework.CONNECTION_PROP_CLIENTIP));
|
||||
|
||||
// parse arguments
|
||||
serverObjects args = new serverObjects(true);
|
||||
serverObjects args = new serverObjects();
|
||||
int argc = 0;
|
||||
if (argsString == null) {
|
||||
// no args here, maybe a POST with multipart extension
|
||||
|
@ -392,7 +392,7 @@ public final class HTTPDFileHandler {
|
|||
Map.Entry<String, byte[]> entry;
|
||||
while (fit.hasNext()) {
|
||||
entry = fit.next();
|
||||
args.put(entry.getKey() + "$file", entry.getValue());
|
||||
args.add(entry.getKey() + "$file", entry.getValue());
|
||||
}
|
||||
}
|
||||
argc = Integer.parseInt(requestHeader.get("ARGC"));
|
||||
|
|
|
@ -329,10 +329,10 @@ public final class HTTPDemon implements serverHandler, Cloneable {
|
|||
if (returncode == UserDB.Entry.PROXY_ALLOK) {
|
||||
return true;
|
||||
}
|
||||
final serverObjects tp = new serverObjects(true);
|
||||
final serverObjects tp = new serverObjects();
|
||||
if (returncode == UserDB.Entry.PROXY_TIMELIMIT_REACHED) {
|
||||
tp.put("limit", "1");//time per day
|
||||
tp.put("limit_timelimit", entry.getTimeLimit());
|
||||
tp.put("limit_timelimit", Long.toString(entry.getTimeLimit()));
|
||||
sendRespondError(prop, session.out, 403, "Internet-Timelimit reached", new File("proxymsg/proxylimits.inc"), tp, null);
|
||||
} else if (returncode == UserDB.Entry.PROXY_NORIGHT){
|
||||
tp.put("limit", "0");
|
||||
|
@ -709,7 +709,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
|
|||
sep = argsString.indexOf("&", eqp + 1);
|
||||
if (sep > 0) {
|
||||
// resulting equations are inserted into the property args with leading '&'
|
||||
args.put(parseArg(argsString.substring(0, eqp)), parseArg(argsString.substring(eqp + 1, sep)));
|
||||
args.add(parseArg(argsString.substring(0, eqp)), parseArg(argsString.substring(eqp + 1, sep)));
|
||||
argsString = argsString.substring(sep + 5);
|
||||
argc++;
|
||||
continue;
|
||||
|
@ -717,7 +717,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
|
|||
sep = argsString.indexOf('&', eqp + 1);
|
||||
if (sep > 0) {
|
||||
// resulting equations are inserted into the property args with leading '&'
|
||||
args.put(parseArg(argsString.substring(0, eqp)), parseArg(argsString.substring(eqp + 1, sep)));
|
||||
args.add(parseArg(argsString.substring(0, eqp)), parseArg(argsString.substring(eqp + 1, sep)));
|
||||
argsString = argsString.substring(sep + 1);
|
||||
argc++;
|
||||
continue;
|
||||
|
@ -864,14 +864,14 @@ public final class HTTPDemon implements serverHandler, Cloneable {
|
|||
// simple text
|
||||
if (item.getContentType() == null || !item.getContentType().contains("charset")) {
|
||||
// old yacy clients use their local default charset, on most systems UTF-8 (I hope ;)
|
||||
args.put(item.getFieldName(), item.getString("UTF-8"));
|
||||
args.add(item.getFieldName(), item.getString("UTF-8"));
|
||||
} else {
|
||||
// use default encoding (given as header or ISO-8859-1)
|
||||
args.put(item.getFieldName(), item.getString());
|
||||
args.add(item.getFieldName(), item.getString());
|
||||
}
|
||||
} else {
|
||||
// file
|
||||
args.put(item.getFieldName(), item.getName());
|
||||
args.add(item.getFieldName(), item.getName());
|
||||
fileContent = FileUtils.read(item.getInputStream(), (int) item.getSize());
|
||||
item.getInputStream().close();
|
||||
files.put(item.getFieldName(), fileContent);
|
||||
|
@ -1075,7 +1075,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
|
|||
}
|
||||
|
||||
// set rewrite values
|
||||
final serverObjects tp = new serverObjects(true);
|
||||
final serverObjects tp = new serverObjects();
|
||||
|
||||
String clientIP = (String) conProp.get(HeaderFramework.CONNECTION_PROP_CLIENTIP); if (clientIP == null) clientIP = Domains.LOCALHOST;
|
||||
|
||||
|
@ -1083,17 +1083,17 @@ public final class HTTPDemon implements serverHandler, Cloneable {
|
|||
final InetAddress hostAddress = Domains.dnsResolve(clientIP);
|
||||
if (hostAddress == null) {
|
||||
tp.put("host", Domains.myPublicLocalIP().getHostAddress());
|
||||
tp.put("port", serverCore.getPortNr(switchboard.getConfig("port", "8090")));
|
||||
tp.put("port", Integer.toString(serverCore.getPortNr(switchboard.getConfig("port", "8090"))));
|
||||
} else if (hostAddress.isSiteLocalAddress() || hostAddress.isLoopbackAddress()) {
|
||||
tp.put("host", Domains.myPublicLocalIP().getHostAddress());
|
||||
tp.put("port", serverCore.getPortNr(switchboard.getConfig("port", "8090")));
|
||||
tp.put("port", Integer.toString(serverCore.getPortNr(switchboard.getConfig("port", "8090"))));
|
||||
} else {
|
||||
tp.put("host", switchboard.myPublicIP());
|
||||
tp.put("port", Integer.toString(serverCore.getPortNr(switchboard.getConfig("port", "8090"))));
|
||||
}
|
||||
|
||||
tp.put("peerName", (getAlternativeResolver() == null) ? "" : getAlternativeResolver().myName());
|
||||
tp.put("errorMessageType", errorcase);
|
||||
tp.put("errorMessageType", Integer.toString(errorcase));
|
||||
tp.put("httpStatus", Integer.toString(httpStatusCode) + " " + httpStatusText);
|
||||
tp.put("requestMethod", (String) conProp.get(HeaderFramework.CONNECTION_PROP_METHOD));
|
||||
tp.put("requestURL", urlString);
|
||||
|
@ -1116,13 +1116,13 @@ public final class HTTPDemon implements serverHandler, Cloneable {
|
|||
|
||||
// building the stacktrace
|
||||
if (stackTrace != null) {
|
||||
tp.put("printStackTrace",1);
|
||||
tp.put("printStackTrace", "1");
|
||||
final ByteBuffer errorMsg = new ByteBuffer(100);
|
||||
stackTrace.printStackTrace(new PrintStream(errorMsg));
|
||||
tp.put("printStackTrace_exception", stackTrace.toString());
|
||||
tp.put("printStackTrace_stacktrace", UTF8.String(errorMsg.getBytes()));
|
||||
} else {
|
||||
tp.put("printStackTrace", 0);
|
||||
tp.put("printStackTrace", "0");
|
||||
}
|
||||
|
||||
// Generated Tue, 23 Aug 2005 11:19:14 GMT by brain.wg (squid/2.5.STABLE3)
|
||||
|
|
|
@ -511,7 +511,7 @@ public final class TemplateEngine {
|
|||
// arg1 = test input; arg2 = replacement for pattern 'test'; arg3 = default replacement
|
||||
try {
|
||||
final InputStream i = new ByteArrayInputStream(UTF8.getBytes(args[0]));
|
||||
final serverObjects h = new serverObjects(true);
|
||||
final serverObjects h = new serverObjects();
|
||||
h.put("test", args[1]);
|
||||
writeTemplate(new PushbackInputStream(i, 100), System.out, h, UTF8.getBytes(args[2]));
|
||||
System.out.flush();
|
||||
|
|
|
@ -89,7 +89,6 @@ public class serverObjects implements Serializable, Cloneable {
|
|||
private final static Pattern patternT = Pattern.compile("\t");
|
||||
|
||||
private boolean localized = true;
|
||||
private boolean allowMultipleEntries = false;
|
||||
|
||||
private final static char BOM = '\uFEFF'; // ByteOrderMark character that may appear at beginnings of Strings (Browser may append that)
|
||||
private final MultiMapSolrParams map;
|
||||
|
@ -99,12 +98,6 @@ public class serverObjects implements Serializable, Cloneable {
|
|||
this.map = new MultiMapSolrParams(new HashMap<String, String[]>());
|
||||
}
|
||||
|
||||
public serverObjects(final boolean allowMultipleEntries) {
|
||||
super();
|
||||
this.allowMultipleEntries = allowMultipleEntries;
|
||||
this.map = new MultiMapSolrParams(new HashMap<String, String[]>());
|
||||
}
|
||||
|
||||
protected serverObjects(serverObjects o) {
|
||||
super();
|
||||
this.map = o.map;
|
||||
|
@ -171,15 +164,29 @@ public class serverObjects implements Serializable, Cloneable {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a key-value pair of Objects to the map.
|
||||
* @param key This method will do nothing if the key is <code>null</code>.
|
||||
* @param value The value that should be mapped to the key.
|
||||
* If value is <code>null</code>, then the element at <code>key</code>
|
||||
* is removed from the map.
|
||||
* @return The value that was added to the map.
|
||||
* @see java.util.Hashtable#insert(K, V)
|
||||
*/
|
||||
public void add(final String key, final String value) {
|
||||
if (key == null) {
|
||||
// this does nothing
|
||||
return;
|
||||
}
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
String[] a = map.getMap().get(key);
|
||||
if (a == null) {
|
||||
map.getMap().put(key, new String[]{value});
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
if (a[i].equals(value)) return;
|
||||
}
|
||||
String[] aa = new String[a.length + 1];
|
||||
System.arraycopy(a, 0, aa, 0, a.length);
|
||||
aa[a.length] = value;
|
||||
map.getMap().put(key, aa);
|
||||
return;
|
||||
}
|
||||
|
||||
public void put(final String key, final String value) {
|
||||
if (key == null) {
|
||||
// this does nothing
|
||||
|
@ -195,19 +202,19 @@ public class serverObjects implements Serializable, Cloneable {
|
|||
map.getMap().put(key, new String[]{value});
|
||||
return;
|
||||
}
|
||||
if (this.allowMultipleEntries) {
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
if (a[i].equals(value)) return;
|
||||
}
|
||||
String[] aa = new String[a.length + 1];
|
||||
System.arraycopy(a, 0, aa, 0, a.length);
|
||||
aa[a.length] = value;
|
||||
map.getMap().put(key, aa);
|
||||
return;
|
||||
}
|
||||
map.getMap().put(key, new String[]{value});
|
||||
}
|
||||
|
||||
public void add(final String key, final byte[] value) {
|
||||
if (value == null) return;
|
||||
add(key, UTF8.String(value));
|
||||
}
|
||||
|
||||
public void put(final String key, final byte[] value) {
|
||||
if (value == null) return;
|
||||
put(key, UTF8.String(value));
|
||||
}
|
||||
|
||||
public void put(final String key, final String[] values) {
|
||||
if (key == null) {
|
||||
// this does nothing
|
||||
|
@ -221,34 +228,6 @@ public class serverObjects implements Serializable, Cloneable {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a key-value pair of Objects to the map.
|
||||
* @param key This method will do nothing if the key is <code>null</code>.
|
||||
* @param value The value that should be mapped to the key.
|
||||
* If value is <code>null</code>, then the element at <code>key</code>
|
||||
* is removed from the map.
|
||||
* @return The value that was added to the map.
|
||||
* @see java.util.Hashtable#insert(K, V)
|
||||
*/
|
||||
public void put(final String key, final StringBuilder value) {
|
||||
if (key == null) {
|
||||
// this does nothing
|
||||
return;
|
||||
}
|
||||
put(key, value.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add byte array to the map, value is kept as it is.
|
||||
* @param key key name as String.
|
||||
* @param value mapped value as a byte array.
|
||||
* @return the previous value as String.
|
||||
*/
|
||||
public void put(final String key, final byte[] value) {
|
||||
if (value == null) return;
|
||||
put(key, UTF8.String(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an unformatted String representation of a double/float value
|
||||
* to the map.
|
||||
|
|
Loading…
Reference in New Issue
Block a user