class StreamReceiverHandler implements Serializable {

    protected void doHandleMultipartFileUpload(VaadinSession session,
            VaadinRequest request, VaadinResponse response,
            StreamReceiver streamReceiver, StateNode owner) throws IOException {
        boolean success = false;
        try {
            if (hasParts(request)) {
                success = handleMultipartFileUploadFromParts(session, request,
                        streamReceiver, owner);
            } else {
                success = handleMultipartFileUploadFromInputStream(session,
                        request, streamReceiver, owner);
            }
        } catch (Exception exception) {
            session.lock();
            try {
                session.getErrorHandler().error(new ErrorEvent(exception));
            } finally {
                session.unlock();
            }
        }
        sendUploadResponse(response, success);
    }

}