2017-11-27 16:30:56 +01:00
|
|
|
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;
|
|
|
|
|
2019-10-17 17:31:42 +02:00
|
|
|
import com.liferay.portal.kernel.log.Log;
|
|
|
|
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
2017-11-27 16:30:56 +01:00
|
|
|
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 {
|
2019-10-17 17:31:42 +02:00
|
|
|
private static Log _log = LogFactoryUtil.getLog(RemoveAccountPortlet.class);
|
|
|
|
public static final String AUTORISED_INFRA_ROLE = "Infrastructure-Manager";
|
|
|
|
|
2017-11-27 16:30:56 +01:00
|
|
|
@ProcessAction(name = "deleteAccount")
|
2019-10-17 17:31:42 +02:00
|
|
|
public void deleteAccount(ActionRequest actionRequest, ActionResponse response) throws IOException, PortletException {
|
2017-11-27 16:30:56 +01:00
|
|
|
User user = null;
|
|
|
|
try {
|
|
|
|
user = PortalUtil.getUser(actionRequest);
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
2019-10-17 17:31:42 +02:00
|
|
|
}
|
|
|
|
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 ...");
|
2017-11-27 16:30:56 +01:00
|
|
|
Thread emailManagersThread = new Thread(new RemovedUserAccountThread(
|
|
|
|
user.getUserId(),
|
2019-10-17 17:31:42 +02:00
|
|
|
username2Remove,
|
2017-11-27 16:30:56 +01:00
|
|
|
user.getFullName(),
|
|
|
|
user.getEmailAddress()));
|
|
|
|
emailManagersThread.start();
|
2019-10-17 17:31:42 +02:00
|
|
|
|
|
|
|
|
2017-11-27 16:30:56 +01:00
|
|
|
ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
|
|
|
|
response.sendRedirect(themeDisplay.getURLSignOut());
|
|
|
|
}
|
|
|
|
}
|