use of com.linkedin.restli.common.ResourceMethod in project rest.li by linkedin.
the class MethodAdapterRegistry method buildResponseBuilders.
private Map<ResourceMethod, RestLiResponseBuilder> buildResponseBuilders(ErrorResponseBuilder errorResponseBuilder) {
Map<ResourceMethod, RestLiResponseBuilder> result = new HashMap<ResourceMethod, RestLiResponseBuilder>(ResourceMethod.values().length);
result.put(ResourceMethod.GET, new GetResponseBuilder());
result.put(ResourceMethod.BATCH_GET, new BatchGetResponseBuilder(errorResponseBuilder));
result.put(ResourceMethod.FINDER, new CollectionResponseBuilder());
result.put(ResourceMethod.CREATE, new CreateResponseBuilder());
result.put(ResourceMethod.PARTIAL_UPDATE, new UpdateResponseBuilder());
result.put(ResourceMethod.UPDATE, new UpdateResponseBuilder());
result.put(ResourceMethod.DELETE, new UpdateResponseBuilder());
result.put(ResourceMethod.ACTION, new ActionResponseBuilder());
result.put(ResourceMethod.BATCH_UPDATE, new BatchUpdateResponseBuilder(errorResponseBuilder));
result.put(ResourceMethod.BATCH_PARTIAL_UPDATE, new BatchUpdateResponseBuilder(errorResponseBuilder));
result.put(ResourceMethod.BATCH_CREATE, new BatchCreateResponseBuilder(errorResponseBuilder));
result.put(ResourceMethod.BATCH_DELETE, new BatchUpdateResponseBuilder(errorResponseBuilder));
result.put(ResourceMethod.GET_ALL, new CollectionResponseBuilder());
return Collections.unmodifiableMap(result);
}
use of com.linkedin.restli.common.ResourceMethod in project rest.li by linkedin.
the class MethodAdapterRegistry method buildAdapterRegistry.
private Map<ResourceMethod, RestLiArgumentBuilder> buildAdapterRegistry() {
Map<ResourceMethod, RestLiArgumentBuilder> result = new HashMap<ResourceMethod, RestLiArgumentBuilder>(ResourceMethod.values().length);
result.put(ResourceMethod.GET, new GetArgumentBuilder());
result.put(ResourceMethod.BATCH_GET, new BatchGetArgumentBuilder());
result.put(ResourceMethod.FINDER, new CollectionArgumentBuilder());
result.put(ResourceMethod.CREATE, new CreateArgumentBuilder());
result.put(ResourceMethod.PARTIAL_UPDATE, new PatchArgumentBuilder());
result.put(ResourceMethod.UPDATE, new UpdateArgumentBuilder());
result.put(ResourceMethod.DELETE, new GetArgumentBuilder());
result.put(ResourceMethod.ACTION, new ActionArgumentBuilder());
result.put(ResourceMethod.BATCH_UPDATE, new BatchUpdateArgumentBuilder());
result.put(ResourceMethod.BATCH_PARTIAL_UPDATE, new BatchPatchArgumentBuilder());
result.put(ResourceMethod.BATCH_CREATE, new BatchCreateArgumentBuilder());
result.put(ResourceMethod.BATCH_DELETE, new BatchDeleteArgumentBuilder());
result.put(ResourceMethod.GET_ALL, new CollectionArgumentBuilder());
return Collections.unmodifiableMap(result);
}
use of com.linkedin.restli.common.ResourceMethod in project rest.li by linkedin.
the class TestRestLiResponseHandler method buildRoutingResult.
private final RoutingResult buildRoutingResult(ResourceMethod resourceMethod, RestRequest request, Map<String, String> acceptHeaders) throws SecurityException, NoSuchMethodException, RestLiSyntaxException {
Method method = ProjectionTestFixture.class.getMethod("batchGet", Set.class);
ResourceModel model = RestLiTestHelper.buildResourceModel(StatusCollectionResource.class);
ResourceMethodDescriptor methodDescriptor = ResourceMethodDescriptor.createForRestful(resourceMethod, method, InterfaceType.SYNC);
model.addResourceMethodDescriptor(methodDescriptor);
ServerResourceContext context = new ResourceContextImpl(new PathKeysImpl(), request, new RequestContext());
RestUtils.validateRequestHeadersAndUpdateResourceContext(acceptHeaders, context);
return new RoutingResult(context, methodDescriptor);
}
use of com.linkedin.restli.common.ResourceMethod in project parseq by linkedin.
the class RequestConfigElement method parse.
static RequestConfigElement parse(String property, String key, Object value) throws RequestConfigKeyParsingException {
RequestConfigKeyParsingErrorListener errorListener = new RequestConfigKeyParsingErrorListener();
ANTLRInputStream input = new ANTLRInputStream(key);
RequestConfigKeyLexer lexer = new RequestConfigKeyLexer(input);
lexer.removeErrorListeners();
lexer.addErrorListener(errorListener);
CommonTokenStream tokens = new CommonTokenStream(lexer);
RequestConfigKeyParser parser = new RequestConfigKeyParser(tokens);
parser.removeErrorListeners();
parser.addErrorListener(errorListener);
KeyContext keyTree = parser.key();
if (!errorListener.hasErrors()) {
InboundContext inbound = keyTree.inbound();
OutboundContext outbound = keyTree.outbound();
Optional<String> inboundName = handlingWildcard(inbound.restResource());
Optional<String> outboundName = handlingWildcard(outbound.restResource());
Optional<String> inboundOp = getOpIn(inbound.operationIn());
Optional<ResourceMethod> outboundOp = getOpOut(outbound.operationOut());
Optional<String> inboundOpName = inboundOp.flatMap(method -> getOpInName(method, inbound.operationIn()));
Optional<String> outboundOpName = outboundOp.flatMap(method -> getOpOutName(method, outbound.operationOut()));
return new RequestConfigElement(key, coerceValue(property, value), property, inboundName, outboundName, inboundOpName, outboundOpName, inboundOp, outboundOp);
} else {
throw new RequestConfigKeyParsingException("Error" + ((errorListener.errorsSize() > 1) ? "s" : "") + " parsing key: " + key + "\n" + errorListener);
}
}
use of com.linkedin.restli.common.ResourceMethod in project rest.li by linkedin.
the class TestCustomMethodAdapterProvider method initClass.
@BeforeClass
public void initClass() throws Exception {
RestLiConfig config = new RestLiConfig();
config.setMethodAdapterProvider(new DefaultMethodAdapterProvider(new ErrorResponseBuilder(ErrorResponseFormat.MESSAGE_AND_SERVICECODE)) {
@Override
public RestLiArgumentBuilder getArgumentBuilder(ResourceMethod resourceMethod) {
// Override the behavior of the CREATE argument builder
if (resourceMethod == ResourceMethod.CREATE) {
return new CreateArgumentBuilder() {
@Override
public RestLiRequestData extractRequestData(RoutingResult routingResult, DataMap dataMap) {
// Always use the FRIENDLY record regardless of the actual data
return new RestLiRequestDataImpl.Builder().entity(FRIENDLY).build();
}
};
} else {
return super.getArgumentBuilder(resourceMethod);
}
}
});
super.init(false, config);
}
Aggregations