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.http;
24  
25  import com.liferay.portal.kernel.log.Log;
26  import com.liferay.portal.kernel.log.LogFactoryUtil;
27  import com.liferay.portal.kernel.util.BooleanWrapper;
28  import com.liferay.portal.kernel.util.IntegerWrapper;
29  import com.liferay.portal.kernel.util.LongWrapper;
30  import com.liferay.portal.kernel.util.MethodWrapper;
31  import com.liferay.portal.kernel.util.NullWrapper;
32  import com.liferay.portal.security.auth.HttpPrincipal;
33  import com.liferay.portal.service.http.TunnelUtil;
34  
35  import com.liferay.portlet.calendar.service.CalEventServiceUtil;
36  
37  /**
38   * <a href="CalEventServiceHttp.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be
42   * overwritten the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This class provides a HTTP utility for the
47   * <code>com.liferay.portlet.calendar.service.CalEventServiceUtil</code> service
48   * utility. The static methods of this class calls the same methods of the
49   * service utility. However, the signatures are different because it requires an
50   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
51   * parameter.
52   * </p>
53   *
54   * <p>
55   * The benefits of using the HTTP utility is that it is fast and allows for
56   * tunneling without the cost of serializing to text. The drawback is that it
57   * only works with Java.
58   * </p>
59   *
60   * <p>
61   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
62   * portal.properties to configure security.
63   * </p>
64   *
65   * <p>
66   * The HTTP utility is only generated for remote services.
67   * </p>
68   *
69   * @author Brian Wing Shun Chan
70   *
71   * @see com.liferay.portal.security.auth.HttpPrincipal
72   * @see com.liferay.portlet.calendar.service.CalEventServiceUtil
73   * @see com.liferay.portlet.calendar.service.http.CalEventServiceSoap
74   *
75   */
76  public class CalEventServiceHttp {
77      public static com.liferay.portlet.calendar.model.CalEvent addEvent(
78          HttpPrincipal httpPrincipal, java.lang.String title,
79          java.lang.String description, int startDateMonth, int startDateDay,
80          int startDateYear, int startDateHour, int startDateMinute,
81          int endDateMonth, int endDateDay, int endDateYear, int durationHour,
82          int durationMinute, boolean allDay, boolean timeZoneSensitive,
83          java.lang.String type, boolean repeating,
84          com.liferay.portal.kernel.cal.TZSRecurrence recurrence,
85          java.lang.String remindBy, int firstReminder, int secondReminder,
86          com.liferay.portal.service.ServiceContext serviceContext)
87          throws com.liferay.portal.PortalException,
88              com.liferay.portal.SystemException {
89          try {
90              Object paramObj0 = title;
91  
92              if (title == null) {
93                  paramObj0 = new NullWrapper("java.lang.String");
94              }
95  
96              Object paramObj1 = description;
97  
98              if (description == null) {
99                  paramObj1 = new NullWrapper("java.lang.String");
100             }
101 
102             Object paramObj2 = new IntegerWrapper(startDateMonth);
103 
104             Object paramObj3 = new IntegerWrapper(startDateDay);
105 
106             Object paramObj4 = new IntegerWrapper(startDateYear);
107 
108             Object paramObj5 = new IntegerWrapper(startDateHour);
109 
110             Object paramObj6 = new IntegerWrapper(startDateMinute);
111 
112             Object paramObj7 = new IntegerWrapper(endDateMonth);
113 
114             Object paramObj8 = new IntegerWrapper(endDateDay);
115 
116             Object paramObj9 = new IntegerWrapper(endDateYear);
117 
118             Object paramObj10 = new IntegerWrapper(durationHour);
119 
120             Object paramObj11 = new IntegerWrapper(durationMinute);
121 
122             Object paramObj12 = new BooleanWrapper(allDay);
123 
124             Object paramObj13 = new BooleanWrapper(timeZoneSensitive);
125 
126             Object paramObj14 = type;
127 
128             if (type == null) {
129                 paramObj14 = new NullWrapper("java.lang.String");
130             }
131 
132             Object paramObj15 = new BooleanWrapper(repeating);
133 
134             Object paramObj16 = recurrence;
135 
136             if (recurrence == null) {
137                 paramObj16 = new NullWrapper(
138                         "com.liferay.portal.kernel.cal.TZSRecurrence");
139             }
140 
141             Object paramObj17 = remindBy;
142 
143             if (remindBy == null) {
144                 paramObj17 = new NullWrapper("java.lang.String");
145             }
146 
147             Object paramObj18 = new IntegerWrapper(firstReminder);
148 
149             Object paramObj19 = new IntegerWrapper(secondReminder);
150 
151             Object paramObj20 = serviceContext;
152 
153             if (serviceContext == null) {
154                 paramObj20 = new NullWrapper(
155                         "com.liferay.portal.service.ServiceContext");
156             }
157 
158             MethodWrapper methodWrapper = new MethodWrapper(CalEventServiceUtil.class.getName(),
159                     "addEvent",
160                     new Object[] {
161                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
162                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
163                         paramObj10, paramObj11, paramObj12, paramObj13,
164                         paramObj14, paramObj15, paramObj16, paramObj17,
165                         paramObj18, paramObj19, paramObj20
166                     });
167 
168             Object returnObj = null;
169 
170             try {
171                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
172             }
173             catch (Exception e) {
174                 if (e instanceof com.liferay.portal.PortalException) {
175                     throw (com.liferay.portal.PortalException)e;
176                 }
177 
178                 if (e instanceof com.liferay.portal.SystemException) {
179                     throw (com.liferay.portal.SystemException)e;
180                 }
181 
182                 throw new com.liferay.portal.SystemException(e);
183             }
184 
185             return (com.liferay.portlet.calendar.model.CalEvent)returnObj;
186         }
187         catch (com.liferay.portal.SystemException se) {
188             _log.error(se, se);
189 
190             throw se;
191         }
192     }
193 
194     public static void deleteEvent(HttpPrincipal httpPrincipal, long eventId)
195         throws com.liferay.portal.PortalException,
196             com.liferay.portal.SystemException {
197         try {
198             Object paramObj0 = new LongWrapper(eventId);
199 
200             MethodWrapper methodWrapper = new MethodWrapper(CalEventServiceUtil.class.getName(),
201                     "deleteEvent", new Object[] { paramObj0 });
202 
203             try {
204                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
205             }
206             catch (Exception e) {
207                 if (e instanceof com.liferay.portal.PortalException) {
208                     throw (com.liferay.portal.PortalException)e;
209                 }
210 
211                 if (e instanceof com.liferay.portal.SystemException) {
212                     throw (com.liferay.portal.SystemException)e;
213                 }
214 
215                 throw new com.liferay.portal.SystemException(e);
216             }
217         }
218         catch (com.liferay.portal.SystemException se) {
219             _log.error(se, se);
220 
221             throw se;
222         }
223     }
224 
225     public static java.io.File exportEvent(HttpPrincipal httpPrincipal,
226         long eventId)
227         throws com.liferay.portal.PortalException,
228             com.liferay.portal.SystemException {
229         try {
230             Object paramObj0 = new LongWrapper(eventId);
231 
232             MethodWrapper methodWrapper = new MethodWrapper(CalEventServiceUtil.class.getName(),
233                     "exportEvent", new Object[] { paramObj0 });
234 
235             Object returnObj = null;
236 
237             try {
238                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
239             }
240             catch (Exception e) {
241                 if (e instanceof com.liferay.portal.PortalException) {
242                     throw (com.liferay.portal.PortalException)e;
243                 }
244 
245                 if (e instanceof com.liferay.portal.SystemException) {
246                     throw (com.liferay.portal.SystemException)e;
247                 }
248 
249                 throw new com.liferay.portal.SystemException(e);
250             }
251 
252             return (java.io.File)returnObj;
253         }
254         catch (com.liferay.portal.SystemException se) {
255             _log.error(se, se);
256 
257             throw se;
258         }
259     }
260 
261     public static java.io.File exportGroupEvents(HttpPrincipal httpPrincipal,
262         long groupId, java.lang.String fileName)
263         throws com.liferay.portal.PortalException,
264             com.liferay.portal.SystemException {
265         try {
266             Object paramObj0 = new LongWrapper(groupId);
267 
268             Object paramObj1 = fileName;
269 
270             if (fileName == null) {
271                 paramObj1 = new NullWrapper("java.lang.String");
272             }
273 
274             MethodWrapper methodWrapper = new MethodWrapper(CalEventServiceUtil.class.getName(),
275                     "exportGroupEvents", new Object[] { paramObj0, paramObj1 });
276 
277             Object returnObj = null;
278 
279             try {
280                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
281             }
282             catch (Exception e) {
283                 if (e instanceof com.liferay.portal.PortalException) {
284                     throw (com.liferay.portal.PortalException)e;
285                 }
286 
287                 if (e instanceof com.liferay.portal.SystemException) {
288                     throw (com.liferay.portal.SystemException)e;
289                 }
290 
291                 throw new com.liferay.portal.SystemException(e);
292             }
293 
294             return (java.io.File)returnObj;
295         }
296         catch (com.liferay.portal.SystemException se) {
297             _log.error(se, se);
298 
299             throw se;
300         }
301     }
302 
303     public static com.liferay.portlet.calendar.model.CalEvent getEvent(
304         HttpPrincipal httpPrincipal, long eventId)
305         throws com.liferay.portal.PortalException,
306             com.liferay.portal.SystemException {
307         try {
308             Object paramObj0 = new LongWrapper(eventId);
309 
310             MethodWrapper methodWrapper = new MethodWrapper(CalEventServiceUtil.class.getName(),
311                     "getEvent", new Object[] { paramObj0 });
312 
313             Object returnObj = null;
314 
315             try {
316                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
317             }
318             catch (Exception e) {
319                 if (e instanceof com.liferay.portal.PortalException) {
320                     throw (com.liferay.portal.PortalException)e;
321                 }
322 
323                 if (e instanceof com.liferay.portal.SystemException) {
324                     throw (com.liferay.portal.SystemException)e;
325                 }
326 
327                 throw new com.liferay.portal.SystemException(e);
328             }
329 
330             return (com.liferay.portlet.calendar.model.CalEvent)returnObj;
331         }
332         catch (com.liferay.portal.SystemException se) {
333             _log.error(se, se);
334 
335             throw se;
336         }
337     }
338 
339     public static void importICal4j(HttpPrincipal httpPrincipal, long groupId,
340         java.io.File file)
341         throws com.liferay.portal.PortalException,
342             com.liferay.portal.SystemException {
343         try {
344             Object paramObj0 = new LongWrapper(groupId);
345 
346             Object paramObj1 = file;
347 
348             if (file == null) {
349                 paramObj1 = new NullWrapper("java.io.File");
350             }
351 
352             MethodWrapper methodWrapper = new MethodWrapper(CalEventServiceUtil.class.getName(),
353                     "importICal4j", new Object[] { paramObj0, paramObj1 });
354 
355             try {
356                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
357             }
358             catch (Exception e) {
359                 if (e instanceof com.liferay.portal.PortalException) {
360                     throw (com.liferay.portal.PortalException)e;
361                 }
362 
363                 if (e instanceof com.liferay.portal.SystemException) {
364                     throw (com.liferay.portal.SystemException)e;
365                 }
366 
367                 throw new com.liferay.portal.SystemException(e);
368             }
369         }
370         catch (com.liferay.portal.SystemException se) {
371             _log.error(se, se);
372 
373             throw se;
374         }
375     }
376 
377     public static com.liferay.portlet.calendar.model.CalEvent updateEvent(
378         HttpPrincipal httpPrincipal, long eventId, java.lang.String title,
379         java.lang.String description, int startDateMonth, int startDateDay,
380         int startDateYear, int startDateHour, int startDateMinute,
381         int endDateMonth, int endDateDay, int endDateYear, int durationHour,
382         int durationMinute, boolean allDay, boolean timeZoneSensitive,
383         java.lang.String type, boolean repeating,
384         com.liferay.portal.kernel.cal.TZSRecurrence recurrence,
385         java.lang.String remindBy, int firstReminder, int secondReminder)
386         throws com.liferay.portal.PortalException,
387             com.liferay.portal.SystemException {
388         try {
389             Object paramObj0 = new LongWrapper(eventId);
390 
391             Object paramObj1 = title;
392 
393             if (title == null) {
394                 paramObj1 = new NullWrapper("java.lang.String");
395             }
396 
397             Object paramObj2 = description;
398 
399             if (description == null) {
400                 paramObj2 = new NullWrapper("java.lang.String");
401             }
402 
403             Object paramObj3 = new IntegerWrapper(startDateMonth);
404 
405             Object paramObj4 = new IntegerWrapper(startDateDay);
406 
407             Object paramObj5 = new IntegerWrapper(startDateYear);
408 
409             Object paramObj6 = new IntegerWrapper(startDateHour);
410 
411             Object paramObj7 = new IntegerWrapper(startDateMinute);
412 
413             Object paramObj8 = new IntegerWrapper(endDateMonth);
414 
415             Object paramObj9 = new IntegerWrapper(endDateDay);
416 
417             Object paramObj10 = new IntegerWrapper(endDateYear);
418 
419             Object paramObj11 = new IntegerWrapper(durationHour);
420 
421             Object paramObj12 = new IntegerWrapper(durationMinute);
422 
423             Object paramObj13 = new BooleanWrapper(allDay);
424 
425             Object paramObj14 = new BooleanWrapper(timeZoneSensitive);
426 
427             Object paramObj15 = type;
428 
429             if (type == null) {
430                 paramObj15 = new NullWrapper("java.lang.String");
431             }
432 
433             Object paramObj16 = new BooleanWrapper(repeating);
434 
435             Object paramObj17 = recurrence;
436 
437             if (recurrence == null) {
438                 paramObj17 = new NullWrapper(
439                         "com.liferay.portal.kernel.cal.TZSRecurrence");
440             }
441 
442             Object paramObj18 = remindBy;
443 
444             if (remindBy == null) {
445                 paramObj18 = new NullWrapper("java.lang.String");
446             }
447 
448             Object paramObj19 = new IntegerWrapper(firstReminder);
449 
450             Object paramObj20 = new IntegerWrapper(secondReminder);
451 
452             MethodWrapper methodWrapper = new MethodWrapper(CalEventServiceUtil.class.getName(),
453                     "updateEvent",
454                     new Object[] {
455                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
456                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
457                         paramObj10, paramObj11, paramObj12, paramObj13,
458                         paramObj14, paramObj15, paramObj16, paramObj17,
459                         paramObj18, paramObj19, paramObj20
460                     });
461 
462             Object returnObj = null;
463 
464             try {
465                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
466             }
467             catch (Exception e) {
468                 if (e instanceof com.liferay.portal.PortalException) {
469                     throw (com.liferay.portal.PortalException)e;
470                 }
471 
472                 if (e instanceof com.liferay.portal.SystemException) {
473                     throw (com.liferay.portal.SystemException)e;
474                 }
475 
476                 throw new com.liferay.portal.SystemException(e);
477             }
478 
479             return (com.liferay.portlet.calendar.model.CalEvent)returnObj;
480         }
481         catch (com.liferay.portal.SystemException se) {
482             _log.error(se, se);
483 
484             throw se;
485         }
486     }
487 
488     private static Log _log = LogFactoryUtil.getLog(CalEventServiceHttp.class);
489 }