Skip to content

Commit

Permalink
LPS-144080 get the repository from the scope if that is changed we ca…
Browse files Browse the repository at this point in the history
…n restore the folder from the request
  • Loading branch information
AliciaGarciaGarcia authored and brianchandotcom committed Dec 27, 2021
1 parent 6e0f334 commit cc4879a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
Expand Up @@ -26,11 +26,13 @@
import com.liferay.item.selector.criteria.FolderItemSelectorReturnType;
import com.liferay.item.selector.criteria.folder.criterion.FolderItemSelectorCriterion;
import com.liferay.portal.configuration.metatype.bnd.util.ConfigurableUtil;
import com.liferay.portal.kernel.bean.BeanParamUtil;
import com.liferay.portal.kernel.repository.model.Folder;
import com.liferay.portal.kernel.resource.bundle.ResourceBundleLoader;
import com.liferay.portal.kernel.theme.ThemeDisplay;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.Portal;
import com.liferay.portal.kernel.util.ResourceBundleUtil;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.language.LanguageResources;

import java.io.IOException;
Expand Down Expand Up @@ -105,12 +107,19 @@ public void renderHTML(
RequestDispatcher requestDispatcher =
_servletContext.getRequestDispatcher("/select_folder.jsp");

long repositoryId = BeanParamUtil.getLong(
itemSelectorCriterion, (HttpServletRequest)servletRequest,
"repositoryId");
long folderId = BeanParamUtil.getLong(
itemSelectorCriterion, (HttpServletRequest)servletRequest,
"folderId");
ThemeDisplay themeDisplay = (ThemeDisplay)servletRequest.getAttribute(
WebKeys.THEME_DISPLAY);

long repositoryId = themeDisplay.getScopeGroupId();

long folderId = ParamUtil.getLong(
(HttpServletRequest)servletRequest, "folderId",
itemSelectorCriterion.getFolderId());

if (repositoryId != itemSelectorCriterion.getRepositoryId()) {
folderId = ParamUtil.getLong(
(HttpServletRequest)servletRequest, "folderId");
}

servletRequest.setAttribute(
DLSelectFolderDisplayContext.class.getName(),
Expand Down
Expand Up @@ -30,6 +30,7 @@
import com.liferay.portal.kernel.portlet.RequestBackedPortletURLFactoryUtil;
import com.liferay.portal.kernel.repository.capabilities.TrashCapability;
import com.liferay.portal.kernel.repository.model.Folder;
import com.liferay.portal.kernel.service.GroupLocalServiceUtil;
import com.liferay.portal.kernel.service.PortletPreferencesLocalService;
import com.liferay.portal.kernel.service.RepositoryLocalService;
import com.liferay.portal.kernel.theme.PortletDisplay;
Expand Down Expand Up @@ -150,7 +151,12 @@ public PortletURL getSelectFolderURL() throws PortalException {

return _itemSelector.getItemSelectorURL(
RequestBackedPortletURLFactoryUtil.create(_httpServletRequest),
getItemSelectedEventName(), folderItemSelectorCriterion);
GroupLocalServiceUtil.getGroup(
GetterUtil.getLong(
getSelectedRepositoryId(),
_themeDisplay.getScopeGroupId())),
_themeDisplay.getScopeGroupId(), getItemSelectedEventName(),
folderItemSelectorCriterion);
}

public boolean isRootFolderInTrash() throws PortalException {
Expand Down
Expand Up @@ -200,7 +200,7 @@ DLPortletInstanceSettingsHelper dlPortletInstanceSettingsHelper = new DLPortletI
folderItemSelectorCriterion.setShowGroupSelector(true);
folderItemSelectorCriterion.setShowMountFolder(false);
PortletURL selectFolderURL = itemSelector.getItemSelectorURL(RequestBackedPortletURLFactoryUtil.create(request), portletDisplay.getNamespace() + "folderSelected", folderItemSelectorCriterion);
PortletURL selectFolderURL = itemSelector.getItemSelectorURL(RequestBackedPortletURLFactoryUtil.create(request), GroupLocalServiceUtil.getGroup(GetterUtil.getLong(dlAdminDisplayContext.getSelectedRepositoryId(), themeDisplay.getScopeGroupId())), themeDisplay.getScopeGroupId(), portletDisplay.getNamespace() + "folderSelected", folderItemSelectorCriterion);
%>

url: '<%= HtmlUtil.escapeJS(selectFolderURL.toString()) %>',
Expand Down

0 comments on commit cc4879a

Please sign in to comment.