List of usage examples for com.liferay.portal.kernel.util PropsUtil get
public static String get(String key)
From source file:com.liferay.documentlibrary.hook.filter.DLRecordFilter.java
License:Open Source License
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { boolean isLogsEnabled = GetterUtil.getBoolean(PropsUtil.get("document.download.logs.enabled"), Boolean.FALSE);//www . ja v a2s.com if (isLogsEnabled) { try { HttpServletRequest httpRequest = PortalUtil .getOriginalServletRequest((HttpServletRequest) servletRequest); String uri = (String) servletRequest.getAttribute(WebKeys.INVOKER_FILTER_URI); /** * In WebServerServlet(Parent servlet) it returns path like /1024/123/Document+Name/uuid * While in this filter URI is like /document/1024/123/Document+Name/uuid. So to use OOB methods * I have replaced intial /document/ with blank. */ uri = StringUtil.replaceFirst(uri, "/documents/", StringPool.BLANK); String[] pathArray = StringUtil.split(uri, CharPool.SLASH); if (Validator.isNumber(pathArray[0])) { User user = _getUser(httpRequest); PrincipalThreadLocal.setName(user.getUserId()); PrincipalThreadLocal.setPassword(PortalUtil.getUserPassword(httpRequest)); PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user); PermissionThreadLocal.setPermissionChecker(permissionChecker); FileEntry fileEntry = getFileEntry(pathArray); String remoteIpAddress = httpRequest.getRemoteAddr(); addDLRecordLog(fileEntry, user, remoteIpAddress); } //System.out.println("URI " + uri); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } } filterChain.doFilter(servletRequest, servletResponse); }
From source file:com.liferay.dynamic.data.mapping.internal.util.DDMIndexerImpl.java
License:Open Source License
@Override public String extractIndexableAttributes(DDMStructure ddmStructure, DDMFormValues ddmFormValues, Locale locale) {/*from w w w . j ava 2s . co m*/ Format dateFormat = FastDateFormatFactoryUtil .getSimpleDateFormat(PropsUtil.get(PropsKeys.INDEX_DATE_FORMAT_PATTERN)); StringBundler sb = new StringBundler(); Fields fields = toFields(ddmStructure, ddmFormValues); for (Field field : fields) { try { String indexType = ddmStructure.getFieldProperty(field.getName(), "indexType"); if (Validator.isNull(indexType)) { continue; } Serializable value = field.getValue(locale); if (value instanceof Boolean || value instanceof Number) { sb.append(value); sb.append(StringPool.SPACE); } else if (value instanceof Date) { sb.append(dateFormat.format(value)); sb.append(StringPool.SPACE); } else if (value instanceof Date[]) { Date[] dates = (Date[]) value; for (Date date : dates) { sb.append(dateFormat.format(date)); sb.append(StringPool.SPACE); } } else if (value instanceof Object[]) { Object[] values = (Object[]) value; for (Object object : values) { sb.append(object); sb.append(StringPool.SPACE); } } else { String valueString = String.valueOf(value); String type = field.getType(); if (type.equals(DDMImpl.TYPE_SELECT)) { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(valueString); String[] stringArray = ArrayUtil.toStringArray(jsonArray); sb.append(stringArray); sb.append(StringPool.SPACE); } else { if (type.equals(DDMImpl.TYPE_DDM_TEXT_HTML)) { valueString = HtmlUtil.extractText(valueString); } sb.append(valueString); sb.append(StringPool.SPACE); } } } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn(e, e); } } } return sb.toString(); }
From source file:com.liferay.evp.admin.service.ClpSerializer.java
License:Open Source License
public static String getServletContextName() { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; }/* w w w. j a va 2 s. c om*/ synchronized (ClpSerializer.class) { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; } try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps"); Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class }); String portletPropsServletContextName = (String) getMethod.invoke(null, "evp-portlet-deployment-context"); if (Validator.isNotNull(portletPropsServletContextName)) { _servletContextName = portletPropsServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portlet properties"); } } if (Validator.isNull(_servletContextName)) { try { String propsUtilServletContextName = PropsUtil.get("evp-portlet-deployment-context"); if (Validator.isNotNull(propsUtilServletContextName)) { _servletContextName = propsUtilServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portal properties"); } } } if (Validator.isNull(_servletContextName)) { _servletContextName = "evp-portlet"; } return _servletContextName; } }
From source file:com.liferay.examples.localizededitor.service.ClpSerializer.java
License:Open Source License
public static String getServletContextName() { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; }/* w w w . jav a2s . c om*/ synchronized (ClpSerializer.class) { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; } try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps"); Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class }); String portletPropsServletContextName = (String) getMethod.invoke(null, "simple-localized-editor-portlet-deployment-context"); if (Validator.isNotNull(portletPropsServletContextName)) { _servletContextName = portletPropsServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portlet properties"); } } if (Validator.isNull(_servletContextName)) { try { String propsUtilServletContextName = PropsUtil .get("simple-localized-editor-portlet-deployment-context"); if (Validator.isNotNull(propsUtilServletContextName)) { _servletContextName = propsUtilServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portal properties"); } } } if (Validator.isNull(_servletContextName)) { _servletContextName = "simple-localized-editor-portlet"; } return _servletContextName; } }
From source file:com.liferay.experts.service.ClpSerializer.java
License:Open Source License
public static String getServletContextName() { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; }//from ww w. j av a 2 s.c om synchronized (ClpSerializer.class) { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; } try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps"); Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class }); String portletPropsServletContextName = (String) getMethod.invoke(null, "experts-portlet-deployment-context"); if (Validator.isNotNull(portletPropsServletContextName)) { _servletContextName = portletPropsServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portlet properties"); } } if (Validator.isNull(_servletContextName)) { try { String propsUtilServletContextName = PropsUtil.get("experts-portlet-deployment-context"); if (Validator.isNotNull(propsUtilServletContextName)) { _servletContextName = propsUtilServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portal properties"); } } } if (Validator.isNull(_servletContextName)) { _servletContextName = "experts-portlet"; } return _servletContextName; } }
From source file:com.liferay.faces.bridge.demos.bean.CaptchaBacking.java
License:Open Source License
public void submit() { FacesContext facesContext = FacesContext.getCurrentInstance(); ExternalContext externalContext = facesContext.getExternalContext(); FacesContextHelper facesContextHelper = FacesContextHelperFactory .getFacesContextHelperInstance(externalContext); // If the user entered non-blank value for the captcha then validation was successful in the // PROCESS_VALIDATIONS phase of the JSF lifecycle. if ((captchaText != null) && (captchaText.trim().length() > 0)) { facesContextHelper.addGlobalInfoMessage(facesContext, "you-entered-the-correct-text-verification-code"); }/*from w w w . jav a 2 s . com*/ // Otherwise, the user entered a blank value for the captcha. else { // If the user checked the "Required" checkbox, then if (requiredChecked) { // If the portal:captcha component indicates that the value is required, then validation should have // failed in the PROCESS_VALIDATIONS phase of the JSF lifecycle and this method should never have been // called now in the INVOKE_APPLICATION phase. This indicates an error condition that should never // happen. UIViewRoot uiViewRoot = facesContext.getViewRoot(); Captcha captcha = (Captcha) uiViewRoot.findComponent(":f1:simpleCaptcha"); if (captcha.isRequired()) { facesContextHelper.addGlobalUnexpectedErrorMessage(); } // Otherwise, if the portal:captcha component indicates that the value is not required, then according // to the JavaDoc for the required attribute, that means the captcha was "inactive" because an // authenticated user has correctly entered the captcha the maximum number of required times. This does // not indicate an error condition. else { String maxChallenges = PropsUtil.get(PropsKeys.CAPTCHA_MAX_CHALLENGES); facesContextHelper.addGlobalInfoMessage(facesContext, "the-captcha-is-no-longer-enabled-since-the-user-entered-a-correct-value-x-times", maxChallenges); } } // Otherwise, since the user did not check the "Required" checkbox, it's OK that the user entered a blank // value. else { facesContextHelper.addGlobalInfoMessage(facesContext, "no-value-was-entered-for-the-non-required-captcha"); } } }
From source file:com.liferay.faces.demos.bean.RegistrantBackingBean.java
License:Open Source License
public boolean isCaptchaRendered() { if (captchaRendered == null) { captchaRendered = Boolean .valueOf(GetterUtil.getBoolean(PropsUtil.get(PropsKeys.CAPTCHA_CHECK_PORTAL_CREATE_ACCOUNT))); }//ww w . jav a 2 s. c o m return captchaRendered.booleanValue(); }
From source file:com.liferay.faces.portal.component.inputrichtext.InputRichText.java
License:Open Source License
@Override protected void validateValue(FacesContext facesContext, Object newValue) { super.validateValue(facesContext, newValue); if (isValid()) { String editorType = null; String editorKey = getEditorKey(); if (editorKey != null) { editorType = PropsUtil.get(editorKey); }/*w ww . j ava 2s . c om*/ RichText.Type richTextType; if ("ckeditor_bbcode".equals(editorType)) { richTextType = RichText.Type.BBCODE; } else if ("ckeditor_creole".equals(editorType)) { richTextType = RichText.Type.CREOLE; } else { richTextType = RichText.Type.HTML; } RichTextFactory richTextFactory = (RichTextFactory) FactoryExtensionFinder .getFactory(RichTextFactory.class); RichText richText = richTextFactory.getRichText(richTextType, newValue.toString()); int length = richText.getPlainTextLength(); int minimum = getMinPlainTextChars(); int maximum = getMaxPlainTextChars(); logger.debug("length=[{0}] minimum=[{1}] maximum=[{2}]", length, minimum, maximum); if ((minimum > 0) && (length < minimum)) { Object label = getAttributes().get("label"); Locale locale = facesContext.getViewRoot().getLocale(); FacesMessage facesMessage = getMessageContext().newFacesMessage(locale, FacesMessage.SEVERITY_ERROR, LengthValidator.MINIMUM_MESSAGE_ID, minimum, label); facesContext.addMessage(getClientId(), facesMessage); setValid(false); } if ((maximum > 0) && (length > maximum)) { Object label = getAttributes().get("label"); Locale locale = facesContext.getViewRoot().getLocale(); FacesMessage facesMessage = getMessageContext().newFacesMessage(locale, FacesMessage.SEVERITY_ERROR, LengthValidator.MAXIMUM_MESSAGE_ID, maximum, label); facesContext.addMessage(getClientId(), facesMessage); setValid(false); } } }
From source file:com.liferay.faces.portal.component.inputrichtext.internal.InputRichTextRenderer.java
License:Open Source License
protected String getEditorType(InputRichText inputRichText) { String editorType = PropsUtil.get(PropsKeys.EDITOR_WYSIWYG_DEFAULT); String editorKey = inputRichText.getEditorKey(); if (editorKey != null) { editorType = PropsUtil.get(editorKey); }/*from w ww . ja va 2s . c o m*/ return editorType; }
From source file:com.liferay.geolocation.service.ClpSerializer.java
License:Open Source License
public static String getServletContextName() { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; }/*from w w w . j a va2 s. com*/ synchronized (ClpSerializer.class) { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; } try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps"); Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class }); String portletPropsServletContextName = (String) getMethod.invoke(null, "geolocation-service-shared-deployment-context"); if (Validator.isNotNull(portletPropsServletContextName)) { _servletContextName = portletPropsServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portlet properties"); } } if (Validator.isNull(_servletContextName)) { try { String propsUtilServletContextName = PropsUtil .get("geolocation-service-shared-deployment-context"); if (Validator.isNotNull(propsUtilServletContextName)) { _servletContextName = propsUtilServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portal properties"); } } } if (Validator.isNull(_servletContextName)) { _servletContextName = "geolocation-service-shared"; } return _servletContextName; } }