1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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.messageboards.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.LongWrapper;
28  import com.liferay.portal.kernel.util.MethodWrapper;
29  import com.liferay.portal.kernel.util.NullWrapper;
30  import com.liferay.portal.security.auth.HttpPrincipal;
31  import com.liferay.portal.service.http.TunnelUtil;
32  
33  import com.liferay.portlet.messageboards.service.MBBanServiceUtil;
34  
35  /**
36   * <a href="MBBanServiceHttp.java.html"><b><i>View Source</i></b></a>
37   *
38   * <p>
39   * ServiceBuilder generated this class. Modifications in this class will be
40   * overwritten the next time is generated.
41   * </p>
42   *
43   * <p>
44   * This class provides a HTTP utility for the
45   * {@link com.liferay.portlet.messageboards.service.MBBanServiceUtil} service utility. The
46   * static methods of this class calls the same methods of the service utility.
47   * However, the signatures are different because it requires an additional
48   * {@link com.liferay.portal.security.auth.HttpPrincipal} 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 <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
59   * 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   * @see       MBBanServiceSoap
68   * @see       com.liferay.portal.security.auth.HttpPrincipal
69   * @see       com.liferay.portlet.messageboards.service.MBBanServiceUtil
70   * @generated
71   */
72  public class MBBanServiceHttp {
73      public static com.liferay.portlet.messageboards.model.MBBan addBan(
74          HttpPrincipal httpPrincipal, long banUserId,
75          com.liferay.portal.service.ServiceContext serviceContext)
76          throws com.liferay.portal.PortalException,
77              com.liferay.portal.SystemException {
78          try {
79              Object paramObj0 = new LongWrapper(banUserId);
80  
81              Object paramObj1 = serviceContext;
82  
83              if (serviceContext == null) {
84                  paramObj1 = new NullWrapper(
85                          "com.liferay.portal.service.ServiceContext");
86              }
87  
88              MethodWrapper methodWrapper = new MethodWrapper(MBBanServiceUtil.class.getName(),
89                      "addBan", new Object[] { paramObj0, paramObj1 });
90  
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.PortalException) {
98                      throw (com.liferay.portal.PortalException)e;
99                  }
100 
101                 if (e instanceof com.liferay.portal.SystemException) {
102                     throw (com.liferay.portal.SystemException)e;
103                 }
104 
105                 throw new com.liferay.portal.SystemException(e);
106             }
107 
108             return (com.liferay.portlet.messageboards.model.MBBan)returnObj;
109         }
110         catch (com.liferay.portal.SystemException se) {
111             _log.error(se, se);
112 
113             throw se;
114         }
115     }
116 
117     public static void deleteBan(HttpPrincipal httpPrincipal, long banUserId,
118         com.liferay.portal.service.ServiceContext serviceContext)
119         throws com.liferay.portal.PortalException,
120             com.liferay.portal.SystemException {
121         try {
122             Object paramObj0 = new LongWrapper(banUserId);
123 
124             Object paramObj1 = serviceContext;
125 
126             if (serviceContext == null) {
127                 paramObj1 = new NullWrapper(
128                         "com.liferay.portal.service.ServiceContext");
129             }
130 
131             MethodWrapper methodWrapper = new MethodWrapper(MBBanServiceUtil.class.getName(),
132                     "deleteBan", new Object[] { paramObj0, paramObj1 });
133 
134             try {
135                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
136             }
137             catch (Exception e) {
138                 if (e instanceof com.liferay.portal.PortalException) {
139                     throw (com.liferay.portal.PortalException)e;
140                 }
141 
142                 if (e instanceof com.liferay.portal.SystemException) {
143                     throw (com.liferay.portal.SystemException)e;
144                 }
145 
146                 throw new com.liferay.portal.SystemException(e);
147             }
148         }
149         catch (com.liferay.portal.SystemException se) {
150             _log.error(se, se);
151 
152             throw se;
153         }
154     }
155 
156     private static Log _log = LogFactoryUtil.getLog(MBBanServiceHttp.class);
157 }