use of org.asqatasun.webapp.exception.AuditParameterMissingException in project Asqatasun by Asqatasun.
the class PageListController method displayPageList.
/**
*
* @param request
* @param response
* @param model
* @return
* @throws java.lang.Exception
*/
@RequestMapping(value = TgolKeyStore.PAGE_LIST_CONTRACT_URL, method = RequestMethod.GET)
@Secured({ TgolKeyStore.ROLE_USER_KEY, TgolKeyStore.ROLE_ADMIN_KEY })
public String displayPageList(HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
String auditId = ServletRequestUtils.getStringParameter(request, TgolKeyStore.AUDIT_ID_KEY);
if (auditId == null) {
throw new AuditParameterMissingException();
}
Audit audit;
try {
audit = getAuditDataService().read(Long.valueOf(auditId));
} catch (NumberFormatException e) {
throw new ForbiddenPageException(e);
}
if (isUserAllowedToDisplayResult(audit)) {
return pageLinkDispatcher(request, audit, model);
} else {
// method returns true or throws an exception
return TgolKeyStore.ACCESS_DENIED_VIEW_NAME;
}
}
use of org.asqatasun.webapp.exception.AuditParameterMissingException in project Asqatasun by Asqatasun.
the class PageListControllerTest method testDisplayPageListWithoutAuditId.
/**
* The servlet is supposed to embed the audit id the page is
* about. If not, the ForbiddenPageException is caught.
* @throws Exception
*/
public void testDisplayPageListWithoutAuditId() throws Exception {
System.out.println("testDisplayPageListWithoutAuditId");
// about. If not, the access denied page is returned
try {
instance.displayPageList(new MockHttpServletRequest(), new MockHttpServletResponse(), new ExtendedModelMap());
assertTrue(false);
} catch (AuditParameterMissingException fbe) {
assertTrue(true);
}
}
Aggregations