
com.liferay.journal.web.asset.JournalFolderAssetRenderer Maven / Gradle / Ivy
/**
* 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.journal.web.asset;
import com.liferay.asset.kernel.model.AssetRendererFactory;
import com.liferay.asset.kernel.model.BaseJSPAssetRenderer;
import com.liferay.journal.constants.JournalPortletKeys;
import com.liferay.journal.model.JournalFolder;
import com.liferay.journal.service.permission.JournalFolderPermission;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.model.Group;
import com.liferay.portal.kernel.portlet.LiferayPortletRequest;
import com.liferay.portal.kernel.portlet.LiferayPortletResponse;
import com.liferay.portal.kernel.security.permission.ActionKeys;
import com.liferay.portal.kernel.security.permission.PermissionChecker;
import com.liferay.portal.kernel.service.GroupLocalServiceUtil;
import com.liferay.portal.kernel.trash.TrashRenderer;
import com.liferay.portal.kernel.util.PortalUtil;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.trash.kernel.util.TrashUtil;
import java.util.Date;
import java.util.Locale;
import javax.portlet.PortletRequest;
import javax.portlet.PortletResponse;
import javax.portlet.PortletURL;
import javax.portlet.WindowState;
import javax.servlet.http.HttpServletRequest;
/**
* @author Alexander Chow
*/
public class JournalFolderAssetRenderer
extends BaseJSPAssetRenderer implements TrashRenderer {
public static final String TYPE = "folder";
public JournalFolderAssetRenderer(JournalFolder folder) {
_folder = folder;
}
@Override
public JournalFolder getAssetObject() {
return _folder;
}
@Override
public String getClassName() {
return JournalFolder.class.getName();
}
@Override
public long getClassPK() {
return _folder.getFolderId();
}
/**
* @deprecated As of 7.0.0, with no direct replacement
*/
@Deprecated
@Override
public Date getDisplayDate() {
return _folder.getModifiedDate();
}
@Override
public long getGroupId() {
return _folder.getGroupId();
}
@Override
public String getJspPath(HttpServletRequest request, String template) {
if (template.equals(TEMPLATE_FULL_CONTENT)) {
request.setAttribute(WebKeys.JOURNAL_FOLDER, _folder);
return "/asset/folder_" + template + ".jsp";
}
else {
return null;
}
}
@Override
public String getPortletId() {
AssetRendererFactory assetRendererFactory =
getAssetRendererFactory();
return assetRendererFactory.getPortletId();
}
@Override
public int getStatus() {
return _folder.getStatus();
}
@Override
public String getSummary(
PortletRequest portletRequest, PortletResponse portletResponse) {
return _folder.getDescription();
}
@Override
public String getTitle(Locale locale) {
return TrashUtil.getOriginalTitle(_folder.getName());
}
@Override
public String getType() {
return TYPE;
}
@Override
public PortletURL getURLEdit(
LiferayPortletRequest liferayPortletRequest,
LiferayPortletResponse liferayPortletResponse)
throws Exception {
Group group = GroupLocalServiceUtil.fetchGroup(_folder.getGroupId());
PortletURL portletURL = PortalUtil.getControlPanelPortletURL(
liferayPortletRequest, group, JournalPortletKeys.JOURNAL, 0, 0,
PortletRequest.RENDER_PHASE);
portletURL.setParameter("mvcPath", "/edit_folder.jsp");
portletURL.setParameter(
"folderId", String.valueOf(_folder.getFolderId()));
return portletURL;
}
@Override
public String getURLView(
LiferayPortletResponse liferayPortletResponse,
WindowState windowState)
throws Exception {
AssetRendererFactory assetRendererFactory =
getAssetRendererFactory();
PortletURL portletURL = assetRendererFactory.getURLView(
liferayPortletResponse, windowState);
portletURL.setParameter("mvcPath", "/asset/folder_full_content.jsp");
portletURL.setParameter(
"folderId", String.valueOf(_folder.getFolderId()));
portletURL.setWindowState(windowState);
return portletURL.toString();
}
@Override
public String getURLViewInContext(
LiferayPortletRequest liferayPortletRequest,
LiferayPortletResponse liferayPortletResponse,
String noSuchEntryRedirect) {
try {
return getURLView(liferayPortletResponse, WindowState.MAXIMIZED);
}
catch (Exception e) {
return noSuchEntryRedirect;
}
}
@Override
public long getUserId() {
return _folder.getUserId();
}
@Override
public String getUserName() {
return _folder.getUserName();
}
@Override
public String getUuid() {
return _folder.getUuid();
}
@Override
public boolean hasEditPermission(PermissionChecker permissionChecker)
throws PortalException {
return JournalFolderPermission.contains(
permissionChecker, _folder, ActionKeys.UPDATE);
}
@Override
public boolean hasViewPermission(PermissionChecker permissionChecker)
throws PortalException {
return JournalFolderPermission.contains(
permissionChecker, _folder, ActionKeys.VIEW);
}
private final JournalFolder _folder;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy