public Collection<String> getImmediateDeleteQueries( RepositorySession repositorySession, Event event) { String topic = event.getTopic(); if (topic.endsWith(StoreListener.DELETE_TOPIC)) { String path = (String) event.getProperty(FIELD_PATH); if (!ignore(path) && !immediateIgnoreCache.containsKey(path)) { String resourceType = (String) event.getProperty("resourceType"); ImmediateIndexingHandler handler = null; if (resourceType != null) { handler = (ImmediateIndexingHandler) getHandler(resourceType, this.immediateIndexers); } else { handler = (ImmediateIndexingHandler) getHandler( repositorySession, path, this.immediateIndexers, this.immediateIgnoreCache); } return handler.getImmediateDeleteQueries(repositorySession, event); } } else { LOGGER.debug("No delete action require on {} ", event); } return ImmutableList.of(); }
public Collection<SolrInputDocument> getImmediateDocuments( RepositorySession repositorySession, Event event) { String topic = event.getTopic(); if (topic.endsWith(StoreListener.UPDATED_TOPIC) || topic.endsWith(StoreListener.ADDED_TOPIC)) { String path = (String) event.getProperty(FIELD_PATH); if (!ignore(path) && !immediateIgnoreCache.containsKey(path)) { ImmediateIndexingHandler handler = getHandler(repositorySession, path, this.immediateIndexers, this.immediateIgnoreCache); List<SolrInputDocument> outputDocs = Lists.newArrayList(); Collection<SolrInputDocument> docs = handler.getImmediateDocuments(repositorySession, event); for (SolrInputDocument doc : docs) { // check the fields of the returned docs to make sure they contain atleast 1 // field that is not a system property. this is not to filter out any system // properties but to make sure there are more things to index than just system // properties. if (!SYSTEM_PROPERTIES.containsAll(doc.getFieldNames())) { try { addDefaultFields(doc, repositorySession); outputDocs.add(doc); } catch (StorageClientException e) { LOGGER.warn("Failed to index {} cause: {} ", path, e.getMessage()); } } } return outputDocs; } else { LOGGER.debug("Ignored action at path:{} require on {} ", path, event); } } else { LOGGER.debug("No update action require on {} ", event); } return ImmutableList.of(); }
public void removeImmediateHandler(String key, ImmediateIndexingHandler handler) { if (handler.equals(immediateIndexers.get(key))) { immediateIndexers.remove(key); } }