@Override public void renameProfile(String versionId, String profileId, String newId, boolean force) { Version v = profileService.getVersion(versionId); if (v != null) { Profiles.renameProfile(fabricService, versionId, profileId, newId, force); } }
private Version findVersion(FabricService fabricService, String versionId) { ProfileService profileService = fabricService.adapt(ProfileService.class); return profileService.getVersion(versionId); }
@Override public void copyProfile(String versionId, String sourceId, String targetId, boolean force) { Version v = profileService.getVersion(versionId); if (v != null) { Profiles.copyProfile(fabricService, versionId, sourceId, targetId, force); } }
@Override public Map<String, Object> getVersion(String versionId, List<String> fields) { return BeanUtils.convertVersionToMap(fabricService, profileService.getVersion(versionId), fields); }
@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(); } }
@Override public String getConfigurationFile(String versionId, String profileId, String fileName) { return Base64.encodeBase64String(profileService.getVersion(versionId).getRequiredProfile(profileId).getFileConfigurations().get(fileName)); }
@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; }
/** * Gets all the existing profiles for the given names. * * @throws IllegalArgumentException if a profile with the given name does not exists */ public static Profile[] getExistingProfiles(FabricService fabricService, String version, List<String> names) { ProfileService profileService = fabricService.adapt(ProfileService.class); return getExistingProfiles(fabricService, profileService.getVersion(version), names); }
/** * Gets all the existing profiles for the given names. * * @throws IllegalArgumentException if a profile with the given name does not exists */ public static Profile[] getExistingProfiles(FabricService fabricService, String version, List<String> names) { ProfileService profileService = fabricService.adapt(ProfileService.class); return getExistingProfiles(fabricService, profileService.getVersion(version), names); }
@Override public Version getVersion() { String versionId = dataStore.getContainerVersion(id); ProfileService profileService = fabricService.adapt(ProfileService.class); return versionId != null ? profileService.getVersion(versionId) : null; }
/** * Gets all the profiles for the given names. * <p/> * <b>Important:</b> If a profile does not already exists with the given name, then a new {@link Profile} is * created and returned in the list. * * @see #getExistingProfiles(io.fabric8.api.FabricService, String, java.util.List) */ public static Profile[] getProfiles(FabricService fabricService, String version, List<String> names) { ProfileService profileService = fabricService.adapt(ProfileService.class); return getProfiles(fabricService, profileService.getVersion(version), names); }
@Override public Map<String, String> getProfileProperties(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) { answer = profile.getConfiguration(pid); } } return answer; }
@Override public List<Map<String, Object>> getProfiles(String versionId, List<String> fields) { List<Map<String, Object>> answer = new ArrayList<Map<String, Object>>(); Version version = profileService.getVersion(versionId); for (Profile p : version.getProfiles()) { answer.add(doGetProfile(version, p.getId(), fields, true)); } return answer; }
public void refreshProfile(String versionId, String profileId) { Version version = profileService.getVersion(versionId); if (version != null) { Profile profile = version.getRequiredProfile(profileId); if (profile != null) { Profiles.refreshProfile(fabricService, profile); } } }
/** * Gets all the profiles for the given names. * <p/> * <b>Important:</b> If a profile does not already exists with the given name, then a new {@link Profile} is * created and returned in the list. * * @see #getExistingProfiles(io.fabric8.api.FabricService, String, java.util.List) */ public static Profile[] getProfiles(FabricService fabricService, String version, List<String> names) { ProfileService profileService = fabricService.adapt(ProfileService.class); return getProfiles(fabricService, profileService.getVersion(version), names); }
@Override public List<String> getProfileIds(String version) { return Ids.getIds(profileService.getVersion(version).getProfiles()); }
@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; }
@Override public Version getVersion(String versionId) { Permit<ProfileService> permit = permitManager.get().aquirePermit(ProfileService.PERMIT, false); try { ProfileService service = permit.getInstance(); return service.getVersion(versionId); } finally { permit.release(); } }
@Override public Version getDefaultVersion() { assertValid(); String versionId = dataStore.get().getDefaultVersion(); return profileService.get().getVersion(versionId); }
@Override public String setProfileProperty(String versionId, String profileId, String pid, String propertyName, String value) { Version version = profileService.getVersion(versionId); Profile profile = version.getRequiredProfile(profileId); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile); Map<String, String> profileProperties = builder.getConfiguration(pid); String answer = profileProperties.put(propertyName, value); builder.addConfiguration(pid, profileProperties); profileService.updateProfile(builder.getProfile()); return answer; }