Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: editor/tools/plugins/com.google.dart.tools.update.core/src/com/google/dart/tools/update/core/internal/UpdateUtils.java

Issue 10689140: Version details go JSON (dartbug.com/3196). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « editor/tools/plugins/com.google.dart.tools.update.core/META-INF/MANIFEST.MF ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.tools.update.core/src/com/google/dart/tools/update/core/internal/UpdateUtils.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.update.core/src/com/google/dart/tools/update/core/internal/UpdateUtils.java (revision 9521)
+++ editor/tools/plugins/com.google.dart.tools.update.core/src/com/google/dart/tools/update/core/internal/UpdateUtils.java (working copy)
@@ -20,6 +20,8 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.util.Util;
import org.eclipse.swt.internal.Library;
+import org.json.JSONException;
+import org.json.JSONObject;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@@ -308,6 +310,33 @@
}
/**
+ * Parse the revision number from a JSON string.
+ * <p>
+ * Sample payload:
+ * </p>
+ *
+ * <pre>
+ * {
+ * "revision" : "9826",
+ * "version" : "0.0.1_v2012070961811",
+ * "date" : "2012-07-09"
+ * }
+ * </pre>
+ *
+ * @param versionJSON the json
+ * @return a revision number or <code>null</code> if none can be found
+ * @throws IOException
+ */
+ public static String parseRevisionNumberFromJSON(String versionJSON) throws IOException {
+ try {
+ JSONObject obj = new JSONObject(versionJSON);
+ return obj.optString("revision", null);
+ } catch (JSONException e) {
+ throw new IOException(e);
+ }
+ }
+
+ /**
* Parse the latest revision from the VERSION file at the given url.
*
* @param url the url to check
@@ -315,8 +344,15 @@
* @throws IOException if an exception occurred in retrieving the revision
*/
public static Revision parseVersionFile(String url) throws IOException {
+
String versionFileContents = readUrlStream(url);
- return Revision.forValue(versionFileContents);
+
+ //TODO (pquitslund): temporary check for "old" numeric format,
+ //to be removed once the JSON format is final
+ String revisionString = versionFileContents.trim().matches("-?\\d+(.\\d+)?")
+ ? versionFileContents : parseRevisionNumberFromJSON(versionFileContents);
+
+ return Revision.forValue(revisionString);
}
/**
« no previous file with comments | « editor/tools/plugins/com.google.dart.tools.update.core/META-INF/MANIFEST.MF ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698