List of usage examples for java.util Properties put
@Override public synchronized Object put(Object key, Object value)
From source file:de.huberlin.german.korpling.laudatioteitool.App.java
private static void fillPropertiesFromCommandLine(Properties props, CommandLine cmd) { for (Object o : cmd.getOptions()) { Option opt = (Option) o; String name = opt.getOpt(); if (cmd.hasOption(opt.getOpt())) { String value = cmd.getOptionValue(name); props.put(name, value); log.debug(messages.getString("SETTING OPTION FROM CMD"), name, value); }//from w w w . j ava2 s. c om } }
From source file:com.flexive.shared.FxMailUtils.java
/** * Sends an email//from w w w. j a v a2s .com * * @param SMTPServer IP Address of the SMTP server * @param subject subject of the email * @param textBody plain text * @param htmlBody html text * @param to recipient * @param cc cc recepient * @param bcc bcc recipient * @param from sender * @param replyTo reply-to address * @param mimeAttachments strings containing mime encoded attachments * @throws FxApplicationException on errors */ public static void sendMail(String SMTPServer, String subject, String textBody, String htmlBody, String to, String cc, String bcc, String from, String replyTo, String... mimeAttachments) throws FxApplicationException { try { // Set the mail server java.util.Properties properties = System.getProperties(); if (SMTPServer != null) properties.put("mail.smtp.host", SMTPServer); // Get a session and create a new message javax.mail.Session session = javax.mail.Session.getInstance(properties, null); MimeMessage msg = new MimeMessage(session); // Set the sender if (StringUtils.isBlank(from)) msg.setFrom(); // Uses local IP Adress and the user under which the server is running else { msg.setFrom(createAddress(from)); } if (!StringUtils.isBlank(replyTo)) msg.setReplyTo(encodePersonal(InternetAddress.parse(replyTo, false))); // Set the To, Cc and Bcc fields if (!StringUtils.isBlank(to)) msg.setRecipients(MimeMessage.RecipientType.TO, encodePersonal(InternetAddress.parse(to, false))); if (!StringUtils.isBlank(cc)) msg.setRecipients(MimeMessage.RecipientType.CC, encodePersonal(InternetAddress.parse(cc, false))); if (!StringUtils.isBlank(bcc)) msg.setRecipients(MimeMessage.RecipientType.BCC, encodePersonal(InternetAddress.parse(bcc, false))); // Set the subject msg.setSubject(subject, "UTF-8"); String sMainType = "Multipart/Alternative;\n\tboundary=\"" + BOUNDARY1 + "\""; StringBuilder body = new StringBuilder(5000); if (mimeAttachments.length > 0) { sMainType = "Multipart/Mixed;\n\tboundary=\"" + BOUNDARY2 + "\""; body.append("This is a multi-part message in MIME format.\n\n"); body.append("--" + BOUNDARY2 + "\n"); body.append("Content-Type: Multipart/Alternative;\n\tboundary=\"" + BOUNDARY1 + "\"\n\n\n"); } if (textBody.length() > 0) { body.append("--" + BOUNDARY1 + "\n"); body.append("Content-Type: text/plain; charset=\"UTF-8\"\n"); body.append("Content-Transfer-Encoding: quoted-printable\n\n"); body.append(encodeQuotedPrintable(textBody)).append("\n"); } if (htmlBody.length() > 0) { body.append("--" + BOUNDARY1 + "\n"); body.append("Content-Type: text/html;\n\tcharset=\"UTF-8\"\n"); body.append("Content-Transfer-Encoding: quoted-printable\n\n"); if (htmlBody.toLowerCase().indexOf("<html>") < 0) { body.append("<HTML><HEAD>\n<TITLE></TITLE>\n"); body.append( "<META http-equiv=3DContent-Type content=3D\"text/html; charset=3Dutf-8\"></HEAD>\n<BODY>\n"); body.append(encodeQuotedPrintable(htmlBody)).append("</BODY></HTML>\n"); } else body.append(encodeQuotedPrintable(htmlBody)).append("\n"); } body.append("\n--" + BOUNDARY1 + "--\n"); if (mimeAttachments.length > 0) { for (String mimeAttachment : mimeAttachments) { body.append("\n--" + BOUNDARY2 + "\n"); body.append(mimeAttachment).append("\n"); } body.append("\n--" + BOUNDARY2 + "--\n"); } msg.setDataHandler( new javax.activation.DataHandler(new ByteArrayDataSource(body.toString(), sMainType))); // Set the header msg.setHeader("X-Mailer", "JavaMailer"); // Set the sent date msg.setSentDate(new java.util.Date()); // Send the message javax.mail.Transport.send(msg); } catch (AddressException e) { throw new FxApplicationException(e, "ex.messaging.mail.address", e.getRef()); } catch (javax.mail.MessagingException e) { throw new FxApplicationException(e, "ex.messaging.mail.send", e.getMessage()); } catch (IOException e) { throw new FxApplicationException(e, "ex.messaging.mail.send", e.getMessage()); } catch (EncoderException e) { throw new FxApplicationException(e, "ex.messaging.mail.send", e.getMessage()); } }
From source file:com.krawler.database.DbPool.java
private static Properties getKrawlerDbProps() { Properties props = new Properties(); props.put("cacheResultSetMetadata", "true"); props.put("cachePrepStmts", "true"); props.put("prepStmtCacheSize", "25"); props.put("autoReconnect", "true"); props.put("useUnicode", "true"); props.put("characterEncoding", "UTF-8"); props.put("dumpQueriesOnException", "true"); String user = ConfigReader.getinstance().get("mysql_user", "root"); String pwd = ConfigReader.getinstance().get("mysql_passwd", "root"); props.put("user", user); props.put("password", pwd); return props; }
From source file:io.druid.query.extraction.namespace.TestKafkaExtractionCluster.java
private static final Properties makeProducerProperties() { final Properties kafkaProducerProperties = new Properties(); kafkaProducerProperties.putAll(kafkaProperties); kafkaProducerProperties.put("metadata.broker.list", String.format("127.0.0.1:%d", kafkaServer.socketServer().port())); kafkaProperties.put("request.required.acks", "1"); return kafkaProducerProperties; }
From source file:info.magnolia.importexport.PropertiesImportExport.java
private static void addDateProperty(Properties out, String path, Calendar date) { if (date != null) { out.put(path, convertCalendarToExportString(date)); }//from w ww.ja va 2 s .c o m }
From source file:com.haulmont.cuba.core.entity.LocaleHelper.java
public static String convertFromSimpleKeyLocales(String enumValue, String localeBundle) { Properties result = new Properties(); Properties properties = loadProperties(localeBundle); if (properties != null) { for (Map.Entry<Object, Object> entry : properties.entrySet()) { String key = (String) entry.getKey(); result.put(key + "/" + enumValue, entry.getValue()); }//from w ww . j av a2s .co m } return convertPropertiesToString(result); }
From source file:ws.argo.DemoWebClient.Browser.BrowserController.java
private static void setDefaultProbeSenderProperties(Properties props) { props.put("multicastPort", DEFAULT_MULTICAST_PORT); props.put("multicastGroupAddr", DEFAULT_MULTICAST_GROUP_ADDR); props.put("listenerIPAddress", ""); props.put("listenerURLPath", DEFAULT_PROBE_RESPONSE_URL_PATH); }
From source file:com.googlecode.gmail4j.javamail.ImapGmailConnection.java
public static IMAPStore connectToImap(String host, int port, String userEmail, String oauthToken, boolean debug) throws Exception { Properties props = new Properties(); props.put("mail.imaps.sasl.enable", "true"); props.put("mail.imaps.sasl.mechanisms", "XOAUTH2"); props.put(OAuth2SaslClientFactory.OAUTH_TOKEN_PROP, oauthToken); Session session = Session.getInstance(props); session.setDebug(debug);/*from www . j av a 2 s . c om*/ final URLName unusedUrlName = null; IMAPSSLStore store = new IMAPSSLStore(session, unusedUrlName); final String emptyPassword = ""; store.connect(host, port, userEmail, emptyPassword); return store; }
From source file:frameworkcontentspeed.Utils.SendEmailAtachament.java
public static void SendEmailSephoraFailed(String adresaSephora, String from, String to1, String to2, String grupSephora, String subject, String filename) throws FileNotFoundException, IOException { Properties props = new Properties(); props.put("mail.smtp.host", "smtp.gmail.com"); props.put("mail.smtp.socketFactory.port", "465"); props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.port", "465"); //get Session Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(from, "anda.cristea"); }// www .j a v a 2 s. c om }); //compose message try { MimeMessage message = new MimeMessage(session); message.addRecipient(Message.RecipientType.TO, new InternetAddress(to1)); message.setSubject(subject); // message.setText(msg); BodyPart messageBodyPart = new MimeBodyPart(); messageBodyPart.setText("Raport teste automate"); Multipart multipart = new MimeMultipart(); multipart.addBodyPart(messageBodyPart); messageBodyPart = new MimeBodyPart(); DataSource source = new FileDataSource(filename); messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setFileName(filename); multipart.addBodyPart(messageBodyPart); message.setContent(multipart); //send message Transport.send(message); } catch (MessagingException e) { throw new RuntimeException(e); } }
From source file:frameworkcontentspeed.Utils.SendEmailAtachament.java
public static void SendEmailSephoraPassed(String adresaSephora, String from, String grupTestContent, String grupSephora, String subject, String filename) throws FileNotFoundException, IOException { //Get properties object Properties props = new Properties(); props.put("mail.smtp.host", "smtp.gmail.com"); props.put("mail.smtp.socketFactory.port", "465"); props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.port", "465"); //get Session Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(from, "anda.cristea"); }//from ww w .j a v a 2 s . c o m }); //compose message try { MimeMessage message = new MimeMessage(session); message.addRecipient(Message.RecipientType.TO, new InternetAddress(grupTestContent)); message.addRecipient(Message.RecipientType.BCC, new InternetAddress(grupSephora)); message.setSubject(subject); // message.setText(msg); BodyPart messageBodyPart = new MimeBodyPart(); messageBodyPart.setText("Raport teste automate"); Multipart multipart = new MimeMultipart(); multipart.addBodyPart(messageBodyPart); messageBodyPart = new MimeBodyPart(); DataSource source = new FileDataSource(filename); messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setFileName(filename); multipart.addBodyPart(messageBodyPart); message.setContent(multipart); //send message Transport.send(message); // System.out.println("message sent successfully"); } catch (Exception ex) { System.out.println("eroare trimitere email-uri"); System.out.println(ex.getMessage()); } }