Examples of PackagePropertiesPart


Examples of org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart

          .addContentType(PackagingURIHelper
              .createPartName("/default.xml"),
              ContentTypes.PLAIN_OLD_XML);

      // Init some PackageBase properties
      pkg.packageProperties = new PackagePropertiesPart(pkg,
          PackagingURIHelper.CORE_PROPERTIES_PART_NAME);
      pkg.packageProperties.setCreatorProperty("Generated by OpenXML4J");
      pkg.packageProperties.setCreatedProperty(new Nullable<Date>(
          new Date()));
    } catch (InvalidFormatException e) {
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart

  public PackageProperties getPackageProperties()
      throws InvalidFormatException {
    this.throwExceptionIfWriteOnly();
    // If no properties part has been found then we create one
    if (this.packageProperties == null) {
      this.packageProperties = new PackagePropertiesPart(this,
          PackagingURIHelper.CORE_PROPERTIES_PART_NAME);
    }
    return this.packageProperties;
  }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart

          .addContentType(PackagingURIHelper
              .createPartName("/default.xml"),
              ContentTypes.PLAIN_OLD_XML);

      // Init some PackageBase properties
      pkg.packageProperties = new PackagePropertiesPart(pkg,
          PackagingURIHelper.CORE_PROPERTIES_PART_NAME);
      pkg.packageProperties.setCreatorProperty("Generated by OpenXML4J");
      pkg.packageProperties.setCreatedProperty(new Nullable<Date>(
          new Date()));
    } catch (InvalidFormatException e) {
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart

  public PackageProperties getPackageProperties()
      throws InvalidFormatException {
    this.throwExceptionIfWriteOnly();
    // If no properties part has been found then we create one
    if (this.packageProperties == null) {
      this.packageProperties = new PackagePropertiesPart(this,
          PackagingURIHelper.CORE_PROPERTIES_PART_NAME);
    }
    return this.packageProperties;
  }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart

  // TODO Load element with XMLBeans or dynamic table
  // TODO Check every element/namespace for compliance
  public PackagePart unmarshall(UnmarshallContext context, InputStream in)
      throws InvalidFormatException, IOException {
    PackagePropertiesPart coreProps = new PackagePropertiesPart(context
        .getPackage(), context.getPartName());

    // If the input stream is null then we try to get it from the
    // package.
    if (in == null) {
      if (context.getZipEntry() != null) {
        in = ((ZipPackage) context.getPackage()).getZipArchive()
            .getInputStream(context.getZipEntry());
      } else if (context.getPackage() != null) {
        // Try to retrieve the part inputstream from the URI
        ZipEntry zipEntry;
        try {
          zipEntry = ZipHelper
              .getCorePropertiesZipEntry((ZipPackage) context
                  .getPackage());
        } catch (OpenXML4JException e) {
          throw new IOException(
              "Error while trying to get the part input stream.");
        }
        in = ((ZipPackage) context.getPackage()).getZipArchive()
            .getInputStream(zipEntry);
      } else
        throw new IOException(
            "Error while trying to get the part input stream.");
    }

    SAXReader xmlReader = new SAXReader();
    Document xmlDoc;
    try {
      xmlDoc = xmlReader.read(in);

      /* Check OPC compliance */

      // Rule M4.2, M4.3, M4.4 and M4.5/
      checkElementForOPCCompliance(xmlDoc.getRootElement());

      /* End OPC compliance */

    } catch (DocumentException e) {
      throw new IOException(e.getMessage());
    }

    coreProps.setCategoryProperty(loadCategory(xmlDoc));
    coreProps.setContentStatusProperty(loadContentStatus(xmlDoc));
    coreProps.setContentTypeProperty(loadContentType(xmlDoc));
    coreProps.setCreatedProperty(loadCreated(xmlDoc));
    coreProps.setCreatorProperty(loadCreator(xmlDoc));
    coreProps.setDescriptionProperty(loadDescription(xmlDoc));
    coreProps.setIdentifierProperty(loadIdentifier(xmlDoc));
    coreProps.setKeywordsProperty(loadKeywords(xmlDoc));
    coreProps.setLanguageProperty(loadLanguage(xmlDoc));
    coreProps.setLastModifiedByProperty(loadLastModifiedBy(xmlDoc));
    coreProps.setLastPrintedProperty(loadLastPrinted(xmlDoc));
    coreProps.setModifiedProperty(loadModified(xmlDoc));
    coreProps.setRevisionProperty(loadRevision(xmlDoc));
    coreProps.setSubjectProperty(loadSubject(xmlDoc));
    coreProps.setTitleProperty(loadTitle(xmlDoc));
    coreProps.setVersionProperty(loadVersion(xmlDoc));

    return coreProps;
  }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart

          .addContentType(PackagingURIHelper
              .createPartName("/default.xml"),
              ContentTypes.PLAIN_OLD_XML);

      // Init some PackageBase properties
      pkg.packageProperties = new PackagePropertiesPart(pkg,
          PackagingURIHelper.CORE_PROPERTIES_PART_NAME);
      pkg.packageProperties.setCreatorProperty("Generated by OpenXML4J");
      pkg.packageProperties.setCreatedProperty(new Nullable<Date>(
          new Date()));
    } catch (InvalidFormatException e) {
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart

  public PackageProperties getPackageProperties()
      throws InvalidFormatException {
    this.throwExceptionIfWriteOnly();
    // If no properties part has been found then we create one
    if (this.packageProperties == null) {
      this.packageProperties = new PackagePropertiesPart(this,
          PackagingURIHelper.CORE_PROPERTIES_PART_NAME);
    }
    return this.packageProperties;
  }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart

  // TODO Load element with XMLBeans or dynamic table
  // TODO Check every element/namespace for compliance
  public PackagePart unmarshall(UnmarshallContext context, InputStream in)
      throws InvalidFormatException, IOException {
    PackagePropertiesPart coreProps = new PackagePropertiesPart(context
        .getPackage(), context.getPartName());

    // If the input stream is null then we try to get it from the
    // package.
    if (in == null) {
      if (context.getZipEntry() != null) {
        in = ((ZipPackage) context.getPackage()).getZipArchive()
            .getInputStream(context.getZipEntry());
      } else if (context.getPackage() != null) {
        // Try to retrieve the part inputstream from the URI
        ZipEntry zipEntry;
        try {
          zipEntry = ZipHelper
              .getCorePropertiesZipEntry((ZipPackage) context
                  .getPackage());
        } catch (OpenXML4JException e) {
          throw new IOException(
              "Error while trying to get the part input stream.");
        }
        in = ((ZipPackage) context.getPackage()).getZipArchive()
            .getInputStream(zipEntry);
      } else
        throw new IOException(
            "Error while trying to get the part input stream.");
    }

    SAXReader xmlReader = new SAXReader();
    Document xmlDoc;
    try {
      xmlDoc = xmlReader.read(in);

      /* Check OPC compliance */

      // Rule M4.2, M4.3, M4.4 and M4.5/
      checkElementForOPCCompliance(xmlDoc.getRootElement());

      /* End OPC compliance */

    } catch (DocumentException e) {
      throw new IOException(e.getMessage());
    }

    coreProps.setCategoryProperty(loadCategory(xmlDoc));
    coreProps.setContentStatusProperty(loadContentStatus(xmlDoc));
    coreProps.setContentTypeProperty(loadContentType(xmlDoc));
    coreProps.setCreatedProperty(loadCreated(xmlDoc));
    coreProps.setCreatorProperty(loadCreator(xmlDoc));
    coreProps.setDescriptionProperty(loadDescription(xmlDoc));
    coreProps.setIdentifierProperty(loadIdentifier(xmlDoc));
    coreProps.setKeywordsProperty(loadKeywords(xmlDoc));
    coreProps.setLanguageProperty(loadLanguage(xmlDoc));
    coreProps.setLastModifiedByProperty(loadLastModifiedBy(xmlDoc));
    coreProps.setLastPrintedProperty(loadLastPrinted(xmlDoc));
    coreProps.setModifiedProperty(loadModified(xmlDoc));
    coreProps.setRevisionProperty(loadRevision(xmlDoc));
    coreProps.setSubjectProperty(loadSubject(xmlDoc));
    coreProps.setTitleProperty(loadTitle(xmlDoc));
    coreProps.setVersionProperty(loadVersion(xmlDoc));

    return coreProps;
  }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart

        extractMetadata(extractor.getCoreProperties(), metadata);
        extractMetadata(extractor.getExtendedProperties(), metadata);
    }

    private void extractMetadata(CoreProperties properties, Metadata metadata) {
        PackagePropertiesPart propsHolder = properties
                .getUnderlyingProperties();

        addProperty(metadata, Metadata.CATEGORY, propsHolder.getCategoryProperty());
        addProperty(metadata, Metadata.CONTENT_STATUS, propsHolder
                .getContentStatusProperty());
        addProperty(metadata, Metadata.DATE, propsHolder
                .getCreatedPropertyString());
        addProperty(metadata, Metadata.CREATOR, propsHolder
                .getCreatorProperty());
        addProperty(metadata, Metadata.AUTHOR, propsHolder
                .getCreatorProperty());
        addProperty(metadata, Metadata.DESCRIPTION, propsHolder
                .getDescriptionProperty());
        addProperty(metadata, Metadata.IDENTIFIER, propsHolder
                .getIdentifierProperty());
        addProperty(metadata, Metadata.KEYWORDS, propsHolder
                .getKeywordsProperty());
        addProperty(metadata, Metadata.LANGUAGE, propsHolder
                .getLanguageProperty());
        addProperty(metadata, Metadata.LAST_AUTHOR, propsHolder
                .getLastModifiedByProperty());
        addProperty(metadata, Metadata.LAST_PRINTED, propsHolder
                .getLastPrintedPropertyString());
        addProperty(metadata, Metadata.LAST_MODIFIED, propsHolder
                .getModifiedPropertyString());
        addProperty(metadata, Metadata.REVISION_NUMBER, propsHolder
                .getRevisionProperty());
        addProperty(metadata, Metadata.SUBJECT, propsHolder
                .getSubjectProperty());
        addProperty(metadata, Metadata.TITLE, propsHolder.getTitleProperty());
        addProperty(metadata, Metadata.VERSION, propsHolder.getVersionProperty());
    }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart

          .addContentType(PackagingURIHelper
              .createPartName("/default.xml"),
              ContentTypes.PLAIN_OLD_XML);

      // Init some PackageBase properties
      pkg.packageProperties = new PackagePropertiesPart(pkg,
          PackagingURIHelper.CORE_PROPERTIES_PART_NAME);
      pkg.packageProperties.setCreatorProperty("Generated by OpenXML4J");
      pkg.packageProperties.setCreatedProperty(new Nullable<Date>(
          new Date()));
    } catch (InvalidFormatException e) {
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.