/**
* 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.wiki.web.internal.security.permission;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.security.permission.BasePermissionPropagator;
import com.liferay.portal.kernel.security.permission.PermissionPropagator;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.wiki.constants.WikiPortletKeys;
import com.liferay.wiki.model.WikiNode;
import com.liferay.wiki.model.WikiPage;
import com.liferay.wiki.service.WikiPageLocalService;
import java.util.List;
import javax.portlet.ActionRequest;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
/**
* @author Hugo Huijser
* @author Angelo Jefferson
*/
@Component(
immediate = true,
property = {
"javax.portlet.name=" + WikiPortletKeys.WIKI,
"javax.portlet.name=" + WikiPortletKeys.WIKI_ADMIN,
"javax.portlet.name=" + WikiPortletKeys.WIKI_DISPLAY
},
service = PermissionPropagator.class
)
public class WikiPermissionPropagatorImpl extends BasePermissionPropagator {
@Override
public void propagateRolePermissions(
ActionRequest actionRequest, String className, String primKey,
long[] roleIds)
throws PortalException {
if (!className.equals(WikiNode.class.getName())) {
return;
}
long nodeId = GetterUtil.getLong(primKey);
List<WikiPage> wikiPages = _wikiPageLocalService.getPages(
nodeId, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
for (WikiPage wikiPage : wikiPages) {
for (long roleId : roleIds) {
propagateRolePermissions(
actionRequest, roleId, WikiNode.class.getName(), nodeId,
WikiPage.class.getName(), wikiPage.getResourcePrimKey());
}
}
}
@Reference(unbind = "-")
protected void setWikiPageLocalService(
WikiPageLocalService wikiPageLocalService) {
_wikiPageLocalService = wikiPageLocalService;
}
private WikiPageLocalService _wikiPageLocalService;
}