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.portlet.documentlibrary.util.DLImpl.java
License:Open Source License
@Override public String getSanitizedFileName(String title, String extension) { String fileName = StringUtil.replace(title, StringPool.SLASH, StringPool.UNDERLINE); if (Validator.isNotNull(extension) && !StringUtil.endsWith(fileName, StringPool.PERIOD + extension)) { fileName += StringPool.PERIOD + extension; }/*from ww w.j a v a2 s. c o m*/ if (fileName.length() > 255) { int x = fileName.length() - 1; if (Validator.isNotNull(extension)) { x = fileName.lastIndexOf(StringPool.PERIOD); } int y = x - (fileName.length() - 255); fileName = fileName.substring(0, y) + fileName.substring(x); } return fileName; }
From source file:com.liferay.portlet.InvokerPortletImpl.java
License:Open Source License
public static String encodeResponseKey(long plid, String portletId, String languageId) { StringBundler sb = new StringBundler(5); sb.append(StringUtil.toHexString(plid)); sb.append(StringPool.UNDERLINE); sb.append(portletId);/*w w w. j a v a 2 s. c o m*/ sb.append(StringPool.UNDERLINE); sb.append(languageId); return sb.toString(); }
From source file:com.liferay.portlet.journal.action.ActionUtil.java
License:Open Source License
protected static Map<String, byte[]> getImages(Fields fields, Locale locale) throws Exception { Map<String, byte[]> images = new HashMap<String, byte[]>(); for (Field field : fields) { String dataType = field.getDataType(); if (!dataType.equals(FieldConstants.IMAGE)) { continue; }/*from w w w. j ava 2s . co m*/ List<Serializable> values = field.getValues(locale); for (int i = 0; i < values.size(); i++) { String content = (String) values.get(i); if (content.equals("update")) { continue; } StringBundler sb = new StringBundler(6); sb.append(StringPool.UNDERLINE); sb.append(field.getName()); sb.append(StringPool.UNDERLINE); sb.append(i); sb.append(StringPool.UNDERLINE); sb.append(LanguageUtil.getLanguageId(locale)); images.put(sb.toString(), UnicodeFormatter.hexToBytes(content)); } } return images; }
From source file:com.liferay.portlet.journal.lar.JournalPortletDataHandlerImpl.java
License:Open Source License
protected static String getArticleImagePath(PortletDataContext portletDataContext, JournalArticle article, JournalArticleImage articleImage, Image image) throws Exception { StringBundler sb = new StringBundler(13); sb.append(portletDataContext.getPortletPath(PortletKeys.JOURNAL)); sb.append("/articles/"); sb.append(article.getArticleResourceUuid()); sb.append(StringPool.SLASH);//from w ww . ja v a2s .c om sb.append(article.getVersion()); sb.append(StringPool.SLASH); sb.append(articleImage.getElInstanceId()); sb.append(StringPool.UNDERLINE); sb.append(articleImage.getElName()); if (Validator.isNotNull(articleImage.getLanguageId())) { sb.append(StringPool.UNDERLINE); sb.append(articleImage.getLanguageId()); } sb.append(StringPool.PERIOD); sb.append(image.getType()); return sb.toString(); }
From source file:com.liferay.portlet.journal.util.JournalArticleIndexer.java
License:Open Source License
@Override public void postProcessContextQuery(BooleanQuery contextQuery, SearchContext searchContext) throws Exception { Long classNameId = (Long) searchContext.getAttribute(Field.CLASS_NAME_ID); if ((classNameId != null) && (classNameId.longValue() != 0)) { contextQuery.addRequiredTerm("classNameId", classNameId.toString()); }/*from w w w . j ava 2s .co m*/ addStatus(contextQuery, searchContext); addSearchClassTypeIds(contextQuery, searchContext); String ddmStructureFieldName = (String) searchContext.getAttribute("ddmStructureFieldName"); Serializable ddmStructureFieldValue = searchContext.getAttribute("ddmStructureFieldValue"); if (Validator.isNotNull(ddmStructureFieldName) && Validator.isNotNull(ddmStructureFieldValue)) { String[] ddmStructureFieldNameParts = StringUtil.split(ddmStructureFieldName, StringPool.SLASH); DDMStructure structure = DDMStructureLocalServiceUtil .getStructure(GetterUtil.getLong(ddmStructureFieldNameParts[1])); String fieldName = StringUtil.replaceLast(ddmStructureFieldNameParts[2], StringPool.UNDERLINE.concat(LocaleUtil.toLanguageId(searchContext.getLocale())), StringPool.BLANK); try { ddmStructureFieldValue = DDMUtil.getIndexedFieldValue(ddmStructureFieldValue, structure.getFieldType(fieldName)); } catch (StructureFieldException sfe) { } contextQuery.addRequiredTerm(ddmStructureFieldName, StringPool.QUOTE + ddmStructureFieldValue + StringPool.QUOTE); } String articleType = (String) searchContext.getAttribute("articleType"); if (Validator.isNotNull(articleType)) { contextQuery.addRequiredTerm(Field.TYPE, articleType); } String ddmStructureKey = (String) searchContext.getAttribute("ddmStructureKey"); if (Validator.isNotNull(ddmStructureKey)) { contextQuery.addRequiredTerm("ddmStructureKey", ddmStructureKey); } String ddmTemplateKey = (String) searchContext.getAttribute("ddmTemplateKey"); if (Validator.isNotNull(ddmTemplateKey)) { contextQuery.addRequiredTerm("ddmTemplateKey", ddmTemplateKey); } }
From source file:com.liferay.portlet.journal.util.JournalArticleIndexer.java
License:Open Source License
@Override protected Document doGetDocument(Object obj) throws Exception { JournalArticle article = (JournalArticle) obj; Document document = getBaseModelDocument(PORTLET_ID, article); long classPK = article.getId(); if (!PropsValues.JOURNAL_ARTICLE_INDEX_ALL_VERSIONS) { classPK = article.getResourcePrimKey(); }/*from w w w . j ava 2 s. c o m*/ document.addUID(PORTLET_ID, classPK); String articleDefaultLanguageId = LocalizationUtil.getDefaultLanguageId(article.getContent()); Locale defaultLocale = LocaleUtil.getSiteDefault(); String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale); String[] languageIds = getLanguageIds(defaultLanguageId, article.getContent()); for (String languageId : languageIds) { String content = extractContent(article, languageId); String description = article.getDescription(languageId); String title = article.getTitle(languageId); if (languageId.equals(articleDefaultLanguageId)) { document.addText(Field.CONTENT, content); document.addText(Field.DESCRIPTION, description); document.addText(Field.TITLE, title); document.addText("defaultLanguageId", languageId); } document.addText(Field.CONTENT.concat(StringPool.UNDERLINE).concat(languageId), content); document.addText(Field.DESCRIPTION.concat(StringPool.UNDERLINE).concat(languageId), description); document.addText(Field.TITLE.concat(StringPool.UNDERLINE).concat(languageId), title); } document.addKeyword(Field.FOLDER_ID, article.getFolderId()); document.addKeyword(Field.LAYOUT_UUID, article.getLayoutUuid()); document.addKeyword(Field.TREE_PATH, StringUtil.split(article.getTreePath(), CharPool.SLASH)); document.addKeyword(Field.TYPE, article.getType()); document.addKeyword(Field.VERSION, article.getVersion()); String articleId = article.getArticleId(); if (article.isInTrash()) { articleId = TrashUtil.getOriginalTitle(articleId); } document.addKeyword("articleId", articleId); document.addKeyword("ddmStructureKey", article.getStructureId()); document.addKeyword("ddmTemplateKey", article.getTemplateId()); document.addDate("displayDate", article.getDisplayDate()); addDDMStructureAttributes(document, article); addStatusHeads(document, article); return document; }
From source file:com.liferay.portlet.journal.util.JournalArticleIndexer.java
License:Open Source License
@Override protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletURL portletURL) { Locale snippetLocale = getSnippetLocale(document, locale); String localizedTitleName = DocumentImpl.getLocalizedName(locale, Field.TITLE); if ((snippetLocale == null) || (document.getField(localizedTitleName) == null)) { snippetLocale = LocaleUtil.fromLanguageId(document.get("defaultLanguageId")); }//from ww w . j a v a 2s .c om String title = document.get(snippetLocale, Field.SNIPPET + StringPool.UNDERLINE + Field.TITLE, Field.TITLE); String content = StringPool.BLANK; String ddmStructureKey = document.get("ddmStructureKey"); if (Validator.isNotNull(ddmStructureKey)) { content = getDDMContentSummary(document, snippetLocale); } else { content = getBasicContentSummary(document, snippetLocale); } String groupId = document.get(Field.GROUP_ID); String articleId = document.get("articleId"); String version = document.get(Field.VERSION); portletURL.setParameter("struts_action", "/journal/edit_article"); portletURL.setParameter("groupId", groupId); portletURL.setParameter("articleId", articleId); portletURL.setParameter("version", version); return new Summary(snippetLocale, title, content, portletURL); }
From source file:com.liferay.portlet.journal.util.JournalArticleIndexer.java
License:Open Source License
protected String getBasicContentSummary(Document document, Locale snippetLocale) { String prefix = Field.SNIPPET + StringPool.UNDERLINE; String content = document.get(snippetLocale, prefix + Field.DESCRIPTION, prefix + Field.CONTENT); if (Validator.isBlank(content)) { content = document.get(snippetLocale, Field.DESCRIPTION, Field.CONTENT); }// w w w . j av a2s .co m if (content.length() > 200) { content = StringUtil.shorten(content, 200); } return content; }
From source file:com.liferay.portlet.journal.util.JournalIndexer.java
License:Open Source License
@Override protected Document doGetDocument(Object obj) throws Exception { JournalArticle article = (JournalArticle) obj; Document document = getBaseModelDocument(PORTLET_ID, article); document.addUID(PORTLET_ID, article.getGroupId(), article.getArticleId()); Locale defaultLocale = LocaleUtil.getDefault(); String defaultLangaugeId = LocaleUtil.toLanguageId(defaultLocale); String[] languageIds = getLanguageIds(defaultLangaugeId, article.getContent()); for (String languageId : languageIds) { String content = extractContent(article.getContentByLocale(languageId)); if (languageId.equals(defaultLangaugeId)) { document.addText(Field.CONTENT, content); }/*from w w w . j av a 2s . c om*/ document.addText(Field.CONTENT.concat(StringPool.UNDERLINE).concat(languageId), content); } document.addLocalizedText(Field.DESCRIPTION, article.getDescriptionMap()); document.addLocalizedText(Field.TITLE, article.getTitleMap()); document.addKeyword(Field.TYPE, article.getType()); document.addKeyword(Field.VERSION, article.getVersion()); document.addKeyword("articleId", article.getArticleId()); document.addDate("displayDate", article.getDisplayDate()); document.addKeyword("layoutUuid", article.getLayoutUuid()); document.addKeyword("structureId", article.getStructureId()); document.addKeyword("templateId", article.getTemplateId()); JournalStructure structure = null; if (Validator.isNotNull(article.getStructureId())) { try { structure = JournalStructureLocalServiceUtil.getStructure(article.getGroupId(), article.getStructureId()); } catch (NoSuchStructureException nsse1) { Group group = GroupLocalServiceUtil.getCompanyGroup(article.getCompanyId()); try { structure = JournalStructureLocalServiceUtil.getStructure(group.getGroupId(), article.getStructureId()); } catch (NoSuchStructureException nsse2) { } } } processStructure(structure, document, article.getContent()); return document; }
From source file:com.liferay.portlet.journal.util.JournalIndexer.java
License:Open Source License
protected void indexField(Document document, Element element, String elType, String elIndexType) { if (Validator.isNull(elIndexType)) { return;//from w w w . jav a 2 s. c om } com.liferay.portal.kernel.xml.Document structureDocument = element.getDocument(); Element rootElement = structureDocument.getRootElement(); String defaultLocale = GetterUtil.getString(rootElement.attributeValue("default-locale")); String name = encodeFieldName(element.attributeValue("name")); List<Element> dynamicContentElements = element.elements("dynamic-content"); for (Element dynamicContentElement : dynamicContentElements) { String contentLocale = GetterUtil.getString(dynamicContentElement.attributeValue("language-id")); String[] value = new String[] { dynamicContentElement.getText() }; if (elType.equals("multi-list")) { List<Element> optionElements = dynamicContentElement.elements("option"); value = new String[optionElements.size()]; for (int i = 0; i < optionElements.size(); i++) { value[i] = optionElements.get(i).getText(); } } if (elIndexType.equals("keyword")) { if (Validator.isNull(contentLocale)) { document.addKeyword(name, value); } else { if (defaultLocale.equals(contentLocale)) { document.addKeyword(name, value); } document.addKeyword(name.concat(StringPool.UNDERLINE).concat(contentLocale), value); } } else if (elIndexType.equals("text")) { if (Validator.isNull(contentLocale)) { document.addText(name, StringUtil.merge(value, StringPool.SPACE)); } else { if (defaultLocale.equals(contentLocale)) { document.addText(name, StringUtil.merge(value, StringPool.SPACE)); } document.addText(name.concat(StringPool.UNDERLINE).concat(contentLocale), StringUtil.merge(value, StringPool.SPACE)); } } } }