/** * Read in a Features from the input stream. * * @param uri uri to read * @param validate whether to validate the input. * @return a Features read from the input stream */ public static Features unmarshal(String uri, boolean validate) { return unmarshal(uri, null, validate); }
protected Features getFeatures(final URL repoUrl) throws JAXBException, IOException { return JaxbUtil.unmarshal(repoUrl.toExternalForm(), false); }
static Features readFeaturesFile(File featuresFile) throws XMLStreamException, JAXBException, IOException { return JaxbUtil.unmarshal(featuresFile.toURI().toASCIIString(), false); }
static Features readFeaturesFile(File featuresFile) throws XMLStreamException, JAXBException, IOException { return JaxbUtil.unmarshal(featuresFile.toURI().toASCIIString(), false); }
private void load(boolean validate) { if (features == null) { try (InputStream inputStream = new InterruptibleInputStream(uri.toURL().openStream())) { features = JaxbUtil.unmarshal(uri.toASCIIString(), inputStream, validate); } catch (Exception e) { throw new RuntimeException(e.getMessage() + " : " + uri, e); } } }
@Override public List<String> list() throws Exception { List<String> repositories = new ArrayList<>(); File storage = new File(STORAGE); if (storage.exists()) { Features features = JaxbUtil.unmarshal(storage.getAbsolutePath(), true); repositories = features.getRepository(); } return repositories; }
@Override public Feature[] repositoryProvidedFeatures(URI uri) throws Exception { Features features = JaxbUtil.unmarshal(uri.toURL().toExternalForm(), true); Feature[] array = new Feature[features.getFeature().size()]; return features.getFeature().toArray(array); }
@Override public void remove(String url) throws Exception { File storage = new File(STORAGE); if (!storage.exists()) { return; } Features features = JaxbUtil.unmarshal(storage.getAbsolutePath(), true); if (!isFeaturesRepositoryRegistered(url, features.getRepository())) { throw new IllegalArgumentException("Features repository " + url + " is not registered in the gateway"); } features.getRepository().remove(url); marshalStorageFile(storage, features); }
@Override public void register(String url) throws Exception { File storage = new File(STORAGE); Features features = new Features(); if (storage.exists()) { features = JaxbUtil.unmarshal(storage.getAbsolutePath(), true); } else { storage.getParentFile().mkdirs(); storage.createNewFile(); } features.setName("cave-gateway"); if (isFeaturesRepositoryRegistered(url, features.getRepository())) { throw new IllegalArgumentException("Features repository " + url + " already registered in the gateway"); } features.getRepository().add(url); marshalStorageFile(storage, features); }
public List<org.apache.karaf.cave.deployer.api.Feature> providedFeatures(String featureRepositoryUrl) throws Exception { Features features = JaxbUtil.unmarshal(featureRepositoryUrl, true); List<org.apache.karaf.cave.deployer.api.Feature> wrappedFeatures = new ArrayList<>(); for (Feature feature : features.getFeature()) { org.apache.karaf.cave.deployer.api.Feature wrappedFeature = new org.apache.karaf.cave.deployer.api.Feature(); wrappedFeature.setName(feature.getName()); wrappedFeature.setVersion(feature.getVersion()); wrappedFeatures.add(wrappedFeature); } return wrappedFeatures; }
protected void retrieveDescriptorsRecursively(String uri, Set<String> bundles, Map<String, Feature> featuresMap) { // let's ensure a mvn: based url is sitting in the local repo before we try reading it Artifact descriptor; try { descriptor = resourceToArtifact(uri, true); } catch (MojoExecutionException e) { throw new RuntimeException(e.getMessage(), e); } if (descriptor != null) { resolveArtifact(descriptor, remoteRepos); descriptorArtifacts.add(descriptor); } if (includeMvnBasedDescriptors) { bundles.add(uri); } String uriToUse = descriptor != null ? descriptor.getFile().toURI().toString() : translateFromMaven(uri); Features repo = JaxbUtil.unmarshal(uriToUse, true); for (Feature f : repo.getFeature()) { featuresMap.put(f.getId(), f); } if (resolveDefinedRepositoriesRecursively) { for (String r : repo.getRepository()) { retrieveDescriptorsRecursively(r, bundles, featuresMap); } } }
protected void retrieveDescriptorsRecursively(String uri, Set<String> bundles, Map<String, Feature> featuresMap) { // let's ensure a mvn: based url is sitting in the local repo before we try reading it Artifact descriptor; try { descriptor = resourceToArtifact(uri, true); } catch (MojoExecutionException e) { throw new RuntimeException(e.getMessage(), e); } if (descriptor != null) { resolveArtifact(descriptor, remoteRepos); descriptorArtifacts.add(descriptor); } if (includeMvnBasedDescriptors) { bundles.add(uri); } String uriToUse = descriptor != null ? descriptor.getFile().toURI().toString() : translateFromMaven(uri); Features repo = JaxbUtil.unmarshal(uriToUse, true); for (Feature f : repo.getFeature()) { featuresMap.put(f.getId(), f); } if (resolveDefinedRepositoriesRecursively) { for (String r : repo.getRepository()) { retrieveDescriptorsRecursively(r, bundles, featuresMap); } } }
/** * Read bundles and configuration files in the features file. * * @return * @throws MojoExecutionException */ private List<Artifact> readResources(File featuresFile) throws MojoExecutionException { List<Artifact> resources = new ArrayList<>(); try { Features features = JaxbUtil.unmarshal(featuresFile.toURI().toASCIIString(), false); for (Feature feature : features.getFeature()) { for (BundleInfo bundle : feature.getBundles()) { if (ignoreDependencyFlag || (!ignoreDependencyFlag && !bundle.isDependency())) { resources.add(resourceToArtifact(bundle.getLocation(), false)); } } for (ConfigFileInfo configFile : feature.getConfigurationFiles()) { resources.add(resourceToArtifact(configFile.getLocation(), false)); } } return resources; } catch (MojoExecutionException e) { throw e; } catch (Exception e) { throw new MojoExecutionException("Could not interpret features.xml", e); } }
/** * Read bundles and configuration files in the features file. * * @return * @throws MojoExecutionException */ private List<Artifact> readResources(File featuresFile) throws MojoExecutionException { List<Artifact> resources = new ArrayList<>(); try { Features features = JaxbUtil.unmarshal(featuresFile.toURI().toASCIIString(), false); for (Feature feature : features.getFeature()) { for (BundleInfo bundle : feature.getBundles()) { if (ignoreDependencyFlag || (!ignoreDependencyFlag && !bundle.isDependency())) { resources.add(resourceToArtifact(bundle.getLocation(), false)); } } for (ConfigFileInfo configFile : feature.getConfigurationFiles()) { resources.add(resourceToArtifact(configFile.getLocation(), false)); } } return resources; } catch (MojoExecutionException e) { throw e; } catch (Exception e) { throw new MojoExecutionException("Could not interpret features.xml", e); } }
@Override public void downloaded(final StreamProvider provider) throws Exception { try (InputStream is = provider.open()) { Features featuresModel = JaxbUtil.unmarshal(provider.getUrl(), is, false); synchronized (loaded) { loaded.put(provider.getUrl(), featuresModel); for (String innerRepository : featuresModel.getRepository()) { if (!processor.isRepositoryBlacklisted(innerRepository)) { downloader.download(innerRepository, this); } } } } } });
@Override public void downloaded(final StreamProvider provider) throws Exception { try (InputStream is = provider.open()) { Features featuresModel = JaxbUtil.unmarshal(provider.getUrl(), is, false); synchronized (loaded) { loaded.put(provider.getUrl(), featuresModel); for (String innerRepository : featuresModel.getRepository()) { if (!processor.isRepositoryBlacklisted(innerRepository)) { downloader.download(innerRepository, this); } } } } } });
Features featuresModel = JaxbUtil.unmarshal(url, is, false);
Features featuresModel = JaxbUtil.unmarshal(url, is, false);
Features repository = JaxbUtil.unmarshal(uri.toASCIIString(), true);
Features repository = JaxbUtil.unmarshal(uri.toASCIIString(), true);