001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.http;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.kernel.util.LongWrapper;
020    import com.liferay.portal.kernel.util.MethodWrapper;
021    import com.liferay.portal.kernel.util.NullWrapper;
022    import com.liferay.portal.security.auth.HttpPrincipal;
023    import com.liferay.portal.service.ClassNameServiceUtil;
024    
025    /**
026     * <p>
027     * This class provides a HTTP utility for the
028     * {@link com.liferay.portal.service.ClassNameServiceUtil} service utility. The
029     * static methods of this class calls the same methods of the service utility.
030     * However, the signatures are different because it requires an additional
031     * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
032     * </p>
033     *
034     * <p>
035     * The benefits of using the HTTP utility is that it is fast and allows for
036     * tunneling without the cost of serializing to text. The drawback is that it
037     * only works with Java.
038     * </p>
039     *
040     * <p>
041     * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
042     * configure security.
043     * </p>
044     *
045     * <p>
046     * The HTTP utility is only generated for remote services.
047     * </p>
048     *
049     * @author    Brian Wing Shun Chan
050     * @see       ClassNameServiceSoap
051     * @see       com.liferay.portal.security.auth.HttpPrincipal
052     * @see       com.liferay.portal.service.ClassNameServiceUtil
053     * @generated
054     */
055    public class ClassNameServiceHttp {
056            public static com.liferay.portal.model.ClassName getClassName(
057                    HttpPrincipal httpPrincipal, long classNameId)
058                    throws com.liferay.portal.kernel.exception.PortalException,
059                            com.liferay.portal.kernel.exception.SystemException {
060                    try {
061                            Object paramObj0 = new LongWrapper(classNameId);
062    
063                            MethodWrapper methodWrapper = new MethodWrapper(ClassNameServiceUtil.class.getName(),
064                                            "getClassName", new Object[] { paramObj0 });
065    
066                            Object returnObj = null;
067    
068                            try {
069                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
070                            }
071                            catch (Exception e) {
072                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
073                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
074                                    }
075    
076                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
077                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
078                                    }
079    
080                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
081                            }
082    
083                            return (com.liferay.portal.model.ClassName)returnObj;
084                    }
085                    catch (com.liferay.portal.kernel.exception.SystemException se) {
086                            _log.error(se, se);
087    
088                            throw se;
089                    }
090            }
091    
092            public static com.liferay.portal.model.ClassName getClassName(
093                    HttpPrincipal httpPrincipal, java.lang.String value)
094                    throws com.liferay.portal.kernel.exception.SystemException {
095                    try {
096                            Object paramObj0 = value;
097    
098                            if (value == null) {
099                                    paramObj0 = new NullWrapper("java.lang.String");
100                            }
101    
102                            MethodWrapper methodWrapper = new MethodWrapper(ClassNameServiceUtil.class.getName(),
103                                            "getClassName", new Object[] { paramObj0 });
104    
105                            Object returnObj = null;
106    
107                            try {
108                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
109                            }
110                            catch (Exception e) {
111                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
112                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
113                                    }
114    
115                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
116                            }
117    
118                            return (com.liferay.portal.model.ClassName)returnObj;
119                    }
120                    catch (com.liferay.portal.kernel.exception.SystemException se) {
121                            _log.error(se, se);
122    
123                            throw se;
124                    }
125            }
126    
127            public static long getClassNameId(HttpPrincipal httpPrincipal,
128                    java.lang.Class<?> classObj)
129                    throws com.liferay.portal.kernel.exception.SystemException {
130                    try {
131                            Object paramObj0 = classObj;
132    
133                            if (classObj == null) {
134                                    paramObj0 = new NullWrapper("java.lang.Class");
135                            }
136    
137                            MethodWrapper methodWrapper = new MethodWrapper(ClassNameServiceUtil.class.getName(),
138                                            "getClassNameId", new Object[] { paramObj0 });
139    
140                            Object returnObj = null;
141    
142                            try {
143                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
144                            }
145                            catch (Exception e) {
146                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
147                            }
148    
149                            return ((Long)returnObj).longValue();
150                    }
151                    catch (com.liferay.portal.kernel.exception.SystemException se) {
152                            _log.error(se, se);
153    
154                            throw se;
155                    }
156            }
157    
158            public static long getClassNameId(HttpPrincipal httpPrincipal,
159                    java.lang.String value)
160                    throws com.liferay.portal.kernel.exception.SystemException {
161                    try {
162                            Object paramObj0 = value;
163    
164                            if (value == null) {
165                                    paramObj0 = new NullWrapper("java.lang.String");
166                            }
167    
168                            MethodWrapper methodWrapper = new MethodWrapper(ClassNameServiceUtil.class.getName(),
169                                            "getClassNameId", new Object[] { paramObj0 });
170    
171                            Object returnObj = null;
172    
173                            try {
174                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
175                            }
176                            catch (Exception e) {
177                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
178                            }
179    
180                            return ((Long)returnObj).longValue();
181                    }
182                    catch (com.liferay.portal.kernel.exception.SystemException se) {
183                            _log.error(se, se);
184    
185                            throw se;
186                    }
187            }
188    
189            private static Log _log = LogFactoryUtil.getLog(ClassNameServiceHttp.class);
190    }