зеркало из https://github.com/mozilla/pjs.git
Bug 718238 - Part 3: correct handling of deletion. Generate valid records for deleted bookmarks and history items. r=nalexander
This commit is contained in:
Родитель
5589445d00
Коммит
94461e643c
|
@ -150,9 +150,13 @@ public class BookmarkRecord extends Record {
|
|||
this.guid = payload.guid;
|
||||
checkGUIDs(p);
|
||||
|
||||
final Object del = p.get("deleted");
|
||||
if (del instanceof Boolean) {
|
||||
this.deleted = (Boolean) del;
|
||||
}
|
||||
|
||||
this.collection = payload.collection;
|
||||
this.lastModified = payload.lastModified;
|
||||
this.deleted = payload.deleted;
|
||||
|
||||
this.type = (String) p.get("type");
|
||||
this.title = (String) p.get("title");
|
||||
|
@ -209,18 +213,23 @@ public class BookmarkRecord extends Record {
|
|||
CryptoRecord rec = new CryptoRecord(this);
|
||||
rec.payload = new ExtendedJSONObject();
|
||||
rec.payload.put("id", this.guid);
|
||||
rec.payload.put("type", this.type);
|
||||
rec.payload.put("title", this.title);
|
||||
rec.payload.put("description", this.description);
|
||||
rec.payload.put("parentid", this.parentID);
|
||||
rec.payload.put("parentName", this.parentName);
|
||||
if (isBookmark()) {
|
||||
rec.payload.put("bmkUri", bookmarkURI);
|
||||
rec.payload.put("keyword", keyword);
|
||||
rec.payload.put("tags", this.tags);
|
||||
}
|
||||
if (isFolder()) {
|
||||
rec.payload.put("children", this.children);
|
||||
|
||||
if (this.deleted) {
|
||||
rec.payload.put("deleted", true);
|
||||
} else {
|
||||
putPayload(rec, "type", this.type);
|
||||
putPayload(rec, "title", this.title);
|
||||
putPayload(rec, "description", this.description);
|
||||
putPayload(rec, "parentid", this.parentID);
|
||||
putPayload(rec, "parentName", this.parentName);
|
||||
|
||||
if (isBookmark()) {
|
||||
rec.payload.put("bmkUri", bookmarkURI);
|
||||
rec.payload.put("keyword", keyword);
|
||||
rec.payload.put("tags", this.tags);
|
||||
} else if (isFolder()) {
|
||||
rec.payload.put("children", this.children);
|
||||
}
|
||||
}
|
||||
return rec;
|
||||
}
|
||||
|
|
|
@ -116,7 +116,10 @@ public class HistoryRecord extends Record {
|
|||
this.checkGUIDs(p);
|
||||
|
||||
this.lastModified = payload.lastModified;
|
||||
this.deleted = payload.deleted;
|
||||
final Object del = p.get("deleted");
|
||||
if (del instanceof Boolean) {
|
||||
this.deleted = (Boolean) del;
|
||||
}
|
||||
|
||||
this.histURI = (String) p.get("histUri");
|
||||
this.title = (String) p.get("title");
|
||||
|
@ -133,10 +136,15 @@ public class HistoryRecord extends Record {
|
|||
CryptoRecord rec = new CryptoRecord(this);
|
||||
rec.payload = new ExtendedJSONObject();
|
||||
Logger.debug(LOG_TAG, "Getting payload for history record " + this.guid + " (" + this.guid.length() + ").");
|
||||
rec.payload.put("id", this.guid);
|
||||
rec.payload.put("title", this.title);
|
||||
rec.payload.put("histUri", this.histURI); // TODO: encoding?
|
||||
rec.payload.put("visits", this.visits);
|
||||
|
||||
if (this.deleted) {
|
||||
rec.payload.put("deleted", true);
|
||||
} else {
|
||||
putPayload(rec, "id", this.guid);
|
||||
putPayload(rec, "title", this.title);
|
||||
putPayload(rec, "histUri", this.histURI); // TODO: encoding?
|
||||
rec.payload.put("visits", this.visits);
|
||||
}
|
||||
return rec;
|
||||
}
|
||||
|
||||
|
|
|
@ -240,6 +240,20 @@ public abstract class Record {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility for safely populating an output CryptoRecord.
|
||||
*
|
||||
* @param rec
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
protected void putPayload(CryptoRecord rec, String key, String value) {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
rec.payload.put(key, value);
|
||||
}
|
||||
|
||||
protected void checkGUIDs(ExtendedJSONObject payload) {
|
||||
String payloadGUID = (String) payload.get("id");
|
||||
if (this.guid == null ||
|
||||
|
|
Загрузка…
Ссылка в новой задаче