use of uk.nhs.digital.website.beans.General in project hippo by NHS-digital-website.
the class GeneralArticleComponent method doBeforeRender.
@Override
public void doBeforeRender(final HstRequest hstRequest, final HstResponse hstResponse) {
super.doBeforeRender(hstRequest, hstResponse);
final HstRequestContext context = RequestContextProvider.get();
HttpServletRequest request = context.getServletRequest();
Object bean = hstRequest.getAttribute(REQUEST_ATTR_DOCUMENT);
if (bean != null && bean instanceof HippoBean) {
General generalDocument = (General) bean;
if (StringUtils.isNotBlank(generalDocument.getEarlyAccessKey()) && !generalDocument.getEarlyAccessKey().equals(request.getParameter("key"))) {
LOGGER.debug("Early access key is set and no or wrong key is being used. Redirecting to 404 error code");
hstResponse.setStatus(HttpServletResponse.SC_NOT_FOUND);
HstResponseUtils.sendRedirect(hstRequest, hstResponse, "/error/404");
}
}
}
Aggregations