@Override public void indexSpellCheckerDictionaries(SearchContext searchContext) throws SearchException { try { for (String languageId : _SUPPORTED_LOCALES) { indexKeywords( searchContext, languageId, PropsKeys.INDEX_SEARCH_SPELL_CHECKER_DICTIONARY, Field.SPELL_CHECK_WORD, SuggestionConstants.TYPE_SPELL_CHECKER, 0); } } catch (Exception e) { throw new SearchException(e); } }
@Around(value = "execution(* se.vgregion.service.innovationsslussen.idea.IdeaServiceImpl.remove(..))", argNames = "idea") public void indexRemoveIdea(ProceedingJoinPoint joinPoint){ Object[] args = joinPoint.getArgs(); if (args.length > 0){ Object arg1 = args[0]; if (arg1.getClass().equals(Idea.class)){ Idea idea = (Idea) arg1; try { Indexer indexer = IndexerRegistryUtil.getIndexer(IDEA_CLASS); indexer.delete(idea); } catch (SearchException e) { e.printStackTrace(); } try { joinPoint.proceed(); } catch (Throwable throwable) { throwable.printStackTrace(); } }else { try { joinPoint.proceed(); } catch (Throwable throwable) { throwable.printStackTrace(); } } } }
@AfterReturning( pointcut = "execution(* se.vgregion.service.innovationsslussen.idea.IdeaServiceImpl.addIdea(..))" , returning= "result") public void indexAddIdea(JoinPoint joinPoint, Object result){ if (result.getClass().equals(Idea.class)){ try { Idea idea = (Idea) result; Indexer indexer = IndexerRegistryUtil.getIndexer(IDEA_CLASS); indexer.reindex(idea); } catch (SearchException e) { e.printStackTrace(); } } }
@Override public void delete(T object) throws SearchException { if (object == null) { return; } try { doDelete(object); } catch (SearchException se) { throw se; } catch (Exception e) { throw new SearchException(e); } }
@AfterReturning( pointcut = "execution(* se.vgregion.service.innovationsslussen.idea.IdeaServiceImpl.addLike(..))" , returning= "result") public void indexAddLike(JoinPoint joinPoint, Object result){ try { Idea idea = (Idea) result; Indexer indexer = IndexerRegistryUtil.getIndexer(IDEA_CLASS); indexer.reindex(idea); } catch (SearchException e) { e.printStackTrace(); } }
@Override public void indexQuerySuggestionDictionaries(SearchContext searchContext) throws SearchException { try { for (String languageId : _SUPPORTED_LOCALES) { indexKeywords( searchContext, languageId, PropsKeys.INDEX_SEARCH_QUERY_SUGGESTION_DICTIONARY, Field.KEYWORD_SEARCH, SuggestionConstants.TYPE_QUERY_SUGGESTION, _querySuggestionMaxNGramLength); } } catch (Exception e) { throw new SearchException(e); } }
@AfterReturning( pointcut = "execution(* se.vgregion.service.innovationsslussen.idea.IdeaService.addMBMessage(..))" , returning= "result") public void indexAddComment(JoinPoint joinPoint, Object result){ try { Idea idea = (Idea) result; Indexer indexer = IndexerRegistryUtil.getIndexer(IDEA_CLASS); indexer.reindex(idea); } catch (SearchException e) { e.printStackTrace(); } }
@Override public void indexSpellCheckerDictionary(SearchContext searchContext) throws SearchException { try { indexKeywords( searchContext, searchContext.getLanguageId(), PropsKeys.INDEX_SEARCH_SPELL_CHECKER_DICTIONARY, Field.SPELL_CHECK_WORD, SuggestionConstants.TYPE_SPELL_CHECKER, 0); } catch (Exception e) { throw new SearchException(e); } }
@AfterReturning( pointcut = "execution(* se.vgregion.service.innovationsslussen.idea.IdeaServiceImpl.updateFromBarium(..))" , returning= "result") public void indexUpdateIdea(JoinPoint joinPoint, Object result){ if(result != null){ if (result.getClass().equals(Idea.class)){ try { Idea idea = (Idea) result; Indexer indexer = IndexerRegistryUtil.getIndexer(IDEA_CLASS); indexer.reindex(idea); } catch (SearchException e) { e.printStackTrace(); } } else if(result.getClass().equals(IdeaService.UpdateFromBariumResult.class)) { try { IdeaService.UpdateFromBariumResult br = (IdeaService.UpdateFromBariumResult) result; Indexer indexer = IndexerRegistryUtil.getIndexer(IDEA_CLASS); indexer.reindex(((IdeaService.UpdateFromBariumResult) result).getNewIdea()); } catch (SearchException e) { e.printStackTrace(); } } } }
@Override public void delete(long companyId, String uid) throws SearchException { try { IndexWriterHelperUtil.deleteDocument( getSearchEngineId(), companyId, uid, _commitImmediately); } catch (SearchException se) { throw se; } catch (Exception e) { throw new SearchException(e); } }
@AfterReturning( pointcut = "execution(* se.vgregion.service.innovationsslussen.idea.IdeaServiceImpl.removeLike(..))" , returning= "result") public void indexRemoveLike(JoinPoint joinPoint, Object result){ try { Idea idea = (Idea) result; Indexer indexer = IndexerRegistryUtil.getIndexer(IDEA_CLASS); indexer.reindex(idea); } catch (SearchException e) { e.printStackTrace(); } }
@Override public void indexQuerySuggestionDictionary(SearchContext searchContext) throws SearchException { try { indexKeywords( searchContext, searchContext.getLanguageId(), PropsKeys.INDEX_SEARCH_QUERY_SUGGESTION_DICTIONARY, Field.KEYWORD_SEARCH, SuggestionConstants.TYPE_QUERY_SUGGESTION, _querySuggestionMaxNGramLength); } catch (Exception e) { throw new SearchException(e); } }
@Override public Summary getSummary( Document document, String snippet, PortletRequest portletRequest, PortletResponse portletResponse) throws SearchException { try { Locale locale = getLocale(portletRequest); Summary summary = doGetSummary( document, locale, snippet, portletRequest, portletResponse); for (IndexerPostProcessor indexerPostProcessor : _indexerPostProcessors) { indexerPostProcessor.postProcessSummary( summary, document, locale, snippet); } return summary; } catch (SearchException se) { throw se; } catch (Exception e) { throw new SearchException(e); } }
throw new SearchException(e.getMessage(), e);
@Override public void reindex(T object) throws SearchException { try { if (IndexWriterHelperUtil.isIndexReadOnly() || IndexWriterHelperUtil.isIndexReadOnly(getClassName()) || !isIndexerEnabled()) { return; } if (object == null) { return; } doReindex(object); } catch (SearchException se) { throw se; } catch (Exception e) { throw new SearchException(e); } }
@Override public Document getDocument(T object) throws SearchException { try { Document document = doGetDocument(object); for (IndexerPostProcessor indexerPostProcessor : _indexerPostProcessors) { indexerPostProcessor.postProcessDocument(document, object); } if (document == null) { return null; } Map<String, Field> fields = document.getFields(); Field groupIdField = fields.get(Field.GROUP_ID); if (groupIdField != null) { long groupId = GetterUtil.getLong(groupIdField.getValue()); addStagingGroupKeyword(document, groupId); } return document; } catch (SearchException se) { throw se; } catch (Exception e) { throw new SearchException(e); } }
@Override public void reindex(String className, long classPK) throws SearchException { try { if (IndexWriterHelperUtil.isIndexReadOnly() || IndexWriterHelperUtil.isIndexReadOnly(getClassName()) || !isIndexerEnabled() || (classPK <= 0)) { return; } doReindex(className, classPK); } catch (NoSuchModelException nsme) { if (_log.isWarnEnabled()) { _log.warn( StringBundler.concat( "Unable to index ", className, " ", String.valueOf(classPK)), nsme); } } catch (SearchException se) { throw se; } catch (Exception e) { throw new SearchException(e); } }
@Override public void reindex(String[] ids) throws SearchException { long companyThreadLocalCompanyId = CompanyThreadLocal.getCompanyId(); try { if (IndexWriterHelperUtil.isIndexReadOnly() || IndexWriterHelperUtil.isIndexReadOnly(getClassName()) || !isIndexerEnabled()) { return; } if (ids.length > 0) { long companyId = GetterUtil.getLong(ids[0]); CompanyThreadLocal.setCompanyId(companyId); } doReindex(ids); } catch (SearchException se) { throw se; } catch (Exception e) { throw new SearchException(e); } finally { CompanyThreadLocal.setCompanyId(companyThreadLocalCompanyId); } }
@Override public String search(HttpServletRequest request, String url) throws SearchException { try { long userId = PortalUtil.getUserId(request); if (userId == 0) { long companyId = PortalUtil.getCompanyId(request); userId = UserLocalServiceUtil.getDefaultUserId(companyId); } String keywords = GetterUtil.getString( HttpUtil.getParameter(url, "keywords", false)); int startPage = GetterUtil.getInteger( HttpUtil.getParameter(url, "p", false), 1); int itemsPerPage = GetterUtil.getInteger( HttpUtil.getParameter(url, "c", false), SearchContainer.DEFAULT_DELTA); String format = GetterUtil.getString( HttpUtil.getParameter(url, "format", false)); return search( request, userId, keywords, startPage, itemsPerPage, format); } catch (SearchException se) { throw se; } catch (Exception e) { throw new SearchException(e); } }