001    /**
002     * Copyright (c) 2000-2013 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            @Override
031            public void addFlag(long entryId, int value)
032                    throws PortalException, SystemException {
033    
034                    announcementsFlagLocalService.addFlag(getUserId(), entryId, value);
035            }
036    
037            @Override
038            public void deleteFlag(long flagId)
039                    throws PortalException, SystemException {
040    
041                    AnnouncementsFlag flag = announcementsFlagPersistence.findByPrimaryKey(
042                            flagId);
043    
044                    if (flag.getUserId() != getUserId()) {
045                            throw new PrincipalException();
046                    }
047    
048                    announcementsFlagLocalService.deleteFlag(flagId);
049            }
050    
051            @Override
052            public AnnouncementsFlag getFlag(long entryId, int value)
053                    throws PortalException, SystemException {
054    
055                    return announcementsFlagLocalService.getFlag(
056                            getUserId(), entryId, value);
057            }
058    
059    }