Examples of DublinCoreAdapter


Examples of org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter

        prop = meta.getProperty(XMPConstants.ADOBE_PDF_NAMESPACE, "Producer");
        System.out.println("Producer: " + prop.getValue());
        prop = meta.getProperty(XMPConstants.ADOBE_PDF_NAMESPACE, "PDFVersion");
        System.out.println("PDF version: " + prop.getValue());
       
        DublinCoreAdapter dc = DublinCoreSchema.getAdapter(meta);
        System.out.println("Default title: " + dc.getTitle());
        System.out.println("German title: " + dc.getTitle("de"));
       
        StreamResult res = new StreamResult(System.out);
        XMPSerializer.writeXML(meta, res);
    }
View Full Code Here

Examples of org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter

    public void testParseBasics() throws Exception {
        URL url = getClass().getResource("test-basics.xmp");
        Metadata meta = XMPParser.parseXMP(url);
       
        DublinCoreAdapter dcAdapter = DublinCoreSchema.getAdapter(meta);
        XMPBasicAdapter basicAdapter = XMPBasicSchema.getAdapter(meta);
        AdobePDFAdapter pdfAdapter = AdobePDFSchema.getAdapter(meta);
       
        XMPProperty prop;
        prop = meta.getProperty(XMPConstants.DUBLIN_CORE_NAMESPACE, "creator");
        XMPArray array;
        array = prop.getArrayValue();
        assertEquals(1, array.getSize());
        assertEquals("John Doe", array.getValue(0).toString());
        assertEquals("John Doe", dcAdapter.getCreators()[0]);
              
        prop = meta.getProperty(XMPConstants.DUBLIN_CORE_NAMESPACE, "title");
        assertEquals("Example document", prop.getValue().toString());
        assertEquals("Example document", dcAdapter.getTitle());
        prop = meta.getProperty(XMPConstants.XMP_BASIC_NAMESPACE, "CreateDate");
        //System.out.println("Creation Date: " + prop.getValue() + " " + prop.getClass().getName());
        prop = meta.getProperty(XMPConstants.XMP_BASIC_NAMESPACE, "CreatorTool");
        assertEquals("An XML editor", prop.getValue().toString());
        assertEquals("An XML editor", basicAdapter.getCreatorTool());
View Full Code Here

Examples of org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter

   
    public void testParse1() throws Exception {
        URL url = getClass().getResource("unknown-schema.xmp");
        Metadata meta = XMPParser.parseXMP(url);
       
        DublinCoreAdapter dcAdapter = DublinCoreSchema.getAdapter(meta);
       
        XMPProperty prop;
        //Access through the known schema as reference
        prop = meta.getProperty(XMPConstants.DUBLIN_CORE_NAMESPACE, "title");
        assertEquals("Unknown Schema", prop.getValue().toString());
        assertEquals("Unknown Schema", dcAdapter.getTitle());
       
        //Access through a schema unknown to the XMP framework
        prop = meta.getProperty("http://unknown.org/something", "dummy");
        assertEquals("Dummy!", prop.getValue().toString());
    }
View Full Code Here

Examples of org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter

        //Important: Acrobat 7's preflight check for PDF/A-1b wants the creation date in the Info
        //object and in the XMP metadata to have the same timezone or else it shows a validation
        //error even if the times are essentially equal.

        //Dublin Core
        DublinCoreAdapter dc = DublinCoreSchema.getAdapter(meta);
        if (info.getAuthor() != null) {
            dc.addCreator(info.getAuthor());
        }
        if (info.getTitle() != null) {
            dc.setTitle(info.getTitle());
        }
        if (info.getSubject() != null) {
            //Subject maps to dc:description["x-default"] as per ISO-19005-1:2005/Cor.1:2007
            dc.setDescription(null, info.getSubject());
        }
        if (root.getLanguage() != null) {
            //Note: No check is performed to make sure the value is valid RFC 3066!
            dc.addLanguage(root.getLanguage());
        }
        dc.addDate(info.getCreationDate());

        //PDF/A identification
        PDFAMode pdfaMode = pdfDoc.getProfile().getPDFAMode();
        if (pdfaMode.isPDFA1LevelB()) {
            PDFAAdapter pdfa = PDFAXMPSchema.getAdapter(meta);
View Full Code Here

Examples of org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter

     * in PDF/A-1 (ISO 19005-1:2005)
     * @param meta the metadata
     * @param info the Info object
     */
    public static void updateInfoFromMetadata(Metadata meta, PDFInfo info) {
        DublinCoreAdapter dc = DublinCoreSchema.getAdapter(meta);
        info.setTitle(dc.getTitle());
        String[] creators = dc.getCreators();
        if (creators != null && creators.length > 0) {
            info.setAuthor(creators[0]);
        } else {
            info.setAuthor(null);
        }
       
        //dc:description["x-default"] maps to Subject as per ISO-19005-1:2005/Cor.1:2007
        info.setSubject(dc.getDescription());
       
        AdobePDFAdapter pdf = AdobePDFSchema.getAdapter(meta);
        info.setKeywords(pdf.getKeywords());
        info.setProducer(pdf.getProducer());
       
View Full Code Here

Examples of org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter

*/
public class PDFAMetadataTestCase extends TestCase {

    public void testInfoUpdate() throws Exception {
        Metadata meta = new Metadata();
        DublinCoreAdapter dc = DublinCoreSchema.getAdapter(meta);
        dc.setTitle("MyTitle");
        dc.setDescription(null, "MySubject");
        dc.addCreator("That's me");
       
        AdobePDFAdapter pdf = AdobePDFSchema.getAdapter(meta);
        pdf.setKeywords("XSL-FO XML");
        pdf.setProducer("SuperFOP");
       
View Full Code Here

Examples of org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter

        cal2.set(Calendar.MILLISECOND, 0);
        info.setModDate(cal2.getTime());
       
        Metadata meta = PDFMetadata.createXMPFromPDFDocument(doc);
       
        DublinCoreAdapter dc = DublinCoreSchema.getAdapter(meta);
        assertEquals("MyTitle", dc.getTitle());
        assertEquals("MySubject", dc.getDescription());
        assertEquals(1, dc.getCreators().length);
        assertEquals("That's me", dc.getCreators()[0]);
        AdobePDFAdapter pdf = AdobePDFSchema.getAdapter(meta);
        assertEquals("XSL-FO XML", pdf.getKeywords());
        assertEquals("SuperFOP", pdf.getProducer());
        XMPBasicAdapter xmp = XMPBasicSchema.getAdapter(meta);
        assertEquals("WonderFOP", xmp.getCreatorTool());
View Full Code Here

Examples of org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter

        assertNull(dc.getContributors());
    }

    public void testPropertyRemovalLangAlt() throws Exception {
        Metadata xmp = new Metadata();
        DublinCoreAdapter dc = DublinCoreSchema.getAdapter(xmp);

        //dc:title is a "Lang Alt"
        dc.setTitle("en", "The title");
        String title = dc.removeTitle("en");
        assertEquals("The title", title);
        dc.setTitle("en", "The title");
        dc.setTitle("de", "Der Titel");
        title = dc.removeTitle("en");
        assertEquals("The title", title);
        title = dc.removeTitle("en");
        assertNull(title);

        title = dc.removeTitle("de");
        assertEquals("Der Titel", title);
        title = dc.removeTitle("de");
        assertNull(title);
    }
View Full Code Here

Examples of org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter

        assertNull(title);
    }

    public void testReplaceLangAlt() throws Exception {
        Metadata xmp = new Metadata();
        DublinCoreAdapter dc = DublinCoreSchema.getAdapter(xmp);
        dc.setTitle("Default title");
        StringWriter writer = new StringWriter();
        XMPSerializer.writeXML(xmp, new StreamResult(writer));
        String xmpString = writer.toString();
        xmp = XMPParser.parseXMP(new StreamSource(new java.io.StringReader(xmpString)));
        dc = DublinCoreSchema.getAdapter(xmp);
        assertEquals("Default title", dc.getTitle());
        dc.setTitle("Updated title");
        XMPProperty prop = xmp.getProperty(new QName(DublinCoreSchema.NAMESPACE, "title"));
        XMPArray array = prop.getArrayValue();
        assertNotNull(array);
        //Check that only one title is present. There used to be a bug that didn't set the
        //non-qualified value equal to the value qualified with "x-default".
View Full Code Here

Examples of org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter

        assertEquals("Updated title", array.getValue(0));
    }

    public void testPropertyValues() throws Exception {
        Metadata xmp = new Metadata();
        DublinCoreAdapter dc = DublinCoreSchema.getAdapter(xmp);

        String format = dc.getFormat();
        assertNull(format);

        dc.setFormat("application/pdf");
        format = dc.getFormat();
        assertEquals("application/pdf", format);

        dc.setFormat("image/jpeg");
        format = dc.getFormat();
        assertEquals("image/jpeg", format);

        dc.setFormat(null);
        format = dc.getFormat();
        assertNull(format);

        dc.setFormat(""); //Empty string same as null value
        format = dc.getFormat();
        assertNull(format);

        dc.setTitle("title");
        String title = dc.getTitle();
        assertEquals("title", title);

        dc.setTitle("Titel");
        title = dc.getTitle();
        assertEquals("Titel", title);

        dc.setTitle(null);
        title = dc.getTitle();
        assertNull(title);

        dc.setTitle("");
        title = dc.getTitle();
        assertNull(title);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.