use of org.openforis.collect.io.exception.DataParsingExeption in project collect by openforis.
the class RecordEntry method parse.
public static RecordEntry parse(String zipEntryName) throws DataParsingExeption {
// for backward compatibility with previous generated backup files
String zipEntryNameFixed = zipEntryName.replace("\\", XMLDataExportProcess.ZIP_DIRECTORY_SEPARATOR);
String[] entryNameSplitted = zipEntryNameFixed.split(XMLDataExportProcess.ZIP_DIRECTORY_SEPARATOR);
if (entryNameSplitted.length != 2) {
throw new DataParsingExeption("Packaged file format exception: wrong zip entry name: " + zipEntryName);
}
// step
String stepNumStr = entryNameSplitted[0];
int stepNumber = Integer.parseInt(stepNumStr);
Step step = Step.valueOf(stepNumber);
// file name
String fileName = entryNameSplitted[1];
String baseName = FilenameUtils.getBaseName(fileName);
int recordId = Integer.parseInt(baseName);
RecordEntry result = new RecordEntry(step, recordId);
return result;
}
Aggregations