* @return The parsed Sone, or {@code null} if the Sone could not be parsed
*/
public Sone parseSone(Sone originalSone, FetchResult fetchResult, FreenetURI requestUri) {
- logger.log(Level.FINEST, "Persing FetchResult (%d bytes, %s) for %s…", new Object[] { fetchResult.size(), fetchResult.getMimeType(), originalSone });
+ logger.log(Level.FINEST, "Parsing FetchResult (%d bytes, %s) for %s…", new Object[] { fetchResult.size(), fetchResult.getMimeType(), originalSone });
Bucket soneBucket = fetchResult.asBucket();
InputStream soneInputStream = null;
try {
}
/**
- * Parses a Sone from the given input stream and updates the given Sone, or
- * creates a new Sone.
+ * Parses a Sone from the given input stream and creates a new Sone from the
+ * parsed data.
*
- * @param sone
+ * @param originalSone
* The Sone to update
* @param soneInputStream
* The input stream to parse the Sone from
* @return The parsed Sone
*/
- public Sone parseSone(Sone sone, InputStream soneInputStream) {
+ public Sone parseSone(Sone originalSone, InputStream soneInputStream) {
/* TODO - impose a size limit? */
Document document;
}
if (document == null) {
/* TODO - mark Sone as bad. */
- logger.log(Level.WARNING, "Could not parse XML for Sone %s!", new Object[] { sone });
+ logger.log(Level.WARNING, "Could not parse XML for Sone %s!", new Object[] { originalSone });
return null;
}
+
+ Sone sone = new Sone(originalSone.getId()).setIdentity(originalSone.getIdentity());
+
SimpleXML soneXml;
try {
soneXml = SimpleXML.fromDocument(document);
sone.setPosts(posts);
sone.setReplies(replies);
sone.setLikePostIds(likedPostIds);
- sone.setModificationCounter(0);
}
return sone;