small fix to batch update
This commit is contained in:
parent
71cacecfea
commit
3cf8987b0b
4 changed files with 25 additions and 19 deletions
|
@ -6,6 +6,7 @@ import static net.osmand.data.IndexConstants.BINARY_MAP_VERSION;
|
||||||
import static net.osmand.data.IndexConstants.VOICE_INDEX_EXT_ZIP;
|
import static net.osmand.data.IndexConstants.VOICE_INDEX_EXT_ZIP;
|
||||||
import static net.osmand.data.IndexConstants.VOICE_VERSION;
|
import static net.osmand.data.IndexConstants.VOICE_VERSION;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -17,8 +18,10 @@ import java.net.HttpURLConnection;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.osmand.LogUtil;
|
import net.osmand.LogUtil;
|
||||||
|
@ -35,13 +38,13 @@ public class DownloaderIndexFromGoogleCode {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) throws URISyntaxException, IOException {
|
public static void main(String[] args) throws URISyntaxException, IOException {
|
||||||
Map<String, String> files = DownloaderIndexFromGoogleCode.getContent(new LinkedHashMap<String, String>(),
|
// Map<String, String> files = DownloaderIndexFromGoogleCode.getContent(new LinkedHashMap<String, String>(),
|
||||||
BINARY_MAP_VERSION + BINARY_MAP_INDEX_EXT,
|
// BINARY_MAP_VERSION + BINARY_MAP_INDEX_EXT,
|
||||||
BINARY_MAP_VERSION + BINARY_MAP_INDEX_EXT_ZIP,
|
// BINARY_MAP_VERSION + BINARY_MAP_INDEX_EXT_ZIP,
|
||||||
VOICE_VERSION + VOICE_INDEX_EXT_ZIP);
|
// VOICE_VERSION + VOICE_INDEX_EXT_ZIP);
|
||||||
for(String s : files.keySet()){
|
// for(String s : files.keySet()){
|
||||||
System.out.println(s + " " + files.get(s)); //$NON-NLS-1$
|
// System.out.println(s + " " + files.get(s)); //$NON-NLS-1$
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
// String odb = ""; //$NON-NLS-1$
|
// String odb = ""; //$NON-NLS-1$
|
||||||
|
@ -57,6 +60,7 @@ public class DownloaderIndexFromGoogleCode {
|
||||||
// deleteFileFromGoogleDownloads(odb, token, pagegen, cookieHSID,cookieSID);
|
// deleteFileFromGoogleDownloads(odb, token, pagegen, cookieHSID,cookieSID);
|
||||||
// }
|
// }
|
||||||
// System.out.println("DELETED " + indexFiles.size());
|
// System.out.println("DELETED " + indexFiles.size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,7 @@ public class GoogleCodeUploadIndex {
|
||||||
* Creates a (base64-encoded) HTTP basic authentication token for the
|
* Creates a (base64-encoded) HTTP basic authentication token for the
|
||||||
* given user name and password.
|
* given user name and password.
|
||||||
*/
|
*/
|
||||||
private static String createAuthToken(String userName, String password) {
|
public static String createAuthToken(String userName, String password) {
|
||||||
String string = (userName + ":" + password); //$NON-NLS-1$
|
String string = (userName + ":" + password); //$NON-NLS-1$
|
||||||
try {
|
try {
|
||||||
return Base64.encode(string.getBytes("UTF-8")); //$NON-NLS-1$
|
return Base64.encode(string.getBytes("UTF-8")); //$NON-NLS-1$
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class IndexBatchCreator {
|
||||||
public String cityAdminLevel;
|
public String cityAdminLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean uploadToOsmandDownloads = true;
|
private boolean uploadToOsmandGooglecode = true;
|
||||||
|
|
||||||
|
|
||||||
// process atributtes
|
// process atributtes
|
||||||
|
@ -94,11 +94,13 @@ public class IndexBatchCreator {
|
||||||
|
|
||||||
String user;
|
String user;
|
||||||
String password;
|
String password;
|
||||||
|
|
||||||
|
private String wget;
|
||||||
|
|
||||||
String cookieHSID = "";
|
String cookieHSID = "";
|
||||||
String cookieSID = "";
|
String cookieSID = "";
|
||||||
String pagegen = "";
|
String pagegen = "";
|
||||||
String token = "";
|
String token = "";
|
||||||
private String wget;
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -192,13 +194,13 @@ public class IndexBatchCreator {
|
||||||
cookieSID = authorization.getAttribute("cookieSID");
|
cookieSID = authorization.getAttribute("cookieSID");
|
||||||
pagegen = authorization.getAttribute("pagegen");
|
pagegen = authorization.getAttribute("pagegen");
|
||||||
token = authorization.getAttribute("token");
|
token = authorization.getAttribute("token");
|
||||||
uploadToOsmandDownloads = Boolean.parseBoolean(process.getAttribute("upload_osmand_download"));
|
uploadToOsmandGooglecode = Boolean.parseBoolean(process.getAttribute("upload_osmand_googlecode"));
|
||||||
if(uploadToOsmandDownloads){
|
if(uploadToOsmandGooglecode){
|
||||||
user = authorization.getAttribute("osmand_download_user");
|
|
||||||
password = authorization.getAttribute("osmand_download_password");
|
|
||||||
} else {
|
|
||||||
user = authorization.getAttribute("google_code_user");
|
user = authorization.getAttribute("google_code_user");
|
||||||
password = authorization.getAttribute("google_code_password");
|
password = authorization.getAttribute("google_code_password");
|
||||||
|
} else {
|
||||||
|
user = authorization.getAttribute("osmand_download_user");
|
||||||
|
password = authorization.getAttribute("osmand_download_password");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,12 +625,12 @@ public class IndexBatchCreator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean uploadFileToServer(File f, File original, String summary) throws IOException {
|
private boolean uploadFileToServer(File f, File original, String summary) throws IOException {
|
||||||
if (f.length() / MB > MAX_UPLOAD_SIZE && !uploadToOsmandDownloads) {
|
if (f.length() / MB > MAX_UPLOAD_SIZE && uploadToOsmandGooglecode) {
|
||||||
System.err.println("ERROR : file " + f.getName() + " exceeded 200 mb!!! Could not be uploaded.");
|
System.err.println("ERROR : file " + f.getName() + " exceeded 200 mb!!! Could not be uploaded.");
|
||||||
return false; // restriction for google code
|
return false; // restriction for google code
|
||||||
}
|
}
|
||||||
double originalLength = (double) original.length() / MB;
|
double originalLength = (double) original.length() / MB;
|
||||||
if (!uploadToOsmandDownloads) {
|
if (uploadToOsmandGooglecode) {
|
||||||
try {
|
try {
|
||||||
DownloaderIndexFromGoogleCode.deleteFileFromGoogleDownloads(f.getName(), token, pagegen, cookieHSID, cookieSID);
|
DownloaderIndexFromGoogleCode.deleteFileFromGoogleDownloads(f.getName(), token, pagegen, cookieHSID, cookieSID);
|
||||||
try {
|
try {
|
||||||
|
@ -646,7 +648,7 @@ public class IndexBatchCreator {
|
||||||
MessageFormat numberFormat = new MessageFormat("{0,number,##.#}", Locale.US);
|
MessageFormat numberFormat = new MessageFormat("{0,number,##.#}", Locale.US);
|
||||||
String size = numberFormat.format(new Object[] { originalLength });
|
String size = numberFormat.format(new Object[] { originalLength });
|
||||||
String date = dateFormat.format(new Object[] { new Date(original.lastModified()) });
|
String date = dateFormat.format(new Object[] { new Date(original.lastModified()) });
|
||||||
if (uploadToOsmandDownloads) {
|
if (!uploadToOsmandGooglecode) {
|
||||||
uploadToDownloadOsmandNet(f, summary, size, date);
|
uploadToDownloadOsmandNet(f, summary, size, date);
|
||||||
} else {
|
} else {
|
||||||
String descriptionFile = "{" + date + " : " + size + " MB}";
|
String descriptionFile = "{" + date + " : " + size + " MB}";
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
or you can upload any file you have to googlecode (just put into 'directory_for_index_files')
|
or you can upload any file you have to googlecode (just put into 'directory_for_index_files')
|
||||||
-->
|
-->
|
||||||
<process directory_for_osm_files="D:/android/batch_gen_osm" directory_for_index_files="D:/android/batch_gen_index"
|
<process directory_for_osm_files="D:/android/batch_gen_osm" directory_for_index_files="D:/android/batch_gen_index"
|
||||||
downloadOsmFiles="true" generateIndexes="true" uploadIndexes="true" upload_osmand_download="true"
|
downloadOsmFiles="true" generateIndexes="true" uploadIndexes="true" upload_osmand_googlecode="true"
|
||||||
deleteFilesAfterUploading="true" indexPOI="true" indexMap="true"
|
deleteFilesAfterUploading="true" indexPOI="true" indexMap="true"
|
||||||
indexTransport="true" indexAddress="true" mapZooms="" renderingTypesFile=""
|
indexTransport="true" indexAddress="true" mapZooms="" renderingTypesFile=""
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue