if (!isValidVanityPath(resource)) {
return;
}
final ValueMap props = resource.adaptTo(ValueMap.class);
long vanityOrder = 0;
if (props.containsKey(PROP_VANITY_ORDER)) {
vanityOrder = props.get(PROP_VANITY_ORDER, Long.class);
}
// url is ignoring scheme and host.port and the path is
// what is stored in the sling:vanityPath property
final String[] pVanityPaths = props.get(PROP_VANITY_PATH, new String[0]);
for (final String pVanityPath : pVanityPaths) {
final String[] result = this.getVanityPathDefinition(pVanityPath);
if (result != null) {
final String url = result[0] + result[1];
// redirect target is the node providing the
// sling:vanityPath
// property (or its parent if the node is called
// jcr:content)
final Resource redirectTarget;
if (resource.getName().equals("jcr:content")) {
redirectTarget = resource.getParent();
} else {
redirectTarget = resource;
}
final String redirect = redirectTarget.getPath();
final String redirectName = redirectTarget.getName();
// whether the target is attained by a external redirect or
// by an internal redirect is defined by the sling:redirect
// property
final int status = props.get(PROP_REDIRECT_EXTERNAL, false) ? props.get(
PROP_REDIRECT_EXTERNAL_REDIRECT_STATUS, factory.getDefaultVanityPathRedirectStatus())
: -1;
final String checkPath = result[1];