1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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  public class CalEventServiceImpl extends CalEventServiceBaseImpl {
43  
44      public CalEvent addEvent(
45              String title, String description, int startDateMonth,
46              int startDateDay, int startDateYear, int startDateHour,
47              int startDateMinute, int endDateMonth, int endDateDay,
48              int endDateYear, int durationHour, int durationMinute,
49              boolean allDay, boolean timeZoneSensitive, String type,
50              boolean repeating, TZSRecurrence recurrence, int remindBy,
51              int firstReminder, int secondReminder,
52              ServiceContext serviceContext)
53          throws PortalException, SystemException {
54  
55          CalendarPermission.check(
56              getPermissionChecker(), serviceContext.getScopeGroupId(),
57              ActionKeys.ADD_EVENT);
58  
59          return calEventLocalService.addEvent(
60              getUserId(), title, description, startDateMonth, startDateDay,
61              startDateYear, startDateHour, startDateMinute, endDateMonth,
62              endDateDay, endDateYear, durationHour, durationMinute, allDay,
63              timeZoneSensitive, type, repeating, recurrence, remindBy,
64              firstReminder, secondReminder, serviceContext);
65      }
66  
67      public void deleteEvent(long eventId)
68          throws PortalException, SystemException {
69  
70          CalEventPermission.check(
71              getPermissionChecker(), eventId, ActionKeys.DELETE);
72  
73          calEventLocalService.deleteEvent(eventId);
74      }
75  
76      public File exportEvent(long eventId)
77          throws PortalException, SystemException {
78  
79          CalEventPermission.check(
80              getPermissionChecker(), eventId, ActionKeys.VIEW);
81  
82          return calEventLocalService.exportEvent(getGuestOrUserId(), eventId);
83      }
84  
85      public File exportGroupEvents(long groupId, String fileName)
86          throws PortalException, SystemException {
87  
88          CalendarPermission.check(
89              getPermissionChecker(), groupId, ActionKeys.EXPORT_ALL_EVENTS);
90  
91          return calEventLocalService.exportGroupEvents(
92              getUserId(), groupId, fileName);
93      }
94  
95      public CalEvent getEvent(long eventId)
96          throws PortalException, SystemException {
97  
98          CalEventPermission.check(
99              getPermissionChecker(), eventId, ActionKeys.VIEW);
100 
101         return calEventLocalService.getEvent(eventId);
102     }
103 
104     public void importICal4j(long groupId, File file)
105         throws PortalException, SystemException {
106 
107         CalendarPermission.check(
108             getPermissionChecker(), groupId, ActionKeys.ADD_EVENT);
109 
110         calEventLocalService.importICal4j(getUserId(), groupId, file);
111     }
112 
113     public CalEvent updateEvent(
114             long eventId, String title, String description,
115             int startDateMonth, int startDateDay, int startDateYear,
116             int startDateHour, int startDateMinute, int endDateMonth,
117             int endDateDay, int endDateYear, int durationHour,
118             int durationMinute, boolean allDay, boolean timeZoneSensitive,
119             String type, boolean repeating, TZSRecurrence recurrence,
120             int remindBy, int firstReminder, int secondReminder,
121             ServiceContext serviceContext)
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, serviceContext);
133     }
134 
135 }