001    /**
002     * Copyright (c) 2000-present 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.security.auth.PrincipalException;
019    import com.liferay.portlet.announcements.model.AnnouncementsFlag;
020    import com.liferay.portlet.announcements.service.base.AnnouncementsFlagServiceBaseImpl;
021    
022    /**
023     * @author Thiago Moreira
024     * @author Raymond Aug??
025     */
026    public class AnnouncementsFlagServiceImpl
027            extends AnnouncementsFlagServiceBaseImpl {
028    
029            @Override
030            public void addFlag(long entryId, int value) throws PortalException {
031                    announcementsFlagLocalService.addFlag(getUserId(), entryId, value);
032            }
033    
034            @Override
035            public void deleteFlag(long flagId) throws PortalException {
036                    AnnouncementsFlag flag = announcementsFlagPersistence.findByPrimaryKey(
037                            flagId);
038    
039                    if (flag.getUserId() != getUserId()) {
040                            throw new PrincipalException();
041                    }
042    
043                    announcementsFlagLocalService.deleteFlag(flagId);
044            }
045    
046            @Override
047            public AnnouncementsFlag getFlag(long entryId, int value)
048                    throws PortalException {
049    
050                    return announcementsFlagLocalService.getFlag(
051                            getUserId(), entryId, value);
052            }
053    
054    }