com.liferay.wiki.internal.security.permission.resource.WikiPortletResourcePermissionRegistrar 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.wiki.internal.security.permission.resource;
import com.liferay.exportimport.kernel.staging.permission.StagingPermission;
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.HashMapDictionary;
import com.liferay.wiki.constants.WikiConstants;
import com.liferay.wiki.constants.WikiPortletKeys;
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(immediate = true, service = {})
public class WikiPortletResourcePermissionRegistrar {
@Activate
protected void activate(BundleContext bundleContext) {
Dictionary properties = new HashMapDictionary<>();
properties.put("resource.name", WikiConstants.RESOURCE_NAME);
_serviceRegistration = bundleContext.registerService(
PortletResourcePermission.class,
PortletResourcePermissionFactory.create(
WikiConstants.RESOURCE_NAME,
new StagedPortletPermissionLogic(
_stagingPermission, WikiPortletKeys.WIKI_ADMIN)),
properties);
}
@Deactivate
protected void deactivate() {
_serviceRegistration.unregister();
}
private ServiceRegistration _serviceRegistration;
@Reference
private StagingPermission _stagingPermission;
}