1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portlet.journal.service.impl;
16  
17  import com.liferay.portal.PortalException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portlet.journal.model.JournalArticleResource;
20  import com.liferay.portlet.journal.service.base.JournalArticleResourceLocalServiceBaseImpl;
21  
22  import java.util.List;
23  
24  /**
25   * <a href="JournalArticleResourceLocalServiceImpl.java.html"><b><i>View Source
26   * </i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   */
30  public class JournalArticleResourceLocalServiceImpl
31      extends JournalArticleResourceLocalServiceBaseImpl {
32  
33      public void deleteArticleResource(long groupId, String articleId)
34          throws PortalException, SystemException {
35  
36          journalArticleResourcePersistence.removeByG_A(groupId, articleId);
37      }
38  
39      public JournalArticleResource getArticleResource(
40              long articleResourcePrimKey)
41          throws PortalException, SystemException {
42  
43          return journalArticleResourcePersistence.findByPrimaryKey(
44              articleResourcePrimKey);
45      }
46  
47      public long getArticleResourcePrimKey(long groupId, String articleId)
48          throws SystemException {
49  
50          JournalArticleResource articleResource =
51              journalArticleResourcePersistence.fetchByG_A(groupId, articleId);
52  
53          if (articleResource == null) {
54              long articleResourcePrimKey = counterLocalService.increment();
55  
56              articleResource = journalArticleResourcePersistence.create(
57                  articleResourcePrimKey);
58  
59              articleResource.setGroupId(groupId);
60              articleResource.setArticleId(articleId);
61  
62              journalArticleResourcePersistence.update(articleResource, false);
63          }
64  
65          return articleResource.getResourcePrimKey();
66      }
67  
68      public List<JournalArticleResource> getArticleResources(long groupId)
69          throws SystemException {
70  
71          return journalArticleResourcePersistence.findByGroupId(groupId);
72      }
73  
74  }