class DefaultOfferResource extends ApplicationStatusResource {

    @PUT
    @Path("/objects/{type}/{objectId:.+}")
    @Consumes(MediaType.APPLICATION_OCTET_STREAM)
    @Produces(MediaType.APPLICATION_JSON)
    public Response putObject(@PathParam("objectId") String objectId, @PathParam("type") DataCategory type,
        @Context HttpHeaders headers, InputStream input) {

        final String xTenantId = headers.getHeaderString(GlobalDataRest.X_TENANT_ID);
        if (Strings.isNullOrEmpty(xTenantId)) {
            LOGGER.error(MISSING_THE_TENANT_ID_X_TENANT_ID);
            return Response.status(Response.Status.BAD_REQUEST).build();
        }
        final String containerName = buildContainerName(type, xTenantId);

        final String size = headers.getHeaderString(GlobalDataRest.VITAM_CONTENT_LENGTH);
        Long inputStreamSize;
        try {
            inputStreamSize = Long.valueOf(size);
        } catch (NumberFormatException e) {
            LOGGER.error("Bad or missing size '" + size + "'");
            return Response.status(Response.Status.BAD_REQUEST).build();
        }

        String xDigestAlgorithm = headers.getHeaderString(GlobalDataRest.X_DIGEST_ALGORITHM);
        if (StringUtils.isEmpty(xDigestAlgorithm)) {
            LOGGER.error("Missing digest");
            return Response.status(Response.Status.BAD_REQUEST).build();
        }
        DigestType digestType = DigestType.fromValue(xDigestAlgorithm);

        try (final SizedInputStream sis = new SizedInputStream(input)) {
            LOGGER.info("Writing object '" + objectId + "' of container " + containerName + " (size: " + size + ")");

            SanityChecker.checkParameter(objectId);
            defaultOfferService.checkOfferPath(containerName, objectId);

            final String digest =
                defaultOfferService.createObject(containerName, objectId, sis,
                    type, inputStreamSize, digestType);
            return Response.status(Response.Status.CREATED)
                .entity("{\"digest\":\"" + digest + "\",\"size\":" + sis.getSize() + "}").build();
        } catch (ConnectionException e) {
            LOGGER.error(RE_AUTHENTICATION_CALL_STREAM_ALREADY_CONSUMED_BUT_NO_FILE_CREATED, e);
            return Response.status(Status.SERVICE_UNAVAILABLE).entity(JsonHandler.createObjectNode()
                .put("msg", RE_AUTHENTICATION_CALL_STREAM_ALREADY_CONSUMED_BUT_NO_FILE_CREATED)).build();

        } catch (NonUpdatableContentAddressableStorageException e) {
            LOGGER.error("Object overriding forbidden", e);
            return Response.status(Status.CONFLICT).build();
        } catch (Exception exc) {
            LOGGER.error("Cannot create object", exc);
            return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
        } finally {
            StreamUtils.closeSilently(input);
        }
    }

    public  DefaultOfferResource(DefaultOfferService defaultOfferService);

}