use of org.asqatasun.webapp.util.HttpStatusCodeFamily in project Asqatasun by Asqatasun.
the class PageListController method pageLinkDispatcher.
/**
* This method dispatches the result depending on the parameters passed to
* the request. Only multi-pages audit are considered here.
*
* @param request
* @param model
* @return
* @throws Exception
*/
private String pageLinkDispatcher(HttpServletRequest request, Audit audit, Model model) throws Exception {
if (audit.getSubject() instanceof Page) {
throw new ForbiddenPageException();
}
String status = ServletRequestUtils.getStringParameter(request, STATUS_KEY);
HttpStatusCodeFamily httpStatusCode = getHttpStatusCodeFamily(status);
// the repartion of the pages regarding the httpStatusCode
if (httpStatusCode == null) {
if (!isAuthorizedScopeForPageList(audit)) {
throw new ForbiddenScopeException();
}
try {
Contract currentContract = retrieveContractFromAudit(audit);
model.addAttribute(CONTRACT_NAME_KEY, currentContract.getLabel());
model.addAttribute(CONTRACT_ID_KEY, currentContract.getId());
String testLabel = ServletRequestUtils.getStringParameter(request, TEST_KEY);
if (StringUtils.isNotBlank(testLabel)) {
model.addAttribute(TEST_CODE_KEY, testDataService.getTestFromAuditAndLabel(audit, testLabel));
}
return this.preparePageListData(audit, model);
} catch (ServletRequestBindingException e) {
return OUPS_VIEW_REDIRECT_NAME;
}
} else {
boolean isAuthorizedScopeForPageList = isAuthorizedScopeForPageList(audit);
Contract currentContract = retrieveContractFromAudit(audit);
model.addAttribute(CONTRACT_NAME_KEY, currentContract.getLabel());
model.addAttribute(CONTRACT_ID_KEY, currentContract.getId());
// used in the jsp
if (!isAuthorizedScopeForPageList) {
model.addAttribute(AUDIT_NUMBER_KEY, true);
}
String testLabel = ServletRequestUtils.getStringParameter(request, TEST_KEY);
if (StringUtils.isNotBlank(testLabel)) {
model.addAttribute(TEST_CODE_KEY, testDataService.getTestFromAuditAndLabel(audit, testLabel));
}
return this.preparePageListStatsByHttpStatusCode(audit, model, httpStatusCode, request, false);
}
}
Aggregations