List of usage examples for com.liferay.portal.kernel.util ParamUtil getString
public static String getString(ServiceContext serviceContext, String param, String defaultValue)
From source file:br.com.thiagomoreira.liferay.plugins.portalpropertiesprettier.PortalPropertiesPrettierPortlet.java
License:Apache License
protected String prettify(PortletRequest request) throws IOException, PortletException { UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(request); String liferayVersion = ParamUtil.getString(uploadPortletRequest, "liferayVersion", "6.2.3-ga4"); boolean printDefaultValue = ParamUtil.getBoolean(uploadPortletRequest, "printDefaultValue"); Properties customProperties = PropertiesUtil .load(uploadPortletRequest.getFileAsStream("portalPropertiesFile"), "UTF-8"); String prettyProperties = prettier.prettify(customProperties, liferayVersion, printDefaultValue); incrementCounter(request);//from w w w .ja va 2s . c om return prettyProperties; }
From source file:com.beorn.onlinepayment.config.ConfigUtil.java
License:Open Source License
/** * @param request//from ww w. j a v a 2s .co m * the request to retreive the configuration from * @param configDescription * the description of the configuration to retreive * @return a JSONObject corresponding to the configuration defined by a * ConfigDescription from a PortletRequest */ public static JSONObject getConfig(PortletRequest request, ConfigDescription configDescription) { JSONObject config = JSONFactoryUtil.createJSONObject(); for (ConfigGroup configGroupDescription : configDescription.getConfigGroups()) { JSONObject configGroup = JSONFactoryUtil.createJSONObject(); for (ConfigParameter configParameterDescription : configGroupDescription.getConfigParameters()) { String parameterName = getParameterName(configGroupDescription.getKey(), configParameterDescription.getKey()); String parameterValue = ParamUtil.getString(request, parameterName, configParameterDescription.getDefault()); configGroup.put(configParameterDescription.getKey(), parameterValue); } config.put(configGroupDescription.getKey(), configGroup); } return config; }
From source file:com.commsen.liferay.multidevice.rules.DeviceRulesProviderImpl.java
License:Open Source License
protected void saveRule(PortletRequest request, List<String> errorMessages) { Rule themeRule;//from www .jav a 2 s.c o m try { themeRule = RuleLocalServiceUtil.createRule(CounterLocalServiceUtil.increment(Rule.class.getName())); } catch (SystemException e) { errorMessages.add("failed-to-create-rule"); log.error("Failed to create device rule!", e); return; } // rule context themeRule.setCompanyId(PortalUtil.getCompanyId(request)); themeRule.setGroupId(ParamUtil.getLong(request, PARAM_LIVE_GROUP_ID, 0)); themeRule.setLayoutId(ParamUtil.getLong(request, PARAM_LAYPOUT_ID, 0)); // rule parameters boolean emptyRule = true; String tmp = ParamUtil.getString(request, PARAM_BRAND, null); if (!StringUtils.isBlank(tmp)) { emptyRule = false; themeRule.setBrand(tmp); } tmp = ParamUtil.getString(request, PARAM_MODEL, null); if (!StringUtils.isBlank(tmp)) { emptyRule = false; themeRule.setModel(tmp); } tmp = ParamUtil.getString(request, PARAM_OS, null); if (!StringUtils.isBlank(tmp)) { emptyRule = false; themeRule.setOs(tmp); } tmp = ParamUtil.getString(request, PARAM_OS_VERSION, null); if (!StringUtils.isBlank(tmp)) { emptyRule = false; themeRule.setOsVersion(tmp); } tmp = ParamUtil.getString(request, PARAM_BROWSER, null); if (!StringUtils.isBlank(tmp)) { emptyRule = false; themeRule.setBrowser(tmp); } tmp = ParamUtil.getString(request, PARAM_BROWSER_VERSION, null); if (!StringUtils.isBlank(tmp)) { emptyRule = false; themeRule.setBrowserVersion(tmp); } tmp = ParamUtil.getString(request, PARAM_POINTING_METHOD, null); if (!StringUtils.isBlank(tmp)) { emptyRule = false; themeRule.setPointingMethod(tmp); } tmp = ParamUtil.getString(request, PARAM_IS_TABLET, null); if ("yes".equalsIgnoreCase(tmp)) { emptyRule = false; themeRule.setTablet(Boolean.TRUE.toString()); } else if ("no".equalsIgnoreCase(tmp)) { emptyRule = false; themeRule.setTablet(Boolean.FALSE.toString()); } tmp = ParamUtil.getString(request, PARAM_HAS_QWERTY_KEYBOARD, null); if ("yes".equalsIgnoreCase(tmp)) { emptyRule = false; themeRule.setQwertyKeyboad(Boolean.TRUE.toString()); } else if ("no".equalsIgnoreCase(tmp)) { emptyRule = false; themeRule.setQwertyKeyboad(Boolean.FALSE.toString()); } if (emptyRule) { errorMessages.add("rule-is-empty"); log.error("Rule is empty. Not saved!"); return; } String action = ParamUtil.getString(request, PARAM_RULE_ACTION, ChangeThemeAction.NAME); if (ChangeThemeAction.NAME.equalsIgnoreCase(action)) { themeRule.setAction(ChangeThemeAction.NAME); String themeId = ParamUtil.getString(request, PARAM_DYNAMIC_THEME_ID); String colorSchemeId = ParamUtil.getString(request, PARAM_DYNAMIC_COLOR_SCHEME_ID); themeRule.setThemeId(themeId); themeRule.setColorSchemeId(colorSchemeId); } if (RedirectAction.NAME.equalsIgnoreCase(action)) { themeRule.setAction(RedirectAction.NAME); String redirectRuleURL = ParamUtil.getString(request, PARAM_REDIRECT_RULE_URL); themeRule.setUrl(redirectRuleURL); } int priority = ParamUtil.getInteger(request, PARAM_RULE_PRIORITY, 100); themeRule.setPriority(priority); // save try { RuleLocalServiceUtil.addRule(themeRule); } catch (SystemException e) { errorMessages.add("failed-to-save-rule"); log.error("Failed to save theme rule!", e); return; } }
From source file:com.commsen.liferay.portlet.customglobalmarkup.CustomGlobalMarkupConfigurationPortlet.java
License:Open Source License
@ProcessAction(name = "save") public void saveMarkups(ActionRequest request, ActionResponse response) throws SystemException, PortalException { List<String> paramNames = Collections.list(request.getParameterNames()); long max_markup_length = 2000; Map<String, String> markup_hints = ModelHintsUtil.getHints(Markup.class.getName(), "markup"); if (markup_hints.containsKey("max-length")) { try {/*from w w w . j a v a2 s. c o m*/ max_markup_length = Long.parseLong(markup_hints.get("max-length")); } catch (NumberFormatException e) { _log.warn("Failed to parse max-length!", e); } } for (String key : paramNames) { if (key.startsWith("markup_")) { long id = Long.parseLong(key.substring(7)); Markup markup = MarkupLocalServiceUtil.getMarkup(id); if (markup != null) { if (ParamUtil.getBoolean(request, "delete_" + id)) { MarkupLocalServiceUtil.deleteMarkup(markup); } else { boolean changed = false; boolean error = false; // process text String markupText = ParamUtil.getString(request, key, ""); if (markupText.length() > max_markup_length) { error = true; SessionErrors.add(request, "custom-global-markup-error-too-long-" + id); } if (!markup.getMarkup().equals(markupText)) { changed = true; markup.setMarkup(markupText); } // process status boolean markupStatus = ParamUtil.getBoolean(request, "active_" + id); if (markup.getActive() != markupStatus) { changed = true; markup.setActive(markupStatus); } // process location short location = ParamUtil.getShort(request, "location_" + id, (short) -1); if (CustomGlobalMarkupLocation.isValid(location) && markup.getLocation() != location) { changed = true; markup.setLocation(location); } // finally if there are any changes update database if (error) { rememberMarkupInSession(request, markup); } else if (changed) { SessionMessages.add(request, "custom-global-markup-save-ok-" + id); MarkupLocalServiceUtil.updateMarkup(markup); } } } else { _log.warn("Markup with id " + id + " not found!"); } } } redirect(request, response); }
From source file:com.commsen.liferay.portlet.tailgate.TailgatePortlet.java
License:Open Source License
@ProcessAction(name = "saveConfig") public void saveConfig(final ActionRequest request, final ActionResponse response) throws SystemException, PortletException, IOException { final String filename = ParamUtil.getString(request, FILE_NAME, null); final int lines = ParamUtil.getInteger(request, LINES, 100); final String height = ParamUtil.getString(request, WINDOW_HEIGHT, "300px"); final PortletPreferences prefs = request.getPreferences(); prefs.setValue(FILE_NAME, filename); prefs.setValue(LINES, Integer.toString(lines)); prefs.setValue(WINDOW_HEIGHT, height); prefs.store();/*from w w w .ja va 2s .c o m*/ SessionMessages.add(request, "tailgate-message:config-saved"); initFileBuffer(request); }
From source file:com.dtt.portal.adminvbpq.search.VanBanDisplayTerms.java
License:Open Source License
public VanBanDisplayTerms(PortletRequest portletRequest) { super(portletRequest); ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); Date now = new Date(); Calendar startCalendar = Calendar.getInstance(); startCalendar.set(Calendar.DATE, 1); startCalendar.set(Calendar.MONTH, 0); Calendar endCalendar = Calendar.getInstance(); endCalendar.setTime(now);//from www . j a v a2 s .co m SimpleDateFormat sdf = new SimpleDateFormat(VanBanPhapQuyUtils.FORMAT_DATE_PATTERN); groupId = ParamUtil.getLong(portletRequest, GROUP_ID, themeDisplay.getScopeGroupId()); coQuanBanHanhId = ParamUtil.getLong(portletRequest, CO_QUAN_BAN_HANH_ID); if (coQuanBanHanhId > 0) { setCoQuanBanHanhIds(new long[] { coQuanBanHanhId }); } else { setCoQuanBanHanhIds(null); } linhVucVanBanId = ParamUtil.getLong(portletRequest, LINH_VUC_VAN_BAN_ID); if (linhVucVanBanId > 0) { setLinhVucVanBanIds(new long[] { linhVucVanBanId }); } else { setLinhVucVanBanIds(null); } loaiVanBanId = ParamUtil.getLong(portletRequest, LOAI_VAN_BAN_ID); if (loaiVanBanId > 0) { setLoaiVanBanIds(new long[] { loaiVanBanId }); } else { setLoaiVanBanIds(null); } startDate = ParamUtil.getString(portletRequest, START_DATE, sdf.format(startCalendar.getTime())); startDateObj = VanBanPhapQuyUtils.parseStringToDate(startDate); endDate = ParamUtil.getString(portletRequest, END_DATE, sdf.format(endCalendar.getTime())); endDateObj = VanBanPhapQuyUtils.parseStringToDate(endDate); status = ParamUtil.getInteger(portletRequest, STATUS, -1); if (status < 0) { setStatusObj(null); } else { setStatusObj(status); } }
From source file:com.evozon.evoportal.myaccount.builder.AccountOperationBuilder.java
public static ActionAccountOperation buildAccountActionOperation(ActionPhaseParameters app) throws PortalException, SystemException { ActionAccountOperation operation = null; String command = ParamUtil.getString(app.getRequest(), Constants.CMD, AccountOperationBuilder.DEFAULT); if (Constants.ADD.equals(command)) { operation = AccountOperationBuilder.buildAddAccountActionOperation(app); } else if (Constants.UPDATE.equals(command)) { operation = AccountOperationBuilder.buildUpdateAccountActionOperation(app); } else if (Constants.DEACTIVATE.equals(command) || MyAccountConstants.CANCEL_DEACTIVATION.equals(command)) { operation = AccountOperationBuilder.buildDeactivateAccountOperation(app); } else if (Constants.RESTORE.equals(command) || MyAccountConstants.CANCEL_ACTIVATION.equals(command)) { operation = AccountOperationBuilder.buildActivateAccountOperation(app); } else if (Constants.DELETE.equals(command)) { operation = AccountOperationBuilder.buildDeleteAccountActionOperation(app); } else {/*from w w w .j a v a 2 s .c om*/ operation = new DefaultAccountActionOperation(app); } return operation; }
From source file:com.evozon.evoportal.myaccount.builder.RequestAccountModelHolderBuilder.java
protected void addFreeDaysToFreeDaysModel(FreeDaysModel daysModel) { int freeDaysFromLastYear = ParamUtil.getInteger(request, "freeDaysLast", 0); int freeDaysInCurrentYear = ParamUtil.getInteger(request, "freeDaysCurrent", 0); int initialFreeDaysLast = ParamUtil.getInteger(request, "initialFreeDaysLast", 0); int adjustValue = ParamUtil.getInteger(request, "adjustValue", 0); if (adjustValue != 0) { String adjustment = ParamUtil.getString(request, "adjustSelection", StringPool.BLANK); if (adjustment.contains("freeDaysCurrentOption")) { freeDaysInCurrentYear += adjustValue; } else if (adjustment.contains("freeDaysLastOption")) { freeDaysFromLastYear += adjustValue; } else if (adjustment.contains("initialFreeDaysLastOption")) { initialFreeDaysLast += adjustValue; }/* w w w.jav a 2 s . co m*/ } daysModel.setFreeDaysFromLastYear(freeDaysFromLastYear); daysModel.setFreeDaysInCurrentYear(freeDaysInCurrentYear); daysModel.setRemainingFreeDaysFromLastYear(initialFreeDaysLast); }
From source file:com.evozon.evoportal.myaccount.builder.RequestAccountModelHolderBuilder.java
protected Date getDateFromRequest(String dateName) { Date dateObject = null;/*from w w w.ja va 2 s. c o m*/ String strDate = ParamUtil.getString(request, dateName, StringPool.BLANK); if (strDate.isEmpty()) { int day = ParamUtil.getInteger(request, dateName + "Day"); int month = ParamUtil.getInteger(request, dateName + "Month"); int year = ParamUtil.getInteger(request, dateName + "Year"); Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_MONTH, day); cal.set(Calendar.MONTH, month); cal.set(Calendar.YEAR, year); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); dateObject = cal.getTime(); } return dateObject; }
From source file:com.evozon.evoportal.my_account.util.MyAccountRequestUtil.java
private static FamilyMember getSpouseFromRequest(PortletRequest actionRequest) throws PortalException, SystemException { FamilyMember spouse = new FamilyMemberClp(); spouse.setFirstName(ParamUtil.getString(actionRequest, "spouseFirstName", StringPool.BLANK)); spouse.setLastName(ParamUtil.getString(actionRequest, "spouseLastName", StringPool.BLANK).trim()); spouse.setCNP(ParamUtil.getString(actionRequest, "spouseCNP", StringPool.BLANK)); spouse.setType(MyAccountConstants.SPOUSE); spouse.setMemberId(ParamUtil.getLong(actionRequest, "spouseId", 0l)); spouse.setUserBelongsId(PortalUtil.getUserId(actionRequest)); spouse.setNumar(StringPool.BLANK);//w w w . j a v a 2 s . c om spouse.setSeries(StringPool.BLANK); return !UserFamilyHandler.isFamilyMemberEmpty(spouse) ? spouse : null; }