public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context)
            throws IOException, TikaException, SAXException {

        configure(context);
        DWGParserConfig dwgc = context.get(DWGParserConfig.class);

        if (!dwgc.getDwgReadExecutable().isEmpty()) {
            DWGReadParser dwr = new DWGReadParser();
            dwr.parse(stream, handler, metadata, context);
        } else {
            // First up, which version of the format are we handling?
            byte[] header = new byte[128];
            IOUtils.readFully(stream, header);
            String version = new String(header, 0, 6, "US-ASCII");

            XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
            xhtml.startDocument();

            switch (version) {
                case "AC1015":
                    metadata.set(Metadata.CONTENT_TYPE, TYPE.toString());
                    if (skipTo2000PropertyInfoSection(stream, header)) {
                        get2000Props(stream, metadata, xhtml);
                    }
                    break;
                case "AC1018":
                    metadata.set(Metadata.CONTENT_TYPE, TYPE.toString());
                    if (skipToPropertyInfoSection(stream, header)) {
                        get2004Props(stream, metadata, xhtml);
                    }
                    break;
                case "AC1027":
                case "AC1032":
                case "AC1021":
                case "AC1024":
                    metadata.set(Metadata.CONTENT_TYPE, TYPE.toString());
                    if (skipToPropertyInfoSection(stream, header)) {
                        get2007and2010Props(stream, metadata, xhtml);
                    }
                    break;
                default:
                    throw new TikaException("Unsupported AutoCAD drawing version: " + version);
            }

            xhtml.endDocument();
        }
    }
@Test
    public void testDWG2010CustomPropertiesParser() throws Exception {
        // Check that standard parsing works
        InputStream testInput = DWGParserTest.class
                .getResourceAsStream("/test-documents/testDWG2010_custom_props.dwg");
        testParser(testInput);

        // Check that custom properties with alternate padding work
        try (InputStream input = DWGParserTest.class
                .getResourceAsStream("/test-documents/testDWG2010_custom_props.dwg")) {
            Metadata metadata = new Metadata();
            ContentHandler handler = new BodyContentHandler();
            new DWGParser().parse(input, handler, metadata,new ParseContext());

            assertEquals("valueforcustomprop1",
                    metadata.get(DWGParser.DWG_CUSTOM_META_PREFIX + "customprop1"));
            assertEquals("valueforcustomprop2",
                    metadata.get(DWGParser.DWG_CUSTOM_META_PREFIX + "customprop2"));
        }
    }