Subsite-Filter leitet jetzt auch Frontpage der Subsite um (Ticket #1877).

git-svn-id: https://svn.libreccm.org/ccm/trunk@2322 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2013-09-21 18:07:13 +00:00
parent cba909a57d
commit 9c7a117618
1 changed files with 31 additions and 19 deletions

View File

@ -15,10 +15,8 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
package com.arsdigita.subsite; package com.arsdigita.subsite;
// import com.arsdigita.subsite.Site; // import com.arsdigita.subsite.Site;
import javax.servlet.FilterChain; import javax.servlet.FilterChain;
@ -33,23 +31,25 @@ import com.arsdigita.web.BaseFilter;
import com.arsdigita.web.URL; import com.arsdigita.web.URL;
import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.navigation.NavigationContext; import com.arsdigita.navigation.NavigationContext;
import com.arsdigita.web.RedirectSignal;
import com.arsdigita.web.Web;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* Package's main worker class, SubsiteFilter intercepts each incomming request * Package's main worker class, SubsiteFilter intercepts each incomming request and checks if it
* and checks if it matches a configured subsite address (name). * matches a configured subsite address (name).
* *
* SubsiteFilter class uses the standard servlet filter mechanism (servlet * SubsiteFilter class uses the standard servlet filter mechanism (servlet specification 2.3 and
* specification 2.3 and beyond) so the servlet container ensures its * beyond) so the servlet container ensures its invocation.
* invocation.
* *
* Usage: SubsiteFilter has to be declared in the web.xml application configuration * Usage: SubsiteFilter has to be declared in the web.xml application configuration file.
* file.
*/ */
public class SubsiteFilter extends BaseFilter { public class SubsiteFilter extends BaseFilter {
/** A logger instance, primarily to assist debugging . */ /**
* A logger instance, primarily to assist debugging .
*/
private static final Logger s_log = Logger.getLogger(SubsiteFilter.class); private static final Logger s_log = Logger.getLogger(SubsiteFilter.class);
/** /**
@ -86,12 +86,24 @@ public class SubsiteFilter extends BaseFilter {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Got site " + site); s_log.debug("Got site " + site);
} }
if ((site != null) && ((sreq.getRequestURI() == null) || ("/".equals(sreq.getRequestURI())))) {
final String redirectUrl =
URL.there(sreq,
site.getFrontPage().getPath()).
toString();
sresp.sendRedirect(redirectUrl);
return;
}
sreq.setAttribute(SubsiteContext.SITE_REQUEST_ATTRIBUTE, sreq.setAttribute(SubsiteContext.SITE_REQUEST_ATTRIBUTE,
site); site);
sreq.setAttribute(NavigationContext.TEMPLATE_CONTEXT, sreq.setAttribute(NavigationContext.TEMPLATE_CONTEXT,
site == null ? null : site == null ? null
site.getTemplateContext()); : site.getTemplateContext());
chain.doFilter(sreq, sresp); chain.doFilter(sreq, sresp);
} }
} }