@Override
  protected Summary doGetSummary(
      Document document,
      Locale locale,
      String snippet,
      PortletURL portletURL,
      PortletRequest portletRequest,
      PortletResponse portletResponse) {

    LiferayPortletURL liferayPortletURL = (LiferayPortletURL) portletURL;

    liferayPortletURL.setLifecycle(PortletRequest.ACTION_PHASE);

    try {
      liferayPortletURL.setWindowState(LiferayWindowState.EXCLUSIVE);
    } catch (WindowStateException wse) {
    }

    String fileEntryId = document.get(Field.ENTRY_CLASS_PK);

    portletURL.setParameter("struts_action", "/document_library/get_file");
    portletURL.setParameter("fileEntryId", fileEntryId);

    Summary summary = createSummary(document, Field.TITLE, Field.CONTENT);

    summary.setMaxContentLength(200);
    summary.setPortletURL(portletURL);

    return summary;
  }
  @Override
  protected Summary doGetSummary(
      Document document, Locale locale, String snippet, PortletURL portletURL) {

    LiferayPortletURL liferayPortletURL = (LiferayPortletURL) portletURL;

    liferayPortletURL.setLifecycle(PortletRequest.ACTION_PHASE);

    try {
      liferayPortletURL.setWindowState(LiferayWindowState.EXCLUSIVE);
    } catch (WindowStateException wse) {
    }

    String folderId = document.get(Field.ENTRY_CLASS_PK);

    portletURL.setParameter("struts_action", "/journal/view");
    portletURL.setParameter("folderId", folderId);

    Summary summary = createSummary(document, Field.TITLE, Field.DESCRIPTION);

    summary.setMaxContentLength(200);
    summary.setPortletURL(portletURL);

    return summary;
  }
