1   /**
2    * Copyright (c) 2000-2007 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.journal.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.LongWrapper;
29  import com.liferay.portal.kernel.util.MethodWrapper;
30  import com.liferay.portal.kernel.util.NullWrapper;
31  import com.liferay.portal.security.auth.HttpPrincipal;
32  import com.liferay.portal.service.http.TunnelUtil;
33  
34  import com.liferay.portlet.journal.service.JournalTemplateServiceUtil;
35  
36  /**
37   * <a href="JournalTemplateServiceHttp.java.html"><b><i>View Source</i></b></a>
38   *
39   * <p>
40   * ServiceBuilder generated this class. Modifications in this class will be overwritten
41   * the next time is generated.
42   * </p>
43   *
44   * <p>
45   * This class provides a HTTP utility for the <code>com.liferay.portlet.journal.service.JournalTemplateServiceUtil</code>
46   * service utility. The static methods of this class calls the same methods of the
47   * service utility. However, the signatures are different because it requires an
48   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code> parameter.
49   * </p>
50   *
51   * <p>
52   * The benefits of using the HTTP utility is that it is fast and allows for tunneling
53   * without the cost of serializing to text. The drawback is that it only works with
54   * Java.
55   * </p>
56   *
57   * <p>
58   * Set the property <code>tunnel.servlet.hosts.allowed</code> in portal.properties
59   * 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.journal.service.JournalTemplateServiceUtil
70   * @see com.liferay.portlet.journal.service.http.JournalTemplateServiceSoap
71   *
72   */
73  public class JournalTemplateServiceHttp {
74      public static com.liferay.portlet.journal.model.JournalTemplate addTemplate(
75          HttpPrincipal httpPrincipal, java.lang.String templateId,
76          boolean autoTemplateId, long plid, java.lang.String structureId,
77          java.lang.String name, java.lang.String description,
78          java.lang.String xsl, boolean formatXsl, java.lang.String langType,
79          boolean smallImage, java.lang.String smallImageURL,
80          java.io.File smallFile, boolean addCommunityPermissions,
81          boolean addGuestPermissions)
82          throws com.liferay.portal.SystemException, 
83              com.liferay.portal.PortalException {
84          try {
85              Object paramObj0 = templateId;
86  
87              if (templateId == null) {
88                  paramObj0 = new NullWrapper("java.lang.String");
89              }
90  
91              Object paramObj1 = new BooleanWrapper(autoTemplateId);
92              Object paramObj2 = new LongWrapper(plid);
93              Object paramObj3 = structureId;
94  
95              if (structureId == null) {
96                  paramObj3 = new NullWrapper("java.lang.String");
97              }
98  
99              Object paramObj4 = name;
100 
101             if (name == null) {
102                 paramObj4 = new NullWrapper("java.lang.String");
103             }
104 
105             Object paramObj5 = description;
106 
107             if (description == null) {
108                 paramObj5 = new NullWrapper("java.lang.String");
109             }
110 
111             Object paramObj6 = xsl;
112 
113             if (xsl == null) {
114                 paramObj6 = new NullWrapper("java.lang.String");
115             }
116 
117             Object paramObj7 = new BooleanWrapper(formatXsl);
118             Object paramObj8 = langType;
119 
120             if (langType == null) {
121                 paramObj8 = new NullWrapper("java.lang.String");
122             }
123 
124             Object paramObj9 = new BooleanWrapper(smallImage);
125             Object paramObj10 = smallImageURL;
126 
127             if (smallImageURL == null) {
128                 paramObj10 = new NullWrapper("java.lang.String");
129             }
130 
131             Object paramObj11 = smallFile;
132 
133             if (smallFile == null) {
134                 paramObj11 = new NullWrapper("java.io.File");
135             }
136 
137             Object paramObj12 = new BooleanWrapper(addCommunityPermissions);
138             Object paramObj13 = new BooleanWrapper(addGuestPermissions);
139             MethodWrapper methodWrapper = new MethodWrapper(JournalTemplateServiceUtil.class.getName(),
140                     "addTemplate",
141                     new Object[] {
142                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
143                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
144                         paramObj10, paramObj11, paramObj12, paramObj13
145                     });
146             Object returnObj = null;
147 
148             try {
149                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
150             }
151             catch (Exception e) {
152                 if (e instanceof com.liferay.portal.SystemException) {
153                     throw (com.liferay.portal.SystemException)e;
154                 }
155 
156                 if (e instanceof com.liferay.portal.PortalException) {
157                     throw (com.liferay.portal.PortalException)e;
158                 }
159 
160                 throw new com.liferay.portal.SystemException(e);
161             }
162 
163             return (com.liferay.portlet.journal.model.JournalTemplate)returnObj;
164         }
165         catch (com.liferay.portal.SystemException se) {
166             _log.error(se, se);
167             throw se;
168         }
169     }
170 
171     public static com.liferay.portlet.journal.model.JournalTemplate addTemplate(
172         HttpPrincipal httpPrincipal, java.lang.String templateId,
173         boolean autoTemplateId, long plid, java.lang.String structureId,
174         java.lang.String name, java.lang.String description,
175         java.lang.String xsl, boolean formatXsl, java.lang.String langType,
176         boolean smallImage, java.lang.String smallImageURL,
177         java.io.File smallFile, java.lang.String[] communityPermissions,
178         java.lang.String[] guestPermissions)
179         throws com.liferay.portal.SystemException, 
180             com.liferay.portal.PortalException {
181         try {
182             Object paramObj0 = templateId;
183 
184             if (templateId == null) {
185                 paramObj0 = new NullWrapper("java.lang.String");
186             }
187 
188             Object paramObj1 = new BooleanWrapper(autoTemplateId);
189             Object paramObj2 = new LongWrapper(plid);
190             Object paramObj3 = structureId;
191 
192             if (structureId == null) {
193                 paramObj3 = new NullWrapper("java.lang.String");
194             }
195 
196             Object paramObj4 = name;
197 
198             if (name == null) {
199                 paramObj4 = new NullWrapper("java.lang.String");
200             }
201 
202             Object paramObj5 = description;
203 
204             if (description == null) {
205                 paramObj5 = new NullWrapper("java.lang.String");
206             }
207 
208             Object paramObj6 = xsl;
209 
210             if (xsl == null) {
211                 paramObj6 = new NullWrapper("java.lang.String");
212             }
213 
214             Object paramObj7 = new BooleanWrapper(formatXsl);
215             Object paramObj8 = langType;
216 
217             if (langType == null) {
218                 paramObj8 = new NullWrapper("java.lang.String");
219             }
220 
221             Object paramObj9 = new BooleanWrapper(smallImage);
222             Object paramObj10 = smallImageURL;
223 
224             if (smallImageURL == null) {
225                 paramObj10 = new NullWrapper("java.lang.String");
226             }
227 
228             Object paramObj11 = smallFile;
229 
230             if (smallFile == null) {
231                 paramObj11 = new NullWrapper("java.io.File");
232             }
233 
234             Object paramObj12 = communityPermissions;
235 
236             if (communityPermissions == null) {
237                 paramObj12 = new NullWrapper("[Ljava.lang.String;");
238             }
239 
240             Object paramObj13 = guestPermissions;
241 
242             if (guestPermissions == null) {
243                 paramObj13 = new NullWrapper("[Ljava.lang.String;");
244             }
245 
246             MethodWrapper methodWrapper = new MethodWrapper(JournalTemplateServiceUtil.class.getName(),
247                     "addTemplate",
248                     new Object[] {
249                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
250                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
251                         paramObj10, paramObj11, paramObj12, paramObj13
252                     });
253             Object returnObj = null;
254 
255             try {
256                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
257             }
258             catch (Exception e) {
259                 if (e instanceof com.liferay.portal.SystemException) {
260                     throw (com.liferay.portal.SystemException)e;
261                 }
262 
263                 if (e instanceof com.liferay.portal.PortalException) {
264                     throw (com.liferay.portal.PortalException)e;
265                 }
266 
267                 throw new com.liferay.portal.SystemException(e);
268             }
269 
270             return (com.liferay.portlet.journal.model.JournalTemplate)returnObj;
271         }
272         catch (com.liferay.portal.SystemException se) {
273             _log.error(se, se);
274             throw se;
275         }
276     }
277 
278     public static void deleteTemplate(HttpPrincipal httpPrincipal,
279         long groupId, java.lang.String templateId)
280         throws com.liferay.portal.SystemException, 
281             com.liferay.portal.PortalException {
282         try {
283             Object paramObj0 = new LongWrapper(groupId);
284             Object paramObj1 = templateId;
285 
286             if (templateId == null) {
287                 paramObj1 = new NullWrapper("java.lang.String");
288             }
289 
290             MethodWrapper methodWrapper = new MethodWrapper(JournalTemplateServiceUtil.class.getName(),
291                     "deleteTemplate", new Object[] { paramObj0, paramObj1 });
292 
293             try {
294                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
295             }
296             catch (Exception e) {
297                 if (e instanceof com.liferay.portal.SystemException) {
298                     throw (com.liferay.portal.SystemException)e;
299                 }
300 
301                 if (e instanceof com.liferay.portal.PortalException) {
302                     throw (com.liferay.portal.PortalException)e;
303                 }
304 
305                 throw new com.liferay.portal.SystemException(e);
306             }
307         }
308         catch (com.liferay.portal.SystemException se) {
309             _log.error(se, se);
310             throw se;
311         }
312     }
313 
314     public static com.liferay.portlet.journal.model.JournalTemplate getTemplate(
315         HttpPrincipal httpPrincipal, long groupId, java.lang.String templateId)
316         throws com.liferay.portal.SystemException, 
317             com.liferay.portal.PortalException {
318         try {
319             Object paramObj0 = new LongWrapper(groupId);
320             Object paramObj1 = templateId;
321 
322             if (templateId == null) {
323                 paramObj1 = new NullWrapper("java.lang.String");
324             }
325 
326             MethodWrapper methodWrapper = new MethodWrapper(JournalTemplateServiceUtil.class.getName(),
327                     "getTemplate", new Object[] { paramObj0, paramObj1 });
328             Object returnObj = null;
329 
330             try {
331                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
332             }
333             catch (Exception e) {
334                 if (e instanceof com.liferay.portal.SystemException) {
335                     throw (com.liferay.portal.SystemException)e;
336                 }
337 
338                 if (e instanceof com.liferay.portal.PortalException) {
339                     throw (com.liferay.portal.PortalException)e;
340                 }
341 
342                 throw new com.liferay.portal.SystemException(e);
343             }
344 
345             return (com.liferay.portlet.journal.model.JournalTemplate)returnObj;
346         }
347         catch (com.liferay.portal.SystemException se) {
348             _log.error(se, se);
349             throw se;
350         }
351     }
352 
353     public static com.liferay.portlet.journal.model.JournalTemplate updateTemplate(
354         HttpPrincipal httpPrincipal, long groupId, java.lang.String templateId,
355         java.lang.String structureId, java.lang.String name,
356         java.lang.String description, java.lang.String xsl, boolean formatXsl,
357         java.lang.String langType, boolean smallImage,
358         java.lang.String smallImageURL, java.io.File smallFile)
359         throws com.liferay.portal.SystemException, 
360             com.liferay.portal.PortalException {
361         try {
362             Object paramObj0 = new LongWrapper(groupId);
363             Object paramObj1 = templateId;
364 
365             if (templateId == null) {
366                 paramObj1 = new NullWrapper("java.lang.String");
367             }
368 
369             Object paramObj2 = structureId;
370 
371             if (structureId == null) {
372                 paramObj2 = new NullWrapper("java.lang.String");
373             }
374 
375             Object paramObj3 = name;
376 
377             if (name == null) {
378                 paramObj3 = new NullWrapper("java.lang.String");
379             }
380 
381             Object paramObj4 = description;
382 
383             if (description == null) {
384                 paramObj4 = new NullWrapper("java.lang.String");
385             }
386 
387             Object paramObj5 = xsl;
388 
389             if (xsl == null) {
390                 paramObj5 = new NullWrapper("java.lang.String");
391             }
392 
393             Object paramObj6 = new BooleanWrapper(formatXsl);
394             Object paramObj7 = langType;
395 
396             if (langType == null) {
397                 paramObj7 = new NullWrapper("java.lang.String");
398             }
399 
400             Object paramObj8 = new BooleanWrapper(smallImage);
401             Object paramObj9 = smallImageURL;
402 
403             if (smallImageURL == null) {
404                 paramObj9 = new NullWrapper("java.lang.String");
405             }
406 
407             Object paramObj10 = smallFile;
408 
409             if (smallFile == null) {
410                 paramObj10 = new NullWrapper("java.io.File");
411             }
412 
413             MethodWrapper methodWrapper = new MethodWrapper(JournalTemplateServiceUtil.class.getName(),
414                     "updateTemplate",
415                     new Object[] {
416                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
417                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
418                         paramObj10
419                     });
420             Object returnObj = null;
421 
422             try {
423                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
424             }
425             catch (Exception e) {
426                 if (e instanceof com.liferay.portal.SystemException) {
427                     throw (com.liferay.portal.SystemException)e;
428                 }
429 
430                 if (e instanceof com.liferay.portal.PortalException) {
431                     throw (com.liferay.portal.PortalException)e;
432                 }
433 
434                 throw new com.liferay.portal.SystemException(e);
435             }
436 
437             return (com.liferay.portlet.journal.model.JournalTemplate)returnObj;
438         }
439         catch (com.liferay.portal.SystemException se) {
440             _log.error(se, se);
441             throw se;
442         }
443     }
444 
445     private static Log _log = LogFactoryUtil.getLog(JournalTemplateServiceHttp.class);
446 }