コード例 #1
0
  @Override
  public void postProcessContextQuery(BooleanQuery contextQuery, SearchContext searchContext)
      throws Exception {

    addStatus(contextQuery, searchContext);

    if (searchContext.isIncludeAttachments()) {
      addRelatedClassNames(contextQuery, searchContext);
    }

    contextQuery.addRequiredTerm(Field.HIDDEN, searchContext.isIncludeAttachments());

    addSearchClassTypeIds(contextQuery, searchContext);

    String ddmStructureFieldName = (String) searchContext.getAttribute("ddmStructureFieldName");
    Serializable ddmStructureFieldValue = searchContext.getAttribute("ddmStructureFieldValue");

    if (Validator.isNotNull(ddmStructureFieldName) && Validator.isNotNull(ddmStructureFieldValue)) {

      String[] ddmStructureFieldNameParts =
          StringUtil.split(ddmStructureFieldName, StringPool.SLASH);

      DDMStructure structure =
          DDMStructureLocalServiceUtil.getStructure(
              GetterUtil.getLong(ddmStructureFieldNameParts[1]));

      String fieldName =
          StringUtil.replaceLast(
              ddmStructureFieldNameParts[2],
              StringPool.UNDERLINE.concat(LocaleUtil.toLanguageId(searchContext.getLocale())),
              StringPool.BLANK);

      try {
        ddmStructureFieldValue =
            DDMUtil.getIndexedFieldValue(ddmStructureFieldValue, structure.getFieldType(fieldName));
      } catch (StructureFieldException sfe) {
      }

      contextQuery.addRequiredTerm(
          ddmStructureFieldName, StringPool.QUOTE + ddmStructureFieldValue + StringPool.QUOTE);
    }

    String[] mimeTypes = (String[]) searchContext.getAttribute("mimeTypes");

    if (ArrayUtil.isNotEmpty(mimeTypes)) {
      BooleanQuery mimeTypesQuery = BooleanQueryFactoryUtil.create(searchContext);

      for (String mimeType : mimeTypes) {
        mimeTypesQuery.addTerm(
            "mimeType", StringUtil.replace(mimeType, CharPool.FORWARD_SLASH, CharPool.UNDERLINE));
      }

      contextQuery.add(mimeTypesQuery, BooleanClauseOccur.MUST);
    }
  }
コード例 #2
0
  public static List<BreadcrumbEntry> getPortletBreadcrumbEntries(HttpServletRequest request) {

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

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    String name = WebKeys.PORTLET_BREADCRUMBS;

    List<BreadcrumbEntry> breadcrumbEntries = (List<BreadcrumbEntry>) request.getAttribute(name);

    if (Validator.isNotNull(portletDisplay.getId())
        && !portletDisplay.isFocused()
        && !Validator.equals(
            portletDisplay.getId(),
            PortletProviderUtil.getPortletId(
                BreadcrumbEntry.class.getName(), PortletProvider.Action.VIEW))) {

      name = name.concat(StringPool.UNDERLINE.concat(portletDisplay.getId()));

      List<BreadcrumbEntry> portletBreadcrumbEntries =
          (List<BreadcrumbEntry>) request.getAttribute(name);

      if (portletBreadcrumbEntries != null) {
        breadcrumbEntries = portletBreadcrumbEntries;
      }
    }

    if (breadcrumbEntries == null) {
      return Collections.emptyList();
    }

    for (int i = 0; i < breadcrumbEntries.size() - 1; i++) {
      BreadcrumbEntry portletBreadcrumbEntry = breadcrumbEntries.get(i);

      String url = portletBreadcrumbEntry.getURL();

      if (Validator.isNotNull(url) && !CookieKeys.hasSessionId(request)) {
        HttpSession session = request.getSession();

        portletBreadcrumbEntry.setURL(PortalUtil.getURLWithSessionId(url, session.getId()));
      }
    }

    return breadcrumbEntries;
  }
