Class GrouperMcpSubjectUtils

java.lang.Object
edu.internet2.middleware.grouper.ws.mcp.GrouperMcpSubjectUtils

public class GrouperMcpSubjectUtils extends Object
Shared utility methods for MCP tools that deal with subject parameters. Provides a consolidated approach using subjectIdOrIdentifier + subjectIdType instead of separate subjectId/subjectIdentifier fields.

The subjectIdType controls how the value is resolved:

  • "subjectIdOrIdentifier" (default) - tries both id and identifier lookup
  • "subjectId" - treats the value as a subject ID only
  • "subjectIdentifier" - treats the value as a subject identifier only
  • Field Details

    • SUBJECT_ID_TYPE_ID_OR_IDENTIFIER

      public static final String SUBJECT_ID_TYPE_ID_OR_IDENTIFIER
      valid values for the subjectIdType parameter
      See Also:
    • SUBJECT_ID_TYPE_ID

      public static final String SUBJECT_ID_TYPE_ID
      valid values for the subjectIdType parameter
      See Also:
    • SUBJECT_ID_TYPE_IDENTIFIER

      public static final String SUBJECT_ID_TYPE_IDENTIFIER
      valid values for the subjectIdType parameter
      See Also:
  • Constructor Details

    • GrouperMcpSubjectUtils

      public GrouperMcpSubjectUtils()
  • Method Details

    • createSubjectLookup

      public static WsSubjectLookup createSubjectLookup(String subjectIdOrIdentifier, String subjectIdType, String sourceId)
      create a WsSubjectLookup from a subjectIdOrIdentifier value and optional subjectIdType. If subjectIdType is null or "subjectIdOrIdentifier", sets both subjectId and subjectIdentifier to the same value so WsSubjectLookup does an id-or-identifier lookup. If subjectIdType is "subjectId", only sets the subjectId field. If subjectIdType is "subjectIdentifier", only sets the subjectIdentifier field.

      For the g:gsa (group) source, applies smart detection: if subjectIdType is "subjectId" but the value contains colons, it is treated as a subjectIdentifier (group name). If subjectIdType is "subjectIdentifier" but the value does not contain colons, it is treated as a subjectId (group UUID).

      Parameters:
      subjectIdOrIdentifier - the subject id or identifier value
      subjectIdType - optional type hint: "subjectIdOrIdentifier" (default), "subjectId", or "subjectIdentifier"
      sourceId - optional source ID to restrict the lookup
      Returns:
      the WsSubjectLookup configured for the appropriate lookup type
    • validateSubjectIdType

      public static String validateSubjectIdType(String subjectIdType)
      validate a subjectIdType value. Returns null if valid, or an error message if invalid.
      Parameters:
      subjectIdType - the value to validate (null/blank is valid, defaults to subjectIdOrIdentifier)
      Returns:
      null if valid, error message if invalid
    • addSubjectIdOrIdentifierProperty

      public static void addSubjectIdOrIdentifierProperty(com.fasterxml.jackson.databind.node.ObjectNode properties, String description)
      add the subjectIdOrIdentifier property to a JSON properties node for tool definitions.
      Parameters:
      properties - the properties node to add to
      description - the description for the field, or null for the default
    • addSubjectIdTypeProperty

      public static void addSubjectIdTypeProperty(com.fasterxml.jackson.databind.node.ObjectNode properties)
      add the subjectIdType property to a JSON properties node for tool definitions.
      Parameters:
      properties - the properties node to add to
    • addSourceIdProperty

      public static void addSourceIdProperty(com.fasterxml.jackson.databind.node.ObjectNode properties, String description)
      add the sourceId property to a JSON properties node for tool definitions.
      Parameters:
      properties - the properties node to add to
      description - the description for the field, or null for the default
    • addSubjectArrayItemProperties

      public static void addSubjectArrayItemProperties(com.fasterxml.jackson.databind.node.ObjectNode subjectProperties)
      add subject properties (subjectIdOrIdentifier, subjectIdType, sourceId) to a JSON properties node inside an array items schema for tool definitions.
      Parameters:
      subjectProperties - the properties node inside the array items to add to