List of usage examples for java.util Properties put
@Override public synchronized Object put(Object key, Object value)
From source file:com.esri.geoportal.commons.pdf.PdfUtils.java
/** * Generates the list of "PARAMETER" entries in the WKT. * /* w w w . j a v a2s.c o m*/ * @param projectionDictionary the GeoPDF projection dictionary * * @returns string of WKT parameters */ private static String generateWKTParameters(COSDictionary projectionDictionary) throws IOException { // Set up the projection parameters Properties parameters = new Properties(); COSDictionaryMap<String, Object> dictionaryMap = COSDictionaryMap .convertBasicTypesToMap(projectionDictionary); if (projectionDictionary.containsKey("CentralMeridian")) { parameters.put("Central_Meridian", (String) dictionaryMap.get("CentralMeridian")); } if (projectionDictionary.containsKey("OriginLatitude")) { parameters.put("Latitude_Of_Origin", (String) dictionaryMap.get("OriginLatitude")); } if (projectionDictionary.containsKey("StandardParallelOne")) { parameters.put("Standard_Parallel_1", (String) dictionaryMap.get("StandardParallelOne")); } if (projectionDictionary.containsKey("StandardParallelTwo")) { parameters.put("Standard_Parallel_2", (String) dictionaryMap.get("StandardParallelTwo")); } if (projectionDictionary.containsKey("FalseEasting")) { parameters.put("False_Easting", (String) dictionaryMap.get("FalseEasting")); } if (projectionDictionary.containsKey("FalseNorthing")) { parameters.put("False_Northing", (String) dictionaryMap.get("FalseNorthing")); } if (projectionDictionary.containsKey("ScaleFactor")) { parameters.put("Scale_Factor", (String) dictionaryMap.get("ScaleFactor")); } return parameters.entrySet().stream() .map(entry -> "PARAMETER[\"" + entry.getKey() + "\", " + entry.getValue() + "]") .collect(Collectors.joining(",")); }
From source file:com.emc.kibana.emailer.KibanaEmailer.java
private static void sendFileEmail(String security) { final String username = smtpUsername; final String password = smtpPassword; // Get system properties Properties properties = System.getProperties(); // Setup mail server properties.setProperty("mail.smtp.host", smtpHost); if (security.equals(SMTP_SECURITY_TLS)) { properties.put("mail.smtp.auth", "true"); properties.put("mail.smtp.starttls.enable", "true"); properties.put("mail.smtp.host", smtpHost); properties.put("mail.smtp.port", smtpPort); } else if (security.equals(SMTP_SECURITY_SSL)) { properties.put("mail.smtp.socketFactory.port", smtpPort); properties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); properties.put("mail.smtp.auth", "true"); properties.put("mail.smtp.port", smtpPort); }//from ww w.jav a 2 s. c o m Session session = Session.getInstance(properties, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); } }); try { // Create a default MimeMessage object. MimeMessage message = new MimeMessage(session); // Set From: header field of the header. message.setFrom(new InternetAddress(sourceAddress)); // Set To: header field of the header. for (String destinationAddress : destinationAddressList) { message.addRecipient(Message.RecipientType.TO, new InternetAddress(destinationAddress)); } // Set Subject: header field message.setSubject(mailTitle); // Create the message part BodyPart messageBodyPart = new MimeBodyPart(); StringBuffer bodyBuffer = new StringBuffer(mailBody); if (!kibanaUrls.isEmpty()) { bodyBuffer.append("\n\n"); } // Add urls info to e-mail for (Map<String, String> kibanaUrl : kibanaUrls) { // Add urls to e-mail String urlName = kibanaUrl.get(NAME_KEY); String reportUrl = kibanaUrl.get(URL_KEY); if (urlName != null && reportUrl != null) { bodyBuffer.append("- ").append(urlName).append(": ").append(reportUrl).append("\n\n\n"); } } // Fill the message messageBodyPart.setText(bodyBuffer.toString()); // Create a multipart message Multipart multipart = new MimeMultipart(); // Set text message part multipart.addBodyPart(messageBodyPart); // Part two is attachments for (Map<String, String> kibanaScreenCapture : kibanaScreenCaptures) { messageBodyPart = new MimeBodyPart(); String absoluteFilename = kibanaScreenCapture.get(ABSOLUE_FILE_NAME_KEY); String filename = kibanaScreenCapture.get(FILE_NAME_KEY); DataSource source = new FileDataSource(absoluteFilename); messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setFileName(filename); multipart.addBodyPart(messageBodyPart); } // Send the complete message parts message.setContent(multipart); // Send message Transport.send(message); logger.info("Sent mail message successfully"); } catch (MessagingException mex) { throw new RuntimeException(mex); } }
From source file:fr.paris.lutece.portal.service.mail.MailUtil.java
/** * Open mail session with the SMTP server using the given credentials. Will * use no authentication if strUsername is null or blank. * * @param strHost The SMTP name or IP address. * @param nPort The port to use//from www . j a va 2 s . c om * @param strUsername the username * @param strPassword the password * @return the mails session object */ protected static Session getMailSession(String strHost, int nPort, final String strUsername, final String strPassword) { String strDebug = AppPropertiesService.getProperty(PROPERTY_MAIL_SESSION_DEBUG, Boolean.FALSE.toString()); boolean bSessionDebug = Boolean.parseBoolean(strDebug); // Initializes a mail session with the SMTP server Properties props = System.getProperties(); props.put(MAIL_HOST, strHost); props.put(MAIL_TRANSPORT_PROTOCOL, SMTP); props.put(MAIL_PROPTOCOL_HOST, strHost); props.put(MAIL_PROPTOCOL_PORT, nPort); Authenticator auth; if (StringUtils.isNotBlank(strUsername)) { props.put(MAIL_SMTP_AUTH, TRUE); // using authenticator class that return a PasswordAuthentication auth = new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(strUsername, strPassword); } }; } else { // no authentication data provided, no authenticator auth = null; } Session mailSession = Session.getDefaultInstance(props, auth); // Activate debugging mailSession.setDebug(bSessionDebug); return mailSession; }
From source file:com.itcs.commons.email.EmailAutoconfigClient.java
public static Properties generateEmailProperties(Map<String, String> settings) { Properties props = new Properties(); if (!StringUtils.isEmpty(settings.get(EnumEmailSettingKeys.MAIL_DEBUG.getKey()))) { if (Boolean.parseBoolean(settings.get(EnumEmailSettingKeys.MAIL_DEBUG.getKey()))) { props.put(MAIL_DEBUG, "true"); }/*from w ww. j a v a 2s . co m*/ } if (settings.get(EnumEmailSettingKeys.STORE_PROTOCOL.getKey()).equalsIgnoreCase("imaps") || settings.get(EnumEmailSettingKeys.STORE_PROTOCOL.getKey()).equalsIgnoreCase("imap") || settings.get(EnumEmailSettingKeys.STORE_PROTOCOL.getKey()).equalsIgnoreCase("pop3s")) { String baseProtocol = MAIL; if (settings.get(EnumEmailSettingKeys.STORE_PROTOCOL.getKey()).equalsIgnoreCase("imaps")) { baseProtocol += PROTOCOL_IMAPS; } else if (settings.get(EnumEmailSettingKeys.STORE_PROTOCOL.getKey()).equalsIgnoreCase("imap")) { baseProtocol += PROTOCOL_IMAP; } else if (settings.get(EnumEmailSettingKeys.STORE_PROTOCOL.getKey()).equalsIgnoreCase("pop3s")) { baseProtocol += PROTOCOL_POP3S; } props.put(baseProtocol + MAIL_PROTOCOL_CONNECTIONTIMEOUT, DEFAULT_CONN_TIMEOUT); props.put(baseProtocol + MAIL_PROTOCOL_TIMEOUT, DEFAULT_IO_TIMEOUT); if (settings.containsKey(EnumEmailSettingKeys.INBOUND_SERVER.getKey()) && StringUtils.isNotEmpty(settings.get(EnumEmailSettingKeys.INBOUND_SERVER.getKey()))) { props.put(baseProtocol + MAIL_PROTOCOL_HOST, settings.get(EnumEmailSettingKeys.INBOUND_SERVER.getKey())); } if (settings.containsKey(EnumEmailSettingKeys.INBOUND_PORT.getKey())) { props.put(baseProtocol + MAIL_PROTOCOL_PORT, settings.get(EnumEmailSettingKeys.INBOUND_PORT.getKey())); } if (settings.containsKey(EnumEmailSettingKeys.INBOUND_USER.getKey()) && StringUtils.isNotEmpty(settings.get(EnumEmailSettingKeys.INBOUND_USER.getKey()))) { props.put(baseProtocol + MAIL_PROTOCOL_USER, settings.get(EnumEmailSettingKeys.INBOUND_USER.getKey())); } if (settings.containsKey(EnumEmailSettingKeys.INBOUND_PASS.getKey()) && StringUtils.isNotEmpty(settings.get(EnumEmailSettingKeys.INBOUND_PASS.getKey()))) { props.put(baseProtocol + MAIL_PROTOCOL_PASSWORD, settings.get(EnumEmailSettingKeys.INBOUND_PASS.getKey())); } if (settings.containsKey(EnumEmailSettingKeys.INBOUND_SSL_ENABLED.getKey())) { props.put(baseProtocol + MAIL_PROTOCOL_SSL_ENABLE, settings.get(EnumEmailSettingKeys.INBOUND_SSL_ENABLED.getKey())); } if (settings.containsKey(EnumEmailSettingKeys.INBOUND_STARTTLS.getKey())) { props.put(baseProtocol + MAIL_PROTOCOL_STARTTLS, settings.get(EnumEmailSettingKeys.INBOUND_STARTTLS.getKey())); props.put(baseProtocol + ".socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.put(baseProtocol + MAIL_PROTOCOL_AUTH, "true"); props.put(baseProtocol + ".ssl.trust", "*"); props.put(baseProtocol + ".starttls.trust", "*"); } } if (settings.containsKey(EnumEmailSettingKeys.SMTP_SERVER.getKey()) && StringUtils.isNotEmpty(settings.get(EnumEmailSettingKeys.SMTP_SERVER.getKey()))) { props.put(MAIL + PROTOCOL_SMTP + MAIL_PROTOCOL_HOST, settings.get(EnumEmailSettingKeys.SMTP_SERVER.getKey())); } if (settings.containsKey(EnumEmailSettingKeys.SMTP_PORT.getKey()) && StringUtils.isNotEmpty(settings.get(EnumEmailSettingKeys.SMTP_PORT.getKey()))) { props.put(MAIL + PROTOCOL_SMTP + MAIL_PROTOCOL_PORT, settings.get(EnumEmailSettingKeys.SMTP_PORT.getKey())); } if (settings.containsKey(EnumEmailSettingKeys.SMTP_USER.getKey()) && StringUtils.isNotEmpty(settings.get(EnumEmailSettingKeys.SMTP_USER.getKey()))) { props.put(MAIL + PROTOCOL_SMTP + MAIL_PROTOCOL_USER, settings.get(EnumEmailSettingKeys.SMTP_USER.getKey())); } if (settings.containsKey(EnumEmailSettingKeys.SMTP_PASS.getKey()) && StringUtils.isNotEmpty(settings.get(EnumEmailSettingKeys.SMTP_PASS.getKey()))) { props.put(MAIL + PROTOCOL_SMTP + MAIL_PROTOCOL_PASSWORD, settings.get(EnumEmailSettingKeys.SMTP_PASS.getKey())); } if (settings.containsKey(EnumEmailSettingKeys.SMTP_FROM.getKey()) && StringUtils.isNotEmpty(settings.get(EnumEmailSettingKeys.SMTP_FROM.getKey()))) { props.put(MAIL + PROTOCOL_SMTP + MAIL_PROTOCOL_FROM, settings.get(EnumEmailSettingKeys.SMTP_FROM.getKey())); } if (settings.containsKey(EnumEmailSettingKeys.SMTP_FROMNAME.getKey()) && StringUtils.isNotEmpty(settings.get(EnumEmailSettingKeys.SMTP_FROMNAME.getKey()))) { props.put(MAIL + PROTOCOL_SMTP + MAIL_PROTOCOL_FROMNAME, settings.get(EnumEmailSettingKeys.SMTP_FROMNAME.getKey())); } if (settings.containsKey(EnumEmailSettingKeys.SMTP_SSL_ENABLED.getKey()) && StringUtils.isNotEmpty(settings.get(EnumEmailSettingKeys.SMTP_SSL_ENABLED.getKey())) && Boolean.parseBoolean(settings.get(EnumEmailSettingKeys.SMTP_SSL_ENABLED.getKey()))) { props.put(MAIL + PROTOCOL_SMTP + MAIL_PROTOCOL_SSL_ENABLE, Boolean.TRUE); props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.put("mail.smtp.auth", "true"); if (settings.containsKey(EnumEmailSettingKeys.SMTP_SOCKET_FACTORY_PORT.getKey())) { props.put(MAIL + PROTOCOL_SMTP + MAIL_PROTOCOL_SOCKET_FACTORY_PORT, settings.get(EnumEmailSettingKeys.SMTP_SOCKET_FACTORY_PORT.getKey())); } else { if (settings.containsKey(EnumEmailSettingKeys.SMTP_PORT.getKey()) && StringUtils.isNotEmpty(settings.get(EnumEmailSettingKeys.SMTP_PORT.getKey()))) { props.put(MAIL + PROTOCOL_SMTP + MAIL_PROTOCOL_SOCKET_FACTORY_PORT, settings.get(EnumEmailSettingKeys.SMTP_PORT.getKey())); } } } else { //check TLS if (settings.containsKey(EnumEmailSettingKeys.SMTP_STARTTLS.getKey()) && StringUtils.isNotEmpty(settings.get(EnumEmailSettingKeys.SMTP_STARTTLS.getKey()))) { String starttls = settings.get(EnumEmailSettingKeys.SMTP_STARTTLS.getKey()); if (Boolean.parseBoolean(starttls)) { props.put(MAIL + PROTOCOL_SMTP + MAIL_PROTOCOL_STARTTLS, "true"); props.put(MAIL + PROTOCOL_SMTP + ".socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.put(MAIL + PROTOCOL_SMTP + MAIL_PROTOCOL_AUTH, "true"); props.put(MAIL + PROTOCOL_SMTP + ".ssl.trust", "*"); } else { props.put(MAIL + PROTOCOL_SMTP + MAIL_PROTOCOL_STARTTLS, "false"); } } } if (settings.containsKey(EnumEmailSettingKeys.SMTP_CONNECTIONTIMEOUT.getKey()) && StringUtils.isNotEmpty(settings.get(EnumEmailSettingKeys.SMTP_CONNECTIONTIMEOUT.getKey()))) { props.put(MAIL + PROTOCOL_SMTP + MAIL_PROTOCOL_CONNECTIONTIMEOUT, settings.get(EnumEmailSettingKeys.SMTP_CONNECTIONTIMEOUT.getKey())); } if (settings.containsKey(EnumEmailSettingKeys.SMTP_TIMEOUT.getKey()) && StringUtils.isNotEmpty(settings.get(EnumEmailSettingKeys.SMTP_TIMEOUT.getKey()))) { props.put(MAIL + PROTOCOL_SMTP + MAIL_PROTOCOL_TIMEOUT, settings.get(EnumEmailSettingKeys.SMTP_TIMEOUT.getKey())); } if (settings.containsKey(EnumEmailSettingKeys.TRANSPORT_PROTOCOL.getKey()) && StringUtils.isNotEmpty(settings.get(EnumEmailSettingKeys.TRANSPORT_PROTOCOL.getKey()))) { props.put(MAIL_TRANSPORT_PROTOCOL, settings.get(EnumEmailSettingKeys.TRANSPORT_PROTOCOL.getKey())); } if (settings.containsKey(EnumEmailSettingKeys.STORE_PROTOCOL.getKey()) && StringUtils.isNotEmpty(settings.get(EnumEmailSettingKeys.STORE_PROTOCOL.getKey()))) { props.put(MAIL_STORE_PROTOCOL, settings.get(EnumEmailSettingKeys.STORE_PROTOCOL.getKey())); } return props; }
From source file:com.t3.model.AssetManager.java
/** * Serialize the asset into the persistent cache. * // ww w . j a v a2 s .c om * @param asset * Asset to serialize */ private static void putInPersistentCache(final Asset asset) { if (!usePersistentCache) { return; } if (!assetIsInPersistentCache(asset)) { final File assetFile = getAssetCacheFile(asset); new Thread() { @Override public void run() { assetFile.getParentFile().mkdirs(); try (OutputStream out = new FileOutputStream(assetFile)) { out.write(asset.getImage()); } catch (IOException ioe) { log.error("Could not persist asset while writing image data", ioe); return; } } }.start(); } if (!assetInfoIsInPersistentCache(asset)) { File infoFile = getAssetInfoFile(asset); try { // Info Properties props = new Properties(); props.put(NAME, asset.getName() != null ? asset.getName() : ""); try (OutputStream out = new FileOutputStream(infoFile)) { props.store(out, "Asset Info"); } } catch (IOException ioe) { log.error("Could not persist asset while writing image properties", ioe); return; } } }
From source file:com.tvh.gmaildrafter.Drafter.java
private static void composeMail(Credentials credentials, String subjectText, String bodyText, String[] attachments, String[] attachmentnames, String[] destinations, String[] cc, String[] bcc, Boolean sendImmediately) throws IOException, AuthenticationFailedException { if (subjectText == null) { subjectText = ""; }/* w w w . ja v a 2 s.c o m*/ if (bodyText == null) { bodyText = ""; } try { Properties props = null; Session session = null; if (!sendImmediately) { props = System.getProperties(); props.setProperty("mail.store.protocol", "imaps"); session = Session.getDefaultInstance(props, null); } else { 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"); final String username = credentials.getUsername(); final String password = credentials.getPassword(); session = Session.getInstance(props, new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); } }); } String signature = Signature.getSignature(credentials); if (signature == null) signature = ""; // Create the message Message draftMail = new MimeMessage(session); draftMail.setSubject(subjectText); Multipart parts = new MimeMultipart(); BodyPart body = new MimeBodyPart(); if (bodyText.toLowerCase().indexOf("<body") < 0) // rough guess to see if the body is html { bodyText = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body>" + StringEscapeUtils.escapeHtml(bodyText).replace("\n", "<br />" + "\n") + "<br>" + "</body></html>"; } if (signature != null && signature != "") { StringBuilder b = new StringBuilder(bodyText); if (signature.indexOf("</") < 0) // assume it's html if there's no </, rough guess { signature = StringEscapeUtils.escapeHtml(signature); } b.replace(bodyText.lastIndexOf("</body>"), bodyText.lastIndexOf("</body>") + 7, "<br>" + signature + "</body>"); bodyText = b.toString(); } body.setContent(bodyText, "text/html; charset=utf-8"); body.setDisposition("inline"); parts.addBodyPart(body); if (attachments != null) { for (int i = 0; i < attachments.length; i++) { BodyPart attachment = new MimeBodyPart(); DataSource source = new FileDataSource(attachments[i]); attachment.setDataHandler(new DataHandler(source)); if (attachmentnames != null && attachmentnames.length > i) { attachment.setFileName(attachmentnames[i]); } else { File file = new File(attachments[i]); attachment.setFileName(file.getName()); } parts.addBodyPart(attachment); } } draftMail.setContent(parts); if (destinations != null && destinations.length > 0) draftMail.setRecipients(Message.RecipientType.TO, stringToInternetAddress(destinations)); if (cc != null && cc.length > 0) draftMail.setRecipients(Message.RecipientType.CC, stringToInternetAddress(cc)); if (bcc != null && bcc.length > 0) draftMail.setRecipients(Message.RecipientType.BCC, stringToInternetAddress(bcc)); draftMail.setFlag(Flags.Flag.SEEN, true); if (sendImmediately) { Transport.send(draftMail); } else { URLName url = new URLName("imaps://imap.gmail.com"); IMAPSSLStore store = new IMAPSSLStore(session, url); store.connect(credentials.getUsername(), credentials.getPassword()); Folder[] f = store.getDefaultFolder().xlist("*"); long threadId = 0; for (Folder fd : f) { IMAPFolder folder = (IMAPFolder) fd; boolean thisIsDrafts = false; String atts[] = folder.getAttributes(); for (String a : atts) { if (a.equalsIgnoreCase("\\Drafts")) { thisIsDrafts = true; break; } } if (thisIsDrafts) { folder.open(Folder.READ_WRITE); Message[] messages = new Message[1]; messages[0] = draftMail; folder.appendMessages(messages); /* * Determine the Google Message Id, needed to open it in the * browser. Because we just created the message it is * reasonable to assume it is the last message in the draft * folder. If this turns out not to be the case we could * start creating the message with a random unique dummy * subject, find it using that subject and then modify the * subject to what it was supposed to be. */ messages[0] = folder.getMessage(folder.getMessageCount()); FetchProfile fp = new FetchProfile(); fp.add(IMAPFolder.FetchProfileItem.X_GM_THRID); folder.fetch(messages, fp); IMAPMessage googleMessage = (IMAPMessage) messages[0]; threadId = googleMessage.getGoogleMessageThreadId(); folder.close(false); } } if (threadId == 0) { System.exit(6); } store.close(); // Open the message in the default browser Runtime rt = Runtime.getRuntime(); String drafturl = "https://mail.google.com/mail/#drafts/" + Long.toHexString(threadId); File chrome = new File("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"); if (!chrome.exists()) chrome = new File("C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"); if (!chrome.exists()) { // Chrome not found, using default browser rt.exec("rundll32 url.dll,FileProtocolHandler " + drafturl); } else { String[] commandLine = new String[2]; commandLine[0] = chrome.getPath(); commandLine[1] = drafturl; rt.exec(commandLine); } } // else branch for sendImmediately } catch (NoSuchProviderException e) { e.printStackTrace(); System.exit(4); } catch (AuthenticationFailedException e) { throw (e); } catch (MessagingException e) { e.printStackTrace(); System.exit(5); } }
From source file:com.glaf.core.config.DBConfiguration.java
/** * ??//from w w w .jav a 2s. com * * @param name * ?? * @param driver * * @param url * JDBCURL * @param user * ??? * @param password * ? */ public static void addDataSourceProperties(String name, String driver, String url, String user, String password) { if (!dataSourceProperties.containsKey(name)) { Properties props = new Properties(); props.put(JDBC_NAME, name); props.put(JDBC_DRIVER, driver); props.put(JDBC_URL, url); props.put(JDBC_USER, user); props.put(JDBC_PASSWORD, password); String dbType = getDatabaseType(url); if (StringUtils.equals(dbType, "postgresql")) { props.put(ConnectionConstants.PROP_VALIDATIONQUERY, " SELECT 'X' "); } else if (StringUtils.equals(dbType, "sqlserver")) { props.put(ConnectionConstants.PROP_VALIDATIONQUERY, " SELECT 'X' "); } else if (StringUtils.equals(dbType, "mysql")) { props.put(ConnectionConstants.PROP_VALIDATIONQUERY, " SELECT 'X' "); } else if (StringUtils.equals(dbType, "oracle")) { props.put(ConnectionConstants.PROP_VALIDATIONQUERY, " SELECT 'x' FROM dual "); } try { if (DBConnectionFactory.checkConnection(props)) { MultiRoutingDataSource.addDataSource(name, props); ConnectionDefinition conn = toConnectionDefinition(props); conn.setUrl(url); conn.setType(dbType); dbTypes.put(name, dbType); props.put(JDBC_TYPE, dbType); dataSourceProperties.put(name, conn); ConfigFactory.put(DBConfiguration.class.getSimpleName(), name, conn.toJsonObject().toJSONString()); } } catch (Exception ex) { ex.printStackTrace(); } } }
From source file:fr.ens.biologie.genomique.eoulsan.it.ITFactory.java
/** * Adds the default properties if does not exist in the configuration file. * @param props the props/*w w w .j a v a2 s. co m*/ */ private static void addDefaultProperties(Properties props) { // Particular case delete files if (props.getProperty(SUCCESS_IT_DELETE_FILE_CONF_KEY) == null) { // Set default value props.put(SUCCESS_IT_DELETE_FILE_CONF_KEY, SUCCESS_IT_DELETE_FILE_DEFAULT_VALUE); } // Add default runtime test duration if (props.getProperty(RUNTIME_IT_MAXIMUM_KEY) == null) { props.put(RUNTIME_IT_MAXIMUM_KEY, "" + RUNTIME_IT_MAXIMUM_DEFAULT); } }
From source file:net.rptools.maptool.model.AssetManager.java
/** * Serialize the asset into the persistent cache. * //w ww . ja v a 2 s.c o m * @param asset * Asset to serialize */ private static void putInPersistentCache(final Asset asset) { if (!usePersistentCache) { return; } if (!assetIsInPersistentCache(asset)) { final File assetFile = getAssetCacheFile(asset); new Thread() { @Override public void run() { try { assetFile.getParentFile().mkdirs(); // Image OutputStream out = new FileOutputStream(assetFile); out.write(asset.getImage()); out.close(); } catch (IOException ioe) { log.error("Could not persist asset while writing image data", ioe); return; } } }.start(); } if (!assetInfoIsInPersistentCache(asset)) { File infoFile = getAssetInfoFile(asset); try { // Info OutputStream out = new FileOutputStream(infoFile); Properties props = new Properties(); props.put(NAME, asset.getName() != null ? asset.getName() : ""); props.store(out, "Asset Info"); out.close(); } catch (IOException ioe) { log.error("Could not persist asset while writing image properties", ioe); return; } } }
From source file:fr.ens.biologie.genomique.eoulsan.it.ITFactory.java
/** * Initialize the constants values./* w w w . j ava 2 s . c om*/ * @return a map with the constants */ private static Properties initConstants() { final Properties constants = new Properties(); // Add java properties for (final Map.Entry<Object, Object> e : System.getProperties().entrySet()) { constants.put(e.getKey(), e.getValue()); } // Add environment properties for (final Map.Entry<String, String> e : System.getenv().entrySet()) { constants.put(e.getKey(), e.getValue()); } return constants; }