Class ScriptSiteService

All Implemented Interfaces:
org.alfresco.processor.ProcessorExtension, Scopeable

public class ScriptSiteService extends BaseScopableProcessorExtension
Script object representing the site service.
Author:
Roy Wetherall
  • Field Details

  • Constructor Details

    • ScriptSiteService

      public ScriptSiteService()
  • Method Details

    • setServiceRegistry

      public void setServiceRegistry(ServiceRegistry serviceRegistry)
      Sets the Service Registry
      Parameters:
      serviceRegistry - ServiceRegistry
    • setSiteService

      public void setSiteService(SiteService siteService)
      Set the site service
      Parameters:
      siteService - the site service
    • createSite

      public Site createSite(String sitePreset, String shortName, String title, String description, boolean isPublic)
      Deprecated.
      Parameters:
      sitePreset - site preset
      shortName - site short name
      title - site title
      description - site description
      isPublic - whether the site is public or not
      Returns:
      Site the created site
      See Also:
    • createSite

      public Site createSite(String sitePreset, String shortName, String title, String description, String visibility)
      Create a new site.

      The site short name will be used to uniquely identify the site so it must be unique.

      Parameters:
      sitePreset - site preset
      shortName - site short name
      title - site title
      description - site description
      visibility - visibility of the site (public|moderated|private)
      Returns:
      Site the created site
    • createSite

      public Site createSite(String sitePreset, String shortName, String title, String description, String visibility, String siteType)
      Create a new site.

      The site short name will be used to uniquely identify the site so it must be unique.

      Parameters:
      sitePreset - site preset
      shortName - site short name
      title - site title
      description - site description
      visibility - visibility of the site (public|moderated|private)
      siteType - qname of site type to create
      Returns:
      Site the created site
    • hasSite

      public boolean hasSite(String shortName)
      Site existence check. Allows private site existence to be tested.
      Parameters:
      shortName - site short name
      Returns:
      true if the site exists, false otherwise.
    • hasCreateSitePermissions

      public boolean hasCreateSitePermissions()
      This method checks if the currently authenticated user has permission to create sites.
      Returns:
      true if the current user is a Contributor to "Sites" node, else false.
      Since:
      3.4
    • isSiteManager

      public boolean isSiteManager(String siteId)
      Determines if the current user is a manager of the given site.
      Parameters:
      siteId - The short name of the site to check
      Returns:
      true if the current user is a manager of the given site
    • getSites

      public Site[] getSites(String filter, String sitePresetFilter, int size)
      Retrieves the sites available in the repository. The returned list can optionally be filtered by name and site preset. If no filters are specified then all the available sites are returned. NOTE: If the filter starts with a * a Lucene based search will be performed, this may discover a wider range of results i.e. those sites that contain the search term as opposed to those that start with the search term, but newly created sites may not be found until the underlying search indexes are updated.
      Parameters:
      filter - inclusion filter for returned sites. Only sites whose cm:name OR cm:title OR cm:description start with the filter string will be returned.
      sitePresetFilter - site preset filter
      size - max results size crop if >0
      Returns:
      Site[] a list of the site filtered as appropriate
    • listSites

      public Site[] listSites(String filter, String sitePresetFilter)
      List the sites available in the repository. The returned list can optionally be filtered by name and site preset.

      If no filters are specified then all the available sites are returned.

      Parameters:
      filter - inclusion filter for returned sites. Only sites whose cm:name OR cm:title OR cm:description start with the filter string will be returned.
      sitePresetFilter - site preset filter
      Returns:
      Site[] a list of the site filtered as appropriate
      See Also:
    • listSites

      public Site[] listSites(String filter, String sitePresetFilter, int size)
      List the sites available in the repository. The returned list can optionally be filtered by name and site preset.

      If no filters are specified then all the available sites are returned.

      Parameters:
      filter - inclusion filter for returned sites. Only sites whose cm:name OR cm:title OR cm:description start with the filter string will be returned.
      sitePresetFilter - site preset filter
      size - max results size crop if >0
      Returns:
      Site[] a list of the site filtered as appropriate
      See Also:
    • findSites

      public Site[] findSites(String filter, String sitePresetFilter, int size)
      Find (search) the sites available in the repository. The returned list can optionally be filtered by name and site preset.

      If no filters are specified then all the available sites are returned.

      Parameters:
      filter - inclusion filter for returned sites. Only sites whose cm:name OR cm:title OR cm:description CONTAIN the filter string will be returned.
      sitePresetFilter - site preset filter
      size - max results size crop if >0
      Returns:
      Site[] a list of the site filtered as appropriate
      Since:
      4.0
      See Also:
    • findSites

      public Site[] findSites(String filter, int size)
      Find (search) the sites available in the repository. The returned list can optionally be filtered by name

      Parameters:
      filter - inclusion filter for returned sites. Only sites whose cm:name OR cm:title OR cm:description CONTAIN the filter string will be returned.
      size - max results size crop if >0
      Returns:
      Site[] a list of the site filtered as appropriate
      Since:
      5.0
      See Also:
    • makeSitesArray

      protected Site[] makeSitesArray(List<SiteInfo> siteInfos)
      Converts the given List of SiteInfo objects to a JavaScript friendly array of Site objects.
      Returns:
      Array of Site objects
    • listUserSites

      public Site[] listUserSites(String userName, int size)
      List all the sites that the specified user has an explicit membership to.
      Parameters:
      userName - user name
      size - maximum list size
      Returns:
      Site[] a list of sites the user has an explicit membership to
    • listUserSites

      public Site[] listUserSites(String userName)
      List all the sites that the specified user has an explicit membership to.
      Parameters:
      userName - user name
      Returns:
      Site[] a list of sites the user has an explicit membership to
    • getSite

      public Site getSite(String shortName)
      Get a site for a provided site short name.

      Returns null if the site does not exist.

      Parameters:
      shortName - short name of the site
      Returns:
      Site the site, null if does not exist
    • getSiteInfo

      public Site getSiteInfo(String shortName)
      Get a site for a provided site short name. If the current user does not have permission to view the site content, the info will still be returned, but none of the operations that would modify site information on save() will work. As usual ACLs will apply on any attempt to modify the Site object.

      Returns null if the site does not exist.

      Parameters:
      shortName - short name of the site
      Returns:
      Site the site, null if does not exist
    • listSiteRoles

      public String[] listSiteRoles()
      Returns an array of all the roles that can be assigned to a member of a site.
      Returns:
      String[] roles available to assign to a member of a site
    • cleanSitePermissions

      public void cleanSitePermissions(NodeRef targetNode)
      It removes permissions which pertain to sites other than the node's current site.
      Parameters:
      targetNode - the root node which is to have its permissions cleaned.
      See Also:
    • cleanSitePermissions

      public void cleanSitePermissions(ScriptNode targetNode)
      This method cleans up the permissions on the specified node and all its primary children. It removes permissions which pertain to sites other than the node's current site.
      Since:
      3.4.2
      See Also:
    • listSiteRoles

      public String[] listSiteRoles(String shortName)
      Returns an array of all the roles that can be assigned to a member of a specific site.
      Returns:
      String[] roles available to assign to a member of a site