small fix to batch update

This commit is contained in:
Victor Shcherb 2011-05-04 22:51:17 +02:00
parent 71cacecfea
commit 3cf8987b0b
4 changed files with 25 additions and 19 deletions

View file

@ -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<String, String> files = DownloaderIndexFromGoogleCode.getContent(new LinkedHashMap<String, String>(),
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<String, String> files = DownloaderIndexFromGoogleCode.getContent(new LinkedHashMap<String, String>(),
// 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());
}

View file

@ -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$

View file

@ -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}";

View file

@ -21,7 +21,7 @@
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"
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"
indexTransport="true" indexAddress="true" mapZooms="" renderingTypesFile=""
>