- added ViewProfile as rdf in foaf syntax

- added link to rdf and vCard version on html page
- can be seen on http://localhost:8080/ViewProfile.html?hash=localhash
- more generics

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4411 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 17 years ago
parent 1b930a6702
commit 4a80902081

@ -3,7 +3,7 @@ javacSource=1.5
javacTarget=1.5
# Release Configuration
releaseVersion=0.563
releaseVersion=0.564
stdReleaseFile=yacy_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz
embReleaseFile=yacy_emb_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz
proReleaseFile=yacy_pro_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz

@ -3,6 +3,7 @@
<head>
<title>YaCy '#[clientname]#': Remote Peer Profile</title>
<link rel="alternate" type="text/x-vcard" title="vCard" href="ViewProfile.vcf?hash=#[hash]#" />
<link rel="meta" type="application/rdf+xml" title="rdf:foaf" href="ViewProfile.rdf?hash=#[hash]#" />
#%env/templates/metas.template%#
</head>
<body id="ViewProfile">
@ -25,7 +26,7 @@
<p class="error">The peer #[peername]# is not online.</p>
::
<h3>This is the Profile of #[peername]#:</h3>
<fieldset>
<dl class="pairs">
<dt>Name</dt>
<dd>#(name)#&nbsp;::#[value]##(/name)#</dd>
@ -58,7 +59,10 @@
<dd>#[value]#&nbsp;</dd>
#{/other}#
</dl>
</fieldset>
#(/success)#
<p>View this profile as <a rel="meta" type="application/rdf+xml" title="rdf:foaf" href="ViewProfile.rdf?hash=#[hash]#"/>rdf:foaf</a> or
<a rel="alternate" type="text/x-vcard" title="vCard" href="ViewProfile.vcf?hash=#[hash]#" />vCard</a></p>
#(display)#
#%env/templates/simplefooter.template%#
::

