Search in sources :

Example 6 with PathSegmentSyntaxException

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());
    }
}
Also used : RoutingException(com.linkedin.restli.server.RoutingException) PathSegmentSyntaxException(com.linkedin.restli.internal.common.PathSegment.PathSegmentSyntaxException) RecordTemplate(com.linkedin.data.template.RecordTemplate)

Aggregations

PathSegmentSyntaxException (com.linkedin.restli.internal.common.PathSegment.PathSegmentSyntaxException)6 DataMap (com.linkedin.data.DataMap)4 DataList (com.linkedin.data.DataList)3 RoutingException (com.linkedin.restli.server.RoutingException)3 TemplateRuntimeException (com.linkedin.data.template.TemplateRuntimeException)2 ComplexResourceKey (com.linkedin.restli.common.ComplexResourceKey)2 CompoundKey (com.linkedin.restli.common.CompoundKey)2 List (java.util.List)2 ByteString (com.linkedin.data.ByteString)1 PathSpec (com.linkedin.data.schema.PathSpec)1 RecordTemplate (com.linkedin.data.template.RecordTemplate)1 MultivaluedMap (com.linkedin.jersey.core.util.MultivaluedMap)1 TestRecord (com.linkedin.restli.client.test.TestRecord)1 ProtocolVersion (com.linkedin.restli.common.ProtocolVersion)1 ListMap (com.linkedin.restli.internal.common.PathSegment.ListMap)1 MapMap (com.linkedin.restli.internal.common.PathSegment.MapMap)1 QueryParamsDataMap (com.linkedin.restli.internal.common.QueryParamsDataMap)1 Key (com.linkedin.restli.server.Key)1 RestLiServiceException (com.linkedin.restli.server.RestLiServiceException)1 URI (java.net.URI)1