Owns the organisation (org) domain: creating, updating, deleting, searching and merging orgs, and managing the custom organisation types attached to them. Reached from Java via C(OrganisationManager.class) or the static OrganisationManager.THIS() helper, and from GraalJS controllers and Velocity templates via the exported methods below. Orgs form a tree rooted at the current account's admin organisation, and most lookups here are scoped to that tree so a tenant cannot see or modify data outside its own account.

Group: Managers


Properties

PropertyReturnsDescription
adminOrgOrganisationThe current account's admin organisation, the root of the org tree for the tenant handling this request.
allLocalesList<Locale>All locales available on the server for date formatting.
allOrgTypesList<OrgType>All organisation types defined for the current account.
parentIdLongThe id of the parent organisation of the current account's admin organisation, or null if the admin organisation has no parent.
primaryDomainStringThe primary domain of the current tenant.
timezoneIdListList<String>The list of timezone ids that can be selected for calendar events.

Methods

getSelectedOrgTypes(Organisation org) · getParentId() · doesAdminDomainExist(String adminDomain) · accountUsage() · updateAllAccountDeps() · updateAllAccountDeps(boolean missingOnly) · updateAllAccountDeps(boolean missingOnly, Consumer<String> progress) · numMembers(Organisation org) · isWithin(Organisation selectedOrg, Organisation possibleParentOrg) · findAllParentOrgs(Organisation childOrg) · currentAdminUrl(String path, Profile loginProfile) · fullAdminDomain(String adminDomain) · adminUrl(String adminDomain, String path, Profile loginProfile) · adminUrl(Organisation adminOrg, String path, Profile loginProfile) · getAdminOrg() · newAccountBuilder() · createAccount(NewAccountBuilder b) · createAccount(String company, Profile profile) · findAdminDomain(String adminDomain) · hasOrgType(String orgTypeName, Organisation org) · findOrg(String orgId) · childOrg(Organisation org, String orgId) · childOrg(Organisation org, Long orgId) · findOrg(Long id) · findOrg(Long id, boolean includeDeletedOrg) · createOrg(Organisation parent, String orgId, String orgTitle) · newOrganisationBuilder() · updateOrg(Organisation org) · deleteOrg(Organisation org) · findDuplicates(MergeDestMode mode) · getAllLocales() · getTimezoneIdList() · mergeOrgs(Object mergeDestId, List<Object> mergeOrgIds) · addOrgType(Organisation org, OrgType orgType) · addOrgType(Organisation org, OrgType orgType, Profile triggeredProfile) · addOrgTypes(Organisation org, List<OrgType> orgTypes, Profile triggeredProfile) · removeOrgType(Organisation org, OrgType orgType) · removeOrgTypes(Organisation org, List<OrgType> orgTypes) · getOrgType(String name) · getOrgTypeExtraFields(OrgType orgType) · findOrgTypeExtraFields(OrgType orgType) · findOrgTypeExtraFieldMeta(OrgType orgType) · updateOrgExtraFields(Organisation org, List<OrgType> orgTypes, FormContext fc) · findOrgTypeById(Long orgTypeId) · findOrgTypeByName(String sOrgType) · getAllOrgTypes() · save(Organisation orgToEdit) · findOrgsByType(OrgType ot) · search(String q, Organisation organisation, OrgType orgType) · searchES(String query, List<Organisation> parentOrgs, List<OrgType> orgTypes, Boolean noOrgType, SearchProperties searchProperties, String excludedOrgId) · searchES(String query, List<Organisation> parentOrgs, List<OrgType> orgTypes, Boolean noOrgType, SearchProperties searchProperties, Boolean paging, String excludedOrgId) · findChildAccounts() · newOrgMatchRequest() · findMatchingES(OrgMatchRequest orgMatchRequest) · findMatchingES(OrgMatchRequest request, SearchProperties searchProperties) · findMatching(OrgMatchRequest request) · findMatching(OrgMatchRequest request, SearchProperties searchProperties) · newAddressBean() · findAppControls(Organisation org) · findDirectSubordinateOrgs(Organisation superordinate) · findDirectSubordinateOrgs(Organisation superordinate, int maxResult) · countDirectSubordinateOrgs(Organisation superordinate) · toOrgDataList(List<Organisation> orgs) · toOrgData(Organisation org) · getPrimaryDomain() · updateHostMappings(Organisation org) · updateHostMappings(Organisation org, boolean processApps) · createOrgType(String name, String title) · deleteOrgType(OrgType type) · createNote(String newNote, Organisation org, Profile enteredBy) · findNotes(Organisation org) · timelineItems(Organisation thisOrg) · findAuditStats(Organisation org) · findAuditItems(Organisation org, Integer max) · hasGroupInWebsite(Website website, Group group) · updateOrgTypeFields(OrgType orgType, Map<String,String> fieldsMap) · updateOrgType(OrgType orgType, FormContext context) · findOrgsById(Collection<Long> ids, Boolean enabled) · hasParent(Organisation org, String adminDomainId) · findExtraFieldNames() · findParentOrganisation(String orgId) · orgDashboardStats()

