1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.announcements.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.IntegerWrapper;
20  import com.liferay.portal.kernel.util.LongWrapper;
21  import com.liferay.portal.kernel.util.MethodWrapper;
22  import com.liferay.portal.security.auth.HttpPrincipal;
23  import com.liferay.portal.service.http.TunnelUtil;
24  
25  import com.liferay.portlet.announcements.service.AnnouncementsFlagServiceUtil;
26  
27  /**
28   * <a href="AnnouncementsFlagServiceHttp.java.html"><b><i>View Source</i></b></a>
29   *
30   * <p>
31   * ServiceBuilder generated this class. Modifications in this class will be
32   * overwritten the next time is generated.
33   * </p>
34   *
35   * <p>
36   * This class provides a HTTP utility for the
37   * {@link com.liferay.portlet.announcements.service.AnnouncementsFlagServiceUtil} service utility. The
38   * static methods of this class calls the same methods of the service utility.
39   * However, the signatures are different because it requires an additional
40   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
41   * </p>
42   *
43   * <p>
44   * The benefits of using the HTTP utility is that it is fast and allows for
45   * tunneling without the cost of serializing to text. The drawback is that it
46   * only works with Java.
47   * </p>
48   *
49   * <p>
50   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
51   * configure security.
52   * </p>
53   *
54   * <p>
55   * The HTTP utility is only generated for remote services.
56   * </p>
57   *
58   * @author    Brian Wing Shun Chan
59   * @see       AnnouncementsFlagServiceSoap
60   * @see       com.liferay.portal.security.auth.HttpPrincipal
61   * @see       com.liferay.portlet.announcements.service.AnnouncementsFlagServiceUtil
62   * @generated
63   */
64  public class AnnouncementsFlagServiceHttp {
65      public static void addFlag(HttpPrincipal httpPrincipal, long entryId,
66          int value)
67          throws com.liferay.portal.kernel.exception.PortalException,
68              com.liferay.portal.kernel.exception.SystemException {
69          try {
70              Object paramObj0 = new LongWrapper(entryId);
71  
72              Object paramObj1 = new IntegerWrapper(value);
73  
74              MethodWrapper methodWrapper = new MethodWrapper(AnnouncementsFlagServiceUtil.class.getName(),
75                      "addFlag", new Object[] { paramObj0, paramObj1 });
76  
77              try {
78                  TunnelUtil.invoke(httpPrincipal, methodWrapper);
79              }
80              catch (Exception e) {
81                  if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
82                      throw (com.liferay.portal.kernel.exception.PortalException)e;
83                  }
84  
85                  if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
86                      throw (com.liferay.portal.kernel.exception.SystemException)e;
87                  }
88  
89                  throw new com.liferay.portal.kernel.exception.SystemException(e);
90              }
91          }
92          catch (com.liferay.portal.kernel.exception.SystemException se) {
93              _log.error(se, se);
94  
95              throw se;
96          }
97      }
98  
99      public static void deleteFlag(HttpPrincipal httpPrincipal, long flagId)
100         throws com.liferay.portal.kernel.exception.PortalException,
101             com.liferay.portal.kernel.exception.SystemException {
102         try {
103             Object paramObj0 = new LongWrapper(flagId);
104 
105             MethodWrapper methodWrapper = new MethodWrapper(AnnouncementsFlagServiceUtil.class.getName(),
106                     "deleteFlag", new Object[] { paramObj0 });
107 
108             try {
109                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
110             }
111             catch (Exception e) {
112                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
113                     throw (com.liferay.portal.kernel.exception.PortalException)e;
114                 }
115 
116                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
117                     throw (com.liferay.portal.kernel.exception.SystemException)e;
118                 }
119 
120                 throw new com.liferay.portal.kernel.exception.SystemException(e);
121             }
122         }
123         catch (com.liferay.portal.kernel.exception.SystemException se) {
124             _log.error(se, se);
125 
126             throw se;
127         }
128     }
129 
130     public static com.liferay.portlet.announcements.model.AnnouncementsFlag getFlag(
131         HttpPrincipal httpPrincipal, long entryId, int value)
132         throws com.liferay.portal.kernel.exception.PortalException,
133             com.liferay.portal.kernel.exception.SystemException {
134         try {
135             Object paramObj0 = new LongWrapper(entryId);
136 
137             Object paramObj1 = new IntegerWrapper(value);
138 
139             MethodWrapper methodWrapper = new MethodWrapper(AnnouncementsFlagServiceUtil.class.getName(),
140                     "getFlag", new Object[] { paramObj0, paramObj1 });
141 
142             Object returnObj = null;
143 
144             try {
145                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
146             }
147             catch (Exception e) {
148                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
149                     throw (com.liferay.portal.kernel.exception.PortalException)e;
150                 }
151 
152                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
153                     throw (com.liferay.portal.kernel.exception.SystemException)e;
154                 }
155 
156                 throw new com.liferay.portal.kernel.exception.SystemException(e);
157             }
158 
159             return (com.liferay.portlet.announcements.model.AnnouncementsFlag)returnObj;
160         }
161         catch (com.liferay.portal.kernel.exception.SystemException se) {
162             _log.error(se, se);
163 
164             throw se;
165         }
166     }
167 
168     private static Log _log = LogFactoryUtil.getLog(AnnouncementsFlagServiceHttp.class);
169 }