001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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    }