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 Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String MODERATED_SITE  
      static java.lang.String PRIVATE_SITE  
      static java.lang.String PUBLIC_SITE
      Visibility helper constants
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void cleanSitePermissions​(ScriptNode targetNode)
      This method cleans up the permissions on the specified node and all its primary children.
      void cleanSitePermissions​(org.alfresco.service.cmr.repository.NodeRef targetNode)
      It removes permissions which pertain to sites other than the node's current site.
      Site createSite​(java.lang.String sitePreset, java.lang.String shortName, java.lang.String title, java.lang.String description, boolean isPublic)
      Deprecated.
      Site createSite​(java.lang.String sitePreset, java.lang.String shortName, java.lang.String title, java.lang.String description, java.lang.String visibility)
      Create a new site.
      Site createSite​(java.lang.String sitePreset, java.lang.String shortName, java.lang.String title, java.lang.String description, java.lang.String visibility, java.lang.String siteType)
      Create a new site.
      Site[] findSites​(java.lang.String filter, int size)
      Find (search) the sites available in the repository.
      Site[] findSites​(java.lang.String filter, java.lang.String sitePresetFilter, int size)
      Find (search) the sites available in the repository.
      Site getSite​(java.lang.String shortName)
      Get a site for a provided site short name.
      Site getSiteInfo​(java.lang.String shortName)
      Get a site for a provided site short name.
      Site[] getSites​(java.lang.String filter, java.lang.String sitePresetFilter, int size)
      Retrieves the sites available in the repository.
      boolean hasCreateSitePermissions()
      This method checks if the currently authenticated user has permission to create sites.
      boolean hasSite​(java.lang.String shortName)
      Site existence check.
      boolean isSiteManager​(java.lang.String siteId)
      Determines if the current user is a manager of the given site.
      java.lang.String[] listSiteRoles()
      Returns an array of all the roles that can be assigned to a member of a site.
      java.lang.String[] listSiteRoles​(java.lang.String shortName)
      Returns an array of all the roles that can be assigned to a member of a specific site.
      Site[] listSites​(java.lang.String filter, java.lang.String sitePresetFilter)
      List the sites available in the repository.
      Site[] listSites​(java.lang.String filter, java.lang.String sitePresetFilter, int size)
      List the sites available in the repository.
      Site[] listUserSites​(java.lang.String userName)
      List all the sites that the specified user has an explicit membership to.
      Site[] listUserSites​(java.lang.String userName, int size)
      List all the sites that the specified user has an explicit membership to.
      protected Site[] makeSitesArray​(java.util.List<SiteInfo> siteInfos)
      Converts the given List of SiteInfo objects to a JavaScript friendly array of Site objects.
      void setServiceRegistry​(ServiceRegistry serviceRegistry)
      Sets the Service Registry
      void setSiteService​(SiteService siteService)
      Set the site service
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ScriptSiteService

        public ScriptSiteService()
    • Method Detail

      • 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​(java.lang.String sitePreset,
                               java.lang.String shortName,
                               java.lang.String title,
                               java.lang.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(String, String, String, String, String)
      • createSite

        public Site createSite​(java.lang.String sitePreset,
                               java.lang.String shortName,
                               java.lang.String title,
                               java.lang.String description,
                               java.lang.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​(java.lang.String sitePreset,
                               java.lang.String shortName,
                               java.lang.String title,
                               java.lang.String description,
                               java.lang.String visibility,
                               java.lang.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​(java.lang.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​(java.lang.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​(java.lang.String filter,
                               java.lang.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​(java.lang.String filter,
                                java.lang.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:
        for a description of the limitations of this method.
      • listSites

        public Site[] listSites​(java.lang.String filter,
                                java.lang.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:
        for a description of the limitations of this method.
      • findSites

        public Site[] findSites​(java.lang.String filter,
                                java.lang.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:
        for a description of the limitations of this method.
      • findSites

        public Site[] findSites​(java.lang.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:
        for a description of the limitations of this method.
      • makeSitesArray

        protected Site[] makeSitesArray​(java.util.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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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 java.lang.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​(org.alfresco.service.cmr.repository.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:
        SiteService.cleanSitePermissions(NodeRef, SiteInfo)
      • 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:
        SiteService.cleanSitePermissions(NodeRef, SiteInfo)
      • listSiteRoles

        public java.lang.String[] listSiteRoles​(java.lang.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