private PythonUtils getPyUtils() throws IndexerException { if (pyUtils == null) { try { pyUtils = new PythonUtils(config); } catch (PluginException ex) { throw new IndexerException(ex); } } return pyUtils; }
/***** * Send a message to the given message queue * * @param messageQueue to connect to * @param message to send * @return boolean flag for success */ public boolean sendMessage(String messageQueue, String message) { try { // log.debug("Queuing '{}' to '{}'", msg, name); sendMessage(getDestination(messageQueue, true), message); return true; } catch (JMSException jmse) { log.error("Failed to queue message", jmse); return false; } }
/** * Shutdown the plugin * * @throws PluginException if any errors occur during shutdown */ @Override public void shutdown() throws PluginException { getPyUtils().shutdown(); }
/** * Send the document to buffer directly * * @param index * @param fields */ public void sendIndexToBuffer(String index, Map<String, List<String>> fields) { String doc = pyUtils.solrDocument(fields); addToBuffer(index, doc); }
/***** * Generate a Solr document from a map of provided key/value pairs. * * @param fields : The lists of evaluated fields for the document * @return String : The generated XML snippet */ public String solrDocument(Map<String, List<String>> fields) { StringBuffer resultBuffer = new StringBuffer("<doc>"); for (Entry<String, List<String>> entry : fields.entrySet()) { for (String value : entry.getValue()) { resultBuffer.append(solrField(entry.getKey(), value)); } } resultBuffer.append("</doc>"); return resultBuffer.toString(); }
/***** * Parse an XML document stored in a payload * * @param payload holding the document * @return Document object after parsing */ public Document getXmlDocument(Payload payload) { try { Document doc = getXmlDocument(payload.open()); payload.close(); return doc; } catch (StorageException ex) { log.error("Failed to access payload", ex); } return null; }
/***** * Parse RDF data stored in a payload * * @param payload containing the data * @return Model object after parsing */ public Model getRdfModel(Payload payload) { try { Model model = getRdfModel(payload.open()); payload.close(); return model; } catch (StorageException ioe) { log.info("Failed to read payload stream", ioe); } return null; }
return getPyUtils().solrDocument(fields); } catch (Exception e) { throw new RuleException(e);