private static String performSqlQuery(String query, String sortBy, String outputFormat, String delimiter, String filemgrUrl)
throws MalformedURLException, CatalogException, ConnectionException, QueryFormulationException {
ComplexQuery complexQuery = SqlParser.parseSqlQuery(query);
complexQuery.setSortByMetKey(sortBy);
complexQuery.setToStringResultFormat(outputFormat);
List<QueryResult> results = new XmlRpcFileManagerClient(new URL(filemgrUrl)).complexQuery(complexQuery);
StringBuffer returnString = new StringBuffer("");
for (QueryResult qr : results)
returnString.append(qr.toString() + delimiter);
return returnString.substring(0, returnString.length() - delimiter.length());
}