public void parse(InputStream file) throws IOException, TikaException {
        ByteArrayOutputStream xmpraw = new ByteArrayOutputStream();
        if (!scanner.parse(file, xmpraw)) {
            return;
        }
        Reader decoded = new InputStreamReader(
                new ByteArrayInputStream(xmpraw.toByteArray()),
                DEFAULT_XMP_CHARSET);
        try {
            XMPMetadata xmp = XMPMetadata.load(new InputSource(decoded));
            XMPSchemaDublinCore dc = xmp.getDublinCoreSchema();
            if (dc != null) {
                if (dc.getTitle() != null) {
                    metadata.set(DublinCore.TITLE, dc.getTitle());
                }
                if (dc.getDescription() != null) {
                    metadata.set(DublinCore.DESCRIPTION, dc.getDescription());
                }
                if (dc.getCreators() != null && dc.getCreators().size() > 0) {
                    metadata.set(DublinCore.CREATOR, joinCreators(dc.getCreators()));
                }
                if (dc.getSubjects() != null && dc.getSubjects().size() > 0) {
                    Iterator<String> keywords = dc.getSubjects().iterator();
                    while (keywords.hasNext()) {
                        metadata.add(DublinCore.SUBJECT, keywords.next());
                    }
                    // TODO should we set KEYWORDS too?
                    // All tested photo managers set the same in Iptc.Application2.Keywords and Xmp.dc.subject
                }
            }
        } catch (IOException e) {
            // Could not parse embedded XMP metadata. That's not a serious
            // problem, so we'll just ignore the issue for now.
            // TODO: Make error handling like this configurable.
        }
    }
public void parse(InputStream file) throws IOException, TikaException {
        ByteArrayOutputStream xmpraw = new ByteArrayOutputStream();
        if (!scanner.parse(file, xmpraw)) {
            return;
        }
        Reader decoded = new InputStreamReader(
                new ByteArrayInputStream(xmpraw.toByteArray()),
                DEFAULT_XMP_CHARSET);
        try {
            XMPMetadata xmp = XMPMetadata.load(new InputSource(decoded));
            XMPSchemaDublinCore dc = xmp.getDublinCoreSchema();
            if (dc != null) {
                if (dc.getTitle() != null) {
                    metadata.set(DublinCore.TITLE, dc.getTitle());
                }
                if (dc.getDescription() != null) {
                    metadata.set(DublinCore.DESCRIPTION, dc.getDescription());
                }
                if (dc.getCreators() != null && dc.getCreators().size() > 0) {
                    metadata.set(DublinCore.CREATOR, joinCreators(dc.getCreators()));
                }
                if (dc.getSubjects() != null && dc.getSubjects().size() > 0) {
                    Iterator<String> keywords = dc.getSubjects().iterator();
                    while (keywords.hasNext()) {
                        metadata.add(DublinCore.SUBJECT, keywords.next());
                    }
                   
                   
                }
            }
        } catch (IOException e) {
           
           
           
        }
    }
public void parse(inputstream file) throws ioexception, tikaexception { bytearrayoutputstream xmpraw = new bytearrayoutputstream(); if (!scanner.parse(file, xmpraw)) { return; } reader decoded = new inputstreamreader( new bytearrayinputstream(xmpraw.tobytearray()), default_xmp_charset); try { xmpmetadata xmp = xmpmetadata.load(new inputsource(decoded)); xmpschemadublincore dc = xmp.getdublincoreschema(); if (dc != null) { if (dc.gettitle() != null) { metadata.set(dublincore.title, dc.gettitle()); } if (dc.getdescription() != null) { metadata.set(dublincore.description, dc.getdescription()); } if (dc.getcreators() != null && dc.getcreators().size() > 0) { metadata.set(dublincore.creator, joincreators(dc.getcreators())); } if (dc.getsubjects() != null && dc.getsubjects().size() > 0) { iterator<string> keywords = dc.getsubjects().iterator(); while (keywords.hasnext()) { metadata.add(dublincore.subject, keywords.next()); } } } } catch (ioexception e) { } }