Skip to content

Commit

Permalink
Fix order and db handling for orgAdmin automatic collabs
Browse files Browse the repository at this point in the history
  • Loading branch information
holmbergius committed Mar 1, 2024
1 parent 783cd19 commit e843320
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/main/java/org/ecocean/security/Collaboration.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,23 @@ public static List<Collaboration> collaborationsForUser(String context, String u
Shepherd myShepherd = new Shepherd(context);
myShepherd.setAction("Collaboration.class1");
myShepherd.beginDBTransaction();
Query query = myShepherd.getPM().newQuery(queryString);
//ArrayList got = myShepherd.getAllOccurrences(query);
List returnMe=myShepherd.getAllOccurrences(query);
query.closeAll();
myShepherd.rollbackDBTransaction();
myShepherd.closeDBTransaction();

returnMe=addAssumedOrgAdminCollaborations(returnMe, myShepherd, username);
List returnMe=new ArrayList();
try {
Query query = myShepherd.getPM().newQuery(queryString);
//ArrayList got = myShepherd.getAllOccurrences(query);
returnMe=myShepherd.getAllOccurrences(query);
query.closeAll();


returnMe=addAssumedOrgAdminCollaborations(returnMe, myShepherd, username);
}
catch(Exception e) {e.printStackTrace();}
finally {
myShepherd.rollbackDBTransaction();
myShepherd.closeDBTransaction();
}



return returnMe;
}
Expand Down Expand Up @@ -407,7 +416,7 @@ public static boolean canUserAccessOwnedObject(String ownerName, HttpServletRequ

String username = request.getUserPrincipal().getName();

return canCollaborate(context, ownerName, username);
return canCollaborate(context, username, ownerName);

}

Expand All @@ -420,7 +429,7 @@ public static boolean canUserAccessEncounter(Encounter enc, HttpServletRequest r
public static boolean canUserAccessEncounter(Encounter enc, String context, String username) {
String owner = enc.getAssignedUsername();
if (User.isUsernameAnonymous(owner)) return true; //anon-owned is "fair game" to anyone
return canCollaborate(context, owner, username);
return canCollaborate(context, username, owner);
}

public static boolean canUserAccessOccurrence(Occurrence occ, HttpServletRequest request) {
Expand Down

0 comments on commit e843320

Please sign in to comment.