Refine search
protected static NodeState getIndexDefinitionState(NodeState defn) { if (isDisableStoredIndexDefinition()){ return defn; } NodeState storedState = defn.getChildNode(INDEX_DEFINITION_NODE); return storedState.exists() ? storedState : defn; }
private void mergeSubtree(NodeBuilder builder, NodeState state, String name, int depth) { NodeState subtree = state.getChildNode(name); if (subtree.exists()) { if (!builder.hasChildNode(name)) { builder.setChildNode(name, subtree); } else if (depth > 0) { NodeBuilder subbuilder = builder.child(name); for (String subname : subtree.getChildNodeNames()) { mergeSubtree(subbuilder, subtree, subname, depth - 1); } } } }
@Test public void noVersionStoragePrePopulated() throws Exception { // default initial content does not have intermediate nodes // pre-populated NodeState system = INITIAL_CONTENT.getChildNode(JCR_SYSTEM); assertTrue(system.exists()); NodeState vs = system.getChildNode(JCR_VERSIONSTORAGE); assertTrue(vs.exists()); assertTrue(vs.getChildNodeCount(Integer.MAX_VALUE) == 0); }
@Override @Nullable public NodeState retrieve(@NotNull String checkpoint) { checkNotNull(checkpoint); NodeState cp = scheduler.getHeadNodeState() .getChildNode("checkpoints") .getChildNode(checkpoint) .getChildNode(ROOT); if (cp.exists()) { return cp; } return null; }
/** * Assumes that given state is of type nt:file and then reads * the jcr:content/@jcr:data property to get the binary content */ @Nullable public static Blob getBlob(NodeState state, String resourceName){ NodeState contentNode = state.getChildNode(JcrConstants.JCR_CONTENT); checkArgument(contentNode.exists(), "Was expecting to find jcr:content node to read resource %s", resourceName); PropertyState property = contentNode.getProperty(JcrConstants.JCR_DATA); return property != null ? property.getValue(Type.BINARY) : null; } }
@NotNull @Override public ReadOnlyBuilder child(@NotNull String name) { NodeState child = state.getChildNode(name); if (child.exists()) { return new ReadOnlyBuilder(child); } else { throw unsupported(); } }
@Nonnull @Override public ReadOnlyBuilder child(@Nonnull String name) { NodeState child = state.getChildNode(name); if (child.exists()) { return new ReadOnlyBuilder(child); } else { throw unsupported(); } }
private int evaluateSuggesterUpdateFrequencyMinutes(NodeState defn, int defaultValue) { NodeState suggestionConfig = defn.getChildNode(FulltextIndexConstants.SUGGESTION_CONFIG); if (!suggestionConfig.exists()) { //handle backward compatibility return getOptionalValue(defn, FulltextIndexConstants.SUGGEST_UPDATE_FREQUENCY_MINUTES, defaultValue); } return getOptionalValue(suggestionConfig, FulltextIndexConstants.SUGGEST_UPDATE_FREQUENCY_MINUTES, defaultValue); }
private boolean evaluateSuggestAnalyzed(NodeState defn, boolean defaultValue) { NodeState suggestionConfig = defn.getChildNode(FulltextIndexConstants.SUGGESTION_CONFIG); if (!suggestionConfig.exists()) { //handle backward compatibility return getOptionalValue(defn, FulltextIndexConstants.SUGGEST_ANALYZED, defaultValue); } return getOptionalValue(suggestionConfig, FulltextIndexConstants.SUGGEST_ANALYZED, defaultValue); }
private boolean isTransientlyAdded(String path) { NodeState node = rootBuilder.getBaseState(); for (String name : PathUtils.elements(path)) { node = node.getChildNode(name); } return !node.exists(); }
private boolean isTransientlyAdded(String path) { NodeState node = rootBuilder.getBaseState(); for (String name : PathUtils.elements(path)) { node = node.getChildNode(name); } return !node.exists(); }
private static void computeLastUpdatedTime(NodeState idxState, LuceneIndexInfo info) { NodeState status = idxState.getChildNode(IndexDefinition.STATUS_NODE); if (status.exists()){ PropertyState updatedTime = status.getProperty(IndexDefinition.STATUS_LAST_UPDATED); if (updatedTime != null) { info.lastUpdatedTime = ISO8601.parse(updatedTime.getValue(Type.DATE)).getTimeInMillis(); } } }
@Nullable public static String getId(@NotNull NodeStore store) { checkNotNull(store, "store is null"); // first try to read an existing clusterId NodeState root = store.getRoot(); NodeState node = root.getChildNode(CLUSTER_CONFIG_NODE); if (node.exists() && node.hasProperty(CLUSTER_ID_PROP)) { return node.getProperty(CLUSTER_ID_PROP).getValue(Type.STRING); } return null; }
private static void computeLastUpdatedTime(NodeState idxState, LuceneIndexInfo info) { NodeState status = idxState.getChildNode(IndexDefinition.STATUS_NODE); if (status.exists()){ PropertyState updatedTime = status.getProperty(IndexDefinition.STATUS_LAST_UPDATED); if (updatedTime != null) { info.lastUpdatedTime = ISO8601.parse(updatedTime.getValue(Type.DATE)).getTimeInMillis(); } } }
@Test public void testGetChildNode() { assertTrue(state.getChildNode("x0").exists()); assertTrue(state.getChildNode("x1").exists()); assertTrue(state.getChildNode("x" + N).exists()); assertFalse(state.getChildNode("x" + (N + 1)).exists()); }
@Test public void testGetChildNode() { assertTrue(state.getChildNode("x").exists()); assertTrue(state.getChildNode("y").exists()); assertTrue(state.getChildNode("z").exists()); assertFalse(state.getChildNode("a").exists()); }
private static void computeIndexDefinitionChange(NodeState idxState, LuceneIndexInfo info) { NodeState storedDefn = idxState.getChildNode(INDEX_DEFINITION_NODE); if (storedDefn.exists()) { NodeState currentDefn = NodeStateCloner.cloneVisibleState(idxState); if (!FilteringEqualsDiff.equals(storedDefn, currentDefn)){ info.indexDefinitionChanged = true; info.indexDiff = JsopDiff.diffToJsop(storedDefn, currentDefn); } } }
private static void computeIndexDefinitionChange(NodeState idxState, LuceneIndexInfo info) { NodeState storedDefn = idxState.getChildNode(INDEX_DEFINITION_NODE); if (storedDefn.exists()) { NodeState currentDefn = NodeStateCloner.cloneVisibleState(idxState); if (!FilteringEqualsDiff.equals(storedDefn, currentDefn)){ info.indexDefinitionChanged = true; info.indexDiff = JsopDiff.diffToJsop(storedDefn, currentDefn); } } }
@NotNull @Override public NodeState getChildNode(@NotNull String name) { NodeState child = state.getChildNode(name); if (child.exists() && !treePermission.canReadAll()) { ChildNodeEntry entry = new MemoryChildNodeEntry(name, child); return new WrapChildEntryFunction().apply(entry).getNodeState(); } else { return child; } }
@NotNull @Override public NodeState getChildNode(@NotNull String name) { NodeState child = state.getChildNode(name); if (child.exists() && !treePermission.canReadAll()) { ChildNodeEntry entry = new MemoryChildNodeEntry(name, child); return new WrapChildEntryFunction().apply(entry).getNodeState(); } else { return child; } }