1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portlet.announcements.service.impl;
16  
17  import com.liferay.portal.PortalException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portal.security.auth.PrincipalException;
20  import com.liferay.portal.security.permission.ActionKeys;
21  import com.liferay.portal.service.permission.PortalPermissionUtil;
22  import com.liferay.portal.service.permission.UserPermissionUtil;
23  import com.liferay.portlet.announcements.model.AnnouncementsDelivery;
24  import com.liferay.portlet.announcements.service.base.AnnouncementsDeliveryServiceBaseImpl;
25  
26  /**
27   * <a href="AnnouncementsDeliveryServiceImpl.java.html"><b><i>View Source</i>
28   * </b></a>
29   *
30   * @author Brian Wing Shun Chan
31   */
32  public class AnnouncementsDeliveryServiceImpl
33      extends AnnouncementsDeliveryServiceBaseImpl {
34  
35      public AnnouncementsDelivery updateDelivery(
36              long userId, String type, boolean email, boolean sms,
37              boolean website)
38          throws PortalException, SystemException {
39  
40          if (!PortalPermissionUtil.contains(
41                  getPermissionChecker(), ActionKeys.ADD_USER) &&
42              !UserPermissionUtil.contains(
43                  getPermissionChecker(), userId, ActionKeys.UPDATE)) {
44  
45              throw new PrincipalException();
46          }
47  
48          return announcementsDeliveryLocalService.updateDelivery(
49              userId, type, email, sms, website);
50      }
51  
52  }