I would like to have one of my pointcut being triggered according to how I name a path variable in my URL.
The fact is that it is a String and I don't want my pointcut to be triggered on every String.
@Pointcut("@annotation(security.annotation.RequireValidUser) && args(datasetName, ..)")
private void methodAnnotatedForValidDatasetName(String datasetName) {
}
In my case this pointcut is successfully triggered in this method (which is ok):
public ResponseEntity<ApiKeyDTO> createApiKey(@PathVariable("name") String datasetName, @RequestBody ApiKeyDTO apiKeyDTO)
But is is also triggered here (which I don't want):
public ResponseEntity<List<ApiKeyDTO>> findApiKeyFromDatasetLabel(@PathVariable("label") String datasetLabel)
I wonder if there are any workaround for me so the pointcut is able to distinguish different Strings with their naming maybe?
EDIT: As suggested by @kuhajeyan, I tried to use 'argNames' as following:
@Pointcut(value = "@annotation(security.annotation.RequireValidUser) && args(datasetName, ..)", argNames = "datasetName")
Unfortunately it doesn't work as intented, it only specifies the name of the arguments inside the pointcut.