Java Code Examples for org.aspectj.util.FileUtil#readAsString()
The following examples show how to use
org.aspectj.util.FileUtil#readAsString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalFileConverter.java From halyard with Apache License 2.0 | 6 votes |
@Override public String convert(String value) { if (EncryptedSecret.isEncryptedSecret(value) || isConfigServerResource(value)) { return value; } if (GlobalApplicationOptions.getInstance().isUseRemoteDaemon()) { try { return FileUtil.readAsString(new File(value)); } catch (IOException e) { throw new HalException( Problem.Severity.FATAL, "Was passed parameter " + value + " to unreadable file: " + e.getMessage()); } } return new File(value).getAbsolutePath(); }
Example 2
Source File: GangliaDeployer.java From ankush with GNU Lesser General Public License v3.0 | 5 votes |
public String getConfigurationContent(String host, String confFileName) throws Exception { String fileContent = null; Map<String, Object> configValues = getConfigValueMap(); String udpRecvChannel = "udp_recv_channel {\n port = " + configValues.get("port") + " \n } "; // 'udp_recv_channel' value for gmond.conf configValues.put("udp_recv_channel", "/*" + udpRecvChannel + "*/"); if (((String) advanceConf .get(GangliaConstants.ClusterProperties.GMETAD_HOST)) .equals(host)) { StringBuffer nodeIpPorts = new StringBuffer(); // Preparing a String of nodeIp:port of gmetad node used in // data_source in gmetad.conf. nodeIpPorts .append(advanceConf .get(GangliaConstants.ClusterProperties.GMETAD_HOST)) .append(Symbols.STR_COLON); nodeIpPorts.append(advanceConf .get(GangliaConstants.ClusterProperties.GANGLIA_PORT)); // Putting the nodeIpsPorts string in map configValues.put("nodeIpsPorts", nodeIpPorts.toString()); // On gmond nodes other than Gmetad node commenting // udp_recv_channel block configValues.put("udp_recv_channel", udpRecvChannel); } // Reading the content of the template file fileContent = FileUtil.readAsString(new File(confFileName)); // Creating a string substitutor using config values map StrSubstitutor sub = new StrSubstitutor(configValues); // Replacing the config values key found in the file content with // respected values. return sub.replace(fileContent); }
Example 3
Source File: GangliaDeployer.java From ankush with GNU Lesser General Public License v3.0 | 4 votes |
public String getGmetadConfigurationContent(String host) throws Exception { String fileContent = null; String confFileName = (String) advanceConf .get(GangliaConstants.ClusterProperties.SERVER_CONF_FOLDER) + GangliaConstants.ConfigurationFiles.GMOND_CONF; Map<String, Object> configValues = getConfigValueMap(); String udpRecvChannel = "udp_recv_channel {\n port = " + configValues.get("port") + " \n } "; configValues.put("udp_recv_channel", "/*" + udpRecvChannel + "*/"); if (((String) advanceConf .get(GangliaConstants.ClusterProperties.GMETAD_HOST)) .equals(host)) { confFileName = (String) advanceConf .get(GangliaConstants.ClusterProperties.SERVER_CONF_FOLDER) + GangliaConstants.ConfigurationFiles.GMETAD_CONF; StringBuffer nodeIpPorts = new StringBuffer(); // Preparing a String of nodeIp:port of gmetad node. nodeIpPorts .append(advanceConf .get(GangliaConstants.ClusterProperties.GMETAD_HOST)) .append(Symbols.STR_COLON); nodeIpPorts.append(advanceConf .get(GangliaConstants.ClusterProperties.GANGLIA_PORT)); // Putting the nodeIpsPorts string in map configValues.put("nodeIpsPorts", nodeIpPorts.toString()); // On gmond nodes other than Gmetad node commenting // udp_recv_channel block configValues.put("udp_recv_channel", udpRecvChannel); } // Reading the content of the template file fileContent = FileUtil.readAsString(new File(confFileName)); // Creating a string substitutor using config values map StrSubstitutor sub = new StrSubstitutor(configValues); // Replacing the config values key found in the file content with // respected values. return sub.replace(fileContent); }