コード例 #3
0
  @Override
  public void postProcessContextBooleanFilter(
      BooleanFilter contextBooleanFilter, SearchContext searchContext) throws Exception {

    addStatus(contextBooleanFilter, searchContext);

    if (searchContext.isIncludeAttachments()) {
      addRelatedClassNames(contextBooleanFilter, searchContext);
    }

    if (ArrayUtil.contains(
        searchContext.getFolderIds(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID)) {

      contextBooleanFilter.addRequiredTerm(Field.HIDDEN, searchContext.isIncludeAttachments());
    }

    addSearchClassTypeIds(contextBooleanFilter, searchContext);

    String ddmStructureFieldName = (String) searchContext.getAttribute("ddmStructureFieldName");
    Serializable ddmStructureFieldValue = searchContext.getAttribute("ddmStructureFieldValue");

    if (Validator.isNotNull(ddmStructureFieldName) && Validator.isNotNull(ddmStructureFieldValue)) {

      String[] ddmStructureFieldNameParts =
          StringUtil.split(ddmStructureFieldName, DDMIndexer.DDM_FIELD_SEPARATOR);

      DDMStructure structure =
          DDMStructureLocalServiceUtil.getStructure(
              GetterUtil.getLong(ddmStructureFieldNameParts[1]));

      String fieldName =
          StringUtil.replaceLast(
              ddmStructureFieldNameParts[2],
              StringPool.UNDERLINE.concat(LocaleUtil.toLanguageId(searchContext.getLocale())),
              StringPool.BLANK);

      try {
        ddmStructureFieldValue =
            DDMUtil.getIndexedFieldValue(ddmStructureFieldValue, structure.getFieldType(fieldName));
      } catch (StructureFieldException sfe) {
        if (_log.isDebugEnabled()) {
          _log.debug(sfe, sfe);
        }
      }

      BooleanQuery booleanQuery = new BooleanQueryImpl();

      booleanQuery.addRequiredTerm(
          ddmStructureFieldName, StringPool.QUOTE + ddmStructureFieldValue + StringPool.QUOTE);

      contextBooleanFilter.add(new QueryFilter(booleanQuery));
    }

    String[] mimeTypes = (String[]) searchContext.getAttribute("mimeTypes");

    if (ArrayUtil.isNotEmpty(mimeTypes)) {
      BooleanFilter mimeTypesBooleanFilter = new BooleanFilter();

      for (String mimeType : mimeTypes) {
        mimeTypesBooleanFilter.addTerm(
            "mimeType", StringUtil.replace(mimeType, CharPool.FORWARD_SLASH, CharPool.UNDERLINE));
      }

      contextBooleanFilter.add(mimeTypesBooleanFilter, BooleanClauseOccur.MUST);
    }
  }
コード例 #4
0
 private String _getPrivateAttributeKey(String attributeName) {
   return StringPool.UNDERLINE.concat(attributeName).concat(StringPool.UNDERLINE);
 }
コード例 #5
0
  @Override
  public void postProcessContextBooleanFilter(
      BooleanFilter contextBooleanFilter, SearchContext searchContext) throws Exception {

    Long classNameId = (Long) searchContext.getAttribute(Field.CLASS_NAME_ID);

    if ((classNameId != null) && (classNameId != 0)) {
      contextBooleanFilter.addRequiredTerm(Field.CLASS_NAME_ID, classNameId.toString());
    }

    addStatus(contextBooleanFilter, searchContext);

    addSearchClassTypeIds(contextBooleanFilter, searchContext);

    String ddmStructureFieldName = (String) searchContext.getAttribute("ddmStructureFieldName");
    Serializable ddmStructureFieldValue = searchContext.getAttribute("ddmStructureFieldValue");

    if (Validator.isNotNull(ddmStructureFieldName) && Validator.isNotNull(ddmStructureFieldValue)) {

      String[] ddmStructureFieldNameParts =
          StringUtil.split(ddmStructureFieldName, DDMIndexer.DDM_FIELD_SEPARATOR);

      DDMStructure structure =
          _ddmStructureLocalService.getStructure(GetterUtil.getLong(ddmStructureFieldNameParts[1]));

      String fieldName =
          StringUtil.replaceLast(
              ddmStructureFieldNameParts[2],
              StringPool.UNDERLINE.concat(LocaleUtil.toLanguageId(searchContext.getLocale())),
              StringPool.BLANK);

      if (structure.hasField(fieldName)) {
        ddmStructureFieldValue =
            DDMUtil.getIndexedFieldValue(ddmStructureFieldValue, structure.getFieldType(fieldName));
      }

      BooleanQuery booleanQuery = new BooleanQueryImpl();

      booleanQuery.addRequiredTerm(
          ddmStructureFieldName, StringPool.QUOTE + ddmStructureFieldValue + StringPool.QUOTE);

      contextBooleanFilter.add(new QueryFilter(booleanQuery));
    }

    String articleType = (String) searchContext.getAttribute("articleType");

    if (Validator.isNotNull(articleType)) {
      contextBooleanFilter.addRequiredTerm(Field.TYPE, articleType);
    }

    String ddmStructureKey = (String) searchContext.getAttribute("ddmStructureKey");

    if (Validator.isNotNull(ddmStructureKey)) {
      contextBooleanFilter.addRequiredTerm("ddmStructureKey", ddmStructureKey);
    }

    String ddmTemplateKey = (String) searchContext.getAttribute("ddmTemplateKey");

    if (Validator.isNotNull(ddmTemplateKey)) {
      contextBooleanFilter.addRequiredTerm("ddmTemplateKey", ddmTemplateKey);
    }

    boolean head = GetterUtil.getBoolean(searchContext.getAttribute("head"), Boolean.TRUE);
    boolean relatedClassName =
        GetterUtil.getBoolean(searchContext.getAttribute("relatedClassName"));

    if (head && !relatedClassName) {
      contextBooleanFilter.addRequiredTerm("head", Boolean.TRUE);
    }
  }