Open MikeNeilson opened 1 month ago
Perhaps CwmsDtoBase should have a getOffice function that CwmsDto can have a default implementation of. At a certain point the DAO need a reference office to set the session permissions, when I first designed that I hadn't considered the nest objects, changing that to a function that downstream implementations provide is probably the best thing.
I only see two references to the Dao.setOfficeId(Context, CwmsDTO) method. Everything else uses the Dao.setOfficeId(Context, String) overload. Is there somewhere else that I'm not seeing that relies on the office for session permissions?
Dang it man, stop pointing out my obvious design failures! :).
Anyways, every call to a non-readonly operation requires the session office being set. We determined the best way was at the point of the Dao's usage of the connection (as it would actually be an active connection that will be directly used.)
Since every DAO was taking a CwmsDto Ryan or I likely made the CwmsDTO over to simplify the operations, for the String overload that was probably for testing.
I would argue that:
So I think I propose changing CwmsDto to
public interface CwmsDto extends CwmsDtoBase {
@JsonIgnore
String getSessionOffice();
@JsonIgnore
CwmsId getCwmsId(); // maybe, implementing DTOs can tell the parsers to split as appropriate but with these two it seems we can properly identify everything.
}
NOTE: approved, but definitely needs some discussion first.
Something else to note: every post would have a DTO with a session office, but delete and rename operations only use query parameters.
I can create a ticket for that, but adding the annotation back in will be problematic right now.
_Originally posted by @RyanM-RMA in https://github.com/USACE/cwms-data-api/pull/731#discussion_r1670885826_