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 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.LogFactoryUtil;
|
||||
|
@ -26,17 +27,21 @@ public class RemoveAccountPortlet extends MVCPortlet {
|
|||
|
||||
@ProcessAction(name = "deleteAccount")
|
||||
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 {
|
||||
user = PortalUtil.getUser(actionRequest);
|
||||
username2Delete = PortalUtil.getUser(actionRequest).getScreenName();
|
||||
} 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());
|
||||
System.out.println("\n The Response sent ...");
|
||||
if (username2Delete != null) {
|
||||
Thread dropUserAccountThread = new Thread(new RemovedUserAccountThread(username2Delete));
|
||||
dropUserAccountThread.start();
|
||||
} else {
|
||||
_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