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.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 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.workflow.service.WorkflowDefinitionServiceUtil</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.workflow.service.WorkflowDefinitionServiceUtil
70   * @see com.liferay.portlet.workflow.service.http.WorkflowDefinitionServiceSoap
71   *
72   */
73  public class WorkflowDefinitionServiceHttp {
74      public static com.liferay.portlet.workflow.model.WorkflowDefinition addDefinition(
75          HttpPrincipal httpPrincipal, java.lang.String xml,
76          boolean addCommunityPermissions, boolean addGuestPermissions)
77          throws com.liferay.portal.SystemException, 
78              com.liferay.portal.PortalException {
79          try {
80              Object paramObj0 = xml;
81  
82              if (xml == null) {
83                  paramObj0 = new NullWrapper("java.lang.String");
84              }
85  
86              Object paramObj1 = new BooleanWrapper(addCommunityPermissions);
87              Object paramObj2 = new BooleanWrapper(addGuestPermissions);
88              MethodWrapper methodWrapper = new MethodWrapper(WorkflowDefinitionServiceUtil.class.getName(),
89                      "addDefinition",
90                      new Object[] { paramObj0, paramObj1, paramObj2 });
91              Object returnObj = null;
92  
93              try {
94                  returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
95              }
96              catch (Exception e) {
97                  if (e instanceof com.liferay.portal.SystemException) {
98                      throw (com.liferay.portal.SystemException)e;
99                  }
100 
101                 if (e instanceof com.liferay.portal.PortalException) {
102                     throw (com.liferay.portal.PortalException)e;
103                 }
104 
105                 throw new com.liferay.portal.SystemException(e);
106             }
107 
108             return (com.liferay.portlet.workflow.model.WorkflowDefinition)returnObj;
109         }
110         catch (com.liferay.portal.SystemException se) {
111             _log.error(se, se);
112             throw se;
113         }
114     }
115 
116     public static com.liferay.portlet.workflow.model.WorkflowDefinition addDefinition(
117         HttpPrincipal httpPrincipal, java.lang.String xml,
118         java.lang.String[] communityPermissions,
119         java.lang.String[] guestPermissions)
120         throws com.liferay.portal.SystemException, 
121             com.liferay.portal.PortalException {
122         try {
123             Object paramObj0 = xml;
124 
125             if (xml == null) {
126                 paramObj0 = new NullWrapper("java.lang.String");
127             }
128 
129             Object paramObj1 = communityPermissions;
130 
131             if (communityPermissions == null) {
132                 paramObj1 = new NullWrapper("[Ljava.lang.String;");
133             }
134 
135             Object paramObj2 = guestPermissions;
136 
137             if (guestPermissions == null) {
138                 paramObj2 = new NullWrapper("[Ljava.lang.String;");
139             }
140 
141             MethodWrapper methodWrapper = new MethodWrapper(WorkflowDefinitionServiceUtil.class.getName(),
142                     "addDefinition",
143                     new Object[] { paramObj0, paramObj1, paramObj2 });
144             Object returnObj = null;
145 
146             try {
147                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
148             }
149             catch (Exception e) {
150                 if (e instanceof com.liferay.portal.SystemException) {
151                     throw (com.liferay.portal.SystemException)e;
152                 }
153 
154                 if (e instanceof com.liferay.portal.PortalException) {
155                     throw (com.liferay.portal.PortalException)e;
156                 }
157 
158                 throw new com.liferay.portal.SystemException(e);
159             }
160 
161             return (com.liferay.portlet.workflow.model.WorkflowDefinition)returnObj;
162         }
163         catch (com.liferay.portal.SystemException se) {
164             _log.error(se, se);
165             throw se;
166         }
167     }
168 
169     public static com.liferay.portlet.workflow.model.WorkflowDefinition addDefinition(
170         HttpPrincipal httpPrincipal, java.lang.String xml,
171         java.lang.Boolean addCommunityPermissions,
172         java.lang.Boolean addGuestPermissions,
173         java.lang.String[] communityPermissions,
174         java.lang.String[] guestPermissions)
175         throws com.liferay.portal.SystemException, 
176             com.liferay.portal.PortalException {
177         try {
178             Object paramObj0 = xml;
179 
180             if (xml == null) {
181                 paramObj0 = new NullWrapper("java.lang.String");
182             }
183 
184             Object paramObj1 = addCommunityPermissions;
185 
186             if (addCommunityPermissions == null) {
187                 paramObj1 = new NullWrapper("java.lang.Boolean");
188             }
189 
190             Object paramObj2 = addGuestPermissions;
191 
192             if (addGuestPermissions == null) {
193                 paramObj2 = new NullWrapper("java.lang.Boolean");
194             }
195 
196             Object paramObj3 = communityPermissions;
197 
198             if (communityPermissions == null) {
199                 paramObj3 = new NullWrapper("[Ljava.lang.String;");
200             }
201 
202             Object paramObj4 = guestPermissions;
203 
204             if (guestPermissions == null) {
205                 paramObj4 = new NullWrapper("[Ljava.lang.String;");
206             }
207 
208             MethodWrapper methodWrapper = new MethodWrapper(WorkflowDefinitionServiceUtil.class.getName(),
209                     "addDefinition",
210                     new Object[] {
211                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
212                     });
213             Object returnObj = null;
214 
215             try {
216                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
217             }
218             catch (Exception e) {
219                 if (e instanceof com.liferay.portal.SystemException) {
220                     throw (com.liferay.portal.SystemException)e;
221                 }
222 
223                 if (e instanceof com.liferay.portal.PortalException) {
224                     throw (com.liferay.portal.PortalException)e;
225                 }
226 
227                 throw new com.liferay.portal.SystemException(e);
228             }
229 
230             return (com.liferay.portlet.workflow.model.WorkflowDefinition)returnObj;
231         }
232         catch (com.liferay.portal.SystemException se) {
233             _log.error(se, se);
234             throw se;
235         }
236     }
237 
238     public static void addDefinitionResources(HttpPrincipal httpPrincipal,
239         com.liferay.portal.model.User user, long definitionId,
240         boolean addCommunityPermissions, boolean addGuestPermissions)
241         throws com.liferay.portal.SystemException, 
242             com.liferay.portal.PortalException {
243         try {
244             Object paramObj0 = user;
245 
246             if (user == null) {
247                 paramObj0 = new NullWrapper("com.liferay.portal.model.User");
248             }
249 
250             Object paramObj1 = new LongWrapper(definitionId);
251             Object paramObj2 = new BooleanWrapper(addCommunityPermissions);
252             Object paramObj3 = new BooleanWrapper(addGuestPermissions);
253             MethodWrapper methodWrapper = new MethodWrapper(WorkflowDefinitionServiceUtil.class.getName(),
254                     "addDefinitionResources",
255                     new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
256 
257             try {
258                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
259             }
260             catch (Exception e) {
261                 if (e instanceof com.liferay.portal.SystemException) {
262                     throw (com.liferay.portal.SystemException)e;
263                 }
264 
265                 if (e instanceof com.liferay.portal.PortalException) {
266                     throw (com.liferay.portal.PortalException)e;
267                 }
268 
269                 throw new com.liferay.portal.SystemException(e);
270             }
271         }
272         catch (com.liferay.portal.SystemException se) {
273             _log.error(se, se);
274             throw se;
275         }
276     }
277 
278     public static void addDefinitionResources(HttpPrincipal httpPrincipal,
279         com.liferay.portal.model.User user, long definitionId,
280         java.lang.String[] communityPermissions,
281         java.lang.String[] guestPermissions)
282         throws com.liferay.portal.SystemException, 
283             com.liferay.portal.PortalException {
284         try {
285             Object paramObj0 = user;
286 
287             if (user == null) {
288                 paramObj0 = new NullWrapper("com.liferay.portal.model.User");
289             }
290 
291             Object paramObj1 = new LongWrapper(definitionId);
292             Object paramObj2 = communityPermissions;
293 
294             if (communityPermissions == null) {
295                 paramObj2 = new NullWrapper("[Ljava.lang.String;");
296             }
297 
298             Object paramObj3 = guestPermissions;
299 
300             if (guestPermissions == null) {
301                 paramObj3 = new NullWrapper("[Ljava.lang.String;");
302             }
303 
304             MethodWrapper methodWrapper = new MethodWrapper(WorkflowDefinitionServiceUtil.class.getName(),
305                     "addDefinitionResources",
306                     new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
307 
308             try {
309                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
310             }
311             catch (Exception e) {
312                 if (e instanceof com.liferay.portal.SystemException) {
313                     throw (com.liferay.portal.SystemException)e;
314                 }
315 
316                 if (e instanceof com.liferay.portal.PortalException) {
317                     throw (com.liferay.portal.PortalException)e;
318                 }
319 
320                 throw new com.liferay.portal.SystemException(e);
321             }
322         }
323         catch (com.liferay.portal.SystemException se) {
324             _log.error(se, se);
325             throw se;
326         }
327     }
328 
329     public static com.liferay.portlet.workflow.model.WorkflowDefinition getDefinition(
330         HttpPrincipal httpPrincipal, long definitionId)
331         throws com.liferay.portal.SystemException, 
332             com.liferay.portal.PortalException {
333         try {
334             Object paramObj0 = new LongWrapper(definitionId);
335             MethodWrapper methodWrapper = new MethodWrapper(WorkflowDefinitionServiceUtil.class.getName(),
336                     "getDefinition", new Object[] { paramObj0 });
337             Object returnObj = null;
338 
339             try {
340                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
341             }
342             catch (Exception e) {
343                 if (e instanceof com.liferay.portal.SystemException) {
344                     throw (com.liferay.portal.SystemException)e;
345                 }
346 
347                 if (e instanceof com.liferay.portal.PortalException) {
348                     throw (com.liferay.portal.PortalException)e;
349                 }
350 
351                 throw new com.liferay.portal.SystemException(e);
352             }
353 
354             return (com.liferay.portlet.workflow.model.WorkflowDefinition)returnObj;
355         }
356         catch (com.liferay.portal.SystemException se) {
357             _log.error(se, se);
358             throw se;
359         }
360     }
361 
362     private static Log _log = LogFactoryUtil.getLog(WorkflowDefinitionServiceHttp.class);
363 }