diff --git a/DataExtractionOSM/src/net/osmand/data/index/DownloaderIndexFromGoogleCode.java b/DataExtractionOSM/src/net/osmand/data/index/DownloaderIndexFromGoogleCode.java index c0f44b7ba5..14da41a663 100644 --- a/DataExtractionOSM/src/net/osmand/data/index/DownloaderIndexFromGoogleCode.java +++ b/DataExtractionOSM/src/net/osmand/data/index/DownloaderIndexFromGoogleCode.java @@ -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_VERSION; +import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; @@ -17,8 +18,10 @@ import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URISyntaxException; import java.net.URL; +import java.net.URLConnection; import java.util.HashMap; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import net.osmand.LogUtil; @@ -35,13 +38,13 @@ public class DownloaderIndexFromGoogleCode { * @throws IOException */ public static void main(String[] args) throws URISyntaxException, IOException { - Map files = DownloaderIndexFromGoogleCode.getContent(new LinkedHashMap(), - BINARY_MAP_VERSION + BINARY_MAP_INDEX_EXT, - BINARY_MAP_VERSION + BINARY_MAP_INDEX_EXT_ZIP, - VOICE_VERSION + VOICE_INDEX_EXT_ZIP); - for(String s : files.keySet()){ - System.out.println(s + " " + files.get(s)); //$NON-NLS-1$ - } +// Map files = DownloaderIndexFromGoogleCode.getContent(new LinkedHashMap(), +// BINARY_MAP_VERSION + BINARY_MAP_INDEX_EXT, +// BINARY_MAP_VERSION + BINARY_MAP_INDEX_EXT_ZIP, +// VOICE_VERSION + VOICE_INDEX_EXT_ZIP); +// for(String s : files.keySet()){ +// System.out.println(s + " " + files.get(s)); //$NON-NLS-1$ +// } // String odb = ""; //$NON-NLS-1$ @@ -57,6 +60,7 @@ public class DownloaderIndexFromGoogleCode { // deleteFileFromGoogleDownloads(odb, token, pagegen, cookieHSID,cookieSID); // } // System.out.println("DELETED " + indexFiles.size()); + } diff --git a/DataExtractionOSM/src/net/osmand/data/index/GoogleCodeUploadIndex.java b/DataExtractionOSM/src/net/osmand/data/index/GoogleCodeUploadIndex.java index b276da1548..f3c3918eea 100644 --- a/DataExtractionOSM/src/net/osmand/data/index/GoogleCodeUploadIndex.java +++ b/DataExtractionOSM/src/net/osmand/data/index/GoogleCodeUploadIndex.java @@ -184,7 +184,7 @@ public class GoogleCodeUploadIndex { * Creates a (base64-encoded) HTTP basic authentication token for the * 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$ try { return Base64.encode(string.getBytes("UTF-8")); //$NON-NLS-1$ diff --git a/DataExtractionOSM/src/net/osmand/data/index/IndexBatchCreator.java b/DataExtractionOSM/src/net/osmand/data/index/IndexBatchCreator.java index 3b6a49b580..49c91a223a 100644 --- a/DataExtractionOSM/src/net/osmand/data/index/IndexBatchCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/index/IndexBatchCreator.java @@ -72,7 +72,7 @@ public class IndexBatchCreator { public String cityAdminLevel; } - private boolean uploadToOsmandDownloads = true; + private boolean uploadToOsmandGooglecode = true; // process atributtes @@ -94,11 +94,13 @@ public class IndexBatchCreator { String user; String password; + + private String wget; + String cookieHSID = ""; String cookieSID = ""; String pagegen = ""; String token = ""; - private String wget; public static void main(String[] args) { @@ -192,13 +194,13 @@ public class IndexBatchCreator { cookieSID = authorization.getAttribute("cookieSID"); pagegen = authorization.getAttribute("pagegen"); token = authorization.getAttribute("token"); - uploadToOsmandDownloads = Boolean.parseBoolean(process.getAttribute("upload_osmand_download")); - if(uploadToOsmandDownloads){ - user = authorization.getAttribute("osmand_download_user"); - password = authorization.getAttribute("osmand_download_password"); - } else { + uploadToOsmandGooglecode = Boolean.parseBoolean(process.getAttribute("upload_osmand_googlecode")); + if(uploadToOsmandGooglecode){ user = authorization.getAttribute("google_code_user"); 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 { - 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."); return false; // restriction for google code } double originalLength = (double) original.length() / MB; - if (!uploadToOsmandDownloads) { + if (uploadToOsmandGooglecode) { try { DownloaderIndexFromGoogleCode.deleteFileFromGoogleDownloads(f.getName(), token, pagegen, cookieHSID, cookieSID); try { @@ -646,7 +648,7 @@ public class IndexBatchCreator { MessageFormat numberFormat = new MessageFormat("{0,number,##.#}", Locale.US); String size = numberFormat.format(new Object[] { originalLength }); String date = dateFormat.format(new Object[] { new Date(original.lastModified()) }); - if (uploadToOsmandDownloads) { + if (!uploadToOsmandGooglecode) { uploadToDownloadOsmandNet(f, summary, size, date); } else { String descriptionFile = "{" + date + " : " + size + " MB}"; diff --git a/DataExtractionOSM/src/net/osmand/data/index/batch.xml b/DataExtractionOSM/src/net/osmand/data/index/batch.xml index a2d24b6648..457782a5c7 100644 --- a/DataExtractionOSM/src/net/osmand/data/index/batch.xml +++ b/DataExtractionOSM/src/net/osmand/data/index/batch.xml @@ -21,7 +21,7 @@ or you can upload any file you have to googlecode (just put into 'directory_for_index_files') -->