*
* @return Obtains the state encoded in Base64 that will be added to the request in the HDIV extra parameter.
*/
public String endRequest() {
IState state = super.getStatesStack().pop();
state.setPageId(this.getPage().getId());
String id = null;
String stateWithSuffix = null;
String stateData = encodingUtil.encode64(state);
// if state's length it's too long for GET methods we have to change the
// strategy to memory
if (stateData.length() > this.allowedLength) {
if (log.isDebugEnabled()) {
log.debug("Move from Hash strategy to Memory because state data [" + stateData.length()
+ "] is greater than allowedLength [" + this.allowedLength);
}
this.getPage().addState(state);
state.setPageId(this.getPage().getId());
id = this.getPage().getId() + DASH + state.getId() + DASH + this.getStateSuffix(state.getMethod());
} else {
// generate hash to add to the page that will be stored in session
stateWithSuffix = stateData + DASH + this.getStateSuffix(state.getMethod());
String stateHash = this.encodingUtil.calculateStateHash(stateWithSuffix);
this.getPage().addState(state.getId(), stateHash);
}
// Save Page in session if this is the first state to add
boolean firstState = page.getStatesCount() == 1;
if (firstState) {