use of org.graalvm.component.installer.SoftwareChannelSource in project graal by oracle.
the class GraalEditionList method init.
void init() {
if (defaultEdition != null) {
return;
}
String defEditionId = targetGraal.getGraalCapabilities().get(CommonConstants.CAP_EDITION);
if (isExplicitOverride()) {
initSimple(defEditionId, overrideCatalogSpec);
return;
}
List<SoftwareChannelSource> srcs = readChannelSources(defEditionId);
if (srcs.isEmpty()) {
// no source channels defined for the editionId
srcs = readChannelSources(null);
}
if (srcs.isEmpty()) {
initSimple(defEditionId, defaultCatalogSpec);
return;
}
List<String> edList = listEditionsFromRelease();
String label;
List<SoftwareChannelSource> sources;
if (edList.contains(defEditionId)) {
edList.remove(defEditionId);
label = getEditionLabel(defEditionId);
sources = readChannelSources(defEditionId);
} else if (!edList.remove("")) {
throw new IllegalStateException("Malformed release file.");
} else {
label = getEditionLabel(null);
sources = readChannelSources(null);
}
GraalEdition ge = new GraalEdition(defEditionId, label);
ge.setSoftwareSources(sources);
registerEdition(ge, true);
for (String id : edList) {
label = getEditionLabel(id);
sources = readChannelSources(id);
ge = new GraalEdition(id, label);
ge.setSoftwareSources(sources);
registerEdition(ge, false);
}
}
use of org.graalvm.component.installer.SoftwareChannelSource in project graal by oracle.
the class GraalEditionList method parseChannelSources.
@SuppressWarnings("ThrowableResultIgnored")
List<SoftwareChannelSource> parseChannelSources(String edId, String overrideSpec) {
List<SoftwareChannelSource> sources = new ArrayList<>();
if (!remoteSourcesAllowed || overrideSpec == null) {
return sources;
}
int priority = 1;
// NOI18N
String[] parts = overrideSpec.split("\\|");
String id = edId;
if (id == null) {
id = targetGraal.getGraalCapabilities().get(CommonConstants.CAP_EDITION);
}
for (String s : parts) {
SoftwareChannelSource chs = new SoftwareChannelSource(s);
chs.setPriority(priority);
chs.setParameter("edition", id);
sources.add(chs);
priority++;
}
return sources;
}
use of org.graalvm.component.installer.SoftwareChannelSource in project graal by oracle.
the class RemoteCatalogDownloader method readChannelSources.
List<SoftwareChannelSource> readChannelSources(String pref, Map<String, String> graalCaps) {
String prefix = pref + CommonConstants.CAP_CATALOG_PREFIX;
List<String> orderedKeys = graalCaps.keySet().stream().filter((k) -> {
String lk = k.toLowerCase(Locale.ENGLISH);
return lk.startsWith(prefix) && lk.endsWith(CAP_CATALOG_URL_SUFFIX);
}).map((k) -> k.substring(0, k.length() - CAP_CATALOG_URL_SUFFIX.length())).collect(Collectors.toList());
Collections.sort(orderedKeys, CHANNEL_KEY_COMPARATOR);
List<SoftwareChannelSource> sources = new ArrayList<>();
for (String key : orderedKeys) {
String url = graalCaps.get(key + CAP_CATALOG_URL_SUFFIX);
String lab = graalCaps.get(key + "_" + CommonConstants.CAP_CATALOG_LABEL);
if (url == null) {
continue;
}
SoftwareChannelSource s = new SoftwareChannelSource(url, lab);
for (String a : graalCaps.keySet()) {
if (!(a.startsWith(key) && a.length() > key.length() + 1)) {
continue;
}
String k = a.substring(key.length() + 1).toLowerCase(Locale.ENGLISH);
switch(k) {
case CommonConstants.CAP_CATALOG_LABEL:
case CommonConstants.CAP_CATALOG_URL:
continue;
}
s.setParameter(k, graalCaps.get(a));
}
sources.add(s);
}
return sources;
}
use of org.graalvm.component.installer.SoftwareChannelSource in project graal by oracle.
the class GraalEditionListTest method testParseRelease20EEWithLabel.
@Test
public void testParseRelease20EEWithLabel() throws Exception {
// this one contains multiple
loadReleaseFile("release20ee.properties");
// substitute "ee", since that's what the DirectoryStorage does in presence of
// 'vm-enterprise' now:
storage.graalInfo.put(CommonConstants.CAP_EDITION, "ee");
GraalEditionList list = new GraalEditionList(this, this, getLocalRegistry());
list.setDefaultCatalogSpec(storage.graalInfo.get(CommonConstants.RELEASE_CATALOG_KEY));
List<GraalEdition> eds = list.editions();
assertFalse(eds.isEmpty());
assertEquals(1, eds.size());
GraalEdition ge = eds.get(0);
assertSame(list.getDefaultEdition(), ge);
assertEquals("Expected ee for vm-enterprise", "ee", ge.getId());
assertEquals("Unqualified label should be picked up", "Enterprise Edition", ge.getDisplayName());
List<SoftwareChannelSource> sources = ge.getSoftwareSources();
assertEquals("Multiple software sources must be read", 3, sources.size());
assertEquals("Expected decreasing priority", 2, sources.get(1).getPriority());
}
use of org.graalvm.component.installer.SoftwareChannelSource in project graal by oracle.
the class RemoteCatalogDownloaderTest method testParseCatalogOverride.
/**
* Checks that simple explicit URL given 'the old way' will define a catalog that will be
* loaded.
*
* @throws Exception
*/
@Test
public void testParseCatalogOverride() throws Exception {
storage.graalInfo.put(CommonConstants.CAP_GRAALVM_VERSION, "0.33-dev");
String single = "test://graalv.org/test/catalog.properties";
RemoteCatalogDownloader d = new RemoteCatalogDownloader(this, this, single);
List<SoftwareChannelSource> sources = d.getChannelSources();
assertNotNull(sources);
assertEquals(1, sources.size());
assertEquals(single, sources.get(0).getLocationURL());
URL clu1 = getClass().getResource("catalogMultiVersions.properties");
Handler.bind(single, clu1);
ComponentStorage store = d.getStorage();
Set<String> ids = store.listComponentIDs();
assertTrue(ids.contains("ruby"));
assertTrue(Handler.isVisited(new URL(single)));
}
Aggregations