You are looking at documentation for an older release. Not what you want? See the current release documentation.
A Site is comprised of a set of pages, navigation definitions, and can be assigned a unique skin. There are three different types of sites: standard sites, group spaces and user dashboards.
A specific site can be retrieved by its SiteId
.
The SiteId
is constructed by passing either the name for a standard site,
the group for a group space or the user for a user dashboard. Alternatively it can be constructed by passing the SiteType and name.
Example of Retrieving Sites is Shown below:
Site standardSite = portal.getSite(new SiteId("classic"));
Site groupSpace = portal.getSite(new SiteId(new Group("platform", "administrators")));
Site userDashboard = portal.getSite(new SiteId(new User("john")));
It is also possible to query for sites using the SiteQuery. The SiteQuery supports filtering, sorting and pagination when querying for sites.
The example below finds standard sites that a user has access permissions to, limited to the 10 first results:
SiteQuery.Builder qb = new SiteQuery.Builder();
qb.withSiteTypes(SiteType.SITE).withPagination(0, 10).withFilter(new Filter<Site>() {
public boolean accept(Site site) {
return portal.hasPermission(user, site.getAccessPermission());
}
});
List<Site> sites = portal.findSites(qb.build());
The default number of results to return is 15. Which means that if no pagination is set while building the query, the maximum number of results will be 15. So be sure to set the correct pagination while querying.
To create a site, first create a new site through the Portal, then set the configuration for the site (such as localized display names and skin), and finally save it using the Portal.
The example below creates a new standard site with the name mysite and a non-localized display name:
Site site = portal.createSite(new SiteId("foo"));
site.setDisplayName("My Site");
portal.saveSite(site);
The site is not visible (or persisted) until saveSitesaveSite is invoked.
It is possible to change attributes for the site, supported attributes are:
sessionAlive : sets if a session is kept alive or not. Valid values are "onDemand", "always", and "never" with the default being "onDemand".
showPortletInfo : sets if the info bar is shown by default when adding applications to pages, the default is 'false'.
The attributes are set by using the associated Key, the example below changes the sessionAlive attribute:
site.getAttributes().put(Site.AttributeKeys.SESSION_BEHAVIOR, "always");
Associated with a site is an access permission and an edit permission, which controls what users and groups are allowed to access and edit the site respectively.
The example below makes a site accessible by everyone, but only editable by users in the /platform/administrators group:
site.setAccessPermission(Permission.everyone());
site.setEditPermission(Permission.any("platform", "administrators"));
portal.saveSite(site);
The changed permissions do not take affect until saveSite is invoked.
A site is deleted by invoking removeSite on the Portal.