@Override public ProfileBuilder profileBuilder(String versionId, String profileId) { return new DefaultProfileBuilder().version(versionId).identity(profileId); }
public static void renameProfile(FabricService fabricService, String versionId, String sourceId, String targetId, boolean force) { ProfileService profileService = fabricService.adapt(ProfileService.class); Profile sourceProfile = profileService.getRequiredProfile(versionId, sourceId); LOGGER.info("renameProfile: {} => {}", sourceProfile, targetId); // [TODO] delete/create profile must be done in an atomic operation maybeDeleteProfile(fabricService, versionId, targetId, force); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(sourceProfile); Profile targetProfile = profileService.createProfile(builder.identity(targetId).getProfile()); // TODO: what about child profiles ? for (Container container : fabricService.getAssociatedContainers(versionId, sourceId)) { Profile[] containerProfiles = container.getProfiles(); Set<Profile> profileSet = new HashSet<Profile>(Arrays.asList(containerProfiles)); profileSet.remove(sourceProfile); profileSet.add(targetProfile); container.setProfiles(profileSet.toArray(new Profile[profileSet.size()])); } maybeDeleteProfile(fabricService, versionId, sourceId, true); }
public static void renameProfile(FabricService fabricService, String versionId, String sourceId, String targetId, boolean force) { ProfileService profileService = fabricService.adapt(ProfileService.class); Profile sourceProfile = profileService.getRequiredProfile(versionId, sourceId); LOGGER.info("renameProfile: {} => {}", sourceProfile, targetId); // [TODO] delete/create profile must be done in an atomic operation maybeDeleteProfile(fabricService, versionId, targetId, force); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(sourceProfile); Profile targetProfile = profileService.createProfile(builder.identity(targetId).getProfile()); // TODO: what about child profiles ? for (Container container : fabricService.getAssociatedContainers(versionId, sourceId)) { Profile[] containerProfiles = container.getProfiles(); Set<Profile> profileSet = new HashSet<Profile>(Arrays.asList(containerProfiles)); profileSet.remove(sourceProfile); profileSet.add(targetProfile); container.setProfiles(profileSet.toArray(new Profile[profileSet.size()])); } maybeDeleteProfile(fabricService, versionId, sourceId, true); }
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()); }