Search in sources :

Example 1 with FailedOperationException

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

the class CatalogInstallTest method testInstallWithBrokenDeps.

@Test
public void testInstallWithBrokenDeps() throws Exception {
    setupVersion("19.3-dev");
    setupCatalog(null);
    paramIterable = new CatalogIterable(this, this);
    textParams.add("additional");
    InstallCommand cmd = new InstallCommand();
    cmd.init(this, withBundle(InstallCommand.class));
    cmd.executionInit();
    exception.expect(FailedOperationException.class);
    exception.expectMessage("INSTALL_UnresolvedDependencies");
    try {
        cmd.executeStep(cmd::prepareInstallation, false);
    } catch (FailedOperationException ex) {
        Set<String> u = cmd.getUnresolvedDependencies();
        assertFalse(u.isEmpty());
        assertEquals("org.graalvm.unknown", u.iterator().next());
        throw ex;
    }
}
Also used : FailedOperationException(org.graalvm.component.installer.FailedOperationException) Set(java.util.Set) CatalogIterable(org.graalvm.component.installer.remote.CatalogIterable) Test(org.junit.Test)

Example 2 with FailedOperationException

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

the class UpgradeProcess method migrateLicenses.

/*
     * public void identifyMigratedCompoents(ComponentInfo target) { if
     * (!satisfiedAddedComponents(target)) { throw
     * feedback.failure("UPGRADE_NoVersionSatisfiesComponents", null); } this.targetInfo = target;
     * this.addComponents.addAll(findInstallables(target)); }
     */
public void migrateLicenses() {
    if (!SystemUtils.isLicenseTrackingEnabled()) {
        return;
    }
    feedback.output("UPGRADE_MigratingLicenses", input.getLocalRegistry().getGraalVersion().displayString(), targetInfo.getVersion().displayString());
    for (Map.Entry<String, Collection<String>> e : input.getLocalRegistry().getAcceptedLicenses().entrySet()) {
        String licId = e.getKey();
        for (String compId : e.getValue()) {
            try {
                String t = input.getLocalRegistry().licenseText(licId);
                ComponentInfo info = input.getLocalRegistry().findComponent(compId);
                Date d = input.getLocalRegistry().isLicenseAccepted(info, licId);
                newGraalRegistry.acceptLicense(info, licId, t, d);
            } catch (FailedOperationException ex) {
                feedback.error("UPGRADE_CannotMigrateLicense", ex, compId, licId);
            }
        }
    }
    // dirty way how to migrate GDS settings:
    Path gdsSettings = SystemUtils.resolveRelative(input.getGraalHomePath(), CommonConstants.PATH_COMPONENT_STORAGE + "/gds");
    if (Files.isDirectory(gdsSettings)) {
        Path targetGdsSettings = SystemUtils.resolveRelative(newInstallPath.resolve(SystemUtils.getGraalVMJDKRoot(newGraalRegistry)), CommonConstants.PATH_COMPONENT_STORAGE + "/gds");
        try {
            SystemUtils.copySubtree(gdsSettings, targetGdsSettings);
        } catch (IOException ex) {
            feedback.error("UPGRADE_CannotMigrateGDS", ex, ex.getLocalizedMessage());
        }
    }
}
Also used : Path(java.nio.file.Path) FailedOperationException(org.graalvm.component.installer.FailedOperationException) ComponentCollection(org.graalvm.component.installer.ComponentCollection) Collection(java.util.Collection) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) IOException(java.io.IOException) HashMap(java.util.HashMap) Map(java.util.Map) Date(java.util.Date)

Example 3 with FailedOperationException

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

the class UpgradeProcess method failIfDirectotyExistsNotEmpty.

