Package com.socrata.datasync.config.userpreferences

Examples of com.socrata.datasync.config.userpreferences.UserPreferences


    @Test
    public void testConfiguration() throws ParseException {
        String[] args = {"-c", "src/test/resources/basic_test_config.json"};
        job.configure(parser.parse(cmd.options, args));

        UserPreferences userPrefs = job.getUserPrefs();

        TestCase.assertEquals("https://sandbox.demo.socrata.com", userPrefs.getDomain());
        TestCase.assertEquals("testuser@gmail.com", userPrefs.getUsername());
        TestCase.assertEquals("OpenData", userPrefs.getPassword());
        TestCase.assertEquals("D8Atrg62F2j017ZTdkMpuZ9vY", userPrefs.getAPIKey());
        TestCase.assertEquals("admin@something.com", userPrefs.getAdminEmail());
        TestCase.assertFalse(userPrefs.emailUponError());
        TestCase.assertEquals("smtp.something.com", userPrefs.getOutgoingMailServer());
        TestCase.assertEquals("21", userPrefs.getSmtpPort());
        TestCase.assertEquals("47", userPrefs.getSslPort());
        TestCase.assertEquals("test@something.com", userPrefs.getSmtpUsername());
        TestCase.assertEquals("smtppass", userPrefs.getSmtpPassword());
        TestCase.assertEquals("10", userPrefs.getFilesizeChunkingCutoffMB());
        TestCase.assertEquals("10000", userPrefs.getNumRowsPerChunk());
    }
View Full Code Here


            sinkSetIDTextField.setEditable(true);
            jobPanel.add(publishMethodContainerLeft);
            jobPanel.add(publishMethodContainerRight);
            publishMethodComboBox.setEnabled(true);
        }
        UserPreferences userPrefs = new UserPreferencesJava();
        SocrataConnectionInfo connectionInfo = userPrefs.getConnectionInfo();
        if (job.getSourceSiteDomain().equals("https://") &&
                !connectionInfo.getUrl().equals("https://")) {
            sourceSiteDomainTextField.setText(connectionInfo.getUrl());
        } else {
            sourceSiteDomainTextField.setText(job.getSourceSiteDomain());
View Full Code Here

     * @throws MessagingException if the connection is dead or not in the connected state
     *                  or if the message is not a MimeMessage
     */
    public static void send(String recipientEmail, String ccEmail, String title, String message)
        throws AddressException, MessagingException {
      UserPreferences userPrefs = new UserPreferencesJava();
     
        //Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
        final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";

        // Get a Properties object
        Properties props = System.getProperties();
        props.setProperty("mail.smtps.host", userPrefs.getOutgoingMailServer());
        props.setProperty("mail.smtp.socketFactory.fallback", "false");
        props.setProperty("mail.smtp.port", userPrefs.getSmtpPort());
        String sslPort = userPrefs.getSslPort();

        boolean useSSL = !(sslPort.equals(""));


        if(useSSL) {

          props.setProperty("mail.smtp.socketFactory.class", SSL_FACTORY);
           props.setProperty("mail.smtp.socketFactory.port", sslPort);
              props.setProperty("mail.smtps.auth", "true");
            /*
        If set to false, the QUIT command is sent and the connection is immediately closed. If set
        to true (the default), causes the transport to wait for the response to the QUIT command.

        ref :   http://java.sun.com/products/javamail/javadocs/com/sun/mail/smtp/package-summary.html
                http://forum.java.sun.com/thread.jspa?threadID=5205249
                smtpsend.java - demo program from javamail
        */
              props.put("mail.smtps.quitwait", "false");
        }

        Session session = Session.getInstance(props, null);

        // -- Create a new message --
        final MimeMessage msg = new MimeMessage(session);

        // -- Set the FROM and TO fields --
        msg.setFrom(new InternetAddress(userPrefs.getSmtpUsername()));
        msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipientEmail, false));

        if (ccEmail.length() > 0) {
            msg.setRecipients(Message.RecipientType.CC, InternetAddress.parse(ccEmail, false));
        }

        msg.setSubject(title);
        msg.setText(message, "utf-8");
        msg.setSentDate(new Date());


        SMTPTransport t = (SMTPTransport)session.getTransport("smtp");
        if (useSSL)
            t = (SMTPTransport)session.getTransport("smtps");
       
        t.connect(userPrefs.getOutgoingMailServer(), userPrefs.getSmtpUsername(), userPrefs.getSmtpPassword());
        t.sendMessage(msg, msg.getAllRecipients());     
        t.close();
    }
