001
014
015 package com.liferay.portlet.journal.asset;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.portlet.LiferayPortletResponse;
020 import com.liferay.portal.kernel.portlet.LiferayPortletURL;
021 import com.liferay.portal.security.permission.PermissionChecker;
022 import com.liferay.portal.theme.ThemeDisplay;
023 import com.liferay.portal.util.PortletKeys;
024 import com.liferay.portlet.asset.model.AssetRenderer;
025 import com.liferay.portlet.asset.model.BaseAssetRendererFactory;
026 import com.liferay.portlet.journal.model.JournalFolder;
027 import com.liferay.portlet.journal.service.JournalFolderLocalServiceUtil;
028 import com.liferay.portlet.journal.service.permission.JournalFolderPermission;
029
030 import javax.portlet.PortletRequest;
031 import javax.portlet.PortletURL;
032 import javax.portlet.WindowState;
033 import javax.portlet.WindowStateException;
034
035
038 public class JournalFolderAssetRendererFactory
039 extends BaseAssetRendererFactory {
040
041 public static final String TYPE = "content_folder";
042
043 @Override
044 public AssetRenderer getAssetRenderer(long classPK, int type)
045 throws PortalException, SystemException {
046
047 JournalFolder folder = JournalFolderLocalServiceUtil.getFolder(classPK);
048
049 JournalFolderAssetRenderer journalFolderAssetRenderer =
050 new JournalFolderAssetRenderer(folder);
051
052 journalFolderAssetRenderer.setAssetRendererType(type);
053
054 return journalFolderAssetRenderer;
055 }
056
057 @Override
058 public String getClassName() {
059 return JournalFolder.class.getName();
060 }
061
062 @Override
063 public String getType() {
064 return TYPE;
065 }
066
067 @Override
068 public PortletURL getURLView(
069 LiferayPortletResponse liferayPortletResponse,
070 WindowState windowState) {
071
072 LiferayPortletURL liferayPortletURL =
073 liferayPortletResponse.createLiferayPortletURL(
074 PortletKeys.JOURNAL, PortletRequest.RENDER_PHASE);
075
076 try {
077 liferayPortletURL.setWindowState(windowState);
078 }
079 catch (WindowStateException wse) {
080 }
081
082 return liferayPortletURL;
083 }
084
085 @Override
086 public boolean hasPermission(
087 PermissionChecker permissionChecker, long classPK, String actionId)
088 throws Exception {
089
090 JournalFolder folder = JournalFolderLocalServiceUtil.getFolder(classPK);
091
092 return JournalFolderPermission.contains(
093 permissionChecker, folder, actionId);
094 }
095
096 @Override
097 public boolean isCategorizable() {
098 return _CATEGORIZABLE;
099 }
100
101 @Override
102 public boolean isLinkable() {
103 return _LINKABLE;
104 }
105
106 @Override
107 protected String getIconPath(ThemeDisplay themeDisplay) {
108 return themeDisplay.getPathThemeImages() + "/common/folder.png";
109 }
110
111 private static final boolean _CATEGORIZABLE = false;
112
113 private static final boolean _LINKABLE = false;
114
115 }