Bridgeline Digital Logo
Menu

Profile API

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

There are several supporting classes needed for the Profile API in order to return a ProfileBundle for use.  These helper classes are available in the API 5.0 Resources and the required classes are JSONMessage, APIRequest, UserBundle and ProfileAPIRequest.

getProfiles

This method retrieves information about OrchestraCMS profiles. The default behavior is to return the current running user's profile. To return other profiles, the running user must have administrative permission for profiles.

Parameters

  • objectId : StringID of the requested profile

Apex Request Example

// Create our Profile API request
ProfileAPIRequest profileRequest = new ProfileAPIRequest();

profileRequest.requestFlags = new Map<String, Boolean>();
profileRequest.requestFlags.put(ProfileAPIRequest.LIST_USERS, true);

profileRequest.listParameters.put(ProfileAPIRequest.PROFILE_IDS, new List<Id>{'a00000000000000000'}); // Replace with the license profile Ids of the desired profiles you will be listing

// Set our API, API version, site, request, and action parameters
Map<String, String> parameters = new Map<String, String>();
parameters.put('service', 'ProfileAPI');
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(profileRequest));
parameters.put('action', ProfileAPIRequest.GET_PROFILES);

// 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);

if (apiResponse.isSuccess) {
    List<ProfileBundle> bundles = (List<ProfileBundle>) JSON.deserialize(apiResponse.responseObject, List<ProfileBundle>.class);
    System.Debug(bundles);
}

Apex Response Example

"ProfileBundle": [
    "activated" = true,
    "licenseExpired" = false,
    "licenseType" = "role.siteAdministrator",
    "permissions" = {
        "approval.override" = true,
        "content.manage" = true,
        "content.manage.create" = true,
        "content.manage.edit" = true,
        "content.manage.publish" = true,
        "content.manage.translate" = true,
        "library.manage" = true,
        "library.manage.createfolder" = true,
        "library.manage.delete" = true,
        "library.manage.edit" = true,
        "library.manage.expire" = true,
        "library.manage.upload" = true,
        "library.manage.view" = true
    },
    "permissions_content_type" = {
        "a01000000000000000" = {
            "content.manage" = true,
            "content.manage.create" = true,
            "content.manage.edit" = true,
            "content.manage.publish" = true,
            "content.manage.translate" = true
        }
    },
    "permissions_library" = {
        "a02000000000000000" = {
            "library.manage" = true,
            "library.manage.createfolder" = true,
            "library.manage.delete" = true,
            "library.manage.edit" = true,
            "library.manage.expire" = true,
            "library.manage.upload" = true,
            "library.manage.view" = true
        }
    },
    "profileId" = "a00000000000000000",
    "profileName" = "Site Administrators",
    "siteLabel" = null,
    "users" = {
        "UserBundle": [
            "userId" = "005000000000000000",
            "userName" = "user@example.com"
        ]
    },
    "when_cached" = "2017-06-01T00:00:00.000Z"
]

addUsers

Add users to an OrchestraCMS profile. The running user must have administrative permission for profiles. The list of requested users cannot contain any users who are already members of a profile for the site. The OrchestraCMS license associated with the profile must have a sufficient number of available licenses for the operation to complete successfully. If there is a failure adding a user to the profile, no users during that transaction will be added.

Apex Request Example

// Create our Profile API request
ProfileAPIRequest profileRequest = new ProfileAPIRequest();

profileRequest.requestFlags = new Map<String, Boolean>();
profileRequest.requestFlags.put(ProfileAPIRequest.ALL_PROFILES, false);
profileRequest.requestFlags.put(APIRequest.NODATA, false);

profileRequest.objectId = 'a00000000000000000'; // Replace with the license profile Id of your desired profile you will be adding users to
profileRequest.listParameters.put(ProfileAPIRequest.USER_IDS, new List<Id>{'005000000000000000', '005000000000000001'});

// Set our API, API version, site, request, and action parameters
Map<String, String> parameters = new Map<String, String>();
parameters.put('service', 'ProfileAPI');
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(profileRequest));
parameters.put('action', ProfileAPIRequest.ADD_USERS);

// 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);

System.Debug(apiResponse);

Apex Response Example

