Package com.socrata.datasync.config.userpreferences

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


    }

    @Test
    public void testLoadIncompletePreferencesWithMessyStart() throws ParseException, BackingStoreException {
        // fill up java preference node with old junk
        UserPreferencesJava userPrefs = new UserPreferencesJava();
        String[] argsOld = {"-t", "LoadPreferences", "-c", "src/test/resources/basic_test_config.json"};
        Main.main(argsOld);

        // run new load job
        String[] argsNew = {"-t", "LoadPreferences", "-c", "src/test/resources/simple_config.json"};
        Main.main(argsNew);

        TestCase.assertEquals("https://someDomain.com", userPrefs.getDomain());
        TestCase.assertEquals("some.user@gmail.com", userPrefs.getUsername());
        TestCase.assertEquals("somePassword", userPrefs.getPassword());
        TestCase.assertEquals("5oMeTokEN", userPrefs.getAPIKey());
        TestCase.assertEquals("https://someDomain.com", userPrefs.getProxyHost());
        TestCase.assertEquals("8080", userPrefs.getProxyPort());
        TestCase.assertEquals("", userPrefs.getAdminEmail());
        TestCase.assertFalse(userPrefs.emailUponError());    // has default
        TestCase.assertEquals("", userPrefs.getLogDatasetID());
        TestCase.assertEquals("", userPrefs.getOutgoingMailServer());
        TestCase.assertEquals("", userPrefs.getSmtpPort());
        TestCase.assertEquals("465", userPrefs.getSslPort());    // has default
        TestCase.assertEquals("", userPrefs.getSmtpUsername());
        TestCase.assertEquals("", userPrefs.getSmtpPassword());
        TestCase.assertEquals("10", userPrefs.getFilesizeChunkingCutoffMB());     // has default
        TestCase.assertEquals("10000", userPrefs.getNumRowsPerChunk());     // has default
    }
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

    private ObjectMapper controlFileMapper =
            new ObjectMapper().enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);

    public IntegrationJob() {
        userPrefs = new UserPreferencesJava();
  }
View Full Code Here

   * Loads integration job data from a file and
   * uses the saved data to populate the fields
   * of this object
   */
  public IntegrationJob(String pathToFile) throws IOException {
        userPrefs = new UserPreferencesJava();
        // first try reading the 'current' format
        ObjectMapper mapper = new ObjectMapper();
        try {
            IntegrationJob loadedJob = mapper.readValue(new File(pathToFile), IntegrationJob.class);
            setDatasetID(loadedJob.getDatasetID());
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

                userPrefs.setProxyUsername(proxyUsername);
                userPrefs.setProxyPassword(proxyPassword);
            }
        } else {
            // load user preferences from Java preferences class
            userPrefs = new UserPreferencesJava();
        }
        return userPrefs;
    }
View Full Code Here

TOP

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

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.