class UploadedDocumentServiceImpl implements UploadedDocumentService,
                                                    Serializable {

    @Override
    public DocumentUploadResponse uploadContent(final DocumentUploadChunk chunk) {

        try {
            DocumentUploadSession session = getSession(chunk);

            if (session.isComplete()) {
                return merge(session);
            } else {
                return new DocumentUploadResponse(DocumentUploadResponse.DocumentUploadState.UPLOADING, true);
            }
        } catch (Exception ex) {
            logger.warn("Cannot upload chunk {}: {}", chunk.getDocumentName(), ex);
            return new DocumentUploadResponse(DocumentUploadResponse.DocumentUploadState.FINISH, false);
        }
    }

    @Inject public  UploadedDocumentServiceImpl(UploadedDocumentStorage storage);

}