async removal of the user after the respons
This commit is contained in:
parent
5ff98c894d
commit
6e368e570c
|
@ -4,9 +4,6 @@
|
|||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
<dependent-module archiveName="remove-account-library-1.2.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/remove-account-library/remove-account-library">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<property name="context-root" value="tou-optout-hook"/>
|
||||
<property name="java-output-path" value="/tou-optout-hook/target/classes"/>
|
||||
</wb-module>
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.liferay.samplestrutsaction.hook.action;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.gcube.portal.removeaccount.D4ScienceRemoveAccountManager;
|
||||
import org.gcube.portal.tou.removeaccount.thread.RemovedUserAccountThread;
|
||||
|
||||
import com.liferay.portal.kernel.struts.BaseStrutsAction;
|
||||
import com.liferay.portal.kernel.struts.StrutsAction;
|
||||
|
@ -17,14 +17,21 @@ public class UpdateTermsOfUseAction extends BaseStrutsAction {
|
|||
public String execute(StrutsAction originalStrutsAction, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
String agreement = request.getParameter("agreement");
|
||||
if (agreement.compareTo("i-disagree")==0) { //the user did not agree
|
||||
User user = PortalUtil.getUser(request);
|
||||
String username2Delete = null;
|
||||
try {
|
||||
D4ScienceRemoveAccountManager removeAccountManager = new D4ScienceRemoveAccountManager(user.getScreenName());
|
||||
removeAccountManager.doAsyncRemoveAccount();
|
||||
System.out.println("*** UpdateTermsOfUseAction user DID NOT AGREE, removeUser account for username=" + user.getScreenName() + " done with success, notified also the managers ... ");
|
||||
User user = PortalUtil.getUser(request);
|
||||
username2Delete = user.getScreenName();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("*** UpdateTermsOfUseAction user DID NOT AGREE, removeUser account for username=" + username2Delete + " ongoing ... ");
|
||||
if (username2Delete != null) {
|
||||
Thread dropUserAccountThread = new Thread(new RemovedUserAccountThread(username2Delete));
|
||||
dropUserAccountThread.start();
|
||||
} else {
|
||||
System.out.println("Account not removed");
|
||||
}
|
||||
|
||||
return "/../c/portal/logout";
|
||||
}
|
||||
else //the user agreed
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package org.gcube.portal.tou.removeaccount.thread;
|
||||
|
||||
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