Skip to content

Commit

Permalink
Merge pull request DSpace#9742 from saschaszott/patch-44
Browse files Browse the repository at this point in the history
Fix potentially invalid usages of == operator
  • Loading branch information
tdonohue committed Aug 2, 2024
2 parents a25b3cb + a13cc82 commit 02e2e72
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ public boolean isMyResourcePolicy(Context context, EPerson eperson, Integer id)
ResourcePolicy resourcePolicy = resourcePolicyDAO.findOneById(context, id);
Group group = resourcePolicy.getGroup();

if (resourcePolicy.getEPerson() != null && resourcePolicy.getEPerson().getID() == eperson.getID()) {
if (resourcePolicy.getEPerson() != null && resourcePolicy.getEPerson().getID().equals(eperson.getID())) {
isMy = true;
} else if (group != null && groupService.isMember(context, eperson, group)) {
isMy = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public List<Relationship> getLeftRelations(Context context, Entity entity) {
List<Relationship> fullList = entity.getRelationships();
List<Relationship> listToReturn = new LinkedList<>();
for (Relationship relationship : fullList) {
if (relationship.getLeftItem().getID() == entity.getItem().getID()) {
if (relationship.getLeftItem().getID().equals(entity.getItem().getID())) {
listToReturn.add(relationship);
}
}
Expand All @@ -72,7 +72,7 @@ public List<Relationship> getRightRelations(Context context, Entity entity) {
List<Relationship> fullList = entity.getRelationships();
List<Relationship> listToReturn = new LinkedList<>();
for (Relationship relationship : fullList) {
if (relationship.getRightItem().getID() == entity.getItem().getID()) {
if (relationship.getRightItem().getID().equals(entity.getItem().getID())) {
listToReturn.add(relationship);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void addMember(Context context, Group group, EPerson e) {
public void addMember(Context context, Group groupParent, Group groupChild) throws SQLException {
// don't add if it's already a member
// and don't add itself
if (groupParent.contains(groupChild) || groupParent.getID() == groupChild.getID()) {
if (groupParent.contains(groupChild) || groupParent.getID().equals(groupChild.getID())) {
return;
}

Expand Down Expand Up @@ -178,7 +178,7 @@ public void removeMember(Context context, Group group, EPerson ePerson) throws S
Role role = stepByName.getRole();
for (CollectionRole collectionRole : collectionRoles) {
if (StringUtils.equals(collectionRole.getRoleId(), role.getId())
&& claimedTask.getWorkflowItem().getCollection() == collectionRole.getCollection()) {
&& claimedTask.getWorkflowItem().getCollection().equals(collectionRole.getCollection())) {
// Count number of EPersons who are *direct* members of this group
int totalDirectEPersons = ePersonService.countByGroups(context, Set.of(group));
// Count number of Groups which have this groupParent as a direct parent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ private Integer getRelId(String authority) {
private void updateRelationshipPlace(Context context, Item dso, int place, Relationship rs) {

try {
if (rs.getLeftItem() == dso) {
if (rs.getLeftItem().equals(dso)) {
rs.setLeftPlace(place);
} else {
rs.setRightPlace(place);
Expand Down

0 comments on commit 02e2e72

Please sign in to comment.