public void setVariableValue(String key, String value) { final JcrNode node; if (hasNode(VARIABLES_NODE_NAME)) { node = getNode(VARIABLES_NODE_NAME); } else { node = addNode(VARIABLES_NODE_NAME, "nt:unstructured"); } node.setProperty(key, value); }
public List<String> getSavedVariableKeys() { if (hasNode(VARIABLES_NODE_NAME)) { JcrNode node = getNode(VARIABLES_NODE_NAME); List<String> result = new ArrayList<String>(); JcrPropertyIterator i = node.getProperties(); while (i.hasNext()) { String name = i.nextProperty().getName(); // filter out jcr: properties (or other possible brix properties) if (!name.contains(":")) { result.add(name); } } return result; } else { return Collections.emptyList(); } }
public String getVariableValue(String key, boolean followTemplate) { if (hasNode(VARIABLES_NODE_NAME)) { JcrNode node = getNode(VARIABLES_NODE_NAME); if (node.hasProperty(key)) { return node.getProperty(key).getString(); } } if (followTemplate) { TemplateNode template = getTemplate(); if (template != null) { return template.getVariableValue(key); } else { return SitePlugin.get().getGlobalVariableValue(getSession(), key); } } return null; }