1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.ui.forms.password;
|
12
|
|
13
|
import org.eclipse.jface.wizard.Wizard;
|
14
|
|
15
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
16
|
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
|
17
|
import eu.etaxonomy.cdm.api.service.IUserService;
|
18
|
import eu.etaxonomy.cdm.model.common.User;
|
19
|
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
|
20
|
import eu.etaxonomy.taxeditor.singlesource.org.eclipse.swt.widgets.DisplayProxy;
|
21
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
22
|
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
|
23
|
|
24
|
/**
|
25
|
* @author n.hoffmann
|
26
|
* @created Mar 10, 2011
|
27
|
* @version 1.0
|
28
|
*/
|
29
|
public class PasswordWizard extends Wizard implements IConversationEnabled{
|
30
|
|
31
|
private PasswordWizardPage passwordPage;
|
32
|
private User user;
|
33
|
private ConversationHolder conversation;
|
34
|
|
35
|
public PasswordWizard(ConversationHolder conversation, User user){
|
36
|
this.conversation = conversation;
|
37
|
this.user = user;
|
38
|
}
|
39
|
|
40
|
/* (non-Javadoc)
|
41
|
* @see org.eclipse.jface.wizard.Wizard#addPages()
|
42
|
*/
|
43
|
@Override
|
44
|
public void addPages() {
|
45
|
CdmFormFactory formFactory = new CdmFormFactory(DisplayProxy.getDefault());
|
46
|
|
47
|
// if(CdmStore.getLoginManager().isAdmin()){
|
48
|
//
|
49
|
// }else{
|
50
|
// }
|
51
|
passwordPage = new PasswordWizardPage(formFactory, getConversationHolder(), user);
|
52
|
addPage(passwordPage);
|
53
|
}
|
54
|
|
55
|
/* (non-Javadoc)
|
56
|
* @see org.eclipse.jface.wizard.Wizard#performFinish()
|
57
|
*/
|
58
|
@Override
|
59
|
public boolean performFinish() {
|
60
|
ConversationHolder internalConversation = CdmStore.getLoginManager().getConversationHolder();
|
61
|
internalConversation.bind();
|
62
|
if(CdmStore.getLoginManager().isAdmin()){
|
63
|
CdmStore.getService(IUserService.class).changePasswordForUser(user.getUsername(), passwordPage.getNewPassword());
|
64
|
}else{
|
65
|
CdmStore.getService(IUserService.class).changePassword(passwordPage.getOldPassword(), passwordPage.getNewPassword());
|
66
|
}
|
67
|
internalConversation.commit();
|
68
|
conversation.bind();
|
69
|
return true;
|
70
|
}
|
71
|
|
72
|
/* (non-Javadoc)
|
73
|
* @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
|
74
|
*/
|
75
|
@Override
|
76
|
public void update(CdmDataChangeMap arg0) {
|
77
|
// TODO Auto-generated method stub
|
78
|
|
79
|
}
|
80
|
|
81
|
/* (non-Javadoc)
|
82
|
* @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
|
83
|
*/
|
84
|
@Override
|
85
|
public ConversationHolder getConversationHolder() {
|
86
|
return conversation;
|
87
|
}
|
88
|
|
89
|
}
|