List of usage examples for com.liferay.portal.kernel.util StringPool DASH
String DASH
To view the source code for com.liferay.portal.kernel.util StringPool DASH.
Click Source Link
From source file:com.liferay.journal.web.util.JournalPortletUtil.java
License:Open Source License
public static String getAddMenuFavItemKey(PortletRequest portletRequest, PortletResponse portletResponse) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); long folderId = ParamUtil.getLong(portletRequest, "folderId"); String key = "journal-add-menu-fav-items-" + themeDisplay.getScopeGroupId(); folderId = getAddMenuFavItemFolderId(folderId); if (folderId <= 0) { return key; }// w w w . ja v a2s . c o m return key + StringPool.DASH + folderId; }
From source file:com.liferay.knowledgebase.admin.importer.util.KBArticleMarkdownConverter.java
License:Open Source License
protected String getUrlTitle(String heading) { String urlTitle = null;//from w w w. j a va2 s.co m int x = heading.indexOf("[](id="); int y = heading.indexOf(StringPool.CLOSE_PARENTHESIS, x); if (y > (x + 1)) { int equalsSign = heading.indexOf(StringPool.EQUAL, x); urlTitle = heading.substring(equalsSign + 1, y); urlTitle = StringUtil.replace(urlTitle, StringPool.SPACE, StringPool.DASH); urlTitle = StringUtil.toLowerCase(urlTitle); } if (!urlTitle.startsWith(StringPool.SLASH)) { urlTitle = StringPool.SLASH + urlTitle; } return urlTitle; }
From source file:com.liferay.knowledgebase.hook.upgrade.v1_3_3.UpgradeKBFolder.java
License:Open Source License
@Override protected void doUpgrade() throws Exception { Connection con = null;/*w w w . ja v a 2 s .c om*/ try { con = DataAccess.getUpgradeOptimizedConnection(); Map<Long, String> urlTitles = _getInitialUrlTitles(con); for (Map.Entry<Long, String> entry : urlTitles.entrySet()) { String uniqueUrlTitle = _findUniqueUrlTitle(con, entry.getValue()); for (int i = 1; uniqueUrlTitle == null; i++) { uniqueUrlTitle = _findUniqueUrlTitle(con, entry.getValue() + StringPool.DASH + i); } _updateKBFolder(con, entry.getKey(), uniqueUrlTitle); } } finally { DataAccess.cleanUp(con); } }
From source file:com.liferay.knowledgebase.service.impl.KBArticleLocalServiceImpl.java
License:Open Source License
protected String getUniqueUrlTitle(long groupId, long kbFolderId, long kbArticleId, String title) throws PortalException { String urlTitle = KnowledgeBaseUtil.getUrlTitle(kbArticleId, title); String uniqueUrlTitle = urlTitle; if (kbFolderId == KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) { int kbArticleCount = kbArticlePersistence.countByG_KBFI_UT_ST(groupId, kbFolderId, uniqueUrlTitle, _STATUSES);//from www .ja v a 2s. c o m for (int i = 1; kbArticleCount > 0; i++) { uniqueUrlTitle = urlTitle + StringPool.DASH + i; kbArticleCount = kbArticlePersistence.countByG_KBFI_UT_ST(groupId, kbFolderId, uniqueUrlTitle, _STATUSES); } return uniqueUrlTitle; } KBFolder kbFolder = kbFolderPersistence.findByPrimaryKey(kbFolderId); int kbArticleCount = kbArticleFinder.countByUrlTitle(groupId, kbFolder.getUrlTitle(), uniqueUrlTitle, _STATUSES); for (int i = 1; kbArticleCount > 0; i++) { uniqueUrlTitle = urlTitle + StringPool.DASH + i; kbArticleCount = kbArticleFinder.countByUrlTitle(groupId, kbFolder.getUrlTitle(), uniqueUrlTitle, _STATUSES); } return uniqueUrlTitle; }
From source file:com.liferay.knowledgebase.service.impl.KBFolderLocalServiceImpl.java
License:Open Source License
protected String getUniqueUrlTitle(long groupId, long parentKbFolderId, long kbFolderId, String name) { String urlTitle = KnowledgeBaseUtil.getUrlTitle(kbFolderId, name); String uniqueUrlTitle = urlTitle; KBFolder kbFolder = null;//from ww w.j a v a 2 s . com for (int i = 1; kbFolder != null; i++) { uniqueUrlTitle = urlTitle + StringPool.DASH + i; kbFolder = kbFolderPersistence.fetchByG_P_UT(groupId, parentKbFolderId, uniqueUrlTitle); } return uniqueUrlTitle; }
From source file:com.liferay.marketplace.service.impl.AppLocalServiceImpl.java
License:Open Source License
protected String getContextName(String fileName) { String context = fileName;//w ww . j av a2 s . c o m while (context.contains(StringPool.DASH)) { if (context.endsWith("-ext") || context.endsWith("-hook") || context.endsWith("-layouttpl") || context.endsWith("-portlet") || context.endsWith("-theme") || context.endsWith("-web")) { return context; } int pos = context.lastIndexOf(StringPool.DASH); if (pos > 0) { context = context.substring(0, pos); } else { break; } } return fileName; }
From source file:com.liferay.portlet.blogs.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
protected String getUniqueUrlTitle(long entryId, long groupId, String title) throws SystemException { String urlTitle = BlogsUtil.getUrlTitle(entryId, title); String newUrlTitle = ModelHintsUtil.trimString(BlogsEntry.class.getName(), "urlTitle", urlTitle); for (int i = 1;; i++) { BlogsEntry entry = blogsEntryPersistence.fetchByG_UT(groupId, newUrlTitle); if ((entry == null) || (entry.getEntryId() == entryId)) { break; } else {//from w w w .j av a 2 s . c o m String suffix = StringPool.DASH + i; String prefix = newUrlTitle; if (newUrlTitle.length() > suffix.length()) { prefix = newUrlTitle.substring(0, newUrlTitle.length() - suffix.length()); } newUrlTitle = prefix + suffix; } } return newUrlTitle; }
From source file:com.liferay.portlet.configuration.icon.locator.internal.LegacyConfigurationIconLocator.java
License:Open Source License
@Override public String getPath(PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String portletId = portletDisplay.getRootPortletId(); Portlet portlet = _portletLocalService.getPortletById(portletId); if (portlet == null) { return StringPool.BLANK; }//from w ww. ja v a 2 s. co m Map<String, String> initParams = portlet.getInitParams(); boolean alwaysDisplayDefaultConfigurationIcons = GetterUtil .getBoolean(initParams.get("always-display-default-configuration-icons")); if (alwaysDisplayDefaultConfigurationIcons) { return StringPool.DASH; } return StringPool.BLANK; }
From source file:com.liferay.portlet.documentlibrary.util.DLImpl.java
License:Open Source License
@Override public String getFileName(long groupId, long folderId, String tempFileName) { String extension = FileUtil.getExtension(tempFileName); int pos = tempFileName.lastIndexOf(EditFileEntryAction.TEMP_RANDOM_SUFFIX); if (pos != -1) { tempFileName = tempFileName.substring(0, pos); if (Validator.isNotNull(extension)) { tempFileName = tempFileName + StringPool.PERIOD + extension; }/*from ww w.ja v a2s . c o m*/ } while (true) { try { DLAppLocalServiceUtil.getFileEntry(groupId, folderId, tempFileName); StringBundler sb = new StringBundler(5); sb.append(FileUtil.stripExtension(tempFileName)); sb.append(StringPool.DASH); sb.append(StringUtil.randomString()); if (Validator.isNotNull(extension)) { sb.append(StringPool.PERIOD); sb.append(extension); } tempFileName = sb.toString(); } catch (Exception e) { break; } } return tempFileName; }
From source file:com.liferay.portlet.documentlibrary.util.DLPreviewableProcessor.java
License:Open Source License
protected int getPreviewTempFileCount(FileVersion fileVersion, String type) { String tempFileId = DLUtil.getTempFileId(fileVersion.getFileEntryId(), fileVersion.getVersion()); StringBundler sb = new StringBundler(5); sb.append(tempFileId);//www.j av a2s . c om sb.append(StringPool.DASH); sb.append("(.*)"); if (Validator.isNotNull(type)) { sb.append(StringPool.PERIOD); sb.append(type); } File dir = new File(PREVIEW_TMP_PATH); File[] files = dir.listFiles(new FileFilter(sb.toString())); if (_log.isDebugEnabled()) { for (File file : files) { _log.debug("Preview page for " + tempFileId + " " + file); } } return files.length; }