use of io.fabric8.api.ProfileService in project fabric8 by jboss-fuse.
the class ProfileDTO method populateBuilder.
/**
* Uses the profile DTO as input to the builder
*/
public void populateBuilder(FabricService fabricService, ProfileService profileService, ProfileBuilder builder) {
System.out.println("Parents are: " + parents);
if (parents != null && parents.size() > 0 && version != null) {
List<Profile> parentProfiles = Profiles.getProfiles(fabricService, parents, version);
System.out.println("Found parents: " + parentProfiles);
for (Profile parent : parentProfiles) {
builder.addParent(parent.getId());
}
}
builder.setOverlay(overlay);
// TODO builder doesn't expose it
// builder.setAbstractProfile(abstractProfile);
builder.setLocked(locked);
if (attributes != null) {
builder.setAttributes(attributes);
}
if (bundles != null) {
builder.setBundles(bundles);
}
if (fabs != null) {
builder.setBundles(fabs);
}
if (features != null) {
builder.setBundles(features);
}
if (repositories != null) {
builder.setBundles(repositories);
}
if (overrides != null) {
builder.setBundles(overrides);
}
}
use of io.fabric8.api.ProfileService in project fabric8 by jboss-fuse.
the class JavaContainers method getJavaContainerArtifactsFiles.
public static Map<String, File> getJavaContainerArtifactsFiles(FabricService fabricService, List<Profile> profileList, DownloadManager downloadManager) throws Exception {
Map<String, File> answer = new HashMap<String, File>();
ProfileService profileService = fabricService.adapt(ProfileService.class);
for (Profile profile : profileList) {
Profile overlay = profileService.getOverlayProfile(profile);
Map<String, Parser> profileArtifacts = AgentUtils.getProfileArtifacts(fabricService, downloadManager, overlay);
appendMavenDependencies(profileArtifacts, profile);
Set<String> rawUrls = profileArtifacts.keySet();
downloadArtifactUrls(downloadManager, rawUrls, answer);
}
return answer;
}
use of io.fabric8.api.ProfileService in project fabric8 by jboss-fuse.
the class BeanUtils method fetchChildIds.
public static List<String> fetchChildIds(FabricService fabricService, Profile self) {
List<String> ids = new ArrayList<String>();
ProfileService profileService = fabricService.adapt(ProfileService.class);
for (Profile p : profileService.getRequiredVersion(self.getVersion()).getProfiles()) {
for (String parentId : p.getParentIds()) {
if (parentId.equals(self.getId())) {
ids.add(p.getId());
break;
}
}
}
return ids;
}
use of io.fabric8.api.ProfileService in project fabric8 by jboss-fuse.
the class VersionEditAction method doExecute.
@Override
protected Object doExecute() throws Exception {
ProfileService profileService = fabricService.adapt(ProfileService.class);
ProfileRegistry profileRegistry = fabricService.adapt(ProfileRegistry.class);
Version version = profileService.getVersion(versionId);
if (version == null) {
System.err.println("Version " + versionId + " does not exist.");
return null;
}
profileRegistry.modifyVersionDescription(version, description);
return null;
}
use of io.fabric8.api.ProfileService in project fabric8 by jboss-fuse.
the class PatchApplyTest method testApplyPatch.
@Test
public void testApplyPatch() throws Exception {
System.err.println(CommandSupport.executeCommand("fabric:create --force --clean -n --wait-for-provisioning"));
BundleContext moduleContext = ServiceLocator.getSystemContext();
ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(moduleContext, FabricService.class);
try {
// copy the original version of the bundle into the system folder
final File jar = new File("system/" + getMavenRepoFile(ORIGINAL_VERSION));
jar.getParentFile().mkdirs();
IOHelpers.writeTo(jar, getClass().getClassLoader().getResourceAsStream("/bundles/patchable-1.0.0.jar"));
// copy the patch zip file into a local working directory
File patch = new File("data/patches/patch-01.zip");
patch.getParentFile().mkdirs();
IOHelpers.writeTo(patch, getClass().getClassLoader().getResourceAsStream("/patches/patch-01.zip"));
FabricService fabricService = fabricProxy.getService();
ProfileService profileService = fabricService.adapt(ProfileService.class);
// set up the 'patchable' profile and make sure it contains the original bundle version
CommandSupport.executeCommand("fabric:profile-create --parents default patchable");
CommandSupport.executeCommand("fabric:profile-edit --bundle mvn:io.fabric8.itests/patchable/1.0.0 patchable");
Profile profile = fabricService.getRequiredDefaultVersion().getRequiredProfile("patchable");
Profile overlay = profileService.getOverlayProfile(profile);
assertTrue(overlay.getBundles().contains(getMavenUrl(ORIGINAL_VERSION)));
assertFalse(overlay.getOverrides().contains(getMavenUrl(PATCHED_VERSION)));
// create a new version and apply the patch
CommandSupport.executeCommand("fabric:version-create 1.1");
Thread.sleep(2000);
CommandSupport.executeCommand(String.format("fabric:patch-apply -u admin -p admin --version 1.1 %s", patch.toURI().toURL()));
// ensure there's an override with the patched bundle version in the 'patchable' profile
profile = profileService.getRequiredVersion("1.1").getProfile("patchable");
overlay = profileService.getOverlayProfile(profile);
assertTrue(overlay.getBundles().contains(getMavenUrl(ORIGINAL_VERSION)));
assertTrue(overlay.getOverrides().contains(getMavenUrl(PATCHED_VERSION)));
} finally {
fabricProxy.close();
}
}
Aggregations