本文整理汇总了Java中com.liferay.portal.kernel.util.PrefsPropsUtil类的典型用法代码示例。如果您正苦于以下问题:Java PrefsPropsUtil类的具体用法?Java PrefsPropsUtil怎么用?Java PrefsPropsUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PrefsPropsUtil类属于com.liferay.portal.kernel.util包,在下文中一共展示了PrefsPropsUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: send
import com.liferay.portal.kernel.util.PrefsPropsUtil; //导入依赖的package包/类
public static void send(String toStr, String subject,
String body, boolean isHtml) throws SystemException, AddressException, PortalException {
Company cmp = null;
try {
cmp = CompanyServiceUtil.getCompanyByVirtualHost(AppConstants.COMPANY_VIRTUAL_HOST);
} catch (Throwable t) {
}
if (cmp != null) {
long cmpId = cmp.getCompanyId();
String fromStr = PrefsPropsUtil.getString(cmpId,
PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);
InternetAddress from = new InternetAddress(fromStr);
InternetAddress to = new InternetAddress(toStr);
if (from != null && to != null && subject != null && body != null) {
MailMessage message = new MailMessage(from, to, subject, body, isHtml);
MailServiceUtil.sendEmail(message);
}
}
}
示例2: run
import com.liferay.portal.kernel.util.PrefsPropsUtil; //导入依赖的package包/类
public void run(String[] arg0) throws ActionException {
try {
boolean brokerActive =
PrefsPropsUtil.getBoolean(
PortletPropsKeys.MQTT_AUTO_CONNECT,
PortletPropsValues.MQTT_AUTO_CONNECT);
if (brokerActive) {
MqttLocalServiceUtil.connect();
}
}
catch (SystemException | MqttException e) {
_log.error(e);
throw new ActionException(e);
}
}
示例3: applySubscriptionsList
import com.liferay.portal.kernel.util.PrefsPropsUtil; //导入依赖的package包/类
@Override
public void applySubscriptionsList() throws MqttException, SystemException {
String[] subscriptions =
PrefsPropsUtil.getStringArray(
PortletPropsKeys.MQTT_SUBSCRIPTIONS_LIST, StringPool.NEW_LINE,
PortletPropsValues.MQTT_SUBSCRIPTIONS_ARRAY);
if (_getInstance().isConnected()) {
String[] topics = ConfigUtil.properties2topic(subscriptions);
int[] qos = ConfigUtil.properties2qos(subscriptions);
for (int i = 0; i<topics.length; i++) {
subscribe(topics[i], qos[i]);
}
}
}
示例4: _noRetry
import com.liferay.portal.kernel.util.PrefsPropsUtil; //导入依赖的package包/类
private void _noRetry() {
try {
PortletPreferences portletPreferences =
PrefsPropsUtil.getPreferences();
portletPreferences.setValue(
PortletPropsKeys.MQTT_ERRORS_RETRY_CONNECT,
String.valueOf(false));
portletPreferences.store();
}
catch (Exception e1) {
_log.error(e1);
}
}
示例5: _notityMail
import com.liferay.portal.kernel.util.PrefsPropsUtil; //导入依赖的package包/类
private void _notityMail(String context, Throwable e) {
try {
String errorMailTo =
PrefsPropsUtil.getString(
PortletPropsKeys.MQTT_ERRORS_SEND_MAIL_TO,
PortletPropsValues.MQTT_ERRORS_SEND_MAIL_TO);
if (Validator.isNotNull(errorMailTo)) {
MailMessage mailMessage = new MailMessage();
long companyId = PortalUtil.getDefaultCompanyId();
String fromAddress = PrefsPropsUtil.getString(
companyId, PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);
mailMessage.setHTMLFormat(false);
mailMessage.setTo(new InternetAddress(errorMailTo));
mailMessage.setSubject(String.format(
"%s Mqtt connector error", PortalUtil.getComputerName()));
mailMessage.setFrom(new InternetAddress(fromAddress));
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
mailMessage.setBody(String.format(
"context: %s\nerror: %s\n stacktrace:%s\n", context,
e.getMessage(), sw.toString()));
MailServiceUtil.sendEmail(mailMessage);
}
}
catch (Exception e1) {
_log.error(e1);
}
}
示例6: _setupRetry
import com.liferay.portal.kernel.util.PrefsPropsUtil; //导入依赖的package包/类
private void _setupRetry(Throwable e) {
try {
PortletPreferences portletPreferences =
PrefsPropsUtil.getPreferences();
portletPreferences.setValue(
PortletPropsKeys.MQTT_ERRORS_RETRY_CONNECT,
String.valueOf(true));
portletPreferences.store();
}
catch (Exception e1) {
_log.error(e);
}
}
示例7: getNameInNamespace
import com.liferay.portal.kernel.util.PrefsPropsUtil; //导入依赖的package包/类
public String getNameInNamespace(long companyId, Binding binding)
throws Exception {
String baseDN = PrefsPropsUtil.getString(companyId,
PropsKeys.LDAP_BASE_DN);
if (Validator.isNull(baseDN)) {
return binding.getName();
} else {
StringBuilder sb = new StringBuilder();
sb.append(binding.getName());
sb.append(StringPool.COMMA);
sb.append(baseDN);
return sb.toString();
}
}
示例8: sendInternal
import com.liferay.portal.kernel.util.PrefsPropsUtil; //导入依赖的package包/类
public static void sendInternal(String subject, String body, boolean isHtml)
throws SystemException, AddressException, PortalException {
Company cmp = null;
try {
cmp = CompanyServiceUtil.getCompanyByVirtualHost(AppConstants.COMPANY_VIRTUAL_HOST);
} catch (Throwable t) {
}
if (cmp != null) {
long cmpId = cmp.getCompanyId();
String toStr = PrefsPropsUtil.getString(cmpId,
PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);
send(toStr, subject, body, isHtml);
}
}
示例9: _getInstance
import com.liferay.portal.kernel.util.PrefsPropsUtil; //导入依赖的package包/类
private synchronized MqttClient _getInstance()
throws MqttException, SystemException {
if (_mqttClient == null) {
String serverURI =
PrefsPropsUtil.getString(
PortletPropsKeys.MQTT_BROKER_URL,
PortletPropsValues.MQTT_BROKER_URL);
String clientID =
PrefsPropsUtil.getString(
PortletPropsKeys.MQTT_BROKER_CLIENTID,
PortletPropsValues.MQTT_BROKER_CLIENTID);
MemoryPersistence persistence = new MemoryPersistence();
_mqttClient = new MqttClient(serverURI, clientID, persistence);
_mqttClient.setCallback(this);
}
return _mqttClient;
}
示例10: getConfigValue
import com.liferay.portal.kernel.util.PrefsPropsUtil; //导入依赖的package包/类
/**
* Gets the value for a given configuration key (or the default setting if not found)
* This method may either access the portlet data-source for local settings or the portal properties for global configuration settings
*
* @param key the configuration key
* @return the configuration value
*/
public static String getConfigValue(final E_ConfigKey key) {
String value = null;
if (key.isSystemProperty()) {
try {
value = PrefsPropsUtil.getString(
PortalUtil.getDefaultCompanyId(),
key.getSystemProperty());
// m_objLog.debug("Got portal property "+key.getSystemProperty()+" = "+value);
} catch (final SystemException e) {
value = key.getDefaultValue();
m_objLog.error(e);
}
} else {
value = AHConfigLocalServiceUtil.getConfig(key.toString(),
key.getDefaultValue());
m_objLog.info("Got portlet property "+key.toString()+" = "+value);
}
return value;
}
示例11: sendNewsUpdateMail
import com.liferay.portal.kernel.util.PrefsPropsUtil; //导入依赖的package包/类
/**
* Send news update mail.
*
* @param sub the sub
* @param offers the offers
*/
public void sendNewsUpdateMail(final AHSubscription sub,
final List<AHOffer> offers) {
try {
final String addr = PrefsPropsUtil.getString(
PortalUtil.getDefaultCompanyId(),
PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);
final InternetAddress from = new InternetAddress(addr);
final InternetAddress to = new InternetAddress(sub.getEmail());
final String subj = CustomPortalServiceHandler
.getConfigValue(E_ConfigKey.NEWS_UPDATE_SUBJ);
final String body = CustomPortalServiceHandler
.getConfigValue(E_ConfigKey.NEWS_UPDATE_BODY);
this.sendNewsMail(from, to, subj, body, sub, offers);
} catch (final Throwable t) {
m_objLog.error(t);
}
}
示例12: readConfiguration
import com.liferay.portal.kernel.util.PrefsPropsUtil; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static Map<String, Object> readConfiguration(
String configurationFile)
throws IOException, SystemException {
ClassLoader classLoader = ConfigurationUtil.class.getClassLoader();
InputStream inputStream = classLoader.getResourceAsStream(
configurationFile);
String configuration = StringUtil.read(inputStream);
String journalArticleIndexPrimaryKeyAttribute;
if (PrefsPropsUtil.getBoolean("journal.articles.index.all.versions")) {
journalArticleIndexPrimaryKeyAttribute = "pk";
}
else {
journalArticleIndexPrimaryKeyAttribute = "resourcePrimKey";
}
configuration = configuration.replace(
"$$JOURNAL_ARTICLE_INDEX_PRIMARY_KEY_ATTRIBUTE$$",
journalArticleIndexPrimaryKeyAttribute);
Yaml yaml = new Yaml();
return (Map<String, Object>)yaml.load(configuration);
}
示例13: messageArrived
import com.liferay.portal.kernel.util.PrefsPropsUtil; //导入依赖的package包/类
@Override
public void messageArrived(String topic, MqttMessage message)
throws Exception {
Message mb = new Message();
mb.put("topic", topic);
mb.put("qos", message.getQos());
mb.put("retained", message.isRetained());
String payload = new String(message.getPayload());
mb.setPayload(payload);
MessageBusUtil.sendMessage(
PortletPropsValues.MQTT_MESSAGES_DESTINATION, mb);
boolean logInfo = PrefsPropsUtil.getBoolean(
PortletPropsKeys.MQTT_EVENTS_LOGINFO,
PortletPropsValues.MQTT_EVENTS_LOGINFO);
if (logInfo) {
_log.info(String.format("arrived [%s,%s,%s] %s",
topic, message.getQos(), message.isRetained()?"R":"",
payload));
}
}
示例14: publish
import com.liferay.portal.kernel.util.PrefsPropsUtil; //导入依赖的package包/类
@Override
public void publish(String topic, byte[] payload, int qos)
throws MqttException, SystemException {
_getInstance().publish(topic, payload, qos, false);
boolean logInfo = PrefsPropsUtil.getBoolean(
PortletPropsKeys.MQTT_EVENTS_LOGINFO,
PortletPropsValues.MQTT_EVENTS_LOGINFO);
if (logInfo) {
_log.info(String.format("send [%s,%s] %s",
topic, qos, payload));
}
}
示例15: resetSubscriptionsList
import com.liferay.portal.kernel.util.PrefsPropsUtil; //导入依赖的package包/类
@Override
public void resetSubscriptionsList() throws MqttException, SystemException {
String[] subscriptions =
PrefsPropsUtil.getStringArray(
PortletPropsKeys.MQTT_SUBSCRIPTIONS_LIST, StringPool.NEW_LINE,
PortletPropsValues.MQTT_SUBSCRIPTIONS_ARRAY);
if (_getInstance().isConnected()) {
String[] topics = ConfigUtil.properties2topic(subscriptions);
_getInstance().unsubscribe(topics);
}
}