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