1   /**
2    * Copyright (c) 2000-2008 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.workflow.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.workflow.service.WorkflowDefinitionServiceUtil;
35  
36  /**
37   * <a href="WorkflowDefinitionServiceHttp.java.html"><b><i>View Source</i></b></a>
38   *
39   * <p>
40   * ServiceBuilder generated this class. Modifications in this class will be
41   * overwritten the next time is generated.
42   * </p>
43   *
44   * <p>
45   * This class provides a HTTP utility for the
46   * <code>com.liferay.portlet.workflow.service.WorkflowDefinitionServiceUtil</code> service
47   * utility. The static methods of this class calls the same methods of the
48   * service utility. However, the signatures are different because it requires an
49   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
50   * parameter.
51   * </p>
52   *
53   * <p>
54   * The benefits of using the HTTP utility is that it is fast and allows for
55   * tunneling without the cost of serializing to text. The drawback is that it
56   * only works with Java.
57   * </p>
58   *
59   * <p>
60   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
61   * portal.properties to configure security.
62   * </p>
63   *
64   * <p>
65   * The HTTP utility is only generated for remote services.
66   * </p>
67   *
68   * @author Brian Wing Shun Chan
69   *
70   * @see com.liferay.portal.security.auth.HttpPrincipal
71   * @see com.liferay.portlet.workflow.service.WorkflowDefinitionServiceUtil
72   * @see com.liferay.portlet.workflow.service.http.WorkflowDefinitionServiceSoap
73   *
74   */
75  public class WorkflowDefinitionServiceHttp {
76      public static com.liferay.portlet.workflow.model.WorkflowDefinition addDefinition(
77          HttpPrincipal httpPrincipal, java.lang.String xml,
78          boolean addCommunityPermissions, boolean addGuestPermissions)
79          throws com.liferay.portal.SystemException,
80              com.liferay.portal.PortalException {
81          try {
82              Object paramObj0 = xml;
83  
84              if (xml == null) {
85                  paramObj0 = new NullWrapper("java.lang.String");
86              }
87  
88              Object paramObj1 = new BooleanWrapper(addCommunityPermissions);
89  
90              Object paramObj2 = new BooleanWrapper(addGuestPermissions);
91  
92              MethodWrapper methodWrapper = new MethodWrapper(WorkflowDefinitionServiceUtil.class.getName(),
93                      "addDefinition",
94                      new Object[] { paramObj0, paramObj1, paramObj2 });
95  
96              Object returnObj = null;
97  
98              try {
99                  returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
100             }
101             catch (Exception e) {
102                 if (e instanceof com.liferay.portal.SystemException) {
103                     throw (com.liferay.portal.SystemException)e;
104                 }
105 
106                 if (e instanceof com.liferay.portal.PortalException) {
107                     throw (com.liferay.portal.PortalException)e;
108                 }
109 
110                 throw new com.liferay.portal.SystemException(e);
111             }
112 
113             return (com.liferay.portlet.workflow.model.WorkflowDefinition)returnObj;
114         }
115         catch (com.liferay.portal.SystemException se) {
116             _log.error(se, se);
117 
118             throw se;
119         }
120     }
121 
122     public static com.liferay.portlet.workflow.model.WorkflowDefinition addDefinition(
123         HttpPrincipal httpPrincipal, java.lang.String xml,
124         java.lang.String[] communityPermissions,
125         java.lang.String[] guestPermissions)
126         throws com.liferay.portal.SystemException,
127             com.liferay.portal.PortalException {
128         try {
129             Object paramObj0 = xml;
130 
131             if (xml == null) {
132                 paramObj0 = new NullWrapper("java.lang.String");
133             }
134 
135             Object paramObj1 = communityPermissions;
136 
137             if (communityPermissions == null) {
138                 paramObj1 = new NullWrapper("[Ljava.lang.String;");
139             }
140 
141             Object paramObj2 = guestPermissions;
142 
143             if (guestPermissions == null) {
144                 paramObj2 = new NullWrapper("[Ljava.lang.String;");
145             }
146 
147             MethodWrapper methodWrapper = new MethodWrapper(WorkflowDefinitionServiceUtil.class.getName(),
148                     "addDefinition",
149                     new Object[] { paramObj0, paramObj1, paramObj2 });
150 
151             Object returnObj = null;
152 
153             try {
154                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
155             }
156             catch (Exception e) {
157                 if (e instanceof com.liferay.portal.SystemException) {
158                     throw (com.liferay.portal.SystemException)e;
159                 }
160 
161                 if (e instanceof com.liferay.portal.PortalException) {
162                     throw (com.liferay.portal.PortalException)e;
163                 }
164 
165                 throw new com.liferay.portal.SystemException(e);
166             }
167 
168             return (com.liferay.portlet.workflow.model.WorkflowDefinition)returnObj;
169         }
170         catch (com.liferay.portal.SystemException se) {
171             _log.error(se, se);
172 
173             throw se;
174         }
175     }
176 
177     public static com.liferay.portlet.workflow.model.WorkflowDefinition addDefinition(
178         HttpPrincipal httpPrincipal, java.lang.String xml,
179         java.lang.Boolean addCommunityPermissions,
180         java.lang.Boolean addGuestPermissions,
181         java.lang.String[] communityPermissions,
182         java.lang.String[] guestPermissions)
183         throws com.liferay.portal.SystemException,
184             com.liferay.portal.PortalException {
185         try {
186             Object paramObj0 = xml;
187 
188             if (xml == null) {
189                 paramObj0 = new NullWrapper("java.lang.String");
190             }
191 
192             Object paramObj1 = addCommunityPermissions;
193 
194             if (addCommunityPermissions == null) {
195                 paramObj1 = new NullWrapper("java.lang.Boolean");
196             }
197 
198             Object paramObj2 = addGuestPermissions;
199 
200             if (addGuestPermissions == null) {
201                 paramObj2 = new NullWrapper("java.lang.Boolean");
202             }
203 
204             Object paramObj3 = communityPermissions;
205 
206             if (communityPermissions == null) {
207                 paramObj3 = new NullWrapper("[Ljava.lang.String;");
208             }
209 
210             Object paramObj4 = guestPermissions;
211 
212             if (guestPermissions == null) {
213                 paramObj4 = new NullWrapper("[Ljava.lang.String;");
214             }
215 
216             MethodWrapper methodWrapper = new MethodWrapper(WorkflowDefinitionServiceUtil.class.getName(),
217                     "addDefinition",
218                     new Object[] {
219                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
220                     });
221 
222             Object returnObj = null;
223 
224             try {
225                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
226             }
227             catch (Exception e) {
228                 if (e instanceof com.liferay.portal.SystemException) {
229                     throw (com.liferay.portal.SystemException)e;
230                 }
231 
232                 if (e instanceof com.liferay.portal.PortalException) {
233                     throw (com.liferay.portal.PortalException)e;
234                 }
235 
236                 throw new com.liferay.portal.SystemException(e);
237             }
238 
239             return (com.liferay.portlet.workflow.model.WorkflowDefinition)returnObj;
240         }
241         catch (com.liferay.portal.SystemException se) {
242             _log.error(se, se);
243 
244             throw se;
245         }
246     }
247 
248     public static void addDefinitionResources(HttpPrincipal httpPrincipal,
249         com.liferay.portal.model.User user, long definitionId,
250         boolean addCommunityPermissions, boolean addGuestPermissions)
251         throws com.liferay.portal.SystemException,
252             com.liferay.portal.PortalException {
253         try {
254             Object paramObj0 = user;
255 
256             if (user == null) {
257                 paramObj0 = new NullWrapper("com.liferay.portal.model.User");
258             }
259 
260             Object paramObj1 = new LongWrapper(definitionId);
261 
262             Object paramObj2 = new BooleanWrapper(addCommunityPermissions);
263 
264             Object paramObj3 = new BooleanWrapper(addGuestPermissions);
265 
266             MethodWrapper methodWrapper = new MethodWrapper(WorkflowDefinitionServiceUtil.class.getName(),
267                     "addDefinitionResources",
268                     new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
269 
270             try {
271                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
272             }
273             catch (Exception e) {
274                 if (e instanceof com.liferay.portal.SystemException) {
275                     throw (com.liferay.portal.SystemException)e;
276                 }
277 
278                 if (e instanceof com.liferay.portal.PortalException) {
279                     throw (com.liferay.portal.PortalException)e;
280                 }
281 
282                 throw new com.liferay.portal.SystemException(e);
283             }
284         }
285         catch (com.liferay.portal.SystemException se) {
286             _log.error(se, se);
287 
288             throw se;
289         }
290     }
291 
292     public static void addDefinitionResources(HttpPrincipal httpPrincipal,
293         com.liferay.portal.model.User user, long definitionId,
294         java.lang.String[] communityPermissions,
295         java.lang.String[] guestPermissions)
296         throws com.liferay.portal.SystemException,
297             com.liferay.portal.PortalException {
298         try {
299             Object paramObj0 = user;
300 
301             if (user == null) {
302                 paramObj0 = new NullWrapper("com.liferay.portal.model.User");
303             }
304 
305             Object paramObj1 = new LongWrapper(definitionId);
306 
307             Object paramObj2 = communityPermissions;
308 
309             if (communityPermissions == null) {
310                 paramObj2 = new NullWrapper("[Ljava.lang.String;");
311             }
312 
313             Object paramObj3 = guestPermissions;
314 
315             if (guestPermissions == null) {
316                 paramObj3 = new NullWrapper("[Ljava.lang.String;");
317             }
318 
319             MethodWrapper methodWrapper = new MethodWrapper(WorkflowDefinitionServiceUtil.class.getName(),
320                     "addDefinitionResources",
321                     new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
322 
323             try {
324                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
325             }
326             catch (Exception e) {
327                 if (e instanceof com.liferay.portal.SystemException) {
328                     throw (com.liferay.portal.SystemException)e;
329                 }
330 
331                 if (e instanceof com.liferay.portal.PortalException) {
332                     throw (com.liferay.portal.PortalException)e;
333                 }
334 
335                 throw new com.liferay.portal.SystemException(e);
336             }
337         }
338         catch (com.liferay.portal.SystemException se) {
339             _log.error(se, se);
340 
341             throw se;
342         }
343     }
344 
345     public static com.liferay.portlet.workflow.model.WorkflowDefinition getDefinition(
346         HttpPrincipal httpPrincipal, long definitionId)
347         throws com.liferay.portal.SystemException,
348             com.liferay.portal.PortalException {
349         try {
350             Object paramObj0 = new LongWrapper(definitionId);
351 
352             MethodWrapper methodWrapper = new MethodWrapper(WorkflowDefinitionServiceUtil.class.getName(),
353                     "getDefinition", new Object[] { paramObj0 });
354 
355             Object returnObj = null;
356 
357             try {
358                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
359             }
360             catch (Exception e) {
361                 if (e instanceof com.liferay.portal.SystemException) {
362                     throw (com.liferay.portal.SystemException)e;
363                 }
364 
365                 if (e instanceof com.liferay.portal.PortalException) {
366                     throw (com.liferay.portal.PortalException)e;
367                 }
368 
369                 throw new com.liferay.portal.SystemException(e);
370             }
371 
372             return (com.liferay.portlet.workflow.model.WorkflowDefinition)returnObj;
373         }
374         catch (com.liferay.portal.SystemException se) {
375             _log.error(se, se);
376 
377             throw se;
378         }
379     }
380 
381     private static Log _log = LogFactoryUtil.getLog(WorkflowDefinitionServiceHttp.class);
382 }