Revision 49d3c2dd
Added by Katja Luther over 1 year ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/password/PasswordWizard.java | ||
---|---|---|
14 | 14 |
import org.springframework.security.access.AccessDeniedException; |
15 | 15 |
import org.springframework.security.core.AuthenticationException; |
16 | 16 |
|
17 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
18 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
|
19 | 17 |
import eu.etaxonomy.cdm.api.service.IUserService; |
20 | 18 |
import eu.etaxonomy.cdm.model.permission.User; |
21 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
|
22 | 19 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
23 | 20 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
24 | 21 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
... | ... | |
29 | 26 |
* @created Mar 10, 2011 |
30 | 27 |
* @version 1.0 |
31 | 28 |
*/ |
32 |
public class PasswordWizard extends Wizard implements IConversationEnabled{
|
|
29 |
public class PasswordWizard extends Wizard { |
|
33 | 30 |
|
34 | 31 |
private PasswordWizardPage passwordPage; |
35 | 32 |
private final User user; |
36 |
private final ConversationHolder conversation; |
|
37 |
|
|
33 |
|
|
38 | 34 |
/** |
39 | 35 |
* @param user the user to change the password for |
40 | 36 |
* @param conversation this optional parameter can be null. Only supply conversation if you |
41 | 37 |
* need to run this wizard is a nested conversation |
42 | 38 |
*/ |
43 |
public PasswordWizard(User user, ConversationHolder conversation){ |
|
44 |
this.conversation = conversation; |
|
39 |
public PasswordWizard(User user){ |
|
45 | 40 |
this.user = user; |
46 | 41 |
setWindowTitle(Messages.PasswordWizardPage_CHANGE_PASSWORD); |
47 | 42 |
} |
... | ... | |
50 | 45 |
public void addPages() { |
51 | 46 |
CdmFormFactory formFactory = new CdmFormFactory(Display.getDefault()); |
52 | 47 |
|
53 |
passwordPage = new PasswordWizardPage(formFactory, getConversationHolder(), user);
|
|
48 |
passwordPage = new PasswordWizardPage(formFactory, user); |
|
54 | 49 |
addPage(passwordPage); |
55 | 50 |
} |
56 | 51 |
|
57 | 52 |
@Override |
58 | 53 |
public boolean performFinish() { |
59 | 54 |
|
60 |
ConversationHolder internalConversation = CdmStore.getCurrentApplicationConfiguration().NewConversation(); |
|
61 |
internalConversation.bind(); |
|
62 |
internalConversation.startTransaction(); |
|
63 | 55 |
String warningTitle = Messages.PasswordWizard_COULD_NOT_CHANGE_PWD; |
64 | 56 |
String warningMessage = Messages.PasswordWizard_OLD_PWD_INCORRECT; |
65 | 57 |
try{ |
... | ... | |
74 | 66 |
if (user.equals(CdmStore.getLoginManager().getAuthenticatedUser())){ |
75 | 67 |
CdmStore.getLoginManager().authenticate(user.getUsername(), passwordPage.getNewPassword()); |
76 | 68 |
} |
77 |
internalConversation.commit(false); |
|
78 |
internalConversation.unbind(); |
|
79 |
internalConversation.close(); |
|
80 |
return true; |
|
69 |
return true; |
|
81 | 70 |
}catch(AccessDeniedException e){ |
82 | 71 |
MessagingUtils.warningDialog(warningTitle, this, warningMessage); |
83 | 72 |
return false; |
... | ... | |
88 | 77 |
}catch(Exception e){ |
89 | 78 |
MessagingUtils.warningDialog(Messages.PasswordWizard_PROBLEM_WITH_CHANGING_PWD, this, Messages.PasswordWizard_PWD_COULD_NOT_BE_CHANGED + e.getMessage()); |
90 | 79 |
return false; |
91 |
}finally{ |
|
92 |
if(conversation != null){ |
|
93 |
conversation.bind(); |
|
94 |
} |
|
95 | 80 |
} |
96 | 81 |
} |
97 | 82 |
|
98 |
@Override |
|
99 |
public void update(CdmDataChangeMap arg0) { |
|
100 |
} |
|
101 |
|
|
102 |
@Override |
|
103 |
public ConversationHolder getConversationHolder() { |
|
104 |
return conversation; |
|
105 |
} |
|
106 |
|
|
83 |
|
|
107 | 84 |
} |
Also available in: Unified diff
ref #10186: remove conversation holder