com.sonyericsson.hudson.plugins.gerrit.gerritevents
Class GerritQueryHandler

java.lang.Object
  extended by com.sonyericsson.hudson.plugins.gerrit.gerritevents.GerritQueryHandler

public class GerritQueryHandler
extends Object

This class helps you call gerrit query to search for patch-sets.

Author:
Robert Sandell <robert.sandell@sonyericsson.com>

Field Summary
static String QUERY_COMMAND
          The base of the query ssh command to send to Gerrit.
 
Constructor Summary
GerritQueryHandler(GerritConnectionConfig config)
          Creates a GerritQueryHandler with the specified config.
GerritQueryHandler(String gerritHostName, int gerritSshPort, Authentication authentication)
          Creates a GerritQueryHandler with the specified values.
 
Method Summary
 List<net.sf.json.JSONObject> queryFiles(String queryString)
          Runs the query and returns the result as a list of Java JSONObjects.
 List<net.sf.json.JSONObject> queryJava(String queryString)
          Runs the query and returns the result as a list of Java JSONObjects.
 List<net.sf.json.JSONObject> queryJava(String queryString, boolean getPatchSets, boolean getCurrentPatchSet, boolean getFiles)
          Runs the query and returns the result as a list of Java JSONObjects.
 List<String> queryJson(String queryString)
          Runs the query and returns the result as a list of JSON formatted strings.
 List<String> queryJson(String queryString, boolean getPatchSets, boolean getCurrentPatchSet, boolean getFiles)
          Runs the query and returns the result as a list of JSON formatted strings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QUERY_COMMAND

public static final String QUERY_COMMAND
The base of the query ssh command to send to Gerrit.

See Also:
Constant Field Values
Constructor Detail

GerritQueryHandler

public GerritQueryHandler(String gerritHostName,
                          int gerritSshPort,
                          Authentication authentication)
Creates a GerritQueryHandler with the specified values.

Parameters:
gerritHostName - the hostName
gerritSshPort - the ssh port that the gerrit server listens to.
authentication - the authentication credentials.

GerritQueryHandler

public GerritQueryHandler(GerritConnectionConfig config)
Creates a GerritQueryHandler with the specified config.

Parameters:
config - the config.
Method Detail

queryJava

public List<net.sf.json.JSONObject> queryJava(String queryString)
                                       throws SshException,
                                              IOException,
                                              GerritQueryException
Runs the query and returns the result as a list of Java JSONObjects. It is the equivalent of calling queryJava(queryString, true, true).

Parameters:
queryString - the query.
Returns:
the query result as a List of JSONObjects.
Throws:
GerritQueryException - if Gerrit reports an error with the query.
SshException - if there is an error in the SSH Connection.
IOException - for some other IO problem.

queryJava

public List<net.sf.json.JSONObject> queryJava(String queryString,
                                              boolean getPatchSets,
                                              boolean getCurrentPatchSet,
                                              boolean getFiles)
                                       throws SshException,
                                              IOException,
                                              GerritQueryException
Runs the query and returns the result as a list of Java JSONObjects.

Parameters:
queryString - the query.
getPatchSets - getPatchSets if all patch-sets of the projects found should be included in the result. Meaning if --patch-sets should be appended to the command call.
getCurrentPatchSet - if the current patch-set for the projects found should be included in the result. Meaning if --current-patch-set should be appended to the command call.
Returns:
the query result as a List of JSONObjects.
Throws:
GerritQueryException - if Gerrit reports an error with the query.
SshException - if there is an error in the SSH Connection.
IOException - for some other IO problem.

queryFiles

public List<net.sf.json.JSONObject> queryFiles(String queryString)
                                        throws SshException,
                                               IOException,
                                               GerritQueryException
Runs the query and returns the result as a list of Java JSONObjects.

Parameters:
queryString - the query.
Returns:
the query result as a List of JSONObjects.
Throws:
GerritQueryException - if Gerrit reports an error with the query.
SshException - if there is an error in the SSH Connection.
IOException - for some other IO problem.

queryJson

public List<String> queryJson(String queryString)
                       throws SshException,
                              IOException
Runs the query and returns the result as a list of JSON formatted strings. This is the equivalent of calling queryJava(queryString, true, true).

Parameters:
queryString - the query.
Returns:
a List of JSON formatted strings.
Throws:
SshException - if there is an error in the SSH Connection.
IOException - for some other IO problem.

queryJson

public List<String> queryJson(String queryString,
                              boolean getPatchSets,
                              boolean getCurrentPatchSet,
                              boolean getFiles)
                       throws SshException,
                              IOException
Runs the query and returns the result as a list of JSON formatted strings.

Parameters:
queryString - the query.
getPatchSets - if all patch-sets of the projects found should be included in the result. Meaning if --patch-sets should be appended to the command call.
getCurrentPatchSet - if the current patch-set for the projects found should be included in the result. Meaning if --current-patch-set should be appended to the command call.
getFiles - if the files of the patch sets should be included in the result. Meaning if --files should be appended to the command call.
Returns:
a List of JSON formatted strings.
Throws:
SshException - if there is an error in the SSH Connection.
IOException - for some other IO problem.


Copyright © 2004-2012 Hudson. All Rights Reserved.