Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
diffing catalog and website scan works
- Loading branch information
Showing
3 changed files
with
119 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
download-tools/src/main/java/slash/navigation/download/tools/base/BaseDownloadTool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
This file is part of RouteConverter. | ||
RouteConverter is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
RouteConverter is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with RouteConverter; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
Copyright (C) 2007 Christian Pesch. All Rights Reserved. | ||
*/ | ||
package slash.navigation.download.tools.base; | ||
|
||
import slash.navigation.datasources.DataSourceService; | ||
|
||
import javax.xml.bind.JAXBException; | ||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileNotFoundException; | ||
import java.io.FilenameFilter; | ||
|
||
import static slash.common.io.Directories.ensureDirectory; | ||
import static slash.common.io.Directories.getApplicationDirectory; | ||
|
||
/** | ||
* Base for the download tools. | ||
* | ||
* @author Christian Pesch | ||
*/ | ||
|
||
public class BaseDownloadTool { | ||
protected static final String URL_ARGUMENT = "url"; | ||
|
||
protected File getDataSourcesTarget() { | ||
return ensureDirectory(getApplicationDirectory("snapshot").getAbsolutePath()); | ||
} | ||
|
||
protected File getEditionTarget() { | ||
return ensureDirectory(new File(getDataSourcesTarget(), "editions")); | ||
} | ||
|
||
protected DataSourceService loadDataSources(File directory) throws JAXBException, FileNotFoundException { | ||
DataSourceService dataSourceService = new DataSourceService(); | ||
File[] files = directory.listFiles(new FilenameFilter() { | ||
public boolean accept(File dir, String name) { | ||
return name.endsWith(".xml"); | ||
} | ||
}); | ||
if (files != null) | ||
for (File file : files) | ||
dataSourceService.load(new FileInputStream(file)); | ||
return dataSourceService; | ||
} | ||
} |