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:com.aspc.cms.module.SyncResourceApp.java

@Override
public void handleCommandLine(CommandLine line) throws Exception {
    super.handleCommandLine(line);

    String tmpURL = (String) System.getProperties().get(PROPERTY_REMOTE_URL);

    if (StringUtilities.isBlank(tmpURL)) {
        throw new Exception("remote URL is mandatory");
    }//from w w w .  jav  a  2 s.  c o  m
    remoteURL = new URL(tmpURL);

    siteName = line.getOptionValue("s");
    if (StringUtilities.isBlank(siteName)) {
        throw new Exception("Site is mandatory");
    }

    String tmpDir = line.getOptionValue("d");

    syncDirectory = new File(tmpDir + "/" + siteName);

    syncDirectory.mkdirs();

    if (syncDirectory.isDirectory() == false) {
        throw new Exception("should be a directory: " + syncDirectory);
    }
}

From source file:com.moviejukebox.themoviedb.tools.WebBrowser.java

public static URLConnection openProxiedConnection(URL url) throws MovieDbException {
    try {//from  w  w  w.  j  ava2 s  . co m
        if (proxyHost != null) {
            System.getProperties().put("proxySet", "true");
            System.getProperties().put("proxyHost", proxyHost);
            System.getProperties().put("proxyPort", proxyPort);
        }

        URLConnection cnx = url.openConnection();

        if (proxyUsername != null) {
            cnx.setRequestProperty("Proxy-Authorization", proxyEncodedPassword);
        }

        return cnx;
    } catch (IOException ex) {
        throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, ex);
    }
}

From source file:de.awtools.config.SystemGlueConfig.java

@SuppressWarnings("unchecked")
public Iterator<String> getKeyIterator() {
    Iterator<String> unmodifiableIterator = (Iterator<String>) IteratorUtils
            .unmodifiableIterator(System.getProperties().keySet().iterator());
    return unmodifiableIterator;
}

From source file:ch.cyberduck.core.s3.S3MultipartCopyFeatureTest.java

@Test
public void testCopy() throws Exception {
    final Host host = new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(), new Credentials(
            System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")));
    final S3Session session = new S3Session(host);
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());

    final Path container = new Path("test-us-east-1-cyberduck",
            EnumSet.of(Path.Type.directory, Path.Type.volume));
    final Path test = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
    final byte[] content = new RandomStringGenerator.Builder().build().generate(1000).getBytes();
    final TransferStatus status = new TransferStatus().length(content.length);
    status.setChecksum(new SHA256ChecksumCompute().compute(new ByteArrayInputStream(content), status));
    final OutputStream out = new S3WriteFeature(session).write(test, status, new DisabledConnectionCallback());
    assertNotNull(out);/*from   w  w w .ja va  2s .c om*/
    new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content),
            out);
    out.close();
    test.attributes().setSize(content.length);
    final Path copy = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));

    final S3MultipartCopyFeature feature = new S3MultipartCopyFeature(session,
            new S3AccessControlListFeature(session));
    feature.copy(test, copy, status, new DisabledConnectionCallback());
    assertTrue(new S3FindFeature(session).find(test));
    assertEquals(content.length, new S3AttributesFinderFeature(session).find(test).getSize());
    new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(),
            new Delete.DisabledCallback());
    assertTrue(new S3FindFeature(session).find(copy));
    assertEquals(content.length, new S3AttributesFinderFeature(session).find(copy).getSize());
    new S3DefaultDeleteFeature(session).delete(Collections.singletonList(copy), new DisabledLoginCallback(),
            new Delete.DisabledCallback());
    session.close();
}

From source file:org.axiom_tools.services.ServiceTest.java

@Before
public void startServer() {
    String[] args = {};//www .ja  v  a 2  s.  c om
    getLogger().info("starting service tests");
    System.getProperties().put("spring.profiles.active", "direct");
    context = SpringApplication.run(ServiceController.class, args);
    assertFalse(getService() == null);
}

From source file:org.duracloud.mill.manifest.cleaner.ManifestCleanerDriver.java

@Override
protected void executeImpl(CommandLine cmd) {
    try {//from  www  .  j a  v a 2  s.  c o  m
        List<PropertyDefinition> defintions = new PropertyDefinitionListBuilder().addMillDb()
                .addManifestExpirationDate().build();
        PropertyVerifier verifier = new PropertyVerifier(defintions);
        verifier.verify(System.getProperties());
        String time = System.getProperty(ConfigConstants.MANIFEST_EXPIRATION_TIME);
        Date expirationDate;
        expirationDate = parseExpirationDate(time);
        new MillJpaPropertiesVerifier().verify();

        ApplicationContext context = new AnnotationConfigApplicationContext("org.duracloud.mill");
        log.info("spring context initialized.");
        ManifestStore store = context.getBean(ManifestStore.class);
        Long deleted = store.purgeDeletedItemsBefore(expirationDate);
        log.info("Deleted {} items that were flagged as deleted before {}", deleted, expirationDate);

    } catch (Exception e) {
        log.error(e.getMessage(), e);
    } finally {
        log.info("exiting...");
    }
}

From source file:ch.cyberduck.core.sftp.auth.SFTPPublicKeyAuthenticationTest.java

@Test
public void testAuthenticateKeyNoPassword() throws Exception {
    final Credentials credentials = new Credentials(System.getProperties().getProperty("sftp.user"));
    final Local key = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    try {/*from   w  ww. j  a  v  a2 s  . c om*/
        credentials.setIdentity(key);
        new DefaultLocalTouchFeature().touch(key);
        IOUtils.copy(new StringReader(System.getProperties().getProperty("sftp.key")),
                key.getOutputStream(false), Charset.forName("UTF-8"));
        final Host host = new Host(new SFTPProtocol(), "test.cyberduck.ch", credentials);
        final SFTPSession session = new SFTPSession(host);
        session.open(new DisabledHostKeyCallback());
        assertTrue(new SFTPPublicKeyAuthentication(session).authenticate(host, new DisabledPasswordStore(),
                new DisabledLoginCallback() {
                    @Override
                    public Credentials prompt(final Host bookmark, String username, String title, String reason,
                            LoginOptions options) throws LoginCanceledException {
                        fail();
                        throw new LoginCanceledException();
                    }
                }, new DisabledCancelCallback()));
        session.close();
    } finally {
        key.delete();
    }
}

From source file:org.cyclop.test.AbstractTestCase.java

private static void setupHistory() throws Exception {
    Path tempPath = FileSystems.getDefault().getPath("target", "cyclop-history-test");
    rmdir(tempPath);/*from  w  w w  .j av a 2  s  .  c o  m*/
    Files.createDirectory(tempPath);
    System.getProperties().setProperty("fileStore.folder", tempPath.toString());
}

From source file:io.apiman.common.config.SystemPropertiesConfiguration.java

/**
 * @see org.apache.commons.configuration.Configuration#getProperty(java.lang.String)
 *//*from   w  w  w  .  j  ava  2 s .co m*/
@Override
public Object getProperty(String key) {
    return System.getProperties().getProperty(key);
}

From source file:jp.go.nict.langrid.serviceexecutor.db.ConnectionManager.java

private void initWithJNDI(String jndiName) throws NamingException {
    this.dataSource = (DataSource) new InitialContext(System.getProperties()).lookup(jndiName);
}