use of com.linkedin.restli.internal.common.PathSegment.PathSegmentSyntaxException in project rest.li by linkedin.
the class RestLiRouter method parseComplexKey.
/**
* Instantiate the complex key from the current path segment (treat is as a list of
* query parameters) and put it into the context.
*
* @param currentPathSegment
* @param context
* @param resource
* @return
*/
private static void parseComplexKey(final ResourceModel resource, final ServerResourceContext context, final String currentPathSegment) {
try {
ComplexKeySpec<? extends RecordTemplate, ? extends RecordTemplate> complexKeyType = ComplexKeySpec.forClassesMaybeNull(resource.getKeyKeyClass(), resource.getKeyParamsClass());
ComplexResourceKey<RecordTemplate, RecordTemplate> complexKey = ComplexResourceKey.parseString(currentPathSegment, complexKeyType, context.getRestliProtocolVersion());
context.getPathKeys().append(resource.getKeyName(), complexKey);
} catch (PathSegmentSyntaxException e) {
throw new RoutingException(String.format("Complex key query parameters parsing error: '%s'", e.getMessage()), HttpStatus.S_400_BAD_REQUEST.getCode());
}
}
Aggregations