1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.announcements.service.http;
21  
22  import com.liferay.portal.kernel.log.Log;
23  import com.liferay.portal.kernel.log.LogFactoryUtil;
24  import com.liferay.portal.kernel.util.BooleanWrapper;
25  import com.liferay.portal.kernel.util.LongWrapper;
26  import com.liferay.portal.kernel.util.MethodWrapper;
27  import com.liferay.portal.kernel.util.NullWrapper;
28  import com.liferay.portal.security.auth.HttpPrincipal;
29  import com.liferay.portal.service.http.TunnelUtil;
30  
31  import com.liferay.portlet.announcements.service.AnnouncementsDeliveryServiceUtil;
32  
33  /**
34   * <a href="AnnouncementsDeliveryServiceHttp.java.html"><b><i>View Source</i></b></a>
35   *
36   * <p>
37   * ServiceBuilder generated this class. Modifications in this class will be
38   * overwritten the next time is generated.
39   * </p>
40   *
41   * <p>
42   * This class provides a HTTP utility for the
43   * <code>com.liferay.portlet.announcements.service.AnnouncementsDeliveryServiceUtil</code> service
44   * utility. The static methods of this class calls the same methods of the
45   * service utility. However, the signatures are different because it requires an
46   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
47   * parameter.
48   * </p>
49   *
50   * <p>
51   * The benefits of using the HTTP utility is that it is fast and allows for
52   * tunneling without the cost of serializing to text. The drawback is that it
53   * only works with Java.
54   * </p>
55   *
56   * <p>
57   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
58   * portal.properties to configure security.
59   * </p>
60   *
61   * <p>
62   * The HTTP utility is only generated for remote services.
63   * </p>
64   *
65   * @author Brian Wing Shun Chan
66   *
67   * @see com.liferay.portal.security.auth.HttpPrincipal
68   * @see com.liferay.portlet.announcements.service.AnnouncementsDeliveryServiceUtil
69   * @see com.liferay.portlet.announcements.service.http.AnnouncementsDeliveryServiceSoap
70   *
71   */
72  public class AnnouncementsDeliveryServiceHttp {
73      public static com.liferay.portlet.announcements.model.AnnouncementsDelivery updateDelivery(
74          HttpPrincipal httpPrincipal, long userId, java.lang.String type,
75          boolean email, boolean sms, boolean website)
76          throws com.liferay.portal.PortalException,
77              com.liferay.portal.SystemException {
78          try {
79              Object paramObj0 = new LongWrapper(userId);
80  
81              Object paramObj1 = type;
82  
83              if (type == null) {
84                  paramObj1 = new NullWrapper("java.lang.String");
85              }
86  
87              Object paramObj2 = new BooleanWrapper(email);
88  
89              Object paramObj3 = new BooleanWrapper(sms);
90  
91              Object paramObj4 = new BooleanWrapper(website);
92  
93              MethodWrapper methodWrapper = new MethodWrapper(AnnouncementsDeliveryServiceUtil.class.getName(),
94                      "updateDelivery",
95                      new Object[] {
96                          paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
97                      });
98  
99              Object returnObj = null;
100 
101             try {
102                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
103             }
104             catch (Exception e) {
105                 if (e instanceof com.liferay.portal.PortalException) {
106                     throw (com.liferay.portal.PortalException)e;
107                 }
108 
109                 if (e instanceof com.liferay.portal.SystemException) {
110                     throw (com.liferay.portal.SystemException)e;
111                 }
112 
113                 throw new com.liferay.portal.SystemException(e);
114             }
115 
116             return (com.liferay.portlet.announcements.model.AnnouncementsDelivery)returnObj;
117         }
118         catch (com.liferay.portal.SystemException se) {
119             _log.error(se, se);
120 
121             throw se;
122         }
123     }
124 
125     private static Log _log = LogFactoryUtil.getLog(AnnouncementsDeliveryServiceHttp.class);
126 }