Skip to content
Snippets Groups Projects
Commit 450b4f56 authored by felmer's avatar felmer
Browse files

SSDM-5721: bug fixed caused by introduction of Me

SVN: 38991
parent ce0286f0
No related branches found
No related tags found
No related merge requests found
...@@ -90,10 +90,10 @@ public class UpdateAuthorizationGroupExecutor ...@@ -90,10 +90,10 @@ public class UpdateAuthorizationGroupExecutor
for (Map.Entry<AuthorizationGroupUpdate, AuthorizationGroupPE> entry : batch.getObjects().entrySet()) for (Map.Entry<AuthorizationGroupUpdate, AuthorizationGroupPE> entry : batch.getObjects().entrySet())
{ {
AuthorizationGroupUpdate update = entry.getKey(); AuthorizationGroupUpdate update = entry.getKey();
AuthorizationGroupPE tag = entry.getValue(); AuthorizationGroupPE group = entry.getValue();
if (update.getDescription() != null && update.getDescription().isModified()) if (update.getDescription() != null && update.getDescription().isModified())
{ {
tag.setDescription(update.getDescription().getValue()); group.setDescription(update.getDescription().getValue());
} }
} }
} }
...@@ -119,10 +119,7 @@ public class UpdateAuthorizationGroupExecutor ...@@ -119,10 +119,7 @@ public class UpdateAuthorizationGroupExecutor
@Override @Override
protected void save(IOperationContext context, List<AuthorizationGroupPE> entities, boolean clearCache) protected void save(IOperationContext context, List<AuthorizationGroupPE> entities, boolean clearCache)
{ {
for (AuthorizationGroupPE group : entities) // Entities updated by Hibernate at the end of the transaction
{
daoFactory.getAuthorizationGroupDAO().persist(group);
}
} }
@Override @Override
......
...@@ -53,7 +53,7 @@ public class MapPersonByIdExecutor extends AbstractMapObjectByIdExecutor<IPerson ...@@ -53,7 +53,7 @@ public class MapPersonByIdExecutor extends AbstractMapObjectByIdExecutor<IPerson
protected void addListers(IOperationContext context, List<IListObjectById<? extends IPersonId, PersonPE>> listers) protected void addListers(IOperationContext context, List<IListObjectById<? extends IPersonId, PersonPE>> listers)
{ {
listers.add(new ListPersonByPermId(personDAO)); listers.add(new ListPersonByPermId(personDAO));
listers.add(new ListPersonByMe()); listers.add(new ListPersonByMe(personDAO));
} }
@Autowired @Autowired
......
...@@ -23,6 +23,8 @@ import ch.ethz.sis.openbis.generic.asapi.v3.dto.person.id.Me; ...@@ -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.executor.IOperationContext;
import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.common.AbstractListObjectById; import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.common.AbstractListObjectById;
import ch.systemsx.cisd.common.exceptions.UserFailureException; 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; import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE;
/** /**
...@@ -33,6 +35,13 @@ 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> public class ListPersonByMe extends AbstractListObjectById<Me, PersonPE>
{ {
private IPersonDAO personDAO;
public ListPersonByMe(IPersonDAO personDAO)
{
this.personDAO = personDAO;
}
@Override @Override
public Me createId(PersonPE entity) public Me createId(PersonPE entity)
{ {
...@@ -47,7 +56,10 @@ public class ListPersonByMe extends AbstractListObjectById<Me, PersonPE> ...@@ -47,7 +56,10 @@ public class ListPersonByMe extends AbstractListObjectById<Me, PersonPE>
{ {
throw new UserFailureException("Can not resolve 'Me' because there is no session user."); 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 @Override
......
define([ "stjs", "as/dto/common/id/ObjectPermId", "as/dto/person/id/IPersonId" ], function(stjs, ObjectPermId, IPersonId) { define([ "stjs", "as/dto/common/id/ObjectPermId", "as/dto/person/id/IPersonId" ], function(stjs, ObjectPermId, IPersonId) {
var Me = function() { 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'; prototype['@type'] = 'as.dto.person.id.Me';
constructor.serialVersionUID = 1; constructor.serialVersionUID = 1;
}, {}); }, {});
......
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
package ch.ethz.sis.openbis.generic.asapi.v3.dto.common.id; 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; import ch.systemsx.cisd.base.annotation.JsonObject;
/** /**
...@@ -31,6 +34,7 @@ public abstract class ObjectPermId implements IObjectId ...@@ -31,6 +34,7 @@ public abstract class ObjectPermId implements IObjectId
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@JsonProperty
private String permId; private String permId;
public ObjectPermId(String permId) public ObjectPermId(String permId)
...@@ -51,6 +55,7 @@ public abstract class ObjectPermId implements IObjectId ...@@ -51,6 +55,7 @@ public abstract class ObjectPermId implements IObjectId
{ {
} }
@JsonIgnore
private void setPermId(String permId) private void setPermId(String permId)
{ {
if (permId == null) if (permId == null)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment