Example usage for java.lang System getProperties

List of usage examples for java.lang System getProperties

Introduction

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

Prototype

public static Properties getProperties() 

Source Link

Document

Determines the current system properties.

Usage

From source file:org.apache.archiva.redback.common.jdo.UserConfigurableJdoFactory.java

private String getConfigString(String key, String currentValue, String defaultValue) {
    String valueFromSysProps = System.getProperty("redback." + key);
    if (StringUtils.isNotEmpty(valueFromSysProps)) {
        return valueFromSysProps;
    }//from w  w  w  . j  a  v  a 2s.co  m
    String value = null;
    if (StringUtils.isNotEmpty(currentValue)) {
        value = userConfiguration.getString(key, currentValue);
    } else {
        value = userConfiguration.getString(key, defaultValue);
    }
    // do some interpolation as we can have some ${plexus.home} etc...
    StringSearchInterpolator interpolator = new StringSearchInterpolator();
    interpolator.addValueSource(new PropertiesBasedValueSource(System.getProperties()));

    try {
        return interpolator.interpolate(value);
    } catch (InterpolationException e) {
        // ignore interpolation issue
        log.warn("skip issue during interpolation {}", e.getMessage());
        return value;
    }
}

From source file:com.photon.phresco.framework.actions.applications.SiteReport.java

public String checkForSiteReport() {
    S_LOGGER.debug("Entering Method  SiteReport.checkForSiteReport()");

    try {//  w  w w .  ja  v  a 2 s  .co  m
        Properties sysProps = System.getProperties();
        S_LOGGER.debug("Phresco FileServer Value of " + PHRESCO_FILE_SERVER_PORT_NO + " is "
                + sysProps.getProperty(PHRESCO_FILE_SERVER_PORT_NO));
        String phrescoFileServerNumber = sysProps.getProperty(PHRESCO_FILE_SERVER_PORT_NO);
        StringBuilder sb = new StringBuilder();
        StringBuilder siteReportPath = new StringBuilder(Utility.getProjectHome());
        siteReportPath.append(projectCode);
        siteReportPath.append(File.separatorChar);
        siteReportPath.append(SITE_TARGET);
        siteReportPath.append(File.separatorChar);
        siteReportPath.append(INDEX_HTML);
        File indexPath = new File(siteReportPath.toString());
        if (indexPath.isFile() && StringUtils.isNotEmpty(phrescoFileServerNumber)) {
            sb.append(HTTP_PROTOCOL);
            sb.append(PROTOCOL_POSTFIX);
            sb.append(LOCALHOST);
            sb.append(COLON);
            sb.append(phrescoFileServerNumber);
            sb.append(FORWARD_SLASH);
            sb.append(projectCode);
            sb.append(FORWARD_SLASH);
            sb.append(SITE_TARGET);
            sb.append(FORWARD_SLASH);
            sb.append(INDEX_HTML);
            getHttpRequest().setAttribute(REQ_SITE_REPORT_PATH, sb.toString());
        } else {
            getHttpRequest().setAttribute(REQ_ERROR, false);
        }
    } catch (Exception e) {
        S_LOGGER.error("Entered into catch block of SiteReport.checkForSiteReport()"
                + FrameworkUtil.getStackTraceAsString(e));
        new LogErrorReport(e, "Getting site report");
    }

    return APP_SITE_REPORT_VIEW;
}

From source file:ch.cyberduck.core.sds.SDSNodeIdProviderTest.java

@Test
public void getFileIdFile() throws Exception {
    final Host host = new Host(new SDSProtocol(), "duck.ssp-europe.eu", new Credentials(
            System.getProperties().getProperty("sds.user"), System.getProperties().getProperty("sds.key")));
    final SDSSession session = new SDSSession(host, new DisabledX509TrustManager(),
            new DefaultX509KeyManager());
    final LoginConnectionService service = new LoginConnectionService(new DisabledLoginCallback(),
            new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener());
    service.connect(session, PathCache.empty(), new DisabledCancelCallback());
    final Path bucket = new SDSDirectoryFeature(session)
            .mkdir(new Path(new AlphanumericRandomStringService().random(),
                    EnumSet.of(Path.Type.directory, Path.Type.volume)), null, new TransferStatus());
    final String name = new AlphanumericRandomStringService().random();
    final Path file = new SDSTouchFeature(session).touch(new Path(bucket, name, EnumSet.of(Path.Type.file)),
            new TransferStatus());
    assertNotNull(new SDSNodeIdProvider(session).getFileid(file, new DisabledListProgressListener()));
    try {// ww w  .ja  v  a  2 s.  co m
        assertNull(new SDSNodeIdProvider(session).getFileid(
                new Path(bucket, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)),
                new DisabledListProgressListener()));
        fail();
    } catch (NotfoundException e) {
        // Expected
    }
    try {
        assertNull(new SDSNodeIdProvider(session).getFileid(
                new Path(bucket, name, EnumSet.of(Path.Type.directory)), new DisabledListProgressListener()));
        fail();
    } catch (NotfoundException e) {
        // Expected
    }
    new SDSDeleteFeature(session).delete(Arrays.asList(file, bucket), new DisabledLoginCallback(),
            new Delete.DisabledCallback());
    session.close();
}

