public boolean checkForUpdates()

in taverna-update-impl/src/main/java/org/apache/taverna/update/impl/UpdateManagerImpl.java [80:115]


	public boolean checkForUpdates() throws UpdateException {
		ApplicationProfile applicationProfile = applicationConfiguration.getApplicationProfile();
		String version = applicationProfile.getVersion();
		Updates updates = applicationProfile.getUpdates();

		URI updatesURL;
		try {
			URI updateSiteURI = new URI(updates.getUpdateSite());
			updatesURL = updateSiteURI.resolve(updates.getUpdatesFile());
		} catch (URISyntaxException e) {
			throw new UpdateException(String.format("Update site URL (%s) is not a valid URL",
					updates.getUpdateSite()), e);
		}
		File updateDirectory = applicationConfiguration.getApplicationHomeDir().resolve("updates").toFile();
		updateDirectory.mkdirs();
		File updatesFile = new File(updateDirectory, updates.getUpdatesFile());
		try {
			downloadManager.download(updatesURL, updatesFile.toPath(), DIGEST_ALGORITHM);
		} catch (DownloadException e) {
			throw new UpdateException(String.format("Error downloading %1$s",
					updatesURL), e);
		}

		try {
			UpdateSite updateSite = (UpdateSite) unmarshaller
					.unmarshal(updatesFile);
			applicationVersions = updateSite.getVersions();
			latestVersion = applicationVersions.getLatestVersion();
			updateAvailable = isHigherVersion(latestVersion.getVersion(), version);
		} catch (JAXBException e) {
			throw new UpdateException(String.format("Error reading %s",
					updatesFile.getName()), e);
		}
		lastCheckTime = System.currentTimeMillis();
		return updateAvailable;
	}