{
    "type": "ProfileBundle",
    "timeNow": "2017-06-01T00:00:00.000Z",
    "isSuccess": true,
    "transactionId": null,
    "responseObject": {
        "when_cached": "2017-06-01T00:00:00.000Z",
        "users": [
            {
                "userName": "user1@example.com",
                "userId": "005000000000000000"
            },
            {
                "userName": "user2@example.com",
                "userId": "005000000000000001"
            }
        ],
        "profileName": "TestProfile",
        "profileId": "a00000000000000000",
        "permissions_library" = {
            "a01000000000000000" = {
                "library.manage": true,
                "library.manage.view": true,
                "library.manage.upload": true,
                "library.manage.createfolder": true,
                "library.manage.edit": true,
                "library.manage.delete": true
            }
        },
        "permissions_content_type" = {
            "a02000000000000000" = {
                "content.manage": true,
                "content.manage.create": true,
                "content.manage.edit": true,
                "content.manage.publish": true,
                "content.manage.translate": true
            }
        },
        "permissions" = {
            "setup.search": true,
            "library.manage.expire": true,
            "library.manage.edit": true,
            "setup.siteupgrade": true,
            "setup.licenses": true,
            "content.manage.create": true,
            "setup.sitedetails": true,
            "library.manage": true,
            "setup.errorpages": true,
            "content.manage.edit": true,
            "setup.scheduler": true,
            "setup.startpage": true,
            "setup.targets": true,
            "setup.workflow": true,
            "setup.accesslevels": true,
            "content.manage.publish": true,
            "setup": true,
            "setup.cache.page": true,
            "setup.customerportal": true,
            "page.manage.publish": true,
            "content.manage": true,
            "page.manage.create": true,
            "setup.site": true,
            "setup.prioritylevels": true,
            "setup.profiles": true,
            "setup.contenttypes": true,
            "page.manage": true,
            "setup.tags": true,
            "setup.contenttemplates": true,
            "setup.translationGroups": true,
            "content.manage.translate": true,
            "library.manage.createfolder": true,
            "setup.libraries": true,
            "library.manage.view": true,
            "setup.languages": true,
            "setup.complianceEngine": true,
            "page.manage.sitemap.edit": true,
            "page.manage.sitemap.publish": true,
            "library.manage.upload":true,
            "setup.pagelayouts": true,
            "page.manage.edit": true,
            "setup.cache.content": true,
            "library.manage.delete": true,
            "setup.utilities": true,
            "setup.remoteSites": true
        },
        "licenseType": "role.siteAdministrator",
        "licenseExpired": false,
        "activated": true
    },
    "message": "Added users to OrchestraCMS profile",
    "error": null
}

removeUsers

Remove users from an OrchestraCMS profile. The running user must have administrative permission for profiles. A success response will be returned even if some or none of the requested users were initially members of the profile. In the former case, the API will remove those users it can. In the latter case, the message property on the API Response object will differ from the standard success message. If there is a failure removing a user from the profile, no users during that transaction will be removed.

Apex Request Example

// Create our Profile API request
ProfileAPIRequest profileRequest = new ProfileAPIRequest();

profileRequest.requestFlags = new Map<String, Boolean>();
profileRequest.requestFlags.put(ProfileAPIRequest.LIST_USERS, true);
profileRequest.requestFlags.put(APIRequest.NODATA, false);

profileRequest.objectId = 'a00000000000000000'; // Replace with the license profile Id of your desired profile you will be removing users from
profileRequest.listParameters.put('userIds', new List<String>{'005000000000000000', '005000000000000001'});

// Set our API, API version, site, request, and action parameters
Map<String, String> parameters = new Map<String, String>();
parameters.put('service', 'ProfileAPI');
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(profileRequest));
parameters.put('action', ProfileAPIRequest.REMOVE_USERS);

// 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);

System.Debug(apiResponse);

Apex Response Example

{
    "type": "ProfileBundle",
    "timeNow": "2017-06-01T00:00:00.000Z",
    "isSuccess": true,
    "transactionId": null,
    "responseObject": {
        "when_cached": "2017-06-01T00:00:00.000Z",
        "users": [
            {
                "userName": "user1@example.com",
                "userId": "005000000000000000"
            }, {
                "userName": "user2@example.com",
                "userId": "005000000000000001"
            }
        ],
        "profileName": "TestProfile",
        "profileId": "a00000000000000000",
        "permissions_library" = {
            "a01000000000000000" = {
                "library.manage": true,
                "library.manage.view": true,
                "library.manage.upload": true,
                "library.manage.createfolder": true,
                "library.manage.edit": true,
                "library.manage.delete": true
            }
        },
        "permissions_content_type" = {
            "a02000000000000000" = {
                "content.manage": true,
                "content.manage.create": true,
                "content.manage.edit": true,
                "content.manage.publish": true,
                "content.manage.translate": true
            }
        },
        "permissions" = {
            "setup.search": true,
            "library.manage.expire": true,
            "library.manage.edit": true,
            "setup.siteupgrade": true,
            "setup.licenses": true,
            "content.manage.create": true,
            "setup.sitedetails": true,
            "library.manage": true,
            "setup.errorpages": true,
            "content.manage.edit": true,
            "setup.scheduler": true,
            "setup.startpage": true,
            "setup.targets": true,
            "setup.workflow": true,
            "setup.accesslevels": true,
            "content.manage.publish": true,
            "setup": true,
            "setup.cache.page": true,
            "setup.customerportal": true,
            "page.manage.publish": true,
            "content.manage": true,
            "page.manage.create": true,
            "setup.site": true,
            "setup.prioritylevels": true,
            "setup.profiles": true,
            "setup.contenttypes": true,
            "page.manage": true,
            "setup.tags": true,
            "setup.contenttemplates": true,
            "setup.translationGroups": true,
            "content.manage.translate": true,
            "library.manage.createfolder": true,
            "setup.libraries": true,
            "library.manage.view": true,
            "setup.languages": true,
            "setup.complianceEngine": true,
            "page.manage.sitemap.edit": true,
            "page.manage.sitemap.publish": true,
            "library.manage.upload":true,
            "setup.pagelayouts": true,
            "page.manage.edit": true,
            "setup.cache.content": true,
            "library.manage.delete": true,
            "setup.utilities": true,
            "setup.remoteSites": true
        },
        "licenseType": "role.siteAdministrator",
        "licenseExpired": false,
        "activated": true
    },
    "message": "Users removed from OrchestraCMS profile",
    "error": null
}
 
All Profile API requests return a ProfileBundle or list of ProfileBundles.