List of usage examples for com.liferay.portal.kernel.messaging Message getInteger
public int getInteger(String key)
From source file:com.liferay.mail.messaging.MailSynchronizationMessageListener.java
License:Open Source License
protected void flagMessage(Message message) throws Exception { long userId = message.getLong("userId"); long accountId = message.getLong("accountId"); String password = message.getString("password"); long folderId = message.getLong("folderId"); long messageId = message.getLong("messageId"); int flag = message.getInteger("flag"); boolean flagValue = message.getBoolean("flagValue"); if (_log.isDebugEnabled()) { _log.debug("Flagging message for messageId " + messageId); }//from w w w . j ava 2 s.c o m if (Validator.isNull(password)) { return; } Mailbox mailbox = MailboxFactoryUtil.getMailbox(userId, accountId, password); mailbox.updateFlags(folderId, new long[] { messageId }, flag, flagValue); }
From source file:com.liferay.mail.messaging.MailSynchronizationMessageListener.java
License:Open Source License
protected void synchronize(Message message) throws Exception { long userId = message.getLong("userId"); long accountId = message.getLong("accountId"); String password = message.getString("password"); long folderId = message.getLong("folderId"); long messageId = message.getLong("messageId"); int pageNumber = message.getInteger("pageNumber"); int messagesPerPage = message.getInteger("messagesPerPage"); if (_log.isDebugEnabled()) { _log.debug("Starting synch for accountId " + accountId + " folderId " + folderId + " and messageId " + messageId);//from w w w. j a va2s. com } try { if (!password.equals(StringPool.BLANK)) { Mailbox mailbox = MailboxFactoryUtil.getMailbox(userId, accountId, password); if (messageId != 0) { mailbox.synchronizeMessage(messageId); } else if (folderId != 0) { if (pageNumber != 0) { mailbox.synchronizePage(folderId, pageNumber, messagesPerPage); } else { mailbox.synchronizeFolder(folderId); } } else { mailbox.synchronize(); } } else { if (_log.isDebugEnabled()) { _log.debug("Unable to acquire synch lock for accountId " + accountId + " and folderId " + folderId + " and messageId " + messageId); } } } catch (NoSuchAccountException nsae) { if (_log.isDebugEnabled()) { _log.debug("Skipping syncronization of accountId " + accountId); } } }
From source file:com.liferay.mobile.pushnotifications.messaging.NotificationMessageListener.java
License:Open Source License
public void receive(Message message) { List<Long> userIds = (List<Long>) message.get("userIds"); String alert = message.getString("alert"); String collapseKey = message.getString("collapseKey"); String data = message.getString("data"); int timeToLive = message.getInteger("timeToLive"); boolean delayWhileIdle = message.getBoolean("delayWhileIdle"); int badge = message.getInteger("badge"); String sound = message.getString("sound"); for (long userId : userIds) { try {/* w w w . j a va2 s.c o m*/ AndroidNotificationSender.send(userId, collapseKey, data, timeToLive, delayWhileIdle); iOSNotificationSender.send(userId, alert, data, badge, sound); } catch (Exception e) { _log.error(e); } } }
From source file:com.liferay.ruon.messaging.RUONMessageListener.java
License:Open Source License
protected void updateNetwork(Message message) throws Exception { String name = message.getString("name"); int ttl = message.getInteger("ttl"); Converter converter = (Converter) message.get("converter"); Network network = NetworkLocalServiceUtil.updateNetwork(name, ttl); _converters.put(network.getNetworkId(), converter); }
From source file:com.liferay.server.admin.web.internal.portlet.action.EditServerMVCActionCommand.java
License:Open Source License
protected void reindex(final ActionRequest actionRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Map<String, Serializable> taskContextMap = new HashMap<>(); String className = ParamUtil.getString(actionRequest, "className"); if (!ParamUtil.getBoolean(actionRequest, "blocking")) { _indexWriterHelper.reindex(themeDisplay.getUserId(), "reindex", _portalInstancesLocalService.getCompanyIds(), className, taskContextMap); return;/*ww w . j av a 2s. c om*/ } final String jobName = "reindex-".concat(_portalUUID.generate()); final CountDownLatch countDownLatch = new CountDownLatch(1); MessageListener messageListener = new MessageListener() { @Override public void receive(Message message) throws MessageListenerException { int status = message.getInteger("status"); if ((status != BackgroundTaskConstants.STATUS_CANCELLED) && (status != BackgroundTaskConstants.STATUS_FAILED) && (status != BackgroundTaskConstants.STATUS_SUCCESSFUL)) { return; } if (!jobName.equals(message.getString("name"))) { return; } PortletSession portletSession = actionRequest.getPortletSession(); long lastAccessedTime = portletSession.getLastAccessedTime(); int maxInactiveInterval = portletSession.getMaxInactiveInterval(); int extendedMaxInactiveIntervalTime = (int) (System.currentTimeMillis() - lastAccessedTime + maxInactiveInterval); portletSession.setMaxInactiveInterval(extendedMaxInactiveIntervalTime); countDownLatch.countDown(); } }; _messageBus.registerMessageListener(DestinationNames.BACKGROUND_TASK_STATUS, messageListener); try { _indexWriterHelper.reindex(themeDisplay.getUserId(), jobName, _portalInstancesLocalService.getCompanyIds(), className, taskContextMap); countDownLatch.await(ParamUtil.getLong(actionRequest, "timeout", Time.HOUR), TimeUnit.MILLISECONDS); } finally { _messageBus.unregisterMessageListener(DestinationNames.BACKGROUND_TASK_STATUS, messageListener); } }