com.atlassian.greenhopper.global
Class AbstractResultBuilder

java.lang.Object
  extended by com.atlassian.greenhopper.global.AbstractLoggable
      extended by com.atlassian.greenhopper.global.AbstractResultBuilder
Direct Known Subclasses:
CumulativeFlowChartModelFactory, RapidBoardViewModelFactory, RapidChartFactory, RapidViewHelper, RapidViewModelFactory, ReleaseViewModelFactory, SwimlanesHelper

public class AbstractResultBuilder
extends AbstractLoggable

Superclass for building "Result" type responses that can be handled automatically by GH.Ajax. The way things work is as follows: - ErrorCollection objects get passed in or are returned by service calls - The ErrorCollection is then passed into one of the builder methods, together with a simple result object or a builder for complex ones - The ResultEntry is rendered into JSON - Inside GH.Ajax (JavaScript), the error/success result is automatically processed (see Ajax.js for details)

Author:
ahennecke

Nested Class Summary
protected static interface AbstractResultBuilder.SuccessBuilder<T>
           
 
Field Summary
 
Fields inherited from class com.atlassian.greenhopper.global.AbstractLoggable
logger
 
Constructor Summary
AbstractResultBuilder()
           
 
Method Summary
protected  ResultEntry buildCombinedResult(com.atlassian.crowd.embedded.api.User user, ErrorCollection errors, java.lang.Object successPayload)
          Build a Result with both error and success object.
protected  ResultEntry buildResult(com.atlassian.crowd.embedded.api.User user, ErrorCollection errors, AbstractResultBuilder.SuccessBuilder<?> successBuilder)
          Build a Result with a complex (expensive to create) success object.
protected  ResultEntry buildResult(com.atlassian.crowd.embedded.api.User user, ErrorCollection errors, java.lang.Object successPayload)
          Build a Result with a simple success object.
 
Methods inherited from class com.atlassian.greenhopper.global.AbstractLoggable
logDebug, logException, logInfo, logTrace, logWarn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractResultBuilder

public AbstractResultBuilder()
Method Detail

buildResult

protected ResultEntry buildResult(com.atlassian.crowd.embedded.api.User user,
                                  ErrorCollection errors,
                                  AbstractResultBuilder.SuccessBuilder<?> successBuilder)
Build a Result with a complex (expensive to create) success object. The SuccessBuilder's build method will only be called if there are no errors, so in an error case, the success object is not unnecessarily created.

Parameters:
errors - : The collected errors from the service call chain
successBuilder - : Builds a success object in case there are no errors
Returns:
ResultEntry object with either errors or success object built by the builder

buildResult

protected ResultEntry buildResult(com.atlassian.crowd.embedded.api.User user,
                                  ErrorCollection errors,
                                  java.lang.Object successPayload)
Build a Result with a simple success object. Simple here means "inexpensive to create".

Parameters:
errors - : The collected errors from the service call chain
successPayload - : The object that gets attached to the Result, if there were no errors
Returns:
ResultEntry object with either errors or success payload

buildCombinedResult

protected ResultEntry buildCombinedResult(com.atlassian.crowd.embedded.api.User user,
                                          ErrorCollection errors,
                                          java.lang.Object successPayload)
Build a Result with both error and success object. If there are no errors, the error property of the Result will be null. This is meant for cases in which we need complete or partial success data to render a page, even if there were errors.



Copyright © 2007-2011 Atlassian. All Rights Reserved.