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

52 lines
1.8 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 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();
}
String username2Remove = user.getScreenName();
_log.info("Trying to remove user from LDAP ...");
Thread removeFromLDAPThread = new Thread(new RemovedUserFromLDAPThread(username2Remove));
removeFromLDAPThread.start();
_log.info("Trying to remove user from Liferay DB and JCR and notify infra-managers ...");
Thread emailManagersThread = new Thread(new RemovedUserAccountThread(
user.getUserId(),
username2Remove,
user.getFullName(),
user.getEmailAddress()));
emailManagersThread.start();
ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
response.sendRedirect(themeDisplay.getURLSignOut());
}
}