@Override public boolean hasProperty(Node node, String name) throws RepositoryException { if (!isEnabled()) { return node.hasProperty(name); } try { // get property using all the rules in getProperty method. If not found, then it doesn't exist. getProperty(node, name); } catch (RepositoryException e) { return false; } return true; }
@Override public Node getNode(Node node, String name) throws RepositoryException { if (isEnabled()) { try { // test for the current language Locale locale = getLocale(); Set<Locale> checkedLocales = new HashSet<Locale>(); // getNextContentLocale() returns null once the end of the locale chain is reached while (locale != null) { String localeSpecificChildName = name + "_" + locale; if (node.hasNode(localeSpecificChildName)) { return node.getNode(localeSpecificChildName); } checkedLocales.add(locale); locale = getNextContentLocale(locale, checkedLocales); } } catch (RepositoryException e) { log.error("can't read i18n node {} from node {}", name, node, e); } } return node.getNode(name); }
@Override public Property getProperty(Node node, String name) throws RepositoryException { if (!isEnabled()) { return node.getProperty(name); } try { // test for the current language Locale locale = getLocale(); Set<Locale> checkedLocales = new HashSet<Locale>(); // getNextContentLocale() returns null once the end of the locale chain is reached while (locale != null) { Property property = getProperty(node, name, locale); if (!isEmpty(property)) { return property; } else if (locale.equals(getDefaultLocale()) && node.hasProperty(name)) { return node.getProperty(name); } checkedLocales.add(locale); locale = getNextContentLocale(locale, checkedLocales); } } catch (RepositoryException e) { log.error("can't read i18n property {} from node {}", name, node, e); } // return the node data return node.getProperty(name); }
@Override public String toI18NURI(String uri) { if (!isEnabled()) { return uri; } Locale locale = getLocale(); if (isLocaleSupported(locale)) { return toI18NURI(uri, locale); } return uri; }
/** * Removes the prefix. */ @Override public String toRawURI(String i18nURI) { if (!isEnabled()) { return i18nURI; } Locale locale = getLocale(); if (isLocaleSupported(locale)) { return toRawURI(i18nURI, locale); } return i18nURI; }