public class ExpansionHandler
extends java.lang.Object
implements org.swisspush.gateleen.routing.RuleProvider.RuleChangesObserver
ExpansionHandler allows to fetch multiple a collection of multiple resources in
a single GET request. To use the ExpansionHandler the parameter expand=x has to be added.
Having a request to a resource defining a collection of resources like this:
{"acls":["admin","developer"]}
Would lead to a result like this:
{
"acls" : {
"admin" : {
"all.edit": {
"methods": [
"GET",
"PUT",
"POST",
"DELETE"
],
"path": "/.*"
}
},
"developer" : {
"role_1.menu.display": {},
"role_2.menu.display": {},
"gateleen.admin.menu": {}
}
}
}
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
EXPAND_PARAM |
static java.lang.String |
MAX_EXPANSION_LEVEL_HARD_PROPERTY |
static java.lang.String |
MAX_EXPANSION_LEVEL_SOFT_PROPERTY |
static java.lang.String |
MAX_SUBREQUEST_PROPERTY |
static java.lang.String |
SERIOUS_EXCEPTION |
static java.lang.String |
ZIP_PARAM |
| Constructor and Description |
|---|
ExpansionHandler(io.vertx.core.Vertx vertx,
org.swisspush.gateleen.core.storage.ResourceStorage storage,
io.vertx.core.http.HttpClient httpClient,
java.util.Map<java.lang.String,java.lang.Object> properties,
java.lang.String serverRoot,
java.lang.String rulesPath)
Creates a new instance of the ExpansionHandler.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getMaxExpansionLevelHard() |
int |
getMaxExpansionLevelSoft() |
int |
getMaxSubRequestCount() |
void |
handleExpansionRecursion(io.vertx.core.http.HttpServerRequest request)
Handles the request as if it is a recursive expansion.
|
void |
handleZipRecursion(io.vertx.core.http.HttpServerRequest request)
Handles the request as if it is a request for a zip stream.
|
protected boolean |
isBackendExpand(java.lang.String uri)
Check to see whether this request will be expanded by the backend (and therefore the expansionhandler
won't do anything).
|
boolean |
isCollection(java.lang.String target)
Returns true if the given name or path belongs
to a collection.
|
boolean |
isExpansionRequest(io.vertx.core.http.HttpServerRequest request)
Returns true when the
ExpansionHandler can deal with the given request. |
protected boolean |
isStorageExpand(java.lang.String uri)
Check to see whether this request is a storageExpand request (will be expanded by in the storage) (and therefore the expansionhandler
won't do the subrequests by itself).
|
boolean |
isZipRequest(io.vertx.core.http.HttpServerRequest request)
Returns true when the
ExpansionHandler can deal with the given request. |
void |
rulesChanged(java.util.List<org.swisspush.gateleen.routing.Rule> rules) |
public static final java.lang.String SERIOUS_EXCEPTION
public static final java.lang.String EXPAND_PARAM
public static final java.lang.String ZIP_PARAM
public static final java.lang.String MAX_EXPANSION_LEVEL_SOFT_PROPERTY
public static final java.lang.String MAX_EXPANSION_LEVEL_HARD_PROPERTY
public static final java.lang.String MAX_SUBREQUEST_PROPERTY
public ExpansionHandler(io.vertx.core.Vertx vertx,
org.swisspush.gateleen.core.storage.ResourceStorage storage,
io.vertx.core.http.HttpClient httpClient,
java.util.Map<java.lang.String,java.lang.Object> properties,
java.lang.String serverRoot,
java.lang.String rulesPath)
vertx - vertxstorage - storagehttpClient - httpClientproperties - propertiesserverRoot - serverRootrulesPath - rulesPathpublic void rulesChanged(java.util.List<org.swisspush.gateleen.routing.Rule> rules)
rulesChanged in interface org.swisspush.gateleen.routing.RuleProvider.RuleChangesObserverpublic int getMaxExpansionLevelSoft()
public int getMaxExpansionLevelHard()
public int getMaxSubRequestCount()
public boolean isExpansionRequest(io.vertx.core.http.HttpServerRequest request)
ExpansionHandler can deal with the given request.
The request must be a GET request and must have the parameter expand=x.
The method called after this check must be handleExpansionRecursion( ... ).request - requestprotected boolean isBackendExpand(java.lang.String uri)
uri - uri to check against the internal list of expandOnBackend urlsprotected boolean isStorageExpand(java.lang.String uri)
uri - uri to check against the internal list of storageExpand urlspublic boolean isZipRequest(io.vertx.core.http.HttpServerRequest request)
ExpansionHandler can deal with the given request.
The request must be a GET request and must have the parameter expand=x&zip=true.
The method called after this check must be handleZipRecursion( ... ).request - requestpublic void handleExpansionRecursion(io.vertx.core.http.HttpServerRequest request)
request - requestpublic void handleZipRecursion(io.vertx.core.http.HttpServerRequest request)
request - requestpublic boolean isCollection(java.lang.String target)
target - target