List of usage examples for com.liferay.portal.kernel.backgroundtask BackgroundTaskConstants STATUS_FAILED
int STATUS_FAILED
To view the source code for com.liferay.portal.kernel.backgroundtask BackgroundTaskConstants STATUS_FAILED.
Click Source Link
From source file:com.liferay.exportimport.internal.lifecycle.NotificationExportImportLifecycleListener.java
License:Open Source License
@Override public void onProcessFailed(ExportImportLifecycleEvent exportImportLifecycleEvent) throws Exception { sendNotification(BackgroundTaskConstants.STATUS_FAILED); }
From source file:com.liferay.exportimport.internal.notifications.ExportImportUserNotificationHandler.java
License:Open Source License
@Override protected String getBody(UserNotificationEvent userNotificationEvent, ServiceContext serviceContext) throws Exception { Locale locale = _portal.getLocale(serviceContext.getRequest()); ResourceBundle resourceBundle = _resourceBundleLoader.loadResourceBundle(locale); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(userNotificationEvent.getPayload()); ExportImportConfiguration exportImportConfiguration = null; try {/*w w w.j a va2 s . co m*/ exportImportConfiguration = _exportImportConfigurationLocalService .getExportImportConfiguration(jsonObject.getLong("exportImportConfigurationId")); } catch (PortalException pe) { if (_log.isDebugEnabled()) { _log.debug(pe, pe); } return LanguageUtil.get(resourceBundle, "the-process-referenced-by-this-notification-does-not-exist"); } String message = "x-" + ExportImportConfigurationConstants.getTypeLabel(exportImportConfiguration.getType()); int status = jsonObject.getInt("status"); if (status == BackgroundTaskConstants.STATUS_SUCCESSFUL) { message += "-process-finished-successfully"; } else if (status == BackgroundTaskConstants.STATUS_FAILED) { message += "-process-failed"; } else { return "Unable to process notification: " + HtmlUtil.escape(jsonObject.toString()); } long backgroundTaskId = jsonObject.getLong("backgroundTaskId"); BackgroundTaskDisplay backgroundTaskDisplay = _backgroundTaskDisplayFactory .getBackgroundTaskDisplay(backgroundTaskId); String processName = backgroundTaskDisplay.getDisplayName(serviceContext.getRequest()); return LanguageUtil.format(resourceBundle, message, processName); }
From source file:com.liferay.exportimport.lifecycle.NotificationExportImportLifecycleListener.java
License:Open Source License
@Override protected void onProcessFailed(List<Serializable> attributes) throws Exception { sendNotification(BackgroundTaskConstants.STATUS_FAILED); }
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;/*from ww w . j a v a 2 s .c o m*/ } 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); } }