1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.service.impl;
16  
17  import com.liferay.portal.NoSuchListTypeException;
18  import com.liferay.portal.kernel.exception.PortalException;
19  import com.liferay.portal.kernel.exception.SystemException;
20  import com.liferay.portal.model.ClassName;
21  import com.liferay.portal.model.ListType;
22  import com.liferay.portal.service.base.ListTypeServiceBaseImpl;
23  
24  import java.util.List;
25  
26  /**
27   * <a href="ListTypeServiceImpl.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Brian Wing Shun Chan
30   */
31  public class ListTypeServiceImpl extends ListTypeServiceBaseImpl {
32  
33      public ListType getListType(int listTypeId)
34          throws PortalException, SystemException {
35  
36          return listTypePersistence.findByPrimaryKey(listTypeId);
37      }
38  
39      public List<ListType> getListTypes(String type) throws SystemException {
40          return listTypePersistence.findByType(type);
41      }
42  
43      public void validate(int listTypeId, String type)
44          throws PortalException, SystemException {
45  
46          ListType listType = listTypePersistence.fetchByPrimaryKey(listTypeId);
47  
48          if ((listType == null) || !listType.getType().equals(type)) {
49              NoSuchListTypeException nslte = new NoSuchListTypeException();
50  
51              nslte.setType(type);
52  
53              throw nslte;
54          }
55      }
56  
57      public void validate(int listTypeId, long classNameId, String type)
58          throws PortalException, SystemException {
59  
60          ClassName className = classNameLocalService.getClassName(classNameId);
61  
62          validate(listTypeId, className.getValue() + type);
63      }
64  
65  }