Search in sources :

Example 56 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class FabricManager method deleteVersion.

@Override
public void deleteVersion(String versionId) {
    Container[] containers = fabricService.getContainers();
    StringBuilder sb = new StringBuilder();
    for (Container container : fabricService.getContainers()) {
        if (versionId.equals(container.getVersionId())) {
            if (sb.length() > 0) {
                sb.append(", ");
            }
            sb.append(container.getId());
        }
    }
    IllegalStateAssertion.assertTrue(sb.length() == 0, "Version " + versionId + " is still used by the following containers: " + sb.toString());
    profileService.deleteVersion(versionId);
}
Also used : Container(io.fabric8.api.Container)

Example 57 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class FabricManager method getOverlayProfileProperties.

@Override
public Map<String, String> getOverlayProfileProperties(String versionId, String profileId, String pid) {
    Map<String, String> answer = null;
    Version version = profileService.getVersion(versionId);
    if (version != null) {
        Profile profile = version.getRequiredProfile(profileId);
        if (profile != null) {
            Profile overlayProfile = profileService.getOverlayProfile(profile);
            answer = overlayProfile.getConfiguration(pid);
        }
    }
    return answer;
}
Also used : GitVersion(io.fabric8.api.commands.GitVersion) Version(io.fabric8.api.Version) Profile(io.fabric8.api.Profile)

Example 58 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class FabricManager method stringsToProfiles.

protected Profile[] stringsToProfiles(Version version, List<String> names) {
    List<Profile> allProfiles = version.getProfiles();
    List<Profile> profiles = new ArrayList<Profile>();
    if (names == null) {
        return new Profile[0];
    }
    for (String name : names) {
        Profile profile = null;
        for (Profile p : allProfiles) {
            if (name.equals(p.getId())) {
                profile = p;
                break;
            }
        }
        if (profile == null) {
            throw new IllegalArgumentException("Profile " + name + " not found.");
        }
        profiles.add(profile);
    }
    return profiles.toArray(new Profile[profiles.size()]);
}
Also used : ArrayList(java.util.ArrayList) Profile(io.fabric8.api.Profile)

Example 59 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class FabricManager method containersForVersion.

@Override
public List<Map<String, Object>> containersForVersion(String versionId, List<String> fields) {
    Version version = profileService.getVersion(versionId);
    List<Map<String, Object>> answer = new ArrayList<Map<String, Object>>();
    if (version != null) {
        for (Container c : fabricService.getContainers()) {
            if (c.getVersion().equals(version)) {
                answer.add(BeanUtils.convertContainerToMap(fabricService, c, fields));
            }
        }
    }
    return answer;
}
Also used : Container(io.fabric8.api.Container) GitVersion(io.fabric8.api.commands.GitVersion) Version(io.fabric8.api.Version) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap)

Example 60 with Version

use of io.fabric8.api.Version in project fabric8 by jboss-fuse.

the class FabricManager method getConfigurationFileNames.

@Override
public List<String> getConfigurationFileNames(String versionId, String profileId) {
    Version version = profileService.getVersion(versionId);
    Profile profile = version.getProfile(profileId);
    if (profile != null) {
        ArrayList<String> fileNames = new ArrayList<>(profile.getConfigurationFileNames());
        return Collections.unmodifiableList(fileNames);
    } else {
        return Collections.emptyList();
    }
}
Also used : GitVersion(io.fabric8.api.commands.GitVersion) Version(io.fabric8.api.Version) ArrayList(java.util.ArrayList) Profile(io.fabric8.api.Profile)

Aggregations

Version (io.fabric8.api.Version)74 Profile (io.fabric8.api.Profile)70 File (java.io.File)52 Test (org.junit.Test)46 IOException (java.io.IOException)41 ArrayList (java.util.ArrayList)36 Container (io.fabric8.api.Container)35 HashMap (java.util.HashMap)34 ProfileService (io.fabric8.api.ProfileService)27 Map (java.util.Map)25 Git (org.eclipse.jgit.api.Git)22 FabricService (io.fabric8.api.FabricService)21 Version (org.osgi.framework.Version)21 ProfileBuilder (io.fabric8.api.ProfileBuilder)18 GitVersion (io.fabric8.api.commands.GitVersion)18 PatchException (io.fabric8.patch.management.PatchException)15 HashSet (java.util.HashSet)15 TreeMap (java.util.TreeMap)14 LinkedList (java.util.LinkedList)13 GitPatchRepository (io.fabric8.patch.management.impl.GitPatchRepository)12