List of usage examples for com.liferay.portal.kernel.util ParamUtil getDouble
public static double getDouble(ServiceContext serviceContext, String param)
From source file:com.beorn.demopaymentplugin.portlet.PaymentPluginPortlet.java
License:Open Source License
public void completePayment(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException { try {// w w w . j a v a2 s. com long transactionId = ParamUtil.getLong(actionRequest, "transactionId"); double amountPaid = ParamUtil.getDouble(actionRequest, "amountPaid"); String successUrl = ParamUtil.getString(actionRequest, "successUrl"); String errorUrl = ParamUtil.getString(actionRequest, "errorUrl"); PaymentPluginSender paymentPluginSender = PaymentPluginUtil.getPaymentPluginSender(); try { // XXX A real payment plugin would use a unique id for this // payment, coming from the remote platform where the payment // happened String remoteId = String.valueOf(transactionId); paymentPluginSender.addPayment(transactionId, remoteId, amountPaid); actionResponse.sendRedirect(successUrl); } catch (Exception e) { actionResponse.sendRedirect(errorUrl); } actionResponse.sendRedirect(successUrl); } catch (Exception e) { _log.error(e); actionResponse.setRenderParameters(actionRequest.getParameterMap()); SessionErrors.add(actionRequest, e.getClass().getName(), e); } }
From source file:com.liferay.classregistration.admin.portlet.AdminPortlet.java
License:Open Source License
public void updateClassEntry(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { long classEntryId = ParamUtil.getLong(actionRequest, "classEntryId"); String title = ParamUtil.getString(actionRequest, "title"); String description = ParamUtil.getString(actionRequest, "description"); int startDateMonth = ParamUtil.getInteger(actionRequest, "startDateMonth"); int startDateDay = ParamUtil.getInteger(actionRequest, "startDateDay"); int startDateYear = ParamUtil.getInteger(actionRequest, "startDateYear"); int startDateHour = ParamUtil.getInteger(actionRequest, "startDateHour"); int startDateMinute = ParamUtil.getInteger(actionRequest, "startDateMinute"); int startDateAmPm = ParamUtil.getInteger(actionRequest, "startDateAmPm"); if (startDateAmPm == Calendar.PM) { startDateHour += 12;/* ww w . ja v a 2 s . c o m*/ } int endDateMonth = ParamUtil.getInteger(actionRequest, "endDateMonth"); int endDateDay = ParamUtil.getInteger(actionRequest, "endDateDay"); int endDateYear = ParamUtil.getInteger(actionRequest, "endDateYear"); int endDateHour = ParamUtil.getInteger(actionRequest, "endDateHour"); int endDateMinute = ParamUtil.getInteger(actionRequest, "endDateMinute"); int endDateAmPm = ParamUtil.getInteger(actionRequest, "endDateAmPm"); if (endDateAmPm == Calendar.PM) { endDateHour += 12; } int maxAttendees = ParamUtil.getInteger(actionRequest, "maxAttendees"); double price = ParamUtil.getDouble(actionRequest, "price"); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); if (classEntryId <= 0) { ClassEntryLocalServiceUtil.addClassEntry(themeDisplay.getUserId(), title, description, startDateMonth, startDateDay, startDateYear, startDateHour, startDateMinute, endDateMonth, endDateDay, endDateYear, endDateHour, endDateMinute, maxAttendees, price); } else { ClassEntryLocalServiceUtil.updateClassEntry(themeDisplay.getUserId(), classEntryId, title, description, startDateMonth, startDateDay, startDateYear, startDateHour, startDateMinute, endDateMonth, endDateDay, endDateYear, endDateHour, endDateMinute, maxAttendees, price); } }
From source file:com.liferay.expando.web.internal.portlet.ExpandoPortlet.java
License:Open Source License
protected Serializable getValue(PortletRequest portletRequest, String name, int type) throws PortalException { String delimiter = StringPool.COMMA; Serializable value = null;//from w ww. jav a2 s .c o m if (type == ExpandoColumnConstants.BOOLEAN) { value = ParamUtil.getBoolean(portletRequest, name); } else if (type == ExpandoColumnConstants.BOOLEAN_ARRAY) { } else if (type == ExpandoColumnConstants.DATE) { User user = _portal.getUser(portletRequest); int valueDateMonth = ParamUtil.getInteger(portletRequest, name + "Month"); int valueDateDay = ParamUtil.getInteger(portletRequest, name + "Day"); int valueDateYear = ParamUtil.getInteger(portletRequest, name + "Year"); int valueDateHour = ParamUtil.getInteger(portletRequest, name + "Hour"); int valueDateMinute = ParamUtil.getInteger(portletRequest, name + "Minute"); int valueDateAmPm = ParamUtil.getInteger(portletRequest, name + "AmPm"); if (valueDateAmPm == Calendar.PM) { valueDateHour += 12; } value = _portal.getDate(valueDateMonth, valueDateDay, valueDateYear, valueDateHour, valueDateMinute, user.getTimeZone(), ValueDataException.class); } else if (type == ExpandoColumnConstants.DATE_ARRAY) { } else if (type == ExpandoColumnConstants.DOUBLE) { value = ParamUtil.getDouble(portletRequest, name); } else if (type == ExpandoColumnConstants.DOUBLE_ARRAY) { String paramValue = ParamUtil.getString(portletRequest, name); if (paramValue.contains(StringPool.NEW_LINE)) { delimiter = StringPool.NEW_LINE; } String[] values = StringUtil.split(paramValue, delimiter); value = GetterUtil.getDoubleValues(values); } else if (type == ExpandoColumnConstants.FLOAT) { value = ParamUtil.getFloat(portletRequest, name); } else if (type == ExpandoColumnConstants.FLOAT_ARRAY) { String paramValue = ParamUtil.getString(portletRequest, name); if (paramValue.contains(StringPool.NEW_LINE)) { delimiter = StringPool.NEW_LINE; } String[] values = StringUtil.split(paramValue, delimiter); value = GetterUtil.getFloatValues(values); } else if (type == ExpandoColumnConstants.INTEGER) { value = ParamUtil.getInteger(portletRequest, name); } else if (type == ExpandoColumnConstants.INTEGER_ARRAY) { String paramValue = ParamUtil.getString(portletRequest, name); if (paramValue.contains(StringPool.NEW_LINE)) { delimiter = StringPool.NEW_LINE; } String[] values = StringUtil.split(paramValue, delimiter); value = GetterUtil.getIntegerValues(values); } else if (type == ExpandoColumnConstants.LONG) { value = ParamUtil.getLong(portletRequest, name); } else if (type == ExpandoColumnConstants.LONG_ARRAY) { String paramValue = ParamUtil.getString(portletRequest, name); if (paramValue.contains(StringPool.NEW_LINE)) { delimiter = StringPool.NEW_LINE; } String[] values = StringUtil.split(paramValue, delimiter); value = GetterUtil.getLongValues(values); } else if (type == ExpandoColumnConstants.NUMBER) { value = ParamUtil.getNumber(portletRequest, name); } else if (type == ExpandoColumnConstants.NUMBER_ARRAY) { String paramValue = ParamUtil.getString(portletRequest, name); if (paramValue.contains(StringPool.NEW_LINE)) { delimiter = StringPool.NEW_LINE; } String[] values = StringUtil.split(paramValue, delimiter); value = GetterUtil.getNumberValues(values); } else if (type == ExpandoColumnConstants.SHORT) { value = ParamUtil.getShort(portletRequest, name); } else if (type == ExpandoColumnConstants.SHORT_ARRAY) { String paramValue = ParamUtil.getString(portletRequest, name); if (paramValue.contains(StringPool.NEW_LINE)) { delimiter = StringPool.NEW_LINE; } String[] values = StringUtil.split(paramValue, delimiter); value = GetterUtil.getShortValues(values); } else if (type == ExpandoColumnConstants.STRING_ARRAY) { String paramValue = ParamUtil.getString(portletRequest, name); if (paramValue.contains(StringPool.NEW_LINE)) { delimiter = StringPool.NEW_LINE; } value = StringUtil.split(paramValue, delimiter); } else if (type == ExpandoColumnConstants.STRING_LOCALIZED) { value = (Serializable) LocalizationUtil.getLocalizationMap(portletRequest, name); } else { value = ParamUtil.getString(portletRequest, name); } return value; }
From source file:com.liferay.journal.web.internal.portlet.action.CopyArticleMVCActionCommand.java
License:Open Source License
protected void copyArticle(ActionRequest actionRequest) throws Exception { long groupId = ParamUtil.getLong(actionRequest, "groupId"); String oldArticleId = ParamUtil.getString(actionRequest, "oldArticleId"); String newArticleId = ParamUtil.getString(actionRequest, "newArticleId"); boolean autoArticleId = ParamUtil.getBoolean(actionRequest, "autoArticleId"); double version = ParamUtil.getDouble(actionRequest, "version"); _journalArticleService.copyArticle(groupId, oldArticleId, newArticleId, autoArticleId, version); }
From source file:com.liferay.journal.web.internal.portlet.JournalPortlet.java
License:Open Source License
@Override public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, PortletException { resourceRequest.setAttribute(JournalWebConfiguration.class.getName(), _journalWebConfiguration); String resourceID = GetterUtil.getString(resourceRequest.getResourceID()); HttpServletRequest request = _portal.getHttpServletRequest(resourceRequest); HttpServletResponse response = _portal.getHttpServletResponse(resourceResponse); if (resourceID.equals("compareVersions")) { ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); long groupId = ParamUtil.getLong(resourceRequest, "groupId"); String articleId = ParamUtil.getString(resourceRequest, "articleId"); double sourceVersion = ParamUtil.getDouble(resourceRequest, "filterSourceVersion"); double targetVersion = ParamUtil.getDouble(resourceRequest, "filterTargetVersion"); String languageId = ParamUtil.getString(resourceRequest, "languageId"); String diffHtmlResults = null; try {/*from ww w.ja v a 2s .c o m*/ diffHtmlResults = JournalUtil.diffHtml(groupId, articleId, sourceVersion, targetVersion, languageId, new PortletRequestModel(resourceRequest, resourceResponse), themeDisplay); } catch (CompareVersionsException cve) { resourceRequest.setAttribute(WebKeys.DIFF_VERSION, cve.getVersion()); } catch (Exception e) { try { _portal.sendError(e, request, response); } catch (ServletException se) { } } resourceRequest.setAttribute(WebKeys.DIFF_HTML_RESULTS, diffHtmlResults); PortletSession portletSession = resourceRequest.getPortletSession(); PortletContext portletContext = portletSession.getPortletContext(); PortletRequestDispatcher portletRequestDispatcher = portletContext .getRequestDispatcher("/compare_versions_diff_html.jsp"); portletRequestDispatcher.include(resourceRequest, resourceResponse); } else { super.serveResource(resourceRequest, resourceResponse); } }
From source file:com.liferay.journal.web.internal.portlet.JournalPortlet.java
License:Open Source License
public void updateArticle(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { UploadException uploadException = (UploadException) actionRequest.getAttribute(WebKeys.UPLOAD_EXCEPTION); if (uploadException != null) { Throwable cause = uploadException.getCause(); if (uploadException.isExceededLiferayFileItemSizeLimit()) { throw new LiferayFileItemException(cause); }//from w ww . j a v a2s .com if (uploadException.isExceededFileSizeLimit() || uploadException.isExceededUploadRequestSizeLimit()) { throw new ArticleContentSizeException(cause); } throw new PortalException(cause); } UploadPortletRequest uploadPortletRequest = _portal.getUploadPortletRequest(actionRequest); if (_log.isDebugEnabled()) { _log.debug("Updating article " + MapUtil.toString(uploadPortletRequest.getParameterMap())); } String actionName = ParamUtil.getString(actionRequest, ActionRequest.ACTION_NAME); long groupId = ParamUtil.getLong(uploadPortletRequest, "groupId"); long folderId = ParamUtil.getLong(uploadPortletRequest, "folderId"); long classNameId = ParamUtil.getLong(uploadPortletRequest, "classNameId"); long classPK = ParamUtil.getLong(uploadPortletRequest, "classPK"); String articleId = ParamUtil.getString(uploadPortletRequest, "articleId"); boolean autoArticleId = ParamUtil.getBoolean(uploadPortletRequest, "autoArticleId"); double version = ParamUtil.getDouble(uploadPortletRequest, "version"); Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(actionRequest, "titleMapAsXML"); Map<Locale, String> descriptionMap = LocalizationUtil.getLocalizationMap(actionRequest, "descriptionMapAsXML"); ServiceContext serviceContext = ServiceContextFactory.getInstance(JournalArticle.class.getName(), uploadPortletRequest); String ddmStructureKey = ParamUtil.getString(uploadPortletRequest, "ddmStructureKey"); DDMStructure ddmStructure = _ddmStructureLocalService.getStructure(_portal.getSiteGroupId(groupId), _portal.getClassNameId(JournalArticle.class), ddmStructureKey, true); Fields fields = DDMUtil.getFields(ddmStructure.getStructureId(), serviceContext); String content = _journalConverter.getContent(ddmStructure, fields); String ddmTemplateKey = ParamUtil.getString(uploadPortletRequest, "ddmTemplateKey"); String layoutUuid = ParamUtil.getString(uploadPortletRequest, "layoutUuid"); Layout targetLayout = JournalUtil.getArticleLayout(layoutUuid, groupId); if (targetLayout == null) { layoutUuid = null; } int displayDateMonth = ParamUtil.getInteger(uploadPortletRequest, "displayDateMonth"); int displayDateDay = ParamUtil.getInteger(uploadPortletRequest, "displayDateDay"); int displayDateYear = ParamUtil.getInteger(uploadPortletRequest, "displayDateYear"); int displayDateHour = ParamUtil.getInteger(uploadPortletRequest, "displayDateHour"); int displayDateMinute = ParamUtil.getInteger(uploadPortletRequest, "displayDateMinute"); int displayDateAmPm = ParamUtil.getInteger(uploadPortletRequest, "displayDateAmPm"); if (displayDateAmPm == Calendar.PM) { displayDateHour += 12; } int expirationDateMonth = ParamUtil.getInteger(uploadPortletRequest, "expirationDateMonth"); int expirationDateDay = ParamUtil.getInteger(uploadPortletRequest, "expirationDateDay"); int expirationDateYear = ParamUtil.getInteger(uploadPortletRequest, "expirationDateYear"); int expirationDateHour = ParamUtil.getInteger(uploadPortletRequest, "expirationDateHour"); int expirationDateMinute = ParamUtil.getInteger(uploadPortletRequest, "expirationDateMinute"); int expirationDateAmPm = ParamUtil.getInteger(uploadPortletRequest, "expirationDateAmPm"); boolean neverExpire = ParamUtil.getBoolean(uploadPortletRequest, "neverExpire"); if (!PropsValues.SCHEDULER_ENABLED) { neverExpire = true; } if (expirationDateAmPm == Calendar.PM) { expirationDateHour += 12; } int reviewDateMonth = ParamUtil.getInteger(uploadPortletRequest, "reviewDateMonth"); int reviewDateDay = ParamUtil.getInteger(uploadPortletRequest, "reviewDateDay"); int reviewDateYear = ParamUtil.getInteger(uploadPortletRequest, "reviewDateYear"); int reviewDateHour = ParamUtil.getInteger(uploadPortletRequest, "reviewDateHour"); int reviewDateMinute = ParamUtil.getInteger(uploadPortletRequest, "reviewDateMinute"); int reviewDateAmPm = ParamUtil.getInteger(uploadPortletRequest, "reviewDateAmPm"); boolean neverReview = ParamUtil.getBoolean(uploadPortletRequest, "neverReview"); if (!PropsValues.SCHEDULER_ENABLED) { neverReview = true; } if (reviewDateAmPm == Calendar.PM) { reviewDateHour += 12; } boolean indexable = ParamUtil.getBoolean(uploadPortletRequest, "indexable"); boolean smallImage = ParamUtil.getBoolean(uploadPortletRequest, "smallImage"); String smallImageURL = ParamUtil.getString(uploadPortletRequest, "smallImageURL"); File smallFile = uploadPortletRequest.getFile("smallFile"); String articleURL = ParamUtil.getString(uploadPortletRequest, "articleURL"); JournalArticle article = null; String oldUrlTitle = StringPool.BLANK; if (actionName.equals("addArticle")) { // Add article article = _journalArticleService.addArticle(groupId, folderId, classNameId, classPK, articleId, autoArticleId, titleMap, descriptionMap, content, ddmStructureKey, ddmTemplateKey, layoutUuid, displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, expirationDateMonth, expirationDateDay, expirationDateYear, expirationDateHour, expirationDateMinute, neverExpire, reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour, reviewDateMinute, neverReview, indexable, smallImage, smallImageURL, smallFile, null, articleURL, serviceContext); } else { // Update article article = _journalArticleService.getArticle(groupId, articleId, version); String tempOldUrlTitle = article.getUrlTitle(); if (actionName.equals("previewArticle") || actionName.equals("updateArticle")) { article = _journalArticleService.updateArticle(groupId, folderId, articleId, version, titleMap, descriptionMap, content, ddmStructureKey, ddmTemplateKey, layoutUuid, displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, expirationDateMonth, expirationDateDay, expirationDateYear, expirationDateHour, expirationDateMinute, neverExpire, reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour, reviewDateMinute, neverReview, indexable, smallImage, smallImageURL, smallFile, null, articleURL, serviceContext); } if (!tempOldUrlTitle.equals(article.getUrlTitle())) { oldUrlTitle = tempOldUrlTitle; } } // Recent articles JournalUtil.addRecentArticle(actionRequest, article); // Journal content String portletResource = ParamUtil.getString(actionRequest, "portletResource"); long referringPlid = ParamUtil.getLong(actionRequest, "referringPlid"); if (Validator.isNotNull(portletResource) && (referringPlid > 0)) { Layout layout = _layoutLocalService.getLayout(referringPlid); PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getStrictPortletSetup(layout, portletResource); if (portletPreferences != null) { portletPreferences.setValue("groupId", String.valueOf(article.getGroupId())); portletPreferences.setValue("articleId", article.getArticleId()); portletPreferences.store(); updateContentSearch(actionRequest, portletResource, article.getArticleId()); } } sendEditArticleRedirect(actionRequest, actionResponse, article, oldUrlTitle); long ddmStructureClassNameId = _portal.getClassNameId(DDMStructure.class); if (article.getClassNameId() == ddmStructureClassNameId) { String ddmPortletId = PortletProviderUtil.getPortletId(DDMStructure.class.getName(), Action.EDIT); MultiSessionMessages.add(actionRequest, ddmPortletId + "requestProcessed"); } }
From source file:com.liferay.journal.web.internal.search.ArticleDisplayTerms.java
License:Open Source License
public ArticleDisplayTerms(PortletRequest portletRequest) { super(portletRequest); articleId = ParamUtil.getString(portletRequest, ARTICLE_ID); content = ParamUtil.getString(portletRequest, CONTENT); ddmStructureKey = ParamUtil.getString(portletRequest, DDM_STRUCTURE_KEY); ddmTemplateKey = ParamUtil.getString(portletRequest, DDM_TEMPLATE_KEY); description = ParamUtil.getString(portletRequest, DESCRIPTION); folderId = ParamUtil.getLong(portletRequest, FOLDER_ID); navigation = ParamUtil.getString(portletRequest, NAVIGATION); status = ParamUtil.getInteger(portletRequest, STATUS); title = ParamUtil.getString(portletRequest, TITLE); version = ParamUtil.getDouble(portletRequest, VERSION); groupId = setGroupId(portletRequest); }
From source file:com.liferay.journal.web.internal.search.ArticleSearchTerms.java
License:Open Source License
public ArticleSearchTerms(PortletRequest portletRequest) { super(portletRequest); articleId = DAOParamUtil.getString(portletRequest, ARTICLE_ID); content = DAOParamUtil.getString(portletRequest, CONTENT); ddmStructureKey = DAOParamUtil.getString(portletRequest, DDM_STRUCTURE_KEY); ddmTemplateKey = DAOParamUtil.getString(portletRequest, DDM_TEMPLATE_KEY); description = DAOParamUtil.getString(portletRequest, DESCRIPTION); status = ParamUtil.getInteger(portletRequest, STATUS); title = DAOParamUtil.getString(portletRequest, TITLE); version = ParamUtil.getDouble(portletRequest, VERSION); groupId = setGroupId(portletRequest); }
From source file:com.liferay.knowledgebase.admin.portlet.AdminPortlet.java
License:Open Source License
public void updateKBArticlesPriorities(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Enumeration<String> enu = actionRequest.getParameterNames(); Map<Long, Double> resourcePrimKeyToPriorityMap = new HashMap<Long, Double>(); while (enu.hasMoreElements()) { String name = enu.nextElement(); if (!name.startsWith("priority")) { continue; }//from ww w.ja v a 2 s. c o m double priority = ParamUtil.getDouble(actionRequest, name); long resourcePrimKey = GetterUtil.getLong(name.substring(8)); resourcePrimKeyToPriorityMap.put(resourcePrimKey, priority); } KBArticleServiceUtil.updateKBArticlesPriorities(themeDisplay.getScopeGroupId(), resourcePrimKeyToPriorityMap); }
From source file:com.liferay.knowledgebase.portlet.BaseKBPortlet.java
License:Open Source License
public void moveKBObject(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { long resourceClassNameId = ParamUtil.getLong(actionRequest, "resourceClassNameId"); long resourcePrimKey = ParamUtil.getLong(actionRequest, "resourcePrimKey"); long parentResourceClassNameId = ParamUtil.getLong(actionRequest, "parentResourceClassNameId", PortalUtil.getClassNameId(KBFolderConstants.getClassName())); long parentResourcePrimKey = ParamUtil.getLong(actionRequest, "parentResourcePrimKey", KBFolderConstants.DEFAULT_PARENT_FOLDER_ID); double priority = ParamUtil.getDouble(actionRequest, "priority"); long kbArticleClassNameId = PortalUtil.getClassNameId(KBArticleConstants.getClassName()); if (resourceClassNameId == kbArticleClassNameId) { KBArticleServiceUtil.moveKBArticle(resourcePrimKey, parentResourceClassNameId, parentResourcePrimKey, priority);// ww w .j av a 2 s . c o m } else { KBFolderServiceUtil.moveKBFolder(resourcePrimKey, parentResourcePrimKey); } }