1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.service.http;
24  
25  import com.liferay.portal.kernel.log.Log;
26  import com.liferay.portal.kernel.log.LogFactoryUtil;
27  import com.liferay.portal.kernel.util.LongWrapper;
28  import com.liferay.portal.kernel.util.MethodWrapper;
29  import com.liferay.portal.kernel.util.NullWrapper;
30  import com.liferay.portal.security.auth.HttpPrincipal;
31  import com.liferay.portal.service.ClassNameServiceUtil;
32  
33  /**
34   * <a href="ClassNameServiceHttp.java.html"><b><i>View Source</i></b></a>
35   *
36   * <p>
37   * ServiceBuilder generated this class. Modifications in this class will be
38   * overwritten the next time is generated.
39   * </p>
40   *
41   * <p>
42   * This class provides a HTTP utility for the
43   * {@link com.liferay.portal.service.ClassNameServiceUtil} service utility. The
44   * static methods of this class calls the same methods of the service utility.
45   * However, the signatures are different because it requires an additional
46   * {@link com.liferay.portal.security.auth.HttpPrincipal} 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 <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
57   * 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   * @see       ClassNameServiceSoap
66   * @see       com.liferay.portal.security.auth.HttpPrincipal
67   * @see       com.liferay.portal.service.ClassNameServiceUtil
68   * @generated
69   */
70  public class ClassNameServiceHttp {
71      public static com.liferay.portal.model.ClassName getClassName(
72          HttpPrincipal httpPrincipal, long classNameId)
73          throws com.liferay.portal.PortalException,
74              com.liferay.portal.SystemException {
75          try {
76              Object paramObj0 = new LongWrapper(classNameId);
77  
78              MethodWrapper methodWrapper = new MethodWrapper(ClassNameServiceUtil.class.getName(),
79                      "getClassName", new Object[] { paramObj0 });
80  
81              Object returnObj = null;
82  
83              try {
84                  returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
85              }
86              catch (Exception e) {
87                  if (e instanceof com.liferay.portal.PortalException) {
88                      throw (com.liferay.portal.PortalException)e;
89                  }
90  
91                  if (e instanceof com.liferay.portal.SystemException) {
92                      throw (com.liferay.portal.SystemException)e;
93                  }
94  
95                  throw new com.liferay.portal.SystemException(e);
96              }
97  
98              return (com.liferay.portal.model.ClassName)returnObj;
99          }
100         catch (com.liferay.portal.SystemException se) {
101             _log.error(se, se);
102 
103             throw se;
104         }
105     }
106 
107     public static com.liferay.portal.model.ClassName getClassName(
108         HttpPrincipal httpPrincipal, java.lang.String value)
109         throws com.liferay.portal.SystemException {
110         try {
111             Object paramObj0 = value;
112 
113             if (value == null) {
114                 paramObj0 = new NullWrapper("java.lang.String");
115             }
116 
117             MethodWrapper methodWrapper = new MethodWrapper(ClassNameServiceUtil.class.getName(),
118                     "getClassName", new Object[] { paramObj0 });
119 
120             Object returnObj = null;
121 
122             try {
123                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
124             }
125             catch (Exception e) {
126                 if (e instanceof com.liferay.portal.SystemException) {
127                     throw (com.liferay.portal.SystemException)e;
128                 }
129 
130                 throw new com.liferay.portal.SystemException(e);
131             }
132 
133             return (com.liferay.portal.model.ClassName)returnObj;
134         }
135         catch (com.liferay.portal.SystemException se) {
136             _log.error(se, se);
137 
138             throw se;
139         }
140     }
141 
142     public static long getClassNameId(HttpPrincipal httpPrincipal,
143         java.lang.Class<?> classObj) throws com.liferay.portal.SystemException {
144         try {
145             Object paramObj0 = classObj;
146 
147             if (classObj == null) {
148                 paramObj0 = new NullWrapper("java.lang.Class");
149             }
150 
151             MethodWrapper methodWrapper = new MethodWrapper(ClassNameServiceUtil.class.getName(),
152                     "getClassNameId", new Object[] { paramObj0 });
153 
154             Object returnObj = null;
155 
156             try {
157                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
158             }
159             catch (Exception e) {
160                 throw new com.liferay.portal.SystemException(e);
161             }
162 
163             return ((Long)returnObj).longValue();
164         }
165         catch (com.liferay.portal.SystemException se) {
166             _log.error(se, se);
167 
168             throw se;
169         }
170     }
171 
172     public static long getClassNameId(HttpPrincipal httpPrincipal,
173         java.lang.String value) throws com.liferay.portal.SystemException {
174         try {
175             Object paramObj0 = value;
176 
177             if (value == null) {
178                 paramObj0 = new NullWrapper("java.lang.String");
179             }
180 
181             MethodWrapper methodWrapper = new MethodWrapper(ClassNameServiceUtil.class.getName(),
182                     "getClassNameId", new Object[] { paramObj0 });
183 
184             Object returnObj = null;
185 
186             try {
187                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
188             }
189             catch (Exception e) {
190                 throw new com.liferay.portal.SystemException(e);
191             }
192 
193             return ((Long)returnObj).longValue();
194         }
195         catch (com.liferay.portal.SystemException se) {
196             _log.error(se, se);
197 
198             throw se;
199         }
200     }
201 
202     private static Log _log = LogFactoryUtil.getLog(ClassNameServiceHttp.class);
203 }