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, int remindBy,
85          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 = new IntegerWrapper(remindBy);
142 
143             Object paramObj18 = new IntegerWrapper(firstReminder);
144 
145             Object paramObj19 = new IntegerWrapper(secondReminder);
146 
147             Object paramObj20 = serviceContext;
148 
149             if (serviceContext == null) {
150                 paramObj20 = new NullWrapper(
151                         "com.liferay.portal.service.ServiceContext");
152             }
153 
154             MethodWrapper methodWrapper = new MethodWrapper(CalEventServiceUtil.class.getName(),
155                     "addEvent",
156                     new Object[] {
157                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
158                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
159                         paramObj10, paramObj11, paramObj12, paramObj13,
160                         paramObj14, paramObj15, paramObj16, paramObj17,
161                         paramObj18, paramObj19, paramObj20
162                     });
163 
164             Object returnObj = null;
165 
166             try {
167                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
168             }
169             catch (Exception e) {
170                 if (e instanceof com.liferay.portal.PortalException) {
171                     throw (com.liferay.portal.PortalException)e;
172                 }
173 
174                 if (e instanceof com.liferay.portal.SystemException) {
175                     throw (com.liferay.portal.SystemException)e;
176                 }
177 
178                 throw new com.liferay.portal.SystemException(e);
179             }
180 
181             return (com.liferay.portlet.calendar.model.CalEvent)returnObj;
182         }
183         catch (com.liferay.portal.SystemException se) {
184             _log.error(se, se);
185 
186             throw se;
187         }
188     }
189 
190     public static void deleteEvent(HttpPrincipal httpPrincipal, long eventId)
191         throws com.liferay.portal.PortalException,
192             com.liferay.portal.SystemException {
193         try {
194             Object paramObj0 = new LongWrapper(eventId);
195 
196             MethodWrapper methodWrapper = new MethodWrapper(CalEventServiceUtil.class.getName(),
197                     "deleteEvent", new Object[] { paramObj0 });
198 
199             try {
200                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
201             }
202             catch (Exception e) {
203                 if (e instanceof com.liferay.portal.PortalException) {
204                     throw (com.liferay.portal.PortalException)e;
205                 }
206 
207                 if (e instanceof com.liferay.portal.SystemException) {
208                     throw (com.liferay.portal.SystemException)e;
209                 }
210 
211                 throw new com.liferay.portal.SystemException(e);
212             }
213         }
214         catch (com.liferay.portal.SystemException se) {
215             _log.error(se, se);
216 
217             throw se;
218         }
219     }
220 
221     public static java.io.File exportEvent(HttpPrincipal httpPrincipal,
222         long eventId)
223         throws com.liferay.portal.PortalException,
224             com.liferay.portal.SystemException {
225         try {
226             Object paramObj0 = new LongWrapper(eventId);
227 
228             MethodWrapper methodWrapper = new MethodWrapper(CalEventServiceUtil.class.getName(),
229                     "exportEvent", new Object[] { paramObj0 });
230 
231             Object returnObj = null;
232 
233             try {
234                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
235             }
236             catch (Exception e) {
237                 if (e instanceof com.liferay.portal.PortalException) {
238                     throw (com.liferay.portal.PortalException)e;
239                 }
240 
241                 if (e instanceof com.liferay.portal.SystemException) {
242                     throw (com.liferay.portal.SystemException)e;
243                 }
244 
245                 throw new com.liferay.portal.SystemException(e);
246             }
247 
248             return (java.io.File)returnObj;
249         }
250         catch (com.liferay.portal.SystemException se) {
251             _log.error(se, se);
252 
253             throw se;
254         }
255     }
256 
257     public static java.io.File exportGroupEvents(HttpPrincipal httpPrincipal,
258         long groupId, java.lang.String fileName)
259         throws com.liferay.portal.PortalException,
260             com.liferay.portal.SystemException {
261         try {
262             Object paramObj0 = new LongWrapper(groupId);
263 
264             Object paramObj1 = fileName;
265 
266             if (fileName == null) {
267                 paramObj1 = new NullWrapper("java.lang.String");
268             }
269 
270             MethodWrapper methodWrapper = new MethodWrapper(CalEventServiceUtil.class.getName(),
271                     "exportGroupEvents", new Object[] { paramObj0, paramObj1 });
272 
273             Object returnObj = null;
274 
275             try {
276                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
277             }
278             catch (Exception e) {
279                 if (e instanceof com.liferay.portal.PortalException) {
280                     throw (com.liferay.portal.PortalException)e;
281                 }
282 
283                 if (e instanceof com.liferay.portal.SystemException) {
284                     throw (com.liferay.portal.SystemException)e;
285                 }
286 
287                 throw new com.liferay.portal.SystemException(e);
288             }
289 
290             return (java.io.File)returnObj;
291         }
292         catch (com.liferay.portal.SystemException se) {
293             _log.error(se, se);
294 
295             throw se;
296         }
297     }
298 
299     public static com.liferay.portlet.calendar.model.CalEvent getEvent(
300         HttpPrincipal httpPrincipal, long eventId)
301         throws com.liferay.portal.PortalException,
302             com.liferay.portal.SystemException {
303         try {
304             Object paramObj0 = new LongWrapper(eventId);
305 
306             MethodWrapper methodWrapper = new MethodWrapper(CalEventServiceUtil.class.getName(),
307                     "getEvent", new Object[] { paramObj0 });
308 
309             Object returnObj = null;
310 
311             try {
312                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
313             }
314             catch (Exception e) {
315                 if (e instanceof com.liferay.portal.PortalException) {
316                     throw (com.liferay.portal.PortalException)e;
317                 }
318 
319                 if (e instanceof com.liferay.portal.SystemException) {
320                     throw (com.liferay.portal.SystemException)e;
321                 }
322 
323                 throw new com.liferay.portal.SystemException(e);
324             }
325 
326             return (com.liferay.portlet.calendar.model.CalEvent)returnObj;
327         }
328         catch (com.liferay.portal.SystemException se) {
329             _log.error(se, se);
330 
331             throw se;
332         }
333     }
334 
335     public static void importICal4j(HttpPrincipal httpPrincipal, long groupId,
336         java.io.File file)
337         throws com.liferay.portal.PortalException,
338             com.liferay.portal.SystemException {
339         try {
340             Object paramObj0 = new LongWrapper(groupId);
341 
342             Object paramObj1 = file;
343 
344             if (file == null) {
345                 paramObj1 = new NullWrapper("java.io.File");
346             }
347 
348             MethodWrapper methodWrapper = new MethodWrapper(CalEventServiceUtil.class.getName(),
349                     "importICal4j", new Object[] { paramObj0, paramObj1 });
350 
351             try {
352                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
353             }
354             catch (Exception e) {
355                 if (e instanceof com.liferay.portal.PortalException) {
356                     throw (com.liferay.portal.PortalException)e;
357                 }
358 
359                 if (e instanceof com.liferay.portal.SystemException) {
360                     throw (com.liferay.portal.SystemException)e;
361                 }
362 
363                 throw new com.liferay.portal.SystemException(e);
364             }
365         }
366         catch (com.liferay.portal.SystemException se) {
367             _log.error(se, se);
368 
369             throw se;
370         }
371     }
372 
373     public static com.liferay.portlet.calendar.model.CalEvent updateEvent(
374         HttpPrincipal httpPrincipal, long eventId, java.lang.String title,
375         java.lang.String description, int startDateMonth, int startDateDay,
376         int startDateYear, int startDateHour, int startDateMinute,
377         int endDateMonth, int endDateDay, int endDateYear, int durationHour,
378         int durationMinute, boolean allDay, boolean timeZoneSensitive,
379         java.lang.String type, boolean repeating,
380         com.liferay.portal.kernel.cal.TZSRecurrence recurrence, int remindBy,
381         int firstReminder, int secondReminder,
382         com.liferay.portal.service.ServiceContext serviceContext)
383         throws com.liferay.portal.PortalException,
384             com.liferay.portal.SystemException {
385         try {
386             Object paramObj0 = new LongWrapper(eventId);
387 
388             Object paramObj1 = title;
389 
390             if (title == null) {
391                 paramObj1 = new NullWrapper("java.lang.String");
392             }
393 
394             Object paramObj2 = description;
395 
396             if (description == null) {
397                 paramObj2 = new NullWrapper("java.lang.String");
398             }
399 
400             Object paramObj3 = new IntegerWrapper(startDateMonth);
401 
402             Object paramObj4 = new IntegerWrapper(startDateDay);
403 
404             Object paramObj5 = new IntegerWrapper(startDateYear);
405 
406             Object paramObj6 = new IntegerWrapper(startDateHour);
407 
408             Object paramObj7 = new IntegerWrapper(startDateMinute);
409 
410             Object paramObj8 = new IntegerWrapper(endDateMonth);
411 
412             Object paramObj9 = new IntegerWrapper(endDateDay);
413 
414             Object paramObj10 = new IntegerWrapper(endDateYear);
415 
416             Object paramObj11 = new IntegerWrapper(durationHour);
417 
418             Object paramObj12 = new IntegerWrapper(durationMinute);
419 
420             Object paramObj13 = new BooleanWrapper(allDay);
421 
422             Object paramObj14 = new BooleanWrapper(timeZoneSensitive);
423 
424             Object paramObj15 = type;
425 
426             if (type == null) {
427                 paramObj15 = new NullWrapper("java.lang.String");
428             }
429 
430             Object paramObj16 = new BooleanWrapper(repeating);
431 
432             Object paramObj17 = recurrence;
433 
434             if (recurrence == null) {
435                 paramObj17 = new NullWrapper(
436                         "com.liferay.portal.kernel.cal.TZSRecurrence");
437             }
438 
439             Object paramObj18 = new IntegerWrapper(remindBy);
440 
441             Object paramObj19 = new IntegerWrapper(firstReminder);
442 
443             Object paramObj20 = new IntegerWrapper(secondReminder);
444 
445             Object paramObj21 = serviceContext;
446 
447             if (serviceContext == null) {
448                 paramObj21 = new NullWrapper(
449                         "com.liferay.portal.service.ServiceContext");
450             }
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, paramObj21
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 }