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.portal.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.IntegerWrapper;
26  import com.liferay.portal.kernel.util.LongWrapper;
27  import com.liferay.portal.kernel.util.MethodWrapper;
28  import com.liferay.portal.kernel.util.NullWrapper;
29  import com.liferay.portal.security.auth.HttpPrincipal;
30  import com.liferay.portal.service.EmailAddressServiceUtil;
31  
32  /**
33   * <a href="EmailAddressServiceHttp.java.html"><b><i>View Source</i></b></a>
34   *
35   * <p>
36   * ServiceBuilder generated this class. Modifications in this class will be
37   * overwritten the next time is generated.
38   * </p>
39   *
40   * <p>
41   * This class provides a HTTP utility for the
42   * <code>com.liferay.portal.service.EmailAddressServiceUtil</code> service
43   * utility. The static methods of this class calls the same methods of the
44   * service utility. However, the signatures are different because it requires an
45   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
46   * parameter.
47   * </p>
48   *
49   * <p>
50   * The benefits of using the HTTP utility is that it is fast and allows for
51   * tunneling without the cost of serializing to text. The drawback is that it
52   * only works with Java.
53   * </p>
54   *
55   * <p>
56   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
57   * portal.properties to configure security.
58   * </p>
59   *
60   * <p>
61   * The HTTP utility is only generated for remote services.
62   * </p>
63   *
64   * @author Brian Wing Shun Chan
65   *
66   * @see com.liferay.portal.security.auth.HttpPrincipal
67   * @see com.liferay.portal.service.EmailAddressServiceUtil
68   * @see com.liferay.portal.service.http.EmailAddressServiceSoap
69   *
70   */
71  public class EmailAddressServiceHttp {
72      public static com.liferay.portal.model.EmailAddress addEmailAddress(
73          HttpPrincipal httpPrincipal, java.lang.String className, long classPK,
74          java.lang.String address, int typeId, boolean primary)
75          throws com.liferay.portal.PortalException,
76              com.liferay.portal.SystemException {
77          try {
78              Object paramObj0 = className;
79  
80              if (className == null) {
81                  paramObj0 = new NullWrapper("java.lang.String");
82              }
83  
84              Object paramObj1 = new LongWrapper(classPK);
85  
86              Object paramObj2 = address;
87  
88              if (address == null) {
89                  paramObj2 = new NullWrapper("java.lang.String");
90              }
91  
92              Object paramObj3 = new IntegerWrapper(typeId);
93  
94              Object paramObj4 = new BooleanWrapper(primary);
95  
96              MethodWrapper methodWrapper = new MethodWrapper(EmailAddressServiceUtil.class.getName(),
97                      "addEmailAddress",
98                      new Object[] {
99                          paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
100                     });
101 
102             Object returnObj = null;
103 
104             try {
105                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
106             }
107             catch (Exception e) {
108                 if (e instanceof com.liferay.portal.PortalException) {
109                     throw (com.liferay.portal.PortalException)e;
110                 }
111 
112                 if (e instanceof com.liferay.portal.SystemException) {
113                     throw (com.liferay.portal.SystemException)e;
114                 }
115 
116                 throw new com.liferay.portal.SystemException(e);
117             }
118 
119             return (com.liferay.portal.model.EmailAddress)returnObj;
120         }
121         catch (com.liferay.portal.SystemException se) {
122             _log.error(se, se);
123 
124             throw se;
125         }
126     }
127 
128     public static void deleteEmailAddress(HttpPrincipal httpPrincipal,
129         long emailAddressId)
130         throws com.liferay.portal.PortalException,
131             com.liferay.portal.SystemException {
132         try {
133             Object paramObj0 = new LongWrapper(emailAddressId);
134 
135             MethodWrapper methodWrapper = new MethodWrapper(EmailAddressServiceUtil.class.getName(),
136                     "deleteEmailAddress", new Object[] { paramObj0 });
137 
138             try {
139                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
140             }
141             catch (Exception e) {
142                 if (e instanceof com.liferay.portal.PortalException) {
143                     throw (com.liferay.portal.PortalException)e;
144                 }
145 
146                 if (e instanceof com.liferay.portal.SystemException) {
147                     throw (com.liferay.portal.SystemException)e;
148                 }
149 
150                 throw new com.liferay.portal.SystemException(e);
151             }
152         }
153         catch (com.liferay.portal.SystemException se) {
154             _log.error(se, se);
155 
156             throw se;
157         }
158     }
159 
160     public static com.liferay.portal.model.EmailAddress getEmailAddress(
161         HttpPrincipal httpPrincipal, long emailAddressId)
162         throws com.liferay.portal.PortalException,
163             com.liferay.portal.SystemException {
164         try {
165             Object paramObj0 = new LongWrapper(emailAddressId);
166 
167             MethodWrapper methodWrapper = new MethodWrapper(EmailAddressServiceUtil.class.getName(),
168                     "getEmailAddress", new Object[] { paramObj0 });
169 
170             Object returnObj = null;
171 
172             try {
173                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
174             }
175             catch (Exception e) {
176                 if (e instanceof com.liferay.portal.PortalException) {
177                     throw (com.liferay.portal.PortalException)e;
178                 }
179 
180                 if (e instanceof com.liferay.portal.SystemException) {
181                     throw (com.liferay.portal.SystemException)e;
182                 }
183 
184                 throw new com.liferay.portal.SystemException(e);
185             }
186 
187             return (com.liferay.portal.model.EmailAddress)returnObj;
188         }
189         catch (com.liferay.portal.SystemException se) {
190             _log.error(se, se);
191 
192             throw se;
193         }
194     }
195 
196     public static java.util.List<com.liferay.portal.model.EmailAddress> getEmailAddresses(
197         HttpPrincipal httpPrincipal, java.lang.String className, long classPK)
198         throws com.liferay.portal.PortalException,
199             com.liferay.portal.SystemException {
200         try {
201             Object paramObj0 = className;
202 
203             if (className == null) {
204                 paramObj0 = new NullWrapper("java.lang.String");
205             }
206 
207             Object paramObj1 = new LongWrapper(classPK);
208 
209             MethodWrapper methodWrapper = new MethodWrapper(EmailAddressServiceUtil.class.getName(),
210                     "getEmailAddresses", new Object[] { paramObj0, paramObj1 });
211 
212             Object returnObj = null;
213 
214             try {
215                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
216             }
217             catch (Exception e) {
218                 if (e instanceof com.liferay.portal.PortalException) {
219                     throw (com.liferay.portal.PortalException)e;
220                 }
221 
222                 if (e instanceof com.liferay.portal.SystemException) {
223                     throw (com.liferay.portal.SystemException)e;
224                 }
225 
226                 throw new com.liferay.portal.SystemException(e);
227             }
228 
229             return (java.util.List<com.liferay.portal.model.EmailAddress>)returnObj;
230         }
231         catch (com.liferay.portal.SystemException se) {
232             _log.error(se, se);
233 
234             throw se;
235         }
236     }
237 
238     public static com.liferay.portal.model.EmailAddress updateEmailAddress(
239         HttpPrincipal httpPrincipal, long emailAddressId,
240         java.lang.String address, int typeId, boolean primary)
241         throws com.liferay.portal.PortalException,
242             com.liferay.portal.SystemException {
243         try {
244             Object paramObj0 = new LongWrapper(emailAddressId);
245 
246             Object paramObj1 = address;
247 
248             if (address == null) {
249                 paramObj1 = new NullWrapper("java.lang.String");
250             }
251 
252             Object paramObj2 = new IntegerWrapper(typeId);
253 
254             Object paramObj3 = new BooleanWrapper(primary);
255 
256             MethodWrapper methodWrapper = new MethodWrapper(EmailAddressServiceUtil.class.getName(),
257                     "updateEmailAddress",
258                     new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
259 
260             Object returnObj = null;
261 
262             try {
263                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
264             }
265             catch (Exception e) {
266                 if (e instanceof com.liferay.portal.PortalException) {
267                     throw (com.liferay.portal.PortalException)e;
268                 }
269 
270                 if (e instanceof com.liferay.portal.SystemException) {
271                     throw (com.liferay.portal.SystemException)e;
272                 }
273 
274                 throw new com.liferay.portal.SystemException(e);
275             }
276 
277             return (com.liferay.portal.model.EmailAddress)returnObj;
278         }
279         catch (com.liferay.portal.SystemException se) {
280             _log.error(se, se);
281 
282             throw se;
283         }
284     }
285 
286     private static Log _log = LogFactoryUtil.getLog(EmailAddressServiceHttp.class);
287 }