Skip to content

Commit

Permalink
fix #10683 with lazy user.getGroupIds()
Browse files Browse the repository at this point in the history
  • Loading branch information
svuillet committed May 15, 2019
1 parent 475232e commit 3931c7e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
Expand Up @@ -1461,11 +1461,7 @@ public String[] getAssignedStates(User user, String roleName) throws WorkflowExc
boolean userGroupsMatch = false;
if (StringUtil.isDefined(wkUser.getGroupId())) {
// check if one of userGroups matches with working group
List<String> groupIds = Arrays.asList(OrganisationControllerFactory.getOrganisationController()
.getAllGroupIdsOfUser(wkUser.getId()));
if (groupIds != null) {
userGroupsMatch = groupIds.contains(wkUser.getGroupId());
}
userGroupsMatch = user.getGroupIds().contains(wkUser.getGroupId());
}

SilverTrace.debug("workflowEngine", "ProcessInstanceImpl.getAssignedStates",
Expand Down
Expand Up @@ -29,7 +29,10 @@
import com.stratelia.webactiv.beans.admin.AdminReference;
import com.stratelia.webactiv.beans.admin.UserDetail;
import com.stratelia.webactiv.beans.admin.UserFull;
import org.silverpeas.core.admin.OrganisationControllerFactory;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
Expand Down Expand Up @@ -120,10 +123,14 @@ public boolean equals(Object user) {

@Override
public List<String> getGroupIds() {
if (groupIds == null) {
String[] ids = OrganisationControllerFactory.getOrganisationController().getAllGroupIdsOfUser(getUserId());
if (ids != null) {
groupIds = Arrays.asList(ids);
} else {
groupIds = new ArrayList<String>();
}
}
return groupIds;
}

public void setGroupIds(List<String> groupIds) {
this.groupIds = groupIds;
}
}
Expand Up @@ -69,11 +69,6 @@ public UserManagerImpl() {
@Override
public User getUser(String userId) throws WorkflowException {
UserImpl user = new UserImpl(getUserDetail(userId));
String[] groupIds = OrganisationControllerFactory.getOrganisationController()
.getAllGroupIdsOfUser(userId);
if (groupIds != null) {
user.setGroupIds(Arrays.asList(groupIds));
}
return user;
}

Expand Down

0 comments on commit 3931c7e

Please sign in to comment.