/** * Returns the Solr index configured with the given name.<p> * The index must exist, otherwise <code>null</code> is returned. * * @param indexName then name of the requested Solr index * @return the Solr index configured with the given name */ public CmsSolrIndex getIndexSolr(String indexName) { CmsSearchIndex index = getIndex(indexName); if (index instanceof CmsSolrIndex) { return (CmsSolrIndex)index; } return null; }
/** * @see org.opencms.workplace.CmsWidgetDialog#actionCommit() */ @Override public void actionCommit() { List<Throwable> errors = new ArrayList<Throwable>(); try { // if new create it first if (m_searchManager.getFieldConfiguration(m_fieldconfiguration.getName()) == null) { m_searchManager.addFieldConfiguration(m_fieldconfiguration); } if (checkWriteConfiguration()) { writeConfiguration(); } } catch (Throwable t) { errors.add(t); } // set the list of errors to display when saving failed setCommitErrors(errors); }
/** * Returns the locale widget configuration.<p> * * @return the locale widget configuration */ private List<CmsSelectWidgetOption> getLocaleWidgetConfiguration() { List<CmsSelectWidgetOption> result = new ArrayList<CmsSelectWidgetOption>(); for (Locale locale : m_searchManager.getAnalyzers().keySet()) { CmsSelectWidgetOption option = new CmsSelectWidgetOption( locale.toString(), locale.equals(getSearchIndexIndex().getLocale())); result.add(option); } return result; }
/** * Rebuilds (if required creates) the index with the given name.<p> * * @param indexName the name of the index to rebuild * @param report the report object to write messages (or <code>null</code>) * * @throws CmsException if something goes wrong */ public synchronized void rebuildIndex(String indexName, I_CmsReport report) throws CmsException { // get the search index by name CmsSearchIndex index = getIndex(indexName); // update the index updateIndex(index, report, null); // clean up the extraction result cache cleanExtractionCache(); }
/** * Returns all Solr index.<p> * * @return all Solr indexes */ public List<CmsSolrIndex> getAllSolrIndexes() { List<CmsSolrIndex> result = new ArrayList<CmsSolrIndex>(); for (String indexName : getIndexNames()) { CmsSolrIndex index = getIndexSolr(indexName); if (index != null) { result.add(index); } } return result; }
/** * Commits the edited search index to the search manager.<p> */ @Override public void actionCommit() { List<Throwable> errors = new ArrayList<Throwable>(); try { // if new create it first if (!m_searchManager.getSearchIndexSources().keySet().contains(m_indexsource.getName())) { m_searchManager.addSearchIndexSource(m_indexsource); } writeConfiguration(); } catch (Throwable t) { errors.add(t); } // set the list of errors to display when saving failed setCommitErrors(errors); }
if (m_searchManager.getSolrServerConfiguration() != null) { Element solr = searchElement.addElement(N_SOLR); CmsSolrConfiguration conf = m_searchManager.getSolrServerConfiguration(); solr.addAttribute(A_ENABLED, new Boolean(conf.isEnabled()).toString()); if (conf.getServerUrl() != null) { searchElement.addElement(N_DIRECTORY).addText(m_searchManager.getDirectory()); searchElement.addElement(N_TIMEOUT).addText(String.valueOf(m_searchManager.getTimeout())); String.valueOf(m_searchManager.getOfflineUpdateFrequency())); searchElement.addElement(N_MAX_INDEX_WAIT_TIME).addText(String.valueOf(m_searchManager.getMaxIndexWaitTime())); if (m_searchManager.getForceunlock() != null) { searchElement.addElement(N_FORCEUNLOCK).addText(m_searchManager.getForceunlock().toString()); searchElement.addElement(N_EXCERPT).addText(String.valueOf(m_searchManager.getMaxExcerptLength())); String.valueOf(m_searchManager.getExtractionCacheMaxAge())); String.valueOf(m_searchManager.getMaxModificationsBeforeCommit())); searchElement.addElement(N_HIGHLIGHTER).addText(m_searchManager.getHighlighter().getClass().getName()); for (CmsSearchDocumentType currSearchDocType : m_searchManager.getDocumentTypeConfigs()) { ArrayList<Locale> analyzerLocaleList = new ArrayList<Locale>(m_searchManager.getAnalyzers().keySet());
searchElement.addElement(N_DIRECTORY).addText(m_searchManager.getDirectory()); searchElement.addElement(N_TIMEOUT).addText(String.valueOf(m_searchManager.getTimeout())); String.valueOf(m_searchManager.getOfflineUpdateFrequency())); if (m_searchManager.getForceunlock() != null) { searchElement.addElement(N_FORCEUNLOCK).addText(m_searchManager.getForceunlock().toString()); searchElement.addElement(N_EXCERPT).addText(String.valueOf(m_searchManager.getMaxExcerptLength())); String.valueOf(m_searchManager.getExtractionCacheMaxAge())); String.valueOf(m_searchManager.getMaxModificationsBeforeCommit())); searchElement.addElement(N_HIGHLIGHTER).addText(m_searchManager.getHighlighter().getClass().getName()); List docTypeKeyList = m_searchManager.getDocumentTypeConfigs(); Iterator docTypeIterator = docTypeKeyList.iterator(); while (docTypeIterator.hasNext()) { List analyzerLocaleList = new ArrayList(m_searchManager.getAnalyzers().keySet()); CmsSearchAnalyzer searchAnalyzer = m_searchManager.getCmsSearchAnalyzer((Locale)analyzersLocaleInterator.next()); Iterator indexIterator = m_searchManager.getSearchIndexes().iterator(); while (indexIterator.hasNext()) { CmsSearchIndex searchIndex = (CmsSearchIndex)indexIterator.next();
/** * Removes all indexes included in the given list (which must contain the name of an index to remove).<p> * * @param indexNames the names of the index to remove */ public void removeSearchIndexes(List<String> indexNames) { Iterator<String> i = indexNames.iterator(); while (i.hasNext()) { String indexName = i.next(); // get the search index by name CmsSearchIndex index = getIndex(indexName); if (index != null) { // remove the index removeSearchIndex(index); } else { if (LOG.isWarnEnabled()) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_NO_INDEX_WITH_NAME_1, indexName)); } } } }
for (int i = 0; i < indexNames.length; i++) { if (manager.getIndex(indexNames[i]) != null) { updateList.add(indexNames[i]); } else { manager.rebuildAllIndexes(report); } else { manager.rebuildIndexes(updateList, report);
OpenCms.getSearchManager().getDirectory() + "/" + m_name); indexSource = OpenCms.getSearchManager().getIndexSource(sourceName); m_sources.add(indexSource); m_fieldConfiguration = OpenCms.getSearchManager().getFieldConfiguration(m_fieldConfigurationName); if (m_fieldConfiguration == null) { Analyzer baseAnalyzer = OpenCms.getSearchManager().getAnalyzer(getLocale()); setAnalyzer(m_fieldConfiguration.getAnalyzer(baseAnalyzer));
CmsSearchIndexSource idxSource = searchManager.getIndexSource(idxSourceName); while (itDocTypes.hasNext()) { docType = searchManager.getDocumentTypeConfig(itDocTypes.next());
/** * Fills details about resource paths of the index source into the given item. <p> * * @param item the list item to fill * @param detailId the id for the detail to fill * */ private void fillDetailResources(CmsListItem item, String detailId) { CmsSearchManager searchManager = OpenCms.getSearchManager(); StringBuffer html = new StringBuffer(); // search for the corresponding CmsSearchIndexSource: String idxSourceName = (String)item.get(LIST_COLUMN_NAME); CmsSearchIndexSource idxSource = searchManager.getIndexSource(idxSourceName); // get the index sources resource strings List<String> resources = idxSource.getResourcesNames(); // output of found index sources Iterator<String> itResources = resources.iterator(); html.append("<ul>\n"); while (itResources.hasNext()) { html.append(" <li>\n").append(" ").append(itResources.next()).append("\n"); html.append(" </li>"); } html.append("</ul>\n"); item.set(detailId, html.toString()); }
/** * @see org.opencms.workplace.list.A_CmsListDialog#validateParamaters() */ @Override protected void validateParamaters() throws Exception { // will throw NPE if something wrong OpenCms.getSearchManager().getFieldConfiguration(getParamFieldconfiguration()).getFields(); }
indexSource = OpenCms.getSearchManager().getIndexSource(sourceName); m_sources.add(indexSource); m_fieldConfiguration = OpenCms.getSearchManager().getFieldConfiguration(m_fieldConfigurationName); if (m_fieldConfiguration == null) { Analyzer baseAnalyzer = OpenCms.getSearchManager().getAnalyzer(getLocale());
/** * Sets the logical key/name of this search index source.<p> * * @param name the logical key/name of this search index source * * @throws CmsIllegalArgumentException if argument name is null, an empty or whitespace-only Strings * or already used for another indexsource's name. */ public void setName(String name) throws CmsIllegalArgumentException { if (CmsStringUtil.isEmptyOrWhitespaceOnly(name)) { throw new CmsIllegalArgumentException( Messages.get().container(Messages.ERR_INDEXSOURCE_CREATE_MISSING_NAME_0)); } // already used? Don't test this at xml-configuration time (no manager) if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_2_INITIALIZING) { CmsSearchManager mngr = OpenCms.getSearchManager(); // don't test this if the indexsource is not new (widget invokes setName even if it was not changed) if (mngr.getIndexSource(name) != this) { if (mngr.getSearchIndexSources().keySet().contains(name)) { throw new CmsIllegalArgumentException( Messages.get().container(Messages.ERR_INDEXSOURCE_CREATE_INVALID_NAME_1, name)); } } } m_name = name; }
CmsSearchIndexSource indexsource = manager.getIndexSource(getParamIndexsource()); List<CmsSearchDocumentType> result; if (indexsource != null) { List<String> systemDoctypeNames = new ArrayList<String>(); Iterator<CmsSearchDocumentType> itDocTypes = manager.getDocumentTypeConfigs().iterator(); while (itDocTypes.hasNext()) { CmsSearchDocumentType docType = itDocTypes.next(); doctypename = it.next(); if (doctypename != null) { doctype = manager.getDocumentTypeConfig(doctypename); if (doctype != null) { result.add(doctype);
/** * Sets the rebuild mode for the requested index. Allowing to disable indexing during module import.<p> * This setting will not be written to the XML configuration file and will only take effect within the current shell instance.<p> * * @param searchIndex the search index * @param mode the rebuild mode to set */ public void setIndexRebuildMode(String searchIndex, String mode) { CmsSearchIndex index = OpenCms.getSearchManager().getIndex(searchIndex); if (index != null) { index.setRebuildMode(mode); // required for this setting to take effect OpenCms.getSearchManager().initOfflineIndexes(); } }
try { updateIndex(searchIndex, report, null); } catch (CmsException e) { container = new CmsMessageContainer( cleanExtractionCache(); if (container != null) {
/** * Commits the edited search index to the search manager.<p> */ @Override public void actionCommit() { List<Throwable> errors = new ArrayList<Throwable>(); try { // if new create it first if (!m_searchManager.getSearchIndexesAll().contains(m_index)) { // check the index name for invalid characters CmsStringUtil.checkName( m_index.getName(), INDEX_NAME_CONSTRAINTS, Messages.ERR_SEARCHINDEX_BAD_INDEXNAME_4, Messages.get()); // empty or null name and uniqueness check in add method m_searchManager.addSearchIndex(m_index); } // check if field configuration has been updated, if thus set field configuration to the now used if (!m_index.getFieldConfigurationName().equals(m_index.getFieldConfiguration().getName())) { m_index.setFieldConfiguration( m_searchManager.getFieldConfiguration(m_index.getFieldConfigurationName())); } writeConfiguration(); } catch (Throwable t) { errors.add(t); } // set the list of errors to display when saving failed setCommitErrors(errors); }