public ProfileDTO(Profile profile) { this.id = profile.getId(); this.version = profile.getVersion(); this.profileHash = profile.getProfileHash(); this.parents = profile.getParentIds(); this.overlay = profile.isOverlay(); this.abstractProfile = profile.isAbstract(); this.locked = profile.isLocked(); this.hidden = profile.isHidden(); this.attributes = profile.getAttributes(); this.bundles = profile.getBundles(); this.features = profile.getFeatures(); this.repositories = profile.getRepositories(); this.fabs = profile.getFabs(); this.overrides = profile.getOverrides(); String versionId = profile.getVersion(); String profileId = profile.getId(); this.configurations = profile.getConfigurationFileNames(); }
@GET @Path("file/{fileName: .*}") public Response file(@PathParam("fileName") String fileName) { byte[] bytes = profile.getFileConfiguration(fileName); if (bytes == null) { return Response.status(Response.Status.NOT_FOUND). entity("No file: " + fileName + " for profile: " + profile.getId() + " version: " + profile.getVersion()).build(); } String mediaType = guessMediaType(fileName); return Response.ok(bytes, mediaType).build(); }
@Override public ProfileBuilder from(Profile profile) { versionId = profile.getVersion(); profileId = profile.getId(); setFileConfigurations(profile.getFileConfigurations()); return this; }
public DeployResults(Profile profile, String profileUrl) { this.profileUrl = profileUrl; this.profileId = profile.getId(); this.versionId = profile.getVersion(); }
boolean isCircularRelationship(Profile a, Profile b){ boolean result = false; List<String> aParents = a.getParentIds(); List<String> bParents = b.getParentIds(); if(a.getParentIds().contains(b.getId()) && b.getParentIds().contains(a.getId())){ result = true; } return result; }
output.println("Profile id: " + profile.getId()); output.println("Version : " + profile.getVersion()); Map<String, String> props = profile.getAttributes(); for (String key : props.keySet()) { output.println("\t" + key + ": " + props.get(key)); String versionId = profile.getVersion(); String profileId = profile.getId(); output.printf("Containers: %s\n", toString(fabricService.getAssociatedContainers(versionId, profileId))); Map<String, Map<String, String>> configuration = new HashMap<>(profile.getConfigurations()); Map<String, byte[]> resources = profile.getFileConfigurations(); Map<String,String> agentConfiguration = profile.getConfiguration(Constants.AGENT_PID); List<String> agentProperties = new ArrayList<String>(); List<String> systemProperties = new ArrayList<String>(); if (profile.getLibraries().size() > 0) { printConfigList("Libraries : ", output, profile.getLibraries()); if (profile.getRepositories().size() > 0) { printConfigList("Repositories : ", output, profile.getRepositories()); if (profile.getFeatures().size() > 0) { printConfigList("Features : ", output, profile.getFeatures()); if (profile.getBundles().size() > 0) { printConfigList("Bundles : ", output, profile.getBundles());
/** * Get a long profile info string */ public static String getProfileInfo(Profile profile) { IllegalArgumentAssertion.assertNotNull(profile, "profile"); StringBuilder builder = new StringBuilder("Profile[ver=" + profile.getVersion() + ",id=" + profile.getId() + "]"); builder.append("\nAttributes"); Map<String, String> attributes = new TreeMap<>(profile.getAttributes()); for (Entry<String, String> entry : attributes.entrySet()) { builder.append("\n " + entry.getKey() + " = " + entry.getValue()); } builder.append("\nConfigurations"); for (String pid : new TreeSet<>(profile.getConfigurations().keySet())) { builder.append("\n " + pid); Map<String, String> config = new TreeMap<>(profile.getConfiguration(pid)); for (Entry<String, String> citem : config.entrySet()) { builder.append("\n " + citem.getKey() + " = " + citem.getValue()); } } builder.append("\nFiles"); for (String fileKey : new TreeSet<>(profile.getFileConfigurations().keySet())) { if (!fileKey.endsWith(Profile.PROPERTIES_SUFFIX)) { builder.append("\n " + fileKey); } } return builder.toString(); }
private String createOrUpdateProfile(GitContext context, Profile lastProfile, Profile profile, Set<String> profiles) throws IOException, GitAPIException { assertWriteLock(); String versionId = profile.getVersion(); String profileId = profile.getId(); for (String parentId : profile.getParentIds()) { Profile parent = getProfileFromCache(profile.getVersion(), parentId); IllegalStateAssertion.assertNotNull(parent, "Parent profile does not exist: " + parentId); Map<String, byte[]> fileConfigurations = profile.getFileConfigurations(); setFileConfigurations(context, versionId, profileId, fileConfigurations);
List<String> parentProfiles = Lists.mutableList(profile.getParentIds()); List<String> bundles = Lists.mutableList(profile.getBundles()); List<String> features = Lists.mutableList(profile.getFeatures()); List<String> repositories = Lists.mutableList(profile.getRepositories()); if (!merge && oldRequirements != null) { removeAll(parentProfiles, oldRequirements.getParentProfiles()); if (!Strings.isEmpty(webContextPath)) { Map<String, String> contextPathConfig = new HashMap<>(); Map<String, String> oldValue = profile.getConfiguration(Constants.WEB_CONTEXT_PATHS_PID); if (oldValue != null) { contextPathConfig.putAll(oldValue); if (!Strings.isEmpty(description)) { String fileName = "Summary.md"; byte[] data = profile.getFileConfiguration(fileName); if (data == null || data.length == 0 || new String(data).trim().length() == 0) { builder.addFileConfiguration(fileName, description.getBytes());
public static List<MQBrokerConfigDTO> createConfigDTOs(MQService mqService, Profile profile) { List<MQBrokerConfigDTO> answer = new ArrayList<MQBrokerConfigDTO>(); Map<String, Map<String, String>> configurations = profile.getConfigurations(); Set<Map.Entry<String, Map<String, String>>> entries = configurations.entrySet(); for (Map.Entry<String, Map<String, String>> entry : entries) { if (isBrokerConfigPid(key)) { String brokerName = getBrokerNameFromPID(key); String profileId = profile.getId(); MQBrokerConfigDTO dto = new MQBrokerConfigDTO(); dto.setProfile(profileId); dto.setBrokerName(brokerName); String version = profile.getVersion(); dto.setVersion(version); List<String> parentIds = profile.getParentIds(); if (parentIds.size() > 0) { dto.setParentProfile(parentIds.get(0));
public static List<String> fetchChildIds(FabricService fabricService, Profile self) { List<String> ids = new ArrayList<String>(); ProfileService profileService = fabricService.adapt(ProfileService.class); for (Profile p : profileService.getRequiredVersion(self.getVersion()).getProfiles()) { for (String parentId : p.getParentIds()) { if (parentId.equals(self.getId())) { ids.add(p.getId()); break; } } } return ids; }
protected void printProfiles(ProfileService profileService, List<Profile> profiles, PrintStream out) { TablePrinter table = new TablePrinter(); table.columns("id", "# containers", "parents"); for (Profile profile : profiles) { String versionId = profile.getVersion(); String profileId = profile.getId(); // skip profiles that do not exists (they may have been deleted) if (profileService.hasProfile(versionId, profileId) && (hidden || !profile.isHidden())) { int active = fabricService.getAssociatedContainers(versionId, profileId).length; String parents = Strings.join(profile.getParentIds(), " "); table.row(profileId, activeContainerCountText(active), parents); } } table.print(); }
private List<Profile> getActiveOrRequiredBrokerProfileMap(Version version, FabricRequirements requirements) { IllegalArgumentAssertion.assertNotNull(fabricService, "fabricService"); List<Profile> answer = new ArrayList<Profile>(); if (version != null) { ProfileService profileService = fabricService.adapt(ProfileService.class); List<Profile> profiles = version.getProfiles(); for (Profile profile : profiles) { String versionId = profile.getVersion(); String profileId = profile.getId(); if (!IGNORED_PROFILES.contains(profileId)) { Profile overlay = profileService.getOverlayProfile(profile); Map<String, Map<String, String>> configurations = overlay.getConfigurations(); Set<Map.Entry<String, Map<String, String>>> entries = configurations.entrySet(); for (Map.Entry<String, Map<String, String>> entry : entries) { String key = entry.getKey(); if (isBrokerConfigPid(key)) { answer.add(overlay); } } } } } return answer; }
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; }
/** * Returns the configuration file names for the given profile */ public static Map<String,String> getConfigurationFileNameMap(Profile[] profiles) { Map<String, String> answer = new TreeMap<String, String>(); for (Profile profile : profiles) { String id = profile.getId(); Set<String> files = profile.getConfigurationFileNames(); for (String file : files) { if (!answer.containsKey(file)) { answer.put(file, id); } } } return answer; }
protected static void appendMavenDependencies(Map<String, Parser> artifacts, Profile profile) { Set<String> configurationFileNames = profile.getConfigurationFileNames(); for (String configurationFileName : configurationFileNames) { if (configurationFileName.startsWith("dependencies/") && configurationFileName.endsWith("-requirements.json")) { byte[] data = profile.getFileConfiguration(configurationFileName); try { ProjectRequirements requirements = DtoHelper.getMapper().readValue(data, ProjectRequirements.class); if (requirements != null) { DependencyDTO rootDependency = requirements.getRootDependency(); if (rootDependency != null) { addMavenDependencies(artifacts, rootDependency); } } } catch (IOException e) { LOGGER.error("Failed to parse project requirements from " + configurationFileName + ". " + e, e); } } } }
public Map<String, String> getConfiguration(String pid) { return delegate.getConfiguration(pid); }
public static List<String> fetchConfigurations(Profile self) { List<String> answer = new ArrayList<String>(); answer.addAll(self.getFileConfigurations().keySet()); return answer; }
/** * Returns the configuration file data for the given file name and list of inherited profiles */ public static byte[] getFileConfiguration(Collection<Profile> profiles, String fileName) { byte[] answer = null; for (Profile profile : profiles) { answer = profile.getFileConfiguration(fileName); if (answer != null) { break; } } return answer; }
/** * 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(); }