Class McpToolPluginUtils

java.lang.Object
io.meeds.mcp.server.tool.util.McpToolPluginUtils

public class McpToolPluginUtils extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The largest page a list tool returns, whatever limit its caller asks for.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    clampLimit(Integer limit, int defaultValue)
    Computes the page size a list tool applies: the default one when the caller asked for none, or for zero or less, and never more than MAX_LIMIT.
    static int
    clampLimit(Integer limit, int defaultValue, int max)
    Computes the page size a list tool applies: the default one when the caller asked for none, or for zero or less, and never more than max.
    static int
    getInteger(Integer i, int defaultValue)
     
    static String
    transformHtmlContent(String htmlText, org.exoplatform.services.security.Identity aclIdentity, Locale locale)
    Transforms an HTML text the way the platform renders it for a viewer.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_LIMIT

      public static final int MAX_LIMIT
      The largest page a list tool returns, whatever limit its caller asks for.
      See Also:
  • Method Details

    • getInteger

      public static int getInteger(Integer i, int defaultValue)
      Parameters:
      i - the value a tool received, may be null
      defaultValue - the value to use when none, or zero, was received
      Returns:
      the received value, or the default one when it is null or zero
    • clampLimit

      public static int clampLimit(Integer limit, int defaultValue)
      Computes the page size a list tool applies: the default one when the caller asked for none, or for zero or less, and never more than MAX_LIMIT.
      Parameters:
      limit - the limit the caller asked for, may be null
      defaultValue - the page size to use when the caller asked for none
      Returns:
      the page size to apply, at most MAX_LIMIT
    • clampLimit

      public static int clampLimit(Integer limit, int defaultValue, int max)
      Computes the page size a list tool applies: the default one when the caller asked for none, or for zero or less, and never more than max.
      Parameters:
      limit - the limit the caller asked for, may be null
      defaultValue - the page size to use when the caller asked for none
      max - the largest page size the tool returns
      Returns:
      the page size to apply
    • transformHtmlContent

      public static String transformHtmlContent(String htmlText, org.exoplatform.services.security.Identity aclIdentity, Locale locale)
      Transforms an HTML text the way the platform renders it for a viewer.
      Parameters:
      htmlText - the HTML text
      aclIdentity - the viewer's identity
      locale - the viewer's locale
      Returns:
      the transformed HTML text