View Full Code Here

        // generate & run job from command line args
            checkVersion();

            CommandLineOptions options = new CommandLineOptions();
            CommandLine cmd = options.getCommandLine(args);
            UserPreferences userPrefs = null;
            try {
                userPrefs = loadUserPreferences(options, cmd);
            } catch (IOException e) {
                System.err.println("Failed to load configuration: " + e.toString());
                System.exit(1);
View Full Code Here

     * @param cmd
     * @return UserPreferences object containing global preferences
     * @throws IOException
     */
    private static UserPreferences loadUserPreferences(CommandLineOptions options, CommandLine cmd) throws IOException {
        UserPreferences userPrefs;
        if (cmd.getOptionValue(options.CONFIG_FLAG) != null) {
            // load user preferences from given JSON config file
            File configFile = new File(cmd.getOptionValue("config"));
            ObjectMapper mapper = new ObjectMapper();
            userPrefs = mapper.readValue(configFile, UserPreferencesFile.class);
            String proxyUsername = cmd.getOptionValue(options.PROXY_USERNAME_FLAG);
            String proxyPassword = cmd.getOptionValue(options.PROXY_PASSWORD_FLAG);
            String jobType = cmd.getOptionValue(options.JOB_TYPE_FLAG, options.DEFAULT_JOBTYPE);
            if (proxyUsername != null && proxyPassword != null && !jobType.equals(Jobs.LOAD_PREFERENCES_JOB.toString())) {
                userPrefs.setProxyUsername(proxyUsername);
                userPrefs.setProxyPassword(proxyPassword);
            }
        } else {
            // load user preferences from Java preferences class
            userPrefs = new UserPreferencesJava();
        }
View Full Code Here

    }

    @Test
    public void tesGetFTPHost() throws URISyntaxException, IOException {
        ObjectMapper mapper = new ObjectMapper();
        UserPreferences userPrefs1 = mapper.readValue("{\"domain\": \"https://sandbox.demo.socrata.com\"}",
                UserPreferencesFile.class);
        UserPreferences userPrefs2 = mapper.readValue("{\"domain\": \"https://adrian.demo.socrata.com\"}",
                UserPreferencesFile.class);
        UserPreferences userPrefs3 = mapper.readValue("{\"domain\": \"https://opendata.test-socrata.com\"}",
                UserPreferencesFile.class);
        TestCase.assertEquals("production.ftp.socrata.net",
                FTPDropbox2Publisher.getFTPHost(userPrefs1));
        TestCase.assertEquals("production.ftp.socrata.net",
                FTPDropbox2Publisher.getFTPHost(userPrefs2));
View Full Code Here

    @Test
    public void testReplaceViaFTPWithHeaderRow() throws IOException, SodaError, InterruptedException, LongRunningQueryException {
        final SodaDdl ddl = createSodaDdl();
        final Soda2Producer producer = createProducer();
        final UserPreferences userPrefs = getUserPrefs();

        // Ensures dataset is in known state (2 rows)
        File twoRowsFile = new File("src/test/resources/datasync_unit_test_two_rows.csv");
        Soda2Publisher.replaceNew(producer, ddl, UNITTEST_DATASET_ID, twoRowsFile, true);
View Full Code Here

    @Test
    public void testReplaceViaFTPWithControlFile() throws IOException, SodaError, InterruptedException, LongRunningQueryException {
        final SodaDdl ddl = createSodaDdl();
        final Soda2Producer producer = createProducer();
        final UserPreferences userPrefs = getUserPrefs();

        // Ensures dataset is in known state (2 rows)
        File twoRowsFile = new File("src/test/resources/datasync_unit_test_two_rows.csv");
        Soda2Publisher.replaceNew(producer, ddl, UNITTEST_DATASET_ID, twoRowsFile, true);
View Full Code Here

    @Test
    public void testReplaceViaFTPWithoutHeader() throws IOException, SodaError, InterruptedException, LongRunningQueryException {
        final SodaDdl ddl = createSodaDdl();
        final Soda2Producer producer = createProducer();
        final UserPreferences userPrefs = getUserPrefs();

        // Ensures dataset is in known state (2 rows)
        File twoRowsFile = new File("src/test/resources/datasync_unit_test_two_rows.csv");
        Soda2Publisher.replaceNew(producer, ddl, UNITTEST_DATASET_ID, twoRowsFile, true);
View Full Code Here

    @Test
    public void testReplaceViaFTPWithInvalidData() throws IOException, SodaError, InterruptedException, LongRunningQueryException {
        final SodaDdl ddl = createSodaDdl();
        final Soda2Producer producer = createProducer();
        final UserPreferences userPrefs = getUserPrefs();

        // Ensures dataset is in known state (2 rows)
        File twoRowsFile = new File("src/test/resources/datasync_unit_test_two_rows.csv");
        Soda2Publisher.replaceNew(producer, ddl, UNITTEST_DATASET_ID, twoRowsFile, true);
View Full Code Here

TOP

Related Classes of com.socrata.datasync.config.userpreferences.UserPreferences

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.