@Override
  protected String getTitle(
      JSONObject jsonObject, AssetRenderer<?> assetRenderer, ServiceContext serviceContext) {

    MBMessage mbMessage = MBMessageLocalServiceUtil.fetchMBMessage(jsonObject.getLong("classPK"));

    AssetRendererFactory<?> assetRendererFactory =
        AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(
            assetRenderer.getClassName());

    String typeName = assetRendererFactory.getTypeName(serviceContext.getLocale());

    ResourceBundle resourceBundle =
        ResourceBundle.getBundle("content.Language", serviceContext.getLocale());

    if ((mbMessage != null) && mbMessage.isDiscussion()) {
      return LanguageUtil.format(
          resourceBundle,
          "x-mentioned-you-in-a-comment-in-a-x",
          new String[] {
            HtmlUtil.escape(assetRenderer.getUserName()),
            StringUtil.toLowerCase(HtmlUtil.escape(typeName))
          },
          false);
    } else {
      return LanguageUtil.format(
          resourceBundle,
          "x-mentioned-you-in-a-x",
          new String[] {
            HtmlUtil.escape(assetRenderer.getUserName()),
            StringUtil.toLowerCase(HtmlUtil.escape(typeName))
          },
          false);
    }
  }
  @Override
  public String getPortletId() {
    AssetRendererFactory<MBCategory> assetRendererFactory =
        AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClass(MBCategory.class);

    return assetRendererFactory.getPortletId();
  }
