001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.xmlrpc;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.kernel.xmlrpc.Success;
019    import com.liferay.portal.kernel.xmlrpc.XmlRpcException;
020    
021    /**
022     * @author Alexander Chow
023     * @author Brian Wing Shun Chan
024     */
025    public class SuccessImpl implements Success {
026    
027            public SuccessImpl(String description) {
028                    _description = description;
029            }
030    
031            public String getDescription() {
032                    return _description;
033            }
034    
035            public String toString() {
036                    return "XML-RPC success " + _description;
037            }
038    
039            public String toXml() throws XmlRpcException {
040                    StringBundler sb = new StringBundler(8);
041    
042                    sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
043    
044                    sb.append("<methodResponse>");
045                    sb.append("<params>");
046                    sb.append("<param>");
047                    sb.append(XmlRpcParser.wrapValue(_description));
048                    sb.append("</param>");
049                    sb.append("</params>");
050                    sb.append("</methodResponse>");
051    
052                    return sb.toString();
053            }
054    
055            private String _description;
056    
057    }