Renamed the getenv and added one for user sources.
Added a (naive) check to prevent duplicate URLs.
Also fixed the repositoy.xml download error message, it was not displaying the reason of failure correctly.
\r
/**\r
* Constructs a new source for the given repository URL.\r
+ * @param url The source URL. Cannot be null. If the URL ends with a /, the default\r
+ * repository.xml filename will be appended automatically.\r
+ * @param userSource True if this a user source (add-ons & packages only.)\r
*/\r
public RepoSource(String url, boolean userSource) {\r
\r
setDefaultDescription();\r
}\r
\r
+ /**\r
+ * Two repo source are equal if they have the same userSource flag and the same URL.\r
+ */\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (obj instanceof RepoSource) {\r
+ RepoSource rs = (RepoSource) obj;\r
+ return rs.isUserSource() == this.isUserSource() && rs.getUrl().equals(this.getUrl());\r
+ }\r
+ return false;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ return mUrl.hashCode() ^ Boolean.valueOf(mUserSource).hashCode();\r
+ }\r
+\r
/** Returns true if this is a user source. We only load addon and extra packages\r
* from a user source and ignore the rest. */\r
public boolean isUserSource() {\r
}\r
}\r
\r
- monitor.setResult("Failed to fetch URL %1$s, reason:", url, reason);\r
+ monitor.setResult("Failed to fetch URL %1$s, reason: %2$s", url, reason);\r
}\r
\r
monitor.incProgress(1);\r
for (int i = 0; i < count; i++) {\r
String url = props.getProperty(String.format("%s%02d", KEY_SRC, i)); //$NON-NLS-1$\r
if (url != null) {\r
- mSources.add(new RepoSource(url, true /*userSource*/));\r
+ RepoSource s = new RepoSource(url, true /*userSource*/);\r
+ if (!hasSource(s)) {\r
+ mSources.add(s);\r
+ }\r
}\r
}\r
}\r
}\r
\r
/**\r
+ * Returns true if there's already a similar source in the sources list.\r
+ * <p/>\r
+ * The search is O(N), which should be acceptable on the expectedly small source list.\r
+ */\r
+ public boolean hasSource(RepoSource source) {\r
+ for (RepoSource s : mSources) {\r
+ if (s.equals(source)) {\r
+ return true;\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ /**\r
* Saves all the user sources.\r
* @param log\r
*/\r
RepoSources sources = mUpdaterData.getSources();\r
sources.add(new RepoSource(SdkRepository.URL_GOOGLE_SDK_REPO_SITE, false /*userSource*/));\r
\r
- String str = System.getenv("TEMP_SDK_URL"); // TODO STOPSHIP temporary remove before shipping\r
+ // SDK_UPDATER_URLS is a semicolon-separated list of URLs that can be used to\r
+ // seed the SDK Updater list for full repositories.\r
+ String str = System.getenv("SDK_UPDATER_URLS");\r
if (str != null) {\r
String[] urls = str.split(";");\r
for (String url : urls) {\r
- sources.add(new RepoSource(url, false /*userSource*/));\r
+ if (url != null && url.length() > 0) {\r
+ RepoSource s = new RepoSource(url, false /*userSource*/);\r
+ if (!sources.hasSource(s)) {\r
+ sources.add(s);\r
+ }\r
+ }\r
}\r
}\r
\r
// Load user sources\r
sources.loadUserSources(mUpdaterData.getSdkLog());\r
\r
+ // SDK_UPDATER_USER_URLS is a semicolon-separated list of URLs that can be used to\r
+ // seed the SDK Updater list for user-only repositories. User sources can only provide\r
+ // add-ons and extra packages.\r
+ str = System.getenv("SDK_UPDATER_USER_URLS");\r
+ if (str != null) {\r
+ String[] urls = str.split(";");\r
+ for (String url : urls) {\r
+ if (url != null && url.length() > 0) {\r
+ RepoSource s = new RepoSource(url, true /*userSource*/);\r
+ if (!sources.hasSource(s)) {\r
+ sources.add(s);\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
mRemotePackagesPage.onSdkChange();\r
}\r
\r