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