Example #3
0
  protected String getEntryURLViewInContext(
      PortletRequest portletRequest, PortletResponse portletResponse, AssetEntry assetEntry)
      throws Exception {

    AssetRendererFactory assetRendererFactory =
        AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(
            assetEntry.getClassName());

    AssetRenderer assetRenderer = assetRendererFactory.getAssetRenderer(assetEntry.getClassPK());

    String viewInContextURL =
        assetRenderer.getURLViewInContext(
            (LiferayPortletRequest) portletRequest, (LiferayPortletResponse) portletResponse, null);

    if (Validator.isNotNull(viewInContextURL)
        && !viewInContextURL.startsWith(Http.HTTP_WITH_SLASH)
        && !viewInContextURL.startsWith(Http.HTTPS_WITH_SLASH)) {

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

      viewInContextURL = themeDisplay.getPortalURL() + viewInContextURL;
    }

    return viewInContextURL;
  }
  public AssetRenderer getAssetRenderer(long classPK) throws PortalException, SystemException {

    AssetRendererFactory assetRendererFactory = getAssetRendererFactory();

    if (assetRendererFactory != null) {
      return assetRendererFactory.getAssetRenderer(classPK, AssetRendererFactory.TYPE_LATEST);
    } else {
      return null;
    }
  }
  @Override
  public String getIconCssClass() {
    AssetRendererFactory assetRendererFactory = getAssetRendererFactory();

    if (assetRendererFactory != null) {
      return assetRendererFactory.getIconCssClass();
    }

    return "icon-file-alt";
  }
  protected void sendNotificationEvent(
      final MicroblogsEntry microblogsEntry, ServiceContext serviceContext) throws PortalException {

    final JSONObject notificationEventJSONObject = JSONFactoryUtil.createJSONObject();

    notificationEventJSONObject.put("className", MicroblogsEntry.class.getName());
    notificationEventJSONObject.put("classPK", microblogsEntry.getMicroblogsEntryId());
    notificationEventJSONObject.put(
        "entryTitle",
        MicroblogsUtil.getProcessedContent(
            StringUtil.shorten(microblogsEntry.getContent(), 50), serviceContext));

    AssetRendererFactory<MicroblogsEntry> assetRendererFactory =
        AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClass(MicroblogsEntry.class);

    AssetRenderer<MicroblogsEntry> assetRenderer =
        assetRendererFactory.getAssetRenderer(microblogsEntry.getMicroblogsEntryId());

    String entryURL = StringPool.BLANK;

    try {
      entryURL =
          assetRenderer.getURLViewInContext(
              serviceContext.getLiferayPortletRequest(),
              serviceContext.getLiferayPortletResponse(),
              null);
    } catch (Exception e) {
      if (_log.isDebugEnabled()) {
        _log.debug(e, e);
      }
    }

    notificationEventJSONObject.put("entryURL", entryURL);
    notificationEventJSONObject.put("userId", microblogsEntry.getUserId());

    final List<Long> receiverUserIds = MicroblogsUtil.getSubscriberUserIds(microblogsEntry);

    Callable<Void> callable =
        new Callable<Void>() {

          @Override
          public Void call() throws Exception {
            MessageBusUtil.sendMessage(
                DestinationNames.ASYNC_SERVICE,
                new NotificationProcessCallable(
                    receiverUserIds, microblogsEntry, notificationEventJSONObject));

            return null;
          }
        };

    TransactionCommitCallbackUtil.registerCallback(callable);
  }
  @Override
  public PortletURL getURLView(
      LiferayPortletResponse liferayPortletResponse, WindowState windowState) throws Exception {

    AssetRendererFactory assetRendererFactory = getAssetRendererFactory();

    PortletURL portletURL = assetRendererFactory.getURLView(liferayPortletResponse, windowState);

    portletURL.setParameter("struts_action", "/message_boards/view_message");
    portletURL.setParameter("messageId", String.valueOf(_message.getMessageId()));
    portletURL.setWindowState(windowState);

    return portletURL;
  }
  @Override
  public PortletURL getURLView(
      LiferayPortletResponse liferayPortletResponse, WindowState windowState) throws Exception {

    AssetRendererFactory assetRendererFactory = getAssetRendererFactory();

    PortletURL portletURL = assetRendererFactory.getURLView(liferayPortletResponse, windowState);

    portletURL.setParameter("mvcRenderCommandName", "/document_library/view_file_entry");
    portletURL.setParameter("fileEntryId", String.valueOf(_fileEntry.getFileEntryId()));
    portletURL.setWindowState(windowState);

    return portletURL;
  }
  public TrashRenderer getTrashRenderer(long classPK) throws PortalException, SystemException {

    AssetRendererFactory assetRendererFactory = getAssetRendererFactory();

    if (assetRendererFactory != null) {
      AssetRenderer assetRenderer = assetRendererFactory.getAssetRenderer(classPK);

      if (assetRenderer instanceof TrashRenderer) {
        return (TrashRenderer) assetRenderer;
      }
    }

    return null;
  }
  @Override
  public PortletURL getURLView(
      LiferayPortletResponse liferayPortletResponse, WindowState windowState) throws Exception {

    AssetRendererFactory<WorkflowableComment> assetRendererFactory = getAssetRendererFactory();

    PortletURL portletURL = assetRendererFactory.getURLView(liferayPortletResponse, windowState);

    portletURL.setParameter("mvcPath", "/view_comment.jsp");
    portletURL.setParameter("commentId", String.valueOf(_workflowableComment.getCommentId()));
    portletURL.setWindowState(windowState);

    return portletURL;
  }
  @Override
  public PortletURL getURLView(
      LiferayPortletResponse liferayPortletResponse, WindowState windowState) throws Exception {

    AssetRendererFactory assetRendererFactory = getAssetRendererFactory();

    PortletURL portletURL = assetRendererFactory.getURLView(liferayPortletResponse, windowState);

    portletURL.setParameter("struts_action", "/bookmarks/view_entry");
    portletURL.setParameter("entryId", String.valueOf(_entry.getEntryId()));
    portletURL.setWindowState(windowState);

    return portletURL;
  }
  protected static AssetRenderer doGetAssetRenderer(String className, long classPK)
      throws Exception {

    if (className.equals(MBThread.class.getName())) {
      className = MBMessage.class.getName();

      MBThread mbThread = MBThreadLocalServiceUtil.getThread(classPK);

      classPK = mbThread.getRootMessageId();
    }

    AssetRendererFactory assetRendererFactory =
        AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(className);

    return assetRendererFactory.getAssetRenderer(classPK);
  }