getSelectedOrgTypes(Organisation org)

Returns: List<OrgTypeBean>

The custom organisation types currently selected on the given org, read from a short-lived cache so bulk operations such as reindexing do not repeatedly hit the database for the same org.

ParameterDescription
orgthe organisation whose selected org types are read

getParentId()

Returns: Long

The id of the parent organisation of the current account's admin organisation, or null if the admin organisation has no parent.

doesAdminDomainExist(String adminDomain)

Returns: boolean

Checks whether an admin organisation exists for the given admin domain, without returning the organisation itself so tenants cannot use this to probe for orgs outside their own account.

ParameterDescription
adminDomainthe admin domain to look up

accountUsage()

Returns: AccountUsage

Creates an AccountUsage view for the current account's admin organisation, used to report on resource usage such as content storage size.

updateAllAccountDeps()

Returns: void

Updates all apps and libs installed in the account to their latest available versions, installing any missing dependencies along the way.

updateAllAccountDeps(boolean missingOnly)

Returns: void

Updates all apps and libs installed in the account, as updateAllAccountDeps(), optionally only installing dependencies that are missing rather than upgrading ones already installed.

ParameterDescription
missingOnlyif true, only install missing dependencies, do not upgrade anything already installed

updateAllAccountDeps(boolean missingOnly, Consumer<String> progress)

Returns: void

As updateAllAccountDeps(boolean), but reports which app is being updated as it goes. Intended for callers running this as a background task, so they can show the user the app currently being updated instead of an unqualified spinner.

ParameterDescription
missingOnlyif true, only install missing dependencies, do not upgrade anything already installed
progresscalled with a status message as each app is updated, may be null

numMembers(Organisation org)

Returns: long

Counts the profiles that are members of the given organisation.

ParameterDescription
orgthe organisation to count members of

isWithin(Organisation selectedOrg, Organisation possibleParentOrg)

Returns: boolean

Checks whether the given organisation is, or is a descendant of, a possible parent organisation.

ParameterDescription
selectedOrgthe organisation to check
possibleParentOrgthe organisation that may be the same org or an ancestor of selectedOrg

findAllParentOrgs(Organisation childOrg)

Returns: List<Long>

Finds the ids of every ancestor organisation of the given org, from its immediate parent up to the current account's admin organisation.

ParameterDescription
childOrgthe organisation whose ancestors are found

currentAdminUrl(String path, Profile loginProfile)

Returns: String

Builds an admin URL under the current account's admin domain, for the given path.

ParameterDescription
paththe path to append to the admin domain
loginProfilethe profile to build the URL for, may affect the domain used, may be null

fullAdminDomain(String adminDomain)

Returns: String

Expands a short admin domain name to its full public hostname.

ParameterDescription
adminDomainthe short admin domain name

adminUrl(String adminDomain, String path, Profile loginProfile)

Returns: String

Builds an admin URL under the given admin domain, for the given path.

ParameterDescription
adminDomainthe admin domain to build the URL under
paththe path to append to the admin domain
loginProfilethe profile to build the URL for, may affect the domain used, may be null

adminUrl(Organisation adminOrg, String path, Profile loginProfile)

Returns: String

Builds an admin URL under the given admin organisation's domain, for the given path.

ParameterDescription
adminOrgthe admin organisation to build the URL under
paththe path to append to the admin domain
loginProfilethe profile to build the URL for, may affect the domain used, may be null

getAdminOrg()

Returns: Organisation

The current account's admin organisation, the root of the org tree for the tenant handling this request.

newAccountBuilder()

Returns: NewAccountBuilder

Deprecated - use AccountManager instead. Creates a new NewAccountBuilder for building a new account.

createAccount(NewAccountBuilder b)

Returns: Organisation

Deprecated - use AccountManager instead. Creates the account described by the builder, and if the builder has no profile set, creates an admin profile for it and sets that profile on the builder.

ParameterDescription
bthe builder describing the account to create

createAccount(String company, Profile profile)

Returns: Organisation

Deprecated - use AccountManager instead. Creates a new account organisation for the given company name.

ParameterDescription
companythe company/organisation title for the new account
profilethe profile to associate with the new account

findAdminDomain(String adminDomain)

Returns: String

Deprecated - use AccountManager instead. Looks up the canonical admin domain matching the given value.

ParameterDescription
adminDomainthe admin domain to look up

hasOrgType(String orgTypeName, Organisation org)

Returns: boolean

Checks whether the given organisation has the named organisation type set on it.

ParameterDescription
orgTypeNamethe name of the org type to check for
orgthe organisation to check

findOrg(String orgId)

Returns: Organisation

Finds an organisation within the current account by its org id (the path-safe identifier, not its database id). Returns null if orgId is blank or no match is found.

ParameterDescription
orgIdthe org id to look up

childOrg(Organisation org, String orgId)

Returns: Organisation

Finds a child organisation of the given org by its org id.

ParameterDescription
orgthe organisation to search within
orgIdthe org id of the child to find

childOrg(Organisation org, Long orgId)

Returns: Organisation

Finds a child organisation of the given org by its database id.

ParameterDescription
orgthe organisation to search within
orgIdthe database id of the child to find

findOrg(Long id)

Returns: Organisation

Finds an organisation within the current account by its database id, including soft-deleted organisations.

ParameterDescription
idthe database id of the organisation to find

findOrg(Long id, boolean includeDeletedOrg)

Returns: Organisation

Finds an organisation within the current account by its database id.

ParameterDescription
idthe database id of the organisation to find
includeDeletedOrgif true, a soft-deleted organisation is still returned; if false, null is returned for a soft-deleted match

createOrg(Organisation parent, String orgId, String orgTitle)

Returns: Organisation

Creates the new org as a child of the given parent (if not null, otherwise creates directly under the current account org), and submits it for reindexing.

ParameterDescription
parentthe parent organisation, or null to create directly under the current account org
orgIdthe org id for the new organisation
orgTitlethe display title for the new organisation

newOrganisationBuilder()

Returns: OrganisationBuilder

Creates a new OrganisationBuilder, a convenient fluent way to build and create a new organisation. Set properties on the builder and then call its build() method to create the organisation.

updateOrg(Organisation org)

Returns: void

Saves changes to the given organisation, stamping its modified date and modifying profile, then submits it for reindexing.

ParameterDescription
orgthe organisation to save

deleteOrg(Organisation org)

Returns: void

Soft-deletes the given organisation and submits it for reindexing so it drops out of search results.

ParameterDescription
orgthe organisation to delete

findDuplicates(MergeDestMode mode)

Returns: List<DuplicateList>

Finds groups of organisations within the current account that share the same title, for review before merging with mergeOrgs(Object, List).

ParameterDescription
modehow the preferred merge destination within each duplicate group is chosen

getAllLocales()

Returns: List<Locale>

All locales available on the server for date formatting.

getTimezoneIdList()

Returns: List<String>

The list of timezone ids that can be selected for calendar events.

mergeOrgs(Object mergeDestId, List<Object> mergeOrgIds)

Returns: int

Merges each of the given organisations into a single destination organisation: moves supplied products, group memberships, org types, sales data records, points, points debits, leads and subscriptions from each source org to the destination, then soft-deletes the source org. An organisation that is itself an admin domain cannot be merged away.

ParameterDescription
mergeDestIdthe id (as a Long or a value convertible to one) of the organisation to merge into
mergeOrgIdsthe ids of the organisations to merge into the destination and then delete

addOrgType(Organisation org, OrgType orgType)

Returns: void

Adds an organisation type to the given organisation and fires an OrganisationTaggedEvent for the current profile.

ParameterDescription
orgthe organisation to tag
orgTypethe org type to add

addOrgType(Organisation org, OrgType orgType, Profile triggeredProfile)

Returns: void

Adds an organisation type to the given organisation and fires an OrganisationTaggedEvent for the given profile.

ParameterDescription
orgthe organisation to tag
orgTypethe org type to add
triggeredProfilethe profile the OrganisationTaggedEvent is attributed to

addOrgTypes(Organisation org, List<OrgType> orgTypes, Profile triggeredProfile)

Returns: void

Adds each of the given organisation types to the given organisation, firing an OrganisationTaggedEvent for the given profile for every type added. A null org or an empty or null orgTypes list is ignored, with a warning logged.

ParameterDescription
orgthe organisation to tag
orgTypesthe org types to add
triggeredProfilethe profile the OrganisationTaggedEvent is attributed to

removeOrgType(Organisation org, OrgType orgType)

Returns: void

Removes an organisation type from the given organisation.

ParameterDescription
orgthe organisation to untag
orgTypethe org type to remove

removeOrgTypes(Organisation org, List<OrgType> orgTypes)

Returns: void

Removes each of the given organisation types from the given organisation. An empty or null orgTypes list is ignored, with a warning logged.

ParameterDescription
orgthe organisation to untag
orgTypesthe org types to remove

getOrgType(String name)

Returns: OrgType

Looks up an organisation type of the current account by its name.

ParameterDescription
namethe name of the org type to look up

getOrgTypeExtraFields(OrgType orgType)

Returns: Map<ExtraField,String>

Deprecated - use findOrgTypeExtraFields instead. Returns the extra field metadata defined for the given org type, keyed by the parsed ExtraField.

ParameterDescription
orgTypethe org type whose extra field metadata is read

findOrgTypeExtraFields(OrgType orgType)

Returns: List<ExtraField>

Finds the extra (custom) field definitions attached to the given org type's fieldset.

ParameterDescription
orgTypethe org type whose extra fields are read

findOrgTypeExtraFieldMeta(OrgType orgType)

Returns: Map<String,String>

Returns the raw extra field metadata for the given org type, as formatted text, keyed on the field name.

ParameterDescription
orgTypethe org type whose extra field metadata is read

updateOrgExtraFields(Organisation org, List<OrgType> orgTypes, FormContext fc)

Returns: void

Saves new custom field values for the given organisation, reading each field's value from the given form context where present and otherwise keeping its existing value.

ParameterDescription
orgthe organisation to save custom field values to
orgTypesthe org types whose extra fields are considered
fca FormContext with user-entered parameters

findOrgTypeById(Long orgTypeId)

Returns: OrgType

Looks up an organisation type of the current account by its database id.

ParameterDescription
orgTypeIdthe database id of the org type to look up

findOrgTypeByName(String sOrgType)

Returns: OrgType

Looks up an organisation type of the current account by its name.

ParameterDescription
sOrgTypethe name of the org type to look up

getAllOrgTypes()

Returns: List<OrgType>

All organisation types defined for the current account.

save(Organisation orgToEdit)

Returns: void

Saves changes to the given organisation and fires an indexed-item-updated event so the search index is refreshed.

ParameterDescription
orgToEditthe organisation to save

findOrgsByType(OrgType ot)

Returns: List<Organisation>

Finds non-soft-deleted organisations that have the given org type.

ParameterDescription
otthe org type to match, if null an empty list is returned

Returns: List<Organisation>

Finds organisations matching the given free-text query, optionally scoped to a parent organisation and org type.

ParameterDescription
qthe free-text search query
organisationthe parent organisation to scope results to, may be null
orgTypethe org type to scope results to, may be null

searchES(String query, List<Organisation> parentOrgs, List<OrgType> orgTypes, Boolean noOrgType, SearchProperties searchProperties, String excludedOrgId)

Returns: KSearchResponse

Standard search method for finding orgs in Elasticsearch, with paging enabled.

