ref #4611 Restructure string externalization for taxeditor.store
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / password / PasswordWizard.java
index 3dbe100ef6134198a5933bbfcbff633414377f34..09289d8c6fb213515e90001e7b428f97180ba1ca 100644 (file)
@@ -1,4 +1,3 @@
-// $Id$
 /**
 * Copyright (C) 2007 EDIT
 * European Distributed Institute of Taxonomy
@@ -20,6 +19,7 @@ import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
 import eu.etaxonomy.cdm.api.service.IUserService;
 import eu.etaxonomy.cdm.model.common.User;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.l10n.Messages;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
@@ -43,11 +43,9 @@ public class PasswordWizard extends Wizard implements IConversationEnabled{
        public PasswordWizard(User user, ConversationHolder conversation){
                this.conversation = conversation;
                this.user = user;
+               setWindowTitle(Messages.PasswordWizardPage_CHANGE_PASSWORD);
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.jface.wizard.Wizard#addPages()
-        */
        @Override
        public void addPages() {
                CdmFormFactory formFactory = new CdmFormFactory(Display.getDefault());
@@ -56,16 +54,15 @@ public class PasswordWizard extends Wizard implements IConversationEnabled{
                addPage(passwordPage);
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.jface.wizard.Wizard#performFinish()
-        */
        @Override
        public boolean performFinish() {
 
                ConversationHolder internalConversation = CdmStore.getCurrentApplicationConfiguration().NewConversation();
            internalConversation.bind();
            internalConversation.startTransaction();
-               try{
+               String warningTitle = Messages.PasswordWizard_COULD_NOT_CHANGE_PWD;
+        String warningMessage = Messages.PasswordWizard_OLD_PWD_INCORRECT;
+        try{
                        if(passwordPage.isChangingOwnPassword()){
                            // change own password with validating of old one
                                CdmStore.getService(IUserService.class).changePassword(passwordPage.getOldPassword(), passwordPage.getNewPassword());
@@ -73,19 +70,21 @@ public class PasswordWizard extends Wizard implements IConversationEnabled{
                            // change others passwords
                            CdmStore.getService(IUserService.class).changePasswordForUser(user.getUsername(), passwordPage.getNewPassword());
                        }
+                       CdmStore.getService(IUserService.class).loadWithUpdate(user.getUuid());
+                       CdmStore.getLoginManager().authenticate(user.getUsername(), passwordPage.getNewPassword());
                    internalConversation.commit(false);
                    internalConversation.unbind();
                    internalConversation.close();
                        return true;
                }catch(AccessDeniedException e){
-                       MessagingUtils.warningDialog("Could not change password", this, "The old password is not correct.");
+                       MessagingUtils.warningDialog(warningTitle, this, warningMessage);
                        return false;
                }catch (AuthenticationException e){
-                       MessagingUtils.warningDialog("Could not change password", this, "The old password is not correct.");
-               
+                       MessagingUtils.warningDialog(warningTitle, this, warningMessage);
+
                        return false;
                }catch(Exception e){
-                       MessagingUtils.warningDialog("Problem with changing password", this, "The password could not be changed. " + e.getMessage());
+                       MessagingUtils.warningDialog(Messages.PasswordWizard_PROBLEM_WITH_CHANGING_PWD, this, Messages.PasswordWizard_PWD_COULD_NOT_BE_CHANGED + e.getMessage());
                        return false;
                }finally{
                    if(conversation != null){
@@ -94,18 +93,10 @@ public class PasswordWizard extends Wizard implements IConversationEnabled{
                }
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
-        */
        @Override
        public void update(CdmDataChangeMap arg0) {
-               // TODO Auto-generated method stub
-
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
-        */
        @Override
        public ConversationHolder getConversationHolder() {
                return conversation;