Example #13
0
  protected String getEntryURLAssetPublisher(
      PortletRequest portletRequest, PortletResponse portletResponse, AssetEntry assetEntry)
      throws Exception {

    AssetRendererFactory assetRendererFactory =
        AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(
            assetEntry.getClassName());

    StringBundler sb = new StringBundler(4);

    sb.append(getAssetPublisherURL(portletRequest));
    sb.append(assetRendererFactory.getType());
    sb.append("/id/");
    sb.append(assetEntry.getEntryId());

    return sb.toString();
  }
  protected String[] getClassNames(String className) {
    if (Validator.isNotNull(className)) {
      return new String[] {className};
    } else {
      List<AssetRendererFactory> rendererFactories =
          AssetRendererFactoryRegistryUtil.getAssetRendererFactories();

      String[] classNames = new String[rendererFactories.size()];

      for (int i = 0; i < rendererFactories.size(); i++) {
        AssetRendererFactory rendererFactory = rendererFactories.get(i);

        classNames[i] = rendererFactory.getClassName();
      }

      return classNames;
    }
  }
  @Override
  public String getClassName(AssetRendererFactory assetRendererFactory) {
    Class<?> clazz = assetRendererFactory.getClass();

    String className = clazz.getName();

    int pos = className.lastIndexOf(StringPool.PERIOD);

    return className.substring(pos + 1);
  }
  protected void setDDMStructure() throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    _ddmStructureDisplayFieldValue = StringPool.BLANK;
    _ddmStructureFieldLabel = StringPool.BLANK;
    _ddmStructureFieldName = StringPool.BLANK;
    _ddmStructureFieldValue = null;

    long[] classNameIds = getClassNameIds();
    long[] classTypeIds = getClassTypeIds();

    if (isSubtypeFieldsFilterEnabled()
        && (classNameIds.length == 1)
        && (classTypeIds.length == 1)) {

      _ddmStructureDisplayFieldValue =
          GetterUtil.getString(
              _portletPreferences.getValue("ddmStructureDisplayFieldValue", StringPool.BLANK));
      _ddmStructureFieldName =
          GetterUtil.getString(
              _portletPreferences.getValue("ddmStructureFieldName", StringPool.BLANK));
      _ddmStructureFieldValue =
          _portletPreferences.getValue("ddmStructureFieldValue", StringPool.BLANK);

      if (Validator.isNotNull(_ddmStructureFieldName)
          && Validator.isNotNull(_ddmStructureFieldValue)) {

        AssetRendererFactory assetRendererFactory =
            AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(
                PortalUtil.getClassName(classNameIds[0]));

        Tuple classTypeFieldName =
            assetRendererFactory.getClassTypeFieldName(
                classTypeIds[0], _ddmStructureFieldName, themeDisplay.getLocale());

        _ddmStructureFieldLabel = (String) classTypeFieldName.getObject(0);
      }
    }
  }
  public static String getURL(
      HttpServletRequest request,
      ThemeDisplay themeDisplay,
      AssetRendererFactory assetRendererFactory,
      AssetRenderer assetRenderer)
      throws Exception {

    long classPK = assetRenderer.getClassPK();
    String className = assetRendererFactory.getClassName();
    String portletId = PortletProviderUtil.getPortletId(className, PortletProvider.Action.VIEW);

    PortletURL portletURL = null;

    if (className.equals(BlogsEntry.class.getName())) {
      portletURL =
          PortletURLFactoryUtil.create(
              request, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

      portletURL.setParameter("mvcRenderCommandName", "/blogs/view_entry");
      portletURL.setParameter("entryId", String.valueOf(classPK));
    } else if (className.equals(JournalArticle.class.getName())) {
      JournalArticle journalArticle = JournalArticleLocalServiceUtil.getLatestArticle(classPK);

      portletURL =
          PortletURLFactoryUtil.create(
              request, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

      portletURL.setParameter("struts_action", "/journal_content/view");
      portletURL.setParameter("groupId", String.valueOf(journalArticle.getGroupId()));
      portletURL.setParameter("articleId", journalArticle.getArticleId());
    } else if (className.equals(KBArticle.class.getName())) {
      portletURL =
          PortletURLFactoryUtil.create(
              request,
              PortletKeys.KNOWLEDGE_BASE_ARTICLE_DEFAULT_INSTANCE,
              themeDisplay.getPlid(),
              PortletRequest.RENDER_PHASE);

      portletURL.setParameter("mvcPath", "/article/view_article.jsp");
      portletURL.setParameter("resourcePrimKey", String.valueOf(classPK));
    } else if (className.equals(MBMessage.class.getName())) {
      portletURL =
          PortletURLFactoryUtil.create(
              request, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

      portletURL.setParameter("struts_action", "/message_boards/view_message");
      portletURL.setParameter("messageId", String.valueOf(classPK));
    } else if (className.equals(WikiPage.class.getName())) {
      WikiPage wikiPage = WikiPageLocalServiceUtil.getPage(classPK);

      portletURL =
          PortletURLFactoryUtil.create(
              request, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

      portletURL.setParameter("struts_action", "/wiki/view");
      portletURL.setParameter("nodeId", String.valueOf(wikiPage.getNodeId()));
      portletURL.setParameter("title", wikiPage.getTitle());
    }

    String currentURL = PortalUtil.getCurrentURL(request);

    if (portletURL == null) {
      return currentURL;
    }

    portletURL.setWindowState(WindowState.MAXIMIZED);
    portletURL.setPortletMode(PortletMode.VIEW);

    portletURL.setParameter("returnToFullPageURL", currentURL);

    return portletURL.toString();
  }
  @Override
  public String getPortletId() {
    AssetRendererFactory assetRendererFactory = getAssetRendererFactory();

    return assetRendererFactory.getPortletId();
  }
  private String getAssetViewURL(
      PortletRequest request, PortletResponse response, AssetEntry assetEntry, String keywords) {

    try {
      ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
      PortletURL returnURL =
          PortletURLFactoryUtil.create(
              request,
              (String) request.getAttribute(WebKeys.PORTLET_ID),
              themeDisplay.getLayout().getPlid(),
              PortletRequest.RENDER_PHASE);
      returnURL.setWindowState(WindowState.NORMAL);
      returnURL.setPortletMode(PortletMode.VIEW);
      returnURL.setParameter("action", "ricercaLibera");
      returnURL.setParameter("cercaPerKeyword", keywords);

      PortletURL viewURL = null;

      String localHost = themeDisplay.getPortalURL();
      List<Layout> layouts = null;

      layouts = LayoutLocalServiceUtil.getLayouts(themeDisplay.getLayout().getGroupId(), false);
      for (Layout layout : layouts) {

        String nodeNameRemoved =
            PortalUtil.getLayoutFriendlyURL(layout, themeDisplay).replace(localHost, "");

        // Viene ricercato l'URL esatto per la pagina successiva
        if (nodeNameRemoved.indexOf(paginaDettaglioContenuto) > 0) {

          viewURL =
              PortletURLFactoryUtil.create(
                  request, assetPublisherPortletId, layout.getPlid(), PortletRequest.RENDER_PHASE);
          viewURL.setWindowState(WindowState.NORMAL);
          viewURL.setPortletMode(PortletMode.VIEW);
          viewURL.setParameter("action", "ricerca");
          viewURL.setParameter("struts_action", "/asset_publisher/view_content");

          // String currentURL = HttpUtil.addParameter(PortalUtil.getCurrentURL(request), "_" +
          // request.getAttribute(WebKeys.PORTLET_ID) + "_cercaPerKeyword", keywords);
          viewURL.setParameter("redirect", returnURL.toString());

          viewURL.setParameter("assetEntryId", String.valueOf(assetEntry.getEntryId()));

          AssetRendererFactory assetRendererFactory = assetEntry.getAssetRendererFactory();

          AssetRenderer assetRenderer = assetEntry.getAssetRenderer();

          viewURL.setParameter("type", assetRendererFactory.getType());

          if (Validator.isNotNull(assetRenderer.getUrlTitle())) {

            if (assetRenderer.getGroupId() != themeDisplay.getScopeGroupId()) {
              viewURL.setParameter("groupId", String.valueOf(assetRenderer.getGroupId()));
            }

            viewURL.setParameter("urlTitle", assetRenderer.getUrlTitle());
          }

          break;
        }
      }

      return viewURL.toString();

    } catch (Exception e) {
      e.printStackTrace();
    }

    return null;
  }
  @Override
  public String getPortletId() {
    AssetRendererFactory<WorkflowableComment> assetRendererFactory = getAssetRendererFactory();

    return assetRendererFactory.getPortletId();
  }
Example #21
0
  public static PortletURL getAddPortletURL(
      LiferayPortletRequest liferayPortletRequest,
      LiferayPortletResponse liferayPortletResponse,
      long groupId,
      String className,
      long classTypeId,
      long[] allAssetCategoryIds,
      String[] allAssetTagNames,
      String redirect)
      throws Exception {

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

    AssetRendererFactory<?> assetRendererFactory =
        AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(className);

    if ((assetRendererFactory == null)
        || !assetRendererFactory.hasAddPermission(
            themeDisplay.getPermissionChecker(), groupId, classTypeId)) {

      return null;
    }

    PortletURL addPortletURL =
        assetRendererFactory.getURLAdd(liferayPortletRequest, liferayPortletResponse, classTypeId);

    if (addPortletURL == null) {
      return null;
    }

    if (redirect != null) {
      addPortletURL.setParameter("redirect", redirect);
    }

    String referringPortletResource = ParamUtil.getString(liferayPortletRequest, "portletResource");

    if (Validator.isNotNull(referringPortletResource)) {
      addPortletURL.setParameter("referringPortletResource", referringPortletResource);
    } else {
      PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

      addPortletURL.setParameter("referringPortletResource", portletDisplay.getId());

      if (allAssetCategoryIds != null) {
        Map<Long, String> assetVocabularyAssetCategoryIds = new HashMap<>();

        for (long assetCategoryId : allAssetCategoryIds) {
          AssetCategory assetCategory =
              AssetCategoryLocalServiceUtil.fetchAssetCategory(assetCategoryId);

          if (assetCategory == null) {
            continue;
          }

          long assetVocabularyId = assetCategory.getVocabularyId();

          if (assetVocabularyAssetCategoryIds.containsKey(assetVocabularyId)) {

            String assetCategoryIds = assetVocabularyAssetCategoryIds.get(assetVocabularyId);

            assetVocabularyAssetCategoryIds.put(
                assetVocabularyId, assetCategoryIds + StringPool.COMMA + assetCategoryId);
          } else {
            assetVocabularyAssetCategoryIds.put(assetVocabularyId, String.valueOf(assetCategoryId));
          }
        }

        for (Map.Entry<Long, String> entry : assetVocabularyAssetCategoryIds.entrySet()) {

          long assetVocabularyId = entry.getKey();
          String assetCategoryIds = entry.getValue();

          addPortletURL.setParameter("assetCategoryIds_" + assetVocabularyId, assetCategoryIds);
        }
      }

      if (allAssetTagNames != null) {
        addPortletURL.setParameter("assetTagNames", StringUtil.merge(allAssetTagNames));
      }
    }

    addPortletURL.setPortletMode(PortletMode.VIEW);
    addPortletURL.setWindowState(LiferayWindowState.POP_UP);

    return addPortletURL;
  }
Example #22
0
  public static Map<String, PortletURL> getAddPortletURLs(
      LiferayPortletRequest liferayPortletRequest,
      LiferayPortletResponse liferayPortletResponse,
      long groupId,
      long[] classNameIds,
      long[] classTypeIds,
      long[] allAssetCategoryIds,
      String[] allAssetTagNames,
      String redirect)
      throws Exception {

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

    Map<String, PortletURL> addPortletURLs =
        new TreeMap<>(new ModelResourceComparator(themeDisplay.getLocale()));

    for (long classNameId : classNameIds) {
      String className = PortalUtil.getClassName(classNameId);

      AssetRendererFactory<?> assetRendererFactory =
          AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(className);

      if (Validator.isNull(assetRendererFactory.getPortletId())) {
        continue;
      }

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

      if (!portlet.isActive()) {
        continue;
      }

      ClassTypeReader classTypeReader = assetRendererFactory.getClassTypeReader();

      List<ClassType> classTypes =
          classTypeReader.getAvailableClassTypes(
              PortalUtil.getCurrentAndAncestorSiteGroupIds(themeDisplay.getScopeGroupId()),
              themeDisplay.getLocale());

      if ((classTypeIds.length == 0) || classTypes.isEmpty()) {
        PortletURL addPortletURL =
            getAddPortletURL(
                liferayPortletRequest,
                liferayPortletResponse,
                groupId,
                className,
                0,
                allAssetCategoryIds,
                allAssetTagNames,
                redirect);

        if (addPortletURL != null) {
          addPortletURLs.put(className, addPortletURL);
        }
      }

      for (ClassType classType : classTypes) {
        long classTypeId = classType.getClassTypeId();

        if (ArrayUtil.contains(classTypeIds, classTypeId) || (classTypeIds.length == 0)) {

          PortletURL addPortletURL =
              getAddPortletURL(
                  liferayPortletRequest,
                  liferayPortletResponse,
                  groupId,
                  className,
                  classTypeId,
                  allAssetCategoryIds,
                  allAssetTagNames,
                  redirect);

          if (addPortletURL != null) {
            String mesage = className + CLASSNAME_SEPARATOR + classType.getName();

            addPortletURLs.put(mesage, addPortletURL);
          }
        }
      }
    }

    return addPortletURLs;
  }
  public AssetEntryQuery getAssetEntryQuery() throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    long[] groupIds = getGroupIds();

    if (!ArrayUtil.contains(groupIds, themeDisplay.getScopeGroupId())) {
      groupIds = ArrayUtil.append(groupIds, themeDisplay.getScopeGroupId());
    }

    AssetEntryQuery assetEntryQuery =
        AssetPublisherUtil.getAssetEntryQuery(_portletPreferences, groupIds);

    long[] classNameIds = getClassNameIds();
    long[] classTypeIds = getClassTypeIds();

    if (isSubtypeFieldsFilterEnabled()
        && (classNameIds.length == 1)
        && (classTypeIds.length == 1)
        && Validator.isNotNull(getDDMStructureFieldName())
        && Validator.isNotNull(getDDMStructureFieldValue())) {

      AssetRendererFactory assetRendererFactory =
          AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(
              PortalUtil.getClassName(classNameIds[0]));

      Tuple classTypeFieldName =
          assetRendererFactory.getClassTypeFieldName(
              classTypeIds[0], getDDMStructureFieldName(), themeDisplay.getLocale());

      long ddmStructureId = GetterUtil.getLong(classTypeFieldName.getObject(3));

      assetEntryQuery.setAttribute(
          "ddmStructureFieldName",
          DDMIndexerUtil.encodeName(
              ddmStructureId, getDDMStructureFieldName(), themeDisplay.getLocale()));
      assetEntryQuery.setAttribute("ddmStructureFieldValue", getDDMStructureFieldValue());
    }

    AssetPublisherUtil.processAssetEntryQuery(
        themeDisplay.getUser(), _portletPreferences, assetEntryQuery);

    assetEntryQuery.setAllCategoryIds(getAllAssetCategoryIds());

    if (hasLayoutGroup(groupIds)) {
      assetEntryQuery.setAllTagIds(
          AssetTagLocalServiceUtil.getTagIds(groupIds, getAllAssetTagNames()));
    } else {
      assetEntryQuery.setAllTagIds(
          AssetTagLocalServiceUtil.getTagIds(getGroupIds(), getAllAssetTagNames()));
    }

    assetEntryQuery.setClassTypeIds(classTypeIds);
    assetEntryQuery.setEnablePermissions(isEnablePermissions());
    assetEntryQuery.setExcludeZeroViewCount(isExcludeZeroViewCount());

    String portletName = getPortletName();

    if (!portletName.equals(PortletKeys.RELATED_ASSETS)) {
      assetEntryQuery.setGroupIds(getGroupIds());
    }

    if (isShowOnlyLayoutAssets()) {
      assetEntryQuery.setLayout(themeDisplay.getLayout());
    }

    if (portletName.equals(PortletKeys.RELATED_ASSETS)) {
      AssetEntry layoutAssetEntry = (AssetEntry) _request.getAttribute(WebKeys.LAYOUT_ASSET_ENTRY);

      if (layoutAssetEntry != null) {
        assetEntryQuery.setLinkedAssetEntryId(layoutAssetEntry.getEntryId());
      }
    }

    assetEntryQuery.setPaginationType(getPaginationType());
    assetEntryQuery.setOrderByCol1(getOrderByColumn1());
    assetEntryQuery.setOrderByCol2(getOrderByColumn2());
    assetEntryQuery.setOrderByType1(getOrderByType1());
    assetEntryQuery.setOrderByType2(getOrderByType2());

    return assetEntryQuery;
  }