From source file:ch.cyberduck.core.cryptomator.B2LargeUploadWriteFeatureTest.java

@Test
public void testWrite() throws Exception {
    final B2Session session = new B2Session(new Host(new B2Protocol(), new B2Protocol().getDefaultHostname(),
            new Credentials(System.getProperties().getProperty("b2.user"),
                    System.getProperties().getProperty("b2.key"))));
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path container = new Path("test-cyberduck", EnumSet.of(Path.Type.volume, Path.Type.directory));
    final CryptoVault cryptomator = new CryptoVault(new Path(container,
            new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)),
            new DisabledPasswordStore());
    final Path vault = cryptomator.create(session, null, new VaultCredentials("test"));
    session.withRegistry(/*from   w  w  w.ja  v a  2  s. c  o  m*/
            new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final CryptoWriteFeature feature = new CryptoWriteFeature<VersionId>(session,
            new B2LargeUploadWriteFeature(session), cryptomator);
    final TransferStatus writeStatus = new TransferStatus();
    final Cryptor cryptor = cryptomator.getCryptor();
    final FileHeader header = cryptor.fileHeaderCryptor().create();
    writeStatus.setHeader(cryptor.fileHeaderCryptor().encryptHeader(header));
    writeStatus.setNonces(new RandomNonceGenerator());
    writeStatus.setLength(-1L);
    final Path test = new Path(vault, new AlphanumericRandomStringService().random(),
            EnumSet.of(Path.Type.file));
    final OutputStream out = feature.write(test, writeStatus, new DisabledConnectionCallback());
    final byte[] content = RandomUtils.nextBytes(6 * 1024 * 1024);
    final ByteArrayInputStream in = new ByteArrayInputStream(content);
    final TransferStatus progress = new TransferStatus();
    new StreamCopier(new TransferStatus(), progress).transfer(in, out);
    assertEquals(content.length, progress.getOffset());
    assertTrue(new CryptoFindFeature(session, new B2FindFeature(session), cryptomator).find(test));
    final byte[] compare = new byte[content.length];
    final InputStream stream = new CryptoReadFeature(session, new B2ReadFeature(session), cryptomator)
            .read(test, new TransferStatus().length(content.length), new DisabledConnectionCallback());
    IOUtils.readFully(stream, compare);
    stream.close();
    assertArrayEquals(content, compare);
    new CryptoDeleteFeature(session, new B2DeleteFeature(session), cryptomator)
            .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}

From source file:com.panet.imeta.core.logging.LogWriter.java

public static final LogWriter getInstance() {
    if (logWriter != null)
        return logWriter;

    String logLevel = (String) System.getProperties().get(Props.STRING_LOG_LEVEL);
    return getInstance(getLogLevel(logLevel));
}

From source file:ch.cyberduck.core.sds.triplecrypt.CryptoWriteFeatureTest.java

