use of org.asqatasun.entity.subject.Site in project Asqatasun by Asqatasun.
the class AuditResultController method displayCriterionResult.
/**
*
* @param webresourceId
* @param criterionId
* @param model
* @return the test-result view name
*/
@RequestMapping(value = TgolKeyStore.CRITERION_RESULT_CONTRACT_URL, method = RequestMethod.GET)
public String displayCriterionResult(@RequestParam(TgolKeyStore.WEBRESOURCE_ID_KEY) String webresourceId, @RequestParam(TgolKeyStore.CRITERION_CODE_KEY) String criterionId, Model model) {
Long wrId;
Long critId;
try {
wrId = Long.valueOf(webresourceId);
critId = Long.valueOf(criterionId);
} catch (NumberFormatException nfe) {
throw new ForbiddenUserException(getCurrentUser());
}
WebResource webResource = getWebResourceDataService().ligthRead(wrId);
if (webResource == null || webResource instanceof Site) {
throw new ForbiddenPageException();
}
Audit audit = getAuditFromWebResource(webResource);
if (isUserAllowedToDisplayResult(audit)) {
Contract contract = retrieveContractFromAudit(audit);
// Attributes for breadcrumb
model.addAttribute(TgolKeyStore.CONTRACT_ID_KEY, contract.getId());
model.addAttribute(TgolKeyStore.CONTRACT_NAME_KEY, contract.getLabel());
model.addAttribute(TgolKeyStore.URL_KEY, webResource.getURL());
Criterion crit = criterionDataService.read(critId);
model.addAttribute(TgolKeyStore.CRITERION_LABEL_KEY, crit.getLabel());
model.addAttribute(TgolKeyStore.AUDIT_ID_KEY, audit.getId());
// Add a boolean used to display the breadcrumb.
model.addAttribute(TgolKeyStore.AUTHORIZED_SCOPE_FOR_PAGE_LIST, isAuthorizedScopeForPageList(audit));
model.addAttribute(TgolKeyStore.TEST_RESULT_LIST_KEY, TestResultFactory.getInstance().getTestResultListFromCriterion(webResource, crit));
return TgolKeyStore.CRITERION_RESULT_VIEW_NAME;
} else {
throw new ForbiddenPageException();
}
}
Aggregations