diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/authorizationgroup/UpdateAuthorizationGroupExecutor.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/authorizationgroup/UpdateAuthorizationGroupExecutor.java index 5bd928a999e35d85e409776d8ee7e3ca64e0d5d0..0749bda7088ff32841fcd7b305d1da66905d568f 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/authorizationgroup/UpdateAuthorizationGroupExecutor.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/authorizationgroup/UpdateAuthorizationGroupExecutor.java @@ -90,10 +90,10 @@ public class UpdateAuthorizationGroupExecutor for (Map.Entry<AuthorizationGroupUpdate, AuthorizationGroupPE> entry : batch.getObjects().entrySet()) { AuthorizationGroupUpdate update = entry.getKey(); - AuthorizationGroupPE tag = entry.getValue(); + AuthorizationGroupPE group = entry.getValue(); if (update.getDescription() != null && update.getDescription().isModified()) { - tag.setDescription(update.getDescription().getValue()); + group.setDescription(update.getDescription().getValue()); } } } @@ -119,10 +119,7 @@ public class UpdateAuthorizationGroupExecutor @Override protected void save(IOperationContext context, List<AuthorizationGroupPE> entities, boolean clearCache) { - for (AuthorizationGroupPE group : entities) - { - daoFactory.getAuthorizationGroupDAO().persist(group); - } + // Entities updated by Hibernate at the end of the transaction } @Override diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/person/MapPersonByIdExecutor.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/person/MapPersonByIdExecutor.java index 0fd8068ceaec9f639d320e1c356af41312794a8d..cf4553563990ed4ebcea458c3d006aabf2e67354 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/person/MapPersonByIdExecutor.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/person/MapPersonByIdExecutor.java @@ -53,7 +53,7 @@ public class MapPersonByIdExecutor extends AbstractMapObjectByIdExecutor<IPerson protected void addListers(IOperationContext context, List<IListObjectById<? extends IPersonId, PersonPE>> listers) { listers.add(new ListPersonByPermId(personDAO)); - listers.add(new ListPersonByMe()); + listers.add(new ListPersonByMe(personDAO)); } @Autowired diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/helper/person/ListPersonByMe.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/helper/person/ListPersonByMe.java index cf0c8a55e031cc433c9de2173e53c969a28f1c73..db8f4c69359201c065a17235507b1a7850bb3d22 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/helper/person/ListPersonByMe.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/helper/person/ListPersonByMe.java @@ -23,6 +23,8 @@ import ch.ethz.sis.openbis.generic.asapi.v3.dto.person.id.Me; import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.IOperationContext; import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.common.AbstractListObjectById; import ch.systemsx.cisd.common.exceptions.UserFailureException; +import ch.systemsx.cisd.openbis.generic.server.dataaccess.IPersonDAO; +import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; /** @@ -33,6 +35,13 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; public class ListPersonByMe extends AbstractListObjectById<Me, PersonPE> { + private IPersonDAO personDAO; + + public ListPersonByMe(IPersonDAO personDAO) + { + this.personDAO = personDAO; + } + @Override public Me createId(PersonPE entity) { @@ -47,7 +56,10 @@ public class ListPersonByMe extends AbstractListObjectById<Me, PersonPE> { throw new UserFailureException("Can not resolve 'Me' because there is no session user."); } - return Collections.nCopies(ids.size(), person); + // The session user has to be loaded from the database because it isn't in the Hibernate session. + // This is important for example when adding the session user to an authorization group. + PersonPE reloadedPerson = personDAO.getByTechId(TechId.create(person)); + return Collections.nCopies(ids.size(), reloadedPerson); } @Override diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/person/id/Me.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/person/id/Me.js index 1e80686cbab88f969a0b81fa15f61d41d242472b..0a622c85398426780cc76e3856f86ebe8e06ba09 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/person/id/Me.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/person/id/Me.js @@ -1,7 +1,8 @@ define([ "stjs", "as/dto/common/id/ObjectPermId", "as/dto/person/id/IPersonId" ], function(stjs, ObjectPermId, IPersonId) { var Me = function() { + ObjectPermId.call(this, null); }; - stjs.extend(PersonPermId, ObjectPermId, [ ObjectPermId, IPersonId ], function(constructor, prototype) { + stjs.extend(Me, ObjectPermId, [ ObjectPermId, IPersonId ], function(constructor, prototype) { prototype['@type'] = 'as.dto.person.id.Me'; constructor.serialVersionUID = 1; }, {}); diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/asapi/v3/dto/common/id/ObjectPermId.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/asapi/v3/dto/common/id/ObjectPermId.java index 1bfe424b2245365fd055ddb228f2f4211e69878b..128c1f9780eff447c6179f9e4dda3f567af6a47c 100644 --- a/openbis_api/source/java/ch/ethz/sis/openbis/generic/asapi/v3/dto/common/id/ObjectPermId.java +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/asapi/v3/dto/common/id/ObjectPermId.java @@ -16,6 +16,9 @@ package ch.ethz.sis.openbis.generic.asapi.v3.dto.common.id; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + import ch.systemsx.cisd.base.annotation.JsonObject; /** @@ -31,6 +34,7 @@ public abstract class ObjectPermId implements IObjectId private static final long serialVersionUID = 1L; + @JsonProperty private String permId; public ObjectPermId(String permId) @@ -51,6 +55,7 @@ public abstract class ObjectPermId implements IObjectId { } + @JsonIgnore private void setPermId(String permId) { if (permId == null)