|
|
|
@ -16,6 +16,9 @@ public class Vault {
|
|
|
|
|
private final UUIDMap<VaultEntry> _entries = new UUIDMap<>();
|
|
|
|
|
private final UUIDMap<VaultGroup> _groups = new UUIDMap<>();
|
|
|
|
|
|
|
|
|
|
// Whether we've migrated the group list to the new format while parsing the vault
|
|
|
|
|
private boolean _isGroupsMigrationFresh = false;
|
|
|
|
|
|
|
|
|
|
public JSONObject toJson() {
|
|
|
|
|
return toJson(null);
|
|
|
|
|
}
|
|
|
|
@ -70,7 +73,9 @@ public class Vault {
|
|
|
|
|
JSONArray array = obj.getJSONArray("entries");
|
|
|
|
|
for (int i = 0; i < array.length(); i++) {
|
|
|
|
|
VaultEntry entry = VaultEntry.fromJson(array.getJSONObject(i));
|
|
|
|
|
vault.migrateOldGroup(entry);
|
|
|
|
|
if (vault.migrateOldGroup(entry)) {
|
|
|
|
|
vault.setGroupsMigrationFresh();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// check the vault has a group corresponding to each one the entry claims to be in
|
|
|
|
|
for (UUID groupUuid: entry.getGroups()) {
|
|
|
|
@ -88,7 +93,15 @@ public class Vault {
|
|
|
|
|
return vault;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void migrateOldGroup(VaultEntry entry) {
|
|
|
|
|
private void setGroupsMigrationFresh() {
|
|
|
|
|
_isGroupsMigrationFresh = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isGroupsMigrationFresh() {
|
|
|
|
|
return _isGroupsMigrationFresh;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean migrateOldGroup(VaultEntry entry) {
|
|
|
|
|
if (entry.getOldGroup() != null) {
|
|
|
|
|
Optional<VaultGroup> optGroup = getGroups().getValues()
|
|
|
|
|
.stream()
|
|
|
|
@ -104,7 +117,10 @@ public class Vault {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
entry.setOldGroup(null);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UUIDMap<VaultEntry> getEntries() {
|
|
|
|
|