Example usage for java.lang System getenv

List of usage examples for java.lang System getenv

Introduction

In this page you can find the example usage for java.lang System getenv.

Prototype

public static String getenv(String name) 

Source Link

Document

Gets the value of the specified environment variable.

Usage

From source file:net.orpiske.tcs.service.config.SecurityConfig.java

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    String user = System.getenv("TCS_USER");
    String password = System.getenv("TCS_PASSWORD");

    if (user == null) {
        logger.fatal("The system username is not provided");
        System.exit(-1);// w ww.j  a v  a 2 s  . c o  m
    }

    if (password == null) {
        logger.fatal("The system password is not provided");
        System.exit(-1);
    }

    auth.inMemoryAuthentication().withUser(user).password(password).roles("USER");
}

From source file:uk.ac.jorum.integration.RestApiBaseTest.java

protected static int jettyPort() {
    return Integer.parseInt(System.getenv("jetty.port"));
}

From source file:com.cloudera.sqoop.manager.NetezzaTestUtils.java

public static String getNZConnectString() {
    String nzHost = System.getenv("NZ_HOST");
    if (nzHost == null) {
        nzHost = NZ_HOST;// w  w w  .  jav a2s  . co  m
    }

    String nzPort = System.getenv("NZ_PORT");
    if (nzPort == null) {
        nzPort = NZ_PORT;
    }
    String nzDB = System.getenv("NZ_DB_NAME");
    if (nzDB == null) {
        nzDB = NZ_DB_NAME;
    }

    StringBuilder url = new StringBuilder(NZ_JDBC_URL_PREFIX);
    url.append("//").append(nzHost).append(':').append(nzPort);
    url.append('/').append(nzDB);

    LOG.info("NZ Connect string generated : " + url.toString());
    return url.toString();
}

From source file:eu.optimis.ip.gui.client.resources.ConfigManager.java

public static String getFilePath(String configFile) {
    String optimisHome = optimis_Home;
    if (optimisHome == null) {
        optimis_Home = System.getenv("OPTIMIS_HOME");
        optimisHome = "/opt/optimis";
        log.warn("Please set environment variable OPTIMIS_HOME. Using default /opt/optimis.");
    }//from  w w w.ja  v  a2s  . c o m

    File fileObject = new File(optimisHome.concat(configFile));
    if (!fileObject.exists()) {
        try {
            createDefaultConfigFile(fileObject);
        } catch (Exception ex) {
            log.error("Error reading " + optimisHome.concat(configFile) + " configuration file: "
                    + ex.getMessage());
            log.error(ex.getMessage());
        }
    }

    return optimisHome.concat(configFile);
}

From source file:net.bpelunit.framework.base.BPELUnitBaseRunner.java

@Override
public void configureInit() throws ConfigurationException {
    setHomeDirectory(System.getenv(BPELUNIT_HOME_ENV));
}

From source file:com.yfiton.notifiers.email.EmailNotifierTest.java

@Test
public void testFree() throws MessagingException, ConfigurationException, ParameterException {
    testSendEmail("smtp.free.fr", "imap.free.fr", System.getenv("FREE_EMAIL"), System.getenv("FREE_USERNAME"),
            System.getenv("FREE_PASSWORD"));
}

From source file:io.github.collaboratory.LauncherTest.java

@Test
public void testCWL() throws Exception {
    File iniFile = FileUtils.getFile("src", "test", "resources", "launcher.ini");
    File cwlFile = FileUtils.getFile("src", "test", "resources", "collab.cwl");
    File jobFile = FileUtils.getFile("src", "test", "resources", "collab-cwl-job-pre.json");

    if (System.getenv("AWS_ACCESS_KEY") == null || System.getenv("AWS_SECRET_KEY") == null) {
        expectedEx.expect(AmazonClientException.class);
        expectedEx.expectMessage("Unable to load AWS credentials from any provider in the chain");
    }/*from   w w  w  . j  a v a2s  .c  o m*/
    final LauncherCWL launcherCWL = new LauncherCWL(new String[] { "--config", iniFile.getAbsolutePath(),
            "--descriptor", cwlFile.getAbsolutePath(), "--job", jobFile.getAbsolutePath() });
    launcherCWL.run(CommandLineTool.class);
}

From source file:uk.co.jassoft.email.EmailSenderService.java

public void send(String recipientAddress, String subject, Map emailContent) throws EmailSendException {
    try {//from www.  j  ava 2  s  . c om
        if (System.getenv("API_SEND_EMAILS").equals("false")) {
            LOG.info("API_SEND_EMAILS is set to [{}]", System.getenv("API_SEND_EMAILS"));
            return;
        }

        // Construct an object to contain the recipient address.
        Destination destination = new Destination().withToAddresses(recipientAddress);

        // Create the subject and body of the message.
        Content subjectContent = new Content().withData(subject);

        Body body = new Body();

        if (template != null)
            body = body.withText(new Content().withData(VelocityEngineUtils
                    .mergeTemplateIntoString(velocityEngine, template, "UTF-8", emailContent)));

        if (htmlTemplate != null)
            body = body.withHtml(new Content().withData(VelocityEngineUtils
                    .mergeTemplateIntoString(velocityEngine, htmlTemplate, "UTF-8", emailContent)));

        // Create a message with the specified subject and body.
        Message message = new Message().withSubject(subjectContent).withBody(body);

        // Assemble the email.
        SendEmailRequest request = new SendEmailRequest().withSource(fromAddress).withDestination(destination)
                .withMessage(message);

        AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(
                new EnvironmentVariableCredentialsProvider());
        Region REGION = Region.getRegion(Regions.EU_WEST_1);
        client.setRegion(REGION);

        // Send the email.
        client.sendEmail(request);
    } catch (Exception exception) {
        throw new EmailSendException(exception.getMessage(), exception);
    }
}

From source file:com.example.flexible.pubsub.PubSubPublish.java

@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
    Publisher publisher = this.publisher;
    try {/*from w  w  w  . j  a  v a2  s. c o  m*/
        String topicId = System.getenv("PUBSUB_TOPIC");
        // create a publisher on the topic
        if (publisher == null) {
            publisher = Publisher
                    .defaultBuilder(TopicName.create(ServiceOptions.getDefaultProjectId(), topicId)).build();
        }
        // construct a pubsub message from the payload
        final String payload = req.getParameter("payload");
        PubsubMessage pubsubMessage = PubsubMessage.newBuilder().setData(ByteString.copyFromUtf8(payload))
                .build();

        publisher.publish(pubsubMessage);
        // redirect to home page
        resp.sendRedirect("/");
    } catch (Exception e) {
        resp.sendError(HttpStatus.SC_INTERNAL_SERVER_ERROR, e.getMessage());
    }
}

From source file:com.consol.citrus.admin.model.build.maven.MavenBuildConfiguration.java

public MavenBuildConfiguration() {
    super("maven");

    if (System.getProperty(Application.MVN_HOME_DIRECTORY) != null) {
        mavenHome = System.getProperty(Application.MVN_HOME_DIRECTORY);
    } else if (StringUtils.hasText(System.getenv("MAVEN_HOME"))) {
        mavenHome = System.getenv("MAVEN_HOME");
    } else if (StringUtils.hasText(System.getenv("M2_HOME"))) {
        mavenHome = System.getenv("M2_HOME");
    } else {// w w  w .  j  a  va2s  .  co m
        mavenHome = "";
    }
}