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.ClassNameServiceUtil;
24  
25  /**
26   * <a href="ClassNameServiceHttp.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.ClassNameServiceUtil} 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       ClassNameServiceSoap
58   * @see       com.liferay.portal.security.auth.HttpPrincipal
59   * @see       com.liferay.portal.service.ClassNameServiceUtil
60   * @generated
61   */
62  public class ClassNameServiceHttp {
63      public static com.liferay.portal.model.ClassName getClassName(
64          HttpPrincipal httpPrincipal, long classNameId)
65          throws com.liferay.portal.kernel.exception.PortalException,
66              com.liferay.portal.kernel.exception.SystemException {
67          try {
68              Object paramObj0 = new LongWrapper(classNameId);
69  
70              MethodWrapper methodWrapper = new MethodWrapper(ClassNameServiceUtil.class.getName(),
71                      "getClassName", new Object[] { paramObj0 });
72  
73              Object returnObj = null;
74  
75              try {
76                  returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
77              }
78              catch (Exception e) {
79                  if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
80                      throw (com.liferay.portal.kernel.exception.PortalException)e;
81                  }
82  
83                  if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
84                      throw (com.liferay.portal.kernel.exception.SystemException)e;
85                  }
86  
87                  throw new com.liferay.portal.kernel.exception.SystemException(e);
88              }
89  
90              return (com.liferay.portal.model.ClassName)returnObj;
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 com.liferay.portal.model.ClassName getClassName(
100         HttpPrincipal httpPrincipal, java.lang.String value)
101         throws com.liferay.portal.kernel.exception.SystemException {
102         try {
103             Object paramObj0 = value;
104 
105             if (value == null) {
106                 paramObj0 = new NullWrapper("java.lang.String");
107             }
108 
109             MethodWrapper methodWrapper = new MethodWrapper(ClassNameServiceUtil.class.getName(),
110                     "getClassName", new Object[] { paramObj0 });
111 
112             Object returnObj = null;
113 
114             try {
115                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
116             }
117             catch (Exception e) {
118                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
119                     throw (com.liferay.portal.kernel.exception.SystemException)e;
120                 }
121 
122                 throw new com.liferay.portal.kernel.exception.SystemException(e);
123             }
124 
125             return (com.liferay.portal.model.ClassName)returnObj;
126         }
127         catch (com.liferay.portal.kernel.exception.SystemException se) {
128             _log.error(se, se);
129 
130             throw se;
131         }
132     }
133 
134     public static long getClassNameId(HttpPrincipal httpPrincipal,
135         java.lang.Class<?> classObj)
136         throws com.liferay.portal.kernel.exception.SystemException {
137         try {
138             Object paramObj0 = classObj;
139 
140             if (classObj == null) {
141                 paramObj0 = new NullWrapper("java.lang.Class");
142             }
143 
144             MethodWrapper methodWrapper = new MethodWrapper(ClassNameServiceUtil.class.getName(),
145                     "getClassNameId", new Object[] { paramObj0 });
146 
147             Object returnObj = null;
148 
149             try {
150                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
151             }
152             catch (Exception e) {
153                 throw new com.liferay.portal.kernel.exception.SystemException(e);
154             }
155 
156             return ((Long)returnObj).longValue();
157         }
158         catch (com.liferay.portal.kernel.exception.SystemException se) {
159             _log.error(se, se);
160 
161             throw se;
162         }
163     }
164 
165     public static long getClassNameId(HttpPrincipal httpPrincipal,
166         java.lang.String value)
167         throws com.liferay.portal.kernel.exception.SystemException {
168         try {
169             Object paramObj0 = value;
170 
171             if (value == null) {
172                 paramObj0 = new NullWrapper("java.lang.String");
173             }
174 
175             MethodWrapper methodWrapper = new MethodWrapper(ClassNameServiceUtil.class.getName(),
176                     "getClassNameId", new Object[] { paramObj0 });
177 
178             Object returnObj = null;
179 
180             try {
181                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
182             }
183             catch (Exception e) {
184                 throw new com.liferay.portal.kernel.exception.SystemException(e);
185             }
186 
187             return ((Long)returnObj).longValue();
188         }
189         catch (com.liferay.portal.kernel.exception.SystemException se) {
190             _log.error(se, se);
191 
192             throw se;
193         }
194     }
195 
196     private static Log _log = LogFactoryUtil.getLog(ClassNameServiceHttp.class);
197 }