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.portlet.documentlibrary.util.DLPreviewableProcessor.java
License:Open Source License
protected String getPreviewTempFilePath(String id, int index, String type) { StringBundler sb = null;/*from w ww. ja v a2 s . com*/ if (index > 0) { sb = new StringBundler(6); } else { sb = new StringBundler(4); } sb.append(PREVIEW_TMP_PATH); sb.append(id); if (index > 0) { sb.append(StringPool.DASH); sb.append(index - 1); } else if (index == -1) { sb.append("-%d"); } if (Validator.isNotNull(type)) { sb.append(StringPool.PERIOD); sb.append(type); } return sb.toString(); }
From source file:com.liferay.portlet.documentlibrary.util.DLPreviewableProcessor.java
License:Open Source License
protected String getThumbnailFilePath(long groupId, long fileEntryId, long fileVersionId, String thumbnailType, int index) { StringBundler sb = new StringBundler(5); sb.append(getPathSegment(groupId, fileEntryId, fileVersionId, false)); if (index != THUMBNAIL_INDEX_DEFAULT) { sb.append(StringPool.DASH); sb.append(index);/*w w w . j a v a 2s.c om*/ } if ((fileVersionId > 0) && Validator.isNotNull(thumbnailType)) { sb.append(StringPool.PERIOD); sb.append(thumbnailType); } return sb.toString(); }
From source file:com.liferay.portlet.documentlibrary.util.ImageProcessorImpl.java
License:Open Source License
private void _storeThumbnail(long companyId, long groupId, long fileEntryId, long fileVersionId, long custom1ImageId, long custom2ImageId, InputStream is, String type) throws Exception { StringBundler sb = new StringBundler(5); sb.append(getPathSegment(groupId, fileEntryId, fileVersionId, false)); if (custom1ImageId != 0) { sb.append(StringPool.DASH); sb.append(1);//from w w w .j a va2 s .c o m } else if (custom2ImageId != 0) { sb.append(StringPool.DASH); sb.append(2); } sb.append(StringPool.PERIOD); sb.append(type); String filePath = sb.toString(); File file = null; try { file = FileUtil.createTempFile(is); addFileToStore(companyId, THUMBNAIL_PATH, filePath, file); } finally { FileUtil.delete(file); } }
From source file:com.liferay.portlet.dynamicdatamapping.util.DDMXSDImpl.java
License:Open Source License
public String getHTML(PageContext pageContext, Element element, Fields fields, String namespace, String mode, boolean readOnly, Locale locale) throws Exception { StringBundler sb = new StringBundler(); HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); String portletId = PortalUtil.getPortletId(request); String portletNamespace = PortalUtil.getPortletNamespace(portletId); List<Element> dynamicElementElements = element.elements("dynamic-element"); for (Element dynamicElementElement : dynamicElementElements) { FreeMarkerContext freeMarkerContext = getFreeMarkerContext(dynamicElementElement, locale); freeMarkerContext.put("portletNamespace", portletNamespace); freeMarkerContext.put("namespace", namespace); if (fields != null) { freeMarkerContext.put("fields", fields); }//from ww w . ja v a2 s .co m Map<String, Object> field = (Map<String, Object>) freeMarkerContext.get("fieldStructure"); String childrenHTML = getHTML(pageContext, dynamicElementElement, fields, namespace, mode, readOnly, locale); field.put("children", childrenHTML); String fieldNamespace = dynamicElementElement.attributeValue("fieldNamespace", _DEFAULT_NAMESPACE); String defaultResourcePath = _TPL_DEFAULT_PATH; boolean fieldReadOnly = GetterUtil.getBoolean(field.get("readOnly")); if ((fieldReadOnly && Validator.isNotNull(mode) && mode.equalsIgnoreCase(DDMTemplateConstants.TEMPLATE_MODE_EDIT)) || readOnly) { fieldNamespace = _DEFAULT_READ_ONLY_NAMESPACE; defaultResourcePath = _TPL_DEFAULT_READ_ONLY_PATH; } String type = dynamicElementElement.attributeValue("type"); String templateName = StringUtil.replaceFirst(type, fieldNamespace.concat(StringPool.DASH), StringPool.BLANK); StringBundler resourcePath = new StringBundler(5); resourcePath.append(_TPL_PATH); resourcePath.append(fieldNamespace.toLowerCase()); resourcePath.append(CharPool.SLASH); resourcePath.append(templateName); resourcePath.append(_TPL_EXT); sb.append(processFTL(pageContext, freeMarkerContext, resourcePath.toString(), defaultResourcePath)); } return sb.toString(); }
From source file:com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
protected String getUniqueUrlTitle(long id, long groupId, String articleId, String title) throws PortalException, SystemException { String urlTitle = JournalUtil.getUrlTitle(id, title); String newUrlTitle = ModelHintsUtil.trimString(JournalArticle.class.getName(), "urlTitle", urlTitle); for (int i = 1;; i++) { JournalArticle article = null;/*from w w w. j ava 2s .c o m*/ try { article = getArticleByUrlTitle(groupId, newUrlTitle); } catch (NoSuchArticleException nsae) { } if ((article == null) || article.getArticleId().equals(articleId)) { break; } else { 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.social.model.impl.SocialActivityLimitImpl.java
License:Open Source License
public int getCount(int limitPeriod) { String[] valueParts = StringUtil.split(getValue(), StringPool.SLASH); if ((limitPeriod != SocialActivityCounterDefinition.LIMIT_PERIOD_LIFETIME) && (valueParts.length < 2)) { return 0; }/* w ww. j av a 2s. c om*/ int count = GetterUtil.getInteger(valueParts[valueParts.length - 1], 0); if (limitPeriod == SocialActivityCounterDefinition.LIMIT_PERIOD_DAY) { int activityDay = SocialCounterPeriodUtil.getActivityDay(); if (activityDay == GetterUtil.getInteger(valueParts[0], 0)) { return count; } } else if (limitPeriod == SocialActivityCounterDefinition.LIMIT_PERIOD_LIFETIME) { return count; } else if (limitPeriod == SocialActivityCounterDefinition.LIMIT_PERIOD_PERIOD) { int activityDay = SocialCounterPeriodUtil.getActivityDay(); String[] periodParts = StringUtil.split(valueParts[0], StringPool.DASH); int startPeriod = GetterUtil.getInteger(periodParts[0]); int endPeriod = GetterUtil.getInteger(periodParts[1]); if ((activityDay >= startPeriod) && (activityDay <= endPeriod)) { return count; } } return 0; }
From source file:com.liferay.portlet.social.model.impl.SocialActivityLimitImpl.java
License:Open Source License
public void setCount(int limitPeriod, int count) { if (limitPeriod == SocialActivityCounterDefinition.LIMIT_PERIOD_DAY) { setValue(String.valueOf(SocialCounterPeriodUtil.getActivityDay()) + StringPool.SLASH + String.valueOf(count)); } else if (limitPeriod == SocialActivityCounterDefinition.LIMIT_PERIOD_LIFETIME) { setValue(String.valueOf(count)); } else if (limitPeriod == SocialActivityCounterDefinition.LIMIT_PERIOD_PERIOD) { StringBundler sb = new StringBundler(5); sb.append(SocialCounterPeriodUtil.getStartPeriod()); sb.append(StringPool.DASH); sb.append(SocialCounterPeriodUtil.getEndPeriod()); sb.append(StringPool.SLASH);//from w ww .j a v a2 s.c om sb.append(count); setValue(sb.toString()); } }
From source file:com.liferay.portlet.wiki.engines.antlrwiki.translator.XhtmlTranslator.java
License:Open Source License
protected String getHeadingMarkup(String prefix, String text) { StringBundler sb = new StringBundler(5); sb.append(_HEADING_ANCHOR_PREFIX);//from w w w . ja va 2 s .c om sb.append(prefix); sb.append(StringPool.DASH); sb.append(text.trim()); return StringUtil.replace(sb.toString(), StringPool.SPACE, StringPool.PLUS); }
From source file:com.liferay.portletbox.ServiceUtil.java
License:BSD License
public static Group addActiveOpenGroup(long userId, String name) throws Exception { boolean active = true; String description = name;// w w w .j a va2 s .co m String friendlyURL = StringPool.FORWARD_SLASH + name.toLowerCase().replaceAll(StringPool.SPACE, StringPool.DASH); boolean siteFlag = true; int type = GroupConstants.TYPE_SITE_OPEN; return GroupLocalServiceUtil.addGroup(userId, (String) null, 0L, name, description, type, friendlyURL, siteFlag, active, new ServiceContext()); }
From source file:com.liferay.resourcesimporter.util.FileSystemImporter.java
License:Open Source License
protected String getJournalId(String fileName) { String id = FileUtil.stripExtension(fileName); id = StringUtil.toUpperCase(id);//from w w w. ja v a 2 s. c om return StringUtil.replace(id, StringPool.SPACE, StringPool.DASH); }