/** * Loads {@link WebAddress}s for all tenants. * * @throws Exception */ @PostConstruct public void init() throws Exception { initWebAddressMap(); if (tenantRepo != null) { tenantRepo.addListener(this); } }
/* (non-Javadoc) * @see org.ocpsoft.rewrite.config.ConfigurationProvider#getConfiguration(java.lang.Object) */ @Override public Configuration getConfiguration(ServletContext context) { log.debug("Preparing legacy Person rewrite configuration"); final ConfigurationBuilder builder = ConfigurationBuilder.begin(); for (Map.Entry<String, TenantState> entry : tenantRepo.getStates().entrySet()) { if (entry.getValue() == TenantState.ACTIVE) { final String tenantId = entry.getKey(); final PersonRepository personRepo = personRepos.get(tenantId); final Set<String> slugPaths = personRepo.findAllSlugsByStatus(StatusMask.ACTIVE_ONLY); if (!slugPaths.isEmpty()) { log.debug("{}ยป Rewriting {} old Person URIs", tenantId, slugPaths.size()); for (String slugPath : slugPaths) { builder .addRule() .when(Direction.isInbound().and(Path.matches("/" + slugPath))) .perform( Redirect.permanent( "/" + SeoBookmarkableMapper.DEFAULT_LOCALE_PREF_ID + "/" + slugPath)); } } } } return builder; }