@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 FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (builder != null) { String pid = file.getFileName().toString(); byte[] data = Files.readAllBytes(file); builder.addFileConfiguration(pid, data); } return FileVisitResult.CONTINUE; } }
return builder.getConfiguration(pid);
private ProfileBuilder addOptions(ProfileBuilder builder) { builder.setAttributes(self.getAttributes()); builder.setFileConfigurations(getFileConfigurations()); builder.setOverlay(true); return builder; }
@Override public void create(String name, List<String> parents) { Profile profile = ProfileBuilder.Factory.create(name) .setParents(parents) .getProfile(); profileService.createProfile(profile); }
@Override public void copy(String source, String target) { Profile profile = ProfileBuilder.Factory.createFrom(profileService.getProfile(source)) .identity(target) .getProfile(); profileService.createProfile(profile); }
/** * Generate internal profile (for the purpose of custom assembly builder) for given <code>stage</code>. * @param stage a {@link Stage} for which the profile is being generated * @param parentProfiles all profiles for given stage will be used as parent profiles * @param repositories repositories to use in generated profile * @param features features to declare in generated profile * @param bundles bundles to declare in generated profile * @return */ private Profile generateProfile(Stage stage, Map<String, Stage> parentProfiles, Map<String, RepositoryInfo> repositories, Map<String, Stage> features, Map<String, Stage> bundles) { String name = "generated-" + stage.name().toLowerCase(); List<String> stagedParentProfiles = getStaged(stage, parentProfiles); if (stagedParentProfiles.isEmpty()) { LOGGER.info("Generating {} profile", name); } else { LOGGER.info("Generating {} profile with parents: {}", name, stagedParentProfiles.stream().collect(Collectors.joining(", "))); } return ProfileBuilder.Factory.create(name) .setParents(stagedParentProfiles) .setRepositories(getStagedRepositories(stage, repositories)) .setFeatures(getStaged(stage, features)) .setBundles(getStaged(stage, bundles)) .getProfile(); }
@Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { if (exc != null) { throw exc; } if (builder != null) { Profile profile = builder.getProfile(); profiles.put(profile.getId(), profile); builder = null; } return FileVisitResult.CONTINUE; } @Override
.setParents(new ArrayList<>(profiles.keySet())) .getProfile(); Profile initialOverlay = Profiles.getOverlay(initialProfile, allProfiles, environment); Profile initialEffective = Profiles.getEffective(initialOverlay, false); .setParents(Arrays.asList(startupProfile.getId(), bootProfile.getId(), installedProfile.getId())); config.forEach((k ,v) -> builder.addConfiguration(Profile.INTERNAL_PID, Profile.CONFIG_PREFIX + k, v)); system.forEach((k ,v) -> builder.addConfiguration(Profile.INTERNAL_PID, Profile.SYSTEM_PREFIX + k, v)); blacklistedBundleURIs.forEach(builder::addBlacklistedBundle); Profile overallProfile = builder.getProfile();
TypedProperties original2 = originals2.get(cfg); original2.putAll(original); builder.addFileConfiguration(cfg + Profile.PROPERTIES_SUFFIX, Utils.toBytes(original2)); return builder.getProfile();
/** * Adds or remove the specified feature repositories to the specified profile. */ private void handleFeatureRepositories(ProfileBuilder builder, String[] repositories, Profile profile) { Map<String, Object> conf = getConfigurationFromBuilder(builder, Profile.INTERNAL_PID); for (String repositoryURI : repositories) { if (set) { System.out.println("Adding feature repository:" + repositoryURI + " to profile:" + profile.getId()); } else if (delete) { System.out.println("Deleting feature repository:" + repositoryURI + " from profile:" + profile.getId()); } updateConfig(conf, ProfileConstants.REPOSITORY_PREFIX + repositoryURI.replace('/', '_'), repositoryURI, set, delete); } builder.addConfiguration(Profile.INTERNAL_PID, conf); }
System.out.println("Importing pid:" + currentPid + " to profile:" + profile.getId()); importPidFromLocalConfigAdmin(currentPid, conf); builder.addConfiguration(currentPid, conf); return true; editInline = true; System.out.println("Deleting pid:" + currentPid + " from profile:" + profile.getId()); builder.deleteConfiguration(currentPid); } else { for (Map.Entry<String, String> configEntries : configMap.entrySet()) { builder.addConfiguration(currentPid, conf);
@Override public Object execute() throws Exception { Profile profile = ProfileBuilder.Factory.createFrom(profileService.getProfile(source)) .identity(target) .getProfile(); profileService.createProfile(profile); return null; }
/** * Generate internal profile (for the purpose of custom assembly builder) for given <code>stage</code>. * @param stage a {@link Stage} for which the profile is being generated * @param parentProfiles all profiles for given stage will be used as parent profiles * @param repositories repositories to use in generated profile * @param features features to declare in generated profile * @param bundles bundles to declare in generated profile * @return */ private Profile generateProfile(Stage stage, Map<String, Stage> parentProfiles, Map<String, RepositoryInfo> repositories, Map<String, Stage> features, Map<String, Stage> bundles) { String name = "generated-" + stage.name().toLowerCase(); List<String> stagedParentProfiles = getStaged(stage, parentProfiles); if (stagedParentProfiles.isEmpty()) { LOGGER.info("Generating {} profile", name); } else { LOGGER.info("Generating {} profile with parents: {}", name, stagedParentProfiles.stream().collect(Collectors.joining(", "))); } return ProfileBuilder.Factory.create(name) .setParents(stagedParentProfiles) .setRepositories(getStagedRepositories(stage, repositories)) .setFeatures(getStaged(stage, features)) .setBundles(getStaged(stage, bundles)) .getProfile(); }
@Override public Object execute() throws Exception { Profile profile = ProfileBuilder.Factory.create(profileId) .setParents(parents) .getProfile(); profileService.createProfile(profile); return null; }
@Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { if (exc != null) { throw exc; } if (builder != null) { Profile profile = builder.getProfile(); profiles.put(profile.getId(), profile); builder = null; } return FileVisitResult.CONTINUE; } @Override
.setParents(new ArrayList<>(profiles.keySet())) .getProfile(); Profile initialOverlay = Profiles.getOverlay(initialProfile, allProfiles, environment); Profile initialEffective = Profiles.getEffective(initialOverlay, false); .setParents(Arrays.asList(startupProfile.getId(), bootProfile.getId(), installedProfile.getId())); config.forEach((k ,v) -> builder.addConfiguration(Profile.INTERNAL_PID, Profile.CONFIG_PREFIX + k, v)); system.forEach((k ,v) -> builder.addConfiguration(Profile.INTERNAL_PID, Profile.SYSTEM_PREFIX + k, v)); blacklistedBundleURIs.forEach(builder::addBlacklistedBundle); Profile overallProfile = builder.getProfile();
private ProfileBuilder addOptions(ProfileBuilder builder) { builder.setAttributes(self.getAttributes()); builder.setFileConfigurations(getFileConfigurations()); builder.setOverlay(true); return builder; }
TypedProperties original2 = originals2.get(cfg); original2.putAll(original); builder.addFileConfiguration(cfg + Profile.PROPERTIES_SUFFIX, Utils.toBytes(original2)); return builder.getProfile();
/** * Adds or remove the specified features to the specified profile. */ private void handleFeatures(ProfileBuilder builder, String[] features, Profile profile) { Map<String, Object> conf = getConfigurationFromBuilder(builder, Profile.INTERNAL_PID); for (String feature : features) { if (delete) { System.out.println("Deleting feature:" + feature + " from profile:" + profile.getId()); } else { System.out.println("Adding feature:" + feature + " to profile:" + profile.getId()); } updateConfig(conf, ProfileConstants.FEATURE_PREFIX + feature.replace('/', '_'), feature, set, delete); builder.addConfiguration(Profile.INTERNAL_PID, conf); } }