use of org.forgerock.http.routing.UriRouterContext in project OpenAM by OpenRock.
the class ServerContextUtils method getId.
/**
* Returns the UriRouterContext's "id" UriTemplateVariable from the provided Context.
*
* @param context from which to pull the id
* @return the id, otherwise null.
*/
public static String getId(Context context) {
if (context.containsContext(UriRouterContext.class)) {
UriRouterContext routerContext = context.asContext(UriRouterContext.class);
Map<String, String> templateVars = routerContext.getUriTemplateVariables();
if (templateVars != null && !templateVars.isEmpty()) {
return templateVars.get("id");
}
}
return null;
}
use of org.forgerock.http.routing.UriRouterContext in project OpenAM by OpenRock.
the class ServerContextUtils method getMatchedUri.
/**
* Returns the UriRouterContext's matchedUri, and appends its id, if there is one.
* Id is retrieved via {@link ServerContextUtils#getId(Context)}.
*
* @param context from which to gather the matched Uri and id information
* @return a String in the form <code>matchedUri | id</code>, omitting either if they are null.
*/
public static String getMatchedUri(Context context) {
String resource = "";
if (context.containsContext(UriRouterContext.class)) {
UriRouterContext routerContext = context.asContext(UriRouterContext.class);
resource = routerContext.getMatchedUri();
}
String id = getId(context);
if (id != null) {
resource += "|" + id;
}
return resource;
}
use of org.forgerock.http.routing.UriRouterContext in project OpenAM by OpenRock.
the class RealmContextFilterTest method verifyUriRouterContextForInvalidRealm.
private void verifyUriRouterContextForInvalidRealm(Context context) {
UriRouterContext routerContext = context.asContext(UriRouterContext.class);
assertThat(routerContext.getBaseUri()).isEqualTo(JSON_PATH_ELEMENT);
assertThat(routerContext.getMatchedUri()).isEmpty();
}
Aggregations