Search in sources :

Example 1 with POIXMLProperties

use of org.apache.poi.ooxml.POIXMLProperties in project ecms by exoplatform.

the class ApachePOIMetadataPlugin method updateMetadata.

/**
 * {@inheritDoc}
 */
@Override
public InputStream updateMetadata(String extension, InputStream source, Date created, String creator, String language) throws IOException, DocumentExtensionNotSupportedException {
    File tempFile = File.createTempFile("editor-document", ".tmp");
    try (POIXMLDocument document = getDocument(source, extension);
        FileOutputStream fos = new FileOutputStream(tempFile)) {
        updateDocLanguage(document, extension, language);
        POIXMLProperties props = document.getProperties();
        POIXMLProperties.CoreProperties coreProps = props.getCoreProperties();
        coreProps.setCreator(creator);
        coreProps.getUnderlyingProperties().setLanguageProperty(language);
        coreProps.setCreated(metadataFormat.format(created));
        document.write(fos);
    }
    return new DeleteOnCloseFileInputStream(tempFile);
}
Also used : FileOutputStream(java.io.FileOutputStream) POIXMLProperties(org.apache.poi.ooxml.POIXMLProperties) POIXMLDocument(org.apache.poi.ooxml.POIXMLDocument) File(java.io.File)

Aggregations

File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 POIXMLDocument (org.apache.poi.ooxml.POIXMLDocument)1 POIXMLProperties (org.apache.poi.ooxml.POIXMLProperties)1