@ -74,7 +74,6 @@ import org.xml.sax.SAXException;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.htmlFilter.htmlFilterWriter;
import de.anomic.plasma.plasmaCondenser;
import de.anomic.kelondro.kelondroCloneableIterator;
import de.anomic.kelondro.kelondroDyn;
import de.anomic.kelondro.kelondroException;
@ -82,6 +81,7 @@ import de.anomic.kelondro.kelondroMapObjects;
import de.anomic.kelondro.kelondroNaturalOrder;
import de.anomic.kelondro.kelondroObjects;
import de.anomic.kelondro.kelondroObjectsMapEntry;
import de.anomic.plasma.plasmaCondenser;
import de.anomic.server.serverDate;
import de.anomic.server.serverFileUtils;
import de.anomic.server.logging.serverLog;
@ -722,15 +722,15 @@ public class bookmarksDB {
public static final String TAG_NAME="tagName";
private String tagHash;
private Map mem;
private Set urlHashes;
private Set<String> urlHashes;
public Tag(String hash, Map map){
tagHash=hash;
mem=map;
if(mem.containsKey(URL_HASHES))
urlHashes=listManager.string2set((String) mem.get(URL_HASHES));
urlHashes = listManager.string2set((String) mem.get(URL_HASHES));
else
urlHashes=new HashSet();
urlHashes = new HashSet();
}
public Tag(String name, HashSet entries){
tagHash=tagHash(name);
@ -776,7 +776,7 @@ public class bookmarksDB {
}
return "notagname";
}
public Set getUrlHashes(){
public Set<String> getUrlHashes(){
return urlHashes;
}
public boolean hasPublicItems(){

@ -154,10 +154,10 @@ public class knwikiParser implements wikiParser {
new DefinitionListToken(),
new TableToken()
};
ArrayList r = new ArrayList();
for (int i=0, k, j; i<tokens.length; i++)
ArrayList<String> r = new ArrayList<String>();
for (int i = 0, k, j; i < tokens.length; i++)
if (tokens[i].getBlockElementNames() != null)
for (j=0; j<tokens[i].getBlockElementNames().length; j++) {
for (j = 0; j < tokens[i].getBlockElementNames().length; j++) {
if (tokens[i].getBlockElementNames()[j] == null) continue;
if ((k = tokens[i].getBlockElementNames()[j].indexOf(' ')) > 1) {
r.add(tokens[i].getBlockElementNames()[j].substring(0, k));
@ -265,7 +265,7 @@ public class knwikiParser implements wikiParser {
int startLen = escapeBegin.length();
int endLen = escapeEnd.length();
ArrayList r = new ArrayList();
ArrayList<Text> r = new ArrayList<Text>();
boolean escaped = text.startsWith(escapeBegin);
if (escaped) r.add(new Text("", false, true));
int i, j = 0;

@ -168,15 +168,15 @@ public class LinkToken extends AbstractToken {
private Link[] getLinksFromBookmarkTag(String tagName) {
Tag tag = this.sb.bookmarksDB.getTag(bookmarksDB.tagHash(tagName));
if (tag == null) return null;
ArrayList r = new ArrayList();
Iterator it = tag.getUrlHashes().iterator();
ArrayList<Link> r = new ArrayList<Link>();
Iterator<String> it = tag.getUrlHashes().iterator();
String hash;
Bookmark bm;
while (it.hasNext())
if ((hash = (String)it.next()) != null)
if ((hash = it.next()) != null)
if ((bm = this.sb.bookmarksDB.getBookmark(hash)) != null)
r.add(new Link(bm.getUrl(), bm.getTitle(), bm.getDescription()));
return (Link[])r.toArray(new Link[r.size()]);
return (Link[]) r.toArray(new Link[r.size()]);
}
private static class Link {

@ -68,7 +68,7 @@ public class ListToken extends AbstractToken {
this.listElement = "li";
this.recursion = true;
this.pattern = new Pattern[] { Pattern.compile("^[" + firstChar + "]([^\n]|\n[" + firstChar + "])*", Pattern.MULTILINE) };
ArrayList r = new ArrayList();
ArrayList<String> r = new ArrayList<String>();
if (this.listBlockElement != null) {
if (this.recursion) r.add(this.listBlockElement);
if (this.listElement != null) r.add(this.listElement);
@ -82,7 +82,7 @@ public class ListToken extends AbstractToken {
this.listElement = listElement;
this.recursion = true;
this.pattern = new Pattern[] { Pattern.compile("^[" + firstChar + "]([^\n]|\n[" + firstChar + "])*", Pattern.MULTILINE) };
ArrayList r = new ArrayList();
ArrayList<String> r = new ArrayList<String>();
if (this.listBlockElement != null) {
if (this.recursion) r.add(this.listBlockElement);
if (this.listElement != null) r.add(this.listElement);
@ -96,7 +96,7 @@ public class ListToken extends AbstractToken {
this.listElement = listElement;
this.recursion = recursion;
this.pattern = new Pattern[] { Pattern.compile("^[" + firstChar + "]([^\n]|\n[" + firstChar + "])*", Pattern.MULTILINE) };
ArrayList r = new ArrayList();
ArrayList<String> r = new ArrayList<String>();
if (this.listBlockElement != null) {
if (this.recursion) r.add(this.listBlockElement);
if (this.listElement != null) r.add(this.listElement);

@ -66,13 +66,13 @@ public class SimpleToken extends AbstractToken {
this.definitionList = definitionList;
int i;
if (isBlockElements) {
ArrayList r = new ArrayList();
ArrayList<String> r = new ArrayList<String>();
int j;
for (i=0; i<definitionList.length; i++)
for (i = 0; i < definitionList.length; i++)
if (definitionList[i] != null)
for (j=0; j<definitionList[i].length; j++)
for (j = 0; j < definitionList[i].length; j++)
r.add(definitionList[i][j]);
this.blockElements = (String[])r.toArray(new String[r.size()]);
this.blockElements = (String[]) r.toArray(new String[r.size()]);
} else {
this.blockElements = null;
}

@ -91,7 +91,7 @@ public class TableToken extends AbstractToken {
// from de.anomic.data.wikiCode.java.parseTableProperties, modified by [FB]
private static final String[] tps = { "rowspan", "colspan", "vspace", "hspace", "cellspacing", "cellpadding", "border" };
private static final HashMap/* <String,String[]> */ ps = new HashMap();
private static final HashMap<String, String[]> ps = new HashMap<String, String[]>();
static {
Arrays.sort(tps);
String[] array;

@ -38,11 +38,11 @@ public abstract class htmlFilterAbstractScraper implements htmlFilterScraper {
public static final char rb = '>';
public static final char sl = '/';
private TreeSet tags0;
private TreeSet tags1;
private TreeSet<String> tags0;
private TreeSet<String> tags1;
// define a translation table for html character codings
private static HashMap trans = new HashMap(300);
private static HashMap<String, String> trans = new HashMap<String, String>(300);
static {
trans.put("&quot;", "\""); //Anf&uuml;hrungszeichen oben
trans.put("&amp;", "&"); //Ampersand-Zeichen, kaufm&auml;nnisches Und
@ -290,7 +290,7 @@ public abstract class htmlFilterAbstractScraper implements htmlFilterScraper {
}
public htmlFilterAbstractScraper(TreeSet tags0, TreeSet tags1) {
public htmlFilterAbstractScraper(TreeSet<String> tags0, TreeSet<String> tags1) {
this.tags0 = tags0;
this.tags1 = tags1;
}

@ -45,20 +45,20 @@ import java.util.TreeSet;
public abstract class htmlFilterAbstractTransformer implements htmlFilterTransformer {
private TreeSet tags0;
private TreeSet tags1;
private TreeSet<String> tags0;
private TreeSet<String> tags1;
public htmlFilterAbstractTransformer(TreeSet tags0, TreeSet tags1) {
this.tags0 = tags0;
this.tags1 = tags1;
public htmlFilterAbstractTransformer(TreeSet<String> tags0, TreeSet<String> tags1) {
this.tags0 = tags0;
this.tags1 = tags1;
}
public boolean isTag0(String tag) {
return tags0.contains(tag);
return tags0.contains(tag);
}
public boolean isTag1(String tag) {
return tags1.contains(tag);
return tags1.contains(tag);
}
//the 'missing' method that shall be implemented:
@ -71,11 +71,11 @@ public abstract class htmlFilterAbstractTransformer implements htmlFilterTransfo
// the other methods must take into account to construct the return value correctly
public char[] transformTag0(String tagname, Properties tagopts, char quotechar) {
return htmlFilterWriter.genTag0(tagname, tagopts, quotechar);
return htmlFilterWriter.genTag0(tagname, tagopts, quotechar);
}
public char[] transformTag1(String tagname, Properties tagopts, char[] text, char quotechar) {
return htmlFilterWriter.genTag1(tagname, tagopts, text, quotechar);
return htmlFilterWriter.genTag1(tagname, tagopts, text, quotechar);
}
public void close() {

@ -59,8 +59,8 @@ import de.anomic.server.serverCharBuffer;
public class htmlFilterContentTransformer extends htmlFilterAbstractTransformer implements htmlFilterTransformer {
// statics: for initialisation of the HTMLFilterAbstractTransformer
private static TreeSet linkTags0;
private static TreeSet linkTags1;
private static TreeSet<String> linkTags0;
private static TreeSet<String> linkTags1;
private static final Collator insensitiveCollator = Collator.getInstance(Locale.US);
static {
@ -69,15 +69,15 @@ public class htmlFilterContentTransformer extends htmlFilterAbstractTransformer
}
static {
linkTags0 = new TreeSet(insensitiveCollator);
linkTags0 = new TreeSet<String>(insensitiveCollator);
linkTags0.add("img");
linkTags0.add("input");
linkTags1 = new TreeSet(insensitiveCollator);
linkTags1 = new TreeSet<String>(insensitiveCollator);
linkTags1.add("a");
}
private ArrayList bluelist = null;
private ArrayList<String> bluelist = null;
public htmlFilterContentTransformer() {
super(linkTags0, linkTags1);
@ -85,8 +85,8 @@ public class htmlFilterContentTransformer extends htmlFilterAbstractTransformer
public void init(String initarg) {
if (bluelist == null) {
// here, the initarg is used to load a list of bluelisted words
bluelist = new ArrayList();
// here, the init arg is used to load a list of blue-listed words
bluelist = new ArrayList<String>();
File f = new File(initarg);
if (f.canRead()) {
try {
@ -127,8 +127,8 @@ public class htmlFilterContentTransformer extends htmlFilterAbstractTransformer
return false;
}
public ArrayList getStrings(byte[] text){
ArrayList result=new ArrayList();
public ArrayList<String> getStrings(byte[] text){
ArrayList<String> result = new ArrayList<String>();
serverByteBuffer sbb = new serverByteBuffer(text);
serverByteBuffer[] sbbs = httpTemplate.splitQuotations(sbb);

@ -42,7 +42,7 @@ package de.anomic.htmlFilter;
import de.anomic.yacy.yacyURL;
public class htmlFilterImageEntry implements Comparable {
public class htmlFilterImageEntry implements Comparable<htmlFilterImageEntry> {
private yacyURL url;
private String alt;
@ -86,13 +86,12 @@ public class htmlFilterImageEntry implements Comparable {
return 0xFFFF0000 | (url.hashCode() & 0xFFFF);
}
public int compareTo(Object h) {
public int compareTo(htmlFilterImageEntry h) {
// this is needed if this object is stored in a TreeSet
// this method uses the image-size ordering from the hashCode method
// assuming that hashCode would return a 'perfect hash' this method would
// create a total ordering on images with respect on the image size
assert (url != null);
assert (h instanceof htmlFilterImageEntry);
if (this.url.toNormalform(true, true).equals(((htmlFilterImageEntry) h).url.toNormalform(true, true))) return 0;
int thc = this.hashCode();
int ohc = ((htmlFilterImageEntry) h).hashCode();
@ -101,8 +100,7 @@ public class htmlFilterImageEntry implements Comparable {
return this.url.toString().compareTo(((htmlFilterImageEntry) h).url.toString());
}
public boolean equals(Object o) {
if (!(o instanceof htmlFilterImageEntry)) return false;
public boolean equals(htmlFilterImageEntry o) {
return compareTo(o) == 0;
}
}

@ -167,7 +167,7 @@ public final class htmlFilterWriter extends Writer {
// a helper method for pretty-printing of properties for html tags
public static char[] genOpts(Properties prop, char quotechar) {
Enumeration e = prop.propertyNames();
Enumeration<?> e = prop.propertyNames();
serverCharBuffer bb = new serverCharBuffer(prop.size() * 40);
String key;
while (e.hasMoreElements()) {

@ -721,9 +721,9 @@ public final class httpHeader extends TreeMap<String, Object> implements Map<Str
// setting the status text if it was not already set
if ((httpStatusText == null)||(httpStatusText.length()==0)) {
if (httpVersion.equals("HTTP/1.0") && httpHeader.http1_0.containsKey(Integer.toString(httpStatusCode)))
httpStatusText = (String) httpHeader.http1_0.get(Integer.toString(httpStatusCode));
httpStatusText = httpHeader.http1_0.get(Integer.toString(httpStatusCode));
else if (httpVersion.equals("HTTP/1.1") && httpHeader.http1_1.containsKey(Integer.toString(httpStatusCode)))
httpStatusText = (String) httpHeader.http1_1.get(Integer.toString(httpStatusCode));
httpStatusText = httpHeader.http1_1.get(Integer.toString(httpStatusCode));
else httpStatusText = "Unknown";
}
@ -802,13 +802,24 @@ public final class httpHeader extends TreeMap<String, Object> implements Map<Str
/**
* Implementation of Map.Entry. Structure that hold two values - exactly what we need!
*/
class Entry implements Map.Entry {
private Object Key;
private Object Value;
Entry(Object Key, String Value){this.Key=Key;this.Value=Value;}
public Object getKey() {return Key;}
public Object getValue() {return Value;}
public Object setValue(Object Value) {return(this.Value=Value);}
class Entry implements Map.Entry<String, Object> {
private String k;
private Object v;
Entry(String k, Object v) {
this.k = k;
this.v = v;
}
public String getKey() {
return k;
}
public Object getValue() {
return v;
}
public Object setValue(Object v) {
Object r = this.v;
this.v = v;
return r;
}
}
/**
@ -895,10 +906,10 @@ public final class httpHeader extends TreeMap<String, Object> implements Map<Str
setCookie( name, value, null, null, null, false);
}
public String getHeaderCookies(){
Iterator it = this.entrySet().iterator();
Iterator<Map.Entry<String, Object>> it = this.entrySet().iterator();
while(it.hasNext())
{
java.util.Map.Entry e = (java.util.Map.Entry) it.next();
Map.Entry<String, Object> e = it.next();
//System.out.println(""+e.getKey()+" : "+e.getValue());
if(e.getKey().equals("Cookie"))
{

@ -70,8 +70,8 @@ public final class httpRemoteProxyConfig {
private String remoteProxyNoProxy = "";
private String[] remoteProxyNoProxyPatterns = null;
public final HashSet remoteProxyAllowProxySet = new HashSet();
public final HashSet remoteProxyDisallowProxySet = new HashSet();
public final HashSet<String> remoteProxyAllowProxySet = new HashSet<String>();
public final HashSet<String> remoteProxyDisallowProxySet = new HashSet<String>();
public boolean useProxy() {
return this.remoteProxyUse;

@ -158,14 +158,14 @@ public final class httpTemplate {
};
public static serverByteBuffer[] splitQuotations(serverByteBuffer text) {
List l = splitQuotation(text, 0);
List<serverByteBuffer> l = splitQuotation(text, 0);
serverByteBuffer[] sbbs = new serverByteBuffer[l.size()];
for (int i = 0; i < l.size(); i++) sbbs[i] = (serverByteBuffer) l.get(i);
for (int i = 0; i < l.size(); i++) sbbs[i] = l.get(i);
return sbbs;
}
public static List splitQuotation(serverByteBuffer text, int qoff) {
ArrayList l = new ArrayList();
public static List<serverByteBuffer> splitQuotation(serverByteBuffer text, int qoff) {
ArrayList<serverByteBuffer> l = new ArrayList<serverByteBuffer>();
if (qoff >= meta_quotation.length) {
if (text.length() > 0) l.add(text);
return l;
@ -229,14 +229,14 @@ public final class httpTemplate {
return false;
}
public static void writeTemplate(InputStream in, OutputStream out, Hashtable pattern, byte[] dflt) throws IOException {
public static void writeTemplate(InputStream in, OutputStream out, Hashtable<String, String> pattern, byte[] dflt) throws IOException {
writeTemplate(in, out, pattern, dflt, new byte[0]);
}
/**
* Reads a input stream, and writes the data with replaced templates on a output stream
*/
public static byte[] writeTemplate(InputStream in, OutputStream out, Hashtable pattern, byte[] dflt, byte[] prefix) throws IOException {
public static byte[] writeTemplate(InputStream in, OutputStream out, Hashtable<String, String> pattern, byte[] dflt, byte[] prefix) throws IOException {
PushbackInputStream pis = new PushbackInputStream(in, 100);
ByteArrayOutputStream keyStream;
byte[] key;
@ -487,7 +487,7 @@ public final class httpTemplate {
return structure.getBytes();
}
public static byte[] replacePattern(String key, Hashtable pattern, byte dflt[]) {
public static byte[] replacePattern(String key, Hashtable<String, String> pattern, byte dflt[]) {
byte[] replacement;
Object value;
if (pattern.containsKey(key)) {
@ -515,8 +515,8 @@ public final class httpTemplate {
// arg1 = test input; arg2 = replacement for pattern 'test'; arg3 = default replacement
try {
InputStream i = new ByteArrayInputStream(args[0].getBytes());
Hashtable h = new Hashtable();
h.put("test", args[1].getBytes());
Hashtable<String, String> h = new Hashtable<String, String>();
h.put("test", args[1]);
writeTemplate(new PushbackInputStream(i, 100), System.out, h, args[2].getBytes());
System.out.flush();
} catch (Exception e) {
@ -526,10 +526,10 @@ public final class httpTemplate {
/*
* loads all Files from path into a filename->content HashMap
*/
public static HashMap loadTemplates(File path) {
public static HashMap<String, String> loadTemplates(File path) {
// reads all templates from a path
// we use only the folder from the given file path
HashMap result = new HashMap();
HashMap<String, String> result = new HashMap<String, String>();
if (path == null) return result;
if (!(path.isDirectory())) path = path.getParentFile();
if ((path == null) || (!(path.isDirectory()))) return result;

@ -107,7 +107,7 @@ public final class httpd implements serverHandler {
*/
//TODO: Load this from a file
private static final HashSet disallowZippedContentEncoding = new HashSet(Arrays.asList(new String[]{
private static final HashSet<String> disallowZippedContentEncoding = new HashSet<String>(Arrays.asList(new String[]{
".gz", ".tgz", ".jpg", ".jpeg", ".gif", ".zip", ".rar", ".bz2", ".lha", ".jar", ".rpm", ".arc", ".arj", ".wmv", ".png", ".ico", ".bmp"
}));
@ -121,8 +121,8 @@ public final class httpd implements serverHandler {
private static String virtualHost = null;
public static boolean keepAliveSupport = false;
private static HashMap YaCyHopAccessRequester = new HashMap();
private static HashMap YaCyHopAccessTargets = new HashMap();
private static HashMap<String, Long> YaCyHopAccessRequester = new HashMap<String, Long>();
private static HashMap<String, Long> YaCyHopAccessTargets = new HashMap<String, Long>();
// class objects
private serverCore.Session session; // holds the session object of the calling class
@ -381,8 +381,8 @@ public final class httpd implements serverHandler {
return true;
}
private static long lastAccessDelta(HashMap accessTable, String domain) {
Long lastAccess = (Long) accessTable.get(domain);
private static long lastAccessDelta(HashMap<String, Long> accessTable, String domain) {
Long lastAccess = accessTable.get(domain);
if (lastAccess == null) return Long.MAX_VALUE; // never accessed
return System.currentTimeMillis() - lastAccess.longValue();
}
@ -1187,9 +1187,9 @@ public final class httpd implements serverHandler {
tp.put("errorMessageType_file", (detailedErrorMsgFile == null) ? "" : detailedErrorMsgFile.toString());
if ((detailedErrorMsgValues != null) && (detailedErrorMsgValues.size() > 0)) {
// rewriting the value-names and add the proper name prefix:
Iterator nameIter = detailedErrorMsgValues.keySet().iterator();
Iterator<String> nameIter = detailedErrorMsgValues.keySet().iterator();
while (nameIter.hasNext()) {
String name = (String) nameIter.next();
String name = nameIter.next();
tp.put("errorMessageType_" + name, detailedErrorMsgValues.get(name));
}
}
@ -1405,12 +1405,11 @@ public final class httpd implements serverHandler {
httpHeader outgoingHeader=requestProperties.getOutgoingHeader();
if (outgoingHeader!=null)
{*/
Iterator it=header.getCookies();
while(it.hasNext())
{
Iterator<httpHeader.Entry> it = header.getCookies();
while(it.hasNext()) {
//Append user properties to the main String
//TODO: Should we check for user properites. What if they intersect properties that are already in header?
java.util.Map.Entry e=(java.util.Map.Entry)it.next();
httpHeader.Entry e = it.next();
headerStringBuffer.append(e.getKey()).append(": ").append(e.getValue()).append("\r\n");
}
@ -1419,13 +1418,13 @@ public final class httpd implements serverHandler {
}*/
// write header
Iterator i = header.keySet().iterator();
Iterator<String> i = header.keySet().iterator();
String key;
char tag;
int count;
//System.out.println("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv");
while (i.hasNext()) {
key = (String) i.next();
key = i.next();
tag = key.charAt(0);
if ((tag != '*') && (tag != '#')) { // '#' in key is reserved for proxy attributes as artificial header values
count = header.keyCount(key);

@ -54,7 +54,7 @@ import java.util.HashMap;
public class httpdByteCountInputStream extends FilterInputStream {
private static final Object syncObject = new Object();
private static final HashMap byteCountInfo = new HashMap(2);
private static final HashMap<String, Long> byteCountInfo = new HashMap<String, Long>(2);
private static long globalByteCount = 0;
private boolean finished = false;
@ -144,7 +144,7 @@ public class httpdByteCountInputStream extends FilterInputStream {
if (this.byteCountAccountName != null) {
long lastByteCount = 0;
if (byteCountInfo.containsKey(this.byteCountAccountName)) {
lastByteCount = ((Long)byteCountInfo.get(this.byteCountAccountName)).longValue();
lastByteCount = byteCountInfo.get(this.byteCountAccountName).longValue();
}
lastByteCount += this.byteCount;
byteCountInfo.put(this.byteCountAccountName,new Long(lastByteCount));

@ -55,7 +55,7 @@ public class httpdByteCountOutputStream extends BufferedOutputStream {
private static long globalByteCount = 0;
private boolean finished = false;
private static final HashMap byteCountInfo = new HashMap(2);
private static final HashMap<String, Long> byteCountInfo = new HashMap<String, Long>(2);
protected long byteCount;
protected String byteCountAccountName = null;

@ -116,10 +116,8 @@ public final class httpdFileHandler {
private static final boolean safeServletsMode = false; // if true then all servlets are called synchronized
// class variables
private static final Properties mimeTable = new Properties();
private static final serverClassLoader provider;
private static final HashMap templates = new HashMap();
private static serverSwitch switchboard;
private static plasmaSwitchboard sb = plasmaSwitchboard.getSwitchboard();
@ -130,8 +128,8 @@ public final class httpdFileHandler {
private static File htDefaultPath = null;
private static File htLocalePath = null;
private static final HashMap templateCache;
private static final HashMap templateMethodCache;
private static final HashMap<File, SoftReference<byte[]>> templateCache;
private static final HashMap<File, SoftReference<Method>> templateMethodCache;
public static boolean useTemplateCache = false;
@ -141,8 +139,8 @@ public final class httpdFileHandler {
static {
serverSwitch switchboard = plasmaSwitchboard.getSwitchboard();
useTemplateCache = switchboard.getConfig("enableTemplateCache","true").equalsIgnoreCase("true");
templateCache = (useTemplateCache)? new HashMap() : new HashMap(0);
templateMethodCache = (useTemplateCache) ? new HashMap() : new HashMap(0);
templateCache = (useTemplateCache)? new HashMap<File, SoftReference<byte[]>>() : new HashMap<File, SoftReference<byte[]>>(0);
templateMethodCache = (useTemplateCache) ? new HashMap<File, SoftReference<Method>>() : new HashMap<File, SoftReference<Method>>(0);
// create a class loader
provider = new serverClassLoader(/*this.getClass().getClassLoader()*/);
@ -396,11 +394,11 @@ public final class httpdFileHandler {
// check for cross site scripting - attacks in request arguments
if (argc > 0) {
// check all values for occurrences of script values
Enumeration e = args.elements(); // enumeration of values
Object val;
Enumeration<String> e = args.elements(); // enumeration of values
String val;
while (e.hasMoreElements()) {
val = e.nextElement();
if ((val != null) && (val instanceof String) && (((String) val).indexOf("<script") >= 0)) {
if ((val != null) && (val.indexOf("<script") >= 0)) {
// deny request
httpd.sendRespondError(conProp,out,4,403,null,"bad post values",null);
return;
@ -549,6 +547,7 @@ public final class httpdFileHandler {
boolean zipContent = requestHeader.acceptGzip() && httpd.shallTransportZipped("." + conProp.getProperty("EXT",""));
if (path.endsWith("html") ||
path.endsWith("xml") ||
path.endsWith("rdf") ||
path.endsWith("rss") ||
path.endsWith("csv") ||
path.endsWith("pac") ||
@ -633,8 +632,6 @@ public final class httpdFileHandler {
targetDate = new Date(System.currentTimeMillis());
nocache = true;
}
// read templates
tp.putAll(templates);
// rewrite the file
InputStream fis = null;
@ -645,7 +642,7 @@ public final class httpdFileHandler {
long fileSize = targetFile.length();
if (fileSize <= 512 * 1024) {
// read from cache
SoftReference ref = (SoftReference) templateCache.get(targetFile);
SoftReference<byte[]> ref = templateCache.get(targetFile);
if (ref != null) {
templateContent = (byte[]) ref.get();
if (templateContent == null) templateCache.remove(targetFile);
@ -657,7 +654,7 @@ public final class httpdFileHandler {
templateContent = serverFileUtils.read(targetFile);
// storing the content into the cache
ref = new SoftReference(templateContent);
ref = new SoftReference<byte[]>(templateContent);
templateCache.put(targetFile, ref);
if (theLogger.isLoggable(Level.FINEST))
theLogger.logFinest("Cache MISS for file " + targetFile);
@ -931,7 +928,7 @@ public final class httpdFileHandler {
// now make a class out of the stream
try {
if (useTemplateCache) {
SoftReference ref = (SoftReference) templateMethodCache.get(classFile);
SoftReference<Method> ref = templateMethodCache.get(classFile);
if (ref != null) {
m = (Method) ref.get();
if (m == null) {
@ -943,8 +940,8 @@ public final class httpdFileHandler {
}
}
Class c = provider.loadClass(classFile);
Class[] params = new Class[] {
Class<?> c = provider.loadClass(classFile);
Class<?>[] params = new Class[] {
httpHeader.class,
serverObjects.class,
serverSwitch.class };
@ -952,8 +949,8 @@ public final class httpdFileHandler {
if (useTemplateCache) {
// storing the method into the cache
SoftReference ref = new SoftReference(m);
templateMethodCache.put(classFile,ref);
SoftReference<Method> ref = new SoftReference<Method>(m);
templateMethodCache.put(classFile, ref);
}
} catch (ClassNotFoundException e) {

@ -113,7 +113,7 @@ public final class httpdProxyHandler {
// static variables
// can only be instantiated upon first instantiation of this class object
private static plasmaSwitchboard switchboard = null;
public static HashSet yellowList = null;
public static HashSet<String> yellowList = null;
private static int timeout = 30000;
private static boolean yacyTrigger = true;
public static boolean isTransparentProxy = false;
@ -205,7 +205,7 @@ public final class httpdProxyHandler {
yellowList = serverFileUtils.loadList(new File(f));
theLogger.logConfig("loaded yellow-list from file " + f + ", " + yellowList.size() + " entries");
} else {
yellowList = new HashSet();
yellowList = new HashSet<String>();
}
String redirectorPath = switchboard.getConfig("externalRedirector", "");
@ -1411,7 +1411,7 @@ public final class httpdProxyHandler {
serverObjects detailedErrorMsgMap = new serverObjects();
// generic toplevel domains
HashSet topLevelDomains = new HashSet(Arrays.asList(new String[]{
HashSet<String> topLevelDomains = new HashSet<String>(Arrays.asList(new String[]{
"aero", // Fluggesellschaften/Luftfahrt
"arpa", // Einrichtung des ARPANet
"biz", // Business
@ -1453,7 +1453,7 @@ public final class httpdProxyHandler {
detailedErrorMsgMap.put("hostName", orgHostName);
// guessing hostnames
HashSet testHostNames = new HashSet();
HashSet<String> testHostNames = new HashSet<String>();
String testHostName = null;
if (!orgHostName.startsWith("www.")) {
testHostName = "www." + orgHostName;
@ -1472,9 +1472,9 @@ public final class httpdProxyHandler {
pos = orgHostName.lastIndexOf(".");
if (pos != -1) {
Iterator iter = topLevelDomains.iterator();
Iterator<String> iter = topLevelDomains.iterator();
while (iter.hasNext()) {
String topLevelDomain = (String) iter.next();
String topLevelDomain = iter.next();
testHostName = orgHostName.substring(0,pos) + "." + topLevelDomain;
InetAddress addr = serverDomains.dnsResolve(testHostName);
if (addr != null) if (addr != null) testHostNames.add(testHostName);
@ -1482,9 +1482,9 @@ public final class httpdProxyHandler {
}
int hostNameCount = 0;
Iterator iter = testHostNames.iterator();
Iterator<String> iter = testHostNames.iterator();
while (iter.hasNext()) {
testHostName = (String) iter.next();
testHostName = iter.next();
detailedErrorMsgMap.put("list_" + hostNameCount + "_hostName",testHostName);
detailedErrorMsgMap.put("list_" + hostNameCount + "_hostPort",orgHostPort);
detailedErrorMsgMap.put("list_" + hostNameCount + "_hostPath",orgHostPath);

@ -48,11 +48,11 @@ import de.anomic.server.serverSwitch;
public final class httpdSwitchboard extends serverAbstractSwitch implements serverSwitch {
private final LinkedList cacheStack;
private final LinkedList<Object> cacheStack;
public httpdSwitchboard(String rootPath, String initPath, String configPath, boolean applyPro) {
super(rootPath, initPath, configPath, applyPro);
cacheStack = new LinkedList();
cacheStack = new LinkedList<Object>();
}
public int queueSize() {

@ -54,7 +54,7 @@ import java.util.TreeMap;
import de.anomic.server.serverCore;
public class icapHeader extends TreeMap implements Map {
public class icapHeader extends TreeMap<String, String> implements Map<String, String> {
private static final long serialVersionUID = 1L;
@ -91,7 +91,7 @@ public class icapHeader extends TreeMap implements Map {
/* =============================================================
* defining default icap status messages
* ============================================================= */
public static final HashMap icap1_0 = new HashMap();
public static final HashMap<String, String> icap1_0 = new HashMap<String, String>();
static {
// (1yz) Informational codes
icap1_0.put("100","Continue after ICAP preview");
@ -145,8 +145,8 @@ public class icapHeader extends TreeMap implements Map {
}
// to make the occurrence of multiple keys possible, we add them using a counter
public Object add(Object key, Object value) {
int c = keyCount((String) key);
public String add(String key, String value) {
int c = keyCount(key);
if (c == 0) return put(key, value);
return put("*" + key + "-" + c, value);
}
@ -186,7 +186,7 @@ public class icapHeader extends TreeMap implements Map {
.append(icapStatusText).append("\r\n");
// write header
Iterator i = keySet().iterator();
Iterator<String> i = keySet().iterator();
String key;
char tag;
int count;

@ -271,8 +271,8 @@ public class ftpc {
super();
}
public Class loadClass(String classname, boolean resolve) throws ClassNotFoundException {
Class c = findLoadedClass(classname);
public Class<?> loadClass(String classname, boolean resolve) throws ClassNotFoundException {
Class<?> c = findLoadedClass(classname);
if (c == null) try {
// second try: ask the system
c = findSystemClass(classname);
@ -324,11 +324,11 @@ public class ftpc {
System.setProperties(pr);
// locate object
Class c = (new cl()).loadClass(obj);
Class<?> c = (new cl()).loadClass(obj);
//Class c = this.getClass().getClassLoader().loadClass(obj);
// locate public static main(String[]) method
Class[] parameterType = new Class[1];
Class<?>[] parameterType = new Class[1];
parameterType[0] = Class.forName("[Ljava.lang.String;");
Method m = c.getMethod("main", parameterType);
@ -477,11 +477,11 @@ public class ftpc {
}
if (ControlSocket == null) return LDIR();
try {
Vector l;
Vector<String> l;
if (cmd.length == 2) l = list(cmd[1],false); else l = list(".",false);
Enumeration x = l.elements();
Enumeration<String> x = l.elements();
out.println(logPrefix + "---- v---v---v---v---v---v---v---v---v---v---v---v---v---v---v---v---v---v---v");
while (x.hasMoreElements()) out.println(logPrefix + (String) x.nextElement());
while (x.hasMoreElements()) out.println(logPrefix + x.nextElement());
out.println(logPrefix + "---- ^---^---^---^---^---^---^---^---^---^---^---^---^---^---^---^---^---^---^");
} catch (IOException e) {
err.println(logPrefix + "---- Error: remote list not available");
@ -581,8 +581,8 @@ public class ftpc {
exec("cd \"" + remote + "\";lmkdir \"" + remote + "\";lcd \"" + remote + "\"",true);
//exec("mget *",true);
try {
Enumeration files = list(".",false).elements();
while (files.hasMoreElements()) retrieveFilesRecursively((String) files.nextElement(), delete);
Enumeration<String> files = list(".",false).elements();
while (files.hasMoreElements()) retrieveFilesRecursively(files.nextElement(), delete);
} catch (IOException ee) {}
exec("cd ..;lcd ..", true);
try {if (delete) rmForced(remote);} catch (IOException eee) {
@ -1009,9 +1009,9 @@ cd ..
}
if (ControlSocket == null) return LLS();
try {
Vector l;
Vector<String> l;
if (cmd.length == 2) l = list(cmd[1],true); else l = list(".",true);
Enumeration x = l.elements();
Enumeration<String> x = l.elements();
out.println(logPrefix + "---- v---v---v---v---v---v---v---v---v---v---v---v---v---v---v---v---v---v---v");
while (x.hasMoreElements()) out.println(logPrefix + (String) x.nextElement());
out.println(logPrefix + "---- ^---^---^---^---^---^---^---^---^---^---^---^---^---^---^---^---^---^---^");
@ -1022,7 +1022,7 @@ cd ..
}
private Vector list(String path, boolean extended) throws IOException {
private Vector<String> list(String path, boolean extended) throws IOException {
// prepare data channel
if (DataSocketPassiveMode) createPassiveDataPort(); else createActiveDataPort();
@ -1050,7 +1050,7 @@ cd ..
// read file system data
String line;
Vector files = new Vector();
Vector<String> files = new Vector<String>();
while ((line = ClientStream.readLine()) != null)
if (!line.startsWith("total ")) files.addElement(line);
@ -1107,8 +1107,8 @@ cd ..
}
private void mget(String pattern, boolean remove) throws IOException {
Vector l = list(".",false);
Enumeration x = l.elements();
Vector<String> l = list(".",false);
Enumeration<String> x = l.elements();
String remote;
File local;
//int idx; // the search for " " is only for improper lists from the server. this fails if the file name has a " " in it
@ -1894,12 +1894,12 @@ cd ..
public void checkPackageAccess(String pkg) { }
public void checkPackageDefinition(String pkg) { }
public void checkSetFactory() { }
public void checkMemberAccess(Class clazz, int which) { }
public void checkMemberAccess(Class<?> clazz, int which) { }
public void checkSecurityAccess(String provider) { }
}
public static Vector dir(String host,
public static Vector<String> dir(String host,
String remotePath,
String account, String password,
boolean extended) {
@ -1907,7 +1907,7 @@ cd ..
ftpc c = new ftpc();
c.cmd = new String[]{"open", host}; c.OPEN();
c.cmd = new String[]{"user", account, password}; c.USER();
c.cmd = new String[]{"ls"}; Vector v = c.list(remotePath, extended);
c.cmd = new String[]{"ls"}; Vector<String> v = c.list(remotePath, extended);
c.cmd = new String[]{"close"}; c.CLOSE();
c.cmd = new String[]{"exit"}; c.EXIT();
return v;
@ -1936,7 +1936,7 @@ cd ..
public StringBuffer dirhtml(String remotePath) {
// returns a directory listing using an existing connection
try {
Vector list = list(remotePath, true);
Vector<String> list = list(remotePath, true);
if (this.remotesystem == null) sys();
String base = "ftp://" + ((account.equals("anonymous")) ? "" : (account + ":" + password + "@")) + host + ((port == 21) ? "" : (":" + port)) + ((remotePath.charAt(0) == '/') ? "" : "/") + remotePath;
@ -1965,7 +1965,7 @@ cd ..
}
}
public static StringBuffer dirhtml(String base, String servermessage, String greeting, String system, Vector list) {
public static StringBuffer dirhtml(String base, String servermessage, String greeting, String system, Vector<String> list) {
// this creates the html output from collected strings
StringBuffer page = new StringBuffer(1024);
String title = "Index of " + base;

@ -152,7 +152,7 @@ public class plasmaDHTTransfer extends Thread {
// transfering seleted words to remote peer
this.transferStatusMessage = "Running: Transfering chunk to target " + this.seed.hash + "/" + this.seed.getName();
HashMap result = yacyClient.transferIndex(this.seed, this.dhtChunk.containers(), this.dhtChunk.urlCacheMap(), this.gzipBody4Transfer, this.timeout4Transfer);
HashMap<String, Object> result = yacyClient.transferIndex(this.seed, this.dhtChunk.containers(), this.dhtChunk.urlCacheMap(), this.gzipBody4Transfer, this.timeout4Transfer);
String error = (String) result.get("result");
if (error == null) {
// words successfully transfered
@ -254,11 +254,13 @@ public class plasmaDHTTransfer extends Thread {
}
}
private long getBusyTime(HashMap result) {
@SuppressWarnings("unchecked")
private long getBusyTime(HashMap<String, Object> result) {
int pause = -1;
HashMap transferRWIResult = (HashMap) result.get("resultTransferRWI");
if (transferRWIResult != null && transferRWIResult.containsKey("pause")) {
String pauseStr = (String) transferRWIResult.get("pause");
Object transferRWIResult = result.get("resultTransferRWI");
assert transferRWIResult instanceof HashMap;
if (transferRWIResult != null && ((HashMap<String, String>) transferRWIResult).containsKey("pause")) {
String pauseStr = (String) ((HashMap<String, String>) transferRWIResult).get("pause");
try { pause = Integer.valueOf(pauseStr).intValue(); } catch (NumberFormatException numEx){}
if (pause < 0) pause = 5000;
else if (pause > 30000) pause = 30000;

@ -95,7 +95,7 @@ public class plasmaRankingCRProcess {
}
// put elements in accumulator file
Iterator el = source_cr.keys();
Iterator<String> el = source_cr.keys();
String key;
kelondroAttrSeq.Entry new_entry, acc_entry;
int FUDate, FDDate, LUDate, UCount, PCount, ACount, VCount, Vita;
@ -168,7 +168,7 @@ public class plasmaRankingCRProcess {
}
// put elements in accumulator file
Iterator el = source_cr.keys();
Iterator<String> el = source_cr.keys();
String key;
kelondroAttrSeq.Entry new_entry;
kelondroRow.Entry acc_entry;
@ -345,12 +345,12 @@ public class plasmaRankingCRProcess {
int size = cr.size();
long start = System.currentTimeMillis();
long l;
final Iterator i = cr.keys();
final Iterator<String> i = cr.keys();
String referee, anchor, anchorDom;
kelondroAttrSeq.Entry cr_entry, rci_entry;
long cr_UDate, rci_UDate;
while (i.hasNext()) {
referee = (String) i.next();
referee = i.next();
cr_entry = cr.getEntry(referee);
cr_UDate = cr_entry.getAttr("UDate", 0);

Loading…
Cancel
Save