async removal of the account after logout
This commit is contained in:
parent
145f6bda68
commit
517af08cf4
|
@ -8,6 +8,7 @@ import javax.portlet.PortletException;
|
||||||
import javax.portlet.ProcessAction;
|
import javax.portlet.ProcessAction;
|
||||||
|
|
||||||
import org.gcube.portal.removeaccount.D4ScienceRemoveAccountManager;
|
import org.gcube.portal.removeaccount.D4ScienceRemoveAccountManager;
|
||||||
|
import org.gcube.portlets.admin.removeaccount.RemovedUserAccountThread;
|
||||||
|
|
||||||
import com.liferay.portal.kernel.log.Log;
|
import com.liferay.portal.kernel.log.Log;
|
||||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||||
|
@ -26,17 +27,21 @@ public class RemoveAccountPortlet extends MVCPortlet {
|
||||||
|
|
||||||
@ProcessAction(name = "deleteAccount")
|
@ProcessAction(name = "deleteAccount")
|
||||||
public void deleteAccount(ActionRequest actionRequest, ActionResponse response) throws IOException, PortletException {
|
public void deleteAccount(ActionRequest actionRequest, ActionResponse response) throws IOException, PortletException {
|
||||||
User user = null;
|
ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
|
||||||
|
System.out.println("\n\n\n****Sending Response ="+themeDisplay.getURLSignOut());
|
||||||
|
response.sendRedirect(themeDisplay.getURLSignOut());
|
||||||
|
String username2Delete = null;
|
||||||
try {
|
try {
|
||||||
user = PortalUtil.getUser(actionRequest);
|
username2Delete = PortalUtil.getUser(actionRequest).getScreenName();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
D4ScienceRemoveAccountManager removeAccountManager = new D4ScienceRemoveAccountManager(user.getScreenName());
|
System.out.println("\n The Response sent ...");
|
||||||
removeAccountManager.doAsyncRemoveAccount();
|
if (username2Delete != null) {
|
||||||
_log.info("The user "+user.getScreenName()+ " removed her/his account");
|
Thread dropUserAccountThread = new Thread(new RemovedUserAccountThread(username2Delete));
|
||||||
|
dropUserAccountThread.start();
|
||||||
ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
|
} else {
|
||||||
response.sendRedirect(themeDisplay.getURLSignOut());
|
_log.error("Account not removed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package org.gcube.portlets.admin.removeaccount;
|
||||||
|
|
||||||
|
import org.gcube.portal.removeaccount.D4ScienceRemoveAccountManager;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Massimiliano Assante ISTI-CNR
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class RemovedUserAccountThread implements Runnable {
|
||||||
|
|
||||||
|
private static final Logger _log = LoggerFactory.getLogger(RemovedUserAccountThread.class);
|
||||||
|
private String userNameToDelete;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public RemovedUserAccountThread(String userNameToDelete) {
|
||||||
|
super();
|
||||||
|
this.userNameToDelete = userNameToDelete;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
|
||||||
|
D4ScienceRemoveAccountManager removeAccountManager = new D4ScienceRemoveAccountManager(userNameToDelete);
|
||||||
|
boolean result = removeAccountManager.doAsyncRemoveAccount();
|
||||||
|
_log.info("The user "+userNameToDelete+ " removed her/his account with success?"+ result);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
_log.error("An error occurred during user workspace removal: ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue