Refine search
@Test public void testActivation() throws Exception { assertTrue( featuresService.isInstalled( featuresService.getFeature( "hibernate-orm" ) ) ); assertTrue( featuresService.isInstalled( featuresService.getFeature( "hibernate-envers" ) ) ); assertActiveBundle( "org.hibernate.orm.core" ); assertActiveBundle( "org.hibernate.orm.envers" ); }
public void uninstallFeature(String name) throws Exception { featuresService.uninstallFeature(name); }
/** * @throws Exception */ @Test public void testAllBundlesActiveAndFeaturesInstalled() throws Exception { // Asssert all bundles except fragments are ACTIVE. for (Bundle b : bundleCtx.getBundles()) { System.out.println(String.format("Checking state of bundle [symbolicName=%s, state=%s]", b.getSymbolicName(), b.getState())); if (b.getHeaders().get(Constants.FRAGMENT_HOST) == null) assertTrue(b.getState() == Bundle.ACTIVE); } // Check that according to the FeaturesService, all Ignite features except ignite-log4j are installed. Feature[] features = featuresSvc.getFeatures(IGNITE_FEATURES_NAME_REGEX); assertNotNull(features); assertEquals(EXPECTED_FEATURES, features.length); for (Feature f : features) { if (IGNORED_FEATURES.contains(f.getName())) continue; boolean installed = featuresSvc.isInstalled(f); System.out.println(String.format("Checking if feature is installed [featureName=%s, installed=%s]", f.getName(), installed)); assertTrue(installed); assertEquals(PROJECT_VERSION.replaceAll("-", "."), f.getVersion().replaceAll("-", ".")); } }
if (!isRepositoryRegisteredLocally(url)) { LOGGER.debug("CELLAR FEATURE: adding repository {}", url); featuresService.addRepository(new URI(url)); for (Repository repository : featuresService.listRepositories()) { URI uri = repository.getURI(); boolean found = false; for (String clusterRepository : clusterRepositories.keySet()) { if (clusterRepository.equals(uri.toString())) { found = true; break; featuresService.removeRepository(uri); try { LOGGER.debug("CELLAR FEATURE: installing feature {}/{}", state.getName(), state.getVersion()); featuresService.installFeature(state.getName(), state.getVersion()); } catch (Exception e) { LOGGER.error("CELLAR FEATURE: failed to install feature {}/{} ", new Object[]{state.getName(), state.getVersion()}, e); try { LOGGER.debug("CELLAR FEATURE: uninstalling feature {}/{}", state.getName(), state.getVersion()); featuresService.uninstallFeature(state.getName(), state.getVersion()); } catch (Exception e) { LOGGER.error("CELLAR FEATURE: failed to uninstall feature {}/{}", new Object[]{state.getName(), state.getVersion()}, e);
if (event.getRefresh() != null && event.getRefresh()) { if (uri == null) { Repository[] repositories = featuresService.listRepositories(); for (Repository repository : repositories) { LOGGER.debug("CELLAR FEATURE: refresh repository {}", repository.getURI().toString()); featuresService.refreshRepository(repository.getURI()); featuresService.refreshRepository(new URI(uri)); featuresService.addRepository(new URI(uri), event.getInstall()); } else { LOGGER.debug("CELLAR FEATURE: repository URI {} is already registered locally", uri); if (isRepositoryRegisteredLocally(uri)) { LOGGER.debug("CELLAR FEATURE: removing repository URI {}", uri); featuresService.removeRepository(new URI(uri), event.getUninstall()); } else { LOGGER.debug("CELLAR FEATURE: repository URI {} is not registered locally");
featuresService.addRepository(new URI(url)); featuresInOldRepositories.put(key, existingRepository.getURI().toString()); singleFeaturesInOldRepositories.put(feature.getName(), existingRepository.getURI().toString()); actualOldFeatureVersions.put(key, v); Repository repository = before.get(oldRepositoryName); for (Feature feature : repository.getFeatures()) { if (featuresService.isInstalled(feature)) { Version v = Utils.getOsgiVersion(feature.getVersion()); Version lowestUpdateableVersion = new Version(v.getMajor(), v.getMinor(), 0); boolean hasInstalledFeatures = false; for (Feature feature : repository.getFeatures()) { if (featuresService.isInstalled(feature)) { FeatureUpdate featureUpdate = new FeatureUpdate(feature.getName(), after.get(unchangedRepositoryName).getURI().toString(), for (String repo : addedRepositoryNames) { if (after.get(repo) != null) { featuresService.removeRepository(after.get(repo).getURI(), false);
/** * Returns currently installed feature repositories. If patch is not installed, we should have the same state * before&after. * @return */ private HashMap<String, Repository> getAvailableFeatureRepositories() { HashMap<String, Repository> before = new HashMap<String, Repository>(); if (featuresService != null) { for (Repository repository : featuresService.listRepositories()) { before.put(repository.getURI().toString(), repository); } } return before; }
@Override protected void doExecute(FeaturesService featuresService) throws Exception { URI uri = featuresService.getRepositoryUriFor(nameOrUrl, version); if (uri == null) { uri = new URI(nameOrUrl); } if (featuresService.isRepositoryUriBlacklisted(uri)) { System.out.println("Feature URL " + uri + " is blacklisted"); return; } System.out.println("Adding feature url " + uri); featuresService.addRepository(uri, install); }
public void addRepository(String uri, boolean install) throws Exception { URI repoUri = new URI(uri); if (featuresService.isRepositoryUriBlacklisted(repoUri)) { throw new RuntimeException("Feature URL " + uri + " is blacklisted"); } featuresService.addRepository(repoUri, install); }
public void addFeaturesRepository(String featuresRepository) throws Exception { featureService.addRepository(new URI(featuresRepository)); }
private boolean removeRepository(String url) { boolean success = false; if (featuresService == null) { this.log.error("Features service is not available"); } try { featuresService.removeRepository(new URI(url)); success = true; } catch (Exception e) { this.log.error("Can't remove features repository {}", url, e); } return success; }
protected Set<URI> selectRepositories(String nameOrUrl, String version) throws Exception { Set<URI> uris = new LinkedHashSet<>(); String effectiveVersion = (version == null) ? "LATEST" : version; URI uri = featuresService.getRepositoryUriFor(nameOrUrl, effectiveVersion); if (uri == null) { // add regex support on installed repositories Pattern pattern = Pattern.compile(nameOrUrl); for (Repository repository : featuresService.listRepositories()) { URI u = repository.getURI(); String rname = repository.getName(); if (pattern.matcher(u.toString()).matches() || rname != null && pattern.matcher(rname).matches()) { uris.add(u); } } } else { uris.add(uri); } return uris; }
public void removeRepository(String uri, boolean uninstall) throws Exception { List<URI> uris = new ArrayList<>(); Pattern pattern = Pattern.compile(uri); for (Repository repository : featuresService.listRepositories()) { if (repository.getName() != null && !repository.getName().isEmpty()) { // first regex on the repository name Matcher nameMatcher = pattern.matcher(repository.getName()); if (nameMatcher.matches()) { uris.add(repository.getURI()); } else { // fallback to repository URI regex Matcher uriMatcher = pattern.matcher(repository.getURI().toString()); if (uriMatcher.matches()) { uris.add(repository.getURI()); } } } else { // repository name is not defined, fallback to repository URI regex Matcher uriMatcher = pattern.matcher(repository.getURI().toString()); if (uriMatcher.matches()) { uris.add(repository.getURI()); } } } for (URI u : uris) { featuresService.removeRepository(u, uninstall); } }
@Override protected void doExecute(FeaturesService admin) throws Exception { Feature auxiliaryStoreServerFeature = admin.getFeature(FEATURE_NAME); if (auxiliaryStoreServerFeature == null ) { admin.addRepository(URI.create("mvn:org.talend.esb.auxiliary.storage/auxiliary-storage-features/" + getProjectVersion() + "/xml")); auxiliaryStoreServerFeature = admin.getFeature(FEATURE_NAME); if (auxiliaryStoreServerFeature == null) { String errorMessage = "Failed to start auxiliary storage repository: feature " + FEATURE_NAME + " is missed"; System.out.println(errorMessage); // log.error(errorMessage); return; } } if (!admin.isInstalled(auxiliaryStoreServerFeature)) { admin.installFeature(FEATURE_NAME); } }
protected void addFeaturesUrl(String url) { try { featuresService.addRepository(URI.create(url)); } catch (Exception e) { throw new RuntimeException(e); } }
private void checkRepository(final URI repoURI) { Repository repo = null; for(Repository r: featuresService.listRepositories()) { if(r.getURI().equals(repoURI)){ repo = r; break; } } Assert.assertNotNull("Repository not found: " + repoURI,repo); }
@Test public void testAmqpInstallation() throws Exception { assertFalse("trellis-amqp already installed!", featuresService.isInstalled(featuresService.getFeature("trellis-amqp"))); featuresService.installFeature("trellis-event-serialization"); featuresService.installFeature("trellis-amqp"); checkTrellisBundlesAreActive(); assertTrue("trellis-amqp not installed!", featuresService.isInstalled(featuresService.getFeature("trellis-amqp"))); }
@Test public void testWebacInstallation() throws Exception { assertFalse("trellis-webac already installed!", featuresService.isInstalled(featuresService.getFeature("trellis-webac"))); featuresService.installFeature("trellis-triplestore"); featuresService.installFeature("trellis-webac"); checkTrellisBundlesAreActive(); assertTrue("trellis-webac not installed!", featuresService.isInstalled(featuresService.getFeature("trellis-webac"))); featuresService.uninstallFeature("trellis-webac"); featuresService.uninstallFeature("trellis-triplestore"); if (featuresService.isInstalled(featuresService.getFeature("trellis-audit"))) { featuresService.uninstallFeature("trellis-audit"); } }
protected void installFeature(String featureName) { try { LOG.info("Installing feature {}", featureName); featuresService.installFeature(featureName); } catch (Exception e) { throw new RuntimeException(e); } }
protected void installAssertAndUninstallFeature(String feature, String version) throws Exception { Set<Feature> featuresBefore = new HashSet<>(Arrays.asList(featuresService.listInstalledFeatures())); try { featuresService.installFeature(feature, version); assertFeatureInstalled(feature, version); } finally { uninstallNewFeatures(featuresBefore); } }