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.permission.PortletPermissionUtil;
30  import com.liferay.portal.util.PortletKeys;
31  import com.liferay.portlet.calendar.model.CalEvent;
32  import com.liferay.portlet.calendar.service.base.CalEventServiceBaseImpl;
33  import com.liferay.portlet.calendar.service.permission.CalEventPermission;
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              long plid, 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              boolean addCommunityPermissions, boolean addGuestPermissions)
53          throws PortalException, SystemException {
54  
55          PortletPermissionUtil.check(
56              getPermissionChecker(), plid, PortletKeys.CALENDAR,
57              ActionKeys.ADD_EVENT);
58  
59          return calEventLocalService.addEvent(
60              getUserId(), plid, title, description, startDateMonth, startDateDay,
61              startDateYear, startDateHour, startDateMinute, endDateMonth,
62              endDateDay, endDateYear, durationHour, durationMinute, allDay,
63              timeZoneSensitive, type, repeating, recurrence, remindBy,
64              firstReminder, secondReminder, addCommunityPermissions,
65              addGuestPermissions);
66      }
67  
68      public CalEvent addEvent(
69              long plid, String title, String description, int startDateMonth,
70              int startDateDay, int startDateYear, int startDateHour,
71              int startDateMinute, int endDateMonth, int endDateDay,
72              int endDateYear, int durationHour, int durationMinute,
73              boolean allDay, boolean timeZoneSensitive, String type,
74              boolean repeating, TZSRecurrence recurrence, int remindBy,
75              int firstReminder, int secondReminder,
76              String[] communityPermissions, String[] guestPermissions)
77          throws PortalException, SystemException {
78  
79          PortletPermissionUtil.check(
80              getPermissionChecker(), plid, PortletKeys.CALENDAR,
81              ActionKeys.ADD_EVENT);
82  
83          return calEventLocalService.addEvent(
84              getUserId(), plid, title, description, startDateMonth, startDateDay,
85              startDateYear, startDateHour, startDateMinute, endDateMonth,
86              endDateDay, endDateYear, durationHour, durationMinute, allDay,
87              timeZoneSensitive, type, repeating, recurrence, remindBy,
88              firstReminder, secondReminder, communityPermissions,
89              guestPermissions);
90      }
91  
92      public void deleteEvent(long eventId)
93          throws PortalException, SystemException {
94  
95          CalEventPermission.check(
96              getPermissionChecker(), eventId, ActionKeys.DELETE);
97  
98          calEventLocalService.deleteEvent(eventId);
99      }
100 
101     public File exportEvent(long eventId)
102         throws PortalException, SystemException {
103 
104         CalEventPermission.check(
105             getPermissionChecker(), eventId, ActionKeys.VIEW);
106 
107         return calEventLocalService.exportEvent(getGuestOrUserId(), eventId);
108     }
109 
110     public File exportGroupEvents(long plid, String fileName)
111         throws PortalException, SystemException {
112 
113         PortletPermissionUtil.check(
114             getPermissionChecker(), plid, PortletKeys.CALENDAR,
115             ActionKeys.EXPORT_ALL_EVENTS);
116 
117         return calEventLocalService.exportGroupEvents(
118             getUserId(), plid, fileName);
119     }
120 
121     public CalEvent getEvent(long eventId)
122         throws PortalException, SystemException {
123 
124         CalEventPermission.check(
125             getPermissionChecker(), eventId, ActionKeys.VIEW);
126 
127         return calEventLocalService.getEvent(eventId);
128     }
129 
130     public void importICal4j(long plid, File file)
131         throws PortalException, SystemException {
132 
133         PortletPermissionUtil.check(
134             getPermissionChecker(), plid, PortletKeys.CALENDAR,
135             ActionKeys.ADD_EVENT);
136 
137         calEventLocalService.importICal4j(getUserId(), plid, file);
138     }
139 
140     public CalEvent updateEvent(
141             long eventId, String title, String description,
142             int startDateMonth, int startDateDay, int startDateYear,
143             int startDateHour, int startDateMinute, int endDateMonth,
144             int endDateDay, int endDateYear, int durationHour,
145             int durationMinute, boolean allDay, boolean timeZoneSensitive,
146             String type, boolean repeating, TZSRecurrence recurrence,
147             int remindBy, int firstReminder, int secondReminder)
148         throws PortalException, SystemException {
149 
150         CalEventPermission.check(
151             getPermissionChecker(), eventId, ActionKeys.UPDATE);
152 
153         return calEventLocalService.updateEvent(
154             getUserId(), eventId, title, description, startDateMonth,
155             startDateDay, startDateYear, startDateHour, startDateMinute,
156             endDateMonth, endDateDay, endDateYear, durationHour, durationMinute,
157             allDay, timeZoneSensitive, type, repeating, recurrence, remindBy,
158             firstReminder, secondReminder);
159     }
160 
161 }