Example usage for org.aspectj.util FileUtil readAsString

List of usage examples for org.aspectj.util FileUtil readAsString

Introduction

In this page you can find the example usage for org.aspectj.util FileUtil readAsString.

Prototype

public static String readAsString(File file) throws IOException 

Source Link

Document

Returns the contents of this file as a String

Usage

From source file:com.github.akutschera.maven.plugin.skiptest.aspect.SkipAspect.java

License:Apache License

private void getListOfTestsToSkip() {
    testsToSkip = new HashSet<>();
    File skipFile = new File(buildDir, inputFileName);

    if (skipFile.exists()) {
        try {//from  w ww  .j av a  2  s  . co m
            String skipList = FileUtil.readAsString(skipFile);
            for (String singleTest : skipList.split(CRLF)) {
                testsToSkip.add(singleTest);
            }
        } catch (IOException e) {
            // file cannot be read, execute everything
        }
    }
}

From source file:com.impetus.ankush2.ganglia.GangliaDeployer.java

License:Open Source License

public String getConfigurationContent(String host, String confFileName) throws Exception {
    String fileContent = null;/*from   w  ww .j  a  v  a  2 s. c  o m*/
    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);
}

From source file:com.impetus.ankush2.ganglia.GangliaDeployer.java

License:Open Source License

public String getGmetadConfigurationContent(String host) throws Exception {
    String fileContent = null;/*from  www. ja  v  a 2s  . co  m*/
    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);
}

From source file:com.netflix.spinnaker.halyard.cli.command.v1.converter.LocalFileConverter.java

License:Apache License

@Override
public String convert(String value) {
    if (GlobalApplicationOptions.getInstance().isUseRemoteDaemon()) {
        try {//from   w w  w .  j  a  v a 2 s.c om
            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();
}

From source file:org.mifos.test.acceptance.rest.api.RESTAPITestHelper.java

License:Open Source License

public String getJSONFromDataSet(String apiType, String by, String apiValue) throws IOException {
    String type = apiType.replace('/', '-');
    String value = apiValue.replace('/', '-');
    String path = String.format("/dataSets/rest/%s-%s-%s.json", type, by, value);
    ClassPathResource resource = new ClassPathResource(path);
    File file = resource.getFile();
    if (file == null) {
        throw new FileNotFoundException("Couldn't find file");
    }/* w w  w  . j  av  a2s  .c  o  m*/
    return FileUtil.readAsString(file);
}

From source file:org.mifos.test.acceptance.rest.api.RESTAPITestHelper.java

License:Open Source License

public String getJSONFromDataSet(String apiType, String apiValue) throws IOException {
    String type = apiType.replace('/', '-');
    String value = apiValue.replace('/', '-');
    String path = String.format("/dataSets/rest/%s%s.json", type, value);
    ClassPathResource resource = new ClassPathResource(path);
    File file = resource.getFile();
    if (file == null) {
        throw new FileNotFoundException("Couldn't find file");
    }//from w  w w.  j av  a 2s .  c o  m
    return FileUtil.readAsString(file);
}