@Test public void testIndexedProperties() throws Exception { SolrClient solrServer = TestUtils.createSolrServer(); try { OakSolrConfiguration configuration = TestUtils.getTestConfiguration(); IndexUpdateCallback callback = mock(IndexUpdateCallback.class); SolrIndexEditor solrIndexEditor = new SolrIndexEditor(solrServer, configuration, callback); NodeState before = mock(NodeState.class); NodeState after = mock(NodeState.class); Iterable properties = (Iterable<PropertyState>) () -> Collections.singletonList(PropertyStates.createProperty("foo1", "bar")).iterator(); when(after.getProperties()).thenReturn(properties); solrIndexEditor.leave(before, after); QueryResponse queryResponse = solrServer.query(new SolrQuery("foo1:*")); assertEquals(1, queryResponse.getResults().getNumFound()); } finally { solrServer.close(); } }
@Override public void leave(NodeState before, NodeState after) throws CommitFailedException { if (propertiesChanged || !before.exists()) { updateCallback.indexUpdate(); try { solrServer.add(docFromState(after)); } catch (SolrServerException e) { throw new CommitFailedException( "Solr", 2, "Failed to add a document to Solr", e); } catch (IOException e) { throw new CommitFailedException( "Solr", 6, "Failed to send data to Solr", e); } } if (parent == null) { try { commitByPolicy(solrServer, configuration.getCommitPolicy()); } catch (SolrServerException e) { throw new CommitFailedException( "Solr", 3, "Failed to commit changes to Solr", e); } catch (IOException e) { throw new CommitFailedException( "Solr", 6, "Failed to send data to Solr", e); } } }
SolrIndexEditor implements IndexEditor { @Override public void leave(NodeState before, NodeState after) throws CommitFailedException { if (propertiesChanged || !before.exists()) { updateCallback.indexUpdate(); try { solrServer.add(docFromState(after)); } catch (SolrServerException e) { throw new CommitFailedException( "Solr", 2, "Failed to add a document to Solr", e); } catch (IOException e) { throw new CommitFailedException( "Solr", 6, "Failed to send data to Solr", e); } } if (parent == null) { try { commitByPolicy(solrServer, configuration.getCommitPolicy()); } catch (SolrServerException e) { throw new CommitFailedException( "Solr", 3, "Failed to commit changes to Solr", e); } catch (IOException e) { throw new CommitFailedException( "Solr", 6, "Failed to send data to Solr", e); } } } }
SolrIndexEditor implements IndexEditor { @Override public void leave(NodeState before, NodeState after) throws CommitFailedException { if (propertiesChanged || !before.exists()) { updateCallback.indexUpdate(); try { solrServer.add(docFromState(after)); } catch (SolrServerException e) { throw new CommitFailedException( "Solr", 2, "Failed to add a document to Solr", e); } catch (IOException e) { throw new CommitFailedException( "Solr", 6, "Failed to send data to Solr", e); } } if (parent == null) { try { commitByPolicy(solrServer, configuration.getCommitPolicy()); } catch (SolrServerException e) { throw new CommitFailedException( "Solr", 3, "Failed to commit changes to Solr", e); } catch (IOException e) { throw new CommitFailedException( "Solr", 6, "Failed to send data to Solr", e); } } } SolrIndexEditor(
            SolrClient solrServer,
            OakSolrConfiguration configuration,
            IndexUpdateCallback callback); private  SolrIndexEditor(SolrIndexEditor parent, String name); }
SolrIndexEditor implements IndexEditor { @Override public void leave(NodeState before, NodeState after) throws CommitFailedException { if (propertiesChanged || !before.exists()) { updateCallback.indexUpdate(); try { solrServer.add(docFromState(after)); } catch (SolrServerException e) { throw new CommitFailedException( "Solr", 2, "Failed to add a document to Solr", e); } catch (IOException e) { throw new CommitFailedException( "Solr", 6, "Failed to send data to Solr", e); } } if (parent == null) { try { commitByPolicy(solrServer, configuration.getCommitPolicy()); } catch (SolrServerException e) { throw new CommitFailedException( "Solr", 3, "Failed to commit changes to Solr", e); } catch (IOException e) { throw new CommitFailedException( "Solr", 6, "Failed to send data to Solr", e); } } } SolrIndexEditor(
            SolrClient solrServer,
            OakSolrConfiguration configuration,
            IndexUpdateCallback callback); private  SolrIndexEditor(SolrIndexEditor parent, String name); @Override void enter(NodeState before, NodeState after); @Override void leave(NodeState before, NodeState after); @Override void propertyAdded(PropertyState after); @Override void propertyChanged(PropertyState before, PropertyState after); @Override void propertyDeleted(PropertyState before); @Override Editor childNodeAdded(String name, NodeState after); @Override Editor childNodeChanged(
            String name, NodeState before, NodeState after); @Override Editor childNodeDeleted(String name, NodeState before); }
SolrIndexEditor implements IndexEditor { @Override public void leave(NodeState before, NodeState after) throws CommitFailedException { if (propertiesChanged || !before.exists()) { updateCallback.indexUpdate(); try { solrServer.add(docFromState(after)); } catch (SolrServerException e) { throw new CommitFailedException( "Solr", 2, "Failed to add a document to Solr", e); } catch (IOException e) { throw new CommitFailedException( "Solr", 6, "Failed to send data to Solr", e); } } if (parent == null) { try { commitByPolicy(solrServer, configuration.getCommitPolicy()); } catch (SolrServerException e) { throw new CommitFailedException( "Solr", 3, "Failed to commit changes to Solr", e); } catch (IOException e) { throw new CommitFailedException( "Solr", 6, "Failed to send data to Solr", e); } } } SolrIndexEditor(
            SolrClient solrServer,
            OakSolrConfiguration configuration,
            IndexUpdateCallback callback); private  SolrIndexEditor(SolrIndexEditor parent, String name); @Override void enter(NodeState before, NodeState after); @Override void leave(NodeState before, NodeState after); @Override void propertyAdded(PropertyState after); @Override void propertyChanged(PropertyState before, PropertyState after); @Override void propertyDeleted(PropertyState before); @Override Editor childNodeAdded(String name, NodeState after); @Override Editor childNodeChanged(
            String name, NodeState before, NodeState after); @Override Editor childNodeDeleted(String name, NodeState before);  }