/** * Returns the available search indexes of this installation. * * @return the available search indexes of this installation */ private List<CmsSearchIndexSource> searchIndexSources() { CmsSearchManager manager = OpenCms.getSearchManager(); return new LinkedList<CmsSearchIndexSource>(manager.getSearchIndexSources().values()); } }
/** * 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); }
/** * @see org.opencms.workplace.list.A_CmsListDialog#getListItems() */ @Override protected List<CmsListItem> getListItems() { List<CmsListItem> result = new ArrayList<CmsListItem>(); // get content // cannot use the returned map: unmodifyable List<CmsSearchIndexSource> allSources = new LinkedList<CmsSearchIndexSource>( OpenCms.getSearchManager().getSearchIndexSources().values()); allSources.removeAll(searchIndexSources()); Iterator<CmsSearchIndexSource> itSources = allSources.iterator(); CmsSearchIndexSource source; while (itSources.hasNext()) { source = itSources.next(); CmsListItem item = getList().newItem(source.getName()); item.set(LIST_COLUMN_NAME, source.getName()); item.set(LIST_COLUMN_INDEXER, source.getIndexer().getClass().getName()); result.add(item); } return result; }
/** * Creates a "dummy" search index that is not linked to the search manager and has * a <code>null</code> name property that will be used for being filled with * the widget bean technology. <p> * * @return a "dummy" search index that is not linked to the search manager and has * a <code>null</code> name property that will be used for being filled with * the widget bean technology */ private CmsSearchIndex createDummySearchIndex() { CmsSearchIndex result = new CmsSearchIndex(); result.setLocale(Locale.ENGLISH); result.setProject("Online"); result.setRebuildMode("auto"); // find default source Map<String, CmsSearchIndexSource> sources = m_searchManager.getSearchIndexSources(); if (sources.isEmpty()) { CmsSearchIndexSource source = createDummyIndexSource(); sources.put(source.getName(), source); } result.addSourceName(sources.keySet().iterator().next()); return result; } }
/** * 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; }
/** * 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; }
List indexSources = new ArrayList(m_searchManager.getSearchIndexSources().values()); Iterator indexsourceIterator = indexSources.iterator(); while (indexsourceIterator.hasNext()) {
for (CmsSearchIndexSource searchIndexSource : m_searchManager.getSearchIndexSources().values()) {