de.smartics.ci.comm.hudson.command
Class AbstractHudsonApiJob<T extends Command<T>>

Package class diagram package AbstractHudsonApiJob
java.lang.Object
  extended by de.smartics.ci.comm.command.AbstractCommand<T>
      extended by de.smartics.ci.comm.command.AbstractJobCommand<T>
          extended by de.smartics.ci.comm.command.AbstractGenericJobCommand<T>
              extended by de.smartics.ci.comm.hudson.command.AbstractHudsonApiJob<T>
Type Parameters:
T - the concrete type of the command.
All Implemented Interfaces:
Command<T>
Direct Known Subclasses:
HudsonCheckStatusJobCommand, HudsonGenericJobCommand

public abstract class AbstractHudsonApiJob<T extends Command<T>>
     
     
extends AbstractGenericJobCommand<T>

This abstract class contains the functionality to handle jobs calling an api. It handles the replacement of variables in the api call and handles methods to handle the response.


Field Summary
protected  CommandResult<T> commandResult
          The result of this command.
protected  Properties properties
          Key value pairs / properties used to replace variables (the keys) in the xml query string with the values.
protected  String xmlQueryString
          The xmlQuery string to execute against the xml api.
 
Fields inherited from class de.smartics.ci.comm.command.AbstractJobCommand
jobName
 
Fields inherited from class de.smartics.ci.comm.command.AbstractCommand
ERROR_CATEGORY_DESTINGUISHER, logLevel
 
Constructor Summary
AbstractHudsonApiJob(String jobName)
          Default constructor.
 
Method Summary
protected  void checkResponseString(String response)
          Check the response.
protected  void createResult(int statusCode, PostMethod method)
          Create the command result and provide the result object in this command object.
 CommandResult<T> getResult()
          Returns the result of the execution of this command.
protected  void logResponse(String response)
          Log the response of this command.
protected  String resolve(String queryString)
          Resolve the query string, resolve all variables in the query string with the given values.
 void setKeyValuePairs(Properties properties)
          Sets the value for keyValuePairs.
 void setXmlQueryString(String xmlQueryString)
          Sets the xmlQuery string to execute against the xml api.
 
Methods inherited from class de.smartics.ci.comm.command.AbstractGenericJobCommand
execute
 
Methods inherited from class de.smartics.ci.comm.command.AbstractJobCommand
buildCiJobApiUrl, setJobName
 
Methods inherited from class de.smartics.ci.comm.command.AbstractCommand
addRequestHeaders, buildQueryString, checkParameterNotBlank, checkResult, checkResultRegardingRedirect, fetchDelimiter, setLogLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xmlQueryString

protected String xmlQueryString
The xmlQuery string to execute against the xml api.


properties

protected Properties properties
Key value pairs / properties used to replace variables (the keys) in the xml query string with the values.


commandResult

protected CommandResult<T extends Command<T>> commandResult
The result of this command.

Constructor Detail

AbstractHudsonApiJob

public AbstractHudsonApiJob(String jobName)
Default constructor.

Parameters:
jobName - the name of the job.
Method Detail

setXmlQueryString

public final void setXmlQueryString(String xmlQueryString)
Sets the xmlQuery string to execute against the xml api.

Parameters:
xmlQueryString - the xmlQuery string to execute against the xml api.

setKeyValuePairs

public final void setKeyValuePairs(Properties properties)
Sets the value for keyValuePairs.

Key value pairs used to replace variables (the keys) in the xml query string with the values.

Parameters:
properties - the value for keyValuePairs.

createResult

protected final void createResult(int statusCode,
                                  PostMethod method)
                           throws IOException,
                                  CommandException
Create the command result and provide the result object in this command object.

Parameters:
statusCode - the status code of the response.
method - the method used to execute the command.
Throws:
IOException - when the communication fails and the response could not be retrieved.
CommandException - when command fails.

checkResponseString

protected void checkResponseString(String response)
                            throws CommandException
Check the response.

Parameters:
response - the response.
Throws:
CommandException - when check fails.

logResponse

protected final void logResponse(String response)
                          throws IOException
Log the response of this command.

Parameters:
response - the response as String.
Throws:
IOException - when the response can not be retrieved from the method.

resolve

protected final String resolve(String queryString)
Resolve the query string, resolve all variables in the query string with the given values.

Parameters:
queryString - the query string containing variables.
Returns:
a query string with replaced variables.

getResult

public final CommandResult<T> getResult()
Description copied from class: AbstractGenericJobCommand
Returns the result of the execution of this command. When this command has not been called until now, null is returned.

Specified by:
getResult in class AbstractGenericJobCommand<T extends Command<T>>
Returns:
the result or null.


Copyright © 2012 Kronseder & Reiner GmbH - smartics. All Rights Reserved.