class CatalogRest {

    @POST
    @Path("{catalogId}/records/{recordId}/branches/{branchId}/conflicts/resolution")
    @Produces(MediaType.TEXT_PLAIN)
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    @RolesAllowed("user")
    @ApiOperation("Merges the two commits identified by the provided IDs.")
    @ActionId(value = Modify.TYPE)
    @ActionAttributes(
            @AttributeValue(type = ValueType.QUERY, id = VersionedRDFRecord.branch_IRI, value = "targetId")
    )
    @ResourceId(type = ValueType.PATH, value = "recordId")
    public Response merge(@Context ContainerRequestContext context,
                   @PathParam("catalogId") String catalogId,
                   @PathParam("recordId") String recordId,
                   @PathParam("branchId") String sourceBranchId,
                   @QueryParam("targetId") String targetBranchId,
                   @FormDataParam("additions") String additionsJson,
                   @FormDataParam("deletions") String deletionsJson) {
        try {
            User activeUser = getActiveUser(context, engineManager);
            Model additions = StringUtils.isEmpty(additionsJson) ? null : convertJsonld(additionsJson);
            Model deletions = StringUtils.isEmpty(deletionsJson) ? null : convertJsonld(deletionsJson);
            Resource newCommitId = versioningManager.merge(vf.createIRI(catalogId), vf.createIRI(recordId),
                    vf.createIRI(sourceBranchId), vf.createIRI(targetBranchId), activeUser, additions, deletions);
            return Response.ok(newCommitId.stringValue()).build();
        } catch (IllegalArgumentException ex) {
            throw ErrorUtils.sendError(ex, ex.getMessage(), Response.Status.BAD_REQUEST);
        } catch (IllegalStateException | MobiException ex) {
            throw ErrorUtils.sendError(ex, ex.getMessage(), Response.Status.INTERNAL_SERVER_ERROR);
        }
    }

}