use of org.asqatasun.webapp.exception.KrashAuditException in project Asqatasun by Asqatasun.
the class AuditLauncherController method preparePageAudit.
/**
* This methods controls the validity of the form and launch an audit with
* values populated by the user. In case of audit failure, an appropriate
* message is displayed
*
* @param pageAuditSetUpCommand
* @param contract
* @param locale
* @param auditScope
* @param model
* @return
*/
private String preparePageAudit(final AuditSetUpCommand auditSetUpCommand, final Contract contract, final Locale locale, final ScopeEnum auditScope, Model model) {
Audit audit;
boolean isPageAudit = true;
// if the form is correct, we launch the audit
try {
if (auditScope.equals(ScopeEnum.FILE)) {
audit = launchUploadAudit(contract, auditSetUpCommand, locale);
isPageAudit = false;
} else {
audit = launchPageAudit(contract, auditSetUpCommand, locale);
}
} catch (KrashAuditException kae) {
return TgolKeyStore.OUPS_VIEW_NAME;
}
// page and send an email when it's ready
if (audit == null) {
model.addAttribute(TgolKeyStore.TESTED_URL_KEY, auditSetUpCommand.getUrlList().get(0));
model.addAttribute(TgolKeyStore.CONTRACT_ID_KEY, contract.getId());
model.addAttribute(TgolKeyStore.CONTRACT_NAME_KEY, contract.getLabel());
model.addAttribute(TgolKeyStore.IS_PAGE_AUDIT_KEY, isPageAudit);
if (!getEmailSentToUserExclusionList().contains(contract.getUser().getEmail1())) {
model.addAttribute(TgolKeyStore.IS_USER_NOTIFIED_KEY, true);
}
return TgolKeyStore.GREEDY_AUDIT_VIEW_NAME;
}
if (audit.getStatus() != AuditStatus.COMPLETED) {
return prepareFailedAuditData(audit, model);
}
if (audit.getSubject() instanceof Site) {
// in case of group of page, we display the list of audited pages
model.addAttribute(TgolKeyStore.AUDIT_ID_KEY, audit.getId());
model.addAttribute(TgolKeyStore.STATUS_KEY, HttpStatusCodeFamily.f2xx);
return TgolKeyStore.PAGE_LIST_XXX_VIEW_REDIRECT_NAME;
} else if (audit.getSubject() instanceof Page) {
model.addAttribute(TgolKeyStore.WEBRESOURCE_ID_KEY, audit.getSubject().getId());
return TgolKeyStore.RESULT_PAGE_VIEW_REDIRECT_NAME;
}
throw new LostInSpaceException(getCurrentUser());
}
Aggregations