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

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

public abstract class AbstractCommand<T extends Command<T>>
     
     
extends Object
implements Command<T>

Abstract command that combines all every command needs.


Field Summary
protected static int ERROR_CATEGORY_DESTINGUISHER
          Using the modulo operator this constant is used to calculate the main status code of a http response e.g 202 % 100 = 2.
protected  LogLevel logLevel
          The log level for this command.
 
Constructor Summary
AbstractCommand()
           
 
Method Summary
protected  void addRequestHeaders(HttpMethodBase method)
          Add request headers to the method.
protected  String buildQueryString(Map<String,String> parameter)
          Build the query string using the given parameter.
protected  void checkParameterNotBlank(String... params)
          Checks if the parameters are blank.
protected  void checkResult(int statusCode)
          Checks the result statusCode of a request.
protected  void checkResultRegardingRedirect(int statusCode)
          Checks the result statusCode of a request.
protected  String fetchDelimiter(boolean isFirstParameter)
          Fetch the delimiter between two parameters of a query string for a get command.
 void setLogLevel(LogLevel logLevel)
          Sets the log level for this command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.smartics.ci.comm.command.Command
execute
 

Field Detail

ERROR_CATEGORY_DESTINGUISHER

protected static final int ERROR_CATEGORY_DESTINGUISHER
Using the modulo operator this constant is used to calculate the main status code of a http response e.g 202 % 100 = 2.

Constant Field Value:
100

logLevel

protected LogLevel logLevel
The log level for this command.

Constructor Detail

AbstractCommand

public AbstractCommand()
Method Detail

setLogLevel

public final void setLogLevel(LogLevel logLevel)
Sets the log level for this command.

Parameters:
logLevel - the log level for this command.

checkParameterNotBlank

protected void checkParameterNotBlank(String... params)
                               throws CommandException
Checks if the parameters are blank.

Parameters:
params - the String parameters to check.
Throws:
CommandException - when at leas one parameter is blan.

checkResult

protected void checkResult(int statusCode)
                    throws InvalidRequestException
Checks the result statusCode of a request.

Parameters:
statusCode - the status code returned from the ci system.
Throws:
InvalidRequestException - when the status code indicates an error.

checkResultRegardingRedirect

protected void checkResultRegardingRedirect(int statusCode)
                                     throws InvalidRequestException
Checks the result statusCode of a request. Redirects are not handled as an error.

Parameters:
statusCode - the status code returned from the ci system.
Throws:
InvalidRequestException - when the status code indicates an error.

buildQueryString

protected String buildQueryString(Map<String,String> parameter)
Build the query string using the given parameter.

Parameters:
parameter - the parameter for the query string.
Returns:
the queryString.

fetchDelimiter

protected String fetchDelimiter(boolean isFirstParameter)
Fetch the delimiter between two parameters of a query string for a get command.

Parameters:
isFirstParameter - wether or not this is the first call.
Returns:
the delimiter.

addRequestHeaders

protected void addRequestHeaders(HttpMethodBase method)
Add request headers to the method.

Parameters:
method - the http method used to add request headers.


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