/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.liferay.staging.bar.web.internal.portlet.action; import com.liferay.portal.kernel.servlet.SessionErrors; import com.liferay.portal.kernel.servlet.SessionMessages; import com.liferay.portal.kernel.util.ParamUtil; import com.liferay.portal.kernel.util.PortalUtil; import com.liferay.staging.bar.web.internal.portlet.constants.StagingBarPortletKeys; import java.io.IOException; import java.util.HashMap; import java.util.Map; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; /** * @author Mate Thurzo */ public class ActionUtil { public static void addLayoutBranchSessionMessages( ActionRequest actionRequest, ActionResponse actionResponse) throws IOException { if (SessionErrors.isEmpty(actionRequest)) { SessionMessages.add( actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, StagingBarPortletKeys.STAGING_BAR); Map<String, String> data = new HashMap<>(); data.put("preventNotification", Boolean.TRUE.toString()); SessionMessages.add( actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET_DATA, data); } String redirect = PortalUtil.escapeRedirect( ParamUtil.getString(actionRequest, "redirect")); actionResponse.sendRedirect(redirect); } }