/** * {@inheritDoc} */ @Override public MappingResult mapURI(String uri) { // delegate the initial processing to RegexpVirtualURIMapping MappingResult mr = super.mapURI(uri); if (mr != null) { if (end > start) { int randomNumber = new Random().nextInt(end - (start - 1)) + start; String randomAsString = StringUtils.leftPad(Integer.toString(randomNumber), padding, '0'); mr.setToURI(StringUtils.replace(mr.getToURI(), RANDOM_PLACEHOLDER, randomAsString)); } else { log.warn("End value must be greater than start value."); } } return mr; }
@Override public MappingResult mapURI(final String uri, String queryString) { if (regexp != null) { final Matcher matcher; if (queryString != null) { matcher = regexp.matcher(uri + "?" + queryString); } else { matcher = regexp.matcher(uri); } if (matcher.find()) { final MappingResult r = new MappingResult(); final int matcherCount = matcher.groupCount(); try { final String replaced = matcher.replaceAll(toURI); r.setLevel(matcherCount + 1); r.setToURI(replaced); return r; } catch (IndexOutOfBoundsException e) { log.warn("{} misconfigured: {}", toString(), e.getMessage()); } } } return null; }
@Override public MappingResult mapURI(final String uri, String queryString) { if (regexp != null) { final Matcher matcher; if (queryString != null) { matcher = regexp.matcher(uri + "?" + queryString); } else { matcher = regexp.matcher(uri); } if (matcher.find()) { final MappingResult r = new MappingResult(); String hostMapping = this.tryToMapHost(); String replaced; try { if (StringUtils.isNotEmpty(hostMapping)) { replaced = matcher.replaceAll(hostMapping); } else { replaced = matcher.replaceAll(toURI); } r.setLevel(matcher.groupCount() + 1); r.setToURI(replaced); return r; } catch (IndexOutOfBoundsException e) { log.warn("{} misconfigured: {}", toString(), e.getMessage()); } } } return null; }
public MappingResult mapURI(String uri) { String destination = toURI; if (pattern != null && pattern.match(uri)) { WebContext webContext = MgnlContext.getWebContextOrNull(); if (webContext != null) { String locale = webContext.getAggregationState().getLocale().toString(); if (destinations != null) { Iterator<Map.Entry<String, String>> destIt = destinations.entrySet().iterator(); while (destIt.hasNext()) { Map.Entry<String, String> hk = destIt.next(); if (locale.startsWith(hk.getKey())) { destination = hk.getValue(); break; } } } } MappingResult r = new MappingResult(); r.setLevel(pattern.getLength()); r.setToURI(destination); return r; } return null; }
r.setToURI(newuri); return r;
/** * {@inheritDoc} */ public MappingResult mapURI(String uri) { if (uri.startsWith(PREFIX_MAPPING)) { String uuid = StringUtils.substringAfter(uri, PREFIX_MAPPING); Node media = MediaEl.node(uuid); if (media != null) { MappingResult mr = new MappingResult(); mr.setToURI("redirect:" + MediaEl.thumbnail(media)); mr.setLevel(1); return mr; } } return null; }
@Override public MappingResult mapURI(String uri) { MappingResult result = super.mapURI(uri); if (result != null) { String destination = toURI; String hostMapping = this.tryToMapHost(); if (hostMapping != null) { destination = hostMapping; } result.setToURI(destination); return result; } return null; }
@Override public MappingResult mapURI(String uri) { if (pattern != null && pattern.match(uri)) { MappingResult r = new MappingResult(); r.setLevel(pattern.getLength()); r.setToURI(toURI); return r; } return null; }