All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.liferay.sharepoint.soap.repository.SharepointWSRepositoryDefiner Maven / Gradle / Ivy

There is a newer version: 5.0.22
Show newest version
/**
 * 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.sharepoint.soap.repository;

import com.liferay.portal.kernel.repository.DocumentRepository;
import com.liferay.portal.kernel.repository.RepositoryConfiguration;
import com.liferay.portal.kernel.repository.RepositoryConfigurationBuilder;
import com.liferay.portal.kernel.repository.RepositoryFactory;
import com.liferay.portal.kernel.repository.capabilities.PortalCapabilityLocator;
import com.liferay.portal.kernel.repository.capabilities.ProcessorCapability;
import com.liferay.portal.kernel.repository.registry.BaseRepositoryDefiner;
import com.liferay.portal.kernel.repository.registry.CapabilityRegistry;
import com.liferay.portal.kernel.repository.registry.RepositoryDefiner;
import com.liferay.portal.kernel.repository.registry.RepositoryFactoryRegistry;
import com.liferay.portal.kernel.resource.bundle.ResourceBundleLoader;
import com.liferay.portal.kernel.util.ResourceBundleUtil;
import com.liferay.sharepoint.soap.repository.constants.SharepointWSConstants;

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 Cristina González
 */
@Component(service = RepositoryDefiner.class)
public class SharepointWSRepositoryDefiner extends BaseRepositoryDefiner {

	@Override
	public String getClassName() {
		return SharepointWSRepository.class.getName();
	}

	@Override
	public RepositoryConfiguration getRepositoryConfiguration() {
		return _repositoryConfiguration;
	}

	@Override
	public boolean isExternalRepository() {
		return true;
	}

	@Override
	public void registerCapabilities(
		CapabilityRegistry capabilityRegistry) {

		capabilityRegistry.addSupportedCapability(
			ProcessorCapability.class,
			_portalCapabilityLocator.getProcessorCapability(
				capabilityRegistry.getTarget(),
				ProcessorCapability.ResourceGenerationStrategy.
					ALWAYS_GENERATE));
	}

	@Override
	public void registerRepositoryFactory(
		RepositoryFactoryRegistry repositoryFactoryRegistry) {

		repositoryFactoryRegistry.setRepositoryFactory(_repositoryFactory);
	}

	@Activate
	protected void activate() {
		ResourceBundleLoader resourceBundleLoader =
			locale -> ResourceBundleUtil.getBundle(locale, getClass());

		RepositoryConfigurationBuilder repositoryConfigurationBuilder =
			new RepositoryConfigurationBuilder(
				resourceBundleLoader,
				SharepointWSConstants.SHAREPOINT_LIBRARY_NAME,
				SharepointWSConstants.SHAREPOINT_LIBRARY_PATH,
				SharepointWSConstants.SHAREPOINT_SERVER_VERSION,
				SharepointWSConstants.SHAREPOINT_SITE_URL);

		_repositoryConfiguration = repositoryConfigurationBuilder.build();
	}

	@Deactivate
	protected void deactivate() {
		_repositoryConfiguration = null;
	}

	@Reference
	private PortalCapabilityLocator _portalCapabilityLocator;

	private RepositoryConfiguration _repositoryConfiguration;

	@Reference(
		target = "(repository.target.class.name=com.liferay.sharepoint.soap.repository.SharepointWSRepository)"
	)
	private RepositoryFactory _repositoryFactory;

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy