Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LPS-105946 Using a more specific name #82120

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -268,4 +268,8 @@ public List<DepotEntryGroupRel> getSearchableDepotEntryGroupRels(
public DepotEntryGroupRel updateDepotEntryGroupRel(
DepotEntryGroupRel depotEntryGroupRel);

public DepotEntryGroupRel updateSearchable(
long depotEntryGroupRelId, boolean searchable)
throws PortalException;

}
Expand Up @@ -319,6 +319,13 @@ public static int getSearchableDepotEntryGroupRelsCount(long groupId) {
return getService().updateDepotEntryGroupRel(depotEntryGroupRel);
}

public static com.liferay.depot.model.DepotEntryGroupRel updateSearchable(
long depotEntryGroupRelId, boolean searchable)
throws com.liferay.portal.kernel.exception.PortalException {

return getService().updateSearchable(depotEntryGroupRelId, searchable);
}

public static DepotEntryGroupRelLocalService getService() {
return _serviceTracker.getService();
}
Expand Down
Expand Up @@ -352,6 +352,15 @@ public com.liferay.depot.model.DepotEntryGroupRel updateDepotEntryGroupRel(
depotEntryGroupRel);
}

@Override
public com.liferay.depot.model.DepotEntryGroupRel updateSearchable(
long depotEntryGroupRelId, boolean searchable)
throws com.liferay.portal.kernel.exception.PortalException {

return _depotEntryGroupRelLocalService.updateSearchable(
depotEntryGroupRelId, searchable);
}

@Override
public DepotEntryGroupRelLocalService getWrappedService() {
return _depotEntryGroupRelLocalService;
Expand Down
Expand Up @@ -18,6 +18,7 @@
import com.liferay.depot.model.DepotEntryGroupRel;
import com.liferay.depot.service.base.DepotEntryGroupRelLocalServiceBaseImpl;
import com.liferay.portal.aop.AopService;
import com.liferay.portal.kernel.exception.PortalException;

import java.util.List;

Expand Down Expand Up @@ -100,4 +101,17 @@ public int getSearchableDepotEntryGroupRelsCount(long groupId) {
return depotEntryGroupRelPersistence.countByS_TGI(true, groupId);
}

@Override
public DepotEntryGroupRel updateSearchable(
long depotEntryGroupRelId, boolean searchable)
throws PortalException {

DepotEntryGroupRel depotEntryGroupRel = getDepotEntryGroupRel(
depotEntryGroupRelId);

depotEntryGroupRel.setSearchable(searchable);

return depotEntryGroupRelPersistence.update(depotEntryGroupRel);
}

}
Expand Up @@ -88,23 +88,21 @@ public DropdownItemList getConnectedSiteDropdownItems(

add(
dropdownItem -> {
ActionURL editDepotEntryGroupRelActionURL =
DepotEntryURLUtil.
getEditDepotEntryGroupRelActionURL(
depotEntryGroupRel.
getDepotEntryGroupRelId(),
!depotEntryGroupRel.isSearchable(),
_currentURL.toString(),
_liferayPortletResponse);
ActionURL updateSearchableActionURL =
DepotEntryURLUtil.getUpdateSearchableActionURL(
depotEntryGroupRel.getDepotEntryGroupRelId(),
!depotEntryGroupRel.isSearchable(),
_currentURL.toString(),
_liferayPortletResponse);

dropdownItem.setHref(
editDepotEntryGroupRelActionURL.toString());
updateSearchableActionURL.toString());

dropdownItem.setLabel(
LanguageUtil.get(
PortalUtil.getHttpServletRequest(
_liferayPortletRequest),
_getSetSearchableKey(depotEntryGroupRel)));
_getUpdateSearchableKey(depotEntryGroupRel)));
});
}
};
Expand Down Expand Up @@ -147,7 +145,9 @@ public String getSiteName(DepotEntryGroupRel depotEntryGroupRel)
return group.getDescriptiveName(locale);
}

private String _getSetSearchableKey(DepotEntryGroupRel depotEntryGroupRel) {
private String _getUpdateSearchableKey(
DepotEntryGroupRel depotEntryGroupRel) {

if (depotEntryGroupRel.isSearchable()) {
return "make-unsearchable";
}
Expand Down
Expand Up @@ -14,15 +14,16 @@

package com.liferay.depot.web.internal.portlet.action;

import com.liferay.depot.model.DepotEntryGroupRel;
import com.liferay.depot.service.DepotEntryGroupRelLocalService;
import com.liferay.depot.web.internal.constants.DepotPortletKeys;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.portlet.bridges.mvc.BaseMVCActionCommand;
import com.liferay.portal.kernel.portlet.bridges.mvc.MVCActionCommand;
import com.liferay.portal.kernel.util.ParamUtil;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
Expand All @@ -34,30 +35,24 @@
property = {
"javax.portlet.name=" + DepotPortletKeys.DEPOT_ADMIN,
"javax.portlet.name=" + DepotPortletKeys.DEPOT_SETTINGS,
"mvc.command.name=/depot_entry/edit_depot_entry_group_rel"
"mvc.command.name=/depot_entry_group_rel/update_searchable"
},
service = MVCActionCommand.class
)
public class EditDepotEntryGroupRelMVCActionCommand
extends BaseMVCActionCommand {
public class UpdateSearchableMVCActionCommand extends BaseMVCActionCommand {

@Override
protected void doProcessAction(
ActionRequest actionRequest, ActionResponse actionResponse) {
ActionRequest actionRequest, ActionResponse actionResponse)
throws PortletException {

long depotEntryGroupRelId = ParamUtil.getLong(
actionRequest, "depotEntryGroupRelId");

DepotEntryGroupRel depotEntryGroupRel =
_depotEntryGroupRelLocalService.fetchDepotEntryGroupRel(
depotEntryGroupRelId);

if (depotEntryGroupRel != null) {
depotEntryGroupRel.setSearchable(
try {
_depotEntryGroupRelLocalService.updateSearchable(
ParamUtil.getLong(actionRequest, "depotEntryGroupRelId"),
ParamUtil.getBoolean(actionRequest, "searchable"));

_depotEntryGroupRelLocalService.updateDepotEntryGroupRel(
depotEntryGroupRel);
}
catch (PortalException pe) {
throw new PortletException(pe);
}
}

Expand Down
Expand Up @@ -42,22 +42,6 @@ public static ActionURL getAddDepotEntryActionURL(
return addDepotEntryURL;
}

public static ActionURL getConnectSiteActionURL(
long depotEntryId, String redirect,
LiferayPortletResponse liferayPortletResponse) {

ActionURL connectSiteActionURL =
liferayPortletResponse.createActionURL();

connectSiteActionURL.setParameter(
ActionRequest.ACTION_NAME, "/depot_entry/connect");
connectSiteActionURL.setParameter("redirect", redirect);
connectSiteActionURL.setParameter(
"depotEntryId", String.valueOf(depotEntryId));

return connectSiteActionURL;
}

public static ActionURL getDeleteDepotEntryActionURL(
long depotEntryId, String redirect,
LiferayPortletResponse liferayPortletResponse) {
Expand Down Expand Up @@ -90,37 +74,6 @@ public static ActionURL getDisconnectSiteActionURL(
return disconnectSiteActionURL;
}

public static ActionURL getEditDepotEntryGroupRelActionURL(
LiferayPortletResponse liferayPortletResponse) {

ActionURL editDepotEntryActionURL =
liferayPortletResponse.createActionURL();

editDepotEntryActionURL.setParameter(
ActionRequest.ACTION_NAME, "/depot_entry/edit");

return editDepotEntryActionURL;
}

public static ActionURL getEditDepotEntryGroupRelActionURL(
long depotEntryGroupRelId, boolean searchable, String redirect,
LiferayPortletResponse liferayPortletResponse) {

ActionURL editDepotEntryGroupRelActionURL =
liferayPortletResponse.createActionURL();

editDepotEntryGroupRelActionURL.setParameter(
ActionRequest.ACTION_NAME,
"/depot_entry/edit_depot_entry_group_rel");
editDepotEntryGroupRelActionURL.setParameter("redirect", redirect);
editDepotEntryGroupRelActionURL.setParameter(
"depotEntryGroupRelId", String.valueOf(depotEntryGroupRelId));
editDepotEntryGroupRelActionURL.setParameter(
"searchable", String.valueOf(searchable));

return editDepotEntryGroupRelActionURL;
}

public static PortletURL getEditDepotEntryPortletURL(
Group group, String redirect,
LiferayPortletRequest httpServletRequest) {
Expand All @@ -138,4 +91,23 @@ public static PortletURL getEditDepotEntryPortletURL(
return editDepotEntryURL;
}

public static ActionURL getUpdateSearchableActionURL(
long depotEntryGroupRelId, boolean searchable, String redirect,
LiferayPortletResponse liferayPortletResponse) {

ActionURL updateSearchableActionURL =
liferayPortletResponse.createActionURL();

updateSearchableActionURL.setParameter(
ActionRequest.ACTION_NAME,
"/depot_entry_group_rel/update_searchable");
updateSearchableActionURL.setParameter("redirect", redirect);
updateSearchableActionURL.setParameter(
"depotEntryGroupRelId", String.valueOf(depotEntryGroupRelId));
updateSearchableActionURL.setParameter(
"searchable", String.valueOf(searchable));

return updateSearchableActionURL;
}

}