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:
-
siteUidString- site unique id
-
cbFunction- callback to run after job is completed
Returns:
the job id
areEqual
-
siteA -
siteB
Returns true if both site ids given are equal
Parameters:
-
siteAString- first site id to compare
-
siteBString- second site id to compare
Returns:
true if equal, false otherwise
createSite
-
options -
cb
Creates a site and saves it to the database.
Parameters:
-
optionsObject- object containing site fields
-
hostnameString- result of site hostname edit/create
-
displayNameString- result of site display name edit/create
-
cbFunction- callback function
deactivateSite
-
siteUid -
cb
Run a job to set a site inactive so that only the admin routes are available.
Parameters:
-
siteUidString- site unique id
-
cbFunction- callback to run after job is completed
Returns:
the job id
deleteSiteSpecificContent
-
siteId -
cb
Parameters:
-
siteIdString -
cbFunction
editSite
-
options -
cb
Run a job to update a site's hostname and/or displayname.
Parameters:
-
optionsObject- object containing site fields
-
uidString- site uid
-
hostnameString- result of site hostname edit/create
-
displayNameString- result of site display name edit/create
-
cbFunction- callback to run after job is completed
Returns:
the job id
getActiveSites
-
cb
Get all site objects where activated is true.
Parameters:
-
cbFunction- the callback function
getAllSites
-
cb
Get all of the site objects in the database
Parameters:
-
cbFunction- the callback function
getByUid
-
uid -
cb
Load full site config from the database using the unique id.
Parameters:
-
uidString- unique id of site
-
cbFunction- the callback function
getCurrentSite
-
siteid
Central place to get the current site. Backwards compatible cleansing
Parameters:
-
siteidString- 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:
-
displayNameString- site display name
-
hostnameString- site hostname
-
idString- Site object Id to exclude from the search
-
cbFunction- 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:
-
hostnameString
Returns:
hostname with protocol attached
getInactiveSites
-
cb
Get all site objects where activated is false.
Parameters:
-
cbFunction- the callback function
getSiteFromObject
-
object
Return site field from object.
Parameters:
-
objectObject
Returns:
the value of the object's site field key
getSiteMap
-
cb
Get all site objects segmented by active status.
Parameters:
-
cbFunction- the callback function
getSiteNameByUid
-
uid -
cb
Get site name given a unique id.
Parameters:
-
uidString- unique id
-
cbFunction- the callback function
init
()
static
Register activate and deactivate commands on initialization
initSites
-
cb
Load all sites into memory.
Parameters:
-
cbFunction
isDisplayNameOrHostnameTaken
-
displayName -
hostname -
id -
cb
Checks to see if a proposed site display name or hostname is already in the system
Parameters:
-
displayNameString- desired name to display
-
hostnameString- hostname of the site
-
idString- Site object Id to exclude from the search
-
cbFunction- Callback function
isGlobal
-
siteId
Returns true if siteId given is global or non-existent (to remain backwards compatible)
Parameters:
-
siteIdString- 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:
-
actualString- site to check
-
expectedString- 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:
-
commandObject- the command to react to.
onCreateEditSiteCommandReceived
-
command
Runs a site deactivation job when command is received.
Parameters:
-
commandObject- the command to react to.
onDeactivateSiteCommandReceived
-
command
Runs a site deactivation job when command is received.
Parameters:
-
commandObject- 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:
-
siteUidString- site unique id
-
cbFunction- callback function
stopAcceptingSiteTraffic
-
siteUid -
cb
Given a site uid, deactivate if the site exists so that user facing routes are off.
Parameters:
-
siteUidString- site unique id
-
cbFunction- 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
