SiteService Class
Service for performing site specific operations.
Constructor
SiteService
()
Item Index
Methods
- activateSite
- areEqual
- createSite
- deactivateSite
- deleteSiteSpecificContent
- editSite
- getActiveSites
- getAllSites
- getByUid
- getCurrentSite
- getExistingDisplayNameHostnameCounts
- getGlobalSiteContext static
- getHostWithProtocol
- getInactiveSites
- getSiteFromObject
- getSiteMap
- getSiteNameByUid
- init static
- initSites
- isDisplayNameOrHostnameTaken
- isGlobal
- isNotSetOrEqual
- onActivateSiteCommandReceived static
- onCreateEditSiteCommandReceived static
- onDeactivateSiteCommandReceived static
- startAcceptingSiteTraffic
- stopAcceptingSiteTraffic
Properties
- GLOBAL_SITE static
- NO_SITE static
- SITE_COLL static
- SITE_COLLECTION static
- SITE_FIELD static
- TYPE static
Methods
activateSite
-
siteUid
-
cb
Run a job to activate a site so that all of its routes are available.
Parameters:
-
siteUid
String- site unique id
-
cb
Function- callback to run after job is completed
Returns:
the job id
areEqual
-
siteA
-
siteB
Returns true if both site ids given are equal
Parameters:
-
siteA
String- first site id to compare
-
siteB
String- second site id to compare
Returns:
true if equal, false otherwise
createSite
-
options
-
cb
Creates a site and saves it to the database.
Parameters:
-
options
Object- object containing site fields
-
hostname
String- result of site hostname edit/create
-
displayName
String- result of site display name edit/create
-
cb
Function- callback function
deactivateSite
-
siteUid
-
cb
Run a job to set a site inactive so that only the admin routes are available.
Parameters:
-
siteUid
String- site unique id
-
cb
Function- callback to run after job is completed
Returns:
the job id
deleteSiteSpecificContent
-
siteId
-
cb
Parameters:
-
siteId
String -
cb
Function
editSite
-
options
-
cb
Run a job to update a site's hostname and/or displayname.
Parameters:
-
options
Object- object containing site fields
-
uid
String- site uid
-
hostname
String- result of site hostname edit/create
-
displayName
String- result of site display name edit/create
-
cb
Function- callback to run after job is completed
Returns:
the job id
getActiveSites
-
cb
Get all site objects where activated is true.
Parameters:
-
cb
Function- the callback function
getAllSites
-
cb
Get all of the site objects in the database
Parameters:
-
cb
Function- the callback function
getByUid
-
uid
-
cb
Load full site config from the database using the unique id.
Parameters:
-
uid
String- unique id of site
-
cb
Function- the callback function
getCurrentSite
-
siteid
Central place to get the current site. Backwards compatible cleansing
Parameters:
-
siteid
String- site is to cleanse
Returns:
SiteService.GLOBAL_SITE if not specified, or siteid otherwise
getExistingDisplayNameHostnameCounts
-
displayName
-
hostname
-
id
-
cb
Gets the total counts of a display name and hostname in the site collection
Parameters:
-
displayName
String- site display name
-
hostname
String- site hostname
-
id
String- Site object Id to exclude from the search
-
cb
Function- Callback function
getGlobalSiteContext
()
Object
static
Retrieves the global site context
Returns:
getHostWithProtocol
-
hostname
Determine whether http or https is being used for the site and return hostname attached to http(s)
Parameters:
-
hostname
String
Returns:
hostname with protocol attached
getInactiveSites
-
cb
Get all site objects where activated is false.
Parameters:
-
cb
Function- the callback function
getSiteFromObject
-
object
Return site field from object.
Parameters:
-
object
Object
Returns:
the value of the object's site field key
getSiteMap
-
cb
Get all site objects segmented by active status.
Parameters:
-
cb
Function- the callback function
getSiteNameByUid
-
uid
-
cb
Get site name given a unique id.
Parameters:
-
uid
String- unique id
-
cb
Function- the callback function
init
()
static
Register activate and deactivate commands on initialization
initSites
-
cb
Load all sites into memory.
Parameters:
-
cb
Function
isDisplayNameOrHostnameTaken
-
displayName
-
hostname
-
id
-
cb
Checks to see if a proposed site display name or hostname is already in the system
Parameters:
-
displayName
String- desired name to display
-
hostname
String- hostname of the site
-
id
String- Site object Id to exclude from the search
-
cb
Function- Callback function
isGlobal
-
siteId
Returns true if siteId given is global or non-existent (to remain backwards compatible)
Parameters:
-
siteId
String- the site id to check
Returns:
true if global or does not exist
isNotSetOrEqual
-
actual
-
expected
Returns true if actual is not set (falsey) or logically equivalent to expected in terms of sites
Parameters:
-
actual
String- site to check
-
expected
String- site you expect to be equal
Returns:
true if actual exists and equals expected
onActivateSiteCommandReceived
-
command
Runs a site activation job when command is received.
Parameters:
-
command
Object- the command to react to.
onCreateEditSiteCommandReceived
-
command
Runs a site deactivation job when command is received.
Parameters:
-
command
Object- the command to react to.
onDeactivateSiteCommandReceived
-
command
Runs a site deactivation job when command is received.
Parameters:
-
command
Object- the command to react to.
startAcceptingSiteTraffic
-
siteUid
-
cb
Given a site uid, activate if the site exists so that user facing routes are on.
Parameters:
-
siteUid
String- site unique id
-
cb
Function- callback function
stopAcceptingSiteTraffic
-
siteUid
-
cb
Given a site uid, deactivate if the site exists so that user facing routes are off.
Parameters:
-
siteUid
String- site unique id
-
cb
Function- callback function
Properties
GLOBAL_SITE
String
static
represents default configuration, not actually a full site
NO_SITE
String
static
represents a site that doesn't exist
SITE_COLL
String
private
static
SITE_COLLECTION
String
static
SITE_FIELD
String
static
TYPE
String
private
static
The name of the DB collection where the resources are persisted