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:org.jasig.portlet.announcements.spring.StringEncryptorFactoryBean.java

@Override
public StringEncryptor getObject() throws Exception {

    final StandardPBEStringEncryptor rslt = new StandardPBEStringEncryptor();

    /*//from w w w.  ja v a 2 s  . co m
     * If properties file encryption is used in this deployment, the
     * encryption key will be made available to the application as an
     * environment variable called UP_JASYPT_KEY.
     */
    final String encryptionKey = System.getenv(JAYSYPT_ENCRYPTION_KEY_VARIABLE);

    if (encryptionKey != null) {

        logger.info("Jasypt support for encrypted property values ENABLED");

        rslt.setPassword(encryptionKey);

    } else {

        logger.info(
                "Jasypt support for encrypted property values DISABLED;  "
                        + "specify environment variable {} to use this feature",
                JAYSYPT_ENCRYPTION_KEY_VARIABLE);

        /*
         * According to the API docs, not setting a password (on the StandardPBEStringEncryptor)
         * will result in an EncryptionInitializationException being thrown during initialization,
         * which will occur on the first call to decrypt(...);
         */

    }

    return rslt;

}

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

protected static String webXmlLocation() {
    return System.getenv("webxml.location");
}

From source file:com.photon.phresco.framework.validators.EnvironmentValidator.java

public List<ValidationResult> validate(String ProjectCode) throws PhrescoException {
    List<ValidationResult> results = new ArrayList<ValidationResult>(16);
    String nodeJSHome = System.getenv("SONAR_HOME");
    if (StringUtils.isEmpty(nodeJSHome)) {
        results.add(new ValidationResult(ValidationResult.Status.ERROR,
                "Environment variable SONAR_HOME is not set"));
    } else {//from   w w  w. j av  a2s.  com
        File nodeJsHomeDir = new File(nodeJSHome);
        if (!nodeJsHomeDir.exists()) {
            results.add(new ValidationResult(ValidationResult.Status.ERROR,
                    "SONAR_HOME " + nodeJSHome + " is incorrect"));
        }

        //TODO:Execute a system command for node ... and try to see if it works
    }
    List<String> invalidproj = validateProjectCode();
    if (!invalidproj.isEmpty()) {
        results.add(new ValidationResult(ValidationResult.Status.ERROR,
                "projects  " + invalidproj + " is incorrect"));
    }
    return results;
}

From source file:org.pgptool.gui.config.impl.ConfigsBasePathResolverUserHomeImpl.java

@Override
public String getConfigsBasePath() {
    if (chosenLocation == null) {
        String[] options = new String[] { System.getenv("USERPROFILE"),
                SystemUtils.getUserHome().getAbsolutePath(), "~" };
        log.debug("Base path options: " + Arrays.toString(options));

        for (int i = 0; i < options.length; i++) {
            if (tryAccept(options[i])) {
                return chosenLocation;
            }//from w  ww .  j av  a  2  s. c o m
        }

        Preconditions.checkState(false,
                "No config path was chosen as acceptable. Check application have rights to write files on the disk");
    }

    return chosenLocation;
}

From source file:com.seleniumtests.ut.connectors.extools.TestSoapUi.java

@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testNoSoapUiEnvVar() {
    PowerMockito.mockStatic(System.class);
    when(System.getenv("SOAPUI_HOME")).thenReturn(null);
    new SoapUi();
}

From source file:de.cosmocode.palava.core.inject.SettingsModule.java

@Override
public void configure(Binder binder) {
    Names.bindProperties(binder, properties);
    LOG.debug("Binding properties {} as settings", properties);
    binder.bind(Properties.class).annotatedWith(Settings.class).toInstance(properties);

    final String environment = System.getenv(PALAVA_ENVIRONMENT);
    if (StringUtils.isNotBlank(environment)) {
        LOG.info("Palava Environment is '{}'", environment);
        binder.bind(String.class).annotatedWith(PalavaEnvironment.class).toInstance(environment);
    } else {/*w  ww .ja  v a 2  s.com*/
        LOG.warn("Palava Environment is not set");
    }
}

From source file:com.github.trask.sandbox.mail.ElasticEmailServiceTest.java

@Before
public void before() throws Exception {
    preExistingThreads = ThreadChecker.currentThreadList();
    String popGmailUsername = System.getenv("POP_GMAIL_USERNAME");
    String popGmailPassword = System.getenv("POP_GMAIL_PASSWORD");
    popClient = new PopGmailClient(popGmailUsername, popGmailPassword);
    popClient.pop();/*from  w  w w.j  a  va 2s.c o m*/
    asyncHttpClient = new AsyncHttpClient();
    String elasticEmailUsername = System.getenv("ELASTIC_EMAIL_USERNAME");
    String elasticEmailApiKey = System.getenv("ELASTIC_EMAIL_API_KEY");
    mailService = new ElasticEmailService(elasticEmailUsername, elasticEmailApiKey, asyncHttpClient);
}

From source file:net.oneandone.shared.artifactory.ArtifactoryModule.java

ArtifactoryModule() {
    this(System.getenv("ARTIFACTORY_INSTANCE"));
}

From source file:at.tuwien.minimee.migration.evaluators.ImageCompareEvaluator.java

/**
 * @throws IllegalStateException if IMAGEMAGICK_HOME is not set
 *//*from  w w w .  ja v  a2  s . c om*/
public ImageCompareEvaluator() {
    IMAGEMAGICK_HOME = System.getenv("IMAGEMAGICK_HOME");

    //
    // IMAGEMAGICK_HOME is set and the directory exists
    if (IMAGEMAGICK_HOME != null && new File(IMAGEMAGICK_HOME).exists()) {
        compareCommand = compareCommand.replace("%IMAGEMAGICK_HOME%",
                new File(IMAGEMAGICK_HOME).getAbsolutePath());

        return;
        //
        // IMAGEMAGICK_HOME is not set, but the operating system is Linux and the ImageMagick is installed
    } else if (IMAGEMAGICK_HOME == null && ("Linux".compareTo(System.getProperty("os.name")) == 0)
            && new File("/usr/bin/compare").exists()) {
        compareCommand = compareCommand.replace("%IMAGEMAGICK_HOME%", "/usr/bin");

        return;
    }

    // 
    // in all other cases, where IMAGEMAGICK_HOME is not set, we throw an exception.
    if (IMAGEMAGICK_HOME == null) {
        throw new IllegalStateException(
                "ImageMagick is not propertly configured - IMAGEMAGICK_HOME is not defined.");
    }
}

From source file:org.createnet.raptor.auth.service.YamlFileApplicationContextInitializer.java

@Override
public void initialize(ConfigurableApplicationContext applicationContext) {

    File configFile = new File(configPath);
    if (!configFile.exists()) {
        logger.warn("Configurations file does not exists: {}", configPath);
        return;/* w w  w.  j  a v  a 2s  . com*/
    }

    try {

        String context = System.getenv("SPRING_PROFILES_ACTIVE");
        if (context == null || context.isEmpty()) {
            context = "default";
        }

        Resource resource = new FileSystemResource(configFile);
        YamlPropertySourceLoader sourceLoader = new YamlPropertySourceLoader();
        PropertySource<?> yamlTestProperties = sourceLoader.load("etcProperties", resource, context);
        applicationContext.getEnvironment().getPropertySources().addFirst(yamlTestProperties);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

}