@Override public void deleteConfigurationFiles(String versionId, List<String> profileIds, List<String> fileNames) { if (profileIds.size() != fileNames.size()) { throw new FabricException("Lists of profile IDs and filenames should be the same size"); } for (int i = 0; i < profileIds.size(); i++) { String profileId = profileIds.get(i); String fileName = fileNames.get(i); Profile profile = profileService.getRequiredProfile(versionId, profileId); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile); builder.deleteFileConfiguration(fileName); profileService.updateProfile(builder.getProfile()); } }
public static void refreshProfile(FabricService fabricService, Profile profile) { LOGGER.info("refreshProfile: {}", profile); ProfileService profileService = fabricService.adapt(ProfileService.class); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile); Map<String, String> agentConfiguration = builder.getConfiguration(Constants.AGENT_PID); agentConfiguration.put("lastRefresh." + profile.getId(), String.valueOf(System.currentTimeMillis())); builder.addConfiguration(Constants.AGENT_PID, agentConfiguration); profileService.updateProfile(builder.getProfile()); }
public static void refreshProfile(FabricService fabricService, Profile profile) { LOGGER.info("refreshProfile: {}", profile); ProfileService profileService = fabricService.adapt(ProfileService.class); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile); Map<String, String> agentConfiguration = builder.getConfiguration(Constants.AGENT_PID); agentConfiguration.put("lastRefresh." + profile.getId(), String.valueOf(System.currentTimeMillis())); builder.addConfiguration(Constants.AGENT_PID, agentConfiguration); profileService.updateProfile(builder.getProfile()); }
@Override public void setProfileOptionals(String versionId, String profileId, List<String> optionals) { Profile profile = profileService.getRequiredProfile(versionId, profileId); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile); builder.setOptionals(optionals); profileService.updateProfile(builder.getProfile()); }
@Override public void setProfileOverrides(String versionId, String profileId, List<String> overrides) { Profile profile = profileService.getRequiredProfile(versionId, profileId); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile); builder.setOverrides(overrides); profileService.updateProfile(builder.getProfile()); }
@Override public void setProfileRepositories(String versionId, String profileId, List<String> repositories) { Profile profile = profileService.getRequiredProfile(versionId, profileId); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile); builder.setRepositories(repositories); profileService.updateProfile(builder.getProfile()); }
@Override public void setProfileBundles(String versionId, String profileId, List<String> bundles) { Profile profile = profileService.getRequiredProfile(versionId, profileId); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile); builder.setBundles(bundles); profileService.updateProfile(builder.getProfile()); }
@Override public void deleteConfigurationFile(String versionId, String profileId, String fileName) { Profile profile = profileService.getRequiredProfile(versionId, profileId); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile); builder.deleteFileConfiguration(fileName); profileService.updateProfile(builder.getProfile()); }
@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; }
@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()); }
public static void copyProfile(FabricService fabricService, String versionId, String sourceId, String targetId, boolean force) { ProfileService profileService = fabricService.adapt(ProfileService.class); Profile sourceProfile = profileService.getRequiredProfile(versionId, sourceId); LOGGER.info("copyProfile: {} => {}", sourceProfile, targetId); // [TODO] delete/create profile must be done in an atomic operation maybeDeleteProfile(fabricService, versionId, targetId, force); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(sourceProfile); profileService.createProfile(builder.identity(targetId).getProfile()); }
public static void copyProfile(FabricService fabricService, String versionId, String sourceId, String targetId, boolean force) { ProfileService profileService = fabricService.adapt(ProfileService.class); Profile sourceProfile = profileService.getRequiredProfile(versionId, sourceId); LOGGER.info("copyProfile: {} => {}", sourceProfile, targetId); // [TODO] delete/create profile must be done in an atomic operation maybeDeleteProfile(fabricService, versionId, targetId, force); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(sourceProfile); profileService.createProfile(builder.identity(targetId).getProfile()); }
/** * Get the effective profile, which is the overlay profile with substituted configurations. */ public static Profile getEffectiveProfile(FabricService fabricService, Profile profile) { ProfileService profileService = fabricService.adapt(ProfileService.class); Profile overlayProfile = profileService.getOverlayProfile(profile); Map<String, Map<String, String>> configurations = overlayProfile.getConfigurations(); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(overlayProfile); builder.setConfigurations(fabricService.substituteConfigurations(configurations, overlayProfile.getId())); return builder.getProfile(); }
@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()); }
@Override public void setConfigurationFile(String versionId, String profileId, String fileName, String data) { Profile profile = profileService.getRequiredProfile(versionId, profileId); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile); builder.addFileConfiguration(fileName, Base64.decodeBase64(data)); // ENTESB-2315: profile equality doesn't consider change of resources contents profileService.updateProfile(builder.getProfile(), true); }
/** * Get the effective profile, which is the overlay profile with substituted configurations. */ public static Profile getEffectiveProfile(FabricService fabricService, Profile profile) { ProfileService profileService = fabricService.adapt(ProfileService.class); Profile overlayProfile = profileService.getOverlayProfile(profile); Map<String, Map<String, String>> configurations = overlayProfile.getConfigurations(); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(overlayProfile); builder.setConfigurations(fabricService.substituteConfigurations(configurations)); return builder.getProfile(); }
@Override public void setConfigurationValue(String versionId, String profileId, String pid, String key, String value) { assertValid(); Version version = profileService.get().getRequiredVersion(versionId); Profile profile = version.getRequiredProfile(profileId); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile); Map<String, String> config = builder.getConfiguration(pid); config.put(key, value); builder.addConfiguration(pid, config); profileService.get().updateProfile(builder.getProfile()); }
@Override public void setProfileFabs(String versionId, String profileId, List<String> fabs) { Profile profile = profileService.getRequiredProfile(versionId, profileId); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile); builder.setFabs(fabs); profileService.updateProfile(builder.getProfile()); }
@Override public void setProfileFeatures(String versionId, String profileId, List<String> features) { Profile profile = profileService.getRequiredProfile(versionId, profileId); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile); builder.setFeatures(features); profileService.updateProfile(builder.getProfile()); }
@Override public void setProfileAttribute(String versionId, String profileId, String attributeId, String value) { Profile profile = profileService.getRequiredProfile(versionId, profileId); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile); builder.addAttribute(attributeId, value); profileService.updateProfile(builder.getProfile()); }