001
014
015 package com.liferay.portal.service.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.exception.NoSuchListTypeException;
020 import com.liferay.portal.kernel.exception.PortalException;
021 import com.liferay.portal.model.ClassName;
022 import com.liferay.portal.model.ListType;
023 import com.liferay.portal.service.base.ListTypeLocalServiceBaseImpl;
024
025 import java.util.List;
026
027
030 @ProviderType
031 public class ListTypeLocalServiceImpl extends ListTypeLocalServiceBaseImpl {
032
033 @Override
034 public ListType addListType(String name, String type) {
035 ListType listType = listTypePersistence.fetchByN_T(name, type);
036
037 if (listType != null) {
038 return listType;
039 }
040
041 long listTypeId = counterLocalService.increment(
042 ListType.class.getName());
043
044 listType = listTypePersistence.create(listTypeId);
045
046 listType.setName(name);
047 listType.setType(type);
048
049 listTypePersistence.update(listType);
050
051 return listType;
052 }
053
054 @Override
055 public ListType getListType(long listTypeId) throws PortalException {
056 return listTypePersistence.findByPrimaryKey(listTypeId);
057 }
058
059 @Override
060 public List<ListType> getListTypes(String type) {
061 return listTypePersistence.findByType(type);
062 }
063
064 @Override
065 public void validate(long listTypeId, long classNameId, String type)
066 throws PortalException {
067
068 ClassName className = classNameLocalService.getClassName(classNameId);
069
070 validate(listTypeId, className.getValue() + type);
071 }
072
073 @Override
074 public void validate(long listTypeId, String type) throws PortalException {
075 ListType listType = listTypePersistence.fetchByPrimaryKey(listTypeId);
076
077 if ((listType == null) || !listType.getType().equals(type)) {
078 NoSuchListTypeException nslte = new NoSuchListTypeException();
079
080 nslte.setType(type);
081
082 throw nslte;
083 }
084 }
085
086 }