1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.calendar.service.impl;
24  
25  import com.liferay.portal.PortalException;
26  import com.liferay.portal.SystemException;
27  import com.liferay.portal.kernel.cal.TZSRecurrence;
28  import com.liferay.portal.security.permission.ActionKeys;
29  import com.liferay.portal.service.ServiceContext;
30  import com.liferay.portlet.calendar.model.CalEvent;
31  import com.liferay.portlet.calendar.service.base.CalEventServiceBaseImpl;
32  import com.liferay.portlet.calendar.service.permission.CalEventPermission;
33  import com.liferay.portlet.calendar.service.permission.CalendarPermission;
34  
35  import java.io.File;
36  
37  /**
38   * <a href="CalEventServiceImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * @author Brian Wing Shun Chan
41   *
42   */
43  public class CalEventServiceImpl extends CalEventServiceBaseImpl {
44  
45      public CalEvent addEvent(
46              String title, String description, int startDateMonth,
47              int startDateDay, int startDateYear, int startDateHour,
48              int startDateMinute, int endDateMonth, int endDateDay,
49              int endDateYear, int durationHour, int durationMinute,
50              boolean allDay, boolean timeZoneSensitive, String type,
51              boolean repeating, TZSRecurrence recurrence, String remindBy,
52              int firstReminder, int secondReminder,
53              ServiceContext serviceContext)
54          throws PortalException, SystemException {
55  
56          CalendarPermission.check(
57              getPermissionChecker(), serviceContext.getScopeGroupId(),
58              ActionKeys.ADD_EVENT);
59  
60          return calEventLocalService.addEvent(
61              getUserId(), title, description, startDateMonth, startDateDay,
62              startDateYear, startDateHour, startDateMinute, endDateMonth,
63              endDateDay, endDateYear, durationHour, durationMinute, allDay,
64              timeZoneSensitive, type, repeating, recurrence, remindBy,
65              firstReminder, secondReminder, serviceContext);
66      }
67  
68      public void deleteEvent(long eventId)
69          throws PortalException, SystemException {
70  
71          CalEventPermission.check(
72              getPermissionChecker(), eventId, ActionKeys.DELETE);
73  
74          calEventLocalService.deleteEvent(eventId);
75      }
76  
77      public File exportEvent(long eventId)
78          throws PortalException, SystemException {
79  
80          CalEventPermission.check(
81              getPermissionChecker(), eventId, ActionKeys.VIEW);
82  
83          return calEventLocalService.exportEvent(getUserId(), eventId);
84      }
85  
86      public File exportGroupEvents(long groupId, String fileName)
87          throws PortalException, SystemException {
88  
89          CalendarPermission.check(
90              getPermissionChecker(), groupId, ActionKeys.EXPORT_ALL_EVENTS);
91  
92          return calEventLocalService.exportGroupEvents(
93              getUserId(), groupId, fileName);
94      }
95  
96      public CalEvent getEvent(long eventId)
97          throws PortalException, SystemException {
98  
99          CalEventPermission.check(
100             getPermissionChecker(), eventId, ActionKeys.VIEW);
101 
102         return calEventLocalService.getEvent(eventId);
103     }
104 
105     public void importICal4j(long groupId, File file)
106         throws PortalException, SystemException {
107 
108         CalendarPermission.check(
109             getPermissionChecker(), groupId, ActionKeys.ADD_EVENT);
110 
111         calEventLocalService.importICal4j(getUserId(), groupId, file);
112     }
113 
114     public CalEvent updateEvent(
115             long eventId, String title, String description,
116             int startDateMonth, int startDateDay, int startDateYear,
117             int startDateHour, int startDateMinute, int endDateMonth,
118             int endDateDay, int endDateYear, int durationHour,
119             int durationMinute, boolean allDay, boolean timeZoneSensitive,
120             String type, boolean repeating, TZSRecurrence recurrence,
121             String remindBy, int firstReminder, int secondReminder)
122         throws PortalException, SystemException {
123 
124         CalEventPermission.check(
125             getPermissionChecker(), eventId, ActionKeys.UPDATE);
126 
127         return calEventLocalService.updateEvent(
128             getUserId(), eventId, title, description, startDateMonth,
129             startDateDay, startDateYear, startDateHour, startDateMinute,
130             endDateMonth, endDateDay, endDateYear, durationHour, durationMinute,
131             allDay, timeZoneSensitive, type, repeating, recurrence, remindBy,
132             firstReminder, secondReminder);
133     }
134 
135 }