001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.service.http;
022:
023: import com.liferay.portal.kernel.log.Log;
024: import com.liferay.portal.kernel.log.LogFactoryUtil;
025: import com.liferay.portal.kernel.util.LongWrapper;
026: import com.liferay.portal.kernel.util.MethodWrapper;
027: import com.liferay.portal.kernel.util.NullWrapper;
028: import com.liferay.portal.security.auth.HttpPrincipal;
029: import com.liferay.portal.service.ClassNameServiceUtil;
030:
031: /**
032: * <a href="ClassNameServiceHttp.java.html"><b><i>View Source</i></b></a>
033: *
034: * <p>
035: * ServiceBuilder generated this class. Modifications in this class will be
036: * overwritten the next time is generated.
037: * </p>
038: *
039: * <p>
040: * This class provides a HTTP utility for the
041: * <code>com.liferay.portal.service.ClassNameServiceUtil</code> service
042: * utility. The static methods of this class calls the same methods of the
043: * service utility. However, the signatures are different because it requires an
044: * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
045: * parameter.
046: * </p>
047: *
048: * <p>
049: * The benefits of using the HTTP utility is that it is fast and allows for
050: * tunneling without the cost of serializing to text. The drawback is that it
051: * only works with Java.
052: * </p>
053: *
054: * <p>
055: * Set the property <code>tunnel.servlet.hosts.allowed</code> in
056: * portal.properties to configure security.
057: * </p>
058: *
059: * <p>
060: * The HTTP utility is only generated for remote services.
061: * </p>
062: *
063: * @author Brian Wing Shun Chan
064: *
065: * @see com.liferay.portal.security.auth.HttpPrincipal
066: * @see com.liferay.portal.service.ClassNameServiceUtil
067: * @see com.liferay.portal.service.http.ClassNameServiceSoap
068: *
069: */
070: public class ClassNameServiceHttp {
071: public static com.liferay.portal.model.ClassName getClassName(
072: HttpPrincipal httpPrincipal, long classNameId)
073: throws com.liferay.portal.SystemException,
074: com.liferay.portal.PortalException {
075: try {
076: Object paramObj0 = new LongWrapper(classNameId);
077:
078: MethodWrapper methodWrapper = new MethodWrapper(
079: ClassNameServiceUtil.class.getName(),
080: "getClassName", new Object[] { paramObj0 });
081:
082: Object returnObj = null;
083:
084: try {
085: returnObj = TunnelUtil.invoke(httpPrincipal,
086: methodWrapper);
087: } catch (Exception e) {
088: if (e instanceof com.liferay.portal.SystemException) {
089: throw (com.liferay.portal.SystemException) e;
090: }
091:
092: if (e instanceof com.liferay.portal.PortalException) {
093: throw (com.liferay.portal.PortalException) e;
094: }
095:
096: throw new com.liferay.portal.SystemException(e);
097: }
098:
099: return (com.liferay.portal.model.ClassName) returnObj;
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: com.liferay.portal.PortalException {
111: try {
112: Object paramObj0 = value;
113:
114: if (value == null) {
115: paramObj0 = new NullWrapper("java.lang.String");
116: }
117:
118: MethodWrapper methodWrapper = new MethodWrapper(
119: ClassNameServiceUtil.class.getName(),
120: "getClassName", new Object[] { paramObj0 });
121:
122: Object returnObj = null;
123:
124: try {
125: returnObj = TunnelUtil.invoke(httpPrincipal,
126: methodWrapper);
127: } catch (Exception e) {
128: if (e instanceof com.liferay.portal.SystemException) {
129: throw (com.liferay.portal.SystemException) e;
130: }
131:
132: if (e instanceof com.liferay.portal.PortalException) {
133: throw (com.liferay.portal.PortalException) e;
134: }
135:
136: throw new com.liferay.portal.SystemException(e);
137: }
138:
139: return (com.liferay.portal.model.ClassName) returnObj;
140: } catch (com.liferay.portal.SystemException se) {
141: _log.error(se, se);
142:
143: throw se;
144: }
145: }
146:
147: private static Log _log = LogFactoryUtil
148: .getLog(ClassNameServiceHttp.class);
149: }
|