
com.liferay.commerce.product.service.impl.CPOptionValueServiceImpl 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.commerce.product.service.impl;
import com.liferay.commerce.product.constants.CPActionKeys;
import com.liferay.commerce.product.constants.CPConstants;
import com.liferay.commerce.product.model.CPOption;
import com.liferay.commerce.product.model.CPOptionValue;
import com.liferay.commerce.product.service.base.CPOptionValueServiceBaseImpl;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.security.permission.resource.PortletResourcePermission;
import com.liferay.portal.kernel.security.permission.resource.PortletResourcePermissionFactory;
import com.liferay.portal.kernel.service.ServiceContext;
import java.util.List;
import java.util.Locale;
import java.util.Map;
/**
* @author Marco Leo
*/
public class CPOptionValueServiceImpl extends CPOptionValueServiceBaseImpl {
@Override
public CPOptionValue addCPOptionValue(
long cpOptionId, Map titleMap, double priority,
String key, ServiceContext serviceContext)
throws PortalException {
CPOption cpOption = cpOptionLocalService.getCPOption(cpOptionId);
_portletResourcePermission.check(
getPermissionChecker(), cpOption.getGroupId(),
CPActionKeys.MANAGE_CATALOG);
return cpOptionValueLocalService.addCPOptionValue(
cpOption.getCPOptionId(), titleMap, priority, key, serviceContext);
}
@Override
public void deleteCPOptionValue(long cpOptionValueId)
throws PortalException {
CPOptionValue cpOptionValue = cpOptionValueService.getCPOptionValue(
cpOptionValueId);
cpOptionValueLocalService.deleteCPOptionValue(cpOptionValue);
}
@Override
public CPOptionValue fetchCPOptionValue(long cpOptionValueId)
throws PortalException {
CPOptionValue cpOptionValue =
cpOptionValueLocalService.fetchCPOptionValue(cpOptionValueId);
if (cpOptionValue != null) {
_portletResourcePermission.check(
getPermissionChecker(), cpOptionValue.getGroupId(),
CPActionKeys.MANAGE_CATALOG);
}
return cpOptionValue;
}
@Override
public CPOptionValue getCPOptionValue(long cpOptionValueId)
throws PortalException {
CPOptionValue cpOptionValue =
cpOptionValueLocalService.getCPOptionValue(cpOptionValueId);
_portletResourcePermission.check(
getPermissionChecker(), cpOptionValue.getGroupId(),
CPActionKeys.MANAGE_CATALOG);
return cpOptionValue;
}
@Override
public List getCPOptionValues(
long cpOptionId, int start, int end)
throws PortalException {
_portletResourcePermission.check(
getPermissionChecker(), cpOptionId, CPActionKeys.MANAGE_CATALOG);
return cpOptionValueLocalService.getCPOptionValues(
cpOptionId, start, end);
}
@Override
public int getCPOptionValuesCount(long cpOptionId) throws PortalException {
_portletResourcePermission.check(
getPermissionChecker(), cpOptionId, CPActionKeys.MANAGE_CATALOG);
return cpOptionValueLocalService.getCPOptionValuesCount(cpOptionId);
}
@Override
public CPOptionValue updateCPOptionValue(
long cpOptionValueId, Map titleMap, double priority,
String key, ServiceContext serviceContext)
throws PortalException {
CPOptionValue cpOptionValue = cpOptionValueService.getCPOptionValue(
cpOptionValueId);
return cpOptionValueLocalService.updateCPOptionValue(
cpOptionValue.getCPOptionValueId(), titleMap, priority, key,
serviceContext);
}
@Override
public CPOptionValue upsertCPOptionValue(
long cpOptionId, Map nameMap, double priority,
String key, String externalReferenceCode,
ServiceContext serviceContext)
throws PortalException {
CPOptionValue cpOptionValue =
cpOptionValueLocalService.fetchByExternalReferenceCode(
serviceContext.getCompanyId(), externalReferenceCode);
if (cpOptionValue == null) {
_portletResourcePermission.check(
getPermissionChecker(), serviceContext.getScopeGroupId(),
CPActionKeys.MANAGE_CATALOG);
}
return cpOptionValueLocalService.upsertCPOptionValue(
cpOptionId, nameMap, priority, key, externalReferenceCode,
serviceContext);
}
private static volatile PortletResourcePermission
_portletResourcePermission =
PortletResourcePermissionFactory.getInstance(
CPOptionServiceImpl.class, "_portletResourcePermission",
CPConstants.RESOURCE_NAME);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy