| ClassNameServiceHttp.java |
1 /**
2 * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions 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 * <code>com.liferay.portal.service.ClassNameServiceUtil</code> service
44 * utility. The static methods of this class calls the same methods of the
45 * service utility. However, the signatures are different because it requires an
46 * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
47 * parameter.
48 * </p>
49 *
50 * <p>
51 * The benefits of using the HTTP utility is that it is fast and allows for
52 * tunneling without the cost of serializing to text. The drawback is that it
53 * only works with Java.
54 * </p>
55 *
56 * <p>
57 * Set the property <code>tunnel.servlet.hosts.allowed</code> in
58 * portal.properties to configure security.
59 * </p>
60 *
61 * <p>
62 * The HTTP utility is only generated for remote services.
63 * </p>
64 *
65 * @author Brian Wing Shun Chan
66 *
67 * @see com.liferay.portal.security.auth.HttpPrincipal
68 * @see com.liferay.portal.service.ClassNameServiceUtil
69 * @see com.liferay.portal.service.http.ClassNameServiceSoap
70 *
71 */
72 public class ClassNameServiceHttp {
73 public static com.liferay.portal.model.ClassName getClassName(
74 HttpPrincipal httpPrincipal, long classNameId)
75 throws com.liferay.portal.PortalException,
76 com.liferay.portal.SystemException {
77 try {
78 Object paramObj0 = new LongWrapper(classNameId);
79
80 MethodWrapper methodWrapper = new MethodWrapper(ClassNameServiceUtil.class.getName(),
81 "getClassName", new Object[] { paramObj0 });
82
83 Object returnObj = null;
84
85 try {
86 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
87 }
88 catch (Exception e) {
89 if (e instanceof com.liferay.portal.PortalException) {
90 throw (com.liferay.portal.PortalException)e;
91 }
92
93 if (e instanceof com.liferay.portal.SystemException) {
94 throw (com.liferay.portal.SystemException)e;
95 }
96
97 throw new com.liferay.portal.SystemException(e);
98 }
99
100 return (com.liferay.portal.model.ClassName)returnObj;
101 }
102 catch (com.liferay.portal.SystemException se) {
103 _log.error(se, se);
104
105 throw se;
106 }
107 }
108
109 public static com.liferay.portal.model.ClassName getClassName(
110 HttpPrincipal httpPrincipal, java.lang.String value)
111 throws com.liferay.portal.SystemException {
112 try {
113 Object paramObj0 = value;
114
115 if (value == null) {
116 paramObj0 = new NullWrapper("java.lang.String");
117 }
118
119 MethodWrapper methodWrapper = new MethodWrapper(ClassNameServiceUtil.class.getName(),
120 "getClassName", new Object[] { paramObj0 });
121
122 Object returnObj = null;
123
124 try {
125 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
126 }
127 catch (Exception e) {
128 if (e instanceof com.liferay.portal.SystemException) {
129 throw (com.liferay.portal.SystemException)e;
130 }
131
132 throw new com.liferay.portal.SystemException(e);
133 }
134
135 return (com.liferay.portal.model.ClassName)returnObj;
136 }
137 catch (com.liferay.portal.SystemException se) {
138 _log.error(se, se);
139
140 throw se;
141 }
142 }
143
144 public static long getClassNameId(HttpPrincipal httpPrincipal,
145 java.lang.Class<?> classObj) throws com.liferay.portal.SystemException {
146 try {
147 Object paramObj0 = classObj;
148
149 if (classObj == null) {
150 paramObj0 = new NullWrapper("java.lang.Class");
151 }
152
153 MethodWrapper methodWrapper = new MethodWrapper(ClassNameServiceUtil.class.getName(),
154 "getClassNameId", new Object[] { paramObj0 });
155
156 Object returnObj = null;
157
158 try {
159 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
160 }
161 catch (Exception e) {
162 throw new com.liferay.portal.SystemException(e);
163 }
164
165 return ((Long)returnObj).longValue();
166 }
167 catch (com.liferay.portal.SystemException se) {
168 _log.error(se, se);
169
170 throw se;
171 }
172 }
173
174 public static long getClassNameId(HttpPrincipal httpPrincipal,
175 java.lang.String value) throws com.liferay.portal.SystemException {
176 try {
177 Object paramObj0 = value;
178
179 if (value == null) {
180 paramObj0 = new NullWrapper("java.lang.String");
181 }
182
183 MethodWrapper methodWrapper = new MethodWrapper(ClassNameServiceUtil.class.getName(),
184 "getClassNameId", new Object[] { paramObj0 });
185
186 Object returnObj = null;
187
188 try {
189 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
190 }
191 catch (Exception e) {
192 throw new com.liferay.portal.SystemException(e);
193 }
194
195 return ((Long)returnObj).longValue();
196 }
197 catch (com.liferay.portal.SystemException se) {
198 _log.error(se, se);
199
200 throw se;
201 }
202 }
203
204 private static Log _log = LogFactoryUtil.getLog(ClassNameServiceHttp.class);
205 }