List of usage examples for com.liferay.portal.kernel.util StringUtil shorten
public static String shorten(String s)
From source file:com.liferay.comment.web.internal.asset.CommentAssetRenderer.java
License:Open Source License
@Override public String getTitle(Locale locale) { return StringUtil.shorten(getSearchSummary(locale)); }
From source file:com.liferay.portlet.messageboards.service.impl.MBMessageLocalServiceImpl.java
License:Open Source License
protected String getSubject(String subject, String body) { if (Validator.isNull(subject)) { return StringUtil.shorten(body); }//from w w w . ja v a 2 s. c o m return subject; }
From source file:com.liferay.so.activities.hook.social.CalendarActivityInterpreter.java
License:Open Source License
protected String getBody(String className, long classPK, ServiceContext serviceContext) throws Exception { StringBundler sb = new StringBundler(15); sb.append("<div class=\"activity-body\"><div class=\"title\">"); sb.append(getPageTitle(className, classPK, serviceContext)); sb.append("</div><div class=\"date\"><strong>"); sb.append(serviceContext.translate("date")); sb.append(": </strong>"); Format dateFormatDate = FastDateFormatFactoryUtil.getDateTime(DateFormat.FULL, DateFormat.SHORT, serviceContext.getLocale(), serviceContext.getTimeZone()); CalendarBooking calendarBooking = CalendarBookingLocalServiceUtil.fetchCalendarBooking(classPK); sb.append(dateFormatDate.format(calendarBooking.getStartTime())); sb.append("</div><div class=\"location\"><strong>"); sb.append(serviceContext.translate("location")); sb.append(": </strong>"); sb.append(calendarBooking.getLocation()); sb.append("</div><div class=\"description\"><strong>"); sb.append(serviceContext.translate("description")); sb.append(": </strong>"); AssetRenderer assetRenderer = getAssetRenderer(className, classPK); sb.append(StringUtil.shorten(HtmlUtil.escape(assetRenderer.getSummary(), 200))); sb.append("</div></div>"); return sb.toString(); }
From source file:com.liferay.so.activities.hook.social.DLActivityInterpreter.java
License:Open Source License
protected String getBody(String className, long classPK, ServiceContext serviceContext) throws Exception { StringBundler sb = new StringBundler(11); sb.append("<div class=\"activity-body document\">"); sb.append("<span class=\"document-thumbnail\"><img src=\""); FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(classPK); FileVersion fileVersion = fileEntry.getFileVersion(); String thumbnailSrc = DLUtil.getThumbnailSrc(fileEntry, fileVersion, null, serviceContext.getThemeDisplay()); sb.append(thumbnailSrc);//from w ww.jav a 2s.c o m sb.append("\"></span>"); sb.append("<div class=\"document-container\"><div class=\"title\">"); sb.append(getPageTitle(className, classPK, serviceContext)); sb.append("</div><div class=\"version\">"); sb.append(serviceContext.translate("version-x", fileVersion.getVersion())); sb.append("</div><div class=\"document-content\">"); AssetRenderer assetRenderer = getAssetRenderer(className, classPK); sb.append(StringUtil.shorten(HtmlUtil.escape(assetRenderer.getSummary(), 200))); sb.append("</div></div></div>"); return sb.toString(); }
From source file:com.liferay.so.activities.hook.social.WikiActivityInterpreter.java
License:Open Source License
protected String getBody(String className, long classPK, ServiceContext serviceContext) throws Exception { StringBundler sb = new StringBundler(5); sb.append("<div class=\"activity-body\"><div class=\"title\">"); sb.append(getPageTitle(className, classPK, serviceContext)); sb.append("</div><div class=\"wiki-page-content\">"); AssetRenderer assetRenderer = getAssetRenderer(className, classPK); sb.append(StringUtil.shorten(HtmlUtil.escape(assetRenderer.getSummary(), 200))); sb.append("</div></div>"); return sb.toString(); }
From source file:com.liferay.tasks.notifications.TasksUserNotificationHandler.java
License:Open Source License
@Override protected String getBody(UserNotificationEvent userNotificationEvent, ServiceContext serviceContext) throws Exception { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(userNotificationEvent.getPayload()); long tasksEntryId = jsonObject.getLong("classPK"); TasksEntry tasksEntry = TasksEntryLocalServiceUtil.fetchTasksEntry(tasksEntryId); if (tasksEntry == null) { UserNotificationEventLocalServiceUtil .deleteUserNotificationEvent(userNotificationEvent.getUserNotificationEventId()); return null; }/*from w ww.jav a2 s. c om*/ String title = serviceContext.translate(jsonObject.getString("title"), HtmlUtil.escape(PortalUtil.getUserName(jsonObject.getLong("userId"), StringPool.BLANK))); return StringUtil.replace(getBodyTemplate(), new String[] { "[$BODY$]", "[$TITLE$]" }, new String[] { HtmlUtil.escape(StringUtil.shorten(HtmlUtil.escape(tasksEntry.getTitle()))), title }); }