Methods Summary |
---|
public static java.lang.String | getColor(org.gudy.azureus2.core3.torrent.TOTorrent torrent)
Map mapContent = getTempGlobalRatingContentMap(torrent);
Object o = mapContent.get(GLOBAL_RATING_COLOR);
if (o instanceof String) {
return (String) o;
} else if (o instanceof byte[]) {
return new String((byte[]) o);
}
if (o != null) {
Debug.out(GLOBAL_RATING_COLOR + " is not String - " + o.getClass() + "("
+ o + ")");
}
return null;
|
public static long | getCount(org.gudy.azureus2.core3.torrent.TOTorrent torrent)
Map mapContent = getTempGlobalRatingContentMap(torrent);
Long l = (Long) mapContent.get(GLOBAL_RATING_COUNT);
if (l == null) {
return 0;
}
return l.longValue();
|
public static java.lang.String | getRatingString(org.gudy.azureus2.core3.torrent.TOTorrent torrent)
Map mapContent = getTempGlobalRatingContentMap(torrent);
Object o = mapContent.get(GLOBAL_RATING_STRING);
if (o instanceof String) {
return (String) o;
} else if (o instanceof byte[]) {
return new String((byte[]) o);
}
if (o != null) {
Debug.out(GLOBAL_RATING_STRING + " is not String - " + o.getClass() + "("
+ o + ")");
}
return null;
|
public static long | getRefreshOn(org.gudy.azureus2.core3.torrent.TOTorrent torrent)
Map mapContent = getTempGlobalRatingContentMap(torrent);
Long l = (Long) mapContent.get(GLOBAL_RATING_REFRESH_ON);
if (l == null) {
return SystemTime.getCurrentTime();
}
return l.longValue();
|
private static java.util.Map | getTempGlobalRatingContentMap(org.gudy.azureus2.core3.torrent.TOTorrent torrent)
Map mapContent = PlatformTorrentUtils.getTempContentMap(torrent);
Object o = mapContent.get(TOR_AZ_PROP_GLOBAL_RATING);
if (o instanceof Map) {
return (Map) o;
}
Map map = new HashMap();
mapContent.put(TOR_AZ_PROP_GLOBAL_RATING, map);
return map;
|
public static void | setRating(org.gudy.azureus2.core3.torrent.TOTorrent torrent, java.lang.String rating, java.lang.String color, long count, long refreshOn)
Map mapContent = getTempGlobalRatingContentMap(torrent);
if (rating == null) {
mapContent.remove(GLOBAL_RATING_STRING);
} else {
mapContent.put(GLOBAL_RATING_STRING, rating);
}
if (color == null) {
mapContent.remove(GLOBAL_RATING_COLOR);
} else {
mapContent.put(GLOBAL_RATING_COLOR, color);
}
mapContent.put(GLOBAL_RATING_REFRESH_ON, new Long(refreshOn));
mapContent.put(GLOBAL_RATING_COUNT, new Long(count));
try {
TorrentUtils.writeToFile(torrent);
} catch (TOTorrentException e) {
Debug.out(e);
}
if (PlatformTorrentUtils.DEBUG_CACHING) {
PlatformTorrentUtils.log("v3.GR.caching: setRating to " + rating
+ " for " + torrent + ". Next refresh in "
+ (refreshOn - SystemTime.getCurrentTime()));
}
SimpleTimer.addEvent("Update G.Rating", refreshOn,
new TimerEventPerformer() {
public void perform(TimerEvent event) {
if (PlatformTorrentUtils.DEBUG_CACHING) {
PlatformTorrentUtils.log("v3.GR.caching: refresh timer calling updateFromPlatform");
}
updateFromPlatform(torrent, 15000);
}
});
|
public static void | updateFromPlatform(org.gudy.azureus2.core3.torrent.TOTorrent torrent, long maxDelayMS)
try {
final String hash = torrent.getHashWrapper().toBase32String();
if (PlatformTorrentUtils.DEBUG_CACHING) {
PlatformTorrentUtils.log("v3.GR.caching: updateFromPlatform for "
+ torrent);
}
PlatformRatingMessenger.getGlobalRating(new String[] {
PlatformRatingMessenger.RATE_TYPE_CONTENT
}, new String[] {
hash
}, 5000, new GetRatingReplyListener() {
public void replyReceived(String replyType,
PlatformRatingMessenger.GetRatingReply reply) {
if (PlatformTorrentUtils.DEBUG_CACHING) {
PlatformTorrentUtils.log("v3.GR.caching: reply '" + replyType
+ "' for " + torrent);
}
if (replyType.equals(PlatformMessenger.REPLY_RESULT)) {
String type = PlatformRatingMessenger.RATE_TYPE_CONTENT;
String rating = reply.getRatingString(hash, type);
String color = reply.getRatingColor(hash, type);
long count = reply.getRatingCount(hash, type);
long expireyMins = reply.getRatingExpireyMins(hash, type);
if (expireyMins <= 0) {
expireyMins = DEF_EXPIRY_MINS;
}
long refreshOn = SystemTime.getCurrentTime()
+ (expireyMins * 60 * 1000L);
setRating(torrent, rating, color, count, refreshOn);
} else if (replyType.equals(PlatformMessenger.REPLY_EXCEPTION)) {
// try again in a bit
SimpleTimer.addEvent("Update MD Retry", SystemTime.getCurrentTime()
+ RETRY_UPDATERATING, new TimerEventPerformer() {
public void perform(TimerEvent event) {
if (PlatformTorrentUtils.DEBUG_CACHING) {
PlatformTorrentUtils.log("v3.GR.caching: retrying..");
}
updateFromPlatform(torrent, 15000);
}
});
}
}
public void messageSent() {
}
});
} catch (TOTorrentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
|