Search in sources :

Example 11 with ProfileService

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

the class FabricFeaturesServiceImpl method getAllProfilesOverlay.

/**
 * Creates an aggregation of all available {@link Profile}s.
 */
private Profile getAllProfilesOverlay() {
    Container container = fabricService.get().getCurrentContainer();
    ProfileService profileService = fabricService.get().adapt(ProfileService.class);
    Version version = container.getVersion();
    Profile versionProfile = getVersionProfile(version);
    return Profiles.getEffectiveProfile(fabricService.get(), profileService.getOverlayProfile(versionProfile));
}
Also used : Container(io.fabric8.api.Container) ProfileService(io.fabric8.api.ProfileService) Version(io.fabric8.api.Version) Profile(io.fabric8.api.Profile)

Example 12 with ProfileService

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

the class ProfileManagerImpl method deleteProfile.

@Override
public void deleteProfile(String versionId, String profileId, boolean force) {
    Permit<ProfileService> permit = permitManager.get().aquirePermit(ProfileService.PERMIT, false);
    try {
        ProfileService service = permit.getInstance();
        service.deleteProfile(versionId, profileId, force);
    } finally {
        permit.release();
    }
}
Also used : ProfileService(io.fabric8.api.ProfileService)

Example 13 with ProfileService

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

the class ProfileManagerImpl method deleteVersion.

@Override
public void deleteVersion(String versionId) {
    Permit<ProfileService> permit = permitManager.get().aquirePermit(ProfileService.PERMIT, false);
    try {
        ProfileService service = permit.getInstance();
        service.deleteVersion(versionId);
    } finally {
        permit.release();
    }
}
Also used : ProfileService(io.fabric8.api.ProfileService)

Example 14 with ProfileService

use of io.fabric8.api.ProfileService 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;
}
Also used : MalformedURLException(java.net.MalformedURLException) Profile(io.fabric8.api.Profile) URL(java.net.URL)

Example 15 with ProfileService

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

the class MQManager method getActiveOrRequiredBrokerProfileMap.

private List<Profile> getActiveOrRequiredBrokerProfileMap(Version version, FabricRequirements requirements) {
    IllegalArgumentAssertion.assertNotNull(fabricService, "fabricService");
    List<Profile> answer = new ArrayList<Profile>();
    if (version != null) {
        ProfileService profileService = fabricService.adapt(ProfileService.class);
        List<Profile> profiles = version.getProfiles();
        for (Profile profile : profiles) {
            String versionId = profile.getVersion();
            String profileId = profile.getId();
            if (!IGNORED_PROFILES.contains(profileId)) {
                Profile overlay = profileService.getOverlayProfile(profile);
                Map<String, Map<String, String>> configurations = overlay.getConfigurations();
                Set<Map.Entry<String, Map<String, String>>> entries = configurations.entrySet();
                for (Map.Entry<String, Map<String, String>> entry : entries) {
                    String key = entry.getKey();
                    if (isBrokerConfigPid(key)) {
                        answer.add(overlay);
                    }
                }
            }
        }
    }
    return answer;
}
Also used : ProfileService(io.fabric8.api.ProfileService) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) Profile(io.fabric8.api.Profile)

Aggregations

ProfileService (io.fabric8.api.ProfileService)36 Profile (io.fabric8.api.Profile)22 Version (io.fabric8.api.Version)12 HashMap (java.util.HashMap)10 ArrayList (java.util.ArrayList)8 FabricService (io.fabric8.api.FabricService)7 Map (java.util.Map)6 Parser (io.fabric8.maven.util.Parser)5 File (java.io.File)5 HashSet (java.util.HashSet)5 ProfileBuilder (io.fabric8.api.ProfileBuilder)4 DownloadManager (io.fabric8.agent.download.DownloadManager)3 Feature (io.fabric8.agent.model.Feature)3 MalformedURLException (java.net.MalformedURLException)3 Container (io.fabric8.api.Container)2 ProfileRequirements (io.fabric8.api.ProfileRequirements)2 IOException (java.io.IOException)2 URL (java.net.URL)2 LinkedHashSet (java.util.LinkedHashSet)2 LinkedList (java.util.LinkedList)2