#5309, #5310 Add load method to retrieve user entity after create and password change
authorCherian Mathew <c.mathew@bgbm.org>
Thu, 8 Oct 2015 13:12:38 +0000 (15:12 +0200)
committerCherian Mathew <c.mathew@bgbm.org>
Thu, 8 Oct 2015 13:13:45 +0000 (15:13 +0200)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/entitycreator/UserCreator.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/service/CdmServiceRequestExecutor.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/password/PasswordWizard.java

index 91b7734797b5af7b5ded0242db68422bb69aab9a..81ebab53c8c63236ee855d06810806a8a13b884d 100644 (file)
@@ -44,7 +44,8 @@ public class UserCreator  implements IEntityCreator<User>{
                try{
                        User user = User.NewInstance(text, text);
                         if(CdmStore.getCurrentSessionManager().isRemoting()) {
-                            user = CdmStore.getService(IUserService.class).merge(user);
+                            CdmStore.getService(IUserService.class).createUser(user);
+                            user = CdmStore.getService(IUserService.class).loadWithUpdate(user.getUuid());
                         } else {
                             CdmStore.getService(IUserService.class).createUser(user);
                         }
index 065a7f24de067ac0002060dabca232ece0c68cb2..d8a07325c67aef0ee3b8a773eca14d5256e9332c 100644 (file)
@@ -2,6 +2,8 @@ package eu.etaxonomy.taxeditor.service;
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.util.HashSet;
+import java.util.Set;
 
 import org.apache.log4j.Logger;
 import org.springframework.remoting.httpinvoker.HttpInvokerClientConfiguration;
@@ -23,8 +25,17 @@ public class CdmServiceRequestExecutor extends CdmAuthenticatedHttpInvokerReques
 
        private RemoteInvocation currentRemoteInvocation;
 
+       protected final static Set<String> cachableMethods = new HashSet<String>();
 
 
+
+       public CdmServiceRequestExecutor() {
+           cachableMethods.add("merge");
+           cachableMethods.add("save");
+           cachableMethods.add("findWithUpdate");
+           cachableMethods.add("loadWithUpdate");
+       }
+
        @Override
        protected void writeRemoteInvocation(RemoteInvocation invocation, OutputStream os) throws IOException {
            if(cdmEntitySessionManager == null) {
@@ -42,18 +53,12 @@ public class CdmServiceRequestExecutor extends CdmAuthenticatedHttpInvokerReques
                                        java.lang.ClassNotFoundException {
                RemoteInvocationResult rir = fromCache(currentRemoteInvocation);
 
-               // if rir is not null at this point we assume that the
-               // the object has already been loaded in the cache and
-               // does not need to be reloaded
-
                if(rir == null) {
                    logger.info("Remote invoking : " + currentRemoteInvocation.getMethodName() + "@" + config.getServiceUrl());
                        rir = super.doExecuteRequest(config, baos);
                        if(rir.getValue() != null && !rir.hasException()) {
-                if("merge".equals(currentRemoteInvocation.getMethodName()) ||
-                        "save".equals(currentRemoteInvocation.getMethodName()) ||
-                        "findWithUpdate".equals(currentRemoteInvocation.getMethodName())) {
-                            rir = new RemoteInvocationResult(cdmEntitySessionManager.load(rir.getValue(), true));
+                if(cachableMethods.contains(currentRemoteInvocation.getMethodName())) {
+                    rir = new RemoteInvocationResult(cdmEntitySessionManager.load(rir.getValue(), true));
                 } else if(rir.getValue() instanceof UpdateResult){
                     UpdateResult result = (UpdateResult)rir.getValue();
                     if(result.isOk()){
index 3dbe100ef6134198a5933bbfcbff633414377f34..177a16a917db82ccab6e70126f11b7a7f0c3679b 100644 (file)
@@ -73,6 +73,7 @@ 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());
                    internalConversation.commit(false);
                    internalConversation.unbind();
                    internalConversation.close();
@@ -82,7 +83,7 @@ public class PasswordWizard extends Wizard implements IConversationEnabled{
                        return false;
                }catch (AuthenticationException e){
                        MessagingUtils.warningDialog("Could not change password", this, "The old password is not correct.");
-               
+
                        return false;
                }catch(Exception e){
                        MessagingUtils.warningDialog("Problem with changing password", this, "The password could not be changed. " + e.getMessage());