Class Site

  • All Implemented Interfaces:
    java.io.Serializable

    public class Site
    extends java.lang.Object
    implements java.io.Serializable
    Site JavaScript object
    Author:
    Roy Wetherall
    See Also:
    Serialized Form
    • Method Detail

      • getSitePreset

        public java.lang.String getSitePreset()
        Get the site preset
        Returns:
        String the site preset
      • getShortName

        public java.lang.String getShortName()
        Set the short name
        Returns:
        String the short name
      • getTitle

        public java.lang.String getTitle()
        Get the title
        Returns:
        String the site title
      • setTitle

        public void setTitle​(java.lang.String title)
        Set the title
        Parameters:
        title - the title
      • getDescription

        public java.lang.String getDescription()
        Get the description
        Returns:
        String the description
      • setDescription

        public void setDescription​(java.lang.String description)
        Set the description
        Parameters:
        description - the description
      • getIsPublic

        public boolean getIsPublic()
        Deprecated.
        since version 3.2, replaced by getVisibility()
        Gets whether the site is public or not
        Returns:
        true is public false otherwise
      • setIsPublic

        public void setIsPublic​(boolean isPublic)
        Deprecated.
        since version 3.2, replaced by setVisibility(String)
        Set whether the site is public or not
        Parameters:
        isPublic - true the site is public false otherwise
      • getVisibility

        public java.lang.String getVisibility()
        Get the site visibility
        Returns:
        String site visibility
      • setVisibility

        public void setVisibility​(java.lang.String visibility)
        Set the site visibility
        Parameters:
        visibility - site visibility (public|moderated|private)
      • getNode

        public ScriptNode getNode()
        Get the site node, null if none
        Returns:
        ScriptNode site node
      • getSiteGroup

        public java.lang.String getSiteGroup()
        Get the site group name
        Returns:
        String site group name
      • getSitePermissionGroups

        public ScriptableHashMap<java.lang.String,​java.lang.String> getSitePermissionGroups()
        Gets a map of role name mapping to associated group name.
        Returns:
        map of role to group name
      • getCreatedDate

        public java.util.Date getCreatedDate()
        Get the site created date
        Returns:
        Date site created date
      • getLastModifiedDate

        public java.util.Date getLastModifiedDate()
        Get the site last modified date
        Returns:
        Date site last modified date
      • save

        public void save()
        Saves any outstanding updates to the site details.

        If properties of the site are changed and save is not called, those changes will be lost.

      • deleteSite

        public void deleteSite()
        Deletes the site
      • listMembers

        public ScriptableHashMap<java.lang.String,​java.lang.String> listMembers​(java.lang.String nameFilter,
                                                                                      java.lang.String roleFilter)
        Gets a map of members of the site with their role within the site. This list can be filtered by name and/or role.

        If no name or role filter is specified all members of the site are listed.

        This list includes both users and groups.

        Parameters:
        nameFilter - user name filter
        roleFilter - user role filter
        Returns:
        list of members of site with their roles
      • listMembers

        public ScriptableHashMap<java.lang.String,​java.lang.String> listMembers​(java.lang.String nameFilter,
                                                                                      java.lang.String roleFilter,
                                                                                      int size)
        Gets a map of members of the site with their role within the site. This list can be filtered by name and/or role.

        If no name or role filter is specified all members of the site are listed.

        This list includes both users and groups.

        Parameters:
        nameFilter - user name filter
        roleFilter - user role filter
        size - max results size crop if >0
        Returns:
        list of members of site with their roles
      • listMembers

        public ScriptableHashMap<java.lang.String,​java.lang.String> listMembers​(java.lang.String nameFilter,
                                                                                      java.lang.String roleFilter,
                                                                                      int size,
                                                                                      boolean collapseGroups)
        Gets a map of members of the site with their role within the site. This list can be filtered by name and/or role.

        If no name or role filter is specified all members of the site are listed.

        This list includes both users and groups if collapseGroups is set to false, otherwise all groups that are members are collapsed into their component users and listed.

        Parameters:
        nameFilter - user name filter
        roleFilter - user role filter
        size - max results size crop if >0
        collapseGroups - true if collapse member groups into user list, false otherwise
        Returns:
        list of members of site with their roles
      • getMembersRole

        public java.lang.String getMembersRole​(java.lang.String authorityName)
        Gets a user's role in this site.

        If the user is not a member of the site then null is returned.

        Parameters:
        authorityName - authority name
        Returns:
        String user's role or null if not a member
      • getMembersRoleInfo

        public SiteMemberInfo getMembersRoleInfo​(java.lang.String authorityName)
        Gets extended information on the user's role in this site.

        If the user is not a member of the site then null is returned.

        Parameters:
        authorityName - authority name
        Returns:
        SiteMemberInfo user's role information or null if not a member
      • isMemberOfGroup

        public boolean isMemberOfGroup​(java.lang.String authorityName)
        Indicates whether a user belongs to a group with access rights to the site or not
        Parameters:
        authorityName - user name
        Returns:
        boolean true if the user belongs to a group with access rights, false otherwise
      • isMember

        public boolean isMember​(java.lang.String authorityName)
        Indicates whether a user is a member of the site.
        Parameters:
        authorityName - user name
        Returns:
        boolean true if the user is a member of the site, false otherwise
      • setMembership

        public void setMembership​(java.lang.String authorityName,
                                  java.lang.String role)
        Sets the membership details for a user.

        If the user is not already a member of the site then they are added with the role given. If the user is already a member of the site then their role is updated to the new role.

        Only a site manager can modify memberships and there must be at least one site manager at all times.

        Parameters:
        authorityName - authority name
        role - site role
      • removeMembership

        public void removeMembership​(java.lang.String authorityName)
        Removes a user or group membership from a site.

        Only a site manager can remove a user's membership and the last site manager can not be removed.

        Parameters:
        authorityName - authority name
      • getContainer

        public ScriptNode getContainer​(java.lang.String componentId)
        Gets (or creates) the "container" folder for the specified component id
        Parameters:
        componentId - String
        Returns:
        node representing the "container" folder (or null, if for some reason the container can not be created - probably due to permissions)
      • createContainer

        public ScriptNode createContainer​(java.lang.String componentId)
        Creates a new site container
        Parameters:
        componentId - component id
        Returns:
        ScriptNode the created container
      • createContainer

        public ScriptNode createContainer​(java.lang.String componentId,
                                          java.lang.String folderType)
        Creates a new site container
        Parameters:
        componentId - component id
        folderType - folder type to create
        Returns:
        ScriptNode the created container
      • createContainer

        public ScriptNode createContainer​(java.lang.String componentId,
                                          java.lang.String folderType,
                                          java.lang.Object permissions)
        Creates a new site container
        Parameters:
        componentId - component id
        folderType - folder type to create
        Returns:
        ScriptNode the created container
      • aquireContainer

        public ScriptNode aquireContainer​(java.lang.String componentId)
        Gets and if missing, creates a new site container. The Site container is created in a new readwrite txn.
        Parameters:
        componentId - component id
        Returns:
        ScriptNode the created container
      • aquireContainer

        public ScriptNode aquireContainer​(java.lang.String componentId,
                                          java.lang.String folderType)
        Gets and if missing, creates a new site container. The Site container is created in a new readwrite txn.
        Parameters:
        componentId - component id
        folderType - folder type to create
        Returns:
        ScriptNode the created container
      • aquireContainer

        public ScriptNode aquireContainer​(java.lang.String componentId,
                                          java.lang.String folderType,
                                          java.lang.Object properties)
        Gets and if missing, creates a new site container. The Site container is created in a new readwrite txn.
        Parameters:
        componentId - component id
        folderType - folder type to create
        Returns:
        ScriptNode the created container
      • createAndSaveContainer

        public ScriptNode createAndSaveContainer​(java.lang.String containerId,
                                                 java.lang.String containerType,
                                                 java.lang.String description)
        This method creates a container of the specified id and type, sets the cm:description on that container node to the specified value and saves the container node updates to the repository. All of this is run as system.
        Parameters:
        containerId - an id for the container node.
        containerType - the type for the container node.
        description - a value for the cm:description property on the container node.
        Returns:
        the newly created and saved container ScriptNode.
        Since:
        3.4
      • hasContainer

        public boolean hasContainer​(java.lang.String componentId)
        Determine if the "container" folder for the specified component exists
        Parameters:
        componentId - String
        Returns:
        true => "container" folder exists
      • setPermissions

        public void setPermissions​(ScriptNode node,
                                   java.lang.Object permissions)
        Apply a set of permissions to the node.
        Parameters:
        node - node
        permissions - permissions
      • resetAllPermissions

        public void resetAllPermissions​(ScriptNode node)
        Reset any permissions that have been set on the node.

        All permissions will be deleted and the node set to inherit permissions.

        Parameters:
        node - node
      • getCustomProperty

        public Site.CustomProperty getCustomProperty​(java.lang.String name)
        Get the value of a custom property, null if the custom property has not been set or doesn't exist.
        Parameters:
        name - qname of the property
        Returns:
        Serializable value of the property, null if not set
      • getCustomProperties

        public ScriptableQNameMap<java.lang.String,​Site.CustomProperty> getCustomProperties()
        Get a map of the sites custom properties
        Returns:
        map of names and values
      • inviteModerated

        public ScriptInvitation<?> inviteModerated​(java.lang.String inviteeComments,
                                                   java.lang.String inviteeUserName,
                                                   java.lang.String inviteeRole)
        Create new moderated invitation to this web site
        Returns:
        the new invitation
      • inviteNominated

        public ScriptInvitation<?> inviteNominated​(java.lang.String inviteeFirstName,
                                                   java.lang.String inviteeLastName,
                                                   java.lang.String inviteeEmail,
                                                   java.lang.String inviteeRole,
                                                   java.lang.String acceptUrl,
                                                   java.lang.String rejectUrl)
        Create new nominated invitation to this web site
        Returns:
        the new invitation
      • inviteNominated

        public ScriptInvitation<?> inviteNominated​(java.lang.String inviteeUserName,
                                                   java.lang.String inviteeRole,
                                                   java.lang.String acceptUrl,
                                                   java.lang.String rejectUrl)
        Create new nominated invitation to this web site
        Returns:
        the new invitation
      • getInvitation

        public ScriptInvitation<?> getInvitation​(java.lang.String invitationId)
        Get an invitation to this web site
        Returns:
        the invitation or null if it does not exist
      • listInvitations

        public ScriptInvitation<?>[] listInvitations()
        list the outstanding invitations for this site Map of name / invitation
      • listInvitations

        public ScriptInvitation<?>[] listInvitations​(org.mozilla.javascript.Scriptable props)
        List the open invitations for this web site. props specifies optional properties to be searched.
        Parameters:
        props - inviteeUserName
        Returns:
        the invitations