Search in sources :

Example 1 with UserAbortException

use of org.graalvm.component.installer.UserAbortException in project graal by oracle.

the class LicensePresenter method displaySingleLicense.

void displaySingleLicense() {
    String licId = licensesToAccept.keySet().iterator().next();
    MetadataLoader ldr = licensesToAccept.get(licId).get(0);
    String type = ldr.getLicenseType();
    String compList = formatComponentList(licId);
    feedback.output("INSTALL_AcceptLicense", compList, type);
    feedback.outputPart("INSTALL_AcceptSingleLicense");
    String input = feedback.acceptLine(true);
    if (isYes(input)) {
        acceptLicense(licId);
        return;
    } else if (isRead(input)) {
        displayLicenseId = licId;
        state = State.LICENSE;
    } else {
        throw new UserAbortException();
    }
}
Also used : MetadataLoader(org.graalvm.component.installer.persist.MetadataLoader) UserAbortException(org.graalvm.component.installer.UserAbortException)

Example 2 with UserAbortException

use of org.graalvm.component.installer.UserAbortException in project graal by oracle.

the class LicensePresenter method processUserInputForList.

int processUserInputForList() {
    String userInput = feedback.acceptLine(true);
    Pattern p = Pattern.compile(feedback.l10n("INSTALL_AcceptPromptResponseAbort@"), Pattern.CASE_INSENSITIVE);
    if (p.matcher(userInput).matches()) {
        throw new UserAbortException();
    }
    if (isYes(userInput)) {
        acceptAllLicenses();
        state = State.NONE;
        return 0;
    }
    if (!ALL_NUMBERS.matcher(userInput).matches()) {
        feedback.output("INSTALL_LicenseNumberInvalidEntry", licensesToAccept.size());
        return -1;
    }
    int n = Integer.parseInt(userInput);
    if (n < 0 || n > licensesToAccept.size()) {
        feedback.output("INSTALL_LicenseNumberOutOfRange", licensesToAccept.size());
        return -1;
    }
    return n;
}
Also used : Pattern(java.util.regex.Pattern) UserAbortException(org.graalvm.component.installer.UserAbortException)

Example 3 with UserAbortException

use of org.graalvm.component.installer.UserAbortException in project graal by oracle.

the class LicensePresenter method displayLicenseText.

void displayLicenseText() throws IOException {
    String text = loadLicenseText(displayLicenseId);
    feedback.verbatimOut(text, false);
    feedback.output("INSTALL_AcceptLicensePrompt");
    String input = feedback.acceptLine(true);
    if (isYes(input)) {
        acceptLicense(displayLicenseId);
        state = multiLicenses ? State.LIST : State.SINGLE;
    } else if (!multiLicenses) {
        throw new UserAbortException();
    } else {
        state = State.LIST;
    }
}
Also used : UserAbortException(org.graalvm.component.installer.UserAbortException)

Example 4 with UserAbortException

use of org.graalvm.component.installer.UserAbortException in project graal by oracle.

the class InstallCommand method executeStep.

void executeStep(Step s, boolean close) throws IOException {
    boolean ok = false;
    try {
        s.execute();
        ok = true;
    } catch (ZipException ex) {
        feedback.error("INSTALL_InvalidComponentArchive", ex, current);
        throw ex;
    } catch (UserAbortException ex) {
        throw ex;
    } catch (InstallerStopException | IOException ex) {
        if (ignoreFailures) {
            if (current == null) {
                feedback.error("INSTALL_IgnoreFailedInstallation", ex, ex.getLocalizedMessage());
            } else {
                feedback.error("INSTALL_IgnoreFailedInstallation2", ex, current, ex.getLocalizedMessage());
            }
        } else {
            if (current != null) {
                feedback.error("INSTALL_ErrorDuringProcessing", ex, current, ex.getLocalizedMessage());
            }
            throw ex;
        }
    } finally {
        if (!ok) {
            for (Installer inst : executedInstallers) {
                inst.revertInstall();
            }
        }
        if (close || !ok) {
            for (Installer inst : installers) {
                try {
                    inst.close();
                } catch (IOException ex) {
                // expected
                }
            }
        }
    }
}
Also used : ComponentInstaller(org.graalvm.component.installer.ComponentInstaller) ZipException(java.util.zip.ZipException) UserAbortException(org.graalvm.component.installer.UserAbortException) IOException(java.io.IOException) InstallerStopException(org.graalvm.component.installer.InstallerStopException)

Aggregations

UserAbortException (org.graalvm.component.installer.UserAbortException)4 IOException (java.io.IOException)1 Pattern (java.util.regex.Pattern)1 ZipException (java.util.zip.ZipException)1 ComponentInstaller (org.graalvm.component.installer.ComponentInstaller)1 InstallerStopException (org.graalvm.component.installer.InstallerStopException)1 MetadataLoader (org.graalvm.component.installer.persist.MetadataLoader)1