com.liferay.portal.xmlrpc.XmlRpcParser Maven / Gradle / Ivy
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.xmlrpc;
import com.liferay.petra.string.CharPool;
import com.liferay.petra.string.StringBundler;
import com.liferay.petra.string.StringPool;
import com.liferay.portal.kernel.io.unsync.UnsyncStringReader;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.Tuple;
import com.liferay.portal.kernel.xmlrpc.Response;
import com.liferay.portal.kernel.xmlrpc.XmlRpcException;
import com.liferay.portal.kernel.xmlrpc.XmlRpcUtil;
import com.liferay.portal.xml.StAXReaderUtil;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamReader;
/**
* @author Alexander Chow
* @author Brian Wing Shun Chan
*/
public class XmlRpcParser {
public static String buildMethod(String methodName, Object[] arguments)
throws XmlRpcException {
StringBundler sb = new StringBundler((arguments.length * 3) + 8);
sb.append("");
sb.append("");
sb.append("");
sb.append(methodName);
sb.append(" ");
sb.append("");
for (Object argument : arguments) {
sb.append("");
sb.append(wrapValue(argument));
sb.append("");
}
sb.append(" ");
sb.append(" ");
return sb.toString();
}
public static Tuple parseMethod(String xml) throws IOException {
XMLStreamReader xmlStreamReader = null;
try {
XMLInputFactory xmlInputFactory =
StAXReaderUtil.getXMLInputFactory();
xmlStreamReader = xmlInputFactory.createXMLStreamReader(
new UnsyncStringReader(xml));
xmlStreamReader.nextTag();
xmlStreamReader.nextTag();
xmlStreamReader.next();
String methodName = xmlStreamReader.getText();
List © 2015 - 2025 Weber Informatics LLC | Privacy Policy