docs: provide complete TaskAuthorizationProvider example - #1146
docs: provide complete TaskAuthorizationProvider example#1146hutiefang76 wants to merge 2 commits into
Conversation
|
|
||
| @ApplicationScoped | ||
| public class MyTaskAuthorizationProvider implements TaskAuthorizationProvider { | ||
| private final ConcurrentMap<String, String> owners = new ConcurrentHashMap<>(); |
There was a problem hiding this comment.
I think the variable ownershipStore makes more sense
There was a problem hiding this comment.
Renamed the map to ownershipStore in both the development guide and the API Javadoc example in ff9a841.
| @Override | ||
| public boolean checkRead(ServerCallContext context, String taskId, TaskOperation op) { | ||
| return isOwner(context.getUser(), taskId); | ||
| String owner = owners.get(taskId); |
There was a problem hiding this comment.
I think this should be in a private method isOwner
There was a problem hiding this comment.
Extracted the ownership lookup into a private isOwner(context, taskId) helper in both examples in ff9a841.
| @Override | ||
| public boolean checkWrite(ServerCallContext context, String taskId, TaskOperation op) { | ||
| return isOwner(context.getUser(), taskId); | ||
| return checkRead(context, taskId, op); |
There was a problem hiding this comment.
calling isOwner here to avoid calling API code
There was a problem hiding this comment.
Both checkRead and checkWrite now call the private isOwner helper directly in ff9a841. The development guide and Javadoc examples are identical. The docs package and server-common reactor package builds passed locally (tests skipped for this documentation-only change).
Description
The authorization examples referenced undefined
isOwnerandownershipStoresymbols, so they could not be used as a complete implementation ofTaskAuthorizationProvider.This change:
putIfAbsent; andTesting
mvn -o -Dmaven.repo.local=/tmp/m2-a2a-1143 -f docs/pom.xml -DskipTests packagemvn -Dmaven.repo.local=/tmp/m2-a2a-1143 -pl server-common -am -DskipTests packageFixes #1143 🦕