Search in sources :

Example 1 with Feedback

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

the class GraalChannel method loadStorage.

@Override
protected ComponentStorage loadStorage() throws IOException {
    FileDownloader dn = new FileDownloader(fb.l10n("OLDS_ReleaseFile"), getIndexURL(), fb);
    dn.download();
    Path storagePath = dn.getLocalFile().toPath();
    List<ReleaseEntry> releases = loadReleasesIndex(storagePath);
    if (releases.isEmpty()) {
        return throwEmptyStorage();
    }
    MergeStorage store = new MergeStorage(localRegistry, fb);
    store.setAcceptAllSources(true);
    for (ReleaseEntry en : releases) {
        URL catURL = en.getCatalogURL();
        Version v = Version.fromString(en.getVersion().displayString());
        SoftwareChannelSource src = new SoftwareChannelSource(catURL.toString(), en.getLabel());
        WebCatalog cata = new WebCatalog(src.getLocationURL(), src) {

            @Override
            protected RemotePropertiesStorage createPropertiesStorage(Feedback aFeedback, ComponentRegistry aLocal, Properties props, String selector, URL baseURL) {
                return new RemotePropertiesStorage(aFeedback, aLocal, props, selector, v, baseURL);
            }
        };
        cata.init(localRegistry, fb);
        cata.setMatchVersion(en.getVersion().match(Version.Match.Type.EXACT));
        cata.setRemoteProcessor((i) -> configureLicense(i, en));
        store.addChannel(src, cata);
    }
    return store;
}
Also used : Path(java.nio.file.Path) SoftwareChannelSource(org.graalvm.component.installer.SoftwareChannelSource) WebCatalog(org.graalvm.component.installer.ce.WebCatalog) RemotePropertiesStorage(org.graalvm.component.installer.remote.RemotePropertiesStorage) MergeStorage(org.graalvm.component.installer.remote.MergeStorage) Properties(java.util.Properties) URL(java.net.URL) Version(org.graalvm.component.installer.Version) Feedback(org.graalvm.component.installer.Feedback) ComponentRegistry(org.graalvm.component.installer.model.ComponentRegistry) FileDownloader(org.graalvm.component.installer.remote.FileDownloader)

Example 2 with Feedback

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

the class DirectoryChannelFactory method createChannel.

@Override
public SoftwareChannel createChannel(SoftwareChannelSource source, CommandInput input, Feedback output) {
    String u = source.getLocationURL();
    if (!u.startsWith("file:")) {
        // NOI18N
        return null;
    }
    Feedback out2 = output.withBundle(DirectoryChannelFactory.class);
    try {
        Path p = new File(new URI(u)).toPath();
        if (!Files.isDirectory(p)) {
            return null;
        }
        DirectoryCatalogProvider dp = new DirectoryCatalogProvider(p, out2);
        dp.setVerifyJars(input.optValue(Commands.OPTION_NO_VERIFY_JARS) == null);
        // do not report errors for directory sources implied by commandline arguments.
        if (Boolean.FALSE.toString().equals(source.getParameter("reportErrors"))) {
            // NOI18N
            dp.setReportErrors(false);
        }
        return dp;
    } catch (URISyntaxException ex) {
        out2.error("ERR_DirectoryURLInvalid", ex, u, ex.getMessage());
        return null;
    }
}
Also used : Path(java.nio.file.Path) Feedback(org.graalvm.component.installer.Feedback) URISyntaxException(java.net.URISyntaxException) File(java.io.File) URI(java.net.URI)

Example 3 with Feedback

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

the class UninstallCommand method checkBrokenDependencies.

void checkBrokenDependencies() {
    if (brokenDependencies.isEmpty()) {
        return;
    }
    Set<ComponentInfo> uninstalled = new HashSet<>(toUninstall.values());
    // get all broken components, excluding the ones scheduled for uninstall
    Stream<ComponentInfo> stm = brokenDependencies.values().stream().flatMap((col) -> col.stream()).filter((c) -> !uninstalled.contains(c));
    // if all broken are uninstalled -> OK
    if (!stm.findFirst().isPresent()) {
        return;
    }
    List<ComponentInfo> sorted = new ArrayList<>(brokenDependencies.keySet());
    P printer;
    boolean warning = removeDependent || breakDependent;
    if (warning) {
        printer = feedback::output;
        feedback.output(removeDependent ? "UNINSTALL_BrokenDependenciesRemove" : "UNINSTALL_BrokenDependenciesWarn");
    } else {
        printer = (a, b) -> feedback.error(a, null, b);
        feedback.error("UNINSTALL_BrokenDependencies", null);
    }
    Comparator<ComponentInfo> c = (a, b) -> a.getId().compareToIgnoreCase(b.getId());
    Collections.sort(sorted, c);
    for (ComponentInfo i : sorted) {
        List<ComponentInfo> deps = new ArrayList<>(brokenDependencies.get(i));
        deps.removeAll(uninstalled);
        if (deps.isEmpty()) {
            continue;
        }
        Collections.sort(sorted, c);
        if (!warning) {
            printer.print("UNINSTALL_BreakDepSource", i.getName(), i.getId());
        }
        for (ComponentInfo d : deps) {
            printer.print("UNINSTALL_BreakDepTarget", d.getName(), d.getId());
        }
    }
    if (warning) {
        return;
    }
    throw feedback.failure("UNINSTALL_BreakDependenciesTerminate", null);
}
Also used : ComponentRegistry(org.graalvm.component.installer.model.ComponentRegistry) InstallerStopException(org.graalvm.component.installer.InstallerStopException) Commands(org.graalvm.component.installer.Commands) HashMap(java.util.HashMap) Feedback(org.graalvm.component.installer.Feedback) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) BundleConstants(org.graalvm.component.installer.BundleConstants) Map(java.util.Map) Path(java.nio.file.Path) LinkedHashSet(java.util.LinkedHashSet) CommandInput(org.graalvm.component.installer.CommandInput) WARN_REBUILD_IMAGES(org.graalvm.component.installer.CommonConstants.WARN_REBUILD_IMAGES) CommonConstants(org.graalvm.component.installer.CommonConstants) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) CatalogContents(org.graalvm.component.installer.model.CatalogContents) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) File(java.io.File) SystemUtils(org.graalvm.component.installer.SystemUtils) List(java.util.List) DistributionType(org.graalvm.component.installer.model.DistributionType) Stream(java.util.stream.Stream) InstallerCommand(org.graalvm.component.installer.InstallerCommand) Comparator(java.util.Comparator) Collections(java.util.Collections) ArrayList(java.util.ArrayList) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

Path (java.nio.file.Path)3 Feedback (org.graalvm.component.installer.Feedback)3 File (java.io.File)2 ComponentRegistry (org.graalvm.component.installer.model.ComponentRegistry)2 IOException (java.io.IOException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1 Properties (java.util.Properties)1 Set (java.util.Set)1