com.liferay.journal.web.internal.asset.model.JournalFolderAssetRendererFactory Maven / Gradle / Ivy
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
package com.liferay.journal.web.internal.asset.model;
import com.liferay.asset.kernel.model.AssetRenderer;
import com.liferay.asset.kernel.model.AssetRendererFactory;
import com.liferay.asset.kernel.model.BaseAssetRendererFactory;
import com.liferay.journal.constants.JournalPortletKeys;
import com.liferay.journal.model.JournalFolder;
import com.liferay.journal.service.JournalFolderLocalService;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.portlet.LiferayPortletResponse;
import com.liferay.portal.kernel.portlet.LiferayPortletURL;
import com.liferay.portal.kernel.security.permission.PermissionChecker;
import com.liferay.portal.kernel.security.permission.resource.ModelResourcePermission;
import com.liferay.trash.TrashHelper;
import javax.portlet.PortletRequest;
import javax.portlet.PortletURL;
import javax.portlet.WindowState;
import javax.portlet.WindowStateException;
import javax.servlet.ServletContext;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
/**
* @author Alexander Chow
*/
@Component(
property = "javax.portlet.name=" + JournalPortletKeys.JOURNAL,
service = AssetRendererFactory.class
)
public class JournalFolderAssetRendererFactory
extends BaseAssetRendererFactory {
public static final String TYPE = "content_folder";
public JournalFolderAssetRendererFactory() {
setCategorizable(false);
setClassName(JournalFolder.class.getName());
setPortletId(JournalPortletKeys.JOURNAL);
setSearchable(true);
}
@Override
public AssetRenderer getAssetRenderer(long classPK, int type)
throws PortalException {
JournalFolderAssetRenderer journalFolderAssetRenderer =
new JournalFolderAssetRenderer(
_journalFolderLocalService.getFolder(classPK), _trashHelper);
journalFolderAssetRenderer.setAssetRendererType(type);
journalFolderAssetRenderer.setServletContext(_servletContext);
return journalFolderAssetRenderer;
}
@Override
public String getClassName() {
return JournalFolder.class.getName();
}
@Override
public String getIconCssClass() {
return "folder";
}
@Override
public String getType() {
return TYPE;
}
@Override
public PortletURL getURLView(
LiferayPortletResponse liferayPortletResponse,
WindowState windowState) {
LiferayPortletURL liferayPortletURL =
liferayPortletResponse.createLiferayPortletURL(
JournalPortletKeys.JOURNAL, PortletRequest.RENDER_PHASE);
try {
liferayPortletURL.setWindowState(windowState);
}
catch (WindowStateException windowStateException) {
if (_log.isDebugEnabled()) {
_log.debug(windowStateException);
}
}
return liferayPortletURL;
}
@Override
public boolean hasPermission(
PermissionChecker permissionChecker, long classPK, String actionId)
throws Exception {
return _journalFolderModelResourcePermission.contains(
permissionChecker, classPK, actionId);
}
private static final Log _log = LogFactoryUtil.getLog(
JournalFolderAssetRendererFactory.class);
@Reference
private JournalFolderLocalService _journalFolderLocalService;
@Reference(
target = "(model.class.name=com.liferay.journal.model.JournalFolder)"
)
private ModelResourcePermission
_journalFolderModelResourcePermission;
@Reference(target = "(osgi.web.symbolicname=com.liferay.journal.web)")
private ServletContext _servletContext;
@Reference
private TrashHelper _trashHelper;
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy