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

com.liferay.commerce.product.service.impl.CommerceChannelRelServiceImpl 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.commerce.product.service.impl;

import com.liferay.commerce.product.model.CPDefinition;
import com.liferay.commerce.product.model.CommerceChannel;
import com.liferay.commerce.product.model.CommerceChannelRel;
import com.liferay.commerce.product.service.base.CommerceChannelRelServiceBaseImpl;
import com.liferay.petra.string.StringPool;
import com.liferay.portal.aop.AopService;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.security.permission.ActionKeys;
import com.liferay.portal.kernel.security.permission.resource.ModelResourcePermission;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.util.OrderByComparator;

import java.util.List;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

/**
 * @author Alessio Antonio Rendina
 */
@Component(
	property = {
		"json.web.service.context.name=commerce",
		"json.web.service.context.path=CommerceChannelRel"
	},
	service = AopService.class
)
public class CommerceChannelRelServiceImpl
	extends CommerceChannelRelServiceBaseImpl {

	@Override
	public CommerceChannelRel addCommerceChannelRel(
			String className, long classPK, long commerceChannelId,
			ServiceContext serviceContext)
		throws PortalException {

		_commerceChannelModelResourcePermission.check(
			getPermissionChecker(), commerceChannelId, ActionKeys.UPDATE);

		return commerceChannelRelLocalService.addCommerceChannelRel(
			className, classPK, commerceChannelId, serviceContext);
	}

	@Override
	public List addCommerceChannelRels(
			String className, long[] classPKs, long commerceChannelId,
			ServiceContext serviceContext)
		throws PortalException {

		_commerceChannelModelResourcePermission.check(
			getPermissionChecker(), commerceChannelId, ActionKeys.UPDATE);

		return commerceChannelRelLocalService.addCommerceChannelRels(
			className, classPKs, commerceChannelId, serviceContext);
	}

	@Override
	public void deleteCommerceChannelRel(long commerceChannelRelId)
		throws PortalException {

		CommerceChannelRel commerceChannelRel =
			commerceChannelRelLocalService.getCommerceChannelRel(
				commerceChannelRelId);

		_commerceChannelModelResourcePermission.check(
			getPermissionChecker(), commerceChannelRel.getCommerceChannelId(),
			ActionKeys.UPDATE);

		commerceChannelRelLocalService.deleteCommerceChannelRel(
			commerceChannelRelId);
	}

	@Override
	public void deleteCommerceChannelRels(String className, long classPK)
		throws PortalException {

		List commerceChannelRels =
			commerceChannelRelLocalService.getCommerceChannelRels(
				className, classPK, StringPool.BLANK, QueryUtil.ALL_POS,
				QueryUtil.ALL_POS);

		for (CommerceChannelRel commerceChannelRel : commerceChannelRels) {
			commerceChannelRelLocalService.deleteCommerceChannelRel(
				commerceChannelRel.getCommerceChannelRelId());
		}
	}

	@Override
	public CommerceChannelRel fetchCommerceChannelRel(
			String className, long classPK, long commerceChannelId)
		throws PortalException {

		_commerceChannelModelResourcePermission.check(
			getPermissionChecker(), commerceChannelId, ActionKeys.VIEW);

		return commerceChannelRelLocalService.fetchCommerceChannelRel(
			className, classPK, commerceChannelId);
	}

	@Override
	public List getCommerceChannelCountries(
			long commerceChannelId, String name, int start, int end)
		throws PortalException {

		_commerceChannelModelResourcePermission.check(
			getPermissionChecker(), commerceChannelId, ActionKeys.VIEW);

		return commerceChannelRelLocalService.getCommerceChannelCountries(
			commerceChannelId, name, start, end);
	}

	@Override
	public int getCommerceChannelCountriesCount(
			long commerceChannelId, String name)
		throws PortalException {

		_commerceChannelModelResourcePermission.check(
			getPermissionChecker(), commerceChannelId, ActionKeys.VIEW);

		return commerceChannelRelLocalService.getCommerceChannelCountriesCount(
			commerceChannelId, name);
	}

	@Override
	public CommerceChannelRel getCommerceChannelRel(long commerceChannelRelId)
		throws PortalException {

		CommerceChannelRel commerceChannelRel =
			commerceChannelRelLocalService.getCommerceChannelRel(
				commerceChannelRelId);

		_commerceChannelModelResourcePermission.check(
			getPermissionChecker(), commerceChannelRel.getCommerceChannelId(),
			ActionKeys.VIEW);

		return commerceChannelRel;
	}

	@Override
	public List getCommerceChannelRels(
			long commerceChannelId, int start, int end,
			OrderByComparator orderByComparator)
		throws PortalException {

		_commerceChannelModelResourcePermission.check(
			getPermissionChecker(), commerceChannelId, ActionKeys.VIEW);

		return commerceChannelRelLocalService.getCommerceChannelRels(
			commerceChannelId, start, end, orderByComparator);
	}

	@Override
	public List getCommerceChannelRels(
			String className, long classPK, String name, int start, int end)
		throws PortalException {

		if (className.equals(CPDefinition.class.getName())) {
			_cpDefinitionModelResourcePermission.check(
				getPermissionChecker(), classPK, ActionKeys.VIEW);
		}

		return commerceChannelRelFinder.findByC_C(
			className, classPK, name, start, end, true);
	}

	@Override
	public int getCommerceChannelRelsCount(long commerceChannelId)
		throws PortalException {

		_commerceChannelModelResourcePermission.check(
			getPermissionChecker(), commerceChannelId, ActionKeys.VIEW);

		return commerceChannelRelLocalService.getCommerceChannelRelsCount(
			commerceChannelId);
	}

	@Override
	public int getCommerceChannelRelsCount(String className, long classPK)
		throws PortalException {

		return commerceChannelRelService.getCommerceChannelRelsCount(
			className, classPK, StringPool.BLANK);
	}

	@Override
	public int getCommerceChannelRelsCount(
			String className, long classPK, String name)
		throws PortalException {

		if (className.equals(CPDefinition.class.getName())) {
			_cpDefinitionModelResourcePermission.check(
				getPermissionChecker(), classPK, ActionKeys.VIEW);
		}

		return commerceChannelRelFinder.countByC_C(
			className, classPK, name, true);
	}

	@Reference(
		target = "(model.class.name=com.liferay.commerce.product.model.CommerceChannel)"
	)
	private ModelResourcePermission
		_commerceChannelModelResourcePermission;

	@Reference(
		target = "(model.class.name=com.liferay.commerce.product.model.CPDefinition)"
	)
	private ModelResourcePermission
		_cpDefinitionModelResourcePermission;

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy