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