forked from I2P_Developers/i2p.i2p
propagate from branch 'i2p.i2p.str4d.cleanup' (head 736423cc308e964bab55068e625f8a1852932ec5)
to branch 'i2p.i2p' (head 0ac335d5dc4ccaeb113af4fb5c0e993a6f42fdbe)
This commit is contained in:
@ -156,11 +156,11 @@ public class MetaInfo
|
||||
if (val == null) {
|
||||
this.announce_list = null;
|
||||
} else {
|
||||
this.announce_list = new ArrayList();
|
||||
this.announce_list = new ArrayList<List<String>>();
|
||||
List<BEValue> bl1 = val.getList();
|
||||
for (BEValue bev : bl1) {
|
||||
List<BEValue> bl2 = bev.getList();
|
||||
List<String> sl2 = new ArrayList();
|
||||
List<String> sl2 = new ArrayList<String>();
|
||||
for (BEValue bev2 : bl2) {
|
||||
sl2.add(bev2.getString());
|
||||
}
|
||||
@ -259,9 +259,9 @@ public class MetaInfo
|
||||
if (size == 0)
|
||||
throw new InvalidBEncodingException("zero size files list");
|
||||
|
||||
List<List<String>> m_files = new ArrayList(size);
|
||||
List<List<String>> m_files_utf8 = new ArrayList(size);
|
||||
List<Long> m_lengths = new ArrayList(size);
|
||||
List<List<String>> m_files = new ArrayList<List<String>>(size);
|
||||
List<List<String>> m_files_utf8 = new ArrayList<List<String>>(size);
|
||||
List<Long> m_lengths = new ArrayList<Long>(size);
|
||||
long l = 0;
|
||||
for (int i = 0; i < list.size(); i++)
|
||||
{
|
||||
@ -287,7 +287,7 @@ public class MetaInfo
|
||||
if (path_length == 0)
|
||||
throw new InvalidBEncodingException("zero size file path list");
|
||||
|
||||
List<String> file = new ArrayList(path_length);
|
||||
List<String> file = new ArrayList<String>(path_length);
|
||||
Iterator<BEValue> it = path_list.iterator();
|
||||
while (it.hasNext()) {
|
||||
String s = it.next().getString();
|
||||
@ -310,7 +310,7 @@ public class MetaInfo
|
||||
path_list = val.getList();
|
||||
path_length = path_list.size();
|
||||
if (path_length > 0) {
|
||||
file = new ArrayList(path_length);
|
||||
file = new ArrayList<String>(path_length);
|
||||
it = path_list.iterator();
|
||||
while (it.hasNext())
|
||||
file.add(it.next().getString());
|
||||
@ -573,10 +573,10 @@ public class MetaInfo
|
||||
*/
|
||||
public MetaInfo reannounce(String announce) throws InvalidBEncodingException
|
||||
{
|
||||
Map<String, BEValue> m = new HashMap();
|
||||
Map<String, BEValue> m = new HashMap<String, BEValue>();
|
||||
if (announce != null)
|
||||
m.put("announce", new BEValue(DataHelper.getUTF8(announce)));
|
||||
Map info = createInfoMap();
|
||||
Map<String, BEValue> info = createInfoMap();
|
||||
m.put("info", new BEValue(info));
|
||||
return new MetaInfo(m);
|
||||
}
|
||||
@ -586,12 +586,12 @@ public class MetaInfo
|
||||
*/
|
||||
public synchronized byte[] getTorrentData()
|
||||
{
|
||||
Map m = new HashMap();
|
||||
Map<String, Object> m = new HashMap<String, Object>();
|
||||
if (announce != null)
|
||||
m.put("announce", announce);
|
||||
if (announce_list != null)
|
||||
m.put("announce-list", announce_list);
|
||||
Map info = createInfoMap();
|
||||
Map<String, BEValue> info = createInfoMap();
|
||||
m.put("info", info);
|
||||
// don't save this locally, we should only do this once
|
||||
return BEncoder.bencode(m);
|
||||
@ -615,31 +615,42 @@ public class MetaInfo
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Creating new infomap", new Exception());
|
||||
// otherwise we must create it
|
||||
Map info = new HashMap();
|
||||
info.put("name", name);
|
||||
Map<String, BEValue> info = new HashMap<String, BEValue>();
|
||||
info.put("name", new BEValue(DataHelper.getUTF8(name)));
|
||||
if (name_utf8 != null)
|
||||
info.put("name.utf-8", name_utf8);
|
||||
info.put("name.utf-8", new BEValue(DataHelper.getUTF8(name_utf8)));
|
||||
// BEP 27
|
||||
if (privateTorrent)
|
||||
info.put("private", "1");
|
||||
info.put("private", new BEValue(DataHelper.getUTF8("1")));
|
||||
|
||||
info.put("piece length", Integer.valueOf(piece_length));
|
||||
info.put("pieces", piece_hashes);
|
||||
info.put("piece length", new BEValue(Integer.valueOf(piece_length)));
|
||||
info.put("pieces", new BEValue(piece_hashes));
|
||||
if (files == null)
|
||||
info.put("length", Long.valueOf(length));
|
||||
info.put("length", new BEValue(Long.valueOf(length)));
|
||||
else
|
||||
{
|
||||
List l = new ArrayList();
|
||||
List<BEValue> l = new ArrayList<BEValue>();
|
||||
for (int i = 0; i < files.size(); i++)
|
||||
{
|
||||
Map file = new HashMap();
|
||||
file.put("path", files.get(i));
|
||||
if ( (files_utf8 != null) && (files_utf8.size() > i) )
|
||||
file.put("path.utf-8", files_utf8.get(i));
|
||||
file.put("length", lengths.get(i));
|
||||
l.add(file);
|
||||
Map<String, BEValue> file = new HashMap<String, BEValue>();
|
||||
List<String> fi = files.get(i);
|
||||
List<BEValue> befiles = new ArrayList<BEValue>(fi.size());
|
||||
for (int j = 0; j < fi.size(); j++) {
|
||||
befiles.add(new BEValue(DataHelper.getUTF8(fi.get(j))));
|
||||
}
|
||||
file.put("path", new BEValue(befiles));
|
||||
if ( (files_utf8 != null) && (files_utf8.size() > i) ) {
|
||||
List<String> fiu = files_utf8.get(i);
|
||||
List<BEValue> beufiles = new ArrayList<BEValue>(fiu.size());
|
||||
for (int j = 0; j < fiu.size(); j++) {
|
||||
beufiles.add(new BEValue(DataHelper.getUTF8(fiu.get(j))));
|
||||
}
|
||||
file.put("path.utf-8", new BEValue(beufiles));
|
||||
}
|
||||
file.put("length", new BEValue(lengths.get(i)));
|
||||
l.add(new BEValue(file));
|
||||
}
|
||||
info.put("files", l);
|
||||
info.put("files", new BEValue(l));
|
||||
}
|
||||
|
||||
// TODO if we add the ability for other keys in the first constructor
|
||||
|
@ -31,7 +31,7 @@ import net.i2p.util.SecureFile;
|
||||
*
|
||||
* @since 0.8.2
|
||||
*/
|
||||
class PartialPiece implements Comparable {
|
||||
class PartialPiece implements Comparable<PartialPiece> {
|
||||
|
||||
// we store the piece so we can use it in compareTo()
|
||||
private final Piece piece;
|
||||
@ -295,8 +295,7 @@ class PartialPiece implements Comparable {
|
||||
* then rarest first,
|
||||
* then highest downloaded first
|
||||
*/
|
||||
public int compareTo(Object o) throws ClassCastException {
|
||||
PartialPiece opp = (PartialPiece)o;
|
||||
public int compareTo(PartialPiece opp) {
|
||||
int d = this.piece.compareTo(opp.piece);
|
||||
if (d != 0)
|
||||
return d;
|
||||
|
@ -39,7 +39,7 @@ import net.i2p.util.Log;
|
||||
|
||||
import org.klomp.snark.bencode.BEValue;
|
||||
|
||||
public class Peer implements Comparable
|
||||
public class Peer implements Comparable<Peer>
|
||||
{
|
||||
private final Log _log = I2PAppContext.getGlobalContext().logManager().getLog(Peer.class);
|
||||
// Identifying property, the peer id of the other side.
|
||||
@ -194,7 +194,7 @@ public class Peer implements Comparable
|
||||
* Compares the PeerIDs.
|
||||
* @deprecated unused?
|
||||
*/
|
||||
public int compareTo(Object o)
|
||||
public int compareTo(Peer o)
|
||||
{
|
||||
Peer p = (Peer)o;
|
||||
int rv = peerID.compareTo(p.peerID);
|
||||
|
@ -42,7 +42,7 @@ import org.klomp.snark.bencode.InvalidBEncodingException;
|
||||
* and the PeerID is not required.
|
||||
* Equality is now determined solely by the dest hash.
|
||||
*/
|
||||
class PeerID implements Comparable
|
||||
class PeerID implements Comparable<PeerID>
|
||||
{
|
||||
private byte[] id;
|
||||
private Destination address;
|
||||
@ -76,15 +76,15 @@ class PeerID implements Comparable
|
||||
* Creates a PeerID from a Map containing BEncoded peer id, ip and
|
||||
* port.
|
||||
*/
|
||||
public PeerID(Map m)
|
||||
public PeerID(Map<String, BEValue> m)
|
||||
throws InvalidBEncodingException, UnknownHostException
|
||||
{
|
||||
BEValue bevalue = (BEValue)m.get("peer id");
|
||||
BEValue bevalue = m.get("peer id");
|
||||
if (bevalue == null)
|
||||
throw new InvalidBEncodingException("peer id missing");
|
||||
id = bevalue.getBytes();
|
||||
|
||||
bevalue = (BEValue)m.get("ip");
|
||||
bevalue = m.get("ip");
|
||||
if (bevalue == null)
|
||||
throw new InvalidBEncodingException("ip missing");
|
||||
address = I2PSnarkUtil.getDestinationFromBase64(bevalue.getString());
|
||||
@ -195,10 +195,8 @@ class PeerID implements Comparable
|
||||
* Compares port, address and id.
|
||||
* @deprecated unused? and will NPE now that address can be null?
|
||||
*/
|
||||
public int compareTo(Object o)
|
||||
public int compareTo(PeerID pid)
|
||||
{
|
||||
PeerID pid = (PeerID)o;
|
||||
|
||||
int result = port - pid.port;
|
||||
if (result != 0)
|
||||
return result;
|
||||
|
@ -7,7 +7,7 @@ import java.util.Set;
|
||||
* This class is used solely by PeerCoordinator.
|
||||
* Caller must synchronize on many of these methods.
|
||||
*/
|
||||
class Piece implements Comparable {
|
||||
class Piece implements Comparable<Piece> {
|
||||
|
||||
private final int id;
|
||||
private final Set<PeerID> peers;
|
||||
@ -26,11 +26,11 @@ class Piece implements Comparable {
|
||||
* Highest priority first,
|
||||
* then rarest first
|
||||
*/
|
||||
public int compareTo(Object o) throws ClassCastException {
|
||||
int pdiff = ((Piece)o).priority - this.priority; // reverse
|
||||
public int compareTo(Piece op) {
|
||||
int pdiff = op.priority - this.priority; // reverse
|
||||
if (pdiff != 0)
|
||||
return pdiff;
|
||||
return this.peers.size() - ((Piece)o).peers.size();
|
||||
return this.peers.size() - op.peers.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -424,7 +424,7 @@ public class SnarkManager implements CompleteListener {
|
||||
String i2cpHost = _config.getProperty(PROP_I2CP_HOST);
|
||||
int i2cpPort = getInt(PROP_I2CP_PORT, 7654);
|
||||
String opts = _config.getProperty(PROP_I2CP_OPTS);
|
||||
Map i2cpOpts = new HashMap();
|
||||
Map<String, String> i2cpOpts = new HashMap<String, String>();
|
||||
if (opts != null) {
|
||||
StringTokenizer tok = new StringTokenizer(opts, " ");
|
||||
while (tok.hasMoreTokens()) {
|
||||
@ -1652,7 +1652,7 @@ public class SnarkManager implements CompleteListener {
|
||||
*/
|
||||
private void monitorTorrents(File dir) {
|
||||
String fileNames[] = dir.list(TorrentFilenameFilter.instance());
|
||||
List<String> foundNames = new ArrayList(0);
|
||||
List<String> foundNames = new ArrayList<String>(0);
|
||||
if (fileNames != null) {
|
||||
for (int i = 0; i < fileNames.length; i++) {
|
||||
try {
|
||||
@ -1738,7 +1738,7 @@ public class SnarkManager implements CompleteListener {
|
||||
* @since 0.9.1
|
||||
*/
|
||||
public List<Tracker> getSortedTrackers() {
|
||||
List<Tracker> rv = new ArrayList(_trackerMap.values());
|
||||
List<Tracker> rv = new ArrayList<Tracker>(_trackerMap.values());
|
||||
Collections.sort(rv, new IgnoreCaseComparator());
|
||||
return rv;
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ public class BDecoder
|
||||
+ (char)c + "'");
|
||||
indicator = 0;
|
||||
|
||||
List result = new ArrayList();
|
||||
List<BEValue> result = new ArrayList<BEValue>();
|
||||
c = getNextIndicator();
|
||||
while (c != 'e')
|
||||
{
|
||||
@ -308,7 +308,7 @@ public class BDecoder
|
||||
+ (char)c + "'");
|
||||
indicator = 0;
|
||||
|
||||
Map result = new HashMap();
|
||||
Map<String, BEValue> result = new HashMap<String, BEValue>();
|
||||
c = getNextIndicator();
|
||||
while (c != 'e')
|
||||
{
|
||||
|
@ -49,12 +49,12 @@ public class BEValue
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public BEValue(List value)
|
||||
public BEValue(List<BEValue> value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public BEValue(Map value)
|
||||
public BEValue(Map<String, BEValue> value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
@ -142,11 +142,12 @@ public class BEValue
|
||||
* succeeds when the BEValue is actually a List, otherwise it will
|
||||
* throw a InvalidBEncodingException.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<BEValue> getList() throws InvalidBEncodingException
|
||||
{
|
||||
try
|
||||
{
|
||||
return (List)value;
|
||||
return (List<BEValue>)value;
|
||||
}
|
||||
catch (ClassCastException cce)
|
||||
{
|
||||
@ -159,11 +160,12 @@ public class BEValue
|
||||
* values. This operation only succeeds when the BEValue is actually
|
||||
* a Map, otherwise it will throw a InvalidBEncodingException.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, BEValue> getMap() throws InvalidBEncodingException
|
||||
{
|
||||
try
|
||||
{
|
||||
return (Map)value;
|
||||
return (Map<String, BEValue>)value;
|
||||
}
|
||||
catch (ClassCastException cce)
|
||||
{
|
||||
|
@ -59,9 +59,9 @@ public class BEncoder
|
||||
else if (o instanceof Number)
|
||||
bencode((Number)o, out);
|
||||
else if (o instanceof List)
|
||||
bencode((List)o, out);
|
||||
bencode((List<?>)o, out);
|
||||
else if (o instanceof Map)
|
||||
bencode((Map<String, Object>)o, out);
|
||||
bencode((Map<?, ?>)o, out);
|
||||
else if (o instanceof BEValue)
|
||||
bencode(((BEValue)o).getValue(), out);
|
||||
else
|
||||
@ -110,7 +110,7 @@ public class BEncoder
|
||||
out.write('e');
|
||||
}
|
||||
|
||||
public static byte[] bencode(List l)
|
||||
public static byte[] bencode(List<?> l)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -124,10 +124,10 @@ public class BEncoder
|
||||
}
|
||||
}
|
||||
|
||||
public static void bencode(List l, OutputStream out) throws IOException
|
||||
public static void bencode(List<?> l, OutputStream out) throws IOException
|
||||
{
|
||||
out.write('l');
|
||||
Iterator it = l.iterator();
|
||||
Iterator<?> it = l.iterator();
|
||||
while (it.hasNext())
|
||||
bencode(it.next(), out);
|
||||
out.write('e');
|
||||
@ -175,7 +175,7 @@ public class BEncoder
|
||||
|
||||
// Keys must be sorted. XXX - But is this the correct order?
|
||||
Set<String> s = m.keySet();
|
||||
List<String> l = new ArrayList(s);
|
||||
List<String> l = new ArrayList<String>(s);
|
||||
Collections.sort(l);
|
||||
|
||||
Iterator<String> it = l.iterator();
|
||||
|
@ -37,10 +37,10 @@ abstract class PersistDHT {
|
||||
public static synchronized void loadDHT(KRPC krpc, File file) {
|
||||
Log log = I2PAppContext.getGlobalContext().logManager().getLog(PersistDHT.class);
|
||||
int count = 0;
|
||||
FileInputStream in = null;
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
in = new FileInputStream(file);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(in, "ISO-8859-1"));
|
||||
br = new BufferedReader(new InputStreamReader(
|
||||
new FileInputStream(file), "ISO-8859-1"));
|
||||
String line = null;
|
||||
while ( (line = br.readLine()) != null) {
|
||||
if (line.startsWith("#"))
|
||||
@ -61,7 +61,7 @@ abstract class PersistDHT {
|
||||
if (log.shouldLog(Log.WARN) && file.exists())
|
||||
log.warn("Error reading the DHT File", ioe);
|
||||
} finally {
|
||||
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
||||
if (br != null) try { br.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
if (log.shouldLog(Log.INFO))
|
||||
log.info("Loaded " + count + " nodes from " + file);
|
||||
|
@ -27,7 +27,6 @@ import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.UnavailableException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
@ -325,7 +324,7 @@ class BasicServlet extends HttpServlet
|
||||
long content_length = content.getContentLength();
|
||||
|
||||
// see if there are any range headers
|
||||
Enumeration reqRanges = request.getHeaders("Range");
|
||||
Enumeration<?> reqRanges = request.getHeaders("Range");
|
||||
|
||||
if (reqRanges == null || !reqRanges.hasMoreElements()) {
|
||||
// if there were no ranges, send entire entity
|
||||
|
@ -1,12 +1,8 @@
|
||||
package org.klomp.snark.web;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.text.Collator;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -16,7 +12,6 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@ -26,14 +21,11 @@ import java.util.TreeSet;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.data.Base64;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.util.I2PAppThread;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
import org.klomp.snark.I2PSnarkUtil;
|
||||
@ -208,7 +200,8 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
resp.sendError(404);
|
||||
} else {
|
||||
String base = addPaths(req.getRequestURI(), "/");
|
||||
String listing = getListHTML(resource, base, true, method.equals("POST") ? req.getParameterMap() : null);
|
||||
@SuppressWarnings("unchecked") // TODO-Java6: Remove cast, return type is correct
|
||||
String listing = getListHTML(resource, base, true, method.equals("POST") ? (Map<String, String[]>) req.getParameterMap() : null);
|
||||
if (method.equals("POST")) {
|
||||
// P-R-G
|
||||
sendRedirect(req, resp, "");
|
||||
@ -684,7 +677,8 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
String action = req.getParameter("action");
|
||||
if (action == null) {
|
||||
// http://www.onenaught.com/posts/382/firefox-4-change-input-type-image-only-submits-x-and-y-not-name
|
||||
Map params = req.getParameterMap();
|
||||
@SuppressWarnings("unchecked") // TODO-Java6: Remove cast, return type is correct
|
||||
Map<String, String[]> params = req.getParameterMap();
|
||||
for (Object o : params.keySet()) {
|
||||
String key = (String) o;
|
||||
if (key.startsWith("action_") && key.endsWith(".x")) {
|
||||
@ -758,8 +752,7 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
if (torrent != null) {
|
||||
byte infoHash[] = Base64.decode(torrent);
|
||||
if ( (infoHash != null) && (infoHash.length == 20) ) { // valid sha1
|
||||
for (Iterator iter = _manager.listTorrentFiles().iterator(); iter.hasNext(); ) {
|
||||
String name = (String)iter.next();
|
||||
for (String name : _manager.listTorrentFiles() ) {
|
||||
Snark snark = _manager.getTorrent(name);
|
||||
if ( (snark != null) && (DataHelper.eq(infoHash, snark.getInfoHash())) ) {
|
||||
_manager.stopTorrent(snark, false);
|
||||
@ -781,8 +774,7 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
if (torrent != null) {
|
||||
byte infoHash[] = Base64.decode(torrent);
|
||||
if ( (infoHash != null) && (infoHash.length == 20) ) { // valid sha1
|
||||
for (Iterator iter = _manager.listTorrentFiles().iterator(); iter.hasNext(); ) {
|
||||
String name = (String)iter.next();
|
||||
for (String name : _manager.listTorrentFiles() ) {
|
||||
Snark snark = _manager.getTorrent(name);
|
||||
if ( (snark != null) && (DataHelper.eq(infoHash, snark.getInfoHash())) ) {
|
||||
MetaInfo meta = snark.getMetaInfo();
|
||||
@ -809,8 +801,7 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
if (torrent != null) {
|
||||
byte infoHash[] = Base64.decode(torrent);
|
||||
if ( (infoHash != null) && (infoHash.length == 20) ) { // valid sha1
|
||||
for (Iterator iter = _manager.listTorrentFiles().iterator(); iter.hasNext(); ) {
|
||||
String name = (String)iter.next();
|
||||
for (String name : _manager.listTorrentFiles() ) {
|
||||
Snark snark = _manager.getTorrent(name);
|
||||
if ( (snark != null) && (DataHelper.eq(infoHash, snark.getInfoHash())) ) {
|
||||
MetaInfo meta = snark.getMetaInfo();
|
||||
@ -849,7 +840,7 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
}
|
||||
}
|
||||
// step 2 make Set of dirs with reverse sort
|
||||
Set<File> dirs = new TreeSet(Collections.reverseOrder());
|
||||
Set<File> dirs = new TreeSet<File>(Collections.reverseOrder());
|
||||
for (List<String> list : files) {
|
||||
for (int i = 1; i < list.size(); i++) {
|
||||
dirs.add(Storage.getFileFromNames(f, list.subList(0, i)));
|
||||
@ -922,8 +913,8 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
if (announceURL.equals("none"))
|
||||
announceURL = null;
|
||||
_lastAnnounceURL = announceURL;
|
||||
List<String> backupURLs = new ArrayList();
|
||||
Enumeration e = req.getParameterNames();
|
||||
List<String> backupURLs = new ArrayList<String>();
|
||||
Enumeration<?> e = req.getParameterNames();
|
||||
while (e.hasMoreElements()) {
|
||||
Object o = e.nextElement();
|
||||
if (!(o instanceof String))
|
||||
@ -955,7 +946,7 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
_manager.addMessage(_("Error - Cannot mix private and public trackers in a torrent"));
|
||||
return;
|
||||
}
|
||||
announceList = new ArrayList(backupURLs.size());
|
||||
announceList = new ArrayList<List<String>>(backupURLs.size());
|
||||
for (String url : backupURLs) {
|
||||
announceList.add(Collections.singletonList(url));
|
||||
}
|
||||
@ -1017,10 +1008,10 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
if (action.equals(_("Delete selected")) || action.equals(_("Save tracker configuration"))) {
|
||||
boolean changed = false;
|
||||
Map<String, Tracker> trackers = _manager.getTrackerMap();
|
||||
List<String> removed = new ArrayList();
|
||||
List<String> open = new ArrayList();
|
||||
List<String> priv = new ArrayList();
|
||||
Enumeration e = req.getParameterNames();
|
||||
List<String> removed = new ArrayList<String>();
|
||||
List<String> open = new ArrayList<String>();
|
||||
List<String> priv = new ArrayList<String>();
|
||||
Enumeration<?> e = req.getParameterNames();
|
||||
while (e.hasMoreElements()) {
|
||||
Object o = e.nextElement();
|
||||
if (!(o instanceof String))
|
||||
@ -1045,7 +1036,7 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
}
|
||||
|
||||
open.removeAll(removed);
|
||||
List<String> oldOpen = new ArrayList(_manager.util().getOpenTrackers());
|
||||
List<String> oldOpen = new ArrayList<String>(_manager.util().getOpenTrackers());
|
||||
Collections.sort(oldOpen);
|
||||
Collections.sort(open);
|
||||
if (!open.equals(oldOpen))
|
||||
@ -1054,7 +1045,7 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
priv.removeAll(removed);
|
||||
// open trumps private
|
||||
priv.removeAll(open);
|
||||
List<String> oldPriv = new ArrayList(_manager.getPrivateTrackers());
|
||||
List<String> oldPriv = new ArrayList<String>(_manager.getPrivateTrackers());
|
||||
Collections.sort(oldPriv);
|
||||
Collections.sort(priv);
|
||||
if (!priv.equals(oldPriv))
|
||||
@ -1074,11 +1065,11 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
_manager.saveTrackerMap();
|
||||
// open trumps private
|
||||
if (req.getParameter("_add_open_") != null) {
|
||||
List newOpen = new ArrayList(_manager.util().getOpenTrackers());
|
||||
List<String> newOpen = new ArrayList<String>(_manager.util().getOpenTrackers());
|
||||
newOpen.add(aurl);
|
||||
_manager.saveOpenTrackers(newOpen);
|
||||
} else if (req.getParameter("_add_private_") != null) {
|
||||
List newPriv = new ArrayList(_manager.getPrivateTrackers());
|
||||
List<String> newPriv = new ArrayList<String>(_manager.getPrivateTrackers());
|
||||
newPriv.add(aurl);
|
||||
_manager.savePrivateTrackers(newPriv);
|
||||
}
|
||||
@ -1141,7 +1132,7 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
}
|
||||
|
||||
private List<Snark> getSortedSnarks(HttpServletRequest req) {
|
||||
ArrayList<Snark> rv = new ArrayList(_manager.getTorrents());
|
||||
ArrayList<Snark> rv = new ArrayList<Snark>(_manager.getTorrents());
|
||||
Collections.sort(rv, new TorrentNameComparator());
|
||||
return rv;
|
||||
}
|
||||
@ -1916,7 +1907,7 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
//out.write("port: <input type=\"text\" name=\"eepPort\" value=\""
|
||||
// + _manager.util().getEepProxyPort() + "\" size=\"5\" maxlength=\"5\" /><br>\n");
|
||||
|
||||
Map<String, String> options = new TreeMap(_manager.util().getI2CPOptions());
|
||||
Map<String, String> options = new TreeMap<String, String>(_manager.util().getI2CPOptions());
|
||||
out.write("<tr><td>");
|
||||
out.write(_("Inbound Settings"));
|
||||
out.write(":<td>");
|
||||
@ -2212,7 +2203,7 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
* @return String of HTML or null if postParams != null
|
||||
* @since 0.7.14
|
||||
*/
|
||||
private String getListHTML(File r, String base, boolean parent, Map postParams)
|
||||
private String getListHTML(File r, String base, boolean parent, Map<String, String[]> postParams)
|
||||
throws IOException
|
||||
{
|
||||
File[] ls = null;
|
||||
@ -2388,7 +2379,7 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
.append(":</b> ")
|
||||
.append(formatSize(needed));
|
||||
if (meta != null) {
|
||||
List files = meta.getFiles();
|
||||
List<List<String>> files = meta.getFiles();
|
||||
int fileCount = files != null ? files.size() : 1;
|
||||
buf.append(" <img alt=\"\" border=\"0\" src=\"" + _imgPath + "file.png\" > <b>")
|
||||
.append(_("Files"))
|
||||
@ -2648,17 +2639,16 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
}
|
||||
|
||||
/** @since 0.8.1 */
|
||||
private void savePriorities(Snark snark, Map postParams) {
|
||||
private void savePriorities(Snark snark, Map<String, String[]> postParams) {
|
||||
Storage storage = snark.getStorage();
|
||||
if (storage == null)
|
||||
return;
|
||||
Set<Map.Entry> entries = postParams.entrySet();
|
||||
for (Map.Entry entry : entries) {
|
||||
String key = (String)entry.getKey();
|
||||
for (Map.Entry<String, String[]> entry : postParams.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (key.startsWith("pri.")) {
|
||||
try {
|
||||
String file = key.substring(4);
|
||||
String val = ((String[])entry.getValue())[0]; // jetty arrays
|
||||
String val = entry.getValue()[0]; // jetty arrays
|
||||
int pri = Integer.parseInt(val);
|
||||
storage.setPriority(file, pri);
|
||||
//System.err.println("Priority now " + pri + " for " + file);
|
||||
|
@ -73,7 +73,7 @@ public class InclusiveByteRange
|
||||
* @param size Size of the resource.
|
||||
* @return List of satisfiable ranges
|
||||
*/
|
||||
public static List<InclusiveByteRange> satisfiableRanges(Enumeration headers, long size)
|
||||
public static List<InclusiveByteRange> satisfiableRanges(Enumeration<?> headers, long size)
|
||||
{
|
||||
List<InclusiveByteRange> satRanges = null;
|
||||
|
||||
@ -128,7 +128,7 @@ public class InclusiveByteRange
|
||||
if (first < size)
|
||||
{
|
||||
if (satRanges == null)
|
||||
satRanges = new ArrayList(4);
|
||||
satRanges = new ArrayList<InclusiveByteRange>(4);
|
||||
InclusiveByteRange range = new InclusiveByteRange(first,last);
|
||||
satRanges.add(range);
|
||||
}
|
||||
|
@ -21,8 +21,6 @@ import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
@ -48,7 +46,7 @@ class MimeTypes
|
||||
private final Map<String, String> _mimeMap;
|
||||
|
||||
public MimeTypes() {
|
||||
_mimeMap = new ConcurrentHashMap();
|
||||
_mimeMap = new ConcurrentHashMap<String, String>();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
Reference in New Issue
Block a user