All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sshtools.jajafx.AppInstall4JUpdateService Maven / Gradle / Ivy

The newest version!
package com.sshtools.jajafx;

import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sshtools.jaul.AppRegistry.App;
import com.sshtools.jaul.Install4JUpdater.Install4JUpdaterBuilder;

public class AppInstall4JUpdateService extends AbstractAppUpdateService {

	static Logger log = LoggerFactory.getLogger(AppInstall4JUpdateService.class);

	private final App app;

	public AppInstall4JUpdateService(JajaApp, ?> context, App app) {
		super(context);
		this.app = app;
	}

	protected String buildUpdateUrl() {
		return app.getUpdatesUrl().orElseThrow(() -> new IllegalStateException("No updates URL set."))
				.replace("${phase}", getContext().getPhase().name().toLowerCase());
	}

	@Override
	protected String doUpdate(boolean checkOnly) throws IOException {
		return Install4JUpdaterBuilder.builder().
				withCheckOnly(checkOnly).
				withCurrentVersion(context.getCommandSpec().version()[0]).withLauncherId(app.getLauncherId()).
				withUpdateUrl(buildUpdateUrl()).onExit((e) -> context.exit(e)).
				build().call();

	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy