com.liferay.journal.internal.security.permission.resource.JournalPortletResourcePermissionRegsitrar 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.internal.security.permission.resource;
import com.liferay.exportimport.kernel.staging.permission.StagingPermission;
import com.liferay.journal.constants.JournalConstants;
import com.liferay.journal.constants.JournalPortletKeys;
import com.liferay.portal.kernel.model.Group;
import com.liferay.portal.kernel.security.permission.ActionKeys;
import com.liferay.portal.kernel.security.permission.PermissionChecker;
import com.liferay.portal.kernel.security.permission.resource.PortletResourcePermission;
import com.liferay.portal.kernel.security.permission.resource.PortletResourcePermissionFactory;
import com.liferay.portal.kernel.security.permission.resource.StagedPortletPermissionLogic;
import com.liferay.portal.kernel.util.HashMapDictionaryBuilder;
import java.util.Dictionary;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
/**
* @author Preston Crary
*/
@Component(service = {})
public class JournalPortletResourcePermissionRegsitrar {
@Activate
protected void activate(BundleContext bundleContext) {
Dictionary properties =
HashMapDictionaryBuilder.put(
"resource.name", JournalConstants.RESOURCE_NAME
).build();
_serviceRegistration = bundleContext.registerService(
PortletResourcePermission.class,
PortletResourcePermissionFactory.create(
JournalConstants.RESOURCE_NAME,
new StagedPortletPermissionLogic(
_stagingPermission, JournalPortletKeys.JOURNAL) {
@Override
public Boolean contains(
PermissionChecker permissionChecker, String name,
Group group, String actionId) {
if (actionId.equals(ActionKeys.SUBSCRIBE)) {
return null;
}
return super.contains(
permissionChecker, name, group, actionId);
}
}),
properties);
}
@Deactivate
protected void deactivate() {
_serviceRegistration.unregister();
}
private ServiceRegistration _serviceRegistration;
@Reference
private StagingPermission _stagingPermission;
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy