Class Site

java.lang.Object
org.alfresco.repo.site.script.Site
All Implemented Interfaces:
Serializable

public class Site extends Object implements Serializable
Site JavaScript object
Author:
Roy Wetherall
See Also:
  • Method Details

    • getSitePreset

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

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

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

      public void setTitle(String title)
      Set the title
      Parameters:
      title - the title
    • getDescription

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

      public void setDescription(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 String getVisibility()
      Get the site visibility
      Returns:
      String site visibility
    • setVisibility

      public void setVisibility(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 String getSiteGroup()
      Get the site group name
      Returns:
      String site group name
    • getSitePermissionGroups

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

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

      public 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<String,String> listMembers(String nameFilter, 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<String,String> listMembers(String nameFilter, 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<String,String> listMembers(String nameFilter, 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 String getMembersRole(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(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(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(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(String authorityName, 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(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(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(String componentId)
      Creates a new site container
      Parameters:
      componentId - component id
      Returns:
      ScriptNode the created container
    • createContainer

      public ScriptNode createContainer(String componentId, 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(String componentId, String folderType, 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(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(String componentId, 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(String componentId, String folderType, 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(String containerId, String containerType, 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(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, 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(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<String,Site.CustomProperty> getCustomProperties()
      Get a map of the sites custom properties
      Returns:
      map of names and values
    • inviteModerated

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

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

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

      public ScriptInvitation<?> getInvitation(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