Support altered data format
This commit is contained in:
parent
816d52b9b3
commit
2dc6170933
|
@ -61,8 +61,9 @@ public abstract class AbstractDatabase<T extends AbstractDatabaseDataSlice<V>, V
|
|||
try (InputStream is = Utils.getContext().getAssets().open(fileName);
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is))) {
|
||||
|
||||
if (!"MDI".equals(bufferedReader.readLine())) {
|
||||
LOG.debug("loadInfoData() incorrect header");
|
||||
String headerString = bufferedReader.readLine();
|
||||
if (!"YACBSIAI".equals(headerString) && !"MDI".equals(headerString)) {
|
||||
LOG.debug("loadInfoData() incorrect header: {}", headerString);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ public abstract class AbstractDatabaseDataSlice<T> {
|
|||
|
||||
LOG.trace("loadFromStream() reading endmark");
|
||||
String endmarkString = stream.readUtf8StringChars(6);
|
||||
if (!"MTZEND".equalsIgnoreCase(endmarkString)) {
|
||||
if (!"YABEND".equalsIgnoreCase(endmarkString) && !"MTZEND".equalsIgnoreCase(endmarkString)) {
|
||||
throw new IllegalStateException("Endmark not found. Found instead: " + endmarkString);
|
||||
}
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ public class CommunityDatabase extends AbstractDatabase<CommunityDatabaseDataSli
|
|||
|
||||
private String getSecondarySliceFilePath(int id) {
|
||||
File dir = Utils.getContext().getFilesDir();
|
||||
return dir.getAbsolutePath() + "/sia_updates_" + id + ".mtz";
|
||||
return dir.getAbsolutePath() + "/sia_updates_" + id + ".sia";
|
||||
}
|
||||
|
||||
public void resetSecondaryDatabase() {
|
||||
|
@ -177,7 +177,7 @@ public class CommunityDatabase extends AbstractDatabase<CommunityDatabaseDataSli
|
|||
FileFilter fileFilter = new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
return pathname.getName().endsWith(".mtz");
|
||||
return pathname.getName().endsWith(".sia");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -242,7 +242,7 @@ public class CommunityDatabase extends AbstractDatabase<CommunityDatabaseDataSli
|
|||
if (contentType != null && "application".equals(contentType.type())) {
|
||||
LOG.trace("updateSecondaryDbInternal() saving response data to file");
|
||||
|
||||
File tempFile = File.createTempFile("mtz", "database", Utils.getContext().getCacheDir());
|
||||
File tempFile = File.createTempFile("sia", "database", Utils.getContext().getCacheDir());
|
||||
|
||||
int totalRead = 0;
|
||||
try (InputStream in = body.byteStream();
|
||||
|
|
|
@ -93,7 +93,8 @@ public class CommunityDatabaseDataSlice extends AbstractDatabaseDataSlice<Commun
|
|||
|
||||
@Override
|
||||
protected void loadFromStreamCheckHeader(String header) {
|
||||
if (!"MTZF".equalsIgnoreCase(header) && !"MTZD".equalsIgnoreCase(header)) {
|
||||
if (!"YABF".equalsIgnoreCase(header) && !"MTZF".equalsIgnoreCase(header)
|
||||
&& !"MTZD".equalsIgnoreCase(header)) {
|
||||
throw new IllegalStateException("Invalid header. Actual value: " + header);
|
||||
}
|
||||
}
|
||||
|
@ -169,7 +170,7 @@ public class CommunityDatabaseDataSlice extends AbstractDatabaseDataSlice<Commun
|
|||
}
|
||||
|
||||
LittleEndianDataOutputStream stream = new LittleEndianDataOutputStream(outputStream);
|
||||
stream.writeUtf8StringChars("MTZF");
|
||||
stream.writeUtf8StringChars("YABF");
|
||||
stream.writeByte((byte) 1);
|
||||
stream.writeInt(newSlice != null ? newSlice.dbVersion : this.dbVersion);
|
||||
stream.writeUtf8StringChars("ww");
|
||||
|
@ -232,7 +233,7 @@ public class CommunityDatabaseDataSlice extends AbstractDatabaseDataSlice<Commun
|
|||
}
|
||||
stream.writeUtf8StringChars("CP");
|
||||
stream.writeInt(0);
|
||||
stream.writeUtf8StringChars("MTZEND");
|
||||
stream.writeUtf8StringChars("YABEND");
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
LOG.error("writeMerged()", e);
|
||||
|
|
|
@ -8,7 +8,7 @@ class DatabaseDataSliceNode {
|
|||
this.sliceTree = new DatabaseDataSliceNode[10];
|
||||
|
||||
for (int i = 0; i <= 9; i++) {
|
||||
if (data.charAt(offset) == '+') {
|
||||
if (data.charAt(offset) == '*' || data.charAt(offset) == '+') {
|
||||
offset++;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ public class FeaturedDatabaseDataSlice extends AbstractDatabaseDataSlice<Feature
|
|||
|
||||
@Override
|
||||
protected void loadFromStreamCheckHeader(String header) {
|
||||
if (!"MTZX".equalsIgnoreCase(header)) {
|
||||
if (!"YABX".equalsIgnoreCase(header) && !"MTZX".equalsIgnoreCase(header)) {
|
||||
throw new IllegalStateException("Invalid header. Actual value: " + header);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue