001    /**
002     * Copyright (c) 2000-2012 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.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            @Override
036            public String toString() {
037                    return "XML-RPC success " + _description;
038            }
039    
040            public String toXml() throws XmlRpcException {
041                    StringBundler sb = new StringBundler(8);
042    
043                    sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
044    
045                    sb.append("<methodResponse>");
046                    sb.append("<params>");
047                    sb.append("<param>");
048                    sb.append(XmlRpcParser.wrapValue(_description));
049                    sb.append("</param>");
050                    sb.append("</params>");
051                    sb.append("</methodResponse>");
052    
053                    return sb.toString();
054            }
055    
056            private String _description;
057    
058    }