Bridgeline Digital Logo
Menu

Site API

The OrchestraCMS Site API provides programmatic access to the metadata of an OrchestraCMS site. The API can be accessed through Apex.

There are seven supporting classes needed for the Site API in order to return a SiteBundle for use. These helper classes are available in the API 5.0 Resources and the required classes are JSONMessage, APIRequest, ProfileAPIRequest, LanguageBundle, TargetBundle, SiteBundle and SiteAPIRequest.

getSiteInfo

Retrieves information about the site. Either the site name or ID can be used to specify the site. If running within an OrchestraCMS runtime context, these parameters are optional as the default will be to return the current runtime site. Information about a site other than the current runtime site can be retrieved with an OrchestraCMS runtime context. A sample return from this API call would be:

Apex Request Example

// Create our Site API request
SiteAPIRequest request = new SiteAPIRequest();
request.requestFlags = new Map<String, Boolean>();
request.requestFlags.put(SiteAPIRequest.LANGUAGES, true);
request.requestFlags.put(SiteAPIRequest.TARGETS, true);

// Set our API, API version, site, request, and action parameters
Map<String, String> parameters = new Map<String, String>();
parameters.put('service', 'SiteAPI');
parameters.put('apiVersion', '5.0');
parameters.put('sname', 'site_name'); // Replace site_name with the name of your OrchestraCMS site
parameters.put('request', json.serialize(request));
parameters.put('action', SiteAPIRequest.GET_SITE_INFO);

// Make API request and output to debug log
String response = cms.ServiceEndPoint.doActionApex(parameters);
JSONMessage.APIResponse apiResponse = (JSONMessage.APIResponse) JSON.deserialize(response, JSONMessage.APIResponse.class);
SiteBundle bundle = (SiteBundle) JSON.deserialize(apiResponse.responseObject, SiteBundle.class);
System.Debug(bundle);

Apex Response Example

SiteBundle: [
    approvalProcessEnabled = true,
    complianceEnabled = false,
    defaultLanguage = a00000000000000000,
    languages = (
        LanguageBundle: [
            allowsFallback = false,
            code = en_US,
            description = Language option - English,
            isActive = true,
            name = English,
            priority = 0
        ],
        LanguageBundle: [
            allowsFallback = true,
            code = fr,
            description = Language option - French,
            isActive = true,
            name = French,
            priority = 1
        ]
    ),
    multilingualEnabled = false,
    profiles = null,
    siteDomain = example.com,
    siteId = a00000000000000000,
    siteLabel = site_name,
    siteName = site_name,
    sitePrefix = null,
    siteSecureDomain = null,
    siteSecureUrl = null,
    siteUrl = http://www.example.com/,
    targetingEnabled = true,
    targets = (
        TargetBundle: [
            description = Country - Canada,
            filters = {Country = {Canada}},
            lastModifiedByName = John Smith,
            lastModifiedDate = 2017-06-01 00:00:00,
            targetKey = aaaaaaaaaaaaaaaaaaaaaaaaaaa,
            targetName = Country - Canada,
            targetType = Predefined
        ],
        TargetBundle: [
            description = Only the Guest User will see this content,
            filters = {FirstName={site_name}},
            lastModifiedByName = John Smith,
            lastModifiedDate = 2017-06-01 00:00:00,
            targetKey = aaaaaaaaaaaaaaaaaaaaaaaaaab,
            targetName = Guest User Only,
            targetType=Predefined
        ]
    )
]
 
All Site API requests return a SiteBundle