com.liferay.message.boards.internal.util.MBTrashUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.liferay.message.boards.service
Show all versions of com.liferay.message.boards.service
Liferay Message Boards Service
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.message.boards.internal.util;
import com.liferay.message.boards.constants.MBCategoryConstants;
import com.liferay.message.boards.model.MBCategory;
import com.liferay.message.boards.service.MBCategoryLocalServiceUtil;
import com.liferay.petra.string.StringBundler;
import com.liferay.petra.string.StringPool;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.theme.ThemeDisplay;
import com.liferay.portal.kernel.util.WebKeys;
import java.util.Collections;
import java.util.List;
import javax.portlet.PortletRequest;
/**
* @author Sergio González
*/
public class MBTrashUtil {
public static String getAbsolutePath(
PortletRequest portletRequest, long mbCategoryId)
throws PortalException {
ThemeDisplay themeDisplay = (ThemeDisplay)portletRequest.getAttribute(
WebKeys.THEME_DISPLAY);
if (mbCategoryId == MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) {
return themeDisplay.translate("home");
}
MBCategory mbCategory = MBCategoryLocalServiceUtil.fetchMBCategory(
mbCategoryId);
List categories = mbCategory.getAncestors();
Collections.reverse(categories);
StringBundler sb = new StringBundler((categories.size() * 3) + 5);
sb.append(themeDisplay.translate("home"));
sb.append(StringPool.SPACE);
for (MBCategory curCategory : categories) {
sb.append(StringPool.RAQUO_CHAR);
sb.append(StringPool.SPACE);
sb.append(curCategory.getName());
}
sb.append(StringPool.RAQUO_CHAR);
sb.append(StringPool.SPACE);
sb.append(mbCategory.getName());
return sb.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy