public Collection<AccessPolicyUserData> getUsersWithWriteAccess(ProjectId projectId, boolean includeTemporaryAccount) {
try {
MetaProject metaProject = MetaProjectManager.getManager().getMetaProject();
Collection<AccessPolicyUserData> userList = new TreeSet<AccessPolicyUserData>(new AccessPolicyUserData());
ProjectInstance projectInstance = getProjectInstance(projectId, metaProject);
Policy policy = metaProject.getPolicy();
Operation writeOperation = metaProject.getOperation(OntologyShareAccessConstants.PROJECT_WRITE_ACCESS_OPERATION);
Set<GroupOperation> groupOperations = projectInstance.getAllowedGroupOperations();
Set<User> allPoliciesUsers = new HashSet<User>();
if (isUsersFromDefaultPolicy(groupOperations, writeOperation)) {
AccessPolicyUserData userEveryBodyUserData = new AccessPolicyUserData();
userEveryBodyUserData.setName(OntologyShareAccessConstants.USER_EVERYBODY_NAME);
userList.add(userEveryBodyUserData);
return userList;
}
if (groupOperations != null) {
for (GroupOperation groupOperation1 : groupOperations) {
try {
GroupOperation groupOperation = groupOperation1;
Group group = groupOperation.getAllowedGroup();
if (group.getMembers() != null) {
allPoliciesUsers.addAll(group.getMembers());
}
}
catch (Exception e) {
}
}
}
Group group = metaProject.getGroup(projectId.getId() + OntologyShareAccessConstants.ONTOLOGY_WRITERS_GROUP_SUFFIX);
List<String> groupUserList = getUserListForGroupOperation(projectInstance, group, writeOperation);
for (User user : allPoliciesUsers) {
if (user.getName() != null && policy.isOperationAuthorized(user, writeOperation, projectInstance)) {
if (includeTemporaryAccount || user.getPropertyValue(InvitationConstants.USER_PROPERTY_IS_TEMPORARY_ACCOUNT) == null || !user.getPropertyValue(InvitationConstants.USER_PROPERTY_IS_TEMPORARY_ACCOUNT).trim().equals("true")) { // Proceed if account is not temporary.
AccessPolicyUserData userData = new AccessPolicyUserData();
userData.setName(user.getName());
if (groupUserList.contains(user.getName())) {
userData.setPartofWriters(true);
}
try {
userList.add(userData);
}
catch (Exception e) {