class XlsSchemaParser implements SchemaParser {

    @Override
    public Schema parse(Request request) {
        final Marker marker = Markers.dataset(request.getMetadata().getId());
        LOGGER.debug(marker, "parsing {} ");
        try {
            List<Schema.SheetContent> sheetContents = parseAllSheets(request);
            Schema result;
            if (!sheetContents.isEmpty()) {
                // only one sheet
                if (sheetContents.size() == 1) {
                    result = Schema.Builder
                            .parserResult() //
                            .sheetContents(sheetContents) //
                            .draft(false) //
                            .sheetName(sheetContents.get(0).getName()) //
                            .build();
                } else {
                    // multiple sheet, set draft flag on
                    result = Schema.Builder
                            .parserResult() //
                            .sheetContents(sheetContents) //
                            .draft(true) //
                            .sheetName(sheetContents.get(0).getName()) //
                            .build();
                }
            }
            // nothing to parse
            else {
                throw new TDPException(DataSetErrorCodes.UNABLE_TO_READ_DATASET_CONTENT);
            }
            return result;
        } catch (TDPException e) {
            throw e;
        } catch (Exception e) {
            LOGGER.debug(marker, "IOException during parsing xls request :" + e.getMessage(), e);
            throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e);
        }

    }

}