/** * Writes given {@link Profile} under a path specified as <code>root</code>. Directory name to store a profile is * derived from {@link Profile#getId()} * @param root * @param profile * @throws IOException */ public static void writeProfile(Path root, Profile profile) throws IOException { Path path = root.resolve(profile.getId().replace("-", root.getFileSystem().getSeparator()) + PROFILE_FOLDER_SUFFIX); Files.createDirectories(path); for (Map.Entry<String, byte[]> entry : profile.getFileConfigurations().entrySet()) { Files.write(path.resolve(entry.getKey()), entry.getValue(), StandardOpenOption.CREATE_NEW); } }
/** * Writes given {@link Profile} under a path specified as <code>root</code>. Directory name to store a profile is * derived from {@link Profile#getId()} * @param root * @param profile * @throws IOException */ public static void writeProfile(Path root, Profile profile) throws IOException { Path path = root.resolve(profile.getId().replaceAll("-", root.getFileSystem().getSeparator()) + PROFILE_FOLDER_SUFFIX); Files.createDirectories(path); for (Map.Entry<String, byte[]> entry : profile.getFileConfigurations().entrySet()) { Files.write(path.resolve(entry.getKey()), entry.getValue(), StandardOpenOption.CREATE_NEW); } }
@Override public ProfileBuilder from(Profile profile) { profileId = profile.getId(); setFileConfigurations(profile.getFileConfigurations()); return this; }
@Override public ProfileBuilder from(Profile profile) { profileId = profile.getId(); setFileConfigurations(profile.getFileConfigurations()); return this; }
static void applyProfiles(File karafBase, List<String> profiles, boolean printOutput) throws IOException { BundleContext bundleContext = FrameworkUtil.getBundle(ProfileApplier.class).getBundleContext(); ServiceReference<ProfileService> reference = bundleContext.getServiceReference(ProfileService.class); ProfileService service = bundleContext.getService(reference); Profile profile = ProfileBuilder.Factory.create("temp") .addParents(profiles) .getProfile(); Profile overlay = service.getOverlayProfile(profile); final Profile effective = service.getEffectiveProfile(overlay, false); Map<String, byte[]> configs = effective.getFileConfigurations(); for (Map.Entry<String, byte[]> config : configs.entrySet()) { String pid = config.getKey(); if (!pid.equals(Profile.INTERNAL_PID + Profile.PROPERTIES_SUFFIX)) { Path configFile = Paths.get(karafBase.toString(), "etc", pid); logDebug("Creating file: %s", printOutput, configFile.toString()); Files.write(configFile, config.getValue()); } } FileLockUtils.execute(new File(karafBase, FEATURES_CFG), properties -> { appendToPropList(properties, "featuresBoot", effective.getFeatures()); appendToPropList(properties, "featuresRepositories", effective.getRepositories()); }, true); bundleContext.ungetService(reference); }
static void applyProfiles(File karafBase, List<String> profiles, boolean printOutput) throws IOException { BundleContext bundleContext = FrameworkUtil.getBundle(ProfileApplier.class).getBundleContext(); ServiceReference<ProfileService> reference = bundleContext.getServiceReference(ProfileService.class); ProfileService service = bundleContext.getService(reference); Profile profile = ProfileBuilder.Factory.create("temp") .addParents(profiles) .getProfile(); Profile overlay = service.getOverlayProfile(profile); final Profile effective = service.getEffectiveProfile(overlay, false); Map<String, byte[]> configs = effective.getFileConfigurations(); for (Map.Entry<String, byte[]> config : configs.entrySet()) { String pid = config.getKey(); if (!pid.equals(Profile.INTERNAL_PID + Profile.PROPERTIES_SUFFIX)) { Path configFile = Paths.get(karafBase.toString(), "etc", pid); logDebug("Creating file: %s", printOutput, configFile.toString()); Files.write(configFile, config.getValue()); } } FileLockUtils.execute(new File(karafBase, FEATURES_CFG), properties -> { appendToPropList(properties, "featuresBoot", effective.getFeatures()); appendToPropList(properties, "featuresRepositories", effective.getRepositories()); }, true); bundleContext.ungetService(reference); }
private void supplement(Profile profile, Map<String, SupplementControl> aggregate) { Map<String, byte[]> configs = profile.getFileConfigurations(); for (String key : configs.keySet()) {
private void supplement(Profile profile, Map<String, SupplementControl> aggregate) { Map<String, byte[]> configs = profile.getFileConfigurations(); for (String key : configs.keySet()) {
Map<String, byte[]> resources = profile.getFileConfigurations(); Map<String,Object> profileConfiguration = profile.getConfiguration(Profile.INTERNAL_PID); List<String> profileProperties = new ArrayList<>();
Map<String, byte[]> resources = profile.getFileConfigurations(); Map<String,Object> profileConfiguration = profile.getConfiguration(Profile.INTERNAL_PID); List<String> profileProperties = new ArrayList<>();
for (Map.Entry<String, byte[]> entry : profile.getFileConfigurations().entrySet()) { if (entry.getKey().endsWith(Profile.PROPERTIES_SUFFIX)) { try {
for (Map.Entry<String, byte[]> entry : profile.getFileConfigurations().entrySet()) { if (entry.getKey().endsWith(Profile.PROPERTIES_SUFFIX)) { try {
for (Map.Entry<String, byte[]> config : overallEffective.getFileConfigurations().entrySet()) { Path configFile = etcDirectory.resolve(config.getKey()); if (Files.exists(configFile)) {
for (Map.Entry<String, byte[]> config : overallEffective.getFileConfigurations().entrySet()) { Path configFile = etcDirectory.resolve(config.getKey()); if (Files.exists(configFile)) {