1   /**
2    * Copyright (c) 2000-2010 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   *
12   *
13   */
14  
15  package com.liferay.portlet.messageboards.service.http;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portal.kernel.util.MethodHandler;
20  import com.liferay.portal.kernel.util.MethodKey;
21  import com.liferay.portal.security.auth.HttpPrincipal;
22  import com.liferay.portal.service.http.TunnelUtil;
23  
24  import com.liferay.portlet.messageboards.service.MBMessageFlagServiceUtil;
25  
26  /**
27   * <a href="MBMessageFlagServiceHttp.java.html"><b><i>View Source</i></b></a>
28   *
29   * <p>
30   * ServiceBuilder generated this class. Modifications in this class will be
31   * overwritten the next time is generated.
32   * </p>
33   *
34   * <p>
35   * This class provides a HTTP utility for the
36   * {@link com.liferay.portlet.messageboards.service.MBMessageFlagServiceUtil} service utility. The
37   * static methods of this class calls the same methods of the service utility.
38   * However, the signatures are different because it requires an additional
39   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
40   * </p>
41   *
42   * <p>
43   * The benefits of using the HTTP utility is that it is fast and allows for
44   * tunneling without the cost of serializing to text. The drawback is that it
45   * only works with Java.
46   * </p>
47   *
48   * <p>
49   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
50   * configure security.
51   * </p>
52   *
53   * <p>
54   * The HTTP utility is only generated for remote services.
55   * </p>
56   *
57   * @author    Brian Wing Shun Chan
58   * @see       MBMessageFlagServiceSoap
59   * @see       com.liferay.portal.security.auth.HttpPrincipal
60   * @see       com.liferay.portlet.messageboards.service.MBMessageFlagServiceUtil
61   * @generated
62   */
63  public class MBMessageFlagServiceHttp {
64      public static void addAnswerFlag(HttpPrincipal httpPrincipal, long messageId)
65          throws com.liferay.portal.PortalException,
66              com.liferay.portal.SystemException {
67          try {
68              MethodKey methodKey = new MethodKey(MBMessageFlagServiceUtil.class.getName(),
69                      "addAnswerFlag", _addAnswerFlagParameterTypes0);
70  
71              MethodHandler methodHandler = new MethodHandler(methodKey, messageId);
72  
73              try {
74                  TunnelUtil.invoke(httpPrincipal, methodHandler);
75              }
76              catch (Exception e) {
77                  if (e instanceof com.liferay.portal.PortalException) {
78                      throw (com.liferay.portal.PortalException)e;
79                  }
80  
81                  if (e instanceof com.liferay.portal.SystemException) {
82                      throw (com.liferay.portal.SystemException)e;
83                  }
84  
85                  throw new com.liferay.portal.SystemException(e);
86              }
87          }
88          catch (com.liferay.portal.SystemException se) {
89              _log.error(se, se);
90  
91              throw se;
92          }
93      }
94  
95      public static void deleteAnswerFlag(HttpPrincipal httpPrincipal,
96          long messageId)
97          throws com.liferay.portal.PortalException,
98              com.liferay.portal.SystemException {
99          try {
100             MethodKey methodKey = new MethodKey(MBMessageFlagServiceUtil.class.getName(),
101                     "deleteAnswerFlag", _deleteAnswerFlagParameterTypes1);
102 
103             MethodHandler methodHandler = new MethodHandler(methodKey, messageId);
104 
105             try {
106                 TunnelUtil.invoke(httpPrincipal, methodHandler);
107             }
108             catch (Exception e) {
109                 if (e instanceof com.liferay.portal.PortalException) {
110                     throw (com.liferay.portal.PortalException)e;
111                 }
112 
113                 if (e instanceof com.liferay.portal.SystemException) {
114                     throw (com.liferay.portal.SystemException)e;
115                 }
116 
117                 throw new com.liferay.portal.SystemException(e);
118             }
119         }
120         catch (com.liferay.portal.SystemException se) {
121             _log.error(se, se);
122 
123             throw se;
124         }
125     }
126 
127     private static Log _log = LogFactoryUtil.getLog(MBMessageFlagServiceHttp.class);
128     private static final Class<?>[] _addAnswerFlagParameterTypes0 = new Class[] {
129             long.class
130         };
131     private static final Class<?>[] _deleteAnswerFlagParameterTypes1 = new Class[] {
132             long.class
133         };
134 }