@Override public void rename(String name, String newName) { Profile profile = ProfileBuilder.Factory.createFrom(profileService.getProfile(name)) .identity(newName) .getProfile(); profileService.createProfile(profile); profileService.deleteProfile(name); }
@Override public Map<String, String> getProfiles() { List<String> ids = new ArrayList<>(profileService.getProfiles()); HashMap<String, String> results = new HashMap<>(); Collections.sort(ids); for (String id : ids) { Profile profile = profileService.getProfile(id); if (profile != null) { String parents = join(" ", profile.getParentIds()); results.put(id, parents); } } return results; }
@Override public Object execute() throws Exception { if (delete) { set = false; } Profile profile = profileService.getRequiredProfile(profileName); editProfile(profile); return null; }
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 void copy(String source, String target) { Profile profile = ProfileBuilder.Factory.createFrom(profileService.getProfile(source)) .identity(target) .getProfile(); profileService.createProfile(profile); }
@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 void create(String name, List<String> parents) { Profile profile = ProfileBuilder.Factory.create(name) .setParents(parents) .getProfile(); profileService.createProfile(profile); }
@Override public Object execute() throws Exception { profileService.deleteProfile(profileId); return null; }
public int complete(Session session, CommandLine commandLine, List<String> candidates) { StringsCompleter delegate = new StringsCompleter(); try { delegate.getStrings().addAll(profileService.getProfiles()); } catch (Exception e) { // ignore } return delegate.complete(session, commandLine, candidates); }
profileService.updateProfile(builder.getProfile());
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 = ProfileBuilder.Factory.createFrom(profileService.getProfile(source)) .identity(target) .getProfile(); profileService.createProfile(profile); 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; }
@Override public void create(String name, List<String> parents) { Profile profile = ProfileBuilder.Factory.create(name) .setParents(parents) .getProfile(); profileService.createProfile(profile); }
@Override public Object execute() throws Exception { profileService.deleteProfile(profileId); return null; }
public int complete(Session session, CommandLine commandLine, List<String> candidates) { StringsCompleter delegate = new StringsCompleter(); try { delegate.getStrings().addAll(profileService.getProfiles()); } catch (Exception e) { // ignore } return delegate.complete(session, commandLine, candidates); }
profileService.updateProfile(builder.getProfile());
profile = profileService.getOverlayProfile(profile); profile = profileService.getEffectiveProfile(profile);
@Override public Object execute() throws Exception { Profile profile = ProfileBuilder.Factory.createFrom(profileService.getProfile(profileName)) .identity(newName) .getProfile(); profileService.createProfile(profile); profileService.deleteProfile(profileName); return null; }
@Override public Object execute() throws Exception { Profile profile = ProfileBuilder.Factory.createFrom(profileService.getProfile(source)) .identity(target) .getProfile(); profileService.createProfile(profile); return null; }