1   /**
2    * Copyright (c) 2000-2010 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   *
12   * 
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.PortalException,
66              com.liferay.portal.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.PortalException) {
80                      throw (com.liferay.portal.PortalException)e;
81                  }
82  
83                  if (e instanceof com.liferay.portal.SystemException) {
84                      throw (com.liferay.portal.SystemException)e;
85                  }
86  
87                  throw new com.liferay.portal.SystemException(e);
88              }
89  
90              return (com.liferay.portal.model.ClassName)returnObj;
91          }
92          catch (com.liferay.portal.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.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.SystemException) {
119                     throw (com.liferay.portal.SystemException)e;
120                 }
121 
122                 throw new com.liferay.portal.SystemException(e);
123             }
124 
125             return (com.liferay.portal.model.ClassName)returnObj;
126         }
127         catch (com.liferay.portal.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) throws com.liferay.portal.SystemException {
136         try {
137             Object paramObj0 = classObj;
138 
139             if (classObj == null) {
140                 paramObj0 = new NullWrapper("java.lang.Class");
141             }
142 
143             MethodWrapper methodWrapper = new MethodWrapper(ClassNameServiceUtil.class.getName(),
144                     "getClassNameId", new Object[] { paramObj0 });
145 
146             Object returnObj = null;
147 
148             try {
149                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
150             }
151             catch (Exception e) {
152                 throw new com.liferay.portal.SystemException(e);
153             }
154 
155             return ((Long)returnObj).longValue();
156         }
157         catch (com.liferay.portal.SystemException se) {
158             _log.error(se, se);
159 
160             throw se;
161         }
162     }
163 
164     public static long getClassNameId(HttpPrincipal httpPrincipal,
165         java.lang.String value) throws com.liferay.portal.SystemException {
166         try {
167             Object paramObj0 = value;
168 
169             if (value == null) {
170                 paramObj0 = new NullWrapper("java.lang.String");
171             }
172 
173             MethodWrapper methodWrapper = new MethodWrapper(ClassNameServiceUtil.class.getName(),
174                     "getClassNameId", new Object[] { paramObj0 });
175 
176             Object returnObj = null;
177 
178             try {
179                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
180             }
181             catch (Exception e) {
182                 throw new com.liferay.portal.SystemException(e);
183             }
184 
185             return ((Long)returnObj).longValue();
186         }
187         catch (com.liferay.portal.SystemException se) {
188             _log.error(se, se);
189 
190             throw se;
191         }
192     }
193 
194     private static Log _log = LogFactoryUtil.getLog(ClassNameServiceHttp.class);
195 }