com.greenpepper.confluence.tools.GetSpec Maven / Gradle / Ivy
package com.greenpepper.confluence.tools;
import static com.greenpepper.util.URIUtil.decoded;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Vector;
import org.apache.xmlrpc.XmlRpcClient;
import org.apache.xmlrpc.XmlRpcClientLite;
import org.apache.xmlrpc.XmlRpcException;
import com.greenpepper.GreenPepperCore;
import com.greenpepper.util.cli.ArgumentMissingException;
import com.greenpepper.util.cli.CommandLine;
import com.greenpepper.util.cli.ParseException;
/**
* GetSpec class.
*
* @author oaouattara
* @version $Id: $Id
*/
public class GetSpec {
/** Constant URI="http://localhost:8090"
*/
public static final String URI = "http://localhost:8090";
/** Constant RPC_PATH="/rpc/xmlrpc"
*/
public static final String RPC_PATH = "/rpc/xmlrpc";
private static final Vector EMPTY = new Vector(0);
private static final Object USER_NAME = "admin";
private static final Object PASSWORD = "admin";
private CommandLine cli;
/**
* Constructor for GetSpec.
*/
public GetSpec() {
this.cli = new CommandLine();
}
/**
* run.
*
* @param args a {@link java.lang.String} object.
* @throws java.lang.Exception if any.
*/
public void run(String... args) throws Exception {
defineCommandLine();
if (!parseCommandLine( args )) return;
getSpecification();
}
private boolean parseCommandLine(String[] args) throws ParseException {
cli.parse( args );
if (optionSpecified( "help" )) return displayUsage();
if (optionSpecified( "version" )) return displayVersion();
if (confluenceUrl() == null) throw new ArgumentMissingException( "confluence_url" );
return true;
}
private String confluenceUrl()
{
return cli.getArgument( 0 ) != null ? decoded( cli.getArgument( 0 ) ) : URI;
}
private boolean optionSpecified(String name)
{
return cli.hasOptionValue( name );
}
private void getSpecification() {
try {
String xmlRpcUrl = getXmlRpcURL();
System.out.println("GettingSpecification : " + xmlRpcUrl);
XmlRpcClient rpcClient = new XmlRpcClientLite(xmlRpcUrl);
Vector
© 2015 - 2025 Weber Informatics LLC | Privacy Policy