void failIfDirectotyExistsNotEmpty(Path target) throws IOException {
    if (!Files.exists(target)) {
        return;
    }
    if (!Files.isDirectory(target)) {
        throw feedback.failure("UPGRADE_TargetExistsNotDirectory", null, target);
    }
    Path ghome = target.resolve(SystemUtils.getGraalVMJDKRoot(input.getLocalRegistry()));
    Path relFile = ghome.resolve("release");
    if (Files.isReadable(relFile)) {
        Version targetVersion = null;
        try {
            ComponentRegistry reg = createRegistryFor(ghome);
            targetVersion = reg.getGraalVersion();
        } catch (FailedOperationException ex) {
        // ignore
        }
        if (targetVersion != null) {
            throw feedback.failure("UPGRADE_TargetExistsContainsGraalVM", null, target, targetVersion.displayString());
        }
    }
    if (Files.list(target).findFirst().isPresent()) {
        throw feedback.failure("UPGRADE_TargetExistsNotEmpty", null, target);
    }
}
Also used : Path(java.nio.file.Path) FailedOperationException(org.graalvm.component.installer.FailedOperationException) Version(org.graalvm.component.installer.Version) ComponentRegistry(org.graalvm.component.installer.model.ComponentRegistry)

Example 4 with FailedOperationException

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

the class MergeStorage method listComponentIDs.

@Override
public Set<String> listComponentIDs() throws IOException {
    Set<String> ids = new HashSet<>();
    List<Exception> savedEx = new ArrayList<>();
    List<SoftwareChannel> errChannels = new ArrayList<>();
    boolean oneSucceeded = false;
    Exception toThrow = null;
    for (SoftwareChannel del : new ArrayList<>(channels)) {
        try {
            ids.addAll(del.getStorage().listComponentIDs());
            oneSucceeded = true;
        } catch (IncompatibleException ex) {
            savedEx.add(ex);
            errChannels.add(del);
            channels.remove(del);
        } catch (IOException | FailedOperationException ex) {
            if (!isIgnoreCatalogErrors()) {
                throw ex;
            }
            if (!idsLoaded) {
                reportError(ex, del);
            }
            toThrow = ex;
            channels.remove(del);
        }
    }
    if (!oneSucceeded || ids.isEmpty()) {
        for (int i = 0; i < savedEx.size(); i++) {
            reportError(toThrow = savedEx.get(i), errChannels.get(i));
        }
        if (toThrow instanceof IOException) {
            throw (IOException) toThrow;
        } else if (toThrow != null) {
            throw (InstallerStopException) toThrow;
        }
    }
    idsLoaded = true;
    return ids;
}
Also used : SoftwareChannel(org.graalvm.component.installer.SoftwareChannel) ArrayList(java.util.ArrayList) IOException(java.io.IOException) InstallerStopException(org.graalvm.component.installer.InstallerStopException) IOException(java.io.IOException) IncompatibleException(org.graalvm.component.installer.IncompatibleException) FailedOperationException(org.graalvm.component.installer.FailedOperationException) FailedOperationException(org.graalvm.component.installer.FailedOperationException) IncompatibleException(org.graalvm.component.installer.IncompatibleException) HashSet(java.util.HashSet)

Example 5 with FailedOperationException

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

the class ComponentPackageLoader method supplyComponentTag.

/**
 * Computes some component hash/tag. Computes a digest from each read/present value in the
 * manifest.
 */
private void supplyComponentTag() {
    String ct = info.getTag();
    if (ct != null && !ct.isEmpty()) {
        return;
    }
    try (StringWriter wr = new StringWriter()) {
        // NOI18N
        props.store(wr, "");
        // NOI18N
        info.setTag(SystemUtils.digestString(wr.toString().replaceAll("#.*\r?\n\r?", ""), false));
    } catch (IOException ex) {
        throw new FailedOperationException(ex.getLocalizedMessage(), ex);
    }
}
Also used : FailedOperationException(org.graalvm.component.installer.FailedOperationException) StringWriter(java.io.StringWriter) IOException(java.io.IOException)

Aggregations

FailedOperationException (org.graalvm.component.installer.FailedOperationException)7 IOException (java.io.IOException)4 Path (java.nio.file.Path)3 Test (org.junit.Test)3 ComponentInfo (org.graalvm.component.installer.model.ComponentInfo)2 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 ComponentCatalog (org.graalvm.component.installer.ComponentCatalog)1 ComponentCollection (org.graalvm.component.installer.ComponentCollection)1 ComponentParam (org.graalvm.component.installer.ComponentParam)1 IncompatibleException (org.graalvm.component.installer.IncompatibleException)1 InstallerStopException (org.graalvm.component.installer.InstallerStopException)1 SoftwareChannel (org.graalvm.component.installer.SoftwareChannel)1 Version (org.graalvm.component.installer.Version)1