refactoring of seed attributes (introduced more constants)

pull/1/head
Michael Peter Christen 11 years ago
parent 1f0bfa8fec
commit ccf2f4e43b

@ -45,6 +45,7 @@ import net.yacy.cora.protocol.RequestHeader;
import net.yacy.data.BlogBoard;
import net.yacy.data.UserDB;
import net.yacy.peers.NewsPool;
import net.yacy.peers.Seed;
import net.yacy.search.Switchboard;
import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch;
@ -112,7 +113,7 @@ public class Blog {
if (sb.peers.mySeed() == null) {
strAuthor = "anonymous";
} else {
strAuthor = sb.peers.mySeed().get("Name", "anonymous");
strAuthor = sb.peers.mySeed().get(Seed.NAME, "anonymous");
}
}
}

@ -46,6 +46,7 @@ import net.yacy.data.MessageBoard;
import net.yacy.data.UserDB;
import net.yacy.data.BlogBoard.BlogEntry;
import net.yacy.peers.Network;
import net.yacy.peers.Seed;
import net.yacy.search.Switchboard;
import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch;
@ -95,7 +96,7 @@ public class BlogComments {
if (sb.peers.mySeed() == null) {
strAuthor = "anonymous";
} else {
strAuthor = sb.peers.mySeed().get("Name", "anonymous");
strAuthor = sb.peers.mySeed().get(Seed.NAME, "anonymous");
}
}
}

@ -46,6 +46,7 @@ import net.yacy.cora.util.ByteBuffer;
import net.yacy.data.Diff;
import net.yacy.data.wiki.WikiBoard;
import net.yacy.peers.NewsPool;
import net.yacy.peers.Seed;
import net.yacy.search.Switchboard;
import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch;
@ -79,7 +80,7 @@ public class Wiki {
if (author.equals(ANONYMOUS)) {
author = WikiBoard.guessAuthor(ip);
if (author == null) {
author = (sb.peers.mySeed() == null) ? ANONYMOUS : sb.peers.mySeed().get("Name", ANONYMOUS);
author = (sb.peers.mySeed() == null) ? ANONYMOUS : sb.peers.mySeed().get(Seed.NAME, ANONYMOUS);
}
}

@ -427,9 +427,9 @@ public class Network
try {
final NewsDB.Record record = this.sb.peers.newsPool.myPublication();
if ( record == null ) {
this.sb.peers.mySeed().put("news", "");
this.sb.peers.mySeed().put(Seed.NEWS, "");
} else {
this.sb.peers.mySeed().put("news", net.yacy.utils.crypt.simpleEncode(record.toString()));
this.sb.peers.mySeed().put(Seed.NEWS, net.yacy.utils.crypt.simpleEncode(record.toString()));
}
} catch (final Exception e ) {
log.severe("publishMySeed: problem with news encoding", e);

@ -207,7 +207,7 @@ public class PeerActions {
if (Network.log.isFine()) Network.log.fine("connect: no contact to a " + peer.get(Seed.PEERTYPE, Seed.PEERTYPE_VIRGIN) + " peer '" + peer.getName() + "' at " + peer.getPublicAddress() + ". Cause: " + cause);
synchronized (this.seedDB) {
if (!this.seedDB.hasDisconnected(ASCII.getBytes(peer.hash))) { this.disconnects++; }
peer.put("dct", Long.toString(System.currentTimeMillis()));
peer.put(Seed.DCT, Long.toString(System.currentTimeMillis()));
this.seedDB.addDisconnected(peer); // update info
}
EventChannel.channels(EventChannel.PEERNEWS).addMessage(new RSSMessage(peer.getName() + " left the network", "", ""));
@ -223,7 +223,7 @@ public class PeerActions {
}
private void processPeerArrival(final Seed peer) {
final String recordString = peer.get("news", null);
final String recordString = peer.get(Seed.NEWS, null);
//System.out.println("### triggered news arrival from peer " + peer.getName() + ", news " + ((recordString == null) ? "empty" : "attached"));
if ((recordString == null) || (recordString.isEmpty())) return;
final String decodedString = net.yacy.utils.crypt.simpleDecode(recordString);

@ -141,7 +141,7 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
/** the name of the peer (user-set) */
public static final String NAME = "Name";
private static final String HASH = "Hash";
public static final String HASH = "Hash";
/** Birthday - first startup */
private static final String BDATE = "BDate";
/** UTC-Offset */
@ -169,6 +169,9 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
public static final String IP = "IP";
public static final String PORT = "Port";
public static final String SEEDLISTURL = "seedURL";
public static final String NEWS = "news"; // news attachment
public static final String DCT = "dct"; // disconnect time
/** zero-value */
private static final String ZERO = "0";

Loading…
Cancel
Save