ParameterDescription
queryfree text search string, supports field:value and -field:value syntax
parentOrgsif provided, only matches orgs with at least one of these as a parent
orgTypesif provided, only matches orgs with at least one of these types
noOrgTypeif true, only matches orgs which do not have any organisation type
searchPropertiespaging and sort order
excludedOrgIdif provided, excludes the org with this org id from the results

searchES(String query, List<Organisation> parentOrgs, List<OrgType> orgTypes, Boolean noOrgType, SearchProperties searchProperties, Boolean paging, String excludedOrgId)

Returns: KSearchResponse

Standard search method for finding orgs in Elasticsearch.

ParameterDescription
queryfree text search string, supports field:value and -field:value syntax
parentOrgsif provided, only matches orgs with at least one of these as a parent
orgTypesif provided, only matches orgs with at least one of these types
noOrgTypeif true, only matches orgs which do not have any organisation type
searchPropertiespaging and sort order
pagingwhether to apply Elasticsearch paging to the request
excludedOrgIdif provided, excludes the org with this org id from the results

findChildAccounts()

Returns: Map<Long,String>

Finds all child accounts (organisations with their own admin domain) within the current tenant organisation.

newOrgMatchRequest()

Returns: OrgMatchRequest

Creates a new, empty OrgMatchRequest for building up search criteria to pass to findMatching or findMatchingES.

findMatchingES(OrgMatchRequest orgMatchRequest)

Returns: List<Organisation>

Uses Elasticsearch to find organisations matching the criteria in the given OrgMatchRequest.

ParameterDescription
orgMatchRequestthe search criteria

findMatchingES(OrgMatchRequest request, SearchProperties searchProperties)

Returns: List<Organisation>

Uses Elasticsearch to find organisations matching the criteria in the given OrgMatchRequest.

ParameterDescription
requestthe search criteria
searchPropertiespagination and sort order, may be null

findMatching(OrgMatchRequest request)

Returns: List<Organisation>

Uses the database (Hibernate criteria) to find organisations matching the given criteria.

ParameterDescription
requestthe search criteria

findMatching(OrgMatchRequest request, SearchProperties searchProperties)

Returns: List<Organisation>

Uses the database (Hibernate criteria) to find organisations matching the given criteria, with optional paging and sort order.

ParameterDescription
requestthe search criteria
searchPropertiespaging and sort order, may be null

newAddressBean()

Returns: AddressBean

Creates a new, empty AddressBean.

findAppControls(Organisation org)

Returns: List<AppControl>

Finds the app control records for the given organisation, provided it is within the current tenant.

ParameterDescription
orgthe organisation whose app controls are found

findDirectSubordinateOrgs(Organisation superordinate)

Returns: List<Organisation>

Finds organisations that are logically subordinate to the given superordinate org, up to a default limit of 40 results. An org is a direct subordinate if its parent org is the superordinate org, or if it has a custom field of type orgselector referring to the superordinate org.

ParameterDescription
superordinatethe organisation to find subordinates of

findDirectSubordinateOrgs(Organisation superordinate, int maxResult)

Returns: List<Organisation>

Finds organisations that are logically subordinate to the given superordinate org, up to the given limit. An org is a direct subordinate if its parent org is the superordinate org, or if it has a custom field of type orgselector referring to the superordinate org.

ParameterDescription
superordinatethe organisation to find subordinates of
maxResultthe maximum number of results to return

countDirectSubordinateOrgs(Organisation superordinate)

Returns: long

Counts the organisations that are logically subordinate to the given superordinate org. An org is a direct subordinate if its parent org is the superordinate org, or if it has a custom field of type orgselector referring to the superordinate org.

ParameterDescription
superordinatethe organisation to count subordinates of

toOrgDataList(List<Organisation> orgs)

Returns: List<OrgData>

Converts a list of organisations to a list of OrgData beans.

ParameterDescription
orgsthe organisations to convert, may be null

toOrgData(Organisation org)

Returns: OrgData

Converts a single organisation to an OrgData bean.

ParameterDescription
orgthe organisation to convert

getPrimaryDomain()

Returns: String

The primary domain of the current tenant.

updateHostMappings(Organisation org)

Returns: void

