use of io.fabric8.api.ProfileBuilder in project fabric8 by jboss-fuse.
the class AbstractProfileManagementTest method testCreateUpdateDeleteProfile.
@Test
public void testCreateUpdateDeleteProfile() throws Exception {
ProfileBuilder pbA10 = ProfileBuilder.Factory.create("1.0", "prfA");
pbA10.addConfiguration("pidA", Collections.singletonMap("keyA", "valA"));
ProfileState prfA = getProxy().createProfile(new ProfileState(pbA10.getProfile()));
try {
Assert.assertEquals("prfA", prfA.getId());
Assert.assertEquals("1.0", prfA.getVersion());
Assert.assertTrue(prfA.getAttributes().isEmpty());
Assert.assertEquals("valA", prfA.getConfiguration("pidA").get("keyA"));
// getProfile
Assert.assertEquals(prfA.toString(), getProxy().getProfile("1.0", "prfA").toString());
// updateProfile
prfA = getProxy().getProfile("1.0", "prfA");
pbA10 = ProfileBuilder.Factory.createFrom(prfA.toProfile());
pbA10.addConfiguration("pidB", "keyB", "valB");
prfA = getProxy().updateProfile(new ProfileState(pbA10.getProfile()));
Assert.assertEquals("prfA", prfA.getId());
Assert.assertEquals("1.0", prfA.getVersion());
Assert.assertTrue(prfA.getAttributes().isEmpty());
Assert.assertEquals("valA", prfA.getConfiguration("pidA").get("keyA"));
Assert.assertEquals("valB", prfA.getConfiguration("pidB").get("keyB"));
} finally {
getProxy().deleteProfile("1.0", "prfA", false);
}
}
use of io.fabric8.api.ProfileBuilder in project fabric8 by jboss-fuse.
the class ProfileCreateAction method doExecute.
@Override
protected Object doExecute() throws Exception {
try {
FabricValidations.validateProfileName(profileId);
} catch (IllegalArgumentException e) {
// we do not want exception in the server log, so print the error message to the console
System.out.println(e.getMessage());
return 1;
}
if (versionId != null) {
profileService.getRequiredVersion(versionId);
} else {
versionId = fabricService.getDefaultVersionId();
}
// we can only use existing parent profiles
Profile[] parents = FabricCommand.getExistingProfiles(fabricService, versionId, this.parents);
ProfileBuilder builder = ProfileBuilder.Factory.create(versionId, profileId);
for (Profile parent : parents) {
builder.addParent(parent.getId());
}
profileService.createProfile(builder.getProfile());
return null;
}
use of io.fabric8.api.ProfileBuilder in project fabric8 by jboss-fuse.
the class ProfileEditAction method editProfile.
private void editProfile(Profile profile) throws Exception {
boolean editInLine = false;
ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile);
if (delete || remove) {
editInLine = true;
}
if (features != null && features.length > 0) {
editInLine = true;
handleFeatures(builder, features, profile);
}
if (repositories != null && repositories.length > 0) {
editInLine = true;
handleFeatureRepositories(builder, repositories, profile);
}
if (libs != null && libs.length > 0) {
editInLine = true;
handleLibraries(builder, libs, profile, "lib", LIB_PREFIX);
}
if (endorsed != null && endorsed.length > 0) {
editInLine = true;
handleLibraries(builder, endorsed, profile, "endorsed lib", ENDORSED_PREFIX);
}
if (extension != null && extension.length > 0) {
editInLine = true;
handleLibraries(builder, extension, profile, "extension lib", EXT_PREFIX);
}
if (bundles != null && bundles.length > 0) {
editInLine = true;
handleBundles(builder, bundles, profile);
}
if (fabs != null && fabs.length > 0) {
editInLine = true;
handleFabs(builder, fabs, profile);
}
if (overrides != null && overrides.length > 0) {
editInLine = true;
handleOverrides(builder, overrides, profile);
}
if (pidProperties != null && pidProperties.length > 0) {
editInLine = handlePid(builder, pidProperties, profile);
}
if (systemProperties != null && systemProperties.length > 0) {
editInLine = true;
handleSystemProperties(builder, systemProperties, profile);
}
if (configProperties != null && configProperties.length > 0) {
editInLine = true;
handleConfigProperties(builder, configProperties, profile);
}
if (resource != null && delete) {
editInLine = true;
builder.deleteFileConfiguration(resource);
}
profileService.updateProfile(builder.getProfile());
if (!editInLine) {
resource = resource != null ? resource : "io.fabric8.agent.properties";
// then open the resource in the editor.
if (pidProperties != null && pidProperties.length == 1) {
resource = pidProperties[0] + ".properties";
}
openInEditor(profile, resource);
}
}
use of io.fabric8.api.ProfileBuilder in project fabric8 by jboss-fuse.
the class GitDataStoreImplProfilesIT method readVersionAndRefreshProfile.
@Test
public void readVersionAndRefreshProfile() {
gdsi.importFromFileSystem("src/test/resources/distros/distro1/fabric/import");
Version version = profileRegistry.getVersion("1.0");
assertNotNull(version);
Profile defaultProfile = version.getProfile("default");
assertNotNull(defaultProfile);
assertThat(defaultProfile.getBundles().size(), equalTo(1));
assertThat(defaultProfile.getBundles().get(0), equalTo("mvn:io.fabric8/fabric-amazing/${version:fabric}"));
assertThat(defaultProfile.getFeatures().size(), equalTo(1));
assertThat(defaultProfile.getFeatures().get(0), equalTo("extraordinary"));
assertThat(defaultProfile.getConfigurations().size(), equalTo(2));
assertThat(defaultProfile.getConfigurations().get("my.special.pid").get("property2"), equalTo("value2"));
assertThat(defaultProfile.getConfigurations().get("io.fabric8.agent").get("some.other.property"), equalTo("valueX"));
assertThat(defaultProfile.getConfigurations().get("io.fabric8.agent").get("io.fabric8.number.of.sources"), equalTo("42,142,200"));
ProfileBuilder builder = ProfileBuilder.Factory.createFrom(defaultProfile);
Map<String, String> agentConfiguration = builder.getConfiguration(Constants.AGENT_PID);
// refresh
agentConfiguration.put("lastRefresh." + defaultProfile.getId(), String.valueOf(System.currentTimeMillis()));
agentConfiguration.put("io.fabric8.number.of.sources", "100");
builder.addConfiguration(Constants.AGENT_PID, agentConfiguration);
profileRegistry.updateProfile(builder.getProfile());
}
use of io.fabric8.api.ProfileBuilder in project fabric8 by jboss-fuse.
the class FabricFeaturesServiceImpl method getVersionProfile.
private Profile getVersionProfile(Version version) {
String profileId = "#version-" + version.getId();
ProfileBuilder builder = ProfileBuilder.Factory.create(profileId).version(version.getId());
VersionProfileOptionsProvider optionsProvider = new VersionProfileOptionsProvider(version);
return builder.addOptions(optionsProvider).getProfile();
}
Aggregations