List of usage examples for com.liferay.portal.kernel.bean BeanPropertiesUtil getString
public static String getString(Object bean, String param)
From source file:com.liferay.alloy.mvc.AlloyPermission.java
License:Open Source License
public static boolean contains(ThemeDisplay themeDisplay, BaseModel<?> baseModel, String action) { return contains(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), BeanPropertiesUtil.getString(baseModel, "modelClassName"), (Long) baseModel.getPrimaryKeyObj(), StringUtil.toUpperCase(action)); }
From source file:com.liferay.dynamic.data.mapping.model.impl.DDMStructureImpl.java
License:Open Source License
@Override public String getFieldProperty(String fieldName, String property) throws PortalException { DDMFormField ddmFormField = getDDMFormField(fieldName); return BeanPropertiesUtil.getString(ddmFormField, property); }
From source file:com.liferay.knowledgebase.admin.util.AdminUtil.java
License:Open Source License
public static String getKBArticleDiff(long resourcePrimKey, int sourceVersion, int targetVersion, String param) throws Exception { if (sourceVersion < KBArticleConstants.DEFAULT_VERSION) { sourceVersion = KBArticleConstants.DEFAULT_VERSION; }/* w ww . jav a2 s . co m*/ if (sourceVersion == targetVersion) { KBArticle kbArticle = KBArticleLocalServiceUtil.getKBArticle(resourcePrimKey, targetVersion); return BeanPropertiesUtil.getString(kbArticle, param); } KBArticle sourceKBArticle = KBArticleLocalServiceUtil.getKBArticle(resourcePrimKey, sourceVersion); KBArticle targetKBArticle = KBArticleLocalServiceUtil.getKBArticle(resourcePrimKey, targetVersion); String sourceHtml = BeanPropertiesUtil.getString(sourceKBArticle, param); String targetHtml = BeanPropertiesUtil.getString(targetKBArticle, param); String diff = DiffHtmlUtil.diff(new UnsyncStringReader(sourceHtml), new UnsyncStringReader(targetHtml)); Source source = new Source(diff); OutputDocument outputDocument = new OutputDocument(source); for (Element element : source.getAllElements()) { StringBundler sb = new StringBundler(4); Attributes attributes = element.getAttributes(); if (attributes == null) { continue; } Attribute changeTypeAttribute = attributes.get("changeType"); if (changeTypeAttribute != null) { String changeTypeValue = changeTypeAttribute.getValue(); if (changeTypeValue.contains("diff-added-image")) { sb.append("border: 10px solid #CFC; "); } else if (changeTypeValue.contains("diff-changed-image")) { sb.append("border: 10px solid #C6C6FD; "); } else if (changeTypeValue.contains("diff-removed-image")) { sb.append("border: 10px solid #FDC6C6; "); } } Attribute classAttribute = attributes.get("class"); if (classAttribute != null) { String classValue = classAttribute.getValue(); if (classValue.contains("diff-html-added")) { sb.append("background-color: #CFC; "); } else if (classValue.contains("diff-html-changed")) { sb.append("background-color: #C6C6FD; "); } else if (classValue.contains("diff-html-removed")) { sb.append("background-color: #FDC6C6; "); sb.append("text-decoration: line-through; "); } } if (Validator.isNull(sb.toString())) { continue; } Attribute styleAttribute = attributes.get("style"); if (styleAttribute != null) { sb.append(GetterUtil.getString(styleAttribute.getValue())); } Map<String, String> map = outputDocument.replace(attributes, false); map.put("style", sb.toString()); } return outputDocument.toString(); }
From source file:com.liferay.knowledgebase.service.impl.KBArticleLocalServiceImpl.java
License:Open Source License
protected Map<String, String> getEmailKBArticleDiffs(KBArticle kbArticle) { Map<String, String> emailKBArticleDiffs = new HashMap<String, String>(); for (String param : new String[] { "content", "title" }) { String value = BeanPropertiesUtil.getString(kbArticle, param); try {//from www . j ava 2 s . c o m value = AdminUtil.getKBArticleDiff(kbArticle.getResourcePrimKey(), kbArticle.getVersion() - 1, kbArticle.getVersion(), param); } catch (Exception e) { _log.error(e, e); } emailKBArticleDiffs.put(param, value); } return emailKBArticleDiffs; }
From source file:com.liferay.mobile.device.rules.web.internal.portlet.action.EditActionMVCRenderCommand.java
License:Open Source License
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) { try {//from www . j a v a2s.co m long actionId = ParamUtil.getLong(renderRequest, "actionId"); MDRAction action = _mdrActionService.fetchAction(actionId); renderRequest.setAttribute(MDRWebKeys.MOBILE_DEVICE_RULES_RULE_GROUP_ACTION, action); String type = BeanPropertiesUtil.getString(action, "type"); renderRequest.setAttribute(MDRWebKeys.MOBILE_DEVICE_RULES_RULE_GROUP_ACTION_TYPE, type); String editorJSP = ActionUtil.getActionEditorJSP(type); renderRequest.setAttribute(MDRWebKeys.MOBILE_DEVICE_RULES_RULE_GROUP_ACTION_EDITOR_JSP, editorJSP); long ruleGroupInstanceId = BeanParamUtil.getLong(action, renderRequest, "ruleGroupInstanceId"); MDRRuleGroupInstance ruleGroupInstance = _mdrRuleGroupInstanceLocalService .getMDRRuleGroupInstance(ruleGroupInstanceId); renderRequest.setAttribute(MDRWebKeys.MOBILE_DEVICE_RULES_RULE_GROUP_INSTANCE, ruleGroupInstance); MDRRuleGroup ruleGroup = ruleGroupInstance.getRuleGroup(); renderRequest.setAttribute(MDRWebKeys.MOBILE_DEVICE_RULES_RULE_GROUP, ruleGroup); return "/edit_action.jsp"; } catch (PortalException pe) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(pe, pe); } return "/error.jsp"; } }
From source file:com.liferay.mobile.device.rules.web.internal.portlet.action.EditRuleMVCRenderCommand.java
License:Open Source License
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) { try {//from w w w. j a va 2s. c o m long ruleId = ParamUtil.getLong(renderRequest, "ruleId"); MDRRule rule = _mdrRuleService.fetchRule(ruleId); renderRequest.setAttribute(MDRWebKeys.MOBILE_DEVICE_RULES_RULE, rule); String type = BeanPropertiesUtil.getString(rule, "type"); renderRequest.setAttribute(MDRWebKeys.MOBILE_DEVICE_RULES_RULE_TYPE, type); renderRequest.setAttribute(MDRWebKeys.MOBILE_DEVICE_RULES_RULE_EDITOR_JSP, ActionUtil.getRuleEditorJSP(type)); long ruleGroupId = BeanParamUtil.getLong(rule, renderRequest, "ruleGroupId"); MDRRuleGroup ruleGroup = _mdrRuleGroupService.getRuleGroup(ruleGroupId); renderRequest.setAttribute(MDRWebKeys.MOBILE_DEVICE_RULES_RULE_GROUP, ruleGroup); return "/edit_rule.jsp"; } catch (PortalException pe) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(pe, pe); } return "/error.jsp"; } }
From source file:com.liferay.opensocial.shindig.util.SerializerUtil.java
License:Open Source License
public static Map<String, Serializable> toExpandoAttributes(Object bean, Object[] fields, long companyId, String className) throws PortalException { ExpandoBridge expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(companyId, className); for (Object field : fields) { String fieldName = field.toString(); String value = BeanPropertiesUtil.getString(bean, fieldName); if ((value != null) && !expandoBridge.hasAttribute(fieldName)) { expandoBridge.addAttribute(fieldName); }//ww w. j av a2 s . com } Map<String, Serializable> expandoBridgeAttributes = new LinkedHashMap<String, Serializable>(); copyProperties(bean, expandoBridgeAttributes, fields); return expandoBridgeAttributes; }
From source file:com.liferay.osb.scv.connector.internal.jsonws.SCVUserJSONWS.java
License:Open Source License
protected JSONObject addUser(JSONObject jsonObject, BaseModel baseModel, List<String> fields) { if ((fields == null) || fields.isEmpty()) { return null; }//from w ww. j av a2 s.co m ExpandoBridge expandoBridge = baseModel.getExpandoBridge(); for (String field : fields) { if (field.startsWith(_CUSTOM_FIELD)) { Serializable attribute = expandoBridge.getAttribute(field.replace(_CUSTOM_FIELD, StringPool.BLANK)); jsonObject.put(field, String.valueOf(attribute)); } else { String value = BeanPropertiesUtil.getString(baseModel, field); jsonObject.put(field, value); } } return jsonObject; }
From source file:com.liferay.osb.scv.connector.internal.model.SCVModel.java
License:Open Source License
@Override public void onAfterUpdate(T model) throws ModelListenerException { long mappingDataSourceId = MappingDataSourceUtil.getMappingDataSourceId(); if (mappingDataSourceId == 0) { return;//from w ww . ja v a2 s. com } Map<String, Object> modelAttributes = model.getModelAttributes(); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); Map<String, String> map = new HashMap<>(); for (Map.Entry<String, Object> entry : modelAttributes.entrySet()) { String key = entry.getKey(); if (ArrayUtil.contains(getRequiredFields(), key) || key.equals(getPrimaryKeyField())) { map.put(entry.getKey(), String.valueOf(entry.getValue())); continue; } if (!ArrayUtil.contains(getAvailableFields(), key)) { continue; } String value = BeanPropertiesUtil.getString(_models.get(model.getPrimaryKeyObj()), entry.getKey()); if (value.equals(BeanPropertiesUtil.getString(model, entry.getKey()))) { continue; } map.put(entry.getKey(), String.valueOf(entry.getValue())); } if (map.isEmpty()) { return; } List<Object> objects = new ArrayList<>(); objects.add(map); jsonObject.put(model.getModelClass().getSimpleName(), objects); Map<String, String> parameters = new HashMap<>(); parameters.put("mappingDataSourceId", String.valueOf(MappingDataSourceUtil.getMappingDataSourceId())); parameters.put("json", jsonObject.toJSONString()); try { addData(parameters); } catch (Exception e) { throw new ModelListenerException(e); } }
From source file:com.liferay.portlet.mobiledevicerules.action.EditActionAction.java
License:Open Source License
@Override public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { long actionId = ParamUtil.getLong(renderRequest, "actionId"); MDRAction action = MDRActionServiceUtil.fetchAction(actionId); renderRequest.setAttribute(WebKeys.MOBILE_DEVICE_RULES_RULE_GROUP_ACTION, action); String type = BeanPropertiesUtil.getString(action, "type"); renderRequest.setAttribute(WebKeys.MOBILE_DEVICE_RULES_RULE_GROUP_ACTION_TYPE, type); String editorJSP = getEditorJSP(type); renderRequest.setAttribute(WebKeys.MOBILE_DEVICE_RULES_RULE_GROUP_ACTION_EDITOR_JSP, editorJSP); long ruleGroupInstanceId = BeanParamUtil.getLong(action, renderRequest, "ruleGroupInstanceId"); MDRRuleGroupInstance ruleGroupInstance = MDRRuleGroupInstanceLocalServiceUtil .getMDRRuleGroupInstance(ruleGroupInstanceId); renderRequest.setAttribute(WebKeys.MOBILE_DEVICE_RULES_RULE_GROUP_INSTANCE, ruleGroupInstance); return mapping.findForward("portlet.mobile_device_rules.edit_action"); }