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); }
@Override public Object execute() throws Exception { Profile profile = profileService.getRequiredProfile(profileId); Profile newProfile = ProfileBuilder.Factory.createFrom(profile) .addParents(parentIds) .getProfile(); profileService.updateProfile(newProfile); return null; }
@Override public Object execute() throws Exception { Profile profile = profileService.getRequiredProfile(profileId); Profile newProfile = ProfileBuilder.Factory.createFrom(profile) .addParents(parentIds) .getProfile(); profileService.updateProfile(newProfile); return null; }