diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java index 670fc57af0fe8688c65a9aed2d676c708a357df7..ad201071eba6e7adbecb8b5b61625d34e4573597 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java @@ -348,17 +348,17 @@ public abstract class AbstractServer<T> extends AbstractServiceWithLogger<T> imp private final void updatePersonIfNecessary(final PersonPE person, final Principal principal) { boolean changed = false; - if (person.getEmail().equals(principal.getEmail()) == false) + if (updateNeeded(person.getEmail(), principal.getEmail())) { person.setEmail(principal.getEmail()); changed = true; } - if (person.getFirstName().equals(principal.getFirstName()) == false) + if (updateNeeded(person.getFirstName(), principal.getFirstName())) { person.setFirstName(principal.getFirstName()); changed = true; } - if (person.getLastName().equals(principal.getLastName()) == false) + if (updateNeeded(person.getLastName(), principal.getLastName())) { person.setLastName(principal.getLastName()); changed = true; @@ -375,6 +375,15 @@ public abstract class AbstractServer<T> extends AbstractServiceWithLogger<T> imp } } + private boolean updateNeeded(String currentValue, String newValue) + { + if (newValue == null) + { + return false; + } + return currentValue == null || currentValue.equals(newValue) == false; + } + protected final PersonPE getSystemUser() { return getSystemUser(daoFactory.getPersonDAO().listPersons()); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/query/server/api/v1/QueryApiServerTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/query/server/api/v1/QueryApiServerTest.java index 9bfe012643bd97372ee68c24df9475cb43f580f1..c84f03e0fcfd3d9d91ba138b99aab7500c0f2fc4 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/query/server/api/v1/QueryApiServerTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/query/server/api/v1/QueryApiServerTest.java @@ -108,6 +108,8 @@ public class QueryApiServerTest extends AbstractServerTestCase one(personDAO).tryFindPersonByUserId(session.getUserName()); will(returnValue(person)); + one(personDAO).updatePerson(person); + one(queryServer).initDatabases(SESSION_TOKEN); } });