Search in sources :

Example 1 with CreateArgumentBuilder

use of com.linkedin.restli.internal.server.methods.arguments.CreateArgumentBuilder 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);
}
Also used : PatchArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.PatchArgumentBuilder) BatchPatchArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.BatchPatchArgumentBuilder) CreateArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.CreateArgumentBuilder) BatchCreateArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.BatchCreateArgumentBuilder) HashMap(java.util.HashMap) BatchPatchArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.BatchPatchArgumentBuilder) RestLiArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.RestLiArgumentBuilder) UpdateArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.UpdateArgumentBuilder) BatchUpdateArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.BatchUpdateArgumentBuilder) BatchGetArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.BatchGetArgumentBuilder) BatchGetArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.BatchGetArgumentBuilder) GetArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.GetArgumentBuilder) BatchCreateArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.BatchCreateArgumentBuilder) BatchDeleteArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.BatchDeleteArgumentBuilder) ActionArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.ActionArgumentBuilder) ResourceMethod(com.linkedin.restli.common.ResourceMethod) CollectionArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.CollectionArgumentBuilder) BatchUpdateArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.BatchUpdateArgumentBuilder)

Example 2 with CreateArgumentBuilder

use of com.linkedin.restli.internal.server.methods.arguments.CreateArgumentBuilder 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);
}
Also used : RoutingResult(com.linkedin.restli.internal.server.RoutingResult) DefaultMethodAdapterProvider(com.linkedin.restli.internal.server.methods.DefaultMethodAdapterProvider) CreateArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.CreateArgumentBuilder) ErrorResponseBuilder(com.linkedin.restli.internal.server.response.ErrorResponseBuilder) RestLiRequestDataImpl(com.linkedin.restli.server.RestLiRequestDataImpl) RestLiArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.RestLiArgumentBuilder) RestLiConfig(com.linkedin.restli.server.RestLiConfig) ResourceMethod(com.linkedin.restli.common.ResourceMethod) DataMap(com.linkedin.data.DataMap) RestLiRequestData(com.linkedin.restli.server.RestLiRequestData) BeforeClass(org.testng.annotations.BeforeClass)

Example 3 with CreateArgumentBuilder

use of com.linkedin.restli.internal.server.methods.arguments.CreateArgumentBuilder in project rest.li by linkedin.

the class DefaultMethodAdapterProvider method buildAdapterRegistry.

private Map<ResourceMethod, RestLiArgumentBuilder> buildAdapterRegistry() {
    Map<ResourceMethod, RestLiArgumentBuilder> result = new HashMap<>(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.BATCH_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);
}
Also used : PatchArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.PatchArgumentBuilder) BatchPatchArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.BatchPatchArgumentBuilder) CreateArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.CreateArgumentBuilder) BatchCreateArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.BatchCreateArgumentBuilder) HashMap(java.util.HashMap) BatchPatchArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.BatchPatchArgumentBuilder) RestLiArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.RestLiArgumentBuilder) UpdateArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.UpdateArgumentBuilder) BatchUpdateArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.BatchUpdateArgumentBuilder) BatchGetArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.BatchGetArgumentBuilder) BatchGetArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.BatchGetArgumentBuilder) GetArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.GetArgumentBuilder) BatchCreateArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.BatchCreateArgumentBuilder) BatchDeleteArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.BatchDeleteArgumentBuilder) ActionArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.ActionArgumentBuilder) ResourceMethod(com.linkedin.restli.common.ResourceMethod) CollectionArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.CollectionArgumentBuilder) BatchUpdateArgumentBuilder(com.linkedin.restli.internal.server.methods.arguments.BatchUpdateArgumentBuilder)

Aggregations

ResourceMethod (com.linkedin.restli.common.ResourceMethod)3 CreateArgumentBuilder (com.linkedin.restli.internal.server.methods.arguments.CreateArgumentBuilder)3 RestLiArgumentBuilder (com.linkedin.restli.internal.server.methods.arguments.RestLiArgumentBuilder)3 ActionArgumentBuilder (com.linkedin.restli.internal.server.methods.arguments.ActionArgumentBuilder)2 BatchCreateArgumentBuilder (com.linkedin.restli.internal.server.methods.arguments.BatchCreateArgumentBuilder)2 BatchDeleteArgumentBuilder (com.linkedin.restli.internal.server.methods.arguments.BatchDeleteArgumentBuilder)2 BatchGetArgumentBuilder (com.linkedin.restli.internal.server.methods.arguments.BatchGetArgumentBuilder)2 BatchPatchArgumentBuilder (com.linkedin.restli.internal.server.methods.arguments.BatchPatchArgumentBuilder)2 BatchUpdateArgumentBuilder (com.linkedin.restli.internal.server.methods.arguments.BatchUpdateArgumentBuilder)2 CollectionArgumentBuilder (com.linkedin.restli.internal.server.methods.arguments.CollectionArgumentBuilder)2 GetArgumentBuilder (com.linkedin.restli.internal.server.methods.arguments.GetArgumentBuilder)2 PatchArgumentBuilder (com.linkedin.restli.internal.server.methods.arguments.PatchArgumentBuilder)2 UpdateArgumentBuilder (com.linkedin.restli.internal.server.methods.arguments.UpdateArgumentBuilder)2 HashMap (java.util.HashMap)2 DataMap (com.linkedin.data.DataMap)1 RoutingResult (com.linkedin.restli.internal.server.RoutingResult)1 DefaultMethodAdapterProvider (com.linkedin.restli.internal.server.methods.DefaultMethodAdapterProvider)1 ErrorResponseBuilder (com.linkedin.restli.internal.server.response.ErrorResponseBuilder)1 RestLiConfig (com.linkedin.restli.server.RestLiConfig)1 RestLiRequestData (com.linkedin.restli.server.RestLiRequestData)1