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.announcements.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.announcements.service.AnnouncementsEntryServiceUtil;
36  
37  /**
38   * <a href="AnnouncementsEntryServiceHttp.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.announcements.service.AnnouncementsEntryServiceUtil</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.announcements.service.AnnouncementsEntryServiceUtil
73   * @see com.liferay.portlet.announcements.service.http.AnnouncementsEntryServiceSoap
74   *
75   */
76  public class AnnouncementsEntryServiceHttp {
77      public static com.liferay.portlet.announcements.model.AnnouncementsEntry addEntry(
78          HttpPrincipal httpPrincipal, long plid, long classNameId, long classPK,
79          java.lang.String title, java.lang.String content, java.lang.String url,
80          java.lang.String type, int displayDateMonth, int displayDateDay,
81          int displayDateYear, int displayDateHour, int displayDateMinute,
82          int expirationDateMonth, int expirationDateDay, int expirationDateYear,
83          int expirationDateHour, int expirationDateMinute, int priority,
84          boolean alert)
85          throws com.liferay.portal.PortalException,
86              com.liferay.portal.SystemException {
87          try {
88              Object paramObj0 = new LongWrapper(plid);
89  
90              Object paramObj1 = new LongWrapper(classNameId);
91  
92              Object paramObj2 = new LongWrapper(classPK);
93  
94              Object paramObj3 = title;
95  
96              if (title == null) {
97                  paramObj3 = new NullWrapper("java.lang.String");
98              }
99  
100             Object paramObj4 = content;
101 
102             if (content == null) {
103                 paramObj4 = new NullWrapper("java.lang.String");
104             }
105 
106             Object paramObj5 = url;
107 
108             if (url == null) {
109                 paramObj5 = new NullWrapper("java.lang.String");
110             }
111 
112             Object paramObj6 = type;
113 
114             if (type == null) {
115                 paramObj6 = new NullWrapper("java.lang.String");
116             }
117 
118             Object paramObj7 = new IntegerWrapper(displayDateMonth);
119 
120             Object paramObj8 = new IntegerWrapper(displayDateDay);
121 
122             Object paramObj9 = new IntegerWrapper(displayDateYear);
123 
124             Object paramObj10 = new IntegerWrapper(displayDateHour);
125 
126             Object paramObj11 = new IntegerWrapper(displayDateMinute);
127 
128             Object paramObj12 = new IntegerWrapper(expirationDateMonth);
129 
130             Object paramObj13 = new IntegerWrapper(expirationDateDay);
131 
132             Object paramObj14 = new IntegerWrapper(expirationDateYear);
133 
134             Object paramObj15 = new IntegerWrapper(expirationDateHour);
135 
136             Object paramObj16 = new IntegerWrapper(expirationDateMinute);
137 
138             Object paramObj17 = new IntegerWrapper(priority);
139 
140             Object paramObj18 = new BooleanWrapper(alert);
141 
142             MethodWrapper methodWrapper = new MethodWrapper(AnnouncementsEntryServiceUtil.class.getName(),
143                     "addEntry",
144                     new Object[] {
145                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
146                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
147                         paramObj10, paramObj11, paramObj12, paramObj13,
148                         paramObj14, paramObj15, paramObj16, paramObj17,
149                         paramObj18
150                     });
151 
152             Object returnObj = null;
153 
154             try {
155                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
156             }
157             catch (Exception e) {
158                 if (e instanceof com.liferay.portal.PortalException) {
159                     throw (com.liferay.portal.PortalException)e;
160                 }
161 
162                 if (e instanceof com.liferay.portal.SystemException) {
163                     throw (com.liferay.portal.SystemException)e;
164                 }
165 
166                 throw new com.liferay.portal.SystemException(e);
167             }
168 
169             return (com.liferay.portlet.announcements.model.AnnouncementsEntry)returnObj;
170         }
171         catch (com.liferay.portal.SystemException se) {
172             _log.error(se, se);
173 
174             throw se;
175         }
176     }
177 
178     public static void deleteEntry(HttpPrincipal httpPrincipal, long entryId)
179         throws com.liferay.portal.PortalException,
180             com.liferay.portal.SystemException {
181         try {
182             Object paramObj0 = new LongWrapper(entryId);
183 
184             MethodWrapper methodWrapper = new MethodWrapper(AnnouncementsEntryServiceUtil.class.getName(),
185                     "deleteEntry", new Object[] { paramObj0 });
186 
187             try {
188                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
189             }
190             catch (Exception e) {
191                 if (e instanceof com.liferay.portal.PortalException) {
192                     throw (com.liferay.portal.PortalException)e;
193                 }
194 
195                 if (e instanceof com.liferay.portal.SystemException) {
196                     throw (com.liferay.portal.SystemException)e;
197                 }
198 
199                 throw new com.liferay.portal.SystemException(e);
200             }
201         }
202         catch (com.liferay.portal.SystemException se) {
203             _log.error(se, se);
204 
205             throw se;
206         }
207     }
208 
209     public static com.liferay.portlet.announcements.model.AnnouncementsEntry updateEntry(
210         HttpPrincipal httpPrincipal, long entryId, java.lang.String title,
211         java.lang.String content, java.lang.String url, java.lang.String type,
212         int displayDateMonth, int displayDateDay, int displayDateYear,
213         int displayDateHour, int displayDateMinute, int expirationDateMonth,
214         int expirationDateDay, int expirationDateYear, int expirationDateHour,
215         int expirationDateMinute, int priority)
216         throws com.liferay.portal.PortalException,
217             com.liferay.portal.SystemException {
218         try {
219             Object paramObj0 = new LongWrapper(entryId);
220 
221             Object paramObj1 = title;
222 
223             if (title == null) {
224                 paramObj1 = new NullWrapper("java.lang.String");
225             }
226 
227             Object paramObj2 = content;
228 
229             if (content == null) {
230                 paramObj2 = new NullWrapper("java.lang.String");
231             }
232 
233             Object paramObj3 = url;
234 
235             if (url == null) {
236                 paramObj3 = new NullWrapper("java.lang.String");
237             }
238 
239             Object paramObj4 = type;
240 
241             if (type == null) {
242                 paramObj4 = new NullWrapper("java.lang.String");
243             }
244 
245             Object paramObj5 = new IntegerWrapper(displayDateMonth);
246 
247             Object paramObj6 = new IntegerWrapper(displayDateDay);
248 
249             Object paramObj7 = new IntegerWrapper(displayDateYear);
250 
251             Object paramObj8 = new IntegerWrapper(displayDateHour);
252 
253             Object paramObj9 = new IntegerWrapper(displayDateMinute);
254 
255             Object paramObj10 = new IntegerWrapper(expirationDateMonth);
256 
257             Object paramObj11 = new IntegerWrapper(expirationDateDay);
258 
259             Object paramObj12 = new IntegerWrapper(expirationDateYear);
260 
261             Object paramObj13 = new IntegerWrapper(expirationDateHour);
262 
263             Object paramObj14 = new IntegerWrapper(expirationDateMinute);
264 
265             Object paramObj15 = new IntegerWrapper(priority);
266 
267             MethodWrapper methodWrapper = new MethodWrapper(AnnouncementsEntryServiceUtil.class.getName(),
268                     "updateEntry",
269                     new Object[] {
270                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
271                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
272                         paramObj10, paramObj11, paramObj12, paramObj13,
273                         paramObj14, paramObj15
274                     });
275 
276             Object returnObj = null;
277 
278             try {
279                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
280             }
281             catch (Exception e) {
282                 if (e instanceof com.liferay.portal.PortalException) {
283                     throw (com.liferay.portal.PortalException)e;
284                 }
285 
286                 if (e instanceof com.liferay.portal.SystemException) {
287                     throw (com.liferay.portal.SystemException)e;
288                 }
289 
290                 throw new com.liferay.portal.SystemException(e);
291             }
292 
293             return (com.liferay.portlet.announcements.model.AnnouncementsEntry)returnObj;
294         }
295         catch (com.liferay.portal.SystemException se) {
296             _log.error(se, se);
297 
298             throw se;
299         }
300     }
301 
302     private static Log _log = LogFactoryUtil.getLog(AnnouncementsEntryServiceHttp.class);
303 }