Examples of XMPMetadata


Examples of org.jempbox.xmp.XMPMetadata

  public void testSetRemoveGetSequenceDateListString() {
    // We don't use this...
  }

  public void testGetAllProperties() throws IOException {
    XMPMetadata xmp = new XMPMetadata();
    XMPSchemaBibtex bibtex = new XMPSchemaBibtex(xmp);

    bibtex.setTextProperty("title", "BlaBla Ta Ta\nHello World");
    bibtex.setTextProperty("abstract", "BlaBla Ta Ta\nHello World");
    bibtex.setTextProperty("review", "BlaBla Ta Ta\nHello World");
View Full Code Here

Examples of org.jempbox.xmp.XMPMetadata

    assertEquals("Mickey Mouse and James Bond", s.get("author"));
  }

  public void testSetBibtexEntry() throws IOException {

    XMPMetadata xmp = new XMPMetadata();
    XMPSchemaBibtex bibtex = new XMPSchemaBibtex(xmp);

    BibtexEntry e = FileBasedTestCase.getBibtexEntry();
    bibtex.setBibtexEntry(e, null);
View Full Code Here

Examples of org.jempbox.xmp.XMPMetadata

      if (metaRaw == null) {
        fail();
        return;
      }

      XMPMetadata meta = new XMPMetadata(XMLUtil.parse(metaRaw
          .createInputStream()));
      meta.addXMLNSMapping(XMPSchemaBibtex.NAMESPACE,
          XMPSchemaBibtex.class);

      // Check Dublin Core
      List<XMPSchema> schemas = meta
          .getSchemasByNamespaceURI("http://purl.org/dc/elements/1.1/");
      assertEquals(1, schemas.size());

      XMPSchemaDublinCore dcSchema = (XMPSchemaDublinCore) schemas
          .iterator().next();
View Full Code Here

Examples of org.jempbox.xmp.XMPMetadata

      if (metaRaw == null) {
        fail();
      }

      XMPMetadata meta = new XMPMetadata(XMLUtil.parse(metaRaw
          .createInputStream()));
      meta.addXMLNSMapping(XMPSchemaBibtex.NAMESPACE,
          XMPSchemaBibtex.class);

      // Check Dublin Core
      List<XMPSchema> schemas = meta
          .getSchemasByNamespaceURI("http://purl.org/dc/elements/1.1/");

      assertEquals(1, schemas.size());

      XMPSchemaDublinCore dcSchema = (XMPSchemaDublinCore) schemas
View Full Code Here

Examples of org.jempbox.xmp.XMPMetadata

    BibtexEntry e = (BibtexEntry) c.iterator().next();

    XMPUtil.writeXMP(pdfFile, e, null);

    XMPMetadata metadata = XMPUtil.readRawXMP(pdfFile);

    List<XMPSchema> schemas = metadata.getSchemas();
    assertEquals(2, schemas.size());
    schemas = metadata.getSchemasByNamespaceURI(XMPSchemaBibtex.NAMESPACE);
    assertEquals(1, schemas.size());
    XMPSchemaBibtex bib = (XMPSchemaBibtex) schemas.get(0);

    List<String> authors = bib.getSequenceList("author");
    assertEquals(4, authors.size());
View Full Code Here

Examples of org.jempbox.xmp.XMPMetadata

        if (metaRaw == null) {
          fail();
        }

        XMPMetadata meta = new XMPMetadata(XMLUtil.parse(metaRaw
            .createInputStream()));
        meta.addXMLNSMapping(XMPSchemaBibtex.NAMESPACE,
            XMPSchemaBibtex.class);

        List<XMPSchema> schemas = meta
            .getSchemasByNamespaceURI("http://purl.org/dc/elements/1.1/");

        assertEquals(1, schemas.size());

        XMPSchemaDublinCore dcSchema = (XMPSchemaDublinCore) schemas
View Full Code Here

Examples of org.jempbox.xmp.XMPMetadata

              "Error: Cannot read metadata from encrypted document.");
        }
        PDDocumentCatalog catalog = document.getDocumentCatalog();
        PDMetadata metaRaw = catalog.getMetadata();

        XMPMetadata meta;
        if (metaRaw != null) {
          meta = new XMPMetadata(XMLUtil.parse(metaRaw
              .createInputStream()));
        } else {
          meta = new XMPMetadata();
        }
        meta.addXMLNSMapping(XMPSchemaBibtex.NAMESPACE,
            XMPSchemaBibtex.class);

        List<XMPSchema> schemas = meta.getSchemas();

        assertEquals(4, schemas.size());

        schemas = meta
            .getSchemasByNamespaceURI(XMPSchemaBibtex.NAMESPACE);
        assertEquals(1, schemas.size());

        schemas = meta
            .getSchemasByNamespaceURI(XMPSchemaDublinCore.NAMESPACE);
        assertEquals(1, schemas.size());
        XMPSchemaDublinCore dc = (XMPSchemaDublinCore) schemas.get(0);
        assertEquals("application/pdf", dc.getFormat());

        schemas = meta
            .getSchemasByNamespaceURI(XMPSchemaBasic.NAMESPACE);
        assertEquals(1, schemas.size());
        XMPSchemaBasic bs = (XMPSchemaBasic) schemas.get(0);
        assertEquals("Acrobat PDFMaker 7.0.7", bs.getCreatorTool());

        Calendar c = Calendar.getInstance();
        c.clear();
        c.set(Calendar.YEAR, 2006);
        c.set(Calendar.MONTH, Calendar.AUGUST);
        c.set(Calendar.DATE, 7);
        c.set(Calendar.HOUR, 14);
        c.set(Calendar.MINUTE, 44);
        c.set(Calendar.SECOND, 24);
        c.setTimeZone(TimeZone.getTimeZone("GMT+2"));

        Calendar other = bs.getCreateDate();

        assertEquals(c.get(Calendar.YEAR), other.get(Calendar.YEAR));
        assertEquals(c.get(Calendar.MONTH), other.get(Calendar.MONTH));
        assertEquals(c.get(Calendar.DATE), other.get(Calendar.DATE));
        assertEquals(c.get(Calendar.HOUR), other.get(Calendar.HOUR));
        assertEquals(c.get(Calendar.MINUTE), other.get(Calendar.MINUTE));
        assertEquals(c.get(Calendar.SECOND), other.get(Calendar.SECOND));
        assertTrue(c.getTimeZone().hasSameRules(other.getTimeZone()));

        schemas = meta
            .getSchemasByNamespaceURI(XMPSchemaMediaManagement.NAMESPACE);
        assertEquals(1, schemas.size());
        XMPSchemaMediaManagement mm = (XMPSchemaMediaManagement) schemas
            .get(0);
        assertEquals("17", mm.getSequenceList("xapMM:VersionID").get(0));

      } finally {
        if (document != null) {
          document.close();
        }
      }
    }

    { // Now alter the Bibtex entry, write it and do all the checks again
      BibtexEntry toSet = t1BibtexEntry();
      toSet.setField("author", "Pokemon!");

      XMPUtil.writeXMP(pdfFile, toSet, null);

      List l = XMPUtil.readXMP(pdfFile.getAbsoluteFile());
      assertEquals(1, l.size());
      BibtexEntry e = (BibtexEntry) l.get(0);

      assertEquals(toSet, e);

      // This is what we really want to test: Is the rest of the
      // descriptions still there?

      PDDocument document = null;
      try {
        document = PDDocument.load(pdfFile.getAbsoluteFile());
        if (document.isEncrypted()) {
          throw new IOException(
              "Error: Cannot read metadata from encrypted document.");
        }
        PDDocumentCatalog catalog = document.getDocumentCatalog();
        PDMetadata metaRaw = catalog.getMetadata();

        XMPMetadata meta;
        if (metaRaw != null) {
          meta = new XMPMetadata(XMLUtil.parse(metaRaw
              .createInputStream()));
        } else {
          meta = new XMPMetadata();
        }
        meta.addXMLNSMapping(XMPSchemaBibtex.NAMESPACE,
            XMPSchemaBibtex.class);

        List schemas = meta.getSchemas();

        assertEquals(4, schemas.size());

        schemas = meta
            .getSchemasByNamespaceURI(XMPSchemaBibtex.NAMESPACE);
        assertEquals(1, schemas.size());

        schemas = meta
            .getSchemasByNamespaceURI(XMPSchemaDublinCore.NAMESPACE);
        assertEquals(1, schemas.size());
        XMPSchemaDublinCore dc = (XMPSchemaDublinCore) schemas.get(0);
        assertEquals("application/pdf", dc.getFormat());

        schemas = meta
            .getSchemasByNamespaceURI(XMPSchemaBasic.NAMESPACE);
        assertEquals(1, schemas.size());
        XMPSchemaBasic bs = (XMPSchemaBasic) schemas.get(0);
        assertEquals("Acrobat PDFMaker 7.0.7", bs.getCreatorTool());

        Calendar c = Calendar.getInstance();
        c.clear();
        c.set(Calendar.YEAR, 2006);
        c.set(Calendar.MONTH, 7);
        c.set(Calendar.DATE, 7);
        c.set(Calendar.HOUR, 14);
        c.set(Calendar.MINUTE, 44);
        c.set(Calendar.SECOND, 24);
        c.setTimeZone(TimeZone.getTimeZone("GMT+2"));

        Calendar other = bs.getCreateDate();

        assertEquals(c.get(Calendar.YEAR), other.get(Calendar.YEAR));
        assertEquals(c.get(Calendar.MONTH), other.get(Calendar.MONTH));
        assertEquals(c.get(Calendar.DATE), other.get(Calendar.DATE));
        assertEquals(c.get(Calendar.HOUR), other.get(Calendar.HOUR));
        assertEquals(c.get(Calendar.MINUTE), other.get(Calendar.MINUTE));
        assertEquals(c.get(Calendar.SECOND), other.get(Calendar.SECOND));
        assertTrue(c.getTimeZone().hasSameRules(other.getTimeZone()));

        schemas = meta
            .getSchemasByNamespaceURI(XMPSchemaMediaManagement.NAMESPACE);
        assertEquals(1, schemas.size());
        XMPSchemaMediaManagement mm = (XMPSchemaMediaManagement) schemas
            .get(0);
        assertEquals("17", mm.getSequenceList("xapMM:VersionID").get(0));
View Full Code Here

Examples of org.jempbox.xmp.XMPMetadata

      if (document.isEncrypted()) {
        throw new EncryptionNotSupportedException(
            "Error: Cannot read metadata from encrypted document.");
      }

      XMPMetadata meta = getXMPMetadata(document);

      // If we did not find any XMP metadata, search for non XMP metadata
      if (meta != null) {

              List<XMPSchema> schemas = meta
                  .getSchemasByNamespaceURI(XMPSchemaBibtex.NAMESPACE);
       
              Iterator<XMPSchema> it = schemas.iterator();
              while (it.hasNext()) {
                XMPSchemaBibtex bib = (XMPSchemaBibtex) it.next();
       
                result.add(bib.getBibtexEntry());
              }
       
              // If we did not find anything have a look if a Dublin Core exists
              if (result.size() == 0) {
                schemas = meta
                    .getSchemasByNamespaceURI(XMPSchemaDublinCore.NAMESPACE);
                it = schemas.iterator();
                while (it.hasNext()) {
                  XMPSchemaDublinCore dc = (XMPSchemaDublinCore) it.next();
       
View Full Code Here

Examples of org.jempbox.xmp.XMPMetadata

      throws IOException, TransformerException {

    if (database != null)
      bibtexEntries = database.resolveForStrings(bibtexEntries, true);

    XMPMetadata x = new XMPMetadata();

    Iterator<BibtexEntry> it = bibtexEntries.iterator();
    while (it.hasNext()) {
      BibtexEntry e = it.next();
      XMPSchemaBibtex schema = new XMPSchemaBibtex(x);
      x.addSchema(schema);
      schema.setBibtexEntry(e);
    }

    x.save(outputStream);
  }
View Full Code Here

Examples of org.jempbox.xmp.XMPMetadata

    if (metaRaw == null) {
      return null;
    }

    XMPMetadata meta = new XMPMetadata(XMLUtil.parse(metaRaw
        .createInputStream()));
    meta.addXMLNSMapping(XMPSchemaBibtex.NAMESPACE, XMPSchemaBibtex.class);
    return meta;
  }
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.