public static List<String> profileIds(Profile... profiles) { List<String> answer = new ArrayList<String>(); if (profiles != null) { for (Profile profile : profiles) { answer.add(profile.getId()); } } return answer; }
public static List<String> profileIds(Iterable<Profile> profiles) { List<String> answer = new ArrayList<String>(); if (profiles != null) { for (Profile profile : profiles) { answer.add(profile.getId()); } } return answer; }
public static String toString(Profile[] profiles) { if (profiles == null) { return ""; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < profiles.length; i++) { if (i != 0) { sb.append(", "); } sb.append(profiles[i].getId()); } return sb.toString(); }
/** * Returns true if the given container has the given profile */ public static boolean containerHasProfile(Container container, Profile profile) { return containerHasProfile(container, profile.getId()); }
public DeployResults(Profile profile, String profileUrl) { this.profileUrl = profileUrl; this.profileId = profile.getId(); this.versionId = profile.getVersion(); }
public ProfileVersionKey(Profile profile) { this.profile = profile; this.profileId = profile.getId(); this.version = profile.getVersion(); }
/** * Returns true if the given container has the given profile */ public static boolean containerHasProfile(Container container, Profile profile) { return containerHasProfile(container, profile.getId()); }
/** * Returns true if the given container has the given profile directly (rather than inheritence) */ public static boolean containerHasProfile(Container container, String profileId) { for (Profile p : container.getProfiles()) { if (profileId.equals(p.getId())) { return true; } } return false; }
private static Profile getProfile(List<Profile> profiles, String name, Version version) { if (profiles == null || profiles.size() == 0) { return null; } for (Profile profile : profiles) { if (profile.getId().equals(name) && profile.getVersion().equals(version.getId())) { return profile; } } return null; } }
private static Profile getProfile(List<Profile> profiles, String name, Version version) { if (profiles == null || profiles.size() == 0) { return null; } for (Profile profile : profiles) { if (profile.getId().equals(name) && profile.getVersion().equals(version.getId())) { return profile; } } return null; } }
@GET @Path("requirements") public ProfileRequirements requirements() { FabricRequirements requirements = getFabricService().getRequirements(); if (requirements != null) { return requirements.getOrCreateProfileRequirement(profile.getId()); } return null; }
@Override public List<Map<String, Object>> getProfiles(String versionId, List<String> fields) { List<Map<String, Object>> answer = new ArrayList<Map<String, Object>>(); Version version = profileService.getVersion(versionId); for (Profile p : version.getProfiles()) { answer.add(doGetProfile(version, p.getId(), fields, true)); } return answer; }
protected Object doExecute() throws Exception { FabricValidations.validateContainerName(container); //Do not validate profile names, because we want to be able to remove non-existent profiles. Container cont = FabricCommand.getContainer(fabricService, container); // allow to remove non-existing profiles List<String> profileIds = new ArrayList<>(); for (Profile profile : FabricCommand.getProfiles(fabricService, cont.getVersion(), profiles)) { profileIds.add(profile.getId()); } cont.removeProfiles(profileIds.toArray(new String[profileIds.size()])); return null; } }
public String call(Git git, GitContext context) throws Exception { String versionId = profile.getVersion(); String profileId = profile.getId(); Version version = getRequiredVersion(versionId); IllegalStateAssertion.assertFalse(version.hasProfile(profileId), "Profile already exists: " + profileId); checkoutRequiredProfileBranch(git, context, versionId, profileId); return createOrUpdateProfile(context, null, profile, new HashSet<String>()); } };
@Override public ProfileBuilder from(Profile profile) { versionId = profile.getVersion(); profileId = profile.getId(); setFileConfigurations(profile.getFileConfigurations()); return this; }
@DELETE public void deleteProfile() { FabricService fabricService = getFabricService(); Objects.notNull(fabricService, "fabricService"); ProfileService profileService = getProfileService(); Objects.notNull(profileService, "profileService"); profileService.deleteProfile(fabricService, profile.getVersion(), profile.getId(), true); }
@Override public Map<String, Object> changeProfileParents(String versionId, String profileId, List<String> parents) { Profile profile = profileService.getRequiredProfile(versionId, profileId); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile).setParents(parents); profile = profileService.updateProfile(builder.getProfile()); return getProfile(versionId, profile.getId()); }
/** * Get the effective profile, which is the overlay profile with substituted configurations. */ public static Profile getEffectiveProfile(FabricService fabricService, Profile profile) { ProfileService profileService = fabricService.adapt(ProfileService.class); Profile overlayProfile = profileService.getOverlayProfile(profile); Map<String, Map<String, String>> configurations = overlayProfile.getConfigurations(); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(overlayProfile); builder.setConfigurations(fabricService.substituteConfigurations(configurations, overlayProfile.getId())); return builder.getProfile(); }
private void openInEditor(Profile profile, String resource) throws Exception { String id = profile.getId(); String version = profile.getVersion(); String location = id + " " + version + " " + resource; //Call the editor ConsoleEditor editor = editorFactory.create("simple",getTerminal(), System.in, System.out); editor.setTitle("Profile"); editor.setOpenEnabled(false); editor.setContentManager(new DatastoreContentManager(fabricService)); editor.open(location, id + " " + version); editor.start(); }