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.portal.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.LongWrapper;
20  import com.liferay.portal.kernel.util.MethodWrapper;
21  import com.liferay.portal.kernel.util.NullWrapper;
22  import com.liferay.portal.security.auth.HttpPrincipal;
23  import com.liferay.portal.service.TeamServiceUtil;
24  
25  /**
26   * <a href="TeamServiceHttp.java.html"><b><i>View Source</i></b></a>
27   *
28   * <p>
29   * ServiceBuilder generated this class. Modifications in this class will be
30   * overwritten the next time is generated.
31   * </p>
32   *
33   * <p>
34   * This class provides a HTTP utility for the
35   * {@link com.liferay.portal.service.TeamServiceUtil} service utility. The
36   * static methods of this class calls the same methods of the service utility.
37   * However, the signatures are different because it requires an additional
38   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
39   * </p>
40   *
41   * <p>
42   * The benefits of using the HTTP utility is that it is fast and allows for
43   * tunneling without the cost of serializing to text. The drawback is that it
44   * only works with Java.
45   * </p>
46   *
47   * <p>
48   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
49   * configure security.
50   * </p>
51   *
52   * <p>
53   * The HTTP utility is only generated for remote services.
54   * </p>
55   *
56   * @author    Brian Wing Shun Chan
57   * @see       TeamServiceSoap
58   * @see       com.liferay.portal.security.auth.HttpPrincipal
59   * @see       com.liferay.portal.service.TeamServiceUtil
60   * @generated
61   */
62  public class TeamServiceHttp {
63      public static com.liferay.portal.model.Team addTeam(
64          HttpPrincipal httpPrincipal, long groupId, java.lang.String name,
65          java.lang.String description)
66          throws com.liferay.portal.kernel.exception.PortalException,
67              com.liferay.portal.kernel.exception.SystemException {
68          try {
69              Object paramObj0 = new LongWrapper(groupId);
70  
71              Object paramObj1 = name;
72  
73              if (name == null) {
74                  paramObj1 = new NullWrapper("java.lang.String");
75              }
76  
77              Object paramObj2 = description;
78  
79              if (description == null) {
80                  paramObj2 = new NullWrapper("java.lang.String");
81              }
82  
83              MethodWrapper methodWrapper = new MethodWrapper(TeamServiceUtil.class.getName(),
84                      "addTeam", new Object[] { paramObj0, paramObj1, paramObj2 });
85  
86              Object returnObj = null;
87  
88              try {
89                  returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
90              }
91              catch (Exception e) {
92                  if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
93                      throw (com.liferay.portal.kernel.exception.PortalException)e;
94                  }
95  
96                  if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
97                      throw (com.liferay.portal.kernel.exception.SystemException)e;
98                  }
99  
100                 throw new com.liferay.portal.kernel.exception.SystemException(e);
101             }
102 
103             return (com.liferay.portal.model.Team)returnObj;
104         }
105         catch (com.liferay.portal.kernel.exception.SystemException se) {
106             _log.error(se, se);
107 
108             throw se;
109         }
110     }
111 
112     public static void deleteTeam(HttpPrincipal httpPrincipal, long teamId)
113         throws com.liferay.portal.kernel.exception.PortalException,
114             com.liferay.portal.kernel.exception.SystemException {
115         try {
116             Object paramObj0 = new LongWrapper(teamId);
117 
118             MethodWrapper methodWrapper = new MethodWrapper(TeamServiceUtil.class.getName(),
119                     "deleteTeam", new Object[] { paramObj0 });
120 
121             try {
122                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
123             }
124             catch (Exception e) {
125                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
126                     throw (com.liferay.portal.kernel.exception.PortalException)e;
127                 }
128 
129                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
130                     throw (com.liferay.portal.kernel.exception.SystemException)e;
131                 }
132 
133                 throw new com.liferay.portal.kernel.exception.SystemException(e);
134             }
135         }
136         catch (com.liferay.portal.kernel.exception.SystemException se) {
137             _log.error(se, se);
138 
139             throw se;
140         }
141     }
142 
143     public static com.liferay.portal.model.Team updateTeam(
144         HttpPrincipal httpPrincipal, long teamId, java.lang.String name,
145         java.lang.String description)
146         throws com.liferay.portal.kernel.exception.PortalException,
147             com.liferay.portal.kernel.exception.SystemException {
148         try {
149             Object paramObj0 = new LongWrapper(teamId);
150 
151             Object paramObj1 = name;
152 
153             if (name == null) {
154                 paramObj1 = new NullWrapper("java.lang.String");
155             }
156 
157             Object paramObj2 = description;
158 
159             if (description == null) {
160                 paramObj2 = new NullWrapper("java.lang.String");
161             }
162 
163             MethodWrapper methodWrapper = new MethodWrapper(TeamServiceUtil.class.getName(),
164                     "updateTeam",
165                     new Object[] { paramObj0, paramObj1, paramObj2 });
166 
167             Object returnObj = null;
168 
169             try {
170                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
171             }
172             catch (Exception e) {
173                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
174                     throw (com.liferay.portal.kernel.exception.PortalException)e;
175                 }
176 
177                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
178                     throw (com.liferay.portal.kernel.exception.SystemException)e;
179                 }
180 
181                 throw new com.liferay.portal.kernel.exception.SystemException(e);
182             }
183 
184             return (com.liferay.portal.model.Team)returnObj;
185         }
186         catch (com.liferay.portal.kernel.exception.SystemException se) {
187             _log.error(se, se);
188 
189             throw se;
190         }
191     }
192 
193     private static Log _log = LogFactoryUtil.getLog(TeamServiceHttp.class);
194 }