@Test
public void testWrite() throws Exception {
    final Host host = new Host(new SDSProtocol(), "duck.ssp-europe.eu", new Credentials(
            System.getProperties().getProperty("sds.user"), System.getProperties().getProperty("sds.key")));
    final SDSSession session = new SDSSession(host, new DisabledX509TrustManager(),
            new DefaultX509KeyManager());
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path room = new Path("CD-TEST-ENCRYPTED",
            EnumSet.of(Path.Type.directory, Path.Type.volume, Path.Type.vault));
    final byte[] content = RandomUtils.nextBytes(32769);
    final TransferStatus status = new TransferStatus();
    status.setLength(content.length);//from   www  .  j  ava 2 s  .  c o m
    final Path test = new Path(room, UUID.randomUUID().toString(),
            EnumSet.of(Path.Type.file, Path.Type.decrypted));
    final SDSEncryptionBulkFeature bulk = new SDSEncryptionBulkFeature(session);
    bulk.pre(Transfer.Type.upload, Collections.singletonMap(test, status), new DisabledConnectionCallback());
    final CryptoWriteFeature writer = new CryptoWriteFeature(session, new SDSWriteFeature(session));
    final StatusOutputStream<VersionId> out = writer.write(test, status, new DisabledConnectionCallback());
    assertNotNull(out);
    new StreamCopier(status, status).transfer(new ByteArrayInputStream(content), out);
    final VersionId version = out.getStatus();
    assertNotNull(version);
    assertTrue(new DefaultFindFeature(session).find(test));
    assertEquals(content.length, new SDSAttributesFinderFeature(session).find(test).getSize());
    final byte[] compare = new byte[content.length];
    final InputStream stream = new CryptoReadFeature(session, new SDSReadFeature(session)).read(test,
            new TransferStatus(), new ConnectionCallback() {
                @Override
                public void warn(final Host bookmark, final String title, final String message,
                        final String defaultButton, final String cancelButton, final String preference)
                        throws ConnectionCanceledException {
                    //
                }

                @Override
                public Credentials prompt(final Host bookmark, final String title, final String reason,
                        final LoginOptions options) throws LoginCanceledException {
                    return new VaultCredentials("ahbic3Ae");
                }
            });
    IOUtils.readFully(stream, compare);
    stream.close();
    assertArrayEquals(content, compare);
    new SDSDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(),
            new Delete.DisabledCallback());
    session.close();
}

From source file:com.nesscomputing.config.SystemOverrideTest.java

@Test
public void loadStringValues() {
    Assert.assertThat(cfg, is(notNullValue()));
    final Configuration config = cfg.getConfiguration();

    Assert.assertThat(config, is(notNullValue()));

    Assert.assertThat(System.getProperty("string-value"), is("OVERRIDDEN"));
    Assert.assertThat(System.getProperties().getProperty("string-value"), is("OVERRIDDEN"));

    final String s_cfg2 = config.getString("string-value");
    Assert.assertThat(s_cfg2, is("OVERRIDDEN"));
}

From source file:ch.cyberduck.core.dav.DAVUploadFeatureTest.java

@Test(expected = AccessDeniedException.class)
public void testAccessDenied() throws Exception {
    final Host host = new Host(new DAVProtocol(), "test.cyberduck.ch",
            new Credentials(System.getProperties().getProperty("webdav.user"),
                    System.getProperties().getProperty("webdav.password")));
    host.setDefaultPath("/dav/basic");
    final DAVSession session = new DAVSession(host);
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final TransferStatus status = new TransferStatus();
    final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    new DefaultLocalTouchFeature().touch(local);
    final Path test = new Path(new Path("/dav/accessdenied", EnumSet.of(Path.Type.directory)), "nosuchname",
            EnumSet.of(Path.Type.file));
    try {/*w w w.j a va 2  s .  c om*/
        new DAVUploadFeature(new DAVWriteFeature(session)).upload(test, local,
                new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status,
                new DisabledConnectionCallback());
    } catch (AccessDeniedException e) {
        assertEquals(
                "Unexpected response (403 Forbidden). Please contact your web hosting service provider for assistance.",
                e.getDetail());
        throw e;
    } finally {
        local.delete();
        session.close();
    }
}

From source file:org.jmxtrans.embedded.util.json.PlaceholderEnabledJsonNodeFactoryTest.java

@Test
public void testWithPlaceholders() throws Exception {
    System.setProperty("graphite.host", "graphite.www.private.mycompany.com");
    System.setProperty("server.name", "tomcat1");
    try {//  www  .  j av  a  2s .c  o  m
        String configurationUrl = "org/jmxtrans/embedded/util/json/jmxtrans-placeholder-test.json";
        InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(configurationUrl);
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.setNodeFactory(new PlaceholderEnabledJsonNodeFactory());
        JsonNode rootNode = objectMapper.readValue(in, JsonNode.class);
        JsonNode outputWritersNode = rootNode.path("outputWriters");
        JsonNode outputWriterNode = outputWritersNode.get(1);
        assertThat(outputWriterNode.path("@class").asText(), is("org.jmxtrans.embedded.output.GraphiteWriter"));
        JsonNode settingsNode = outputWriterNode.path("settings");
        assertThat(settingsNode.path("host").asText(), is("graphite.www.private.mycompany.com"));
        assertThat(settingsNode.path("port").asInt(), is(2003));
        assertThat(settingsNode.path("namePrefix").asText(), is("servers.tomcat1."));

    } finally {
        System.getProperties().remove("graphite.host");
        System.getProperties().remove("server.name");
    }
}

From source file:com.qwazr.server.configuration.ServerConfiguration.java

public ServerConfiguration(final String... args) throws IOException {
    this(System.getenv(), System.getProperties(), argsToMap(args));
}