private static CompoundKey parseCompoundKey(final ResourceModel resource,
final ServerResourceContext context,
final String pathSegment)
{
CompoundKey compoundKey;
try
{
compoundKey =
ArgumentUtils.parseCompoundKey(pathSegment, resource.getKeys(),
context.getRestliProtocolVersion());
}
catch (PathSegmentSyntaxException e)
{
throw new RoutingException(String.format("input %s is not a Compound key", pathSegment),
HttpStatus.S_400_BAD_REQUEST.getCode(),
e);
}
catch (IllegalArgumentException e)
{
throw new RoutingException(String.format("input %s is not a Compound key", pathSegment),
HttpStatus.S_400_BAD_REQUEST.getCode(),
e);
}
for (String simpleKeyName : compoundKey.getPartKeys())
{
context.getPathKeys().append(simpleKeyName, compoundKey.getPart(simpleKeyName));
}
context.getPathKeys().append(resource.getKeyName(), compoundKey);
return compoundKey;
}