@ Override protected MatchingPart toPart ( List < MatchingPart > leadingParts , String part ) { switch ( leadingParts . size ( ) ) { case 0 : // The first part must either be a constant or a pure wildcard; expressions such as // <code>if(or("sor","blob"))</code> are not permitted. MatchingPart resolvedPart = createEmoPermissionPart ( part , PartType . CONTEXT ) ; checkArgument ( resolvedPart instanceof ConstantPart || resolvedPart . impliesAny ( ) , "First part must be a constant or pure wildcard" ) ; return resolvedPart ; case 1 : // If the first part was a pure wildcard then there cannot be a second part; expressions such as // "*|create_table" are not permitted. checkArgument ( ! MatchingPart . getContext ( leadingParts ) . impliesAny ( ) , "Cannot narrow permission without initial scope" ) ; return createEmoPermissionPart ( part , PartType . ACTION ) ; case 2 : // For sor and blob permissions the third part narrows to a table. Otherwise it narrows to a // named resource such as a queue name or databus subscription. PartType partType ; if ( MatchingPart . contextImpliedBy ( SOR_PART , leadingParts ) ) { partType = PartType . SOR_TABLE ; } else if ( MatchingPart . contextImpliedBy ( BLOB_PART , leadingParts ) ) { partType = PartType . BLOB_TABLE ; } else { partType = PartType . NAMED_RESOURCE ; } return createEmoPermissionPart ( part , partType ) ; case 3 : // Only roles support four parts, where the group is the third part and the role ID is the fourth part. if ( MatchingPart . contextImpliedBy ( ROLE_PART , leadingParts ) ) { return createEmoPermissionPart ( part , PartType . NAMED_RESOURCE ) ; } break ; } throw new IllegalArgumentException ( format ( "Too many parts for EmoPermission in \"%s\" context" , MatchingPart . getContext ( leadingParts ) ) ) ; }
Override the logic in the parent to meet the requirements for EmoPermission .