make the -local work also for regions.xml file
This commit is contained in:
parent
f7075d82d4
commit
2f044e68de
1 changed files with 18 additions and 5 deletions
|
@ -90,7 +90,6 @@ public class IndexBatchCreator {
|
||||||
File osmDirFiles;
|
File osmDirFiles;
|
||||||
File indexDirFiles;
|
File indexDirFiles;
|
||||||
File backupUploadedFiles;
|
File backupUploadedFiles;
|
||||||
File regionsFile;
|
|
||||||
|
|
||||||
boolean indexPOI = false;
|
boolean indexPOI = false;
|
||||||
boolean indexTransport = false;
|
boolean indexTransport = false;
|
||||||
|
@ -108,6 +107,7 @@ public class IndexBatchCreator {
|
||||||
String cookieSID = "";
|
String cookieSID = "";
|
||||||
String pagegen = "";
|
String pagegen = "";
|
||||||
String token = "";
|
String token = "";
|
||||||
|
private boolean local;
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -121,6 +121,7 @@ public class IndexBatchCreator {
|
||||||
InputStream stream;
|
InputStream stream;
|
||||||
if(name.equals("-local")){
|
if(name.equals("-local")){
|
||||||
stream = IndexBatchCreator.class.getResourceAsStream("batch.xml");
|
stream = IndexBatchCreator.class.getResourceAsStream("batch.xml");
|
||||||
|
creator.setLocal(true);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
stream = new FileInputStream(name);
|
stream = new FileInputStream(name);
|
||||||
|
@ -154,6 +155,10 @@ public class IndexBatchCreator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setLocal(boolean local) {
|
||||||
|
this.local = local;
|
||||||
|
}
|
||||||
|
|
||||||
public void runBatch(Document doc) throws SAXException, IOException, ParserConfigurationException{
|
public void runBatch(Document doc) throws SAXException, IOException, ParserConfigurationException{
|
||||||
NodeList list = doc.getElementsByTagName("process");
|
NodeList list = doc.getElementsByTagName("process");
|
||||||
if(list.getLength() != 1){
|
if(list.getLength() != 1){
|
||||||
|
@ -187,13 +192,21 @@ public class IndexBatchCreator {
|
||||||
throw new IllegalArgumentException("Please specify directory with generated index files as directory_for_index_files (attribute)"); //$NON-NLS-1$
|
throw new IllegalArgumentException("Please specify directory with generated index files as directory_for_index_files (attribute)"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
indexDirFiles = new File(dir);
|
indexDirFiles = new File(dir);
|
||||||
|
InputStream regionsStream = null;
|
||||||
if(downloadFiles){
|
if(downloadFiles){
|
||||||
dir = process.getAttribute("list_download_regions_file");
|
dir = process.getAttribute("list_download_regions_file");
|
||||||
if(!Algoritms.isEmpty(dir)) {
|
if(!Algoritms.isEmpty(dir)) {
|
||||||
regionsFile = new File(dir);
|
File regionsFile = new File(dir);
|
||||||
if(!regionsFile.exists()){
|
if(!regionsFile.exists()){
|
||||||
|
if (local) {
|
||||||
|
regionsStream = IndexBatchCreator.class.getResourceAsStream("regions.xml");
|
||||||
|
}
|
||||||
|
if (regionsStream == null) {
|
||||||
throw new IllegalArgumentException("Please specify file with regions to download as list_download_regions_file (attribute)"); //$NON-NLS-1$
|
throw new IllegalArgumentException("Please specify file with regions to download as list_download_regions_file (attribute)"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
regionsStream = new FileInputStream(regionsFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,8 +255,8 @@ public class IndexBatchCreator {
|
||||||
|
|
||||||
List<RegionCountries> countriesToDownload = new ArrayList<RegionCountries>();
|
List<RegionCountries> countriesToDownload = new ArrayList<RegionCountries>();
|
||||||
parseCountriesToDownload(doc, countriesToDownload);
|
parseCountriesToDownload(doc, countriesToDownload);
|
||||||
if(regionsFile != null){
|
if(regionsStream != null){
|
||||||
Document innerDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(regionsFile);
|
Document innerDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(regionsStream);
|
||||||
parseCountriesToDownload(innerDoc, countriesToDownload);
|
parseCountriesToDownload(innerDoc, countriesToDownload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue