Fluent builder for registering a URL to controller mapping for a custom app, reached from controllerMappings.adminController() for admin screens or controllerMappings.websiteController() for website controllers. Set the path, view and any role privileges, add one JS function per HTTP method with addMethod, then call build to create the mapping and, unless the app engine has already finished initialising, register it for routing.
Group: Builders
Properties
| Property | Returns | Description |
|---|---|---|
| rolePrivs | Map<String,List<Priviledge>> | The privileges configured so far on this builder, keyed by role name. May be null if no role has been added yet. |
Methods
addRole(String roleName, String privNames) · addRole(String roleName, List<Priviledge> privs) · getRolePrivs() · path(String s) · pathSegmentName(String s) · pathSegmentResolver(String groupName, Object resolver) · title(Object s) · breadCrumbs(String functionName) · breadCrumbs(Map breadCrumbMap) · uniqueId(Object uniqueId) · modifiedDate(Object modifiedDate) · contentLength(Object contentLength) · seoContent(Object s) · addPathResolver(String groupName, Object resolver) · enabled(boolean b) · defaultView(View view) · addMethod(String method, String function) · addFunction(String method, VarArgFunction function) · addMethod(String method, String functionName, String requiredParam) · addFunction(String method, VarArgFunction function, String requiredParam) · addMethod(String method, String functionName, String requiredParam, View view) · addFunction(String method, VarArgFunction function, String requiredParam, View view) · isPublic(Boolean isPub) · postPriviledge(String s) · types(String[] types) · addType(String type) · mountRepository(String repoName) · build() · child(ControllerMappingBuilder childBuilder)
addRole(String roleName, String privNames)
Returns: ControllerMappingBuilder
Grants the named role the given privileges on this controller. Unknown privilege names are logged and skipped rather than failing the whole call.
| Parameter | Description |
|---|---|
roleName | the role to grant privileges to |
privNames | the names of the AccessControlledResource.Priviledge values to grant; unknown names are ignored |
addRole(String roleName, List<Priviledge> privs)
Returns: ControllerMappingBuilder
Grants the named role the given privileges on this controller.
| Parameter | Description |
|---|---|
roleName | the role to grant privileges to |
privs | the privileges to grant |
getRolePrivs()
Returns: Map<String,List<Priviledge>>
The privileges configured so far on this builder, keyed by role name. May be null if no role has been added yet.
path(String s)
Returns: ControllerMappingBuilder
Sets the path or regular expression this controller is mapped to, for example /services/uploads/*.
| Parameter | Description |
|---|---|
s | the path pattern to match incoming requests against |
pathSegmentName(String s)
Returns: ControllerMappingBuilder
Sets this mapping as a single dynamic path segment with a fixed name, rather than a fixed path or regular expression.
| Parameter | Description |
|---|---|
s | the segment name to match |
pathSegmentResolver(String groupName, Object resolver)
Returns: ControllerMappingBuilder
Sets this mapping as a single dynamic path segment whose value is resolved at request time by the given resolver, registered under the given group name.
| Parameter | Description |
|---|---|
groupName | the name the resolver is registered under |
resolver | the resolver used to compute this segment's value at request time |
title(Object s)
Returns: ControllerMappingBuilder
Sets the title for this controller, either a literal value or the name of a JS function invoked to compute it at request time.
| Parameter | Description |
|---|---|
s | the title, or the name of a function that computes it |
breadCrumbs(String functionName)
Returns: ControllerMappingBuilder
Sets the breadcrumbs for this controller to be computed at request time by the named JS function.
| Parameter | Description |
|---|---|
functionName | name of the JS function invoked to generate the breadcrumbs |
breadCrumbs(Map breadCrumbMap)
Returns: ControllerMappingBuilder
Sets a fixed, prebuilt set of breadcrumbs for this controller. Useful for statically defined pages; the map should be a LinkedHashMap to retain entry ordering.
| Parameter | Description |
|---|---|
breadCrumbMap | the prebuilt breadcrumbs map |
uniqueId(Object uniqueId)
Returns: ControllerMappingBuilder
Sets the unique id for this controller, either a literal value or the name of a JS function invoked to compute it at request time.
| Parameter | Description |
|---|---|
uniqueId | the unique id, or the name of a function that computes it |
modifiedDate(Object modifiedDate)
Returns: ControllerMappingBuilder
Sets the modified date for this controller, either a literal value or the name of a JS function invoked to compute it at request time.
| Parameter | Description |
|---|---|
modifiedDate | the modified date, or the name of a function that computes it |
contentLength(Object contentLength)
Returns: ControllerMappingBuilder
Sets the content length for this controller, either a literal value or the name of a JS function invoked to compute it at request time.
| Parameter | Description |
|---|---|
contentLength | the content length, or the name of a function that computes it |
seoContent(Object s)
Returns: ControllerMappingBuilder
Sets the SEO content for this controller, typically the name of a JS function invoked to populate it at request time.
| Parameter | Description |
|---|---|
s | the SEO content, or the name of a function that computes it |
addPathResolver(String groupName, Object resolver)
Returns: ControllerMappingBuilder
Registers a resolver used to compute the value of a named path segment at request time.
| Parameter | Description |
|---|---|
groupName | the named regular expression group the resolver applies to |
resolver | the resolver used to compute that segment's value at request time |
enabled(boolean b)
Returns: ControllerMappingBuilder
Sets whether this controller mapping is active. A disabled mapping is not matched to incoming requests.
| Parameter | Description |
|---|---|
b | true to enable the mapping |
defaultView(View view)
Returns: ControllerMappingBuilder
Sets the view used to render this controller's response when a matched method does not specify its own view.
| Parameter | Description |
|---|---|
view | the default view for this controller |
addMethod(String method, String function)
Returns: ControllerMappingBuilder
Registers a JS function to handle the given HTTP method on this controller, with no required parameter.
| Parameter | Description |
|---|---|
method | the HTTP method to handle, for example GET or POST |
function | name of the JS function to invoke |
addFunction(String method, VarArgFunction function)
Returns: ControllerMappingBuilder
Registers a JS function reference to handle the given HTTP method on this controller, with no required parameter.
| Parameter | Description |
|---|---|
method | the HTTP method to handle, for example GET or POST |
function | the JS function to invoke |
addMethod(String method, String functionName, String requiredParam)
Returns: ControllerMappingBuilder
Registers a JS function to handle the given HTTP method on this controller, only invoked when the given request parameter is present.
| Parameter | Description |
|---|---|
method | the HTTP method to handle, for example GET or POST |
functionName | name of the JS function to invoke |
requiredParam | name of the request parameter that must be present for this method to match |
addFunction(String method, VarArgFunction function, String requiredParam)
Returns: ControllerMappingBuilder
Registers a JS function reference to handle the given HTTP method on this controller, only invoked when the given request parameter is present.
| Parameter | Description |
|---|---|
method | the HTTP method to handle, for example GET or POST |
function | the JS function to invoke |
requiredParam | name of the request parameter that must be present for this method to match |
addMethod(String method, String functionName, String requiredParam, View view)
Returns: ControllerMappingBuilder
Registers a JS function to handle the given HTTP method on this controller, only invoked when the given request parameter is present, rendering its result with the given view instead of this mapping's default view.
| Parameter | Description |
|---|---|
method | the HTTP method to handle, for example GET or POST |
functionName | name of the JS function to invoke |
requiredParam | name of the request parameter that must be present for this method to match |
view | the view used to render this method's result |
addFunction(String method, VarArgFunction function, String requiredParam, View view)
Returns: ControllerMappingBuilder
Registers a JS function reference to handle the given HTTP method on this controller, only invoked when the given request parameter is present, rendering its result with the given view instead of this mapping's default view.
| Parameter | Description |
|---|---|
method | the HTTP method to handle, for example GET or POST |
function | the JS function to invoke |
requiredParam | name of the request parameter that must be present for this method to match |
view | the view used to render this method's result |
isPublic(Boolean isPub)
Returns: ControllerMappingBuilder
Sets whether this controller can be accessed without authentication. A null value is treated as true.
| Parameter | Description |
|---|---|
isPub | true or null to make the controller public, false to require authentication |
postPriviledge(String s)
Returns: ControllerMappingBuilder
Sets the privilege a user must hold to POST to this controller.
| Parameter | Description |
|---|---|
s | the name of an AccessControlledResource.Priviledge value |
types(String[] types)
Returns: ControllerMappingBuilder
Replaces this controller's resource type tags with the given set, used to match roles and other type-based rules against it.
| Parameter | Description |
|---|---|
types | the type tags to set; a null value clears the tags to an empty set |
addType(String type)
Returns: ControllerMappingBuilder
Adds a single resource type tag to this controller, used to match roles and other type-based rules against it, without replacing tags already set.
| Parameter | Description |
|---|---|
type | the type tag to add |
mountRepository(String repoName)
Returns: ControllerMappingBuilder
Mounts the named content repository at this controller's path and marks the mapping as a collection.
| Parameter | Description |
|---|---|
repoName | the name of the content repository to mount |
build()
Returns: ControllerMapping
Builds the ControllerMapping configured on this builder and, unless the app engine has already finished initialising, registers it with the root mappings list it was created against for routing.
child(ControllerMappingBuilder childBuilder)
Returns: ControllerMappingBuilder
Builds the given child builder and adds the resulting mapping as a child of this controller, marking this mapping as a collection. The child mapping is not itself registered with the root mappings list.
| Parameter | Description |
|---|---|
childBuilder | the builder for the child controller to add |