dan-s1 commented on code in PR #10134:
URL: https://github.com/apache/nifi/pull/10134#discussion_r2231090580


##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/authorization/StandardAuthorizableLookup.java:
##########
@@ -628,6 +608,25 @@ public Authorizable getAuthorizableFromResource(final 
String resource) {
         }
     }
 
+    private Authorizable handleResourceTypeContainingOtherResourceType(final 
String resource, final ResourceType resourceType) {
+        // get the resource type
+        final String baseResource = StringUtils.substringAfter(resource, 
resourceType.getValue());
+        final ResourceType baseResourceType = 
ResourceType.fromRawValue(baseResource);
+
+        if (baseResourceType == null) {
+            throw new ResourceNotFoundException("Unrecognized base resource: " 
+ resource);
+        }
+
+        return switch (resourceType) {
+            case Policy -> new 
AccessPolicyAuthorizable(getAccessPolicy(baseResourceType, resource));
+            case Data -> new 
DataAuthorizable(getAccessPolicy(baseResourceType, resource));
+            case DataTransfer -> new 
DataTransferAuthorizable(getAccessPolicy(baseResourceType, resource));
+            case ProvenanceData -> new 
ProvenanceDataAuthorizable(getAccessPolicy(baseResourceType, resource));
+            case Operation -> new 
OperationAuthorizable(getAccessPolicy(baseResourceType, resource));
+            default -> null;

Review Comment:
   It did not. I initially did not have a `default` and the compiler complained 
that something has to be returned so I put a return null after the switch 
statement. Then Intellij suggested to refactor to an enhanced switch statement 
whereby it inserted the default with a return of null. Honestly this method 
should never be used except for in the five cases where a resource type can 
have another resource type so the default should never be reached. Its only 
there to make the compiler happy.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to