Class SpaceNameResolver

java.lang.Object
org.exoplatform.documents.mcp.SpaceNameResolver

public class SpaceNameResolver extends Object
Finds the space a document tool call names by its name, among the spaces the calling user is a member of, and only those: a space the user isn't a member of is never found, whatever its visibility.

The name is matched against the space's display name, ignoring case, leading and trailing whitespace and repeated inner whitespace. Only when no display name matches, it is matched against the space's pretty name (its URL name) or its group id (/spaces/<pretty name>), ignoring case. Nothing is ever guessed: no match is refused with the closest names the user's spaces carry, and several spaces with that name are refused with their ids, so the caller picks one by its id.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The most spaces a refusal names.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SpaceNameResolver(org.exoplatform.social.core.space.spi.SpaceService spaceService)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.exoplatform.social.core.space.model.Space
    resolve(String spaceName, String username)
    Finds the one space with that name among the spaces the user is a member of.

    Methods inherited from class Object

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

    • MAX_SUGGESTIONS

      public static final int MAX_SUGGESTIONS
      The most spaces a refusal names.
      See Also:
  • Constructor Details

    • SpaceNameResolver

      public SpaceNameResolver(org.exoplatform.social.core.space.spi.SpaceService spaceService)
      Parameters:
      spaceService - reads the spaces the user is a member of
  • Method Details

    • resolve

      public org.exoplatform.social.core.space.model.Space resolve(String spaceName, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Finds the one space with that name among the spaces the user is a member of.
      Parameters:
      spaceName - the space's name as the caller gave it
      username - the calling user
      Returns:
      the space, never null
      Throws:
      IllegalArgumentException - when the name is blank, or when several of the user's spaces carry it: the message lists them with their ids
      org.exoplatform.commons.exception.ObjectNotFoundException - when none of the user's spaces carries it: the message names the closest ones