Class SpaceMcpTool

java.lang.Object
io.meeds.mcp.server.tool.SpaceMcpTool
All Implemented Interfaces:
io.meeds.mcp.server.plugin.McpToolPlugin

@Service public class SpaceMcpTool extends Object implements io.meeds.mcp.server.plugin.McpToolPlugin
  • Constructor Details

    • SpaceMcpTool

      public SpaceMcpTool()
  • Method Details

    • createSpace

      public SpaceModel createSpace(long spaceTemplateId, String name, String description, Visibility visibility, Registration registration, List<String> usernamesToInvite, Long parentSpaceId) throws org.exoplatform.social.core.space.SpaceException
      Throws:
      org.exoplatform.social.core.space.SpaceException
    • updateSpaceSettings

      public SpaceModel updateSpaceSettings(long spaceId, String name, String description, Visibility visibility, Registration registration)
      Updates the settings of a space the current user manages. The current user is the editor of the update, as in the Social REST endpoint.
      Parameters:
      spaceId - the space
      name - the new display name, ignored when blank
      description - the new description, ignored when blank
      visibility - the new visibility, ignored when null
      registration - the new registration, ignored when null
      Returns:
      the updated space
    • getAllSpaces

      public List<SpaceModel> getAllSpaces(String query, Integer offset, Integer limit)
    • getMySpaces

      public List<SpaceModel> getMySpaces(String query, Integer offset, Integer limit)
    • countMySpaces

      public long countMySpaces(String query)
    • getManagedSpaces

      public List<SpaceModel> getManagedSpaces(String query, Integer offset, Integer limit)
    • getSpaceById

      public SpaceModel getSpaceById(long spaceId)
    • listUsersOfSpaceByRole

      public List<UserModel> listUsersOfSpaceByRole(long spaceId, SpaceRole spaceRole, Integer offset, Integer limit)
    • inviteUsersToSpace

      public void inviteUsersToSpace(long spaceId, List<String> usernamesToInvite)
    • removeUsersFromSpace

      public void removeUsersFromSpace(long spaceId, List<String> usernamesToRemove)
      Removes users from a space the current user manages. Refused before any removal when one of them is the space's only manager, or when the list holds every manager; each user is then checked again against the space as stored, right before its removal, so that a change made elsewhere before that read is taken into account. The read and the removal are not one transaction: a manager demoted or removed elsewhere between them, by a concurrent removal of the other manager among others, can still leave the space without one. A refusal at that point leaves the users removed before it removed. The current user is the editor of each removal, as in the Social REST endpoint.
      Parameters:
      spaceId - the space
      usernamesToRemove - the users, possibly prefixed with "@"
      Throws:
      IllegalStateException - when the space doesn't exist, the current user can't manage it, or a removal would leave it without a manager
    • setUserRoleInSpace

      public void setUserRoleInSpace(long spaceId, String username, SpaceRole spaceRole)
    • removeUserRoleInSpace

      public void removeUserRoleInSpace(long spaceId, String username, SpaceRole spaceRole)
      Removes a role of a member of a space the current user manages. The current user is the editor of the change, as in the Social REST endpoint.
      Parameters:
      spaceId - the space
      username - the member
      spaceRole - the role to remove
      Throws:
      IllegalStateException - when the space doesn't exist, the current user can't manage it, the user isn't a member of it, or the role is the manager one of its only manager
    • setSpaceAvatar

      public SpaceModel setSpaceAvatar(long spaceId, String imageUrl, String imageBase64, String attachmentObjectType, String attachmentObjectId, String uploadId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
      Sets a space's avatar from an image provided as exactly one of an http(s) URL, a base64 string, an ACL-checked reference to a readable platform attachment, or the upload id of a file the current user sent with start_upload. Only a manager of the space may change it.
      Parameters:
      spaceId - the space
      imageUrl - the public http(s) URL of the image, or null
      imageBase64 - the base64 bytes of the image, or null
      attachmentObjectType - the type of the object holding an attachment to use, or null
      attachmentObjectId - the id of the object holding an attachment to use, or null
      uploadId - the upload id of an image the current user uploaded, or null; consumed by the call
      Returns:
      the updated space
      Throws:
      IllegalAccessException - when the user does not manage the space, or may not read the attachment
      org.exoplatform.commons.exception.ObjectNotFoundException - when the space, the attachment or the upload does not exist
    • setSpaceBanner

      public SpaceModel setSpaceBanner(long spaceId, String imageUrl, String imageBase64, String attachmentObjectType, String attachmentObjectId, String uploadId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
      Sets a space's banner from an image provided as exactly one of an http(s) URL, a base64 string, an ACL-checked reference to a readable platform attachment, or the upload id of a file the current user sent with start_upload. Only a manager of the space may change it.
      Parameters:
      spaceId - the space
      imageUrl - the public http(s) URL of the image, or null
      imageBase64 - the base64 bytes of the image, or null
      attachmentObjectType - the type of the object holding an attachment to use, or null
      attachmentObjectId - the id of the object holding an attachment to use, or null
      uploadId - the upload id of an image the current user uploaded, or null; consumed by the call
      Returns:
      the updated space
      Throws:
      IllegalAccessException - when the user does not manage the space, or may not read the attachment
      org.exoplatform.commons.exception.ObjectNotFoundException - when the space, the attachment or the upload does not exist
    • joinSpace

      public SpaceModel joinSpace(long spaceId) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • requestToJoinSpace

      public SpaceModel requestToJoinSpace(long spaceId) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • cancelJoinRequest

      public SpaceModel cancelJoinRequest(long spaceId) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • leaveSpace

      public SpaceModel leaveSpace(long spaceId) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • acceptSpaceInvitation

      public SpaceModel acceptSpaceInvitation(long spaceId) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • declineSpaceInvitation

      public SpaceModel declineSpaceInvitation(long spaceId) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • listSpaceJoinRequests

      public List<UserModel> listSpaceJoinRequests(long spaceId, Integer offset, Integer limit) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • acceptSpaceJoinRequest

      public void acceptSpaceJoinRequest(long spaceId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • declineSpaceJoinRequest

      public void declineSpaceJoinRequest(long spaceId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • getSpaceMembers

      public List<SpaceMemberModel> getSpaceMembers(long spaceId, Integer offset, Integer limit) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • listSubSpaces

      public SubSpacesPageModel listSubSpaces(long parentSpaceId, Integer offset, Integer limit) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Lists the sub-spaces of a space that the current user can access. A call limited to one space answers where every member of that space reads it, so it leaves out the hidden sub-spaces, which those members may not know of, and loads further until the page holds limit sub-spaces, the list ends, or 5 loads of limit sub-spaces were made. The page then says where the next one starts, after the last sub-space it read: an offset among the accessible sub-spaces, hidden ones included, so no sub-space is skipped or repeated whatever the page left out.
      Parameters:
      parentSpaceId - the parent space
      offset - the offset among the accessible sub-spaces: 0, or the next offset of the previous page
      limit - the page size, a larger one than 100 is capped
      Returns:
      the sub-spaces of the page, possibly fewer than limit while more follow, and the next page's offset, null when the list has ended
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the parent space doesn't exist
      IllegalAccessException - when the parent space is hidden from the current user
      IllegalArgumentException - when the limit is negative
      IllegalStateException - when the call's identity can't be read, before any sub-space is loaded
    • deleteSpace

      public void deleteSpace(long spaceId) throws org.exoplatform.commons.exception.ObjectNotFoundException, org.exoplatform.social.core.space.SpaceException
      Deletes a space the current user holds the delete permission on, with the current user as the editor of the deletion, as the Social REST endpoint does.
      Parameters:
      spaceId - technical id of the space
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the space doesn't exist
      org.exoplatform.social.core.space.SpaceException - when the space service refuses the deletion
    • getScopeSpaceId

      protected Long getScopeSpaceId()
      Returns:
      the space the current call is limited to, null when it isn't
      Throws:
      IllegalStateException - when the call's identity can't be read