Serves the response for a single request matched against a ControllerMapping, running the mapping's JS handler function for the request method and rendering the result with the configured or returned view. Created by ControllerResource.create when a controller mapping is located for the requested path. Scripts invoked from a ControllerResource have access to global variables including controllerMappings, views (a ViewsBuilder), formatter, log, applications, transactionManager (an AppTransactionManager), and fileManager (a FileManager).

Group: Resources

Extends: AbstractResource

Implements: GetableResource, PostableResource, ReplaceableResource, DeletableResource, TitledPage, HashResource, SeoResource


Properties

PropertyReturnsDescription
appSettingsMap<String,String>The configuration settings of the owning repository app for the current organisation and branch, lazily loaded and cached on first access.
breadCrumbsMapThe breadcrumb trail for this resource, either taken directly from the controller mapping's configured breadcrumb map or computed by running its breadcrumb function.
controllerMappingsControllerMappingListThe full set of controller mappings registered by the owning app, of which this resource's mapping is one.
currentUserUserResourceReturns the currently authenticated user for this request.
hashStringA hash identifying the current content of this resource, taken from the view resolved for a GET request if that view is a FileHashView.
hrefStringThe URL path this resource was resolved from.
methodControllerMethodThe controller method resolved for the current request's HTTP method, used to run the matching JS handler and select the response view.
modifiedDateDateThe last modified date of this resource, computed by running the controller mapping's modified-date function if one is configured, otherwise delegating to the superclass.
nameStringThe final path segment of this resource's path.
parentCommonCollectionResourceThe root folder this resource was resolved within.
pathPathThe Milton path this resource was resolved from.
pathParamsMap<String,Object>The named path parameters extracted from matching this resource's URL against its controller mapping's path pattern, for example an id captured from a path segment.
publicbooleanWhether this resource can be accessed without authentication, taken from its controller mapping.
repoAppNameStringThe instance id of the repository app that registered the controller mapping serving this resource.
rolePrivsMap<String,List<Priviledge>>The privileges granted to each role by this resource's controller mapping, used by appendPriviledges to calculate a user's effective privileges.
seoContentSeoContentBeanSEO metadata for this resource, populated by running the controller mapping's SEO content function if one is configured.
sourceTenantIdlongThe id of the organisation that owns this resource, taken from the resource's root folder.
titleStringThe title of this resource, computed by running the controller mapping's title function if one is configured, falling back to the selected view's title if it implements TitledView, and finally to the resource's name.
typesSet<String>The resource type tags applied to this resource's controller mapping, for example html.
uniqueIdStringA unique id for this resource, computed by running the controller mapping's unique-id function if one is configured, otherwise delegating to the superclass.
websiteNameStringThe name of the website this resource belongs to.

Inherited from AbstractResource

Properties

PropertyReturnsDescription
accessControlListMap<Principal,List<Priviledge>>The access control list of allowed privileges per principal for this resource. This implementation is not populated; access is instead resolved dynamically via the security manager, so this always returns null.
asListResourceListThis resource wrapped as a single-element ResourceList, convenient for scripts that want to treat a single resource the same way as a list of resources.
attributesMap<String,Object>A mutable, request-scoped map of arbitrary attributes attached to this resource instance, for passing values between code that shares a reference to the same resource.
createDateDateThe date this resource was created. This base implementation always returns null; subclasses that track creation dates override it.
dirbooleanWhether this resource is a collection (folder-like) resource rather than a single item.
linkStringA ready-to-use HTML anchor tag linking to this resource's href, using its name as the link text.
oAuth2ProvidersMap<String,OAuth2Provider>The OAuth2 login providers available for this resource, combining the providers configured on the social login app with the platform's built-in social posting services mapped onto their OAuth2 provider templates.
principalCollectionHrefsHrefListThe hrefs of the collections that contain principals, so a WebDAV client can discover where to list users. This base implementation always returns the single href "/users/".
principalURLStringThe href of the owning principal resource for this resource, found by walking up the parent chain to the nearest principal resource.
readablebooleanWhether the current user, who may be null for an anonymous request, has READ_CONTENT permission on this resource.
realmStringThe HTTP authentication realm used for digest and basic authentication challenges on this resource.
writablebooleanWhether the current user, who may be null for an anonymous request, has WRITE_CONTENT permission on this resource.

Methods

getRealm() · getPrincipalURL() · getPrincipalCollectionHrefs() · getLink() · find(String path) · find(Path p) · isDir() · getContentType(String accepts) · getCreateDate() · getAccessControlList() · closest(String type) · closest(Class<T> c) · isReadable() · isWritable() · getAsList() · getOAuth2Providers() · getAttributes()

getRealm()

Returns: String

The HTTP authentication realm used for digest and basic authentication challenges on this resource.

getPrincipalURL()

Returns: String

The href of the owning principal resource for this resource, found by walking up the parent chain to the nearest principal resource.

getPrincipalCollectionHrefs()

Returns: HrefList

The hrefs of the collections that contain principals, so a WebDAV client can discover where to list users. This base implementation always returns the single href "/users/".

Returns: String

A ready-to-use HTML anchor tag linking to this resource's href, using its name as the link text.

find(String path)

Returns: Resource

Finds a resource within the website by its path. A relative path is evaluated relative to this resource; an absolute path is evaluated from the website root. For example find("/programs/p1") looks up the program p1 from the root, and find("../p1") looks up p1 in the folder above this resource.

ParameterDescription
paththe relative or absolute path to resolve

find(Path p)

Returns: Resource

Finds a resource by walking a Path object one part at a time, following "." and ".." segments and looking up each remaining part as a child of the current resource.

ParameterDescription
pthe path to resolve, relative to this resource or absolute

isDir()

Returns: boolean

Whether this resource is a collection (folder-like) resource rather than a single item.

getContentType(String accepts)

Returns: String

The content type this resource should be served as. This base implementation always returns "text/html; charset=UTF-8" for getable resources (regardless of the accepts header, since XHTML is not used because of CKEditor compatibility) and an empty string otherwise. Subclasses override this where a different content type is needed.

ParameterDescription
acceptsthe client's Accept header value, currently not used to vary the result

getCreateDate()

Returns: Date

The date this resource was created. This base implementation always returns null; subclasses that track creation dates override it.

getAccessControlList()

Returns: Map<Principal,List<Priviledge>>

The access control list of allowed privileges per principal for this resource. This implementation is not populated; access is instead resolved dynamically via the security manager, so this always returns null.

closest(String type)

Returns: CommonResource

Finds the closest resource, starting from this one and walking up through its parents, whose is(type) returns true.

ParameterDescription
typethe type name to match, as used by is(String)

closest(Class<T> c)

Returns: T

Finds the closest resource, starting from this one and walking up through its parents, that is an instance of the given class.

ParameterDescription
cthe class to match against

isReadable()

Returns: boolean

Whether the current user, who may be null for an anonymous request, has READ_CONTENT permission on this resource.

isWritable()

Returns: boolean

Whether the current user, who may be null for an anonymous request, has WRITE_CONTENT permission on this resource.

getAsList()

Returns: ResourceList

This resource wrapped as a single-element ResourceList, convenient for scripts that want to treat a single resource the same way as a list of resources.

getOAuth2Providers()

Returns: Map<String,OAuth2Provider>

The OAuth2 login providers available for this resource, combining the providers configured on the social login app with the platform's built-in social posting services mapped onto their OAuth2 provider templates.

getAttributes()

Returns: Map<String,Object>

A mutable, request-scoped map of arbitrary attributes attached to this resource instance, for passing values between code that shares a reference to the same resource.


Methods

getSourceTenantId() · getRepoAppName() · setMenuActive() · getHash() · isPublic() · getWebsiteName() · getCurrentUser() · getParent() · getName() · getTitle() · getModifiedDate() · getUniqueId() · getPathParams() · getMethod() · getAppSettings() · getSeoContent() · jsonView(Object jsonObject) · templateView(String template) · jsonResult(boolean result) · jsonResult(boolean result, String message) · jsonResult(boolean result, String message, String nextHref) · getHref() · getPath() · throwNotFound(String reason) · throwBadRequest(String reason) · throwNotAuthorized(String reason) · getControllerMappings() · dataBind(Object target, Map params) · getTypes() · getBreadCrumbs() · getRolePrivs()

getSourceTenantId()

Returns: long

The id of the organisation that owns this resource, taken from the resource's root folder.

getRepoAppName()

Returns: String

The instance id of the repository app that registered the controller mapping serving this resource.

setMenuActive()

Returns: void

Marks the menu item matching this resource's mapping, or failing that its href, as active for the current request, so the rendered page can highlight the current position in the navigation menu.

getHash()

Returns: String

A hash identifying the current content of this resource, taken from the view resolved for a GET request if that view is a FileHashView.

isPublic()

Returns: boolean

Whether this resource can be accessed without authentication, taken from its controller mapping.

getWebsiteName()

Returns: String

The name of the website this resource belongs to.

getCurrentUser()

Returns: UserResource

Returns the currently authenticated user for this request.

getParent()

Returns: CommonCollectionResource

The root folder this resource was resolved within.

getName()

Returns: String

The final path segment of this resource's path.

getTitle()

Returns: String

The title of this resource, computed by running the controller mapping's title function if one is configured, falling back to the selected view's title if it implements TitledView, and finally to the resource's name.

getModifiedDate()

Returns: Date

The last modified date of this resource, computed by running the controller mapping's modified-date function if one is configured, otherwise delegating to the superclass.

getUniqueId()

Returns: String

A unique id for this resource, computed by running the controller mapping's unique-id function if one is configured, otherwise delegating to the superclass.

getPathParams()

Returns: Map<String,Object>

The named path parameters extracted from matching this resource's URL against its controller mapping's path pattern, for example an id captured from a path segment.

getMethod()

Returns: ControllerMethod

The controller method resolved for the current request's HTTP method, used to run the matching JS handler and select the response view.

getAppSettings()

Returns: Map<String,String>

The configuration settings of the owning repository app for the current organisation and branch, lazily loaded and cached on first access.

getSeoContent()

Returns: SeoContentBean

SEO metadata for this resource, populated by running the controller mapping's SEO content function if one is configured.

jsonView(Object jsonObject)

Returns: JsonView

Creates a view which serialises the given object to JSON. If the object is already a JsonResult it is wrapped as-is.

ParameterDescription
jsonObjectthe object to serialise as the response body

templateView(String template)

Returns: TemplateView

Creates a view which renders the given template.

ParameterDescription
templatethe path of the template to render

jsonResult(boolean result)

Returns: JsonView

Creates a view which renders a simple JSON result with the given success flag.

ParameterDescription
resulttrue if the operation succeeded, false otherwise

jsonResult(boolean result, String message)

Returns: JsonView

Creates a view which renders a JSON result with the given success flag and message.

ParameterDescription
resulttrue if the operation succeeded, false otherwise
messagea message describing the result

jsonResult(boolean result, String message, String nextHref)

Returns: JsonView

Creates a view which renders a JSON result with the given success flag, message, and a href the client should navigate to next.

ParameterDescription
resulttrue if the operation succeeded, false otherwise
messagea message describing the result
nextHrefthe href the client should navigate to next

getHref()

Returns: String

The URL path this resource was resolved from.

getPath()

Returns: Path

The Milton path this resource was resolved from.

throwNotFound(String reason)

Returns: void

Raises a not-found error, for a controller script to signal that the requested item does not exist.

ParameterDescription
reasona message explaining what could not be found

throwBadRequest(String reason)

Returns: void

Raises a bad-request error, for a controller script to signal that the request is invalid.

ParameterDescription
reasona message explaining why the request is invalid

throwNotAuthorized(String reason)

Returns: void

Raises a not-authorized error, for a controller script to signal that the current user cannot perform the requested action.

ParameterDescription
reasona message explaining why the request is not authorized

getControllerMappings()

Returns: ControllerMappingList

The full set of controller mappings registered by the owning app, of which this resource's mapping is one.

dataBind(Object target, Map params)

Returns: void

Populates the given target object's properties from the given request parameters, then saves it: as a Hibernate entity if it is one, or by calling save on it if it is a JsonDocumentResource.

ParameterDescription
targetthe object to populate and save, must not be null
paramsthe request parameters to bind onto target

getTypes()

Returns: Set<String>

The resource type tags applied to this resource's controller mapping, for example html.

getBreadCrumbs()

Returns: Map

The breadcrumb trail for this resource, either taken directly from the controller mapping's configured breadcrumb map or computed by running its breadcrumb function.

getRolePrivs()

Returns: Map<String,List<Priviledge>>

The privileges granted to each role by this resource's controller mapping, used by appendPriviledges to calculate a user's effective privileges.

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