use of org.apache.karaf.features.Repository in project karaf by apache.
the class RepoListCommand method doExecute.
protected void doExecute(FeaturesService featuresService) throws Exception {
if (reload) {
reloadAllRepos(featuresService);
}
ShellTable table = new ShellTable();
table.column("Repository");
table.column("URL");
if (showBlacklisted) {
table.column("Blacklisted");
}
table.emptyTableText("No repositories available");
Repository[] repos = featuresService.listRepositories();
for (Repository repo : repos) {
if (repo != null) {
if (showBlacklisted || !repo.isBlacklisted()) {
Row row = table.addRow();
row.addContent(repo.getName(), repo.getURI().toString());
if (showBlacklisted) {
row.addContent(repo.isBlacklisted() ? "yes" : "no");
}
}
}
}
table.print(System.out, !noFormat);
}
use of org.apache.karaf.features.Repository in project karaf by apache.
the class RepoRefreshCommand method doExecute.
@Override
protected void doExecute(FeaturesService featuresService) throws Exception {
Set<URI> uris = new LinkedHashSet<>();
if (nameOrUrl != null) {
uris = selectRepositories(nameOrUrl, version);
if (uris.isEmpty()) {
System.err.println("No matching repository for " + nameOrUrl + (version != null ? " / " + version : ""));
return;
}
} else {
Repository[] repos = featuresService.listRepositories();
for (Repository repo : repos) {
uris.add(repo.getURI());
}
}
String uriString = uris.stream().map(URI::toString).collect(Collectors.joining(", "));
try {
System.out.println("Refreshing feature url: " + uriString);
featuresService.refreshRepositories(uris);
} catch (Exception e) {
System.err.println("Error refreshing " + uriString + ": " + e.getMessage());
}
}
use of org.apache.karaf.features.Repository in project karaf by apache.
the class FeaturesPlugin method writeJSON.
private void writeJSON(final PrintWriter pw) throws IOException {
final List<Repository> repositories = this.getRepositories();
final List<ExtendedFeature> features = this.getFeatures(repositories);
final String statusLine = this.getStatusLine(features);
final JSONWriter jw = new JSONWriter(pw);
jw.object();
jw.key("status");
jw.value(statusLine);
jw.key("repositories");
jw.array();
for (Repository r : repositories) {
jw.object();
jw.key("name");
String name = "";
if (r.getName() != null)
name = r.getName();
jw.value(name);
jw.key("url");
String uri = r.getURI().toString();
jw.value(uri);
jw.key("actions");
jw.array();
boolean enable = true;
if (uri.startsWith("bundle")) {
enable = false;
}
action(jw, enable, "refreshRepository", "Refresh", "refresh");
action(jw, enable, "removeRepository", "Remove", "delete");
jw.endArray();
jw.endObject();
}
jw.endArray();
jw.key("features");
jw.array();
for (ExtendedFeature f : features) {
featureInfo(jw, f);
}
jw.endArray();
jw.endObject();
}
use of org.apache.karaf.features.Repository in project karaf by apache.
the class JmxRepositoryTest method testJmxRepositoryCompositeData.
@Test
public void testJmxRepositoryCompositeData() throws Exception {
Features features = new Features();
features.setName("test-1.0.0");
features.getRepository().add("mvn:org.test/test-dependency/1.0.0/xml/features");
features.getFeature().add(new Feature("test-feature", "1.0.0"));
URI uri = new URI("mvn:org.test/test/1.0.0/xml/features");
Repository repository = new RepositoryImpl(uri, features, true);
JmxRepository jmxRepository = new JmxRepository(repository);
CompositeData compositeData = jmxRepository.asCompositeData();
assertEquals("test-1.0.0", compositeData.get(REPOSITORY_NAME));
assertEquals(uri.toString(), compositeData.get(REPOSITORY_URI));
assertTrue((Boolean) compositeData.get(REPOSITORY_BLACKLISTED));
String[] repositoryUris = (String[]) compositeData.get(REPOSITORY_REPOSITORIES);
assertEquals(1, repositoryUris.length);
assertEquals("mvn:org.test/test-dependency/1.0.0/xml/features", repositoryUris[0]);
TabularData repositoryFeatures = (TabularData) compositeData.get(REPOSITORY_FEATURES);
assertEquals(1, repositoryFeatures.size());
assertNotNull(repositoryFeatures.get(new Object[] { "test-feature", "1.0.0" }));
}
use of org.apache.karaf.features.Repository in project karaf by apache.
the class FeaturesDumpProvider method writeDump.
/**
* {@inheritDoc}
*/
protected void writeDump(OutputStreamWriter outputStreamWriter) throws Exception {
// creates header
outputStreamWriter.write("Repositories:\n");
// list repositories
for (Repository repo : features.listRepositories()) {
outputStreamWriter.write(repo.getURI() + " (" + repo.getName() + ")\n");
}
// list features
outputStreamWriter.write("\nfeatures:\n");
for (Feature feature : features.listFeatures()) {
outputStreamWriter.write(feature.getName() + " " + feature.getVersion());
outputStreamWriter.write(" installed: " + features.isInstalled(feature));
outputStreamWriter.write("\nBundles:\n");
for (BundleInfo bundle : feature.getBundles()) {
outputStreamWriter.write("\t" + bundle.getLocation());
if (bundle.getStartLevel() != 0) {
outputStreamWriter.write(" start level " + bundle.getStartLevel());
}
outputStreamWriter.write("\n\n");
}
}
// flush & close stream
outputStreamWriter.close();
}
Aggregations