List of usage examples for com.liferay.portal.kernel.util StringPool UNDERLINE
String UNDERLINE
To view the source code for com.liferay.portal.kernel.util StringPool UNDERLINE.
Click Source Link
From source file:com.liferay.frontend.theme.contributor.extender.internal.ThemeContributorExtender.java
License:Open Source License
private BundleWebResourcesImpl _scanForResources(Bundle bundle) { final List<String> cssResourcePaths = new ArrayList<>(); final List<String> jsResourcePaths = new ArrayList<>(); Enumeration<URL> cssEntries = bundle.findEntries("/META-INF/resources", "*.css", true); Enumeration<URL> jsEntries = bundle.findEntries("/META-INF/resources", "*.js", true); if (cssEntries != null) { while (cssEntries.hasMoreElements()) { URL url = cssEntries.nextElement(); String path = url.getFile(); path = path.replace("/META-INF/resources", ""); int index = path.lastIndexOf('/'); if (!StringPool.UNDERLINE.equals(path.charAt(index + 1)) && !path.endsWith("_rtl.css")) { cssResourcePaths.add(path); }//from w w w . j a va 2 s. c om } } if (jsEntries != null) { while (jsEntries.hasMoreElements()) { URL url = jsEntries.nextElement(); String path = url.getFile(); jsResourcePaths.add(path.replace("/META-INF/resources", "")); } } if (cssResourcePaths.isEmpty() && jsResourcePaths.isEmpty()) { return null; } else { return new BundleWebResourcesImpl(cssResourcePaths, jsResourcePaths); } }
From source file:com.liferay.jbpm.util.TaskFormElement.java
License:Open Source License
public String getDateName() { if (Validator.isNotNull(_displayName)) { return StringUtil.replace(_displayName, StringPool.DASH, StringPool.UNDERLINE); } else {//w w w . java2 s .c om return _displayName; } }
From source file:com.liferay.journal.exportimport.data.handler.test.JournalExportImportTest.java
License:Open Source License
@Override protected Map<String, String[]> getExportParameterMap() throws Exception { Map<String, String[]> parameterMap = super.getExportParameterMap(); MapUtil.merge(parameterMap, getBaseParameterMap(group.getGroupId(), layout.getPlid())); parameterMap.put(PortletDataHandlerKeys.PORTLET_DATA + StringPool.UNDERLINE + JournalPortletKeys.JOURNAL, new String[] { Boolean.TRUE.toString() }); return parameterMap; }
From source file:com.liferay.journal.internal.upgrade.v1_0_0.UpgradeJournalArticleImage.java
License:Open Source License
protected void updateJournalArticleImagesName() throws Exception { try (LoggingTimer loggingTimer = new LoggingTimer(); PreparedStatement ps1 = connection .prepareStatement("select articleImageId, elName from JournalArticleImage"); ResultSet rs = ps1.executeQuery()) { try (PreparedStatement ps2 = AutoBatchPreparedStatementUtil.autoBatch(connection .prepareStatement("update JournalArticleImage set elName = ? where " + "articleImageId = ?"))) { while (rs.next()) { long articleImageId = rs.getLong(1); String elName = rs.getString(2); int lastIndexOf = elName.lastIndexOf(StringPool.UNDERLINE); if (lastIndexOf > 0) { elName = elName.substring(0, lastIndexOf); }/*from w w w .j a v a 2 s . c o m*/ ps2.setString(1, elName); ps2.setLong(2, articleImageId); ps2.addBatch(); } ps2.executeBatch(); } } }
From source file:com.liferay.journal.search.JournalArticleIndexer.java
License:Open Source License
@Override protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletRequest portletRequest, PortletResponse portletResponse) { Locale defaultLocale = LocaleUtil.fromLanguageId(document.get("defaultLanguageId")); Locale snippetLocale = getSnippetLocale(document, locale); String localizedTitleName = DocumentImpl.getLocalizedName(locale, Field.TITLE); if ((snippetLocale == null) && (document.getField(localizedTitleName) == null)) { snippetLocale = defaultLocale;/*from w w w .ja va 2s . c om*/ } else { snippetLocale = locale; } String title = document.get(snippetLocale, Field.SNIPPET + StringPool.UNDERLINE + Field.TITLE, Field.TITLE); if (Validator.isNull(title) && !snippetLocale.equals(defaultLocale)) { title = document.get(defaultLocale, Field.SNIPPET + StringPool.UNDERLINE + Field.TITLE, Field.TITLE); } String content = getDDMContentSummary(document, snippetLocale, portletRequest, portletResponse); if (Validator.isNull(content) && !snippetLocale.equals(defaultLocale)) { content = getDDMContentSummary(document, defaultLocale, portletRequest, portletResponse); } Summary summary = new Summary(snippetLocale, title, content); summary.setMaxContentLength(200); return summary; }
From source file:com.liferay.journal.service.impl.JournalFeedLocalServiceImpl.java
License:Open Source License
protected boolean isValidStructureOptionValue(Map<String, DDMFormField> ddmFormFieldsMap, String contentField) { for (DDMFormField ddmFormField : ddmFormFieldsMap.values()) { String ddmFormFieldType = ddmFormField.getType(); if (!(ddmFormFieldType.equals("radio") || ddmFormFieldType.equals("select"))) { continue; }//from www. j a v a 2s . c o m DDMFormFieldOptions ddmFormFieldOptions = ddmFormField.getDDMFormFieldOptions(); for (String optionValue : ddmFormFieldOptions.getOptionsValues()) { optionValue = ddmFormField.getName() + StringPool.UNDERLINE + optionValue; if (contentField.equals(optionValue)) { return true; } } } return false; }
From source file:com.liferay.journal.transformer.JournalTransformer.java
License:Open Source License
protected String doTransform(ThemeDisplay themeDisplay, Map<String, Object> contextObjects, Map<String, String> tokens, String viewMode, String languageId, Document document, PortletRequestModel portletRequestModel, String script, String langType, boolean propagateException) throws Exception { // Setup listeners if (_log.isDebugEnabled()) { _log.debug("Language " + languageId); }//ww w .j a v a2 s .c o m if (Validator.isNull(viewMode)) { viewMode = Constants.VIEW; } if (_logTokens.isDebugEnabled()) { String tokensString = PropertiesUtil.list(tokens); _logTokens.debug(tokensString); } if (_logTransformBefore.isDebugEnabled()) { _logTransformBefore.debug(document); } List<TransformerListener> transformerListeners = JournalTransformerListenerRegistryUtil .getTransformerListeners(); for (TransformerListener transformerListener : transformerListeners) { // Modify XML if (_logXmlBeforeListener.isDebugEnabled()) { _logXmlBeforeListener.debug(document); } if (transformerListener != null) { document = transformerListener.onXml(document, languageId, tokens); if (_logXmlAfterListener.isDebugEnabled()) { _logXmlAfterListener.debug(document); } } // Modify script if (_logScriptBeforeListener.isDebugEnabled()) { _logScriptBeforeListener.debug(script); } if (transformerListener != null) { script = transformerListener.onScript(script, document, languageId, tokens); if (_logScriptAfterListener.isDebugEnabled()) { _logScriptAfterListener.debug(script); } } } // Transform String output = null; if (Validator.isNull(langType)) { output = LocalizationUtil.getLocalization(document.asXML(), languageId); } else { long companyId = 0; long companyGroupId = 0; long articleGroupId = 0; long classNameId = 0; if (tokens != null) { companyId = GetterUtil.getLong(tokens.get("company_id")); companyGroupId = GetterUtil.getLong(tokens.get("company_group_id")); articleGroupId = GetterUtil.getLong(tokens.get("article_group_id")); classNameId = GetterUtil.getLong(tokens.get(TemplateConstants.CLASS_NAME_ID)); } long scopeGroupId = 0; long siteGroupId = 0; if (themeDisplay != null) { companyId = themeDisplay.getCompanyId(); companyGroupId = themeDisplay.getCompanyGroupId(); scopeGroupId = themeDisplay.getScopeGroupId(); siteGroupId = themeDisplay.getSiteGroupId(); } String templateId = tokens.get("template_id"); templateId = getTemplateId(templateId, companyId, companyGroupId, articleGroupId); Template template = getTemplate(templateId, tokens, languageId, document, script, langType); if (contextObjects != null) { template.putAll(contextObjects); } UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter(); try { if (document != null) { Element rootElement = document.getRootElement(); List<TemplateNode> templateNodes = getTemplateNodes(themeDisplay, rootElement, Long.valueOf(tokens.get("ddm_structure_id"))); if (templateNodes != null) { for (TemplateNode templateNode : templateNodes) { template.put(templateNode.getName(), templateNode); } } if (portletRequestModel != null) { template.put("request", portletRequestModel.toMap()); if (langType.equals(TemplateConstants.LANG_TYPE_XSL)) { Document requestDocument = SAXReaderUtil.read(portletRequestModel.toXML()); Element requestElement = requestDocument.getRootElement(); template.put("xmlRequest", requestElement.asXML()); } } else { Element requestElement = rootElement.element("request"); template.put("request", insertRequestVariables(requestElement)); if (langType.equals(TemplateConstants.LANG_TYPE_XSL)) { template.put("xmlRequest", requestElement.asXML()); } } } template.put("articleGroupId", articleGroupId); template.put("company", getCompany(themeDisplay, companyId)); template.put("companyId", companyId); template.put("device", getDevice(themeDisplay)); String templatesPath = getTemplatesPath(companyId, articleGroupId, classNameId); Locale locale = LocaleUtil.fromLanguageId(languageId); template.put("locale", locale); template.put("permissionChecker", PermissionThreadLocal.getPermissionChecker()); template.put("randomNamespace", StringUtil.randomId() + StringPool.UNDERLINE); template.put("scopeGroupId", scopeGroupId); template.put("siteGroupId", siteGroupId); template.put("templatesPath", templatesPath); template.put("viewMode", viewMode); if (themeDisplay != null) { TemplateManager templateManager = TemplateManagerUtil.getTemplateManager(langType); HttpServletRequest request = themeDisplay.getRequest(); templateManager.addTaglibSupport(template, request, themeDisplay.getResponse()); templateManager.addTaglibTheme(template, "taglibLiferay", request, new PipingServletResponse(themeDisplay.getResponse(), unsyncStringWriter)); } // Deprecated variables template.put("groupId", articleGroupId); template.put("journalTemplatesPath", templatesPath); mergeTemplate(template, unsyncStringWriter, propagateException); } catch (Exception e) { if (e instanceof DocumentException) { throw new TransformException("Unable to read XML document", e); } else if (e instanceof IOException) { throw new TransformException("Error reading template", e); } else if (e instanceof TransformException) { throw (TransformException) e; } else { throw new TransformException("Unhandled exception", e); } } output = unsyncStringWriter.toString(); } // Postprocess output for (TransformerListener transformerListener : transformerListeners) { // Modify output if (_logOutputBeforeListener.isDebugEnabled()) { _logOutputBeforeListener.debug(output); } output = transformerListener.onOutput(output, languageId, tokens); if (_logOutputAfterListener.isDebugEnabled()) { _logOutputAfterListener.debug(output); } } if (_logTransfromAfter.isDebugEnabled()) { _logTransfromAfter.debug(output); } return output; }
From source file:com.liferay.knowledgebase.admin.util.AdminUtil.java
License:Open Source License
public static String[] escapeSections(String[] sections) { if (ArrayUtil.isEmpty(sections)) { return new String[0]; }/* w ww . j a v a 2 s . c o m*/ sections = ArrayUtil.clone(sections); for (int i = 0; i < sections.length; i++) { sections[i] = StringPool.UNDERLINE.concat(sections[i]).concat(StringPool.UNDERLINE); } return sections; }
From source file:com.liferay.knowledgebase.admin.util.AdminUtil.java
License:Open Source License
public static String[] unescapeSections(String sections) { String[] sectionsArray = StringUtil.split(sections); for (int i = 0; i < sectionsArray.length; i++) { String section = sectionsArray[i]; if (StringUtil.startsWith(section, StringPool.UNDERLINE) && StringUtil.endsWith(section, StringPool.UNDERLINE)) { sectionsArray[i] = section.substring(1, section.length() - 1); }//from w w w . j a v a 2 s . co m } return sectionsArray; }
From source file:com.liferay.logbridge.LogBridge.java
License:Open Source License
public void logged(LogEntry logEntry) { int level = logEntry.getLevel(); Bundle bundle = logEntry.getBundle(); String symbolicName = StringUtil.replace(bundle.getSymbolicName(), StringPool.PERIOD, StringPool.UNDERLINE); Log log = LogFactoryUtil.getLog("osgi.logging." + symbolicName); String message = logEntry.getMessage(); ServiceReference<?> serviceReference = logEntry.getServiceReference(); if (serviceReference != null) { message += " " + serviceReference.toString(); }//from w w w. jav a2 s .com if ((level == LogService.LOG_DEBUG) && log.isDebugEnabled()) { log.debug(message, logEntry.getException()); } else if ((level == LogService.LOG_ERROR) && log.isErrorEnabled()) { log.error(message, logEntry.getException()); } else if ((level == LogService.LOG_INFO) && log.isInfoEnabled()) { log.info(message, logEntry.getException()); } else if ((level == LogService.LOG_WARNING) && log.isWarnEnabled()) { log.warn(message, logEntry.getException()); } }