Rebuilds the host mappings (hostnames routed to this org's cluster) for the given admin organisation, including hostnames contributed by other apps.

ParameterDescription
orgthe admin organisation to rebuild host mappings for

updateHostMappings(Organisation org, boolean processApps)

Returns: void

Rebuilds the host mappings (hostnames routed to this org's cluster) for the given admin organisation: collects the admin domain, website and branch domains, and optionally domains contributed by other apps such as CloudFront, then creates, updates or removes HostMapping records to match. Throws if org is not an admin organisation.

ParameterDescription
orgthe admin organisation to rebuild host mappings for
processAppsif true, also collect hostnames from apps implementing HostnameProviderApplication and remove stale host mappings that no longer match any known hostname

createOrgType(String name, String title)

Returns: OrgType

Creates a new organisation type on the current account, with the given name and display title.

ParameterDescription
namethe machine-safe name of the new org type
titlethe display title of the new org type

deleteOrgType(OrgType type)

Returns: boolean

Safely deletes an organisation type: refuses if any active organisation still has the type, unlinks it from any soft-deleted organisations and groups that reference it, then removes it from the account.

ParameterDescription
typethe org type to delete

createNote(String newNote, Organisation org, Profile enteredBy)

Returns: LeadNote

Creates a note attached to the specified org.

ParameterDescription
newNotethe text to save in the note
orgthe organisation to attach the note to
enteredBythe current user entering the note, required

findNotes(Organisation org)

Returns: List<LeadNote>

Finds all notes created for the specified org.

ParameterDescription
orgthe organisation whose notes are found

timelineItems(Organisation thisOrg)

Returns: List<StreamEventBean>

Builds a combined activity timeline for the given org by asking every active ManageProfileApplication to contribute its own org actions, then sorting the combined list newest first and capping it at 300 items.

ParameterDescription
thisOrgthe organisation to build the timeline for

findAuditStats(Organisation org)

Returns: Map<Date,Integer>

Counts audit changes recorded for the given org, grouped by the start of the day each change occurred on, over the most recent 1000 audit items.

ParameterDescription
orgthe organisation whose audit history is examined

findAuditItems(Organisation org, Integer max)

Returns: List<AuditItem>

Finds the most recent audit items recorded for the given org, in the current tenant.

ParameterDescription
orgthe organisation whose audit items are found
maxthe maximum number of items to return, capped at 1000, defaults to 1000 if null

hasGroupInWebsite(Website website, Group group)

Returns: boolean

Checks whether the given group has access to the given website.

ParameterDescription
websitethe website to check
groupthe group to check

updateOrgTypeFields(OrgType orgType, Map<String,String> fieldsMap)

Returns: void

Replaces the extra field values stored on the given org type's fieldset with the given values, creating a new fieldset only if the values actually changed.

ParameterDescription
orgTypethe org type whose fieldset is updated
fieldsMapthe new field name to value pairs

updateOrgType(OrgType orgType, FormContext context)

Returns: OrgType

Updates an org type's fields from a form context, using reflection-based bean population.

ParameterDescription
orgTypethe org type to update
contextthe form context supplying new field values

findOrgsById(Collection<Long> ids, Boolean enabled)

Returns: List<Organisation>

Finds organisations with the given ids, using multiple queries in batches of 200 where necessary. Only matches organisations that are within the current tenant org.

ParameterDescription
idsthe database ids to look up
enabledif true, only enabled (not soft-deleted) orgs are returned; if false, only deleted orgs are returned; if null, both are returned

hasParent(Organisation org, String adminDomainId)

Returns: boolean

Checks whether the given org has an ancestor whose admin domain matches the given value.

ParameterDescription
orgthe organisation to check, may be null
adminDomainIdthe admin domain to match against an ancestor

findExtraFieldNames()

Returns: List<String>

Finds the distinct extra (custom) field names defined across all of the current account's organisation types, sorted alphabetically.

findParentOrganisation(String orgId)

Returns: Organisation

Finds the parent organisation of the organisation identified by the given org id.

ParameterDescription
orgIdthe org id of the organisation whose parent is found

orgDashboardStats()

Returns: OrgDashboardStats

Aggregate usage counts for the current account's dashboard: total organisations, profiles and groups. Results are cached briefly per admin organisation.

To get full access to the Kademi Hub existing customers can login here, or new customers can register here.