List of usage examples for com.liferay.portal.util PrefsPropsUtil getBoolean
public static boolean getBoolean(String name)
From source file:com.liferay.mail.service.impl.MailServiceImpl.java
License:Open Source License
public Session getSession() throws SystemException { if (_session != null) { return _session; }//ww w . j a v a 2 s.c om Session session = InfrastructureUtil.getMailSession(); if (!PrefsPropsUtil.getBoolean(PropsKeys.MAIL_SESSION_MAIL)) { _session = session; return _session; } String advancedPropertiesString = PrefsPropsUtil.getString(PropsKeys.MAIL_SESSION_MAIL_ADVANCED_PROPERTIES, PropsValues.MAIL_SESSION_MAIL_ADVANCED_PROPERTIES); String pop3Host = PrefsPropsUtil.getString(PropsKeys.MAIL_SESSION_MAIL_POP3_HOST, PropsValues.MAIL_SESSION_MAIL_POP3_HOST); String pop3Password = PrefsPropsUtil.getString(PropsKeys.MAIL_SESSION_MAIL_POP3_PASSWORD, PropsValues.MAIL_SESSION_MAIL_POP3_PASSWORD); int pop3Port = PrefsPropsUtil.getInteger(PropsKeys.MAIL_SESSION_MAIL_POP3_PORT, PropsValues.MAIL_SESSION_MAIL_POP3_PORT); String pop3User = PrefsPropsUtil.getString(PropsKeys.MAIL_SESSION_MAIL_POP3_USER, PropsValues.MAIL_SESSION_MAIL_POP3_USER); String smtpHost = PrefsPropsUtil.getString(PropsKeys.MAIL_SESSION_MAIL_SMTP_HOST, PropsValues.MAIL_SESSION_MAIL_SMTP_HOST); String smtpPassword = PrefsPropsUtil.getString(PropsKeys.MAIL_SESSION_MAIL_SMTP_PASSWORD, PropsValues.MAIL_SESSION_MAIL_SMTP_PASSWORD); int smtpPort = PrefsPropsUtil.getInteger(PropsKeys.MAIL_SESSION_MAIL_SMTP_PORT, PropsValues.MAIL_SESSION_MAIL_SMTP_PORT); String smtpUser = PrefsPropsUtil.getString(PropsKeys.MAIL_SESSION_MAIL_SMTP_USER, PropsValues.MAIL_SESSION_MAIL_SMTP_USER); String storeProtocol = PrefsPropsUtil.getString(PropsKeys.MAIL_SESSION_MAIL_STORE_PROTOCOL, PropsValues.MAIL_SESSION_MAIL_STORE_PROTOCOL); String transportProtocol = PrefsPropsUtil.getString(PropsKeys.MAIL_SESSION_MAIL_TRANSPORT_PROTOCOL, PropsValues.MAIL_SESSION_MAIL_TRANSPORT_PROTOCOL); Properties properties = session.getProperties(); // Incoming if (!storeProtocol.equals(Account.PROTOCOL_POPS)) { storeProtocol = Account.PROTOCOL_POP; } properties.setProperty("mail.store.protocol", storeProtocol); String storePrefix = "mail." + storeProtocol + "."; properties.setProperty(storePrefix + "host", pop3Host); properties.setProperty(storePrefix + "password", pop3Password); properties.setProperty(storePrefix + "port", String.valueOf(pop3Port)); properties.setProperty(storePrefix + "user", pop3User); // Outgoing if (!transportProtocol.equals(Account.PROTOCOL_SMTPS)) { transportProtocol = Account.PROTOCOL_SMTP; } properties.setProperty("mail.transport.protocol", transportProtocol); String transportPrefix = "mail." + transportProtocol + "."; boolean smtpAuth = false; if (Validator.isNotNull(smtpPassword) || Validator.isNotNull(smtpUser)) { smtpAuth = true; } properties.setProperty(transportPrefix + "auth", String.valueOf(smtpAuth)); properties.setProperty(transportPrefix + "host", smtpHost); properties.setProperty(transportPrefix + "password", smtpPassword); properties.setProperty(transportPrefix + "port", String.valueOf(smtpPort)); properties.setProperty(transportPrefix + "user", smtpUser); // Advanced try { if (Validator.isNotNull(advancedPropertiesString)) { Properties advancedProperties = PropertiesUtil.load(advancedPropertiesString); Iterator<Map.Entry<Object, Object>> itr = advancedProperties.entrySet().iterator(); while (itr.hasNext()) { Map.Entry<Object, Object> entry = itr.next(); String key = (String) entry.getKey(); String value = (String) entry.getValue(); properties.setProperty(key, value); } } } catch (IOException ioe) { if (_log.isWarnEnabled()) { _log.warn(ioe, ioe); } } _session = Session.getInstance(properties); return _session; }
From source file:com.liferay.portlet.documentlibrary.util.PDFProcessorImpl.java
License:Open Source License
public boolean isImageMagickEnabled() throws Exception { if (PrefsPropsUtil.getBoolean(PropsKeys.IMAGEMAGICK_ENABLED)) { return true; }/*from w ww. ja v a 2 s .c o m*/ if (!_warned) { StringBundler sb = new StringBundler(5); sb.append("Liferay is not configured to use ImageMagick for "); sb.append("generating Document Library previews and will default "); sb.append("to PDFBox. For better quality previews, install "); sb.append("ImageMagick and enable it in portal-ext.properties."); _log.warn(sb.toString()); _warned = true; } return false; }