diff --git a/magnolia-templating/src/main/java/info/magnolia/templating/functions/TemplatingFunctions.java b/magnolia-templating/src/main/java/info/magnolia/templating/functions/TemplatingFunctions.java index 9ece36b..369aec6 100644 --- a/magnolia-templating/src/main/java/info/magnolia/templating/functions/TemplatingFunctions.java +++ b/magnolia-templating/src/main/java/info/magnolia/templating/functions/TemplatingFunctions.java @@ -881,6 +881,59 @@ return SessionUtil.getNodeByIdentifier(workspace, id); } + /* + * Start: New by Christian for review + * Info: Always return true or false for the scripts, never null. Or an additional check in the script is needed. + * The templater only needs to know if the item exists. The null differentiation done in SessionUtil is for the Java world. + */ + public Boolean contentExists(String path){ + return nodeExists(path); + } + + public Boolean contentExists(String path, String workspace){ + return nodeExists(path, workspace); + } + + public Boolean nodeExists(String path){ + return nodeExists(path, RepositoryConstants.WEBSITE); + } + + public Boolean nodeExists(String path, String workspace){ + Boolean nodeExists = SessionUtil.nodeExists(workspace, path); + return (nodeExists == null) ? false : nodeExists; + } + + public Boolean itemExists(String path){ + return itemExists(path, RepositoryConstants.WEBSITE); + } + + public Boolean itemExists(String path, String workspace){ + Boolean itemExists = SessionUtil.itemExists(workspace, path); + return (itemExists == null) ? false : itemExists; + } + + public Boolean propertyExists(String path){ + return propertyExists(path, RepositoryConstants.WEBSITE); + } + + public Boolean propertyExists(String path, String workspace){ + Boolean propertyExists = SessionUtil.propertyExists(workspace, path); + return (propertyExists == null) ? false : propertyExists; + } + + public Boolean idExists(String id) { + return idExists(id, RepositoryConstants.WEBSITE); + } + + public Boolean idExists(String id, String workspace) { + Boolean idExists = SessionUtil.idExists(workspace, id); + return (idExists == null) ? false : idExists; + } + + /* + * End: New by Christian for review + */ + /** * Returns a {@link Node} object which is referenced by its id, stored in * the @param propertyName.