001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.announcements.service.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.security.auth.PrincipalException;
020    import com.liferay.portlet.announcements.model.AnnouncementsFlag;
021    import com.liferay.portlet.announcements.service.base.AnnouncementsFlagServiceBaseImpl;
022    
023    /**
024     * @author Thiago Moreira
025     * @author Raymond Augé
026     */
027    public class AnnouncementsFlagServiceImpl
028            extends AnnouncementsFlagServiceBaseImpl {
029    
030            public void addFlag(long entryId, int value)
031                    throws PortalException, SystemException {
032    
033                    announcementsFlagLocalService.addFlag(getUserId(), entryId, value);
034            }
035    
036            public void deleteFlag(long flagId)
037                    throws PortalException, SystemException {
038    
039                    AnnouncementsFlag flag = announcementsFlagPersistence.findByPrimaryKey(
040                            flagId);
041    
042                    if (flag.getUserId() != getUserId()) {
043                            throw new PrincipalException();
044                    }
045    
046                    announcementsFlagLocalService.deleteFlag(flagId);
047            }
048    
049            public AnnouncementsFlag getFlag(long entryId, int value)
050                    throws PortalException, SystemException {
051    
052                    return announcementsFlagLocalService.getFlag(
053                            getUserId(), entryId, value);
054            }
055    
056    }