Пример #3
0
  @Override
  public Summary getSummary(
      Indexer indexer, Document document, Locale locale, String snippet, PortletURL portletURL)
      throws SearchException {

    Summary summary = super.getSummary(indexer, document, locale, snippet, portletURL);

    portletURL = summary.getPortletURL();

    portletURL.setParameter("struts_action", "/directory/view_user");

    return summary;
  }
  @Override
  protected Summary doGetSummary(
      Document document,
      Locale locale,
      String snippet,
      PortletRequest portletRequest,
      PortletResponse portletResponse) {

    Summary summary = createSummary(document, Field.TITLE, Field.CONTENT);

    summary.setMaxContentLength(200);

    return summary;
  }
  @Override
  protected Summary doGetSummary(
      Document document, Locale locale, String snippet, PortletURL portletURL) {

    String entryId = document.get(Field.ENTRY_CLASS_PK);

    portletURL.setParameter("struts_action", "/bookmarks/view_entry");
    portletURL.setParameter("entryId", entryId);

    Summary summary = createSummary(document, Field.TITLE, Field.URL);

    summary.setPortletURL(portletURL);

    return summary;
  }
  @Override
  protected Summary doGetSummary(
      Document document,
      Locale locale,
      String snippet,
      PortletRequest portletRequest,
      PortletResponse portletResponse) {

    String calendarId = document.get(Field.ENTRY_CLASS_PK);

    Summary summary = createSummary(document, Field.NAME, Field.DESCRIPTION);

    summary.setMaxContentLength(200);

    return summary;
  }
  @Override
  protected Summary doGetSummary(
      Document document,
      Locale locale,
      String snippet,
      PortletRequest portletRequest,
      PortletResponse portletResponse) {

    Locale defaultLocale = LocaleUtil.fromLanguageId(document.get("defaultLanguageId"));

    Locale snippetLocale = getSnippetLocale(document, locale);

    String localizedTitleName = DocumentImpl.getLocalizedName(locale, Field.TITLE);

    if ((snippetLocale == null) && (document.getField(localizedTitleName) == null)) {

      snippetLocale = defaultLocale;
    } else {
      snippetLocale = locale;
    }

    String title =
        document.get(
            snippetLocale, Field.SNIPPET + StringPool.UNDERLINE + Field.TITLE, Field.TITLE);

    if (Validator.isNull(title) && !snippetLocale.equals(defaultLocale)) {
      title =
          document.get(
              defaultLocale, Field.SNIPPET + StringPool.UNDERLINE + Field.TITLE, Field.TITLE);
    }

    String content = getDDMContentSummary(document, snippetLocale, portletRequest, portletResponse);

    if (Validator.isNull(content) && !snippetLocale.equals(defaultLocale)) {
      content = getDDMContentSummary(document, defaultLocale, portletRequest, portletResponse);
    }

    Summary summary = new Summary(snippetLocale, title, content);

    summary.setMaxContentLength(200);

    return summary;
  }
  @Override
  protected Summary doGetSummary(
      Document document,
      Locale locale,
      String snippet,
      PortletURL portletURL,
      PortletRequest portletRequest,
      PortletResponse portletResponse)
      throws Exception {

    String exportImportConfigurationId = document.get(Field.ENTRY_CLASS_PK);

    Summary summary = createSummary(document, Field.TITLE, Field.DESCRIPTION);

    portletURL.setParameter("struts_action", "/layouts_admin/edit_export_configuration");
    portletURL.setParameter("exportImportConfigurationId", exportImportConfigurationId);

    summary.setPortletURL(portletURL);

    return summary;
  }
  public String search(
      HttpServletRequest request,
      long groupId,
      long userId,
      String keywords,
      int startPage,
      int itemsPerPage,
      String format)
      throws SearchException {

    try {
      ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

      int start = (startPage * itemsPerPage) - itemsPerPage;
      int end = startPage * itemsPerPage;

      Hits results =
          CompanyLocalServiceUtil.search(themeDisplay.getCompanyId(), userId, keywords, start, end);

      String[] queryTerms = results.getQueryTerms();

      int total = results.getLength();

      Object[] values =
          addSearchResults(
              queryTerms,
              keywords,
              startPage,
              itemsPerPage,
              total,
              start,
              "Liferay Portal Search: " + keywords,
              SEARCH_PATH,
              format,
              themeDisplay);

      com.liferay.portal.kernel.xml.Document doc =
          (com.liferay.portal.kernel.xml.Document) values[0];
      Element root = (Element) values[1];

      for (int i = 0; i < results.getDocs().length; i++) {
        Document result = results.doc(i);

        String portletId = result.get(Field.PORTLET_ID);

        Portlet portlet =
            PortletLocalServiceUtil.getPortletById(themeDisplay.getCompanyId(), portletId);

        if (portlet == null) {
          continue;
        }

        String portletTitle = PortalUtil.getPortletTitle(portletId, themeDisplay.getUser());

        long resultGroupId = GetterUtil.getLong(result.get(Field.GROUP_ID));

        String entryClassName = GetterUtil.getString(result.get(Field.ENTRY_CLASS_NAME));

        long entryClassPK = GetterUtil.getLong(result.get(Field.ENTRY_CLASS_PK));

        String title = StringPool.BLANK;

        PortletURL portletURL = getPortletURL(request, portletId, resultGroupId);

        String url = portletURL.toString();

        Date modifedDate = result.getDate(Field.MODIFIED);

        String content = StringPool.BLANK;

        if (Validator.isNotNull(portlet.getIndexerClass())) {
          Indexer indexer = (Indexer) InstancePool.get(portlet.getIndexerClass());

          String snippet = results.snippet(i);

          Summary summary = indexer.getSummary(result, snippet, portletURL);

          title = summary.getTitle();
          url = portletURL.toString();
          content = summary.getContent();

          if (portlet.getPortletId().equals(PortletKeys.JOURNAL)) {
            url = getJournalURL(themeDisplay, resultGroupId, result);
          }
        }

        double score = results.score(i);

        addSearchResult(
            root,
            resultGroupId,
            entryClassName,
            entryClassPK,
            portletTitle + " " + CharPool.RAQUO + " " + title,
            url,
            modifedDate,
            content,
            score,
            format);
      }

      if (_log.isDebugEnabled()) {
        _log.debug("Return\n" + doc.asXML());
      }

      return doc.asXML();

    } catch (Exception e) {
      throw new SearchException(e);
    }
  }