use of io.fabric8.api.Version in project fabric8 by jboss-fuse.
the class ProvisionSupport method profileAvailable.
public static Boolean profileAvailable(String profile, String version, Long timeout) throws Exception {
FabricService fabricService = ServiceLocator.awaitService(FabricService.class);
ProfileRegistry profileRegistry = fabricService.adapt(ProfileRegistry.class);
for (long t = 0; (!profileRegistry.hasProfile(version, profile) && t < timeout); t += 2000L) {
Thread.sleep(2000L);
}
return profileRegistry.hasProfile(version, profile);
}
use of io.fabric8.api.Version in project fabric8 by jboss-fuse.
the class Log4jLogQuery method loadCoords.
protected String loadCoords(String coords, String filePath, String classifier) throws IOException {
String[] split = coords.split("/");
if (split != null && split.length > 2) {
String groupId = split[0];
String artifactId = split[1];
String version = split[2];
if (resolver == null) {
Properties defaultProperties = getDefaultProperties();
Properties systemProperties = System.getProperties();
if (config == null) {
Properties combined = new Properties();
combined.putAll(defaultProperties);
combined.putAll(systemProperties);
if (properties != null) {
combined.putAll(properties);
}
config = new MavenConfigurationImpl(new PropertiesPropertyResolver(combined), ServiceConstants.PID);
}
resolver = new AetherBasedResolver(config);
}
File file = resolver.resolveFile(groupId, artifactId, classifier, "jar", version);
if (file.exists() && file.isFile()) {
if (isRoot(filePath)) {
return jarIndex(file);
}
String fileUri = file.toURI().toString();
URL url = new URL("jar:" + fileUri + "!" + filePath);
return loadString(url);
}
}
return null;
}
use of io.fabric8.api.Version in project fabric8 by jboss-fuse.
the class AbstractProfileManagementTest method testCreateVersionFrom.
@Test
public void testCreateVersionFrom() throws Exception {
// [FABRIC-1169] Profile version attributes leak to other versions
// VersionState v12 = getProxy().createVersion("1.0", "1.2", Collections.singletonMap("keyA", "valA"));
VersionState v12 = getProxy().createVersionFrom("1.0", "1.2", null);
try {
Assert.assertEquals("1.2", v12.getId());
// Assert.assertEquals("valA", v12.getAttributes().get("keyA"));
List<String> profiles = v12.getProfiles();
Assert.assertTrue(profiles.contains("default"));
Assert.assertTrue(profiles.contains("fabric"));
} finally {
getProxy().deleteVersion("1.2");
}
}
use of io.fabric8.api.Version in project fabric8 by jboss-fuse.
the class GitPatchManagementServiceImpl method trackBaselinesForChildContainers.
/**
* Tracks all baselines for child containers that weren't tracked already. These are looked up inside
* <code>system/org/apache/karaf/admin/org.apache.karaf.admin.core/**</code>
* @param fork
*/
private void trackBaselinesForChildContainers(Git fork) throws IOException, GitAPIException {
if (fork.getRepository().getRef("refs/heads/" + gitPatchRepository.getChildBranchName()) == null) {
// checkout patches-child branch - it'll track baselines for fabric:container-create-child containers
String startPoint = "patch-management^{commit}";
if (fork.getRepository().getRef("refs/remotes/origin/" + gitPatchRepository.getChildBranchName()) != null) {
startPoint = "refs/remotes/origin/" + gitPatchRepository.getChildBranchName();
}
gitPatchRepository.checkout(fork).setName(gitPatchRepository.getChildBranchName()).setStartPoint(startPoint).setCreateBranch(true).setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK).call();
} else {
gitPatchRepository.checkout(fork).setName(gitPatchRepository.getChildBranchName()).call();
}
File systemRepo = getSystemRepository(karafHome, systemContext);
File[] versionDirs = new File(systemRepo, "org/apache/karaf/admin/org.apache.karaf.admin.core").listFiles();
Set<Version> versions = new TreeSet<>();
if (versionDirs != null) {
for (File version : versionDirs) {
if (version.isDirectory()) {
versions.add(Utils.getOsgiVersion(version.getName()));
}
}
}
for (Version v : versions) {
String karafVersion = v.toString();
String tagName = String.format(EnvType.FABRIC_CHILD.getBaselineTagFormat(), karafVersion);
if (gitPatchRepository.containsTag(fork, tagName)) {
continue;
}
File baselineDistribution = null;
String location = String.format(systemRepo.getCanonicalPath() + "/org/apache/karaf/admin/org.apache.karaf.admin.core/%1$s/org.apache.karaf.admin.core-%1$s.jar", karafVersion);
if (new File(location).isFile()) {
baselineDistribution = new File(location);
Activator.log(LogService.LOG_INFO, "Found child baseline distribution: " + baselineDistribution.getCanonicalPath());
}
if (baselineDistribution != null) {
try {
unzipKarafAdminJar(baselineDistribution, fork.getRepository().getWorkTree());
fork.add().addFilepattern(".").call();
RevCommit commit = gitPatchRepository.prepareCommit(fork, String.format(MARKER_BASELINE_CHILD_COMMIT_PATTERN, karafVersion)).call();
// and we'll tag the child baseline
fork.tag().setName(tagName).setObjectId(commit).call();
} catch (Exception e) {
Activator.log(LogService.LOG_ERROR, null, e.getMessage(), e, true);
}
}
}
gitPatchRepository.push(fork, gitPatchRepository.getChildBranchName());
}
use of io.fabric8.api.Version in project fabric8 by jboss-fuse.
the class GitPatchManagementServiceImpl method gatherOverrides.
/**
* Returns list of bundle updates (maven coordinates) from HF/P patch that should be preserved during
* installation of R patch
* @param hfPatchId ID of patch that was detected to be HF patch
* @param patch currently installed R patch
* @return
*/
private List<String> gatherOverrides(String hfPatchId, Patch patch) {
Patch hf = loadPatch(new PatchDetailsRequest(hfPatchId));
List<String> result = new LinkedList<>();
if (hf != null && hf.getPatchData() != null) {
result.addAll(hf.getPatchData().getBundles());
// leave only these artifacts that are in newer version than in R patch being installed
if (patch != null && patch.getPatchData() != null) {
Map<String, Artifact> cache = new HashMap<>();
for (String bu : patch.getPatchData().getBundles()) {
Artifact rPatchArtifact = Utils.mvnurlToArtifact(bu, true);
if (rPatchArtifact != null) {
cache.put(String.format("%s:%s", rPatchArtifact.getGroupId(), rPatchArtifact.getArtifactId()), rPatchArtifact);
}
}
for (String bu : hf.getPatchData().getBundles()) {
Artifact hfPatchArtifact = Utils.mvnurlToArtifact(bu, true);
String key = String.format("%s:%s", hfPatchArtifact.getGroupId(), hfPatchArtifact.getArtifactId());
if (cache.containsKey(key)) {
Version hfVersion = Utils.getOsgiVersion(hfPatchArtifact.getVersion());
Version rVersion = Utils.getOsgiVersion(cache.get(key).getVersion());
if (rVersion.compareTo(hfVersion) >= 0) {
result.remove(bu);
}
}
}
}
}
return result;
}
Aggregations