/** * @param queryNode * @param queryOptions * @return * @throws RepositoryException * @throws ValueFormatException * @throws PathNotFoundException * @throws JSONException */ private JSONObject accumulateQueryOptions(Node queryNode) throws RepositoryException, ValueFormatException, PathNotFoundException, JSONException { JSONObject queryOptions = null; if (queryNode.hasProperty(SAKAI_QUERY_TEMPLATE_OPTIONS)) { // process the options as JSON string String optionsProp = queryNode.getProperty(SAKAI_QUERY_TEMPLATE_OPTIONS).getString(); queryOptions = new JSONObject(optionsProp); } else if (queryNode.hasNode(SAKAI_QUERY_TEMPLATE_OPTIONS)) { // process the options as a sub-node Node optionsNode = queryNode.getNode(SAKAI_QUERY_TEMPLATE_OPTIONS); if (optionsNode.hasProperties()) { queryOptions = new JSONObject(); PropertyIterator props = optionsNode.getProperties(); while (props.hasNext()) { javax.jcr.Property prop = props.nextProperty(); if (!prop.getName().startsWith("jcr:")) { queryOptions.put(prop.getName(), prop.getString()); } } } } return queryOptions; }