@Override protected boolean accepts(ProcessingContext context, PathElementsProvider provider) { String current = provider.current(); Degree degree = Degree.readBySigla(current); if (degree == null) { return false; } else { DegreeContext ownContext = (DegreeContext) context; ownContext.setDegree(degree); /* * This is an ugly hack so this process still works until the * semester ends where we can easily notify everyone that the link * format has changed. * * 04-02-2007 pcma */ DegreeSite portalInstance = degree.getSite(); MetaDomainObjectPortal portal = (MetaDomainObjectPortal) MetaDomainObject.getMeta(portalInstance.getClass()).getAssociatedPortal(); List<Content> contents = new ArrayList<Content>(); contents.add(portal); contents.add(portalInstance); HttpServletRequest request = context.getRequest(); FilterFunctionalityContext filterContext = new FilterFunctionalityContext(request, contents); filterContext.setHasBeenForwarded(); request.setAttribute(FunctionalityContext.CONTEXT_KEY, filterContext); return true; } }
private void dispatchTo( final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse, final FilterFunctionalityContext functionalityContext, String path) throws ServletException, IOException { httpServletRequest.setAttribute( ContentInjectionRewriter.CONTEXT_ATTRIBUTE_NAME, functionalityContext.getCurrentContextPath()); final RequestDispatcher requestDispatcher = httpServletRequest.getRequestDispatcher(path); functionalityContext.setHasBeenForwarded(); requestDispatcher.forward(httpServletRequest, httpServletResponse); }
@Override protected boolean forward(ProcessingContext context, PathElementsProvider provider) throws IOException, ServletException { if (provider.hasNext()) { return false; } else { SemesterContext ownContext = (SemesterContext) context; ExecutionCourse executionCourse = ownContext.getExecutionCourse(); if (executionCourse == null) { return false; } else { /* * This is an ugly hack so this process still works until the * semester ends where we can easily notify everyone that the * link format has changed. * * 04-02-2007 pcma */ HttpServletRequest request = context.getRequest(); ExecutionCourseSite portalInstance = executionCourse.getSite(); MetaDomainObjectPortal portal = MetaDomainObjectPortal.getPortal(portalInstance.getClass()); List<Content> contents = new ArrayList<Content>(); contents.add(portal); contents.add(portalInstance); FilterFunctionalityContext filterContext = (FilterFunctionalityContext) request.getAttribute(FunctionalityContext.CONTEXT_KEY); if (filterContext != null) { request.removeAttribute(FunctionalityContext.CONTEXT_KEY); } filterContext = new FilterFunctionalityContext(request, contents); filterContext.setHasBeenForwarded(); request.setAttribute(FunctionalityContext.CONTEXT_KEY, filterContext); String url = portalInstance.getReversePath(); context.getResponse().sendRedirect(context.getRequest().getContextPath() + url); return true; } } }