use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.
the class BeanUtils method getFields.
public static List<String> getFields(Class clazz) {
List<String> answer = new ArrayList<String>();
try {
for (PropertyDescriptor desc : PropertyUtils.getPropertyDescriptors(clazz)) {
if (desc.getReadMethod() != null) {
answer.add(desc.getName());
}
}
} catch (Exception e) {
throw new FabricException("Failed to get property descriptors for " + clazz.toString(), e);
}
// few tweaks to maintain compatibility with existing views for now...
if (clazz.getSimpleName().equals("Container")) {
answer.add("parentId");
answer.add("versionId");
answer.add("profileIds");
answer.add("childrenIds");
answer.remove("fabricService");
} else if (clazz.getSimpleName().equals("Profile")) {
answer.add("id");
answer.add("parentIds");
answer.add("childIds");
answer.add("containerCount");
answer.add("containers");
answer.add("fileConfigurations");
} else if (clazz.getSimpleName().equals("Version")) {
answer.add("id");
answer.add("defaultVersion");
}
return answer;
}
use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.
the class FabricManager method applyVersionToContainers.
@Override
public void applyVersionToContainers(String targetVersion, List<String> containerIds) {
Version version = profileService.getVersion(targetVersion);
for (String containerId : containerIds) {
Container container = fabricService.getContainer(containerId);
List<Profile> profiles = Arrays.asList(container.getProfiles());
for (Profile profile : profiles) {
if (!profileService.hasProfile(version.getId(), profile.getId())) {
String noVersionForProfile = String.format("Can't upgrade container %s since profile %s does not have version %s", containerId, profile.getId(), version.getId());
throw new IllegalStateException(noVersionForProfile);
}
}
container.setVersion(version);
}
}
use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.
the class FabricManager method doGetProfile.
Map<String, Object> doGetProfile(Version version, String profileId, List<String> fields, boolean mandatory) {
Profile profile;
if (mandatory) {
profile = version.getRequiredProfile(profileId);
} else {
profile = version.getProfile(profileId);
}
if (profile == null) {
return null;
}
Map<String, Object> answer = BeanUtils.convertProfileToMap(fabricService, profile, fields);
String iconURLField = "iconURL";
if (fields.contains(iconURLField) && !profile.isOverlay()) {
// TODO this could move to Profile.getIconURL() but that would require
// introducing profileService into ProfileImpl and the ProfileBuilder stuff
String restApi = restApiUrl();
if (restApi != null && restApi.length() > 0) {
// turn REST into relative URI so it works with docker containers etc (avoids local ports etc)
try {
URL url = new URL(restApi);
restApi = url.getPath();
} catch (MalformedURLException e) {
// Ignore
}
String icon = getIconURL(version, version.getId(), profile, profileId, restApi);
answer.put(iconURLField, icon);
}
}
return answer;
}
use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.
the class FabricManager method setProfileTags.
@Override
public void setProfileTags(String versionId, String profileId, List<String> tags) {
Profile profile = profileService.getRequiredProfile(versionId, profileId);
ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile);
builder.setTags(tags);
profileService.updateProfile(builder.getProfile());
}
use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.
the class FabricManager method changeProfileParents.
@Override
public Map<String, Object> changeProfileParents(String versionId, String profileId, List<String> parents) {
Profile profile = profileService.getRequiredProfile(versionId, profileId);
ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile).setParents(parents);
profile = profileService.updateProfile(builder.getProfile());
return getProfile(versionId, profile.getId());
}
Aggregations