/** * 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; }
/** * 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; }
public Byte[] getFileConfiguration(String fileName) { byte[] array = delegate.getFileConfiguration(fileName); return fromPrimitiveArray(array); }
public Byte[] getFileConfiguration(String fileName) { byte[] array = delegate.getFileConfiguration(fileName); return fromPrimitiveArray(array); }
@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(); }
/** * Loads content from the specified location. */ @Override public String load(String location) throws IOException { try { String[] parts = location.trim().split(" "); if (parts.length < 3) { throw new IllegalArgumentException("Invalid location:" + location); } String profileId = parts[0]; String versionId = parts[1]; String resource = parts[2]; Profile profile = profileRegistry.getRequiredProfile(versionId, profileId); String data = new String(profile.getFileConfiguration(resource)); return data != null ? data : ""; } catch (Exception e) { throw new IOException("Failed to read data from zookeeper.", e); } }
@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(); }
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); } } } }
private ProjectRequirements writeRequirementsJson(ProjectRequirements requirements, Profile profile, ProfileBuilder builder) throws IOException { ObjectMapper mapper = DtoHelper.getMapper(); byte[] json = mapper.writeValueAsBytes(requirements); String fileName = DtoHelper.getRequirementsConfigFileName(requirements); // lets read the previous requirements if there are any ProfileRegistry profileRegistry = fabricService.get().adapt(ProfileRegistry.class); byte[] oldData = profile.getFileConfiguration(fileName); LOG.info("Writing file " + fileName + " to profile " + profile); builder.addFileConfiguration(fileName, json); if (oldData == null || oldData.length == 0) { return null; } else { return mapper.reader(ProjectRequirements.class).readValue(oldData); } }
bytes = overlayProfile.getFileConfiguration(path); resolved = true; } catch (IllegalStateException e) {
byte[] keystore = overlay.getFileConfiguration("keystore.jks"); if( keystore==null ) { try { byte[] truststore = overlay.getFileConfiguration("truststore.jks"); if (truststore == null && configs.get("keystore.password")!=null) { try {
if (configFile.startsWith(routePath)) { LOG.info("Sending file: " + configFile + " to " + endpoint); byte[] data = effectiveProfile.getFileConfiguration(configFile); if (data != null) {
if (configFile.startsWith(routePath)) { LOG.info("Sending file: " + configFile + " to " + endpoint); byte[] data = effectiveProfile.getFileConfiguration(configFile); if (data != null) {
} else { ProfileBuilder builder = ProfileBuilder.Factory.createFrom(fabricProfile); Properties agentProps = DataStoreUtils.toProperties(fabricProfile.getFileConfiguration("io.fabric8.agent.properties")); agentProps.put("feature.fabric-commands", "fabric-commands"); builder.addFileConfiguration("io.fabric8.agent.properties", DataStoreUtils.toBytes(agentProps));
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());