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.portlet.announcements.service.impl;
16  
17  import com.liferay.portal.kernel.exception.PortalException;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.security.auth.PrincipalException;
20  import com.liferay.portlet.announcements.model.AnnouncementsFlag;
21  import com.liferay.portlet.announcements.service.base.AnnouncementsFlagServiceBaseImpl;
22  
23  /**
24   * <a href="AnnouncementsFlagServiceImpl.java.html"><b><i>View Source</i></b>
25   * </a>
26   *
27   * @author Thiago Moreira
28   * @author Raymond Augé
29   */
30  public class AnnouncementsFlagServiceImpl
31      extends AnnouncementsFlagServiceBaseImpl {
32  
33      public void addFlag(long entryId, int value)
34          throws PortalException, SystemException {
35  
36          announcementsFlagLocalService.addFlag(getUserId(), entryId, value);
37      }
38  
39      public void deleteFlag(long flagId)
40          throws PortalException, SystemException {
41  
42          AnnouncementsFlag flag = announcementsFlagPersistence.findByPrimaryKey(
43              flagId);
44  
45          if (flag.getUserId() != getUserId()) {
46              throw new PrincipalException();
47          }
48  
49          announcementsFlagLocalService.deleteFlag(flagId);
50      }
51  
52      public AnnouncementsFlag getFlag(long entryId, int value)
53          throws PortalException, SystemException {
54  
55          return announcementsFlagLocalService.getFlag(
56              getUserId(), entryId, value);
57      }
58  
59  }