This repository has been archived on 2021-03-03. You can view files and clone it, but cannot push or open issues or pull requests.
remove-account-portlet/src/main/java/org/gcube/portlets/admin/RemoveAccountPortlet.java

43 lines
1.5 KiB
Java
Raw Normal View History

package org.gcube.portlets.admin;
import java.io.IOException;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.ProcessAction;
import org.gcube.portal.removeaccount.D4ScienceRemoveAccountManager;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.model.User;
import com.liferay.portal.theme.ThemeDisplay;
import com.liferay.portal.util.PortalUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;
/**
* Portlet implementation class RemoveAccountPortlet
*/
public class RemoveAccountPortlet extends MVCPortlet {
private static Log _log = LogFactoryUtil.getLog(RemoveAccountPortlet.class);
public static final String AUTORISED_INFRA_ROLE = "Infrastructure-Manager";
@ProcessAction(name = "deleteAccount")
public void deleteAccount(ActionRequest actionRequest, ActionResponse response) throws IOException, PortletException {
User user = null;
try {
user = PortalUtil.getUser(actionRequest);
} catch (Exception e) {
e.printStackTrace();
}
D4ScienceRemoveAccountManager removeAccountManager = new D4ScienceRemoveAccountManager(user.getScreenName());
removeAccountManager.doAsyncRemoveAccount();
_log.info("The user "+user.getScreenName()+ " removed her/his account");
ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
response.sendRedirect(themeDisplay.